{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "command-palette",
  "type": "registry:item",
  "title": "Command Palette",
  "description": "A search box for actions and pages, opened with ⌘K or Ctrl+K (`hotkey`). Type to filter, arrow keys to move, Enter to run, Escape to close. `items` is `[{ id, label, group?, hint?, href? }]`; an item with `href` is followed. It's a modal <dialog> with a combobox and a listbox, so screen readers hear the active item as it moves. `open` is two-way.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "navigation"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/command-palette.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/command-palette.js",
      "content": "// Generated by zubra from command-palette.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { effect, emit, id } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"command-palette\";\n\nexport default $define(tag, {\n  props: {\n    \"open\": { attribute: \"open\", default: false, required: false, model: true },\n    \"items\": { attribute: \"items\", default: [], required: false },\n    \"placeholder\": { attribute: \"placeholder\", default: \"Search actions and pages…\", required: false },\n    \"hotkey\": { attribute: \"hotkey\", default: \"k\", required: false },\n    \"label\": { attribute: \"label\", default: \"Command palette\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"openchange\", \"select\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (command-palette) to ([data-zb-slotted=\\\"command-palette\\\"]) {\\n  dialog { width: min(36rem, calc(100vw - 2rem)); margin: 12vh auto auto; padding: 0; border: 1px solid var(--border, #e4e4e7); border-radius: calc(var(--radius, 0.625rem) * 1.4); background: var(--popover, #fff); color: var(--popover-foreground, #18181b); box-shadow: 0 24px 64px #0d122040; }\\n  dialog { opacity: 0; scale: 0.97; translate: 0 -0.5rem; transition: opacity var(--duration-fast, 150ms) var(--ease-out, ease-out), scale var(--duration-fast, 150ms) var(--ease-out, ease-out), translate var(--duration-fast, 150ms) var(--ease-out, ease-out), overlay var(--duration-fast, 150ms) allow-discrete, display var(--duration-fast, 150ms) allow-discrete; }\\n  dialog[open] { opacity: 1; scale: 1; translate: 0; }\\n  @starting-style { dialog[open] { opacity: 0; scale: 0.97; translate: 0 -0.5rem; } }\\n  dialog::backdrop { background: #0d122000; transition: background-color var(--duration-fast, 150ms) var(--ease-out, ease-out), overlay var(--duration-fast, 150ms) allow-discrete, display var(--duration-fast, 150ms) allow-discrete; }\\n  dialog[open]::backdrop { background: #0d122059; }\\n  @starting-style { dialog[open]::backdrop { background: #0d122000; } }\\n  .palette-search { display: flex; align-items: center; gap: 0.6rem; padding: 0 1rem; border-bottom: 1px solid var(--border, #e4e4e7); }\\n  .palette-search svg { flex: none; color: var(--muted-foreground, #71717a); }\\n  /* The focus ring is the search row's bottom edge: an outline on the field would be cut off by the dialog. */\\n  .palette-search:focus-within { box-shadow: inset 0 -2px 0 var(--ring, #a1a1aa); }\\n  .palette-search input:focus-visible { outline: none; }\\n  input { flex: 1; min-width: 0; height: 3.25rem; border: 0; outline: 0; background: none; color: inherit; font: inherit; font-size: 1rem; }\\n  input::placeholder { color: var(--muted-foreground, #71717a); }\\n  ul { max-height: min(22rem, 55vh); overflow: auto; margin: 0; padding: 0.4rem; list-style: none; }\\n  .palette-group { padding: 0.6rem 0.6rem 0.25rem; font-size: 0.775rem; font-weight: 600; color: color-mix(in oklab, var(--muted-foreground, #71717a) 75%, var(--foreground, #18181b)); }\\n  .palette-option { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.6rem; border-radius: calc(var(--radius, 0.625rem) * 0.7); cursor: pointer; }\\n  .palette-option[aria-selected=true] { background: var(--accent, #f4f4f5); color: var(--accent-foreground, #18181b); }\\n  .palette-label { flex: 1; }\\n  kbd, .palette-hint { font: inherit; font-size: 0.8rem; color: color-mix(in oklab, var(--muted-foreground, #71717a) 75%, var(--foreground, #18181b)); }\\n  .palette-empty { padding: 1.5rem; text-align: center; color: var(--muted-foreground, #71717a); }\\n  footer { display: flex; gap: 1rem; padding: 0.55rem 1rem; border-top: 1px solid var(--border, #e4e4e7); font-size: 0.775rem; color: color-mix(in oklab, var(--muted-foreground, #71717a) 75%, var(--foreground, #18181b)); }\\n  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; animation-iteration-count: 1 !important; } }\\n}\\n}\\n\",\n  template: \"\\n  <!---->\\n  <dialog>\\n    <div class=\\\"palette-search\\\">\\n      <svg aria-hidden=\\\"true\\\" viewBox=\\\"0 0 24 24\\\" width=\\\"18\\\" height=\\\"18\\\" fill=\\\"none\\\" stroke=\\\"currentColor\\\" stroke-width=\\\"2\\\" stroke-linecap=\\\"round\\\"><circle cx=\\\"11\\\" cy=\\\"11\\\" r=\\\"7\\\"></circle><path d=\\\"m20 20-3.5-3.5\\\"></path></svg>\\n      <input type=\\\"text\\\" role=\\\"combobox\\\" aria-expanded=\\\"true\\\" aria-autocomplete=\\\"list\\\" autocomplete=\\\"off\\\" spellcheck=\\\"false\\\">\\n    </div>\\n    <ul role=\\\"listbox\\\">\\n      <!--[--><!--]-->\\n      <!--[--><!--]-->\\n    </ul>\\n    <footer aria-hidden=\\\"true\\\"><span><kbd>↑</kbd> <kbd>↓</kbd> to move</span><span><kbd>Enter</kbd> to run</span><span><kbd>Esc</kbd> to close</span></footer>\\n  </dialog>\\n\",\n  setup($p, $emit) {\n    const emit = $emit;\nfunction __zubraAssign(signal, value) { signal.set(value); return value }\nfunction __zubraUpdate(signal, delta, prefix) { const old = signal.get(); signal.set(old + delta); return prefix ? old + delta : old }\n                                                   \n\n  const listId = id()\n  const optionId = id()\n  const dialog = __zubraState(null)\n  const input = __zubraState(null)\n  const query = __zubraState(\"\")\n  const active = __zubraState(0)\n\n  const matches = __zubraComputed(() => ($p.items.filter((item) => {\n    const words = query.get().toLowerCase().split(/\\s+/).filter(Boolean)\n    const text = `${item.label} ${item.group ?? \"\"} ${item.hint ?? \"\"}`.toLowerCase()\n    return words.every((word) => text.includes(word))\n  })))\n  // Rows in order, with a group heading where the group changes.\n  const rows = __zubraComputed(() => (matches.get().map((item, index) => ({ item, index, heading: index === 0 || matches.get()[index - 1].group !== item.group ? item.group ?? \"\" : \"\" }))))\n\n  effect(() => {\n    if (!dialog.get()) return\n    if ($p.open && !dialog.get().open) { __zubraAssign(query, \"\"); __zubraAssign(active, 0); dialog.get().showModal(); input.get()?.focus() }\n    else if (!$p.open && dialog.get().open) dialog.get().close()\n  })\n  function key(event) {\n    if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n      event.preventDefault()\n      if (!matches.get().length) return\n      __zubraAssign(active, (active.get() + (event.key === \"ArrowDown\" ? 1 : -1) + matches.get().length) % matches.get().length)\n      dialog.get().querySelector(`#${optionId}-${active.get()}`)?.scrollIntoView({ block: \"nearest\" })\n    } else if (event.key === \"Enter\") {\n      event.preventDefault()\n      if (matches.get()[active.get()]) run(matches.get()[active.get()])\n    }\n  }\n  function run(item) {\n    $p.open = false\n    emit('select', item.id)\n    if (item.href) location.href = item.href\n  }\n  function shortcut(event) {\n    if ($p.hotkey && (event.metaKey || event.ctrlKey) && event.key.toLowerCase() === $p.hotkey.toLowerCase()) {\n      event.preventDefault()\n      $p.open = !$p.open\n    }\n  }\n    return [\n      { path: [0], global: \"document\", on: \"keydown\", handler: () => $r(shortcut) },\n      { path: [1], ref: () => (($el) => (__zubraAssign(dialog, $el))) },\n      { path: [1], attribute: \"aria-label\", value: () => $p.label },\n      { path: [1], on: \"close\", handler: () => (() => ($p.open = false)) },\n      { path: [1], on: \"click\", handler: () => (() => ($p.open = false)), modifiers: { self: true } },\n      { path: [1, 0, 1], ref: () => (($el) => (__zubraAssign(input, $el))) },\n      { path: [1, 0, 1], attribute: \"aria-controls\", value: () => $r(listId) },\n      { path: [1, 0, 1], attribute: \"aria-activedescendant\", value: () => (matches.get().length ? `${optionId}-${active.get()}` : null) },\n      { path: [1, 0, 1], attribute: \"placeholder\", value: () => $p.placeholder },\n      { path: [1, 0, 1], attribute: \"value\", value: () => $r(query) },\n      { path: [1, 0, 1], on: \"input\", handler: () => ((event) => { __zubraAssign(query, event.target.value); __zubraAssign(active, 0) }) },\n      { path: [1, 0, 1], on: \"keydown\", handler: () => $r(key) },\n      { path: [1, 1], attribute: \"id\", value: () => $r(listId) },\n      { path: [1, 1], attribute: \"aria-label\", value: () => $p.label },\n      { path: [1, 1, 0], each: () => $r(rows), key: (row, $index) => $r(row).item.id, block: { template: \"\\n        <!--[--><!--]-->\\n        <li class=\\\"palette-option\\\" role=\\\"option\\\">\\n          <span class=\\\"palette-label\\\"></span>\\n          <!--[--><!--]-->\\n        </li>\\n      \", parts: (row, $index) => [{ path: [0], when: () => $r(row).heading, blocks: [{ template: \"<li class=\\\"palette-group\\\" role=\\\"presentation\\\"></li>\", parts: () => [{ path: [0], text: () => $t($r(row).heading) }] }, null] }, { path: [1], attribute: \"id\", value: () => (`${optionId}-${$r(row).index}`) }, { path: [1], attribute: \"aria-selected\", value: () => (($r(row).index === $r(active)) ? \"true\" : \"false\") }, { path: [1], on: \"pointermove\", handler: () => (() => (__zubraAssign(active, $r(row).index))) }, { path: [1], on: \"click\", handler: () => (() => run($r(row).item)) }, { path: [1, 0], text: () => $t($r(row).item.label) }, { path: [1, 1], when: () => $r(row).item.hint, blocks: [{ template: \"<span class=\\\"palette-hint\\\"></span>\", parts: () => [{ path: [0], text: () => $t($r(row).item.hint) }] }, null] }] } },\n      { path: [1, 1, 1], when: () => !($r(matches).length), blocks: [{ template: \"<li class=\\\"palette-empty\\\" role=\\\"presentation\\\"></li>\", parts: () => [{ path: [0], text: () => \"Nothing matches \\\"\" + $t($r(query)) + \"\\\".\" }] }, null] },\n    ];\n  },\n});\n"
    }
  ]
}
