import { OTPInput, OTPInputContext } from "input-otp"; import { Minus } from "lucide-react"; import { cn } from "../../lib/utils"; import { ComponentPropsWithoutRef, ElementRef, forwardRef, useContext, } from "react"; const InputOTP = forwardRef< ElementRef, ComponentPropsWithoutRef >(({ className, containerClassName, ...props }, ref) => ( )); InputOTP.displayName = "InputOTP"; const InputOTPGroup = forwardRef< ElementRef<"div">, ComponentPropsWithoutRef<"div"> >(({ className, ...props }, ref) => (
)); InputOTPGroup.displayName = "InputOTPGroup"; const InputOTPSlot = forwardRef< ElementRef<"div">, ComponentPropsWithoutRef<"div"> & { index: number } >(({ index, className, ...props }, ref) => { const inputOTPContext = useContext(OTPInputContext); const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index]; return (
{char} {hasFakeCaret && (
)}
); }); InputOTPSlot.displayName = "InputOTPSlot"; const InputOTPSeparator = forwardRef< ElementRef<"div">, ComponentPropsWithoutRef<"div"> >(({ ...props }, ref) => (
)); InputOTPSeparator.displayName = "InputOTPSeparator"; export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };