fumadocs-ui
Version:
The Radix UI version of Fumadocs UI
64 lines • 1.97 kB
TypeScript
import { DefaultSearchDialogProps } from "../components/dialog/search-default.js";
import { ComponentType, ReactNode } from "react";
//#region src/contexts/search.d.ts
interface HotKey {
display: ReactNode;
/**
* Key code or a function determining whether the key is pressed.
*/
key: string | ((e: KeyboardEvent) => boolean);
}
interface SharedProps {
open: boolean;
onOpenChange: (open: boolean) => void;
}
type SearchLink = [name: string, href: string];
interface TagItem {
name: string;
value: string;
}
interface SearchProviderProps<DialogProps extends SharedProps = DefaultSearchDialogProps> {
/**
* Preload search dialog before opening it
*
* @defaultValue `true`
*/
preload?: boolean;
/**
* Custom links to be displayed if search is empty
*/
links?: SearchLink[];
/**
* Hotkeys for triggering search dialog
*
* @defaultValue Meta/Ctrl + K
*/
hotKey?: HotKey[];
/**
* Replace default search dialog, allowing you to use other solutions such as Algolia Search
*
* It receives the `open` and `onOpenChange` prop, can be lazy loaded with `React.lazy()`
*/
SearchDialog?: ComponentType<DialogProps>;
/**
* Additional props to the dialog
*/
options?: Partial<DialogProps>;
children?: ReactNode;
}
interface SearchContextType {
enabled: boolean;
open: boolean;
hotKey: HotKey[];
setOpenSearch: (value: boolean) => void;
}
declare function useSearchContext(): SearchContextType;
declare function SearchProvider<DialogProps extends SharedProps = DefaultSearchDialogProps>({ SearchDialog, children, preload, options, hotKey, links }: SearchProviderProps<DialogProps>): import("react").JSX.Element;
/**
* Show children only when search is enabled via React Context
*/
declare function SearchOnly({ children }: {
children: ReactNode;
}): ReactNode;
//#endregion
export { SearchLink, SearchOnly, SearchProvider, SearchProviderProps, SharedProps, TagItem, useSearchContext };