{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "star-rating",
  "type": "registry:item",
  "title": "Star Rating",
  "description": "A star rating that is a form control: it submits its value under its `name`, is invalid while `required` and unset, and goes back to 0 when its form resets. `readonly` shows a rating.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/star-rating.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/star-rating.js",
      "content": "// Generated by zubra from star-rating.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { effect, formValue, host, validity } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"star-rating\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: 0, required: false, model: true },\n    \"max\": { attribute: \"max\", default: 5, required: false },\n    \"required\": { attribute: \"required\", default: false, required: false },\n    \"readonly\": { attribute: \"readonly\", default: false, required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n    \"label\": { attribute: \"label\", default: \"Rating\", 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 (star-rating) to ([data-zb-slotted=\\\"star-rating\\\"]) {\\n  :scope { display: inline-flex; }\\n  [role=group] { display: inline-flex; gap: 0.1rem; }\\n  /* 32px targets: easy to hit with a finger or an unsteady hand. */\\n  button { font: inherit; font-size: 1.5rem; line-height: 1; min-width: 2rem; min-height: 2rem; padding: 0; border: 0; background: none; color: color-mix(in oklab, var(--muted-foreground, #71717a) 80%, transparent); cursor: pointer; }\\n  button.on { color: var(--primary, #e07a2f); }\\n  :scope:is([readonly]) button { cursor: default; font-size: 1rem; }\\n  button:disabled { opacity: 0.55; cursor: not-allowed; }\\n}\\n}\\n\",\n  template: \"\\n  <span role=\\\"group\\\">\\n  <!--[--><!--]-->\\n  </span>\\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 hovered = __zubraState(0)\n  const shown = __zubraComputed(() => (hovered.get() || $p.value))\n  const stars = __zubraComputed(() => (Array.from({ length: $p.max }, (_, index) => index + 1)))\n\n  formValue(() => ($p.value ? $p.value : null))\n  validity(() => ($p.required && !$p.value ? \"Pick a rating\" : \"\"))\n\n  function rate(stars) {\n    if ($p.readonly || $p.disabled) return\n    $p.value = stars\n  }\n    return [\n      { path: [0], attribute: \"aria-label\", value: () => $p.label },\n      { path: [0, 0], each: () => $r(stars), key: (n, $index) => $r(n), block: { template: \"\\n    <button type=\\\"button\\\">★</button>\\n  \", parts: (n, $index) => [{ path: [0], toggle: \"on\", value: () => ($r(n) <= $r(shown)) }, { path: [0], attribute: \"aria-label\", value: () => (`${$r(n)} of ${$p.max}`) }, { path: [0], attribute: \"aria-pressed\", value: () => (($r(n) === $p.value) ? \"true\" : \"false\") }, { path: [0], attribute: \"disabled\", boolean: true, value: () => $p.disabled }, { path: [0], on: \"click\", handler: () => (() => rate($r(n))) }, { path: [0], on: \"mouseenter\", handler: () => (() => (__zubraAssign(hovered, $p.readonly || $p.disabled ? 0 : $r(n)))) }, { path: [0], on: \"mouseleave\", handler: () => (() => (__zubraAssign(hovered, 0))) }] } },\n    ];\n  },\n});\n"
    }
  ]
}
