{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "casework-command-palette",
  "title": "Casework jump palette",
  "description": "A dialog holding one combobox that jumps to a work item, queue or page by typing, with every label taken from Casework content.",
  "dependencies": [
    "@base-ui/react@1.8.0"
  ],
  "registryDependencies": [
    "@registrystack/casework-content",
    "@registrystack/ui-combobox",
    "@registrystack/ui-dialog"
  ],
  "files": [
    {
      "path": "casework/command-palette.tsx",
      "content": "import { useState } from \"react\";\nimport { Combobox as ComboboxPrimitive } from \"@base-ui/react\";\nimport { Dialog as DialogPrimitive } from \"@base-ui/react/dialog\";\nimport { DialogOverlay, DialogPortal } from \"@/components/ui/dialog\";\nimport {\n  ComboboxEmpty,\n  ComboboxInput,\n  ComboboxItem,\n  ComboboxList,\n} from \"@/components/ui/combobox\";\nimport { useCaseworkContent } from \"@/blocks/casework/casework-content\";\n\n/** A place the palette can jump to. */\nexport interface Place {\n  path: string;\n  label: string;\n}\n\n/**\n * The jump palette: a dialog holding one combobox whose list is rendered\n * inline, so the officer types a place's name and presses Enter. The\n * combobox's open state is the dialog's, as Base UI asks for this\n * composition, so closing either closes both.\n */\nexport function CommandPalette({\n  open,\n  onOpenChange,\n  places,\n  navigate,\n}: {\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  places: Place[];\n  /** Where picking a place goes. The palette assumes no router of its own. */\n  navigate: (path: string) => void;\n}) {\n  const c = useCaseworkContent();\n  const [query, setQuery] = useState(\"\");\n  const close = () => {\n    setQuery(\"\");\n    onOpenChange(false);\n  };\n  return (\n    <ComboboxPrimitive.Root\n      items={places}\n      inline\n      open={open}\n      onOpenChange={(next) => (next ? onOpenChange(true) : close())}\n      value={null}\n      onValueChange={(place: Place | null) => {\n        if (!place) return;\n        close();\n        navigate(place.path);\n      }}\n      inputValue={query}\n      onInputValueChange={setQuery}\n      itemToStringLabel={(place: Place) => place.label}\n      autoHighlight\n      modal={false}\n    >\n      <DialogPrimitive.Root\n        open={open}\n        onOpenChange={(next) => !next && close()}\n      >\n        <DialogPortal>\n          <DialogOverlay />\n          <DialogPrimitive.Popup\n            className=\"command-palette\"\n            aria-label={c.goTo}\n          >\n            <ComboboxInput\n              placeholder={c.goToPlaceholder}\n              showTrigger={false}\n              autoFocus\n              aria-label={c.goTo}\n            />\n            <ComboboxEmpty>{c.noMatchingPlace}</ComboboxEmpty>\n            <ComboboxList aria-label={c.goToList}>\n              {(place: Place) => (\n                <ComboboxItem key={place.path} value={place}>\n                  {place.label}\n                </ComboboxItem>\n              )}\n            </ComboboxList>\n          </DialogPrimitive.Popup>\n        </DialogPortal>\n      </DialogPrimitive.Root>\n    </ComboboxPrimitive.Root>\n  );\n}\n",
      "type": "registry:block",
      "target": "@components/casework/command-palette.tsx"
    }
  ],
  "type": "registry:block"
}