igniteui-webcomponents 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +6 -1
- package/components/button/button-base.d.ts +5 -0
- package/components/button/button-base.js +4 -0
- package/components/button/button-base.js.map +1 -1
- package/components/button/icon-button.js +10 -8
- package/components/button/icon-button.js.map +1 -1
- package/components/button/themes/button/light/button.base.css.js +1 -1
- package/components/button/themes/button/light/button.base.css.js.map +1 -1
- package/components/button/themes/button/light/button.material.css.js +1 -1
- package/components/button/themes/button/light/button.material.css.js.map +1 -1
- package/components/button/themes/icon-button/light/icon-button.base.css.js +1 -1
- package/components/button/themes/icon-button/light/icon-button.base.css.js.map +1 -1
- package/components/button/themes/icon-button/light/icon-button.bootstrap.css.js +1 -1
- package/components/button/themes/icon-button/light/icon-button.bootstrap.css.js.map +1 -1
- package/components/button/themes/icon-button/light/icon-button.fluent.css.js +1 -1
- package/components/button/themes/icon-button/light/icon-button.fluent.css.js.map +1 -1
- package/components/button/themes/icon-button/light/icon-button.indigo.css.js +1 -1
- package/components/button/themes/icon-button/light/icon-button.indigo.css.js.map +1 -1
- package/components/button/themes/icon-button/light/icon-button.material.css.js +1 -1
- package/components/button/themes/icon-button/light/icon-button.material.css.js.map +1 -1
- package/components/calendar/common/calendar-base.js +16 -12
- package/components/calendar/common/calendar-base.js.map +1 -1
- package/components/checkbox/themes/light/switch.base.css.js +1 -1
- package/components/checkbox/themes/light/switch.base.css.js.map +1 -1
- package/components/common/definitions/defineAllComponents.js +8 -0
- package/components/common/definitions/defineAllComponents.js.map +1 -1
- package/components/expansion-panel/expansion-panel.d.ts +72 -0
- package/components/expansion-panel/expansion-panel.js +167 -0
- package/components/expansion-panel/expansion-panel.js.map +1 -0
- package/components/expansion-panel/themes/light/expansion-panel.base.css.d.ts +1 -0
- package/components/expansion-panel/themes/light/expansion-panel.base.css.js +3 -0
- package/components/expansion-panel/themes/light/expansion-panel.base.css.js.map +1 -0
- package/components/expansion-panel/themes/light/expansion-panel.bootstrap.css.d.ts +1 -0
- package/components/expansion-panel/themes/light/expansion-panel.bootstrap.css.js +3 -0
- package/components/expansion-panel/themes/light/expansion-panel.bootstrap.css.js.map +1 -0
- package/components/expansion-panel/themes/light/expansion-panel.fluent.css.d.ts +1 -0
- package/components/expansion-panel/themes/light/expansion-panel.fluent.css.js +3 -0
- package/components/expansion-panel/themes/light/expansion-panel.fluent.css.js.map +1 -0
- package/components/expansion-panel/themes/light/expansion-panel.indigo.css.d.ts +1 -0
- package/components/expansion-panel/themes/light/expansion-panel.indigo.css.js +3 -0
- package/components/expansion-panel/themes/light/expansion-panel.indigo.css.js.map +1 -0
- package/components/form/form.js +10 -2
- package/components/form/form.js.map +1 -1
- package/components/icon/icon.registry.js +3 -0
- package/components/icon/icon.registry.js.map +1 -1
- package/components/input/themes/light/input.base.css.js +1 -1
- package/components/input/themes/light/input.base.css.js.map +1 -1
- package/components/list/themes/light/list.base.css.js +1 -1
- package/components/list/themes/light/list.base.css.js.map +1 -1
- package/components/mask-input/mask-input.d.ts +102 -0
- package/components/mask-input/mask-input.js +260 -0
- package/components/mask-input/mask-input.js.map +1 -0
- package/components/mask-input/mask-parser.d.ts +30 -0
- package/components/mask-input/mask-parser.js +167 -0
- package/components/mask-input/mask-parser.js.map +1 -0
- package/components/nav-drawer/nav-drawer-item.d.ts +1 -0
- package/components/nav-drawer/nav-drawer-item.js +5 -2
- package/components/nav-drawer/nav-drawer-item.js.map +1 -1
- package/components/nav-drawer/styles/indigo/nav-drawer-item.indigo.css.js +1 -1
- package/components/nav-drawer/styles/indigo/nav-drawer-item.indigo.css.js.map +1 -1
- package/components/nav-drawer/styles/nav-drawer-item.base.css.js +1 -1
- package/components/nav-drawer/styles/nav-drawer-item.base.css.js.map +1 -1
- package/components/nav-drawer/styles/nav-drawer.base.css.js +1 -1
- package/components/nav-drawer/styles/nav-drawer.base.css.js.map +1 -1
- package/components/navbar/navbar.js +2 -1
- package/components/navbar/navbar.js.map +1 -1
- package/components/navbar/themes/light/navbar.base.css.js +1 -1
- package/components/navbar/themes/light/navbar.base.css.js.map +1 -1
- package/components/navbar/themes/light/navbar.bootstrap.css.js +1 -1
- package/components/navbar/themes/light/navbar.bootstrap.css.js.map +1 -1
- package/components/navbar/themes/light/navbar.fluent.css.d.ts +1 -0
- package/components/navbar/themes/light/navbar.fluent.css.js +3 -0
- package/components/navbar/themes/light/navbar.fluent.css.js.map +1 -0
- package/components/rating/rating.base.css.js +1 -1
- package/components/rating/rating.base.css.js.map +1 -1
- package/components/rating/rating.fluent.css.js +1 -1
- package/components/rating/rating.fluent.css.js.map +1 -1
- package/components/rating/rating.js +1 -1
- package/components/rating/rating.js.map +1 -1
- package/components/toggle/toggle.directive.js +5 -4
- package/components/toggle/toggle.directive.js.map +1 -1
- package/components/tree/themes/dark/tree-item.bootstrap.css.d.ts +1 -0
- package/components/tree/themes/dark/tree-item.bootstrap.css.js +3 -0
- package/components/tree/themes/dark/tree-item.bootstrap.css.js.map +1 -0
- package/components/tree/themes/dark/tree-item.fluent.css.d.ts +1 -0
- package/components/tree/themes/dark/tree-item.fluent.css.js +3 -0
- package/components/tree/themes/dark/tree-item.fluent.css.js.map +1 -0
- package/components/tree/themes/dark/tree-item.indigo.css.d.ts +1 -0
- package/components/tree/themes/dark/tree-item.indigo.css.js +3 -0
- package/components/tree/themes/dark/tree-item.indigo.css.js.map +1 -0
- package/components/tree/themes/light/tree-item.base.css.d.ts +1 -0
- package/components/tree/themes/light/tree-item.base.css.js +3 -0
- package/components/tree/themes/light/tree-item.base.css.js.map +1 -0
- package/components/tree/themes/light/tree-item.bootstrap.css.d.ts +1 -0
- package/components/tree/themes/light/tree-item.bootstrap.css.js +3 -0
- package/components/tree/themes/light/tree-item.bootstrap.css.js.map +1 -0
- package/components/tree/themes/light/tree-item.fluent.css.d.ts +1 -0
- package/components/tree/themes/light/tree-item.fluent.css.js +3 -0
- package/components/tree/themes/light/tree-item.fluent.css.js.map +1 -0
- package/components/tree/themes/light/tree-item.indigo.css.d.ts +1 -0
- package/components/tree/themes/light/tree-item.indigo.css.js +3 -0
- package/components/tree/themes/light/tree-item.indigo.css.js.map +1 -0
- package/components/tree/themes/light/tree.base.css.d.ts +1 -0
- package/components/tree/themes/light/tree.base.css.js +3 -0
- package/components/tree/themes/light/tree.base.css.js.map +1 -0
- package/components/tree/tree-item.d.ts +116 -0
- package/components/tree/tree-item.js +447 -0
- package/components/tree/tree-item.js.map +1 -0
- package/components/tree/tree.common.d.ts +17 -0
- package/components/tree/tree.common.js +2 -0
- package/components/tree/tree.common.js.map +1 -0
- package/components/tree/tree.d.ts +71 -0
- package/components/tree/tree.js +139 -0
- package/components/tree/tree.js.map +1 -0
- package/components/tree/tree.navigation.d.ts +41 -0
- package/components/tree/tree.navigation.js +260 -0
- package/components/tree/tree.navigation.js.map +1 -0
- package/components/tree/tree.selection.d.ts +55 -0
- package/components/tree/tree.selection.js +265 -0
- package/components/tree/tree.selection.js.map +1 -0
- package/custom-elements.json +632 -2
- package/index.d.ts +4 -0
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/themes/dark/bootstrap.css +1 -1
- package/themes/dark/fluent.css +1 -1
- package/themes/dark/indigo.css +1 -1
- package/themes/light/bootstrap.css +1 -1
- package/themes/light/fluent.css +1 -1
- package/vscode-html-custom-data.json +313 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.base.css.js","sourceRoot":"","sources":["../../../../../src/components/list/themes/light/list.base.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,
|
|
1
|
+
{"version":3,"file":"list.base.css.js","sourceRoot":"","sources":["../../../../../src/components/list/themes/light/list.base.css.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA,w+CAAw+C,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styles = css`:host{position:relative;-webkit-box-sizing:border-box;box-sizing:border-box;scrollbar-width:var(--scrolbar-size, 0.875rem);scrollbar-color:var(--igc-scrollbar-thumb-color, hsla(var(--igc-gray-400), var(--igc-gray-a))) var(--igc-scrollbar-track-color, hsla(var(--igc-gray-200), var(--igc-gray-a)))}:host *,:host *::before,:host *::after{-webkit-box-sizing:border-box;box-sizing:border-box}:host ::-webkit-scrollbar{width:var(--scrolbar-size, 0.875rem);height:var(--scrolbar-size, 0.875rem);background:var(--igc-scrollbar-track-color, hsla(var(--igc-gray-200), var(--igc-gray-a)))}:host ::-webkit-scrollbar-thumb{background:var(--igc-scrollbar-thumb-color, hsla(var(--igc-gray-400), var(--igc-gray-a)))}[hidden]{display:none !important}:host{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-flow:column nowrap;flex-flow:column nowrap;font-family:var(--igc-font-family);overflow:hidden auto;height:auto;background:hsla(var(--igc-surface-500), var(--igc-surface-a))}:host([size=small]) ::slotted(igc-list-item),:host([size=small]) ::slotted(igc-list-header){padding:var(--igc-spacing-small) calc(var(--igc-spacing-small)*2)}:host([size=medium]) ::slotted(igc-list-item),:host([size=medium]) ::slotted(igc-list-header){padding:var(--igc-spacing-medium) calc(var(--igc-spacing-medium)*2)}:host([size=large]) ::slotted(igc-list-item),:host([size=large]) ::slotted(igc-list-header){padding:var(--igc-spacing-large) calc(var(--igc-spacing-large)*2)}`;\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { IgcInputBaseComponent } from '../input/input-base.js';
|
|
2
|
+
import { MaskParser } from './mask-parser.js';
|
|
3
|
+
interface MaskSelection {
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A masked input is an input field where a developer can control user input and format the visible value,
|
|
9
|
+
* based on configurable rules
|
|
10
|
+
*
|
|
11
|
+
* @element igc-mask-input
|
|
12
|
+
*
|
|
13
|
+
* @slot prefix - Renders content before the input
|
|
14
|
+
* @slot suffix - Renders content after the input
|
|
15
|
+
* @slot helper-text - Renders content below the input
|
|
16
|
+
*
|
|
17
|
+
* @fires igcInput - Emitted when the control receives user input
|
|
18
|
+
* @fires igcChange - Emitted when an alteration of the control's value is committed by the user
|
|
19
|
+
* @fires igcFocus - Emitted when the control gains focus
|
|
20
|
+
* @fires igcBlur - Emitted when the control loses focus
|
|
21
|
+
*
|
|
22
|
+
* @csspart container - The main wrapper that holds all main input elements
|
|
23
|
+
* @csspart input - The native input element
|
|
24
|
+
* @csspart label - The native label element
|
|
25
|
+
* @csspart prefix - The prefix wrapper
|
|
26
|
+
* @csspart suffix - The suffix wrapper
|
|
27
|
+
* @csspart helper-text - The helper text wrapper
|
|
28
|
+
*/
|
|
29
|
+
export default class IgcMaskInputComponent extends IgcInputBaseComponent {
|
|
30
|
+
static readonly tagName = "igc-mask-input";
|
|
31
|
+
protected parser: MaskParser;
|
|
32
|
+
protected _value: string;
|
|
33
|
+
protected selection: MaskSelection;
|
|
34
|
+
protected compositionStart: number;
|
|
35
|
+
protected hasFocus: boolean;
|
|
36
|
+
protected maskedValue: string;
|
|
37
|
+
protected get inputSelection(): MaskSelection;
|
|
38
|
+
/** The direction attribute of the control. */
|
|
39
|
+
dir: 'ltr' | 'rtl' | 'auto';
|
|
40
|
+
/** Controls the validity of the control. */
|
|
41
|
+
invalid: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Dictates the behavior when retrieving the value of the control:
|
|
44
|
+
*
|
|
45
|
+
* - `raw` will return the clean user input.
|
|
46
|
+
* - `withFormatting` will return the value with all literals and prompts.
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
valueMode: 'raw' | 'withFormatting';
|
|
50
|
+
/**
|
|
51
|
+
* The value of the input.
|
|
52
|
+
*
|
|
53
|
+
* Regardless of the currently set `value-mode`, an empty value will return an empty string.
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
get value(): string;
|
|
57
|
+
set value(string: string);
|
|
58
|
+
/** The mask pattern to apply on the input. */
|
|
59
|
+
mask: string;
|
|
60
|
+
/** The prompt symbol to use for unfilled parts of the mask. */
|
|
61
|
+
prompt: string;
|
|
62
|
+
protected promptChange(): void;
|
|
63
|
+
protected maskChange(): void;
|
|
64
|
+
protected handleInvalidState(): void;
|
|
65
|
+
connectedCallback(): void;
|
|
66
|
+
protected handleKeydown(e: KeyboardEvent): void;
|
|
67
|
+
protected handleCompositionStart(): void;
|
|
68
|
+
protected handleCompositionEnd({ data }: CompositionEvent): void;
|
|
69
|
+
protected handleInput({ inputType, isComposing }: InputEvent): void | Promise<void>;
|
|
70
|
+
protected updateInput(part: string, start: number, finish: number): void;
|
|
71
|
+
protected handleCut(): void;
|
|
72
|
+
protected handleDragStart(): void;
|
|
73
|
+
protected handleDragEnter(): void;
|
|
74
|
+
protected handleDragLeave(): void;
|
|
75
|
+
protected handleFocus(): void;
|
|
76
|
+
protected handleBlur(): void;
|
|
77
|
+
protected handleChange(): void;
|
|
78
|
+
protected handleInvalid(): void;
|
|
79
|
+
protected handleClick(): void;
|
|
80
|
+
protected updateMaskedValue(): void;
|
|
81
|
+
/** Replaces the selected text in the control and re-applies the mask */
|
|
82
|
+
setRangeText(replacement: string, start: number, end: number, _selectMode?: 'select' | 'start' | 'end' | 'preserve'): void;
|
|
83
|
+
setSelectionRange(start: number, end: number, direction?: 'backward' | 'forward' | 'none'): void;
|
|
84
|
+
/** Checks for validity of the control and shows the browser message if it's invalid. */
|
|
85
|
+
reportValidity(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Sets a custom validation message for the control.
|
|
88
|
+
* As long as `message` is not empty, the control is considered invalid.
|
|
89
|
+
*/
|
|
90
|
+
setCustomValidity(message: string): void;
|
|
91
|
+
/** Check for validity of the control */
|
|
92
|
+
checkValidity(): boolean;
|
|
93
|
+
/** Selects all text within the input. */
|
|
94
|
+
select(): void;
|
|
95
|
+
protected renderInput(): import("lit-html").TemplateResult<1>;
|
|
96
|
+
}
|
|
97
|
+
declare global {
|
|
98
|
+
interface HTMLElementTagNameMap {
|
|
99
|
+
'igc-mask-input': IgcMaskInputComponent;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
|
+
import { live } from 'lit/directives/live.js';
|
|
11
|
+
import { watch } from '../common/decorators/watch.js';
|
|
12
|
+
import { blazorTwoWayBind } from '../common/decorators/blazorTwoWayBind.js';
|
|
13
|
+
import { partNameMap } from '../common/util.js';
|
|
14
|
+
import { IgcInputBaseComponent } from '../input/input-base.js';
|
|
15
|
+
import { MaskParser } from './mask-parser.js';
|
|
16
|
+
export default class IgcMaskInputComponent extends IgcInputBaseComponent {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.parser = new MaskParser();
|
|
20
|
+
this._value = '';
|
|
21
|
+
this.selection = { start: 0, end: 0 };
|
|
22
|
+
this.compositionStart = 0;
|
|
23
|
+
this.hasFocus = false;
|
|
24
|
+
this.maskedValue = '';
|
|
25
|
+
this.dir = 'auto';
|
|
26
|
+
this.invalid = false;
|
|
27
|
+
this.valueMode = 'raw';
|
|
28
|
+
}
|
|
29
|
+
get inputSelection() {
|
|
30
|
+
return {
|
|
31
|
+
start: this.input.selectionStart || 0,
|
|
32
|
+
end: this.input.selectionEnd || 0,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
get value() {
|
|
36
|
+
return this._value
|
|
37
|
+
? this.valueMode !== 'raw'
|
|
38
|
+
? this.maskedValue
|
|
39
|
+
: this._value
|
|
40
|
+
: this._value;
|
|
41
|
+
}
|
|
42
|
+
set value(string) {
|
|
43
|
+
this._value = string !== null && string !== void 0 ? string : '';
|
|
44
|
+
this.maskedValue = this.parser.apply(this._value);
|
|
45
|
+
}
|
|
46
|
+
promptChange() {
|
|
47
|
+
this.parser.prompt = this.prompt;
|
|
48
|
+
if (this.value) {
|
|
49
|
+
this.maskedValue = this.parser.apply(this._value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
maskChange() {
|
|
53
|
+
this.parser.mask = this.mask;
|
|
54
|
+
if (this.value) {
|
|
55
|
+
this.maskedValue = this.parser.apply(this._value);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
handleInvalidState() {
|
|
59
|
+
this.updateComplete.then(() => (this.invalid = !this.checkValidity()));
|
|
60
|
+
}
|
|
61
|
+
connectedCallback() {
|
|
62
|
+
super.connectedCallback();
|
|
63
|
+
this.mask = this.mask || this.parser.mask;
|
|
64
|
+
this.prompt = this.prompt || this.parser.prompt;
|
|
65
|
+
}
|
|
66
|
+
handleKeydown(e) {
|
|
67
|
+
if (!e.key) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.selection = this.inputSelection;
|
|
71
|
+
}
|
|
72
|
+
handleCompositionStart() {
|
|
73
|
+
this.compositionStart = this.inputSelection.start;
|
|
74
|
+
}
|
|
75
|
+
handleCompositionEnd({ data }) {
|
|
76
|
+
const start = this.compositionStart, end = this.inputSelection.end;
|
|
77
|
+
this.updateInput(data, start, end);
|
|
78
|
+
}
|
|
79
|
+
handleInput({ inputType, isComposing }) {
|
|
80
|
+
const value = this.input.value;
|
|
81
|
+
const start = this.selection.start;
|
|
82
|
+
let end = this.selection.end;
|
|
83
|
+
switch (inputType) {
|
|
84
|
+
case 'deleteContentForward':
|
|
85
|
+
this.updateInput('', start, (end = start === end ? ++end : end));
|
|
86
|
+
return this.updateComplete.then(() => this.input.setSelectionRange(end, end));
|
|
87
|
+
case 'deleteContentBackward':
|
|
88
|
+
if (isComposing)
|
|
89
|
+
return;
|
|
90
|
+
return this.updateInput('', this.inputSelection.start, end);
|
|
91
|
+
case 'deleteByCut':
|
|
92
|
+
return this.updateInput('', start, end);
|
|
93
|
+
case 'insertText':
|
|
94
|
+
return this.updateInput(value.substring(start, this.inputSelection.end), start, end);
|
|
95
|
+
case 'insertFromPaste':
|
|
96
|
+
return this.updateInput(value.substring(start, this.inputSelection.end), start, this.inputSelection.start);
|
|
97
|
+
case 'insertFromDrop':
|
|
98
|
+
return this.updateInput(value.substring(this.inputSelection.start, this.inputSelection.end), this.inputSelection.start, this.inputSelection.end);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
updateInput(part, start, finish) {
|
|
102
|
+
const { value, end } = this.parser.replace(this.maskedValue, part, start, finish);
|
|
103
|
+
this.maskedValue = value;
|
|
104
|
+
this._value = this.parser.parse(value);
|
|
105
|
+
this.requestUpdate();
|
|
106
|
+
if (start !== this.mask.length) {
|
|
107
|
+
this.emitEvent('igcInput', { detail: this.value });
|
|
108
|
+
}
|
|
109
|
+
this.updateComplete.then(() => this.input.setSelectionRange(end, end));
|
|
110
|
+
}
|
|
111
|
+
handleCut() {
|
|
112
|
+
this.selection = this.inputSelection;
|
|
113
|
+
}
|
|
114
|
+
handleDragStart() {
|
|
115
|
+
this.selection = this.inputSelection;
|
|
116
|
+
}
|
|
117
|
+
handleDragEnter() {
|
|
118
|
+
if (!this.hasFocus && !this._value) {
|
|
119
|
+
this.maskedValue = this.parser.apply();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
handleDragLeave() {
|
|
123
|
+
if (!this.hasFocus) {
|
|
124
|
+
this.updateMaskedValue();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
handleFocus() {
|
|
128
|
+
this.hasFocus = true;
|
|
129
|
+
super.handleFocus();
|
|
130
|
+
if (this.readonly) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (!this._value) {
|
|
134
|
+
this.maskedValue = this.parser.apply();
|
|
135
|
+
this.updateComplete.then(() => this.select());
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
handleBlur() {
|
|
139
|
+
this.hasFocus = false;
|
|
140
|
+
this.updateMaskedValue();
|
|
141
|
+
super.handleBlur();
|
|
142
|
+
}
|
|
143
|
+
handleChange() {
|
|
144
|
+
this.emitEvent('igcChange', { detail: this.value });
|
|
145
|
+
this.invalid = !this.checkValidity();
|
|
146
|
+
}
|
|
147
|
+
handleInvalid() {
|
|
148
|
+
this.invalid = true;
|
|
149
|
+
}
|
|
150
|
+
handleClick() {
|
|
151
|
+
if (this.input.selectionStart === this.input.selectionEnd &&
|
|
152
|
+
this.input.selectionStart === this.maskedValue.length) {
|
|
153
|
+
this.select();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
updateMaskedValue() {
|
|
157
|
+
if (this.maskedValue === this.parser.apply()) {
|
|
158
|
+
this.maskedValue = '';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
setRangeText(replacement, start, end, _selectMode = 'preserve') {
|
|
162
|
+
this.input.value = this.parser.replace(this.input.value, replacement, start, end).value;
|
|
163
|
+
this.maskedValue = this.parser.apply(this.parser.parse(this.input.value));
|
|
164
|
+
this._value = this.parser.parse(this.maskedValue);
|
|
165
|
+
}
|
|
166
|
+
setSelectionRange(start, end, direction) {
|
|
167
|
+
super.setSelectionRange(start, end, direction);
|
|
168
|
+
this.selection = { start, end };
|
|
169
|
+
}
|
|
170
|
+
reportValidity() {
|
|
171
|
+
const state = this._value
|
|
172
|
+
? this.parser.isValidString(this.input.value)
|
|
173
|
+
: this.input.reportValidity();
|
|
174
|
+
this.invalid = !state;
|
|
175
|
+
return state;
|
|
176
|
+
}
|
|
177
|
+
setCustomValidity(message) {
|
|
178
|
+
this.input.setCustomValidity(message);
|
|
179
|
+
this.invalid = !this.input.checkValidity();
|
|
180
|
+
}
|
|
181
|
+
checkValidity() {
|
|
182
|
+
if (this.disabled) {
|
|
183
|
+
return this.input.checkValidity();
|
|
184
|
+
}
|
|
185
|
+
if (!this._value) {
|
|
186
|
+
return !this.required;
|
|
187
|
+
}
|
|
188
|
+
return (this.input.checkValidity() && this.parser.isValidString(this.input.value));
|
|
189
|
+
}
|
|
190
|
+
select() {
|
|
191
|
+
this.input.select();
|
|
192
|
+
}
|
|
193
|
+
renderInput() {
|
|
194
|
+
var _a;
|
|
195
|
+
return html `
|
|
196
|
+
<input
|
|
197
|
+
type="text"
|
|
198
|
+
part=${partNameMap(this.resolvePartNames('input'))}
|
|
199
|
+
name=${ifDefined(this.name)}
|
|
200
|
+
.value=${live(this.maskedValue)}
|
|
201
|
+
.placeholder=${live((_a = this.placeholder) !== null && _a !== void 0 ? _a : this.parser.escapedMask)}
|
|
202
|
+
?readonly=${this.readonly}
|
|
203
|
+
?disabled=${this.disabled}
|
|
204
|
+
?required=${this.required}
|
|
205
|
+
@dragenter=${this.handleDragEnter}
|
|
206
|
+
@dragleave=${this.handleDragLeave}
|
|
207
|
+
@dragstart=${this.handleDragStart}
|
|
208
|
+
@blur=${this.handleBlur}
|
|
209
|
+
@focus=${this.handleFocus}
|
|
210
|
+
@cut=${this.handleCut}
|
|
211
|
+
@change=${this.handleChange}
|
|
212
|
+
@click=${this.handleClick}
|
|
213
|
+
@compositionstart=${this.handleCompositionStart}
|
|
214
|
+
@compositionend=${this.handleCompositionEnd}
|
|
215
|
+
@input=${this.handleInput}
|
|
216
|
+
aria-invalid="${this.invalid ? 'true' : 'false'}"
|
|
217
|
+
@invalid="${this.handleInvalid}"
|
|
218
|
+
@keydown=${this.handleKeydown}
|
|
219
|
+
/>
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
IgcMaskInputComponent.tagName = 'igc-mask-input';
|
|
224
|
+
__decorate([
|
|
225
|
+
state()
|
|
226
|
+
], IgcMaskInputComponent.prototype, "hasFocus", void 0);
|
|
227
|
+
__decorate([
|
|
228
|
+
state()
|
|
229
|
+
], IgcMaskInputComponent.prototype, "maskedValue", void 0);
|
|
230
|
+
__decorate([
|
|
231
|
+
property({ reflect: true })
|
|
232
|
+
], IgcMaskInputComponent.prototype, "dir", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
property({ reflect: true, type: Boolean })
|
|
235
|
+
], IgcMaskInputComponent.prototype, "invalid", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
property({ attribute: 'value-mode' })
|
|
238
|
+
], IgcMaskInputComponent.prototype, "valueMode", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
property(),
|
|
241
|
+
blazorTwoWayBind('igcChange', 'detail')
|
|
242
|
+
], IgcMaskInputComponent.prototype, "value", null);
|
|
243
|
+
__decorate([
|
|
244
|
+
property()
|
|
245
|
+
], IgcMaskInputComponent.prototype, "mask", void 0);
|
|
246
|
+
__decorate([
|
|
247
|
+
property()
|
|
248
|
+
], IgcMaskInputComponent.prototype, "prompt", void 0);
|
|
249
|
+
__decorate([
|
|
250
|
+
watch('prompt')
|
|
251
|
+
], IgcMaskInputComponent.prototype, "promptChange", null);
|
|
252
|
+
__decorate([
|
|
253
|
+
watch('mask')
|
|
254
|
+
], IgcMaskInputComponent.prototype, "maskChange", null);
|
|
255
|
+
__decorate([
|
|
256
|
+
watch('required', { waitUntilFirstUpdate: true }),
|
|
257
|
+
watch('disabled', { waitUntilFirstUpdate: true }),
|
|
258
|
+
watch('value', { waitUntilFirstUpdate: true })
|
|
259
|
+
], IgcMaskInputComponent.prototype, "handleInvalidState", null);
|
|
260
|
+
//# sourceMappingURL=mask-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask-input.js","sourceRoot":"","sources":["../../../src/components/mask-input/mask-input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA6B9C,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,qBAAqB;IAAxE;;QAGY,WAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC1B,WAAM,GAAG,EAAE,CAAC;QACZ,cAAS,GAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;QAChD,qBAAgB,GAAG,CAAC,CAAC;QAGrB,aAAQ,GAAG,KAAK,CAAC;QAGjB,gBAAW,GAAG,EAAE,CAAC;QAWX,QAAG,GAA2B,MAAM,CAAC;QAI9C,YAAO,GAAG,KAAK,CAAC;QAUhB,cAAS,GAA6B,KAAK,CAAC;IAuSrD,CAAC;IA9TC,IAAc,cAAc;QAC1B,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,IAAI,CAAC;YACrC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAA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oB,EAAE,IAAI,EAAE,CAAC;+DAG9C","sourcesContent":["import { html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { watch } from '../common/decorators/watch.js';\nimport { blazorTwoWayBind } from '../common/decorators/blazorTwoWayBind.js';\nimport { partNameMap } from '../common/util.js';\nimport { IgcInputBaseComponent } from '../input/input-base.js';\nimport { MaskParser } from './mask-parser.js';\n\ninterface MaskSelection {\n start: number;\n end: number;\n}\n\n/**\n * A masked input is an input field where a developer can control user input and format the visible value,\n * based on configurable rules\n *\n * @element igc-mask-input\n *\n * @slot prefix - Renders content before the input\n * @slot suffix - Renders content after the input\n * @slot helper-text - Renders content below the input\n *\n * @fires igcInput - Emitted when the control receives user input\n * @fires igcChange - Emitted when an alteration of the control's value is committed by the user\n * @fires igcFocus - Emitted when the control gains focus\n * @fires igcBlur - Emitted when the control loses focus\n *\n * @csspart container - The main wrapper that holds all main input elements\n * @csspart input - The native input element\n * @csspart label - The native label element\n * @csspart prefix - The prefix wrapper\n * @csspart suffix - The suffix wrapper\n * @csspart helper-text - The helper text wrapper\n */\nexport default class IgcMaskInputComponent extends IgcInputBaseComponent {\n public static readonly tagName = 'igc-mask-input';\n\n protected parser = new MaskParser();\n protected _value = '';\n protected selection: MaskSelection = { start: 0, end: 0 };\n protected compositionStart = 0;\n\n @state()\n protected hasFocus = false;\n\n @state()\n protected maskedValue = '';\n\n protected get inputSelection(): MaskSelection {\n return {\n start: this.input.selectionStart || 0,\n end: this.input.selectionEnd || 0,\n };\n }\n\n /** The direction attribute of the control. */\n @property({ reflect: true })\n public override dir: 'ltr' | 'rtl' | 'auto' = 'auto';\n\n /** Controls the validity of the control. */\n @property({ reflect: true, type: Boolean })\n public invalid = false;\n\n /**\n * Dictates the behavior when retrieving the value of the control:\n *\n * - `raw` will return the clean user input.\n * - `withFormatting` will return the value with all literals and prompts.\n *\n */\n @property({ attribute: 'value-mode' })\n public valueMode: 'raw' | 'withFormatting' = 'raw';\n\n /**\n * The value of the input.\n *\n * Regardless of the currently set `value-mode`, an empty value will return an empty string.\n *\n */\n @property()\n @blazorTwoWayBind('igcChange', 'detail')\n public get value() {\n return this._value\n ? this.valueMode !== 'raw'\n ? this.maskedValue\n : this._value\n : this._value;\n }\n\n public set value(string: string) {\n this._value = string ?? '';\n this.maskedValue = this.parser.apply(this._value);\n }\n\n /** The mask pattern to apply on the input. */\n @property()\n public mask!: string;\n\n /** The prompt symbol to use for unfilled parts of the mask. */\n @property()\n public prompt!: string;\n\n @watch('prompt')\n protected promptChange() {\n this.parser.prompt = this.prompt;\n if (this.value) {\n this.maskedValue = this.parser.apply(this._value);\n }\n }\n\n @watch('mask')\n protected maskChange() {\n this.parser.mask = this.mask;\n if (this.value) {\n this.maskedValue = this.parser.apply(this._value);\n }\n }\n\n @watch('required', { waitUntilFirstUpdate: true })\n @watch('disabled', { waitUntilFirstUpdate: true })\n @watch('value', { waitUntilFirstUpdate: true })\n protected handleInvalidState() {\n this.updateComplete.then(() => (this.invalid = !this.checkValidity()));\n }\n\n public override connectedCallback() {\n super.connectedCallback();\n\n this.mask = this.mask || this.parser.mask;\n this.prompt = this.prompt || this.parser.prompt;\n }\n\n protected handleKeydown(e: KeyboardEvent) {\n if (!e.key) {\n return;\n }\n this.selection = this.inputSelection;\n }\n\n protected handleCompositionStart() {\n this.compositionStart = this.inputSelection.start;\n }\n\n protected handleCompositionEnd({ data }: CompositionEvent) {\n const start = this.compositionStart,\n end = this.inputSelection.end;\n this.updateInput(data, start, end);\n }\n\n protected handleInput({ inputType, isComposing }: InputEvent) {\n const value = this.input.value;\n const start = this.selection.start;\n let end = this.selection.end;\n\n switch (inputType) {\n case 'deleteContentForward':\n this.updateInput('', start, (end = start === end ? ++end : end));\n return this.updateComplete.then(() =>\n this.input.setSelectionRange(end, end)\n );\n\n case 'deleteContentBackward':\n if (isComposing) return;\n return this.updateInput('', this.inputSelection.start, end);\n\n case 'deleteByCut':\n return this.updateInput('', start, end);\n\n case 'insertText':\n return this.updateInput(\n value.substring(start, this.inputSelection.end),\n start,\n end\n );\n\n case 'insertFromPaste':\n return this.updateInput(\n value.substring(start, this.inputSelection.end),\n start,\n this.inputSelection.start\n );\n\n case 'insertFromDrop':\n return this.updateInput(\n value.substring(this.inputSelection.start, this.inputSelection.end),\n this.inputSelection.start,\n this.inputSelection.end\n );\n }\n }\n\n protected updateInput(part: string, start: number, finish: number) {\n const { value, end } = this.parser.replace(\n this.maskedValue,\n part,\n start,\n finish\n );\n this.maskedValue = value;\n this._value = this.parser.parse(value);\n\n this.requestUpdate();\n if (start !== this.mask.length) {\n this.emitEvent('igcInput', { detail: this.value });\n }\n this.updateComplete.then(() => this.input.setSelectionRange(end, end));\n }\n\n protected handleCut() {\n this.selection = this.inputSelection;\n }\n\n protected handleDragStart() {\n this.selection = this.inputSelection;\n }\n\n protected handleDragEnter() {\n if (!this.hasFocus && !this._value) {\n this.maskedValue = this.parser.apply();\n }\n }\n\n protected handleDragLeave() {\n if (!this.hasFocus) {\n this.updateMaskedValue();\n }\n }\n\n protected override handleFocus() {\n this.hasFocus = true;\n super.handleFocus();\n\n if (this.readonly) {\n return;\n }\n\n if (!this._value) {\n this.maskedValue = this.parser.apply();\n // In case of empty value, select the whole mask\n this.updateComplete.then(() => this.select());\n }\n }\n\n protected override handleBlur() {\n this.hasFocus = false;\n this.updateMaskedValue();\n super.handleBlur();\n }\n\n protected override handleChange() {\n this.emitEvent('igcChange', { detail: this.value });\n this.invalid = !this.checkValidity();\n }\n\n protected handleInvalid() {\n this.invalid = true;\n }\n\n protected handleClick() {\n // Clicking at the end of the input field will select the entire mask\n if (\n this.input.selectionStart === this.input.selectionEnd &&\n this.input.selectionStart === this.maskedValue.length\n ) {\n this.select();\n }\n }\n\n protected updateMaskedValue() {\n if (this.maskedValue === this.parser.apply()) {\n this.maskedValue = '';\n }\n }\n\n /** Replaces the selected text in the control and re-applies the mask */\n public override setRangeText(\n replacement: string,\n start: number,\n end: number,\n _selectMode: 'select' | 'start' | 'end' | 'preserve' = 'preserve'\n ) {\n this.input.value = this.parser.replace(\n this.input.value,\n replacement,\n start,\n end\n ).value;\n this.maskedValue = this.parser.apply(this.parser.parse(this.input.value));\n this._value = this.parser.parse(this.maskedValue);\n }\n\n public override setSelectionRange(\n start: number,\n end: number,\n direction?: 'backward' | 'forward' | 'none'\n ): void {\n super.setSelectionRange(start, end, direction);\n this.selection = { start, end };\n }\n\n /** Checks for validity of the control and shows the browser message if it's invalid. */\n public reportValidity() {\n const state = this._value\n ? this.parser.isValidString(this.input.value)\n : this.input.reportValidity();\n this.invalid = !state;\n return state;\n }\n\n /**\n * Sets a custom validation message for the control.\n * As long as `message` is not empty, the control is considered invalid.\n */\n public setCustomValidity(message: string) {\n this.input.setCustomValidity(message);\n this.invalid = !this.input.checkValidity();\n }\n\n /** Check for validity of the control */\n public checkValidity() {\n if (this.disabled) {\n return this.input.checkValidity();\n }\n\n if (!this._value) {\n return !this.required;\n }\n\n return (\n this.input.checkValidity() && this.parser.isValidString(this.input.value)\n );\n }\n\n /** Selects all text within the input. */\n public select() {\n this.input.select();\n }\n\n protected override renderInput() {\n return html`\n <input\n type=\"text\"\n part=${partNameMap(this.resolvePartNames('input'))}\n name=${ifDefined(this.name)}\n .value=${live(this.maskedValue)}\n .placeholder=${live(this.placeholder ?? this.parser.escapedMask)}\n ?readonly=${this.readonly}\n ?disabled=${this.disabled}\n ?required=${this.required}\n @dragenter=${this.handleDragEnter}\n @dragleave=${this.handleDragLeave}\n @dragstart=${this.handleDragStart}\n @blur=${this.handleBlur}\n @focus=${this.handleFocus}\n @cut=${this.handleCut}\n @change=${this.handleChange}\n @click=${this.handleClick}\n @compositionstart=${this.handleCompositionStart}\n @compositionend=${this.handleCompositionEnd}\n @input=${this.handleInput}\n aria-invalid=\"${this.invalid ? 'true' : 'false'}\"\n @invalid=\"${this.handleInvalid}\"\n @keydown=${this.handleKeydown}\n />\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-mask-input': IgcMaskInputComponent;\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface MaskOptions {
|
|
2
|
+
format: string;
|
|
3
|
+
promptCharacter: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class MaskParser {
|
|
6
|
+
protected options: MaskOptions;
|
|
7
|
+
constructor(options?: MaskOptions);
|
|
8
|
+
protected literals: Map<number, string>;
|
|
9
|
+
protected _escapedMask: string;
|
|
10
|
+
protected get literalPositions(): number[];
|
|
11
|
+
get escapedMask(): string;
|
|
12
|
+
get mask(): string;
|
|
13
|
+
set mask(value: string);
|
|
14
|
+
get prompt(): string;
|
|
15
|
+
set prompt(value: string);
|
|
16
|
+
protected getMaskLiterals(): void;
|
|
17
|
+
protected isPromptChar(char: string): boolean;
|
|
18
|
+
protected replaceCharAt(string: string, pos: number, char: string): string;
|
|
19
|
+
protected validate(char: string, maskedChar: string): boolean;
|
|
20
|
+
protected getNonLiteralPositions(mask?: string): number[];
|
|
21
|
+
protected getRequiredNonLiteralPositions(mask: string): number[];
|
|
22
|
+
replace(masked: string | undefined, value: string, start: number, end: number): {
|
|
23
|
+
value: string;
|
|
24
|
+
end: number;
|
|
25
|
+
};
|
|
26
|
+
parse(masked?: string): string;
|
|
27
|
+
isValidString(input?: string): boolean;
|
|
28
|
+
apply(input?: string): string;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
const FLAGS = new Set('aACL09#&?');
|
|
2
|
+
const REGEX = new Map([
|
|
3
|
+
['C', /(?!^$)/u],
|
|
4
|
+
['&', /[^\p{Separator}]/u],
|
|
5
|
+
['a', /[\p{Letter}\d\p{Separator}]/u],
|
|
6
|
+
['A', /[\p{Letter}\d]/u],
|
|
7
|
+
['?', /[\p{Letter}\p{Separator}]/u],
|
|
8
|
+
['L', /\p{Letter}/u],
|
|
9
|
+
['0', /\d/],
|
|
10
|
+
['9', /[\d\p{Separator}]/u],
|
|
11
|
+
['#', /[\d\-+]/],
|
|
12
|
+
]);
|
|
13
|
+
const REQUIRED = new Set('0#LA&');
|
|
14
|
+
const replaceIMENumbers = (string) => {
|
|
15
|
+
return string.replace(/[0123456789]/g, (num) => ({
|
|
16
|
+
'1': '1',
|
|
17
|
+
'2': '2',
|
|
18
|
+
'3': '3',
|
|
19
|
+
'4': '4',
|
|
20
|
+
'5': '5',
|
|
21
|
+
'6': '6',
|
|
22
|
+
'7': '7',
|
|
23
|
+
'8': '8',
|
|
24
|
+
'9': '9',
|
|
25
|
+
'0': '0',
|
|
26
|
+
}[num]));
|
|
27
|
+
};
|
|
28
|
+
export class MaskParser {
|
|
29
|
+
constructor(options = { format: 'CCCCCCCCCC', promptCharacter: '_' }) {
|
|
30
|
+
this.literals = new Map();
|
|
31
|
+
this.options = options;
|
|
32
|
+
}
|
|
33
|
+
get literalPositions() {
|
|
34
|
+
this.getMaskLiterals();
|
|
35
|
+
return Array.from(this.literals.keys());
|
|
36
|
+
}
|
|
37
|
+
get escapedMask() {
|
|
38
|
+
this.getMaskLiterals();
|
|
39
|
+
return this._escapedMask;
|
|
40
|
+
}
|
|
41
|
+
get mask() {
|
|
42
|
+
return this.options.format;
|
|
43
|
+
}
|
|
44
|
+
set mask(value) {
|
|
45
|
+
this.options.format = value || this.options.format;
|
|
46
|
+
this.getMaskLiterals();
|
|
47
|
+
}
|
|
48
|
+
get prompt() {
|
|
49
|
+
return this.options.promptCharacter;
|
|
50
|
+
}
|
|
51
|
+
set prompt(value) {
|
|
52
|
+
this.options.promptCharacter = value
|
|
53
|
+
? value.substring(0, 1)
|
|
54
|
+
: this.options.promptCharacter;
|
|
55
|
+
}
|
|
56
|
+
getMaskLiterals() {
|
|
57
|
+
this.literals.clear();
|
|
58
|
+
this._escapedMask = this.mask;
|
|
59
|
+
for (let i = 0, j = 0; i < this.mask.length; i++, j++) {
|
|
60
|
+
const [current, next] = [this.mask.charAt(i), this.mask.charAt(i + 1)];
|
|
61
|
+
if (current === '\\' && FLAGS.has(next)) {
|
|
62
|
+
this._escapedMask = this.replaceCharAt(this._escapedMask, j, '');
|
|
63
|
+
this.literals.set(j, next);
|
|
64
|
+
i++;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
if (!FLAGS.has(current)) {
|
|
68
|
+
this.literals.set(j, current);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
isPromptChar(char) {
|
|
74
|
+
return char === this.prompt;
|
|
75
|
+
}
|
|
76
|
+
replaceCharAt(string, pos, char) {
|
|
77
|
+
return `${string.substring(0, pos)}${char}${string.substring(pos + 1)}`;
|
|
78
|
+
}
|
|
79
|
+
validate(char, maskedChar) {
|
|
80
|
+
const regex = REGEX.get(maskedChar);
|
|
81
|
+
return regex ? regex.test(char) : false;
|
|
82
|
+
}
|
|
83
|
+
getNonLiteralPositions(mask = '') {
|
|
84
|
+
const positions = this.literalPositions;
|
|
85
|
+
return Array.from(mask)
|
|
86
|
+
.map((_, pos) => (!positions.includes(pos) ? pos : -1))
|
|
87
|
+
.filter((pos) => pos > -1);
|
|
88
|
+
}
|
|
89
|
+
getRequiredNonLiteralPositions(mask) {
|
|
90
|
+
const positions = this.literalPositions;
|
|
91
|
+
return Array.from(mask)
|
|
92
|
+
.map((char, pos) => REQUIRED.has(char) && !positions.includes(pos) ? pos : -1)
|
|
93
|
+
.filter((pos) => pos > -1);
|
|
94
|
+
}
|
|
95
|
+
replace(masked = '', value, start, end) {
|
|
96
|
+
const chars = Array.from(replaceIMENumbers(value));
|
|
97
|
+
const positions = this.literalPositions;
|
|
98
|
+
end = Math.min(end, masked.length);
|
|
99
|
+
let cursor = start;
|
|
100
|
+
for (let i = start; i < end || (chars.length && i < masked.length); i++) {
|
|
101
|
+
if (positions.includes(i)) {
|
|
102
|
+
if (chars[0] === masked[i]) {
|
|
103
|
+
cursor = i + 1;
|
|
104
|
+
chars.shift();
|
|
105
|
+
}
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (chars[0] &&
|
|
109
|
+
!this.validate(chars[0], this._escapedMask[i]) &&
|
|
110
|
+
!this.isPromptChar(chars[0])) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
let char = this.prompt;
|
|
114
|
+
if (chars.length) {
|
|
115
|
+
cursor = i + 1;
|
|
116
|
+
char = chars.shift();
|
|
117
|
+
}
|
|
118
|
+
masked = this.replaceCharAt(masked, i, char);
|
|
119
|
+
}
|
|
120
|
+
return { value: masked, end: cursor };
|
|
121
|
+
}
|
|
122
|
+
parse(masked = '') {
|
|
123
|
+
return Array.from(masked).reduce((prev, char, pos) => {
|
|
124
|
+
return `${prev}${!this.literalPositions.includes(pos) && !this.isPromptChar(char)
|
|
125
|
+
? char
|
|
126
|
+
: ''}`;
|
|
127
|
+
}, '');
|
|
128
|
+
}
|
|
129
|
+
isValidString(input = '') {
|
|
130
|
+
const required = this.getRequiredNonLiteralPositions(this._escapedMask);
|
|
131
|
+
if (required.length > this.parse(input).length) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return required.every((pos) => {
|
|
135
|
+
const char = input.charAt(pos);
|
|
136
|
+
return (char !== undefined &&
|
|
137
|
+
this.validate(char, this._escapedMask.charAt(pos)) &&
|
|
138
|
+
!this.isPromptChar(char));
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
apply(input = '') {
|
|
142
|
+
const nonLiteralPositions = this.getNonLiteralPositions(this._escapedMask);
|
|
143
|
+
let output = new Array(this._escapedMask.length).fill(this.prompt).join('');
|
|
144
|
+
this.literals.forEach((char, pos) => {
|
|
145
|
+
output = this.replaceCharAt(output, pos, char);
|
|
146
|
+
});
|
|
147
|
+
if (!input) {
|
|
148
|
+
return output;
|
|
149
|
+
}
|
|
150
|
+
const values = nonLiteralPositions.map((pos, index) => {
|
|
151
|
+
const char = input.charAt(index);
|
|
152
|
+
return !this.validate(char, this._escapedMask.charAt(pos)) &&
|
|
153
|
+
!this.isPromptChar(char)
|
|
154
|
+
? this.prompt
|
|
155
|
+
: char;
|
|
156
|
+
});
|
|
157
|
+
if (values.length > nonLiteralPositions.length) {
|
|
158
|
+
values.splice(nonLiteralPositions.length);
|
|
159
|
+
}
|
|
160
|
+
let pos = 0;
|
|
161
|
+
for (const each of values) {
|
|
162
|
+
output = this.replaceCharAt(output, nonLiteralPositions[pos++], each);
|
|
163
|
+
}
|
|
164
|
+
return output;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=mask-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask-parser.js","sourceRoot":"","sources":["../../../src/components/mask-input/mask-parser.ts"],"names":[],"mappings":"AAKA,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;AACnC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC;IACpB,CAAC,GAAG,EAAE,SAAS,CAAC;IAChB,CAAC,GAAG,EAAE,mBAAmB,CAAC;IAC1B,CAAC,GAAG,EAAE,8BAA8B,CAAC;IACrC,CAAC,GAAG,EAAE,iBAAiB,CAAC;IACxB,CAAC,GAAG,EAAE,4BAA4B,CAAC;IACnC,CAAC,GAAG,EAAE,aAAa,CAAC;IACpB,CAAC,GAAG,EAAE,IAAI,CAAC;IACX,CAAC,GAAG,EAAE,oBAAoB,CAAC;IAC3B,CAAC,GAAG,EAAE,SAAS,CAAC;CACjB,CAAC,CAAC;AACH,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;AAElC,MAAM,iBAAiB,GAAG,CAAC,MAAc,EAAE,EAAE;IAC3C,OAAO,MAAM,CAAC,OAAO,CACnB,eAAe,EACf,CAAC,GAAG,EAAE,EAAE,CACN,CAAC;QACC,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG;QACR,GAAG,EAA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CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,MAAM,CAAC;SACf;QAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACpD,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACxD,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC;gBACxB,CAAC,CAAC,IAAI,CAAC,MAAM;gBACb,CAAC,CAAC,IAAI,CAAC;QACX,CAAC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,EAAE;YAC9C,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;SAC3C;QAED,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;YACzB,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;SACvE;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["interface MaskOptions {\n format: string;\n promptCharacter: string;\n}\n\nconst FLAGS = new Set('aACL09#&?');\nconst REGEX = new Map([\n ['C', /(?!^$)/u], // Non-empty\n ['&', /[^\\p{Separator}]/u], // Whitespace\n ['a', /[\\p{Letter}\\d\\p{Separator}]/u], // Alphanumeric & whitespace\n ['A', /[\\p{Letter}\\d]/u], // Alphanumeric\n ['?', /[\\p{Letter}\\p{Separator}]/u], // Alpha & whitespace\n ['L', /\\p{Letter}/u], // Alpha\n ['0', /\\d/], // Numeric\n ['9', /[\\d\\p{Separator}]/u], // Numeric & whitespace\n ['#', /[\\d\\-+]/], // Numeric and sign\n]);\nconst REQUIRED = new Set('0#LA&');\n\nconst replaceIMENumbers = (string: string) => {\n return string.replace(\n /[0123456789]/g,\n (num) =>\n ({\n '1': '1',\n '2': '2',\n '3': '3',\n '4': '4',\n '5': '5',\n '6': '6',\n '7': '7',\n '8': '8',\n '9': '9',\n '0': '0',\n }[num] as string)\n );\n};\n\nexport class MaskParser {\n protected options!: MaskOptions;\n\n constructor(\n options: MaskOptions = { format: 'CCCCCCCCCC', promptCharacter: '_' }\n ) {\n this.options = options;\n }\n\n protected literals = new Map<number, string>();\n protected _escapedMask!: string;\n\n protected get literalPositions() {\n this.getMaskLiterals();\n return Array.from(this.literals.keys());\n }\n\n public get escapedMask() {\n this.getMaskLiterals();\n return this._escapedMask;\n }\n\n public get mask() {\n return this.options.format;\n }\n\n public set mask(value: string) {\n this.options.format = value || this.options.format;\n this.getMaskLiterals();\n }\n\n public get prompt() {\n return this.options.promptCharacter;\n }\n\n public set prompt(value: string) {\n this.options.promptCharacter = value\n ? value.substring(0, 1)\n : this.options.promptCharacter;\n }\n\n protected getMaskLiterals() {\n this.literals.clear();\n this._escapedMask = this.mask;\n\n for (let i = 0, j = 0; i < this.mask.length; i++, j++) {\n const [current, next] = [this.mask.charAt(i), this.mask.charAt(i + 1)];\n\n if (current === '\\\\' && FLAGS.has(next)) {\n this._escapedMask = this.replaceCharAt(this._escapedMask, j, '');\n this.literals.set(j, next);\n i++;\n } else {\n if (!FLAGS.has(current)) {\n this.literals.set(j, current);\n }\n }\n }\n }\n\n protected isPromptChar(char: string) {\n return char === this.prompt;\n }\n\n protected replaceCharAt(string: string, pos: number, char: string) {\n return `${string.substring(0, pos)}${char}${string.substring(pos + 1)}`;\n }\n\n protected validate(char: string, maskedChar: string) {\n const regex = REGEX.get(maskedChar);\n return regex ? regex.test(char) : false;\n }\n\n protected getNonLiteralPositions(mask = '') {\n const positions = this.literalPositions;\n return Array.from(mask)\n .map((_, pos) => (!positions.includes(pos) ? pos : -1))\n .filter((pos) => pos > -1);\n }\n\n protected getRequiredNonLiteralPositions(mask: string) {\n const positions = this.literalPositions;\n return Array.from(mask)\n .map((char, pos) =>\n REQUIRED.has(char) && !positions.includes(pos) ? pos : -1\n )\n .filter((pos) => pos > -1);\n }\n\n public replace(masked = '', value: string, start: number, end: number) {\n const chars = Array.from(replaceIMENumbers(value));\n const positions = this.literalPositions;\n end = Math.min(end, masked.length);\n let cursor = start;\n\n for (let i = start; i < end || (chars.length && i < masked.length); i++) {\n if (positions.includes(i)) {\n if (chars[0] === masked[i]) {\n cursor = i + 1;\n chars.shift();\n }\n continue;\n }\n\n if (\n chars[0] &&\n !this.validate(chars[0], this._escapedMask[i]) &&\n !this.isPromptChar(chars[0])\n ) {\n break;\n }\n\n let char = this.prompt;\n if (chars.length) {\n cursor = i + 1;\n char = chars.shift() as string;\n }\n masked = this.replaceCharAt(masked, i, char);\n }\n\n return { value: masked, end: cursor };\n }\n\n public parse(masked = '') {\n return Array.from(masked).reduce((prev, char, pos) => {\n return `${prev}${\n !this.literalPositions.includes(pos) && !this.isPromptChar(char)\n ? char\n : ''\n }`;\n }, '');\n }\n\n public isValidString(input = '') {\n const required = this.getRequiredNonLiteralPositions(this._escapedMask);\n\n if (required.length > this.parse(input).length) {\n return false;\n }\n return required.every((pos) => {\n const char = input.charAt(pos);\n return (\n char !== undefined &&\n this.validate(char, this._escapedMask.charAt(pos)) &&\n !this.isPromptChar(char)\n );\n });\n }\n\n public apply(input = '') {\n const nonLiteralPositions = this.getNonLiteralPositions(this._escapedMask);\n let output = new Array(this._escapedMask.length).fill(this.prompt).join('');\n\n this.literals.forEach((char, pos) => {\n output = this.replaceCharAt(output, pos, char);\n });\n\n if (!input) {\n return output;\n }\n\n const values = nonLiteralPositions.map((pos, index) => {\n const char = input.charAt(index);\n return !this.validate(char, this._escapedMask.charAt(pos)) &&\n !this.isPromptChar(char)\n ? this.prompt\n : char;\n });\n\n if (values.length > nonLiteralPositions.length) {\n values.splice(nonLiteralPositions.length);\n }\n\n let pos = 0;\n for (const each of values) {\n output = this.replaceCharAt(output, nonLiteralPositions[pos++], each);\n }\n\n return output;\n }\n}\n"]}
|
|
@@ -20,6 +20,7 @@ export default class IgcNavDrawerItemComponent extends LitElement {
|
|
|
20
20
|
active: boolean;
|
|
21
21
|
private _textLength;
|
|
22
22
|
private _text;
|
|
23
|
+
protected navdrawerIcon: Array<Node>;
|
|
23
24
|
connectedCallback(): void;
|
|
24
25
|
protected resolvePartNames(base: string): {
|
|
25
26
|
[x: string]: boolean;
|