{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"single-field-otp-input-with-letter-spacing","type":"registry:component","title":"Single Field OTP Input With Letter Spacing","description":"","dependencies":[],"files":[{"path":"components/we-inc/single-field-otp-input-with-letter-spacing.tsx","type":"registry:component","content":"import { useState } from \"react\";\n\nconst LENGTH = 6;\n// Width of one digit cell in ch. The field, the drawn boxes and the letter spacing all use it.\nconst CELL = 2.2;\n\nexport default function SingleFieldOtpInputWithLetterSpacing() {\n  const [code, setCode] = useState(\"90\");\n  const [sent, setSent] = useState(false);\n  const full = code.length === LENGTH;\n\n  return (\n    <section className=\"bg-sky-50 px-4 py-16\">\n      <form\n        onSubmit={(e) => { e.preventDefault(); if (full) setSent(true); }}\n        className=\"mx-auto max-w-sm rounded-2xl bg-white p-6 shadow-sm ring-1 ring-sky-100 sm:p-8\"\n      >\n        <h2 className=\"text-lg font-semibold text-slate-900\">Two-step sign in</h2>\n        <p className=\"mt-1 text-sm text-slate-600\">Open your authenticator app and type the code shown for Tidewater Books.</p>\n\n        <label htmlFor=\"sfotp-code\" className=\"mt-6 block text-sm font-medium text-slate-800\">6-digit code</label>\n        <div className=\"relative mt-2 overflow-hidden rounded-lg font-mono text-2xl focus-within:ring-2 focus-within:ring-sky-600 focus-within:ring-offset-4\" style={{ width: `${LENGTH * CELL + (LENGTH - 1) * 0.4}ch` }}>\n          {/* the boxes are drawn behind one real input */}\n          <div className=\"pointer-events-none absolute inset-0 flex\" aria-hidden=\"true\">\n            {Array.from({ length: LENGTH }, (_, i) => (\n              <span\n                key={i}\n                style={{ width: `${CELL}ch` }}\n                className={`mr-[0.4ch] h-full rounded-lg border-2 font-mono text-2xl last:mr-0 ${i === code.length && !full ? \"border-sky-500 bg-sky-50\" : i < code.length ? \"border-slate-300 bg-white\" : \"border-slate-200 bg-slate-50\"}`}\n              />\n            ))}\n          </div>\n          <input\n            id=\"sfotp-code\"\n            name=\"code\"\n            value={code}\n            onChange={(e) => { setCode(e.target.value.replace(/\\D/g, \"\").slice(0, LENGTH)); setSent(false); }}\n            inputMode=\"numeric\"\n            autoComplete=\"one-time-code\"\n            pattern=\"\\d{6}\"\n            maxLength={LENGTH}\n            aria-describedby=\"sfotp-hint\"\n            spellCheck={false}\n            style={{ width: `${LENGTH * (CELL + 0.4) + 1}ch`, letterSpacing: `${CELL + 0.4 - 1}ch`, paddingLeft: `${(CELL - 1) / 2}ch` }}\n            className=\"relative h-14 bg-transparent font-mono text-2xl font-semibold text-slate-900 caret-transparent focus:outline-none\"\n          />\n        </div>\n        <p id=\"sfotp-hint\" className=\"mt-2 text-xs text-slate-600\">Codes refresh every 30 seconds. Password managers can fill this field.</p>\n\n        <button type=\"submit\" disabled={!full} className=\"mt-6 h-11 w-full rounded-xl bg-sky-700 text-sm font-semibold text-white hover:bg-sky-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-700 focus-visible:ring-offset-2 disabled:bg-slate-200 disabled:text-slate-700\">\n          Sign in\n        </button>\n        <p role=\"status\" className=\"mt-3 min-h-[1.25rem] text-center text-sm font-medium text-emerald-700\">{sent ? \"Code accepted, signing you in\" : \"\"}</p>\n      </form>\n    </section>\n  );\n}\n"}]}
