{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "choice-cards",
  "type": "registry:item",
  "title": "Choice Cards",
  "description": "Pick one of several cards: a radio group. A form control; arrow keys move the choice. Each item is `{ id, title, detail, price, note }` (`note` and `price` optional).",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/choice-cards.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/choice-cards.js",
      "content": "// Generated by zubra from choice-cards.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { effect, host, validity } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"choice-cards\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: \"\", required: false, model: true },\n    \"items\": { attribute: \"items\", default: [], required: false },\n    \"required\": { attribute: \"required\", default: false, required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n    \"label\": { attribute: \"label\", default: \"\", 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 (choice-cards) to ([data-zb-slotted=\\\"choice-cards\\\"]) {\\n  :scope { display: block; }\\n  [role=radiogroup] { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 0.75rem; }\\n  button { display: grid; gap: 0.25rem; text-align: left; padding: 0.9rem 1rem; border: 2px solid var(--border, #dde); border-radius: calc(var(--radius, 0.625rem) * 1.44); background: var(--card, #fff); color: inherit; font: inherit; cursor: pointer; transition: border-color var(--duration-fast, 150ms), box-shadow var(--duration-fast, 150ms); }\\n  button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary, #36c) 50%, transparent); }\\n  button[aria-checked=true] { border-color: var(--primary, #36c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary, #36c) 20%, transparent); }\\n  button:disabled { opacity: 0.45; cursor: not-allowed; }\\n  strong { font-size: 1rem; }\\n  .detail { font-size: 0.8125rem; color: var(--muted-foreground, #667); }\\n  .row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0.35rem; }\\n  .price { font-weight: 700; }\\n  .note { font-size: 0.75rem; font-weight: 600; color: var(--primary, #36c); }\\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  <div role=\\\"radiogroup\\\">\\n  <!--[--><!--]-->\\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  // `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  const group = __zubraState(null)\n  validity(() => ($p.required && !$p.value ? \"Choose one\" : \"\"))\n\n  function choose(item) {\n    if ($p.disabled || item.disabled || item.id === $p.value) return\n    $p.value = item.id\n  }\n  function move(index, step) {\n    const enabled = $p.items.filter((item) => !item.disabled)\n    const at = enabled.findIndex((item) => item.id === $p.items[index].id)\n    const next = enabled[(at + step + enabled.length) % enabled.length]\n    choose(next)\n    queueMicrotask(() => group.get().querySelector(`[data-id=\"${next.id}\"]`)?.focus())\n  }\n    return [\n      { path: [0], attribute: \"aria-label\", value: () => $p.label },\n      { path: [0], ref: () => (($el) => (__zubraAssign(group, $el))) },\n      { path: [0, 0], each: () => $p.items, key: (item, index) => $r(item).id, block: { template: \"\\n    <button type=\\\"button\\\" role=\\\"radio\\\">\\n      <strong></strong>\\n      <!--[--><!--]-->\\n      <!--[--><!--]-->\\n    </button>\\n  \", parts: (item, index) => [{ path: [0], attribute: \"data-id\", value: () => $r(item).id }, { path: [0], attribute: \"aria-checked\", value: () => (($r(item).id === $p.value) ? \"true\" : \"false\") }, { path: [0], attribute: \"tabindex\", value: () => ((($r(item).id === $p.value) || (!($p.value) && ($r(index) === 0))) ? \"0\" : \"-1\") }, { path: [0], attribute: \"disabled\", boolean: true, value: () => ($p.disabled || ($r(item).disabled ?? false)) }, { path: [0], on: \"click\", handler: () => (() => choose($r(item))) }, { path: [0], on: \"keydown\", handler: () => (() => move($r(index), 1)), modifiers: { prevent: true, keys: [\"ArrowDown\", \"ArrowRight\"] } }, { path: [0], on: \"keydown\", handler: () => (() => move($r(index), -1)), modifiers: { prevent: true, keys: [\"ArrowUp\", \"ArrowLeft\"] } }, { path: [0, 0], text: () => $t($r(item).title) }, { path: [0, 1], when: () => $r(item).detail, blocks: [{ template: \"<span class=\\\"detail\\\"></span>\", parts: () => [{ path: [0], text: () => $t($r(item).detail) }] }, null] }, { path: [0, 2], when: () => ($r(item).note || $r(item).price), blocks: [{ template: \"<span class=\\\"row\\\"><span class=\\\"note\\\"></span><span class=\\\"price\\\"></span></span>\", parts: () => [{ path: [0, 0], text: () => $t(($r(item).note ?? \"\")) }, { path: [0, 1], text: () => $t(($r(item).price ?? \"\")) }] }, null] }] } },\n    ];\n  },\n});\n"
    }
  ]
}
