{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "money-input",
  "type": "registry:item",
  "title": "Money Input",
  "description": "An amount of money. Typing is free-form; on blur it's formatted (`1234.5` → `1,234.50`). The value is a number (or null when empty). A form control: `required` and `min` validate it.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/money-input.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/money-input.js",
      "content": "// Generated by zubra from money-input.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 = \"money-input\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: null, required: false, model: true },\n    \"symbol\": { attribute: \"symbol\", default: \"$\", required: false },\n    \"required\": { attribute: \"required\", default: false, required: false },\n    \"min\": { attribute: \"min\", default: 0, required: false },\n    \"disabled\": { attribute: \"disabled\", default: false, required: false },\n    \"label\": { attribute: \"label\", default: \"Amount\", 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 (money-input) to ([data-zb-slotted=\\\"money-input\\\"]) {\\n  :scope { display: block; }\\n  .box { display: flex; align-items: center; border: 1px solid var(--border, #d9dce3); border-radius: calc(var(--radius, 0.625rem) * 0.96); background: var(--card, #ffffff); }\\n  .box:focus-within { outline: 2px solid var(--primary, #4f5df5); outline-offset: 1px; }\\n  span { padding-left: 0.7rem; color: var(--muted-foreground, #667085); font-weight: 600; }\\n  .error { margin: 0.35rem 0 0; color: var(--destructive, #d92d20); font-size: 0.875rem; }\\n  input { flex: 1; min-width: 0; padding: 0.55rem 0.7rem 0.55rem 0.3rem; border: 0; outline: 0; background: none; font: inherit; font-variant-numeric: tabular-nums; color: inherit; text-align: right; }\\n}\\n}\\n\",\n  template: \"\\n  <div class=\\\"box\\\">\\n    <span aria-hidden=\\\"true\\\"></span>\\n    <input inputmode=\\\"decimal\\\" autocomplete=\\\"off\\\" placeholder=\\\"0.00\\\">\\n  </div>\\n  <p class=\\\"error\\\" aria-live=\\\"polite\\\"></p>\\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 format = (amount) => (amount == null ? \"\" : amount.toLocaleString(\"en-US\", { minimumFractionDigits: 2, maximumFractionDigits: 2 }))\n  const text = __zubraState(format($p.value))\n  const focused = __zubraState(false)\n  // Typed text that isn't an amount (\"12 dollars\", \"1e5\") is kept on screen with a message,\n  // rather than quietly changed into some other number.\n  const bad = __zubraState(false)\n  const shown = __zubraComputed(() => (focused.get() || bad.get() ? text.get() : format($p.value)))\n\n  validity(() => (bad.get() ? \"Enter an amount, like 12.50\" : $p.required && $p.value == null ? \"Enter an amount\" : $p.value != null && $p.value < $p.min ? `At least ${format($p.min)}` : \"\"))\n\n  function input(event) {\n    __zubraAssign(text, event.target.value)\n    // Spaces, thousands separators and currency signs are fine; anything else isn't an amount.\n    const cleaned = text.get().replace(/[\\s,$€£¥]/g, \"\").split($p.symbol).join(\"\")\n    const number = /^-?(\\d+\\.?\\d*|\\.\\d+)$/.test(cleaned) ? Number(cleaned) : NaN\n    __zubraAssign(bad, cleaned !== \"\" && !Number.isFinite(number))\n    const next = cleaned === \"\" || bad.get() ? null : Math.round(number * 100) / 100\n    if (next === $p.value) return\n    $p.value = next\n  }\n  // While focused the text is left as typed; on blur it's formatted again.\n  function focus() {\n    if (!bad.get()) __zubraAssign(text, format($p.value))\n    __zubraAssign(focused, true)\n  }\n    return [\n      { path: [0, 0], text: () => $t($p.symbol) },\n      { path: [0, 1], attribute: \"aria-label\", value: () => $p.label },\n      { path: [0, 1], attribute: \"aria-invalid\", value: () => ($r(bad) ? \"true\" : \"false\") },\n      { path: [0, 1], attribute: \"disabled\", boolean: true, value: () => $p.disabled },\n      { path: [0, 1], attribute: \"value\", value: () => $r(shown) },\n      { path: [0, 1], on: \"input\", handler: () => $r(input) },\n      { path: [0, 1], on: \"focus\", handler: () => $r(focus) },\n      { path: [0, 1], on: \"blur\", handler: () => (() => (__zubraAssign(focused, false))) },\n      { path: [1], text: () => $t(($r(bad) ? \"Enter an amount, like 12.50\" : \"\")) },\n    ];\n  },\n});\n"
    }
  ]
}
