{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "combo-box",
  "type": "registry:item",
  "title": "Combo Box",
  "description": "A combobox: type to filter, arrow keys to move, Enter to pick, Escape to close. A form control. `items` is `[{ value, label }]`; `value` is two-way.",
  "dependencies": [
    "@zubra/runtime@^5.13.1",
    "@zag-js/vanilla",
    "@zag-js/combobox"
  ],
  "categories": [
    "widget"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/combo-box.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/combo-box.js",
      "content": "// Generated by zubra from combo-box.zb. Do not edit.\nimport { spread as $spread } from \"@zubra/runtime/spread\";\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport * as combobox from '@zag-js/combobox';\nimport { id, computed, effect, host } from '@zubra/runtime';\nimport { useMachine, normalizeProps } from '@zubra/runtime/zag';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"combo-box\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: \"\", required: false, model: true },\n    \"label\": { attribute: \"label\", default: \"\", required: false },\n    \"placeholder\": { attribute: \"placeholder\", default: \"\", required: false },\n    \"items\": { attribute: \"items\", default: [], required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: true,\n  slots: [],\n  events: [\"valuechange\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (combo-box) to ([data-zb-slotted=\\\"combo-box\\\"]) {\\n  :scope { display: inline-block; font: inherit; }\\n  [data-part=root] { display: grid; gap: 0.3rem; }\\n  [data-part=label] { font-weight: 600; }\\n  [data-part=control] { display: flex; border: 1px solid var(--border, #dde); border-radius: calc(var(--radius, 0.625rem) * 0.8); background: var(--card, #fff); }\\n  [data-part=control]:focus-within { outline: 2px solid var(--primary, #36c); outline-offset: 1px; }\\n  input { flex: 1; min-width: 0; padding: 0.45rem 0.6rem; border: 0; background: transparent; color: inherit; font: inherit; outline: none; }\\n  [data-part=trigger] { padding: 0 0.6rem; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }\\n  ul { list-style: none; margin: 0; padding: 0.3rem; min-width: 12rem; max-height: 16rem; overflow: auto; border: 1px solid var(--border, #dde); border-radius: calc(var(--radius, 0.625rem) * 0.96); background: var(--card, #fff); box-shadow: 0 8px 24px #0d122026; }\\n  ul:not([data-state=open]) { display: none; }\\n  li { padding: 0.4rem 0.6rem; border-radius: calc(var(--radius, 0.625rem) * 0.64); cursor: pointer; }\\n  li[data-highlighted] { background: var(--accent, #f2f4f8); }\\n  li[data-state=checked] { font-weight: 700; }\\n}\\n}\\n\",\n  template: \"\\n  <div>\\n    <label></label>\\n    <div>\\n      <input>\\n      <button type=\\\"button\\\">▾</button>\\n    </div>\\n  </div>\\n  <div>\\n    <ul>\\n      <!--[--><!--]-->\\n    </ul>\\n  </div>\\n\",\n  setup($p, $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\n  // `disabled` set from code (el.disabled = true) also goes on the element as the attribute, which\n  // is where the browser looks: it leaves a disabled control out of the form. A disabled\n  // <fieldset> needs nothing here; the browser disables the controls inside it too.\n  const element = host()\n  effect(() => element.toggleAttribute('disabled', $p.disabled))\n                                                                 \n\n  const query = __zubraState(\"\")\n  const shown = __zubraComputed(() => ($p.items.filter((item) => item.label.toLowerCase().includes(query.get().toLowerCase()))))\n  const collection = __zubraComputed(() => (combobox.collection({ items: shown.get(), itemToValue: (item) => item.value, itemToString: (item) => item.label })))\n\n  const uid = id() // once: Zag's ids must be stable\n  const machine = useMachine(combobox.machine, () => ({\n    id: uid,\n    collection: collection.get(),\n    value: $p.value ? [$p.value] : [],\n    placeholder: $p.placeholder,\n    disabled: $p.disabled,\n    onInputValueChange: (details) => { __zubraAssign(query, details.inputValue) },\n    // Opened from the button or the arrow keys: show everything, as Zag's own examples do.\n    onOpenChange: (details) => { if (details.open && details.reason !== \"input-change\") __zubraAssign(query, \"\") },\n    onValueChange: (details) => { $p.value = details.value[0] ?? \"\" },\n  }))\n  const api = computed(() => combobox.connect(machine.current, normalizeProps))\n    return [\n      { path: [0], spread: () => (api.get().getRootProps()), own: [], bind: $spread },\n      { path: [0, 0], spread: () => (api.get().getLabelProps()), own: [], bind: $spread },\n      { path: [0, 0], text: () => $t($p.label) },\n      { path: [0, 1], spread: () => (api.get().getControlProps()), own: [], bind: $spread },\n      { path: [0, 1, 0], spread: () => (api.get().getInputProps()), own: [], bind: $spread },\n      { path: [0, 1, 1], spread: () => (api.get().getTriggerProps()), own: [\"type\"], bind: $spread },\n      { path: [1], spread: () => (api.get().getPositionerProps()), own: [], bind: $spread },\n      { path: [1, 0], spread: () => (api.get().getContentProps()), own: [], bind: $spread },\n      { path: [1, 0, 0], each: () => $r(shown), key: (item, $index) => $r(item).value, block: { template: \"\\n        <li></li>\\n      \", parts: (item, $index) => [{ path: [0], spread: () => (api.get().getItemProps({ item: $r(item) })), own: [], bind: $spread }, { path: [0], text: () => $t($r(item).label) }] } },\n    ];\n  },\n});\n"
    }
  ]
}
