/** * Six-slot OTP input. Wraps `input-otp-native`'s headless OTPInput with * mobile design tokens (bg-secondary/50 box, primary border on active slot, * 2px caret). Paste-to-fill, autofocus, and iOS/Android one-time-code * autofill are handled by the underlying library (textContentType + autoComplete * are set inside its TextInput). * * Numeric input enforced via `inputMode="numeric"` (library default). */ import { forwardRef } from "react"; import { Text, View } from "react-native"; import { OTPInput, type OTPInputProps, type OTPInputRef, type SlotProps, } from "input-otp-native"; import { cn } from "@/lib/utils"; export type { OTPInputRef as OtpInputRef }; export interface OtpInputProps extends Omit { numberOfDigits?: number; } export const OtpInput = forwardRef( ({ numberOfDigits = 6, ...rest }, ref) => { return ( ( <> {slots.map((slot, idx) => ( ))} )} {...rest} /> ); }, ); OtpInput.displayName = "OtpInput"; function Slot({ slot }: { slot: SlotProps }) { return ( {slot.char ? ( {slot.char} ) : slot.hasFakeCaret ? ( ) : null} ); }