UNPKG

ngxsmk-otp-input

Version:

Angular 17+ OTP/PIN input component (standalone + SCSS)

63 lines (60 loc) 2.76 kB
import * as i0 from '@angular/core'; import { EventEmitter, QueryList, ElementRef } from '@angular/core'; import { ControlValueAccessor } from '@angular/forms'; /** * ngxsmk-otp-input — Standalone OTP/PIN input for Angular 17+ * - Works with Angular forms via ControlValueAccessor * - Any length (default 6) * - Numeric-only option * - Paste support * - Arrow/Backspace navigation * - Masked mode (•) optional * - Emits (changed) and (completed) */ declare class OtpInputComponent implements ControlValueAccessor { /** Number of boxes */ length: number; /** Only allow 0-9 */ numeric: boolean; /** Autofill hint for iOS/Android */ autocomplete: 'one-time-code' | 'otp' | 'off'; /** Mask characters with maskChar */ mask: boolean; /** Character used for masking */ maskChar: string; /** Optional aria label for the input group */ ariaLabel: string; /** Optional aria-describedby id */ ariaDescribedby?: string; /** Optional invalid styling hook */ isInvalid: boolean; /** ID prefix for inputs */ idPrefix: string; /** Emits on any change */ changed: EventEmitter<string>; /** Emits when all boxes are filled with valid chars */ completed: EventEmitter<string>; hostClass: boolean; inputs: QueryList<ElementRef<HTMLInputElement>>; private values; disabled: boolean; get boxes(): unknown[]; private onChange; private onTouched; writeValue(v: string | null): void; registerOnChange(fn: (v: string) => void): void; registerOnTouched(fn: () => void): void; setDisabledState(isDisabled: boolean): void; private focusFirstIfNeeded; displayChar(i: number): string; private sanitizeChar; private getInputAt; private emitAll; boxAriaLabel(i: number): string; onInput(e: any, i: number): void; onKeydown(e: KeyboardEvent, i: number): void; onPaste(e: ClipboardEvent, i: number): void; static ɵfac: i0.ɵɵFactoryDeclaration<OtpInputComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<OtpInputComponent, "ngxsmk-otp-input", never, { "length": { "alias": "length"; "required": false; }; "numeric": { "alias": "numeric"; "required": false; }; "autocomplete": { "alias": "autocomplete"; "required": false; }; "mask": { "alias": "mask"; "required": false; }; "maskChar": { "alias": "maskChar"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; "ariaDescribedby": { "alias": "ariaDescribedby"; "required": false; }; "isInvalid": { "alias": "isInvalid"; "required": false; }; "idPrefix": { "alias": "idPrefix"; "required": false; }; }, { "changed": "changed"; "completed": "completed"; }, never, never, true, never>; } export { OtpInputComponent };