{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "quantity-stepper",
  "type": "registry:item",
  "title": "Quantity Stepper",
  "description": "A number with − and + buttons, between `min` and `max`. A form control. `editable` lets the number be typed as well (a stock count of 40 shouldn't take forty presses); what's typed is clamped to `min`..`max` when the field is left.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/quantity-stepper.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/quantity-stepper.js",
      "content": "// Generated by zubra from quantity-stepper.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 = \"quantity-stepper\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: 1, required: false, model: true },\n    \"min\": { attribute: \"min\", default: 0, required: false },\n    \"max\": { attribute: \"max\", default: 10, required: false },\n    \"label\": { attribute: \"label\", default: \"Quantity\", required: false },\n    \"editable\": { attribute: \"editable\", default: false, 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 (quantity-stepper) to ([data-zb-slotted=\\\"quantity-stepper\\\"]) {\\n  :scope { display: inline-flex; align-items: center; gap: 0.5rem; }\\n  button { width: 2.25rem; height: 2.25rem; border-radius: 50%; border: 1px solid var(--border, #ccd); background: var(--card, #fff); font: inherit; font-size: 1.125rem; cursor: pointer; }\\n  /* aria-disabled, not disabled: a disabled button would drop keyboard focus at the limit. */\\n  button[aria-disabled=true] { opacity: 0.5; cursor: default; }\\n  /* `disabled` itself: the whole control is off. */\\n  button:disabled, input:disabled { opacity: 0.5; cursor: not-allowed; }\\n  output { min-width: 2ch; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }\\n  input { width: calc(4ch + 1.2rem); padding: 0.35rem 0.4rem; border: 1px solid var(--border, #ccd); border-radius: calc(var(--radius, 0.625rem) * 0.8); background: var(--background, #fff); color: inherit; font: inherit; font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; appearance: textfield; }\\n  input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; margin: 0; }\\n}\\n}\\n\",\n  template: \"\\n  <button type=\\\"button\\\" class=\\\"less\\\">−</button>\\n  <!--[--><!--]-->\\n  <button type=\\\"button\\\" class=\\\"more\\\">+</button>\\n\",\n  setup($p, $emit) {\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  // A value set from code is shown clamped to min..max (and a non-number as min).\n  const shown = __zubraComputed(() => (Number.isFinite(Number($p.value)) ? Math.min($p.max, Math.max($p.min, Number($p.value))) : $p.min))\n  function step(by) {\n    if ($p.disabled) return\n    const next = Math.min($p.max, Math.max($p.min, shown.get() + by))\n    if (next === $p.value) return\n    $p.value = next\n  }\n  function typed(event) {\n    const number = Math.round(Number(event.target.value))\n    const next = Number.isFinite(number) && event.target.value.trim() !== \"\" ? Math.min($p.max, Math.max($p.min, number)) : shown.get()\n    event.target.value = String(next)\n    if (next !== $p.value) $p.value = next\n  }\n    return [\n      { path: [0], attribute: \"aria-label\", value: () => (`Fewer ${$p.label}`) },\n      { path: [0], attribute: \"aria-disabled\", value: () => (($r(shown) <= $p.min) ? \"true\" : \"false\") },\n      { path: [0], attribute: \"disabled\", boolean: true, value: () => $p.disabled },\n      { path: [0], on: \"click\", handler: () => (() => step(-1)) },\n      { path: [1], when: () => $p.editable, blocks: [{ template: \"<input type=\\\"number\\\" inputmode=\\\"numeric\\\" step=\\\"1\\\">\", parts: () => [{ path: [0], attribute: \"min\", value: () => $p.min }, { path: [0], attribute: \"max\", value: () => $p.max }, { path: [0], attribute: \"aria-label\", value: () => $p.label }, { path: [0], attribute: \"disabled\", boolean: true, value: () => $p.disabled }, { path: [0], attribute: \"value\", value: () => $r(shown) }, { path: [0], on: \"change\", handler: () => $r(typed) }, { path: [0], on: \"keydown\", handler: () => $r(typed), modifiers: { keys: [\"Enter\"] } }] }, { template: \"<output aria-live=\\\"polite\\\"></output>\", parts: () => [{ path: [0], attribute: \"aria-label\", value: () => $p.label }, { path: [0], text: () => $t($r(shown)) }] }] },\n      { path: [2], attribute: \"aria-label\", value: () => (`More ${$p.label}`) },\n      { path: [2], attribute: \"aria-disabled\", value: () => (($r(shown) >= $p.max) ? \"true\" : \"false\") },\n      { path: [2], attribute: \"disabled\", boolean: true, value: () => $p.disabled },\n      { path: [2], on: \"click\", handler: () => (() => step(1)) },\n    ];\n  },\n});\n"
    }
  ]
}
