/** * Copyright Aquera Inc 2026 * * This source code is licensed under the BSD-3-Clause license found in the * LICENSE file in the root directory of this source tree. */ import NileElement from '../internal/nile-element'; import type { CSSResultGroup } from 'lit'; import type { NileFormControl } from '../internal/nile-element'; import '../nile-form-help-text'; import '../nile-form-error-message'; /** * @summary OTP input renders a segmented set of cells but behaves like a single logical form control. * @tag nile-otp-input * * @slot label - The input label. Alternatively, use the `label` attribute. * @slot help-text - Helpful guidance text. Alternatively, use the `help-text` attribute. * * @event nile-input - Emitted whenever the OTP value changes from user input. * @event nile-change - Emitted whenever the OTP value changes from user input. * @event nile-complete - Emitted when all OTP cells are filled. * @event nile-focus - Emitted when focus enters the component. * @event nile-blur - Emitted when focus leaves the component. * @event nile-paste - Emitted when OTP text is pasted. * @event nile-invalid - Emitted when the control is invalid. * * @csspart form-control - Wrapper for label, input, and help/error content. * @csspart form-control-label - Label wrapper. * @csspart form-control-input - Input wrapper. * @csspart form-control-help-text - Help text wrapper. * @csspart form-control-error-message - Error message wrapper. * @csspart base - OTP cell container. * @csspart cell - Individual OTP cell. * @csspart separator - Separator element between cell groups. */ export declare class NileOtpInput extends NileElement implements NileFormControl { static styles: CSSResultGroup; private readonly formControlController; private readonly hasSlotController; private customValidationMessage; private wasComplete; valueInput: HTMLInputElement; cellInputs: NodeListOf; private hasFocus; private activeIndex; private cells; /** The name of the input, submitted as a name/value pair with form data. */ name: string; /** The current value of the OTP control. */ value: string; /** The default value of the form control. Primarily used for resetting the form control. */ defaultValue: string; /** Number of OTP cells. Values below 4 are clamped to 4. */ length: number; /** Restricts input to numeric digits when true. Overridden by `alphanumeric`. */ numericOnly: boolean; /** Allows both letters and digits. When present, overrides `numeric-only`. */ alphanumeric: boolean; /** The input's label. */ label: string; helpText: string; errorMessage: string; /** Placeholder shown inside each OTP cell. */ placeholder: string; /** Optional separator text rendered between configured OTP groups (for example "-"). */ separator: string; /** Renders a separator after each N cells when `separator` is set. */ separatorEvery: number; /** Comma-separated zero-based cell indexes after which separators are rendered. */ separatorPositions: string; /** Masks filled cells with dots, showing each character briefly while typing. */ masked: boolean; /** Sets the input to a warning state, changing its visual appearance. */ warning: boolean; /** Sets the input to an error state, changing its visual appearance. */ error: boolean; /** Sets the input to a success state, changing its visual appearance. */ success: boolean; /** Disables the control. */ disabled: boolean; /** Makes the control readonly. */ readonly: boolean; /** * By default, form controls are associated with the nearest containing `
` element. This attribute allows you * to place the form control outside of a form and associate it with the form that has this `id`. */ form: string; /** Makes this field required. */ required: boolean; /** Optional regex pattern for full OTP validation. */ pattern: string; /** Indicates that the input should receive focus on page load. */ autofocus: boolean; /** Controls keyboard type shown on supporting virtual keyboards. */ inputmode: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url'; /** The autocomplete mode used on the first OTP cell. */ autocomplete: string; connectedCallback(): void; disconnectedCallback(): void; firstUpdated(): void; /** Gets the validity state object. */ get validity(): ValidityState; /** Gets the validation message. */ get validationMessage(): string; /** Returns true when all OTP cells have values. */ get complete(): boolean; private getNormalizedLength; private isNumericMode; private getResolvedInputMode; private getValidationPattern; private isAllowedCharacter; private toOtpCharacters; private normalizeValue; private createCells; private syncCellsFromValue; private isComplete; private getFirstEmptyIndex; private getSeparatorIndices; private getCellPlaceholder; private focusCell; private updateCell; private fillFromIndex; private commitUserValueUpdate; private handleInvalid; private handleCellFocus; private handleCellBlur; private handleCellInput; private handleCellPaste; private handleCellKeyDown; handleLengthChange(): void; handleValueChange(): void; handleDisabledChange(): void; handleNumericOnlyChange(): void; handlePatternChange(): void; /** Checks validity without showing browser UI. */ checkValidity(): boolean; /** Returns associated form if one exists. */ getForm(): HTMLFormElement | null; /** Checks validity and shows browser UI when invalid. */ reportValidity(): boolean; /** Sets a custom validation message. Pass empty string to restore validity. */ setCustomValidity(message: string): void; /** Focuses the first empty cell, or the last one when complete. */ focus(options?: FocusOptions): void; /** Removes focus from whichever OTP cell is currently focused. */ blur(): void; /** Clears all OTP cells. */ clear(): void; render(): import("lit-html").TemplateResult<1>; } export default NileOtpInput; declare global { interface HTMLElementTagNameMap { 'nile-otp-input': NileOtpInput; } }