igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
74 lines (73 loc) • 3.25 kB
TypeScript
import type { LitElement } from 'lit';
import type { MaskParser } from '../../mask-input/mask-parser.js';
import type { RangeTextSelectMode, SelectionRangeDirection } from '../../types.js';
import type { AbstractConstructor } from './constructor.js';
export type MaskSelection = {
start: number;
end: number;
};
/**
* Public + protected interface contributed by {@link MaskBehaviorMixin}.
* Declared as a `declare class` so consumers can see protected members through
* the cast return type (mirrors the pattern used by the form-associated mixins).
*/
export declare class MaskBehaviorElementInterface {
protected readonly _input?: HTMLInputElement;
protected readonly _parser: MaskParser;
/** Reflects the current parser state into the host's public value. */
protected _syncValueFromMask(): void;
/** Delegates Enter-key handling to the form-associated base. */
protected _handleEnterKeydown(event: KeyboardEvent): void;
protected _maskSelection: MaskSelection;
protected _compositionStart: number;
protected _focused: boolean;
protected _maskedValue: string;
protected get _inputSelection(): MaskSelection;
protected get _isEmptyMask(): boolean;
/**
* Makes the control a readonly field.
* @attr readonly
* @default false
*/
readOnly: boolean;
/**
* The mask pattern of the component.
* @attr
*/
get mask(): string;
set mask(value: string);
/**
* The prompt symbol to use for unfilled parts of the mask pattern.
* @attr
* @default '_'
*/
get prompt(): string;
set prompt(value: string);
protected _handleInput(event: InputEvent): Promise<void>;
protected _updateInput(text: string, range: MaskSelection): Promise<void>;
protected _emitInputEvent(): void;
protected _setMaskSelection(event: Event): void;
protected _handleCompositionStart(): void;
protected _handleCompositionEnd(event: CompositionEvent): void;
protected _handleClick(): void;
/** Sets the text selection range of the control. */
setSelectionRange(start?: number, end?: number, direction?: SelectionRangeDirection): void;
/** Replaces the selected text in the control and re-applies the mask. */
setRangeText(replacement: string, start?: number, end?: number, selectMode?: RangeTextSelectMode): void;
}
/**
* Adds masked-input behavior (parser-driven editing, selection tracking,
* composition handling, range text replacement) to a LitElement-derived class.
*
* The host class is expected to provide:
* - `_input` – the native `<input>` element (typically via `@query('input')`).
* - `_parser` – a {@link MaskParser} (or subclass) instance.
* - `_setTouchedState` – from `FormAssociatedMixin`.
* - `emitEvent` – from `EventEmitterMixin`.
* - `select` – from the host base.
*
* The host class must implement `_syncValueFromMask` to bridge the masked
* text back into its public `value`. It is called by the default
* `_updateInput` implementation and by `setRangeText`.
*/
export declare function MaskBehaviorMixin<T extends AbstractConstructor<LitElement>>(superClass: T): AbstractConstructor<MaskBehaviorElementInterface> & T;