| 30 | } |
| 31 | |
| 32 | function InputOTPSlot({ |
| 33 | index, |
| 34 | className, |
| 35 | ...props |
| 36 | }: React.ComponentProps<"div"> & { |
| 37 | index: number; |
| 38 | }) { |
| 39 | const inputOTPContext = React.useContext(OTPInputContext); |
| 40 | const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}; |
| 41 | |
| 42 | return ( |
| 43 | <div |
| 44 | data-slot="input-otp-slot" |
| 45 | data-active={isActive} |
| 46 | className={cn( |
| 47 | "relative flex h-9 w-9 items-center justify-center border-y border-r border-input text-sm shadow-xs transition-all outline-none first:rounded-l-md first:border-l last:rounded-r-md aria-invalid:border-destructive data-[active=true]:z-10 data-[active=true]:border-ring data-[active=true]:ring-[3px] data-[active=true]:ring-ring/50 data-[active=true]:aria-invalid:border-destructive data-[active=true]:aria-invalid:ring-destructive/20 dark:bg-input/30 dark:data-[active=true]:aria-invalid:ring-destructive/40", |
| 48 | className, |
| 49 | )} |
| 50 | {...props} |
| 51 | > |
| 52 | {char} |
| 53 | {hasFakeCaret && ( |
| 54 | <div className="pointer-events-none absolute inset-0 flex items-center justify-center"> |
| 55 | <div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" /> |
| 56 | </div> |
| 57 | )} |
| 58 | </div> |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | function InputOTPSeparator({ ...props }: React.ComponentProps<"div">) { |
| 63 | return ( |