import type { UseTRPCQueryResult } from "@trpc/react-query/shared"; import type { stringOrTranslation } from "@homarr/translation"; import type { inferSearchInteractionDefinition, inferSearchInteractionOptions, SearchInteraction } from "./interaction"; type CommonSearchGroup, TOptionProps extends Record> = { // key path is used to define the path to a unique key in the option object keyPath: keyof TOption; title: stringOrTranslation; Component: (option: TOption) => JSX.Element; useInteraction: (option: TOption, query: string) => inferSearchInteractionDefinition; onKeyDown?: ( event: KeyboardEvent, options: TOption[], query: string, actions: { setChildrenOptions: (options: inferSearchInteractionOptions<"children">) => void; }, ) => void; } & TOptionProps; // eslint-disable-next-line @typescript-eslint/no-explicit-any export type SearchGroup = any> = | CommonSearchGroup boolean; options: TOption[] }> | CommonSearchGroup< TOption, { filter: (query: string, option: TOption) => boolean; sort?: (query: string, options: [TOption, TOption]) => number; useOptions: () => TOption[]; } > | CommonSearchGroup UseTRPCQueryResult }>; export const createGroup = >(group: SearchGroup) => group;