import { CSSProperties } from 'react'; import { MenuEntry } from '../menu/menu.types.js'; import { Presentation } from '../configProvider/presentation.types.js'; import { SlotClassNames, SlotStyles, HtmlProps } from '../types/slots.types.js'; export type CommandPaletteSlots = 'root' | 'search' | 'input' | 'list' | 'item' | 'itemIcon' | 'itemLabel' | 'itemShortcut' | 'heading' | 'separator' | 'empty'; export interface CommandPaletteLabels { /** Accessible name of the dialog and the search field. Default: "Search commands". */ label?: string; /** Placeholder in the search field. Default: "Type a command or search…". */ placeholder?: string; /** Shown when nothing matches. Default: "No results". */ empty?: string; /** Shown while `isLoading` and nothing matches yet. Default: "Searching…". */ loading?: string; /** Announced to screen readers as the matches change. */ results?: (count: number) => string; } export interface CommandPaletteProps extends HtmlProps { /** The commands, in the same shape `Menu` takes. Headings group them; separators split groups. */ items: MenuEntry[]; isOpen: boolean; onClose: () => void; /** Called with the id of the command that was run, after its own `onClick`. */ onAction?: (id: string) => void; /** Called on every keystroke, and with `''` each time the palette opens. */ onQueryChange?: (query: string) => void; /** * Filter `items` by the query. Default `true`. Set `false` when `items` are already the results, * e.g. fetched from a server in `onQueryChange`. */ filter?: boolean; /** Shows the `loading` label instead of `empty` while nothing matches. */ isLoading?: boolean; /** Centred dialog, bottom sheet, or a sheet only on a small touch screen. */ presentation?: Presentation; /** Text this component renders of its own. */ labels?: CommandPaletteLabels; className?: string; style?: CSSProperties; classNames?: SlotClassNames; styles?: SlotStyles; }