{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "color-swatches",
  "type": "registry:item",
  "title": "Color Swatches",
  "description": "Pick a colour from `colors`. A form control (a radio group): arrow keys move the choice. `names` are what each colour is called, in the same order (\"Barn red\"), for screen readers and the tooltip; a colour without one is announced by its value.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/color-swatches.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/color-swatches.js",
      "content": "// Generated by zubra from color-swatches.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { effect, host } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"color-swatches\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: \"#16a34a\", required: false, model: true },\n    \"colors\": { attribute: \"colors\", default: [\"#16a34a\",\"#2563eb\",\"#db2777\",\"#ea580c\",\"#7c3aed\",\"#0891b2\"], required: false },\n    \"names\": { attribute: \"names\", default: [\"Green\",\"Blue\",\"Pink\",\"Orange\",\"Violet\",\"Cyan\"], required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n    \"label\": { attribute: \"label\", default: \"Colour\", 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 (color-swatches) to ([data-zb-slotted=\\\"color-swatches\\\"]) {\\n  :scope { display: block; }\\n  div { display: flex; flex-wrap: wrap; gap: 0.4rem; }\\n  button { width: 1.75rem; height: 1.75rem; padding: 0; border: 2px solid transparent; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 2px var(--card, #ffffff); }\\n  button[aria-checked=true] { border-color: var(--foreground, #1d2130); }\\n  button:disabled { opacity: 0.55; cursor: not-allowed; }\\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\n  function pick(color) {\n    if (color === $p.value) return\n    $p.value = color\n  }\n  function move(index, step) {\n    const next = $p.colors[(index + step + $p.colors.length) % $p.colors.length]\n    pick(next)\n    queueMicrotask(() => group.get().querySelector(`[data-color=\"${next}\"]`)?.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.colors, key: (color, index) => $r(color), block: { template: \"\\n      <button type=\\\"button\\\" role=\\\"radio\\\"></button>\\n    \", parts: (color, index) => [{ path: [0], style: \"background\", value: () => $r(color) }, { path: [0], attribute: \"data-color\", value: () => $r(color) }, { path: [0], attribute: \"aria-label\", value: () => ($p.names[$r(index)] || $r(color)) }, { path: [0], attribute: \"title\", value: () => ($p.names[$r(index)] || null) }, { path: [0], attribute: \"aria-checked\", value: () => (($r(color) === $p.value) ? \"true\" : \"false\") }, { path: [0], attribute: \"tabindex\", value: () => (($r(color) === $p.value) ? \"0\" : \"-1\") }, { path: [0], attribute: \"disabled\", boolean: true, value: () => $p.disabled }, { path: [0], on: \"click\", handler: () => (() => pick($r(color))) }, { path: [0], on: \"keydown\", handler: () => (() => move($r(index), 1)), modifiers: { prevent: true, keys: [\"ArrowRight\", \"ArrowDown\"] } }, { path: [0], on: \"keydown\", handler: () => (() => move($r(index), -1)), modifiers: { prevent: true, keys: [\"ArrowLeft\", \"ArrowUp\"] } }] } },\n    ];\n  },\n});\n"
    }
  ]
}
