import { default as React } from 'react'; import { FormValidator } from '../../services/formValidation/index.js'; import { SlotClassNames, SlotStyles, HtmlProps } from '../types/slots.types.js'; export type OtpInputSlots = 'root' | 'label' | 'inputs' | 'input' | 'separator'; export declare enum OtpInputCharset { /** Digits only (0-9). Shows a numeric mobile keyboard. */ Numeric = "numeric", /** Letters and digits. */ Alphanumeric = "alphanumeric" } /** Text OtpInput renders of its own, for translating it. */ export interface OtpInputLabels { /** The group of boxes, used when no `label` is given. */ field?: string; /** One box, given its 1-based position and how many there are. */ digit?: (position: number, length: number) => string; } export interface OtpInputProps extends Omit { /** Number of character boxes. Default 6. */ length?: number; /** Current code as a plain string, e.g. "123456". */ value?: string; /** Fired on every change with the full current code (may be shorter than `length`). */ onChange?: ((value: string) => void) | null; /** Fired once, when the code reaches `length` characters. */ onComplete?: ((value: string) => void) | null; formValidator?: FormValidator | null; /** Restricts which characters can be typed and picks the mobile keyboard. Default `numeric`. */ charset?: OtpInputCharset; /** Render each box's value as a dot, like a password field. */ masked?: boolean; /** Draw a small gap after these 1-based box indices, e.g. `[3]` to split 6 boxes into 3+3. */ groupAfter?: number[]; label?: string; isValid?: boolean; /** Shown in an error Tooltip on focus/hover once `isValid` is `false` (or, with a * `formValidator`, once its `shouldShowError` is true). Persists until the value changes * `isValid`/`formValidator`'s error state itself — see `clearOnError` to auto-dismiss it. */ errorMessage?: string; isRequired?: boolean; /** When an error newly appears (`isValid`/`formValidator` turning invalid), clear every box and * refocus the first one after `clearErrorDelay`, so the next attempt starts clean instead of the * user editing individual wrong digits (and re-triggering `onComplete` on every keystroke while * the code stays at full length). Default `false`. */ clearOnError?: boolean; /** Delay in ms before `clearOnError` clears the boxes, so the wrong code and error message are * still visible for a moment first. Default `900`. */ clearErrorDelay?: number; disabled?: boolean; /** Focuses the first empty box (or the first box) on mount. */ autoFocus?: boolean; className?: string; style?: React.CSSProperties; /** Ref to the root element. */ ref?: React.Ref; classNames?: SlotClassNames; styles?: SlotStyles; /** Overrides the text OtpInput renders of its own. Merged per key. */ labels?: OtpInputLabels; }