import * as i0 from '@angular/core'; import { OnInit, OnDestroy, ElementRef, ChangeDetectorRef } from '@angular/core'; import { ControlValueAccessor, Validator } from '@angular/forms'; import { BooleanInput } from '@angular/cdk/coercion'; import { Subject } from 'rxjs'; import * as i1 from '@angular/common'; import * as i2 from '@aposin/ng-aquila/formfield'; interface NxMaskConfig { mask: string; convertTo?: MaskConversionTypes; separators?: string[]; dropSpecialCharacters?: boolean; deactivateMask?: boolean; hooks?: { beforeInput?: [(event: Event) => void]; afterInput?: [(event: Event) => void]; beforePaste?: [(event: ClipboardEvent) => void]; onChange?: [(value: string) => void]; }; } type MASK_TYPE = '0' | 'A' | 'S'; /** Options for input case sensitivity. */ type MaskConversionTypes = 'lower' | 'upper'; /** Interface for saving the cursor information. */ interface CursorInfo { selectionStart?: number; selectionEnd?: number; position?: number; } declare const DEFAULT_SEPARATORS: string[]; declare const DEFAULT_MASK_CONFIG: Omit; /** * Standalone mask implementation that is not tied to Angular. */ declare class NxMask { readonly element: HTMLInputElement; private eventHandlers; /** * _cursor is a helper for saving a position or a selectionRange (selectionStart + selectionEnd) * and then apply it later on (in onInput()). * * _cursor.position is used for saving a position that is then applied without any changes. * * If the position is saved, selectionStart and selectionEnd will be ignored in onInput(). * _cursor.selectionStart and selectionEnd is used for saving the current cursor position, * and a new cursor position is then calculated with this data. */ private _cursor; /** Helper variable for saving the current value of the input element to compare it then with a new value. */ private _inputValue; /** Helper variable for saving the masked string of a pasted value and then applying it in onInput(). */ private _pastedData; private _separators; private maskConfig; constructor(element: HTMLInputElement, maskConfig: NxMaskConfig); /** Changes the input value based on the current config. */ init(): void; updateConfig(maskConfig: NxMaskConfig, { callOnChange, updateValue }?: { callOnChange?: boolean | undefined; updateValue?: boolean | undefined; }): void; private addListener; getUnmaskedValue(value: string): string; private onInput; private onPaste; /** * this._cursor can be set to a new value in this function; * in onInput() it is then used to set the cursor position. */ private onKeydown; private handleDelete; /** When you want to programmatically update the value. */ setValue(value: string): void; private updateValue; private isSeparator; /** * Returns the cursor position after a letter is entered at `selectionStart` position in the mask. * There are two cases to consider ('|' => cursor position where the character is entered, mask: 00:00:00): * - before the separators there is space for entering the letter: '12:3|4:5' => '12:30:|45' * - the letter has to be shifted and is entered after the separators: '12:34|:5' => '12:34:0|5'. */ private _calculateCursorShift; private _isStringAllowed; getMaskedString(inputValue: string, maskStartIndex?: number): string; onDestroy(): void; } declare const NX_MASK_VALUE_ACCESSOR: any; declare const NX_MASK_VALIDATORS: any; declare class NxMaskDirective implements ControlValueAccessor, Validator, OnInit, OnDestroy { private readonly _elementRef; private readonly _cdr; /** * Emits the unmasked value before the value changes. */ readonly cvaModelChange: Subject; /** Whether the mask validation should be deactivated. */ set deactivateMask(value: BooleanInput); get deactivateMask(): boolean; private _deactivateMask?; /** Sets the mask. */ set mask(value: string); get mask(): string; private _mask; /** Sets the case sensitivity of the mask. */ set convertTo(value: MaskConversionTypes | null | undefined); get convertTo(): MaskConversionTypes; private _convertTo?; /** * Sets the keys that are recognized as separators. * Default separators: / ( ) . : - + , and space. */ set separators(values: string[]); get separators(): string[]; private _separators; /** Whether the separators should be dropped in the control value accessor. */ set dropSpecialCharacters(value: BooleanInput); get dropSpecialCharacters(): boolean; private _dropSpecialCharacters; /** Whether the mask validation should be applied on the input. Default: true. */ set validateMask(value: BooleanInput); get validateMask(): boolean; private _validateMask; /** @docs-private */ get elementRefValue(): string; nxMask?: NxMask; constructor(_elementRef: ElementRef, _cdr: ChangeDetectorRef); ngOnInit(): void; private updateNxMask; private get maskConfig(); private handleMaskChange; ngOnDestroy(): void; private _onChangeCallback?; private _onTouchedCallback; private _validatorOnChange; private _beforeInputHook; private _afterInputHook; private _beforePasteHook; /** * Registers a function to be executed before the onInput handler. */ registerBeforeInputHook(beforeInput: (event: Event) => void): void; /** * Registers a function to be executed after the onInput handler. * The registered hook receives a `KeyboardEvent` from the onInput event handler as a parameter. * * **Note:** If you register a `afterInputHook`, you may also register a `beforePasteHook` * to perform similar changes for pasting. */ registerAfterInputHook(afterInput: (event: Event) => void): void; /** * Registers a function to be executed before the onPaste handler. * The registered hook receives a `ClipboardEvent` from the onPaste event handler as a parameter. */ registerBeforePasteHook(beforePaste: (event: ClipboardEvent) => void): void; getUnmaskedValue(): string; /** * Sets the mask (for programmatical use). Use `withUpdate = false` to not call * the internal updateValue function if needed. * * No `_onChangeCallback()` will be called! */ setMask(value: string, withUpdate?: boolean): void; private _isStringAllowed; /** @docs-private */ getMaskedString(inputValue: string, maskStartIndex?: number): string; private isSeparator; writeValue(value: any): void; registerOnChange(onChange: any): void; registerOnTouched(onTouched: any): void; /** @docs-private */ registerOnValidatorChange(fn: () => void): void; private isEmptyInputValue; _validateFn(): { nxMaskLengthError: { length: number; actual: any; }; } | null; /** @docs-private */ validate(): { nxMaskLengthError: { length: number; actual: any; }; } | null; _touch(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare const NX_IBAN_MASK_VALIDATORS: any; /** * To use the `NxIbanMaskDirective`, you have to install the **peer dependency** `iban.js`. */ declare class NxIbanMaskDirective implements OnInit, OnDestroy, Validator { private readonly _elementRef; private readonly maskDirective; private _countryCode; private readonly _destroyed; constructor(_elementRef: ElementRef, maskDirective: NxMaskDirective); private _setCountryCodeFromInputValue; private _beforePasteHook; private _setCountryCode; ngOnInit(): void; ngOnDestroy(): void; private _getMask; private _validateFn; /** @docs-private */ validate(): { nxIbanInvalidCountryError: string; nxIbanParseError?: undefined; } | { nxIbanParseError: string; nxIbanInvalidCountryError?: undefined; } | null; private _countryCodeInvalid; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } declare class NxMaskModule { static ɵfac: i0.ɵɵFactoryDeclaration; static ɵmod: i0.ɵɵNgModuleDeclaration; static ɵinj: i0.ɵɵInjectorDeclaration; } export { DEFAULT_MASK_CONFIG, DEFAULT_SEPARATORS, NX_IBAN_MASK_VALIDATORS, NX_MASK_VALIDATORS, NX_MASK_VALUE_ACCESSOR, NxIbanMaskDirective, NxMask, NxMaskDirective, NxMaskModule }; export type { CursorInfo, MASK_TYPE, MaskConversionTypes, NxMaskConfig };