import type React from 'react'; import { ValuesOf } from '../utils/typeUtils'; import { SIZE, STATUS } from './OTPInput.constants'; export type OTPInputStatus = ValuesOf; export type OTPInputSize = ValuesOf; export type OTPInputProps = { /** Applies a data-hook HTML attribute that can be used in tests. */ dataHook?: string; /** Specifies a CSS class name to be appended to the component's root element. * @internal */ className?: string; /** Assigns a unique identifier to the input. Give a `FormField` the same `id` and clicking its label focuses the input, like it does for `Input`. */ id?: string; /** Sets the name of the input, so the code is submitted with a native `
`. */ name?: string; /** * Controls the size of the slots. The default heights and text sizes match `Input` in every theme. * @default 'medium' */ size?: OTPInputSize; /** * Sets the number of characters in the code, and the number of slots shown when no children are passed. * @default 6 */ length?: number; /** Sets the entered code. Use it with `onChange` to control the component. */ value?: string; /** Sets the initial code when the component isn't controlled with `value`. */ defaultValue?: string; /** Defines a callback function which is called every time the entered code changes. */ onChange?: (value: string) => void; /** Defines a callback function which is called when an edit leaves a complete, changed code, whether by typing, pasting or autofill. After `focus()` selects the first slot of a complete code, the user is retyping it, so the call waits until the last slot is filled; clicking a slot or using the arrow keys to fix a single digit calls it right away. It isn't called when `value` changes from outside or when an edit changes nothing. */ onComplete?: (value: string) => void; /** Sets the status of the slots. Inside a `FormField` the status of the `FormField` is used unless this prop is set, and the message comes from the `FormField`. The status only changes how the slots look; call `clear()` on the ref to empty them. `loading` doesn't change the slots and only marks the input as busy, so show the progress in the `FormField` message. */ status?: OTPInputStatus; /** * Specifies whether the input is disabled. * @default false */ disabled?: boolean; /** * Specifies whether the code can't be edited, for example while it is verified. * @default false */ readOnly?: boolean; /** * Specifies whether the input is focused when the component mounts. Use it when the code is the main task on the screen, such as a two-step login step. * @default false */ autoFocus?: boolean; /** Defines a standard input onFocus callback. */ onFocus?: React.FocusEventHandler; /** Defines a standard input onBlur callback. */ onBlur?: React.FocusEventHandler; /** Sets the accessible name of the input, for example "Verification code". */ ariaLabel?: string; /** Associates the input with an element that labels it. Inside a `FormField` this defaults to its label. */ ariaLabelledBy?: string; /** Arranges the slots into groups with `OTPInput.Group`, `OTPInput.Slot` and `OTPInput.Separator`. Without children, `length` slots are shown in one row. */ children?: React.ReactNode; }; export type OTPInputGroupProps = { /** Holds the `OTPInput.Slot` elements of the group. */ children?: React.ReactNode; }; export type OTPInputSlotProps = { /** Sets which character of the code the slot shows, starting at 0. */ index: number; }; export type OTPInputImperativeActions = { /** Sets focus on the input: on the first empty slot, or with the first slot selected when the code is complete, so typing overwrites it from the start. */ focus: () => void; /** Empties the code, calls `onChange` with an empty string and focuses the input. */ clear: () => void; }; //# sourceMappingURL=OTPInput.types.d.ts.map