import * as React from "react"; export type CommandPaletteItem = { id: string; label: React.ReactNode; searchValue?: string; meta?: React.ReactNode; disabled?: boolean; }; export type CommandPaletteGroup = { id: string; label: React.ReactNode; items: CommandPaletteItem[]; }; export type CommandPaletteLabels = { open: string; title: string; description: string; placeholder: string; empty: React.ReactNode; loading?: React.ReactNode; move?: React.ReactNode; select?: React.ReactNode; close?: React.ReactNode; }; export type CommandPaletteProps = { groups: CommandPaletteGroup[]; labels: CommandPaletteLabels; onSelect: (item: CommandPaletteItem) => void; open?: boolean; defaultOpen?: boolean; onOpenChange?: (open: boolean) => void; /** * Controlled search-box query. Pairs with `onSearchChange`; leave it out for the uncontrolled * palette (seeded by `defaultSearch`). */ search?: string; /** Initial uncontrolled query, and the value the palette resets to when it closes. Default `""`. */ defaultSearch?: string; /** * Fires on every keystroke with the current query — the seam a server-backed group needs to run * search-as-you-type. Also fires with `defaultSearch` when the palette closes. */ onSearchChange?: (query: string) => void; /** * Whether the palette filters `groups` itself (cmdk's client-side fuzzy match). Set `false` when * the QUERY is answered by a server and `groups` already holds the matches — otherwise every row * is scored a second time against the same string and late-arriving matches are dropped. */ shouldFilter?: boolean; loading?: boolean; error?: React.ReactNode; /** * The control that opens the palette. * * `undefined` (omitted) — the default outline Button with the ⌘K hint. * `null` — **NO trigger at all**, for a palette driven purely by `shortcut`. * * The two are deliberately NOT the same, and that is the whole point of gh#778: the previous * `trigger ?? ` collapsed them, so `null` — the spelling every consumer reaches for — * silently rendered the very Button it was asked to remove. The only working spelling was * `trigger={<>}`, which is a hack that renders an empty fragment into the trigger slot. * * A keyboard-only palette is a NORMAL shape: `shortcut` already binds ⌘K/Ctrl+K and handles * `event.isComposing` (i.e. every keystroke of a Japanese IME) and focus restore, so it is a * better handler than a consumer's own. A topbar with no width to spare should be able to say so. */ trigger?: React.ReactNode; shortcut?: boolean; }; /** * Unchanged. - **`shouldFilter={false}` (server-side)** — the PALETTE owns it, derived * synchronously from props: the empty node renders when `groups` carries no items, and never while * `loading` or `error` is set. cmdk's own empty node cannot be trusted here, because it is driven * by a scheduled count of the items that have REGISTERED in the DOM, not by what the consumer * knows — so an async group that populates a frame late flips it on and off and any assertion over * it races. Reading `groups` instead makes "did we render the empty state?" a pure function of the * props at that render, which is what a contract test can assert. */ export declare function CommandPalette({ groups, labels, onSelect, open: controlledOpen, defaultOpen, onOpenChange, search: controlledSearch, defaultSearch, onSearchChange, shouldFilter, loading, error, trigger, shortcut, }: CommandPaletteProps): React.JSX.Element;