igniteui-webcomponents 4.1.0-alpha.1 → 4.1.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/components/combo/themes/light/combo.base.css.js +4 -0
  3. package/components/combo/themes/light/combo.base.css.js.map +1 -1
  4. package/components/date-time-input/date-time-input.d.ts +2 -2
  5. package/components/date-time-input/date-time-input.js +6 -5
  6. package/components/date-time-input/date-time-input.js.map +1 -1
  7. package/components/input/themes/light/input.base.css.js +7 -0
  8. package/components/input/themes/light/input.base.css.js.map +1 -1
  9. package/components/input/themes/light/input.bootstrap.css.js +2 -1
  10. package/components/input/themes/light/input.bootstrap.css.js.map +1 -1
  11. package/components/input/themes/light/input.fluent.css.js +0 -4
  12. package/components/input/themes/light/input.fluent.css.js.map +1 -1
  13. package/components/input/themes/light/input.indigo.css.js +1 -2
  14. package/components/input/themes/light/input.indigo.css.js.map +1 -1
  15. package/components/input/themes/light/input.material.css.js +5 -3
  16. package/components/input/themes/light/input.material.css.js.map +1 -1
  17. package/components/mask-input/mask-input-base.d.ts +6 -7
  18. package/components/mask-input/mask-input-base.js +22 -13
  19. package/components/mask-input/mask-input-base.js.map +1 -1
  20. package/components/mask-input/mask-input.d.ts +5 -7
  21. package/components/mask-input/mask-input.js +17 -23
  22. package/components/mask-input/mask-input.js.map +1 -1
  23. package/components/mask-input/mask-parser.d.ts +3 -1
  24. package/components/mask-input/mask-parser.js +16 -0
  25. package/components/mask-input/mask-parser.js.map +1 -1
  26. package/components/select/select.d.ts +2 -2
  27. package/components/select/select.js +5 -4
  28. package/components/select/select.js.map +1 -1
  29. package/components/select/themes/light/select.base.css.js +4 -0
  30. package/components/select/themes/light/select.base.css.js.map +1 -1
  31. package/package.json +1 -1
  32. package/vscode-html-custom-data.json +2 -2
@@ -1,12 +1,12 @@
1
1
  import { IgcInputBaseComponent } from '../input/input-base.js';
2
2
  import { MaskParser } from './mask-parser.js';
3
- interface MaskSelection {
3
+ export type MaskRange = {
4
4
  start: number;
5
5
  end: number;
6
- }
6
+ };
7
7
  export declare abstract class IgcMaskInputBaseComponent extends IgcInputBaseComponent {
8
8
  protected parser: MaskParser;
9
- protected selection: MaskSelection;
9
+ protected selection: MaskRange;
10
10
  protected compositionStart: number;
11
11
  protected hasFocus: boolean;
12
12
  protected maskedValue: string;
@@ -15,7 +15,7 @@ export declare abstract class IgcMaskInputBaseComponent extends IgcInputBaseComp
15
15
  prompt: string;
16
16
  /** Controls the validity of the control. */
17
17
  invalid: boolean;
18
- protected get inputSelection(): MaskSelection;
18
+ protected get inputSelection(): MaskRange;
19
19
  protected get emptyMask(): string;
20
20
  connectedCallback(): void;
21
21
  /**
@@ -26,13 +26,12 @@ export declare abstract class IgcMaskInputBaseComponent extends IgcInputBaseComp
26
26
  /** Selects all text within the input. */
27
27
  select(): void;
28
28
  protected handleInput({ inputType, isComposing }: InputEvent): void | Promise<void>;
29
- protected handleKeydown(e: KeyboardEvent): void;
29
+ protected handleKeydown({ key }: KeyboardEvent): void;
30
30
  protected handleCut(): void;
31
31
  protected handleDragStart(): void;
32
32
  protected handleCompositionStart(): void;
33
33
  protected handleCompositionEnd({ data }: CompositionEvent): void;
34
34
  protected handleInvalid(): void;
35
35
  setSelectionRange(start: number, end: number, direction?: 'backward' | 'forward' | 'none'): void;
36
- protected abstract updateInput(part: string, start: number, finish: number): void;
36
+ protected abstract updateInput(string: string, range: MaskRange): void;
37
37
  }
38
- export {};
@@ -42,29 +42,36 @@ let IgcMaskInputBaseComponent = class IgcMaskInputBaseComponent extends IgcInput
42
42
  this.input.select();
43
43
  }
44
44
  handleInput({ inputType, isComposing }) {
45
+ const EMPTY = '';
45
46
  const value = this.input.value;
46
- const start = this.selection.start;
47
- let end = this.selection.end;
47
+ const { start, end } = this.selection;
48
+ const deleteEnd = this.parser.getNextNonLiteralPosition(end) + 1;
48
49
  switch (inputType) {
49
50
  case 'deleteContentForward':
50
- this.updateInput('', start, (end = start === end ? ++end : end));
51
- return this.updateComplete.then(() => this.input.setSelectionRange(end, end));
51
+ this.updateInput(EMPTY, { start, end: deleteEnd });
52
+ return this.updateComplete.then(() => this.input.setSelectionRange(deleteEnd, deleteEnd));
52
53
  case 'deleteContentBackward':
53
54
  if (isComposing)
54
55
  return;
55
- return this.updateInput('', this.inputSelection.start, end);
56
+ return this.updateInput(EMPTY, {
57
+ start: this.parser.getPreviousNonLiteralPosition(this.inputSelection.start),
58
+ end,
59
+ });
56
60
  case 'deleteByCut':
57
- return this.updateInput('', start, end);
61
+ return this.updateInput(EMPTY, this.selection);
58
62
  case 'insertText':
59
- return this.updateInput(value.substring(start, this.inputSelection.end), start, end);
63
+ return this.updateInput(value.substring(start, this.inputSelection.end), this.selection);
60
64
  case 'insertFromPaste':
61
- return this.updateInput(value.substring(start, this.inputSelection.end), start, this.inputSelection.start);
65
+ return this.updateInput(value.substring(start, this.inputSelection.end), {
66
+ start,
67
+ end: this.inputSelection.start,
68
+ });
62
69
  case 'insertFromDrop':
63
- return this.updateInput(value.substring(this.inputSelection.start, this.inputSelection.end), this.inputSelection.start, this.inputSelection.end);
70
+ return this.updateInput(value.substring(this.inputSelection.start, this.inputSelection.end), { ...this.inputSelection });
64
71
  }
65
72
  }
