Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

961 B
Raw Blame
import type { JSX, ReactNode } from "react";

import type { inferSearchInteractionDefinition } from "./interaction";

export interface CreateChildrenOptionsProps<TParentOptions extends Record<string, unknown>> {
  DetailComponent: ({ options }: { options: TParentOptions }) => ReactNode;
  useActions: (options: TParentOptions, query: string) => ChildrenAction<TParentOptions>[];
}

export interface ChildrenAction<TParentOptions extends Record<string, unknown>> {
  key: string;
  Component: (option: TParentOptions) => JSX.Element;
  useInteraction: (
    option: TParentOptions,
    query: string,
  ) => inferSearchInteractionDefinition<"link" | "javaScript" | "children">;
  hide?: boolean | ((option: TParentOptions) => boolean);
}

export const createChildrenOptions = <TParentOptions extends Record<string, unknown>>(
  props: CreateChildrenOptionsProps<TParentOptions>,
) => {
  return (option: TParentOptions) => ({
    option,
    ...props,
  });
};