// Six-cell one-time-code input: one real (invisible, full-bleed) carries the value // and the OTC autofill semantics; the cells are presentation. Click anywhere to focus; // paste works because the input is real. import { useState } from "react"; const LENGTH = 6; export default function CodeInput({ value, onChange, error = false, }: { value: string; onChange: (code: string) => void; error?: boolean; }) { const [focused, setFocused] = useState(false); const digits = value.slice(0, LENGTH).split(""); const active = Math.min(digits.length, LENGTH - 1); return (
setFocused(true)} onBlur={() => setFocused(false)} onChange={(ev) => onChange(ev.target.value.replace(/\D/g, "").slice(0, LENGTH))} /> {Array.from({ length: LENGTH }, (_, i) => ( ))}
); }