- Name
focusIndex- Kind
- property
- Type
number- Requirement
- required
DocsAPI referenceUI machinesinput-otp
input-otp machine
The public state machine contract for @grassroot/ui-machines/input-otp. The machine owns behaviour; the matching headless layer owns composition.
@grassroot/ui-machines/input-otp
Package
Service example
input-otp.tsts
import { createService } from "@grassroot/statechart";import { inputOTPMachine } from "@grassroot/ui-machines/input-otp"; const service = createService(inputOTPMachine, { input: {} });service.start();service.send({ type: "…" });service.stop();10 of 10
Exports
InputOTPCommand
typeInputOTPCommandts
type InputOTPCommand = CommandObject & ({ readonly type: "VALUE_CHANGE_REQUEST"; readonly value: string; readonly reason: InputOTPReason;} | { readonly type: "COMPLETE"; readonly value: string;});InputOTPContext
typeInputOTPContextts
type InputOTPContext = { readonly value: string; readonly focusIndex: number; readonly mode: BindingMode;};Name
Kind
Type
Requirement
focusIndexproperty
numberrequired
modeproperty
BindingModerequired
valueproperty
stringrequired
- Name
mode- Kind
- property
- Type
BindingMode- Requirement
- required
- Name
value- Kind
- property
- Type
string- Requirement
- required
InputOTPDiagnosticCodes
valueInputOTPDiagnosticCodests
export declare const InputOTPDiagnosticCodes: readonly DiagnosticCatalogueEntry[];InputOTPEvent
typeInputOTPEventts
type InputOTPEvent = { readonly type: "SET_CHAR"; readonly index: number; readonly value: string; readonly reason?: InputOTPReason;} | { readonly type: "PASTE"; readonly index: number; readonly value: string;} | { readonly type: "BACKSPACE"; readonly index: number;} | { readonly type: "MOVE_FOCUS"; readonly index: number;} | { readonly type: "RESET";};InputOTPInput
typeInputOTPInputts
type InputOTPInput = { readonly length?: number; readonly value?: string; readonly defaultValue?: string; readonly disabled?: boolean;};Name
Kind
Type
Requirement
defaultValueproperty
stringoptional
disabledproperty
booleanoptional
lengthproperty
numberoptional
valueproperty
stringoptional
- Name
defaultValue- Kind
- property
- Type
string- Requirement
- optional
- Name
disabled- Kind
- property
- Type
boolean- Requirement
- optional
- Name
length- Kind
- property
- Type
number- Requirement
- optional
- Name
value- Kind
- property
- Type
string- Requirement
- optional
inputOTPMachine
valueinputOTPMachinets
export declare const inputOTPMachine: Machine<InputOTPInput, "ready", InputOTPContext, InputOTPEvent, InputOTPCommand>;InputOTPReason
typeInputOTPReasonts
type InputOTPReason = "input" | "paste" | "backspace" | "programmatic";inputOTPReplaySequence
valueinputOTPReplaySequencets
export declare const inputOTPReplaySequence: readonly InputOTPEvent[];inputOTPSelectors
valueinputOTPSelectorsts
export declare const inputOTPSelectors: { value: (snapshot: InputOTPSnapshot) => string; focusIndex: (snapshot: InputOTPSnapshot) => number;};Name
Kind
Type
Requirement
focusIndexproperty
(snapshot: InputOTPSnapshot) => numberrequired
valueproperty
(snapshot: InputOTPSnapshot) => stringrequired
- Name
focusIndex- Kind
- property
- Type
(snapshot: InputOTPSnapshot) => number- Requirement
- required
- Name
value- Kind
- property
- Type
(snapshot: InputOTPSnapshot) => string- Requirement
- required
InputOTPSnapshot
typeInputOTPSnapshotts
type InputOTPSnapshot = Snapshot<"ready", InputOTPContext>;