{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "code-input",
  "type": "registry:item",
  "title": "Code Input",
  "description": "A one-time code (from an email or text message), shown as boxes but typed into one native field: phones offer the code from the message (`autocomplete=\"one-time-code\"`), pasting the whole code works, and Backspace goes back. `length` is the number of characters; `numeric` keeps it to digits. `value` is two-way.",
  "dependencies": [
    "@zubra/runtime@^5.13.1"
  ],
  "categories": [
    "input"
  ],
  "registryDependencies": [
    "https://zubra-js.github.io/zubra-ui/r/theme.json"
  ],
  "files": [
    {
      "path": "components/code-input.js",
      "type": "registry:file",
      "target": "~/src/components/zubra/code-input.js",
      "content": "// Generated by zubra from code-input.zb. Do not edit.\nimport { $define, $r, $t } from \"@zubra/runtime\";\nimport { emit, id } from '@zubra/runtime';\nimport { state as __zubraState, computed as __zubraComputed } from \"@zubra/runtime\";\n\nexport const tag = \"code-input\";\n\nexport default $define(tag, {\n  props: {\n    \"value\": { attribute: \"value\", default: \"\", required: false, model: true },\n    \"length\": { attribute: \"length\", default: 6, required: false },\n    \"numeric\": { attribute: \"numeric\", default: true, required: false },\n    \"label\": { attribute: \"label\", default: \"Verification code\", required: false },\n    \"name\": { attribute: \"name\", default: \"\", required: false },\n  },\n  abi: 3,\n  shadow: false,\n  form: false,\n  slots: [],\n  events: [\"valuechange\", \"complete\"],\n  styled: true,\n  styles: \"@layer theme, base, components, utilities;\\n@layer components {\\n@scope (code-input) to ([data-zb-slotted=\\\"code-input\\\"]) {\\n  :scope { display: block; }\\n  label { display: block; margin-bottom: 0.5rem; font-weight: 600; font-size: 0.925rem; }\\n  .code-row { position: relative; display: inline-flex; gap: 0.4rem; max-width: 100%; }\\n  .code-box { display: grid; place-items: center; width: clamp(1.9rem, 11vw, 2.6rem); height: 3rem; border: 1px solid var(--input, #d4d4d8); border-radius: calc(var(--radius, 0.625rem) * 0.8); background: var(--background, #fff); font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }\\n  .code-current { border-color: var(--ring, #a1a1aa); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring, #a1a1aa) 40%, transparent); }\\n  /* The real field sits over the boxes, transparent, so taps, paste and the keyboard reach it. */\\n  input { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; font-size: 16px; cursor: text; }\\n}\\n}\\n\",\n  template: \"\\n  <label></label>\\n  <div class=\\\"code-row\\\">\\n    <!--[--><!--]-->\\n    <input autocomplete=\\\"one-time-code\\\" spellcheck=\\\"false\\\">\\n  </div>\\n\",\n  setup($p, $emit) {\n    const emit = $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  const inputId = id()\n  const focused = __zubraState(false)\n  const boxes = __zubraComputed(() => (Array.from({ length: $p.length }, (_, i) => ({ i, char: $p.value[i] ?? \"\", current: focused.get() && (i === Math.min($p.value.length, $p.length - 1)) }))))\n\n  function input(event) {\n    const clean = event.target.value.replace($p.numeric ? /\\D/g : /\\s/g, \"\").slice(0, $p.length)\n    event.target.value = clean\n    if (clean === $p.value) return\n    $p.value = clean\n    if (clean.length === $p.length) emit('complete', clean)\n  }\n    return [\n      { path: [0], attribute: \"for\", value: () => $r(inputId) },\n      { path: [0], text: () => $t($p.label) },\n      { path: [1, 0], each: () => $r(boxes), key: (box, $index) => $r(box).i, block: { template: \"\\n      <span class=\\\"code-box\\\" aria-hidden=\\\"true\\\"></span>\\n    \", parts: (box, $index) => [{ path: [0], toggle: \"code-current\", value: () => $r(box).current }, { path: [0], text: () => $t($r(box).char) }] } },\n      { path: [1, 1], attribute: \"id\", value: () => $r(inputId) },\n      { path: [1, 1], attribute: \"name\", value: () => ($p.name || null) },\n      { path: [1, 1], attribute: \"value\", value: () => $p.value },\n      { path: [1, 1], attribute: \"maxlength\", value: () => $p.length },\n      { path: [1, 1], attribute: \"inputmode\", value: () => ($p.numeric ? \"numeric\" : \"text\") },\n      { path: [1, 1], attribute: \"pattern\", value: () => ($p.numeric ? `\\\\d{${$p.length}}` : null) },\n      { path: [1, 1], on: \"input\", handler: () => $r(input) },\n      { path: [1, 1], on: \"focus\", handler: () => (() => (__zubraAssign(focused, true))) },\n      { path: [1, 1], on: \"blur\", handler: () => (() => (__zubraAssign(focused, false))) },\n    ];\n  },\n});\n"
    }
  ]
}
