mirror of
https://github.com/lukevella/rallly.git
synced 2025-07-20 09:47:21 +02:00
30 lines
658 B
TypeScript
30 lines
658 B
TypeScript
import { Input } from "@rallly/ui/input";
|
|
import React from "react";
|
|
|
|
const InputOTP = React.forwardRef<
|
|
HTMLInputElement,
|
|
React.ComponentProps<typeof Input> & { onValidCode?: (code: string) => void }
|
|
>(({ onValidCode, onChange, ...rest }, ref) => {
|
|
return (
|
|
<Input
|
|
ref={ref}
|
|
{...rest}
|
|
onChange={(e) => {
|
|
onChange?.(e);
|
|
|
|
if (e.target.value.length === 6) {
|
|
onValidCode?.(e.target.value);
|
|
}
|
|
}}
|
|
maxLength={6}
|
|
data-1p-ignore
|
|
inputMode="numeric"
|
|
autoComplete="one-time-code"
|
|
pattern="\d{6}"
|
|
/>
|
|
);
|
|
});
|
|
|
|
InputOTP.displayName = "InputOTP";
|
|
|
|
export { InputOTP };
|