{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "otp-grouped-separator",
  "title": "OTP Grouped Separator",
  "description": "A one-time code split into readable groups such as 123 456 that is still one input, with pasted 123-456 stripped to digits.",
  "registryDependencies": [
    "input-otp"
  ],
  "files": [
    {
      "path": "registry/patterns/otp-grouped-separator/otp-grouped-separator.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport {\n  InputOTP,\n  InputOTPGroup,\n  InputOTPSeparator,\n  InputOTPSlot,\n} from \"@/components/ui/input-otp\"\n\nexport interface OtpGroupedSeparatorProps {\n  /** Group sizes, e.g. [3, 3] for 123-456. Default [3, 3]. */\n  groups?: number[]\n  onComplete: (code: string) => void\n  disabled?: boolean\n}\n\n/**\n * A code split into readable groups (123 456, or 1234 5678). The groups are\n * visual: the field is still one input, so typing, paste, autofill and\n * screen readers see one code. Pasting `123-456` or `123 456` strips the\n * separators. The group sizes sum to the code length.\n */\nexport function OtpGroupedSeparator({\n  groups = [3, 3],\n  onComplete,\n  disabled,\n}: OtpGroupedSeparatorProps) {\n  const length = groups.reduce((a, b) => a + b, 0)\n  const starts = groups.map((_, g) =>\n    groups.slice(0, g).reduce((a, b) => a + b, 0)\n  )\n  return (\n    <InputOTP\n      maxLength={length}\n      disabled={disabled}\n      aria-label={`${length}-digit code`}\n      inputMode=\"numeric\"\n      autoComplete=\"one-time-code\"\n      pasteTransformer={(pasted) => pasted.replace(/[\\s-]/g, \"\")}\n      onComplete={onComplete}\n    >\n      {groups.map((size, g) => {\n        const start = starts[g]\n        return (\n          <React.Fragment key={g}>\n            {g > 0 ? <InputOTPSeparator /> : null}\n            <InputOTPGroup>\n              {Array.from({ length: size }, (_, i) => (\n                <InputOTPSlot key={start + i} index={start + i} />\n              ))}\n            </InputOTPGroup>\n          </React.Fragment>\n        )\n      })}\n    </InputOTP>\n  )\n}\n",
      "type": "registry:block"
    }
  ],
  "type": "registry:block"
}