66
- handleKeydown(e) {
67
- if (!e.key) {
73
+ handleKeydown({ key }) {
74
+ if (!key) {
68
75
  return;
69
76
  }
70
77
  this.selection = this.inputSelection;
@@ -79,8 +86,10 @@ let IgcMaskInputBaseComponent = class IgcMaskInputBaseComponent extends IgcInput
79
86
  this.compositionStart = this.inputSelection.start;
80
87
  }
81
88
  handleCompositionEnd({ data }) {
82
- const start = this.compositionStart, end = this.inputSelection.end;
83
- this.updateInput(data, start, end);
89
+ this.updateInput(data, {
90
+ start: this.compositionStart,
91
+ end: this.inputSelection.end,
92
+ });
84
93
  }
85
94
  handleInvalid() {
86
95
  this.invalid = true;
@@ -1 +1 @@
1
- {"version":3,"file":"mask-input-base.js","sourceRo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AS,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAClC,CAAC;CAOF,CAAA;AAtIC;IADC,KAAK,EAAE;2DACmB;AAG3B;IADC,KAAK,EAAE;8DACmB;AAG3B;IADC,KAAK,EAAE;wDACa;AAIrB;IADC,QAAQ,EAAE;yDACY;AAIvB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DACpB;AA0GvB;IADC,cAAc,EAAE;kEAQhB;AArImB,yBAAyB;IAD9C,gBAAgB;GACK,yBAAyB,CA4I9C;SA5IqB,yBAAyB","sourcesContent":["import { property, state } from 'lit/decorators.js';\nimport { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';\nimport { blazorSuppress } from '../common/decorators/blazorSuppress.js';\nimport { IgcInputBaseComponent } from '../input/input-base.js';\nimport { MaskParser } from './mask-parser.js';\ninterface MaskSelection {\n start: number;\n end: number;\n}\n\n@blazorDeepImport\nexport abstract class IgcMaskInputBaseComponent extends IgcInputBaseComponent {\n protected parser = new MaskParser();\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 @state()\n protected _mask = '';\n\n /** The prompt symbol to use for unfilled parts of the mask. */\n @property()\n public prompt!: string;\n\n /** Controls the validity of the control. */\n @property({ reflect: true, type: Boolean })\n public invalid = false;\n\n protected get inputSelection(): MaskSelection {\n return {\n start: this.input.selectionStart || 0,\n end: this.input.selectionEnd || 0,\n };\n }\n\n protected get emptyMask(): string {\n return this.parser.apply();\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 /**\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 /** Selects all text within the input. */\n public select() {\n this.input.select();\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 handleKeydown(e: KeyboardEvent) {\n if (!e.key) {\n return;\n }\n this.selection = this.inputSelection;\n }\n\n protected handleCut() {\n this.selection = this.inputSelection;\n }\n\n protected handleDragStart() {\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 handleInvalid() {\n this.invalid = true;\n }\n\n @blazorSuppress()\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 protected abstract updateInput(\n part: string,\n start: number,\n finish: number\n ): void;\n}\n"]}
1
+ {"version":3,"file":"mask-input-base.js","sourceRoot":"","sources":["../../../src/components/mask-input/mask-input-base.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE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E,CAAC;IAClC,CAAC;CAGF,CAAA;AAzIC;IADC,KAAK,EAAE;2DACmB;AAG3B;IADC,KAAK,EAAE;8DACmB;AAG3B;IADC,KAAK,EAAE;wDACa;AAIrB;IADC,QAAQ,EAAE;yDACY;AAIvB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0DACpB;AAiHvB;IADC,cAAc,EAAE;kEAQhB;AA5ImB,yBAAyB;IAD9C,gBAAgB;GACK,yBAAyB,CA+I9C;SA/IqB,yBAAyB","sourcesContent":["import { property, state } from 'lit/decorators.js';\nimport { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';\nimport { blazorSuppress } from '../common/decorators/blazorSuppress.js';\nimport { IgcInputBaseComponent } from '../input/input-base.js';\nimport { MaskParser } from './mask-parser.js';\n\nexport type MaskRange = {\n start: number;\n end: number;\n};\n\n@blazorDeepImport\nexport abstract class IgcMaskInputBaseComponent extends IgcInputBaseComponent {\n protected parser = new MaskParser();\n protected selection: MaskRange = { start: 0, end: 0 };\n protected compositionStart = 0;\n\n @state()\n protected hasFocus = false;\n\n @state()\n protected maskedValue = '';\n\n @state()\n protected _mask = '';\n\n /** The prompt symbol to use for unfilled parts of the mask. */\n @property()\n public prompt!: string;\n\n /** Controls the validity of the control. */\n @property({ reflect: true, type: Boolean })\n public invalid = false;\n\n protected get inputSelection(): MaskRange {\n return {\n start: this.input.selectionStart || 0,\n end: this.input.selectionEnd || 0,\n };\n }\n\n protected get emptyMask(): string {\n return this.parser.apply();\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 /**\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 /** Selects all text within the input. */\n public select() {\n this.input.select();\n }\n\n protected handleInput({ inputType, isComposing }: InputEvent) {\n const EMPTY = '';\n const value = this.input.value;\n const { start, end } = this.selection;\n const deleteEnd = this.parser.getNextNonLiteralPosition(end) + 1;\n\n switch (inputType) {\n case 'deleteContentForward':\n this.updateInput(EMPTY, { start, end: deleteEnd });\n return this.updateComplete.then(() =>\n this.input.setSelectionRange(deleteEnd, deleteEnd)\n );\n\n case 'deleteContentBackward':\n if (isComposing) return;\n return this.updateInput(EMPTY, {\n start: this.parser.getPreviousNonLiteralPosition(\n this.inputSelection.start\n ),\n end,\n });\n\n case 'deleteByCut':\n return this.updateInput(EMPTY, this.selection);\n\n case 'insertText':\n return this.updateInput(\n value.substring(start, this.inputSelection.end),\n this.selection\n );\n\n case 'insertFromPaste':\n return this.updateInput(\n value.substring(start, this.inputSelection.end),\n {\n start,\n end: this.inputSelection.start,\n }\n );\n\n case 'insertFromDrop':\n return this.updateInput(\n value.substring(this.inputSelection.start, this.inputSelection.end),\n { ...this.inputSelection }\n );\n }\n }\n\n protected handleKeydown({ key }: KeyboardEvent) {\n if (!key) {\n return;\n }\n this.selection = this.inputSelection;\n }\n\n protected handleCut() {\n this.selection = this.inputSelection;\n }\n\n protected handleDragStart() {\n this.selection = this.inputSelection;\n }\n\n protected handleCompositionStart() {\n this.compositionStart = this.inputSelection.start;\n }\n\n protected handleCompositionEnd({ data }: CompositionEvent) {\n this.updateInput(data, {\n start: this.compositionStart,\n end: this.inputSelection.end,\n });\n }\n\n protected handleInvalid() {\n this.invalid = true;\n }\n\n @blazorSuppress()\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 protected abstract updateInput(string: string, range: MaskRange): void;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { IgcMaskInputBaseComponent } from './mask-input-base.js';
1
+ import { IgcMaskInputBaseComponent, MaskRange } from './mask-input-base.js';
2
2
  /**
3
3
  * A masked input is an input field where a developer can control user input and format the visible value,
4
4
  * based on configurable rules
@@ -46,15 +46,13 @@ export default class IgcMaskInputComponent extends IgcMaskInputBaseComponent {
46
46
  */
47
47
  get mask(): string;
48
48
  /** The mask pattern to apply on the input. */
49
- set mask(val: string);
49
+ set mask(value: string);
50
50
  protected promptChange(): void;
51
- protected maskChange(): void;
52
- protected handleInvalidState(): void;
53
- connectedCallback(): void;
54
- protected updateInput(part: string, start: number, finish: number): void;
51
+ protected handleInvalidState(): Promise<void>;
52
+ protected updateInput(string: string, range: MaskRange): Promise<void>;
55
53
  protected handleDragEnter(): void;
56
54
  protected handleDragLeave(): void;
57
- protected handleFocus(): void;
55
+ protected handleFocus(): Promise<void>;
58
56
  protected handleBlur(): void;
59
57
  protected handleChange(): void;
60
58
  protected handleClick(): void;
@@ -32,38 +32,34 @@ export default class IgcMaskInputComponent extends IgcMaskInputBaseComponent {
32
32
  get mask() {
33
33
  return this._mask;
34
34
  }
35
- set mask(val) {
36
- this._mask = val;
37
- }
38
- promptChange() {
39
- this.parser.prompt = this.prompt;
35
+ set mask(value) {
36
+ this._mask = value;
37
+ this.parser.mask = value;
40
38
  if (this.value) {
41
39
  this.maskedValue = this.parser.apply(this._value);
42
40
  }
43
41
  }
44
- maskChange() {
45
- this.parser.mask = this.mask;
42
+ promptChange() {
43
+ this.parser.prompt = this.prompt;
46
44
  if (this.value) {
47
45
  this.maskedValue = this.parser.apply(this._value);
48
46
  }
49
47
  }
50
- handleInvalidState() {
51
- this.updateComplete.then(() => (this.invalid = !this.checkValidity()));
52
- }
53
- connectedCallback() {
54
- super.connectedCallback();
55
- this.mask = this.mask || this.parser.mask;
56
- this.prompt = this.prompt || this.parser.prompt;
48
+ async handleInvalidState() {
49
+ await this.updateComplete;
50
+ this.invalid = !this.checkValidity();
57
51
  }
58
- updateInput(part, start, finish) {
59
- const { value, end } = this.parser.replace(this.maskedValue, part, start, finish);
52
+ async updateInput(string, range) {
53
+ const { value, end } = this.parser.replace(this.maskedValue, string, range.start, range.end);
60
54
  this.maskedValue = value;
61
55
  this._value = this.parser.parse(value);
62
56
  this.requestUpdate();
63
- if (start !== this.mask.length) {
57
+ if (range.start !== this.mask.length) {
64
58
  this.emitEvent('igcInput', { detail: this.value });
65
59
  }
66
- this.updateComplete.then(() => this.input.setSelectionRange(end, end));
60
+ await this.updateComplete;
61
+ this.input.setSelectionRange(end, end);
62
+ this.invalid = !this.checkValidity();
67
63
  }
68
64
  handleDragEnter() {
69
65
  if (!this.hasFocus && !this._value) {
@@ -75,7 +71,7 @@ export default class IgcMaskInputComponent extends IgcMaskInputBaseComponent {
75
71
  this.updateMaskedValue();
76
72
  }
77
73
  }
78
- handleFocus() {
74
+ async handleFocus() {
79
75
  this.hasFocus = true;
80
76
  super.handleFocus();
81
77
  if (this.readonly) {
@@ -83,7 +79,8 @@ export default class IgcMaskInputComponent extends IgcMaskInputBaseComponent {
83
79
  }
84
80
  if (!this._value) {
85
81
  this.maskedValue = this.parser.apply();
86
- this.updateComplete.then(() => this.select());
82
+ await this.updateComplete;
83
+ this.select();
87
84
  }
88
85
  }
89
86
  handleBlur() {
@@ -171,9 +168,6 @@ __decorate([
171
168
  __decorate([
172
169
  watch('prompt')
173
170
  ], IgcMaskInputComponent.prototype, "promptChange", null);
174
- __decorate([
175
- watch('_mask')
176
- ], IgcMaskInputComponent.prototype, "maskChange", null);
177
171
  __decorate([
178
172
  watch('required', { waitUntilFirstUpdate: true }),
179
173
  watch('disabled', { waitUntilFirstUpdate: true }),
@@ -1 +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,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,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AI,EAAE,CAAC;IACjD,KAAK,CAAC,OAAO,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;+DAG9C","sourcesContent":["import { html } from 'lit';\nimport { property } 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 { IgcMaskInputBaseComponent } from './mask-input-base.js';\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 IgcMaskInputBaseComponent {\n public static readonly tagName = 'igc-mask-input';\n\n protected _value = '';\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 * @attr value-mode\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 * @attr\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 /**\n * The mask pattern to apply on the input.\n * @attr\n */\n @property()\n public get mask() {\n return this._mask;\n }\n\n /** The mask pattern to apply on the input. */\n public set mask(val: string) {\n this._mask = val;\n }\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 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 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 handleChange() {\n this.emitEvent('igcChange', { detail: this.value });\n this.invalid = !this.checkValidity();\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 /** 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 /** 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 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"]}
1
+ {"version":3,"file":"mask-input.js","sourceRoot":"","sources":["../../../src/components/mask-input/mask-input.ts"],"names":[],"m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,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;+DAI9C","sourcesContent":["import { html } from 'lit';\nimport { property } 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 { IgcMaskInputBaseComponent, MaskRange } from './mask-input-base.js';\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 IgcMaskInputBaseComponent {\n public static readonly tagName = 'igc-mask-input';\n\n protected _value = '';\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 * @attr value-mode\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 * @attr\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 /**\n * The mask pattern to apply on the input.\n * @attr\n */\n @property()\n public get mask() {\n return this._mask;\n }\n\n /** The mask pattern to apply on the input. */\n public set mask(value: string) {\n this._mask = value;\n this.parser.mask = value;\n if (this.value) {\n this.maskedValue = this.parser.apply(this._value);\n }\n }\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('required', { waitUntilFirstUpdate: true })\n @watch('disabled', { waitUntilFirstUpdate: true })\n @watch('value', { waitUntilFirstUpdate: true })\n protected async handleInvalidState() {\n await this.updateComplete;\n this.invalid = !this.checkValidity();\n }\n\n protected async updateInput(string: string, range: MaskRange) {\n const { value, end } = this.parser.replace(\n this.maskedValue,\n string,\n range.start,\n range.end\n );\n\n this.maskedValue = value;\n this._value = this.parser.parse(value);\n\n this.requestUpdate();\n\n if (range.start !== this.mask.length) {\n this.emitEvent('igcInput', { detail: this.value });\n }\n await this.updateComplete;\n\n this.input.setSelectionRange(end, end);\n this.invalid = !this.checkValidity();\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 async handleFocus() {\n this.hasFocus = true;\n super.handleFocus();\n\n if (this.readonly) {\n return;\n }\n\n if (!this._value) {\n // In case of empty value, select the whole mask\n this.maskedValue = this.parser.apply();\n\n await this.updateComplete;\n this.select();\n }\n }\n\n protected override handleBlur() {\n this.hasFocus = false;\n this.updateMaskedValue();\n super.handleBlur();\n }\n\n protected handleChange() {\n this.emitEvent('igcChange', { detail: this.value });\n this.invalid = !this.checkValidity();\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 /** 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 /** 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 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"]}
@@ -7,7 +7,7 @@ export declare class MaskParser {
7
7
  constructor(options?: MaskOptions);
8
8
  protected literals: Map<number, string>;
9
9
  protected _escapedMask: string;
10
- protected get literalPositions(): number[];
10
+ get literalPositions(): number[];
11
11
  get escapedMask(): string;
12
12
  get mask(): string;
13
13
  set mask(value: string);
@@ -19,6 +19,8 @@ export declare class MaskParser {
19
19
  protected validate(char: string, maskedChar: string): boolean;
20
20
  protected getNonLiteralPositions(mask?: string): number[];
21
21
  protected getRequiredNonLiteralPositions(mask: string): number[];
22
+ getPreviousNonLiteralPosition(start: number): number;
23
+ getNextNonLiteralPosition(start: number): number;
22
24
  replace(masked: string | undefined, value: string, start: number, end: number): {
23
25
  value: string;
24
26
  end: number;
@@ -92,6 +92,22 @@ export class MaskParser {
92
92
  .map((char, pos) => REQUIRED.has(char) && !positions.includes(pos) ? pos : -1)
93
93
  .filter((pos) => pos > -1);
94
94
  }
95
+ getPreviousNonLiteralPosition(start) {
96
+ const positions = this.literalPositions;
97
+ for (let i = start; i > 0; i--) {
98
+ if (!positions.includes(i))
99
+ return i;
100
+ }
101
+ return start;
102
+ }
103
+ getNextNonLiteralPosition(start) {
104
+ const positions = this.literalPositions;
105
+ for (let i = start; i < this._escapedMask.length; i++) {
106
+ if (!positions.includes(i))
107
+ return i;
108
+ }
109
+ return start;
110
+ }
95
111
  replace(masked = '', value, start, end) {
96
112
  const chars = Array.from(replaceIMENumbers(value));
97
113
  const positions = this.literalPositions;
@@ -1 +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,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\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"]}
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,E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,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 public 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 getPreviousNonLiteralPosition(start: number) {\n const positions = this.literalPositions;\n for (let i = start; i > 0; i--) {\n if (!positions.includes(i)) return i;\n }\n return start;\n }\n\n public getNextNonLiteralPosition(start: number) {\n const positions = this.literalPositions;\n for (let i = start; i < this._escapedMask.length; i++) {\n if (!positions.includes(i)) return i;\n }\n return start;\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"]}
@@ -118,9 +118,9 @@ export default class IgcSelectComponent extends IgcSelectComponent_base {
118
118
  focus(options?: FocusOptions): void;
119
119
  /** Removes focus from the component. */
120
120
  blur(): void;
121
- /** Checks the validity of the control. */
121
+ /** Checks the validity of the control and moves the focus to it if it is not valid. */
122
122
  reportValidity(): boolean;
123
- /** A wrapper around the custom reportValidity method to comply with the native select API. */
123
+ /** Checks the validity of the control. */
124
124
  checkValidity(): boolean;
125
125
  firstUpdated(): Promise<void>;
126
126
  protected updateValue(): void;
@@ -69,13 +69,14 @@ let IgcSelectComponent = class IgcSelectComponent extends EventEmitterMixin(IgcD
69
69
  this.target.blur();
70
70
  }
71
71
  reportValidity() {
72
- this.invalid = this.required && !this.value;
73
- if (this.invalid)
72
+ const valid = this.checkValidity();
73
+ if (!valid)
74
74
  this.target.focus();
75
- return !this.invalid;
75
+ return valid;
76
76
  }
77
77
  checkValidity() {
78
- return this.reportValidity();
78
+ this.invalid = this.required && !this.value;
79
+ return !this.invalid;
79
80
  }
80
81
  async firstUpdated() {
81
82
  super.firstUpdated();
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/components/select/select.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,KAAK,CAAC;AAC7C,OAAO,EACL,QAAQ,EACR,KAAK,EACL,qBAAqB,EACrB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,sDAAsD,CAAC;AACpG,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAE7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,oBAEN,MAAM,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,MAAM,iBAAiB,CAAC;AAC/C,OAAO,iBAAiB,MAAM,mBAAmB,CAAC;AAClD,OAAO,uBAAuB,MAAM,mBAAmB,CAAC;AACxD,OAAO,wBAAwB,MAAM,oBAAoB,CAAC;AAC1D,OAAO,sBAAsB,MAAM,kBAAkB,CAAC;AAEtD,OAAO,E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xB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDACpB;AAOvB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDACnB;AAOxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qDACQ;AAOpC;IADC,QAAQ,EAAE;iDACW;AAOtB;IADC,QAAQ,EAAE;uDACiB;AAO5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;qDACpB;AAOjC;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACyB;AA8DrD;IADC,KAAK,CAAC,cAAc,CAAC;qDAGrB;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;wDAkBd;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;kDAGd;AApNkB,kBAAkB;IA/BtC,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC/C,4BAA4B,CAC3B,gHAAgH,CACjH;GA4BoB,kBAAkB,CAoatC;eApaoB,kBAAkB","sourcesContent":["import { html, PropertyValueMap } from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n state,\n} from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { themes } from '../../theming/index.js';\nimport { blazorAdditionalDependencies } from '../common/decorators/blazorAdditionalDependencies.js';\nimport { watch } from '../common/decorators/watch.js';\nimport { defineComponents } from '../common/definitions/defineComponents.js';\nimport { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport IgcDropdownItemComponent from '../dropdown/dropdown-item.js';\nimport IgcDropdownComponent, {\n IgcDropdownEventMap,\n} from '../dropdown/dropdown.js';\nimport IgcIconComponent from '../icon/icon.js';\nimport IgcInputComponent from '../input/input.js';\nimport IgcSelectGroupComponent from './select-group.js';\nimport IgcSelectHeaderComponent from './select-header.js';\nimport IgcSelectItemComponent from './select-item.js';\nimport type { ThemeController, Theme } from '../../theming/types.js';\nimport { styles } from './themes/light/select.base.css.js';\nimport { styles as bootstrap } from './themes/light/select.bootstrap.css.js';\nimport { styles as fluent } from './themes/light/select.fluent.css.js';\nimport { styles as indigo } from './themes/light/select.indigo.css.js';\nimport { styles as material } from './themes/light/select.material.css.js';\n\ndefineComponents(\n IgcIconComponent,\n IgcInputComponent,\n IgcSelectGroupComponent,\n IgcSelectHeaderComponent,\n IgcSelectItemComponent\n);\n\nexport interface IgcSelectEventMap extends IgcDropdownEventMap {\n igcFocus: CustomEvent<void>;\n igcBlur: CustomEvent<void>;\n}\n\n@themes({ bootstrap, material, fluent, indigo })\n@blazorAdditionalDependencies(\n 'IgcIconComponent, IgcInputComponent, IgcSelectGroupComponent, IgcSelectHeaderComponent, IgcSelectItemComponent'\n)\n/**\n * @element igc-select\n *\n * @slot - Renders the list of select items.\n * @slot prefix - Renders content before the input.\n * @slot suffix - Renders content after input.\n * @slot header - Renders a container before the list of options.\n * @slot footer - Renders a container after the list of options.\n * @slot helper-text - Renders content below the input.\n * @slot toggle-icon - Renders content inside the suffix container.\n *\n * @fires igcFocus - Emitted when the select gains focus.\n * @fires igcBlur - Emitted when the select loses focus.\n * @fires igcChange - Emitted when the control's checked state changes.\n * @fires igcOpening - Emitted just before the list of options is opened.\n * @fires igcOpened - Emitted after the list of options is opened.\n * @fires igcClosing - Emitter just before the list of options is closed.\n * @fires igcClosed - Emitted after the list of options is closed.\n *\n * @csspart list - The list of options wrapper.\n * @csspart input - The encapsulated igc-input.\n * @csspart label - The encapsulated text label.\n * @csspart prefix - The prefix wrapper.\n * @csspart suffix - The suffix wrapper.\n * @csspart toggle-icon - The toggle icon wrapper.\n * @csspart helper-text - The helper text wrapper.\n */\nexport default class IgcSelectComponent extends EventEmitterMixin<\n IgcSelectEventMap,\n Constructor<IgcDropdownComponent>\n>(IgcDropdownComponent) {\n /** @private */\n public static readonly tagName = 'igc-select';\n public static styles = styles;\n private searchTerm = '';\n private lastKeyTime = Date.now();\n protected themeController!: ThemeController;\n protected theme!: Theme;\n\n private readonly targetKeyHandlers: Map<string, Function> = new Map(\n Object.entries({\n ' ': this.onTargetEnterKey,\n Tab: this.onTargetTabKey,\n Escape: this.onEscapeKey,\n Enter: this.onTargetEnterKey,\n ArrowLeft: this.onTargetArrowLeftKeyDown,\n ArrowRight: this.onTargetArrowRightKeyDown,\n ArrowUp: this.onTargetArrowUpKeyDown,\n ArrowDown: this.onTargetArrowDownKeyDown,\n Home: this.onTargetHomeKey,\n End: this.onTargetEndKey,\n })\n );\n\n @queryAssignedElements({ flatten: true, selector: 'igc-select-item' })\n protected override items!: Array<IgcSelectItemComponent>;\n\n @queryAssignedElements({ flatten: true, selector: 'igc-select-group' })\n protected override groups!: Array<IgcSelectGroupComponent>;\n\n @queryAssignedElements({ slot: 'helper-text' })\n protected helperText!: Array<HTMLElement>;\n\n @queryAssignedElements({ slot: 'suffix' })\n protected inputSuffix!: Array<HTMLElement>;\n\n @queryAssignedElements({ slot: 'prefix' })\n protected inputPrefix!: Array<HTMLElement>;\n\n @state()\n protected override selectedItem!: IgcSelectItemComponent | null;\n\n @query('div[role=\"combobox\"]')\n protected override target!: IgcInputComponent;\n\n /**\n * The value attribute of the control.\n * @attr\n */\n @property({ reflect: false, type: String })\n public value?: string | undefined;\n\n /**\n * The name attribute of the control.\n * @attr\n */\n @property()\n public name!: string;\n\n /**\n * The disabled attribute of the control.\n * @attr\n */\n @property({ reflect: true, type: Boolean })\n public disabled = false;\n\n /**\n * The required attribute of the control.\n * @attr\n */\n @property({ reflect: true, type: Boolean })\n public required = false;\n\n /**\n * The invalid attribute of the control.\n * @attr\n */\n @property({ reflect: true, type: Boolean })\n public invalid = false;\n\n /**\n * The outlined attribute of the control.\n * @attr\n */\n @property({ reflect: true, type: Boolean })\n public outlined = false;\n\n /**\n * The autofocus attribute of the control.\n * @attr\n */\n @property({ type: Boolean })\n public override autofocus!: boolean;\n\n /**\n * The label attribute of the control.\n * @attr\n */\n @property()\n public label!: string;\n\n /**\n * The placeholder attribute of the control.\n * @attr\n */\n @property()\n public placeholder!: string;\n\n /**\n * Whether the dropdown's width should be the same as the target's one.\n * @attr same-width\n */\n @property({ type: Boolean, attribute: 'same-width' })\n public override sameWidth = true;\n\n /**\n * The direction attribute of the control.\n * @attr\n */\n @property({ reflect: true })\n public override dir: 'ltr' | 'rtl' | 'auto' = 'auto';\n\n constructor() {\n super();\n this.size = 'medium';\n\n /** Return the focus to the target element when closing the list of options. */\n this.addEventListener('igcChange', () => {\n if (this.open) this.target.focus();\n });\n }\n\n protected themeAdopted(controller: ThemeController) {\n this.themeController = controller;\n }\n\n protected override willUpdate(changes: PropertyValueMap<any>) {\n super.willUpdate(changes);\n\n this.theme = this.themeController.theme;\n }\n\n /** Override the dropdown target focusout behavior to prevent the focus from\n * being returned to the target element when the select loses focus. */\n protected override handleFocusout() {}\n\n /** Sets focus on the component. */\n public override focus(options?: FocusOptions) {\n this.target.focus(options);\n }\n\n /** Removes focus from the component. */\n public override blur() {\n this.target.blur();\n }\n\n /** Checks the validity of the control. */\n public reportValidity() {\n this.invalid = this.required && !this.value;\n if (this.invalid) this.target.focus();\n return !this.invalid;\n }\n\n /** A wrapper around the custom reportValidity method to comply with the native select API. */\n public checkValidity() {\n return this.reportValidity();\n }\n\n public override async firstUpdated() {\n super.firstUpdated();\n await this.updateComplete;\n\n if (!this.selectedItem && this.value) {\n this.updateSelected();\n }\n\n if (this.autofocus) {\n this.target.focus();\n }\n }\n\n @watch('selectedItem')\n protected updateValue() {\n this.value = this.selectedItem?.value;\n }\n\n @watch('value')\n protected updateSelected() {\n if (this.allItems.length === 0) return;\n\n if (this.selectedItem?.value !== this.value) {\n const matches = this.allItems.filter((i) => i.value === this.value);\n const index = this.allItems.indexOf(\n matches.at(-1) as IgcSelectItemComponent\n );\n\n if (index === -1) {\n this.value = undefined;\n this.clearSelection();\n return;\n }\n\n this.select(index);\n }\n }\n\n @watch('value')\n protected validate() {\n this.updateComplete.then(() => this.reportValidity());\n }\n\n protected selectNext() {\n const activeItemIndex = [...this.allItems].indexOf(\n this.selectedItem ?? this.activeItem\n );\n\n const next = this.getNearestSiblingFocusableItemIndex(\n activeItemIndex ?? -1,\n 1\n );\n this.selectItem(this.allItems[next], true);\n }\n\n protected selectPrev() {\n const activeItemIndex = [...this.allItems].indexOf(\n this.selectedItem ?? this.activeItem\n );\n const prev = this.getNearestSiblingFocusableItemIndex(\n activeItemIndex ?? -1,\n -1\n );\n this.selectItem(this.allItems[prev], true);\n }\n\n protected selectInteractiveItem(index: number) {\n const item = this.allItems\n .filter((i) => !i.disabled)\n .at(index) as IgcDropdownItemComponent;\n\n if (item.value !== this.value) {\n this.selectItem(item, true);\n }\n }\n\n protected searchItem(event: KeyboardEvent): void {\n // ignore longer keys ('Alt', 'ArrowDown', etc)\n if (!/^.$/u.test(event.key)) {\n return;\n }\n\n const currentTime = Date.now();\n\n if (currentTime - this.lastKeyTime > 500) {\n this.searchTerm = '';\n }\n\n this.searchTerm += event.key;\n this.lastKeyTime = currentTime;\n\n const item = this.allItems\n .filter((i) => !i.disabled)\n .find((i) =>\n i.textContent\n ?.trim()\n .toLowerCase()\n .startsWith(this.searchTerm.toLowerCase())\n );\n\n if (item && this.value !== item.value) {\n this.open ? this.activateItem(item) : this.selectItem(item);\n }\n }\n\n protected handleFocus() {\n if (this.open) return;\n this.emitEvent('igcFocus');\n }\n\n protected handleBlur() {\n if (this.open) return;\n this.emitEvent('igcBlur');\n }\n\n protected onTargetTabKey() {\n this.target.blur();\n if (this.open) this.hide();\n }\n\n protected onTargetEnterKey() {\n !this.open ? this.target.click() : this.onEnterKey();\n }\n\n protected onTargetArrowLeftKeyDown() {\n !this.open ? this.selectPrev() : this.onArrowUpKeyDown();\n }\n\n protected onTargetArrowRightKeyDown() {\n !this.open ? this.selectNext() : this.onArrowDownKeyDown();\n }\n\n protected onTargetArrowUpKeyDown(event: KeyboardEvent) {\n if (event.altKey) {\n this.toggle();\n } else {\n !this.open ? this.selectPrev() : this.onArrowUpKeyDown();\n }\n }\n\n protected onTargetArrowDownKeyDown(event: KeyboardEvent) {\n if (event.altKey) {\n this.toggle();\n } else {\n !this.open ? this.selectNext() : this.onArrowDownKeyDown();\n }\n }\n\n protected onTargetHomeKey() {\n !this.open ? this.selectInteractiveItem(0) : this.onHomeKey();\n }\n\n protected onTargetEndKey() {\n !this.open ? this.selectInteractiveItem(-1) : this.onEndKey();\n }\n\n protected handleTargetKeyDown(event: KeyboardEvent) {\n event.stopPropagation();\n\n if (this.targetKeyHandlers.has(event.key)) {\n event.preventDefault();\n this.targetKeyHandlers.get(event.key)?.call(this, event);\n } else {\n this.searchItem(event);\n }\n }\n\n protected get hasPrefixes() {\n return this.inputPrefix.length > 0;\n }\n\n protected get hasSuffixes() {\n return this.inputSuffix.length > 0;\n }\n\n protected override render() {\n const openIcon =\n this.theme === 'material' ? 'keyboard_arrow_up' : 'arrow_drop_up';\n const closeIcon =\n this.theme === 'material' ? 'keyboard_arrow_down' : 'arrow_drop_down';\n\n return html`\n <div\n role=\"combobox\"\n tabindex=${this.disabled ? -1 : 0}\n aria-owns=\"dropdown\"\n aria-describedby=\"helper-text\"\n aria-disabled=${this.disabled}\n @focusin=${this.handleFocus}\n @focusout=${this.handleBlur}\n @keydown=${this.handleTargetKeyDown}\n @click=${this.handleTargetClick}\n >\n <igc-input\n id=\"input\"\n readonly\n exportparts=\"container: input, input: native-input, label, prefix, suffix\"\n value=${ifDefined(this.selectedItem?.textContent?.trim())}\n placeholder=${ifDefined(this.placeholder)}\n label=${ifDefined(this.label)}\n size=${this.size}\n dir=${this.dir}\n tabindex=\"-1\"\n .disabled=\"${this.disabled}\"\n .required=${this.required}\n .invalid=${this.invalid}\n .outlined=${this.outlined}\n @igcBlur=${(e: Event) => e.stopPropagation()}\n @igcFocus=${(e: Event) => e.stopPropagation()}\n >\n <span slot=${this.hasPrefixes ? 'prefix' : ''}>\n <slot name=\"prefix\"></slot>\n </span>\n <span slot=${this.hasSuffixes ? 'suffix' : ''}>\n <slot name=\"suffix\"></slot>\n </span>\n <span slot=\"suffix\" part=\"toggle-icon\" style=\"display: flex\">\n <slot name=\"toggle-icon\">\n <igc-icon\n size=${this.size}\n name=${this.open ? openIcon : closeIcon}\n collection=\"internal\"\n aria-hidden=\"true\"\n ></igc-icon>\n </slot>\n </span>\n </igc-input>\n </div>\n <div\n id=\"helper-text\"\n part=\"helper-text\"\n ?hidden=\"${this.helperText.length === 0}\"\n >\n <slot name=\"helper-text\"></slot>\n </div>\n <div\n part=\"base\"\n style=${styleMap({ position: this.positionStrategy })}\n @click=${this.handleClick}\n ${this.toggleController.toggleDirective}\n >\n <div id=\"dropdown\" role=\"listbox\" part=\"list\" aria-labelledby=\"input\">\n <slot name=\"header\"></slot>\n <slot></slot>\n <slot name=\"footer\"></slot>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-select': IgcSelectComponent;\n }\n}\n"]}
1
+ {"version":3,"file":"select.js","sourceRoot":"","sources":["../../../src/components/select/select.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,KAAK,CAAC;AAC7C,OAAO,EACL,QAAQ,EACR,KAAK,EACL,qBAAqB,EACrB,KAAK,GACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,sDAAsD,CAAC;AACpG,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAA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E;wDACwD;AAGhE;IADC,KAAK,CAAC,sBAAsB,CAAC;kDACgB;AAO9C;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iDACT;AAOlC;IADC,QAAQ,EAAE;gDACU;AAOrB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDACnB;AAOxB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDACnB;AAOxB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDACpB;AAOvB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oDACnB;AAOxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;qDACQ;AAOpC;IADC,QAAQ,EAAE;iDACW;AAOtB;IADC,QAAQ,EAAE;uDACiB;AAO5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;qDACpB;AAOjC;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACyB;AA+DrD;IADC,KAAK,CAAC,cAAc,CAAC;qDAGrB;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;wDAkBd;AAGD;IADC,KAAK,CAAC,OAAO,CAAC;kDAGd;AArNkB,kBAAkB;IA/BtC,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC/C,4BAA4B,CAC3B,gHAAgH,CACjH;GA4BoB,kBAAkB,CAqatC;eAraoB,kBAAkB","sourcesContent":["import { html, PropertyValueMap } from 'lit';\nimport {\n property,\n query,\n queryAssignedElements,\n state,\n} from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { themes } from '../../theming/index.js';\nimport { blazorAdditionalDependencies } from '../common/decorators/blazorAdditionalDependencies.js';\nimport { watch } from '../common/decorators/watch.js';\nimport { defineComponents } from '../common/definitions/defineComponents.js';\nimport { Constructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport IgcDropdownItemComponent from '../dropdown/dropdown-item.js';\nimport IgcDropdownComponent, {\n IgcDropdownEventMap,\n} from '../dropdown/dropdown.js';\nimport IgcIconComponent from '../icon/icon.js';\nimport IgcInputComponent from '../input/input.js';\nimport IgcSelectGroupComponent from './select-group.js';\nimport IgcSelectHeaderComponent from './select-header.js';\nimport IgcSelectItemComponent from './select-item.js';\nimport type { ThemeController, Theme } from '../../theming/types.js';\nimport { styles } from './themes/light/select.base.css.js';\nimport { styles as bootstrap } from './themes/light/select.bootstrap.css.js';\nimport { styles as fluent } from './themes/light/select.fluent.css.js';\nimport { styles as indigo } from './themes/light/select.indigo.css.js';\nimport { styles as material } from './themes/light/select.material.css.js';\n\ndefineComponents(\n IgcIconComponent,\n IgcInputComponent,\n IgcSelectGroupComponent,\n IgcSelectHeaderComponent,\n IgcSelectItemComponent\n);\n\nexport interface IgcSelectEventMap extends IgcDropdownEventMap {\n igcFocus: CustomEvent<void>;\n igcBlur: CustomEvent<void>;\n}\n\n@themes({ bootstrap, material, fluent, indigo })\n@blazorAdditionalDependencies(\n 'IgcIconComponent, IgcInputComponent, IgcSelectGroupComponent, IgcSelectHeaderComponent, IgcSelectItemComponent'\n)\n/**\n * @element igc-select\n *\n * @slot - Renders the list of select items.\n * @slot prefix - Renders content before the input.\n * @slot suffix - Renders content after input.\n * @slot header - Renders a container before the list of options.\n * @slot footer - Renders a container after the list of options.\n * @slot helper-text - Renders content below the input.\n * @slot toggle-icon - Renders content inside the suffix container.\n *\n * @fires igcFocus - Emitted when the select gains focus.\n * @fires igcBlur - Emitted when the select loses focus.\n * @fires igcChange - Emitted when the control's checked state changes.\n * @fires igcOpening - Emitted just before the list of options is opened.\n * @fires igcOpened - Emitted after the list of options is opened.\n * @fires igcClosing - Emitter just before the list of options is closed.\n * @fires igcClosed - Emitted after the list of options is closed.\n *\n * @csspart list - The list of options wrapper.\n * @csspart input - The encapsulated igc-input.\n * @csspart label - The encapsulated text label.\n * @csspart prefix - The prefix wrapper.\n * @csspart suffix - The suffix wrapper.\n * @csspart toggle-icon - The toggle icon wrapper.\n * @csspart helper-text - The helper text wrapper.\n */\nexport default class IgcSelectComponent extends EventEmitterMixin<\n IgcSelectEventMap,\n Constructor<IgcDropdownComponent>\n>(IgcDropdownComponent) {\n /** @private */\n public static readonly tagName = 'igc-select';\n public static styles = styles;\n private searchTerm = '';\n private lastKeyTime = Date.now();\n protected themeController!: ThemeController;\n protected theme!: Theme;\n\n private readonly targetKeyHandlers: Map<string, Function> = new Map(\n Object.entries({\n ' ': this.onTargetEnterKey,\n Tab: this.onTargetTabKey,\n Escape: this.onEscapeKey,\n Enter: this.onTargetEnterKey,\n ArrowLeft: this.onTargetArrowLeftKeyDown,\n ArrowRight: this.onTargetArrowRightKeyDown,\n ArrowUp: this.onTargetArrowUpKeyDown,\n ArrowDown: this.onTargetArrowDownKeyDown,\n Home: this.onTargetHomeKey,\n End: this.onTargetEndKey,\n })\n );\n\n @queryAssignedElements({ flatten: true, selector: 'igc-select-item' })\n protected override items!: Array<IgcSelectItemComponent>;\n\n @queryAssignedElements({ flatten: true, selector: 'igc-select-group' })\n protected override groups!: Array<IgcSelectGroupComponent>;\n\n @queryAssignedElements({ slot: 'helper-text' })\n protected helperText!: Array<HTMLElement>;\n\n @queryAssignedElements({ slot: 'suffix' })\n protected inputSuffix!: Array<HTMLElement>;\n\n @queryAssignedElements({ slot: 'prefix' })\n protected inputPrefix!: Array<HTMLElement>;\n\n @state()\n protected override selectedItem!: IgcSelectItemComponent | null;\n\n @query('div[role=\"combobox\"]')\n protected override target!: IgcInputComponent;\n\n /**\n * The value attribute of the control.\n * @attr\n */\n @property({ reflect: false, type: String })\n public value?: string | undefined;\n\n /**\n * The name attribute of the control.\n * @attr\n */\n @property()\n public name!: string;\n\n /**\n * The disabled attribute of the control.\n * @attr\n */\n @property({ reflect: true, type: Boolean })\n public disabled = false;\n\n /**\n * The required attribute of the control.\n * @attr\n */\n @property({ reflect: true, type: Boolean })\n public required = false;\n\n /**\n * The invalid attribute of the control.\n * @attr\n */\n @property({ reflect: true, type: Boolean })\n public invalid = false;\n\n /**\n * The outlined attribute of the control.\n * @attr\n */\n @property({ reflect: true, type: Boolean })\n public outlined = false;\n\n /**\n * The autofocus attribute of the control.\n * @attr\n */\n @property({ type: Boolean })\n public override autofocus!: boolean;\n\n /**\n * The label attribute of the control.\n * @attr\n */\n @property()\n public label!: string;\n\n /**\n * The placeholder attribute of the control.\n * @attr\n */\n @property()\n public placeholder!: string;\n\n /**\n * Whether the dropdown's width should be the same as the target's one.\n * @attr same-width\n */\n @property({ type: Boolean, attribute: 'same-width' })\n public override sameWidth = true;\n\n /**\n * The direction attribute of the control.\n * @attr\n */\n @property({ reflect: true })\n public override dir: 'ltr' | 'rtl' | 'auto' = 'auto';\n\n constructor() {\n super();\n this.size = 'medium';\n\n /** Return the focus to the target element when closing the list of options. */\n this.addEventListener('igcChange', () => {\n if (this.open) this.target.focus();\n });\n }\n\n protected themeAdopted(controller: ThemeController) {\n this.themeController = controller;\n }\n\n protected override willUpdate(changes: PropertyValueMap<any>) {\n super.willUpdate(changes);\n\n this.theme = this.themeController.theme;\n }\n\n /** Override the dropdown target focusout behavior to prevent the focus from\n * being returned to the target element when the select loses focus. */\n protected override handleFocusout() {}\n\n /** Sets focus on the component. */\n public override focus(options?: FocusOptions) {\n this.target.focus(options);\n }\n\n /** Removes focus from the component. */\n public override blur() {\n this.target.blur();\n }\n\n /** Checks the validity of the control and moves the focus to it if it is not valid. */\n public reportValidity() {\n const valid = this.checkValidity();\n if (!valid) this.target.focus();\n return valid;\n }\n\n /** Checks the validity of the control. */\n public checkValidity() {\n this.invalid = this.required && !this.value;\n return !this.invalid;\n }\n\n public override async firstUpdated() {\n super.firstUpdated();\n await this.updateComplete;\n\n if (!this.selectedItem && this.value) {\n this.updateSelected();\n }\n\n if (this.autofocus) {\n this.target.focus();\n }\n }\n\n @watch('selectedItem')\n protected updateValue() {\n this.value = this.selectedItem?.value;\n }\n\n @watch('value')\n protected updateSelected() {\n if (this.allItems.length === 0) return;\n\n if (this.selectedItem?.value !== this.value) {\n const matches = this.allItems.filter((i) => i.value === this.value);\n const index = this.allItems.indexOf(\n matches.at(-1) as IgcSelectItemComponent\n );\n\n if (index === -1) {\n this.value = undefined;\n this.clearSelection();\n return;\n }\n\n this.select(index);\n }\n }\n\n @watch('value')\n protected validate() {\n this.updateComplete.then(() => this.reportValidity());\n }\n\n protected selectNext() {\n const activeItemIndex = [...this.allItems].indexOf(\n this.selectedItem ?? this.activeItem\n );\n\n const next = this.getNearestSiblingFocusableItemIndex(\n activeItemIndex ?? -1,\n 1\n );\n this.selectItem(this.allItems[next], true);\n }\n\n protected selectPrev() {\n const activeItemIndex = [...this.allItems].indexOf(\n this.selectedItem ?? this.activeItem\n );\n const prev = this.getNearestSiblingFocusableItemIndex(\n activeItemIndex ?? -1,\n -1\n );\n this.selectItem(this.allItems[prev], true);\n }\n\n protected selectInteractiveItem(index: number) {\n const item = this.allItems\n .filter((i) => !i.disabled)\n .at(index) as IgcDropdownItemComponent;\n\n if (item.value !== this.value) {\n this.selectItem(item, true);\n }\n }\n\n protected searchItem(event: KeyboardEvent): void {\n // ignore longer keys ('Alt', 'ArrowDown', etc)\n if (!/^.$/u.test(event.key)) {\n return;\n }\n\n const currentTime = Date.now();\n\n if (currentTime - this.lastKeyTime > 500) {\n this.searchTerm = '';\n }\n\n this.searchTerm += event.key;\n this.lastKeyTime = currentTime;\n\n const item = this.allItems\n .filter((i) => !i.disabled)\n .find((i) =>\n i.textContent\n ?.trim()\n .toLowerCase()\n .startsWith(this.searchTerm.toLowerCase())\n );\n\n if (item && this.value !== item.value) {\n this.open ? this.activateItem(item) : this.selectItem(item);\n }\n }\n\n protected handleFocus() {\n if (this.open) return;\n this.emitEvent('igcFocus');\n }\n\n protected handleBlur() {\n if (this.open) return;\n this.emitEvent('igcBlur');\n }\n\n protected onTargetTabKey() {\n this.target.blur();\n if (this.open) this.hide();\n }\n\n protected onTargetEnterKey() {\n !this.open ? this.target.click() : this.onEnterKey();\n }\n\n protected onTargetArrowLeftKeyDown() {\n !this.open ? this.selectPrev() : this.onArrowUpKeyDown();\n }\n\n protected onTargetArrowRightKeyDown() {\n !this.open ? this.selectNext() : this.onArrowDownKeyDown();\n }\n\n protected onTargetArrowUpKeyDown(event: KeyboardEvent) {\n if (event.altKey) {\n this.toggle();\n } else {\n !this.open ? this.selectPrev() : this.onArrowUpKeyDown();\n }\n }\n\n protected onTargetArrowDownKeyDown(event: KeyboardEvent) {\n if (event.altKey) {\n this.toggle();\n } else {\n !this.open ? this.selectNext() : this.onArrowDownKeyDown();\n }\n }\n\n protected onTargetHomeKey() {\n !this.open ? this.selectInteractiveItem(0) : this.onHomeKey();\n }\n\n protected onTargetEndKey() {\n !this.open ? this.selectInteractiveItem(-1) : this.onEndKey();\n }\n\n protected handleTargetKeyDown(event: KeyboardEvent) {\n event.stopPropagation();\n\n if (this.targetKeyHandlers.has(event.key)) {\n event.preventDefault();\n this.targetKeyHandlers.get(event.key)?.call(this, event);\n } else {\n this.searchItem(event);\n }\n }\n\n protected get hasPrefixes() {\n return this.inputPrefix.length > 0;\n }\n\n protected get hasSuffixes() {\n return this.inputSuffix.length > 0;\n }\n\n protected override render() {\n const openIcon =\n this.theme === 'material' ? 'keyboard_arrow_up' : 'arrow_drop_up';\n const closeIcon =\n this.theme === 'material' ? 'keyboard_arrow_down' : 'arrow_drop_down';\n\n return html`\n <div\n role=\"combobox\"\n tabindex=${this.disabled ? -1 : 0}\n aria-owns=\"dropdown\"\n aria-describedby=\"helper-text\"\n aria-disabled=${this.disabled}\n @focusin=${this.handleFocus}\n @focusout=${this.handleBlur}\n @keydown=${this.handleTargetKeyDown}\n @click=${this.handleTargetClick}\n >\n <igc-input\n id=\"input\"\n readonly\n exportparts=\"container: input, input: native-input, label, prefix, suffix\"\n value=${ifDefined(this.selectedItem?.textContent?.trim())}\n placeholder=${ifDefined(this.placeholder)}\n label=${ifDefined(this.label)}\n size=${this.size}\n dir=${this.dir}\n tabindex=\"-1\"\n .disabled=\"${this.disabled}\"\n .required=${this.required}\n .invalid=${this.invalid}\n .outlined=${this.outlined}\n @igcBlur=${(e: Event) => e.stopPropagation()}\n @igcFocus=${(e: Event) => e.stopPropagation()}\n >\n <span slot=${this.hasPrefixes ? 'prefix' : ''}>\n <slot name=\"prefix\"></slot>\n </span>\n <span slot=${this.hasSuffixes ? 'suffix' : ''}>\n <slot name=\"suffix\"></slot>\n </span>\n <span slot=\"suffix\" part=\"toggle-icon\" style=\"display: flex\">\n <slot name=\"toggle-icon\">\n <igc-icon\n size=${this.size}\n name=${this.open ? openIcon : closeIcon}\n collection=\"internal\"\n aria-hidden=\"true\"\n ></igc-icon>\n </slot>\n </span>\n </igc-input>\n </div>\n <div\n id=\"helper-text\"\n part=\"helper-text\"\n ?hidden=\"${this.helperText.length === 0}\"\n >\n <slot name=\"helper-text\"></slot>\n </div>\n <div\n part=\"base\"\n style=${styleMap({ position: this.positionStrategy })}\n @click=${this.handleClick}\n ${this.toggleController.toggleDirective}\n >\n <div id=\"dropdown\" role=\"listbox\" part=\"list\" aria-labelledby=\"input\">\n <slot name=\"header\"></slot>\n <slot></slot>\n <slot name=\"footer\"></slot>\n </div>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-select': IgcSelectComponent;\n }\n}\n"]}
@@ -84,6 +84,10 @@ export const styles = css `:host {
84
84
  outline-style: none;
85
85
  }
86
86
 
87
+ :host([invalid]) ::slotted([slot=helper-text]) {
88
+ color: hsla(var(--ig-error-500), var(--ig-error-a));
89
+ }
90
+
87
91
  :host([disabled]) ::slotted([slot=helper-text]) {
88
92
  color: hsla(var(--ig-gray-400), var(--ig-gray-a));
89
93
  }