igniteui-webcomponents 6.4.0 → 6.5.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 (90) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/components/calendar/base.d.ts +7 -3
  3. package/components/calendar/base.js +10 -14
  4. package/components/calendar/base.js.map +1 -1
  5. package/components/calendar/calendar.d.ts +48 -46
  6. package/components/calendar/calendar.js +259 -242
  7. package/components/calendar/calendar.js.map +1 -1
  8. package/components/calendar/days-view/days-view.d.ts +49 -27
  9. package/components/calendar/days-view/days-view.js +169 -160
  10. package/components/calendar/days-view/days-view.js.map +1 -1
  11. package/components/calendar/helpers.js +40 -28
  12. package/components/calendar/helpers.js.map +1 -1
  13. package/components/calendar/model.d.ts +9 -3
  14. package/components/calendar/model.js +29 -19
  15. package/components/calendar/model.js.map +1 -1
  16. package/components/calendar/months-view/months-view.d.ts +6 -7
  17. package/components/calendar/months-view/months-view.js +24 -27
  18. package/components/calendar/months-view/months-view.js.map +1 -1
  19. package/components/calendar/years-view/years-view.d.ts +6 -5
  20. package/components/calendar/years-view/years-view.js +11 -14
  21. package/components/calendar/years-view/years-view.js.map +1 -1
  22. package/components/checkbox/checkbox-base.d.ts +1 -1
  23. package/components/chip/themes/dark/chip.fluent.css.js +1 -1
  24. package/components/chip/themes/dark/chip.fluent.css.js.map +1 -1
  25. package/components/chip/themes/dark/chip.indigo.css.js +1 -1
  26. package/components/chip/themes/dark/chip.indigo.css.js.map +1 -1
  27. package/components/chip/themes/light/chip.fluent.css.js +1 -1
  28. package/components/chip/themes/light/chip.fluent.css.js.map +1 -1
  29. package/components/chip/themes/light/chip.indigo.css.js +1 -1
  30. package/components/chip/themes/light/chip.indigo.css.js.map +1 -1
  31. package/components/chip/themes/light/chip.shared.css.js +1 -1
  32. package/components/chip/themes/light/chip.shared.css.js.map +1 -1
  33. package/components/chip/themes/shared/chip.indigo.css.js +1 -1
  34. package/components/chip/themes/shared/chip.indigo.css.js.map +1 -1
  35. package/components/common/definitions/defineAllComponents.js +2 -0
  36. package/components/common/definitions/defineAllComponents.js.map +1 -1
  37. package/components/date-range-picker/date-range-picker.js +1 -1
  38. package/components/date-range-picker/date-range-picker.js.map +1 -1
  39. package/components/date-time-input/date-time-input.d.ts +4 -1
  40. package/components/date-time-input/date-time-input.js +17 -6
  41. package/components/date-time-input/date-time-input.js.map +1 -1
  42. package/components/file-input/file-input.d.ts +15 -13
  43. package/components/file-input/file-input.js +49 -47
  44. package/components/file-input/file-input.js.map +1 -1
  45. package/components/input/input-base.d.ts +31 -34
  46. package/components/input/input-base.js +58 -83
  47. package/components/input/input-base.js.map +1 -1
  48. package/components/input/input.d.ts +18 -7
  49. package/components/input/input.js +34 -19
  50. package/components/input/input.js.map +1 -1
  51. package/components/mask-input/mask-input-base.d.ts +10 -4
  52. package/components/mask-input/mask-input-base.js +18 -14
  53. package/components/mask-input/mask-input-base.js.map +1 -1
  54. package/components/mask-input/mask-input.d.ts +9 -3
  55. package/components/mask-input/mask-input.js +26 -6
  56. package/components/mask-input/mask-input.js.map +1 -1
  57. package/components/mask-input/validators.js +1 -1
  58. package/components/mask-input/validators.js.map +1 -1
  59. package/components/theme-provider/theme-provider.d.ts +65 -0
  60. package/components/theme-provider/theme-provider.js +58 -0
  61. package/components/theme-provider/theme-provider.js.map +1 -0
  62. package/components/tile-manager/tile.js +6 -3
  63. package/components/tile-manager/tile.js.map +1 -1
  64. package/custom-elements.json +2136 -1596
  65. package/extras/chat-markdown-renderer.d.ts +72 -4
  66. package/extras/chat-markdown-renderer.js +19 -7
  67. package/extras/chat-markdown-renderer.js.map +1 -1
  68. package/igniteui-webcomponents.html-data.json +1 -1
  69. package/index.d.ts +3 -0
  70. package/index.js +2 -0
  71. package/index.js.map +1 -1
  72. package/package.json +1 -1
  73. package/themes/dark/bootstrap.css +1 -1
  74. package/themes/dark/fluent.css +1 -1
  75. package/themes/dark/indigo.css +1 -1
  76. package/themes/dark/material.css +1 -1
  77. package/themes/light/bootstrap.css +1 -1
  78. package/themes/light/fluent.css +1 -1
  79. package/themes/light/indigo.css +1 -1
  80. package/themes/light/material.css +1 -1
  81. package/theming/context.d.ts +36 -0
  82. package/theming/context.js +3 -0
  83. package/theming/context.js.map +1 -0
  84. package/theming/theming-controller.d.ts +7 -1
  85. package/theming/theming-controller.js +48 -12
  86. package/theming/theming-controller.js.map +1 -1
  87. package/theming/utils.d.ts +10 -0
  88. package/theming/utils.js +8 -42
  89. package/theming/utils.js.map +1 -1
  90. package/web-types.json +1 -1
@@ -34,13 +34,20 @@ export default class IgcFileInputComponent extends IgcFileInputComponent_base {
34
34
  static readonly tagName = "igc-file-input";
35
35
  static styles: import("lit").CSSResult[];
36
36
  static register(): void;
37
+ protected readonly _themes: import("../../theming/theming-controller.js").ThemingController;
38
+ protected readonly _slots: import("../common/controllers/slot.js").SlotController<"invalid" | "prefix" | "[default]" | "helper-text" | "suffix" | "value-missing" | "custom-error" | "file-selector-text" | "file-missing-text">;
39
+ protected readonly _formValue: import("../common/mixins/forms/form-value.js").FormValue<FileList | null>;
37
40
  protected readonly _i18nController: import("../common/i18n/i18n-controller.js").I18nController<IFileInputResourceStrings>;
38
41
  protected get __validators(): import("../common/validators.js").Validator<IgcFileInputComponent>[];
39
- protected readonly _formValue: import("../common/mixins/forms/form-value.js").FormValue<FileList | null>;
40
- private _hasActivation;
41
42
  private get _fileNames();
43
+ /**
44
+ * Indicates whether the file picker dialog is currently active.
45
+ * Used to manage validation on blur.
46
+ */
47
+ private _filePickerActive;
42
48
  /**
43
49
  * The value of the control.
50
+ * Similar to native file input, this property is read-only and cannot be set programmatically.
44
51
  * @attr
45
52
  */
46
53
  set value(value: string);
@@ -59,7 +66,9 @@ export default class IgcFileInputComponent extends IgcFileInputComponent_base {
59
66
  /**
60
67
  * The multiple attribute of the control.
61
68
  * Used to indicate that a file input allows the user to select more than one file.
69
+ *
62
70
  * @attr
71
+ * @default false
63
72
  */
64
73
  multiple: boolean;
65
74
  /**
@@ -73,22 +82,15 @@ export default class IgcFileInputComponent extends IgcFileInputComponent_base {
73
82
  * @attr
74
83
  */
75
84
  autofocus: boolean;
76
- /** @hidden */
77
- readonly readOnly = false;
78
- /** Returns the selected files, if any; otherwise returns null. */
79
- get files(): FileList | null;
80
- constructor();
85
+ /** Returns the list of selected files. */
86
+ get files(): FileList;
81
87
  protected _restoreDefaultValue(): void;
82
- /** @hidden */
83
- setSelectionRange(): void;
84
- /** @hidden */
85
- setRangeText(): void;
86
88
  private _handleChange;
87
89
  private _handleCancel;
88
90
  protected _handleBlur(): void;
89
91
  protected _handleClick(): void;
90
- protected renderFileParts(): import("lit-html").TemplateResult<1>;
91
- protected renderInput(): import("lit-html").TemplateResult<1>;
92
+ protected _renderFileParts(): import("lit-html").TemplateResult<1>;
93
+ protected _renderInput(): import("lit-html").TemplateResult<1>;
92
94
  }
93
95
  declare global {
94
96
  interface HTMLElementTagNameMap {
@@ -9,21 +9,42 @@ import { html } from 'lit';
9
9
  import { property, state } from 'lit/decorators.js';
10
10
  import { addThemingController } from '../../theming/theming-controller.js';
11
11
  import IgcButtonComponent from '../button/button.js';
12
+ import { addSlotController, setSlots } from '../common/controllers/slot.js';
12
13
  import { registerComponent } from '../common/definitions/register.js';
13
14
  import { addI18nController } from '../common/i18n/i18n-controller.js';
14
15
  import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
15
16
  import { FormValueFileListTransformers } from '../common/mixins/forms/form-transformers.js';
16
17
  import { createFormValueState } from '../common/mixins/forms/form-value.js';
17
18
  import { partMap } from '../common/part-map.js';
18
- import { bindIf, hasFiles, isEmpty } from '../common/util.js';
19
+ import { bindIf, hasFiles } from '../common/util.js';
19
20
  import { IgcInputBaseComponent, } from '../input/input-base.js';
21
+ import { styles as baseStyle } from '../input/themes/input.base.css.js';
22
+ import { styles as shared } from '../input/themes/shared/input.common.css.js';
20
23
  import IgcValidationContainerComponent from '../validation-container/validation-container.js';
21
24
  import { styles } from './themes/file-input.base.css.js';
22
25
  import { all } from './themes/themes.js';
23
26
  import { fileValidators } from './validators.js';
27
+ const Slots = setSlots('prefix', 'suffix', 'helper-text', 'file-selector-text', 'file-missing-text', 'value-missing', 'custom-error', 'invalid');
24
28
  export default class IgcFileInputComponent extends EventEmitterMixin(IgcInputBaseComponent) {
29
+ constructor() {
30
+ super(...arguments);
31
+ this._themes = addThemingController(this, all);
32
+ this._slots = addSlotController(this, {
33
+ slots: Slots,
34
+ });
35
+ this._formValue = createFormValueState(this, {
36
+ initialValue: null,
37
+ transformers: FormValueFileListTransformers,
38
+ });
39
+ this._i18nController = addI18nController(this, {
40
+ defaultEN: FileInputResourceStringsEN,
41
+ });
42
+ this._filePickerActive = false;
43
+ this.multiple = false;
44
+ this.accept = '';
45
+ }
25
46
  static { this.tagName = 'igc-file-input'; }
26
- static { this.styles = [...IgcInputBaseComponent.styles, styles]; }
47
+ static { this.styles = [baseStyle, shared, styles]; }
27
48
  static register() {
28
49
  registerComponent(IgcFileInputComponent, IgcValidationContainerComponent, IgcButtonComponent);
29
50
  }
@@ -31,19 +52,20 @@ export default class IgcFileInputComponent extends EventEmitterMixin(IgcInputBas
31
52
  return fileValidators;
32
53
  }
33
54
  get _fileNames() {
34
- return hasFiles(this)
35
- ? Array.from(this.files)
36
- .map((file) => file.name)
37
- .join(', ')
38
- : null;
55
+ if (!hasFiles(this)) {
56
+ return null;
57
+ }
58
+ return Array.from(this.files)
59
+ .map((file) => file.name || 'unnamed')
60
+ .join(', ');
39
61
  }
40
62
  set value(value) {
41
- if (value === '' && this.input) {
42
- this.input.value = value;
63
+ if (value === '' && this._input) {
64
+ this._input.value = value;
43
65
  }
44
66
  }
45
67
  get value() {
46
- return this.input?.value ?? '';
68
+ return this._input?.value ?? '';
47
69
  }
48
70
  set resourceStrings(value) {
49
71
  this._i18nController.resourceStrings = value;
@@ -58,51 +80,34 @@ export default class IgcFileInputComponent extends EventEmitterMixin(IgcInputBas
58
80
  return this._i18nController.locale;
59
81
  }
60
82
  get files() {
61
- return this.input?.files ?? null;
62
- }
63
- constructor() {
64
- super();
65
- this._i18nController = addI18nController(this, {
66
- defaultEN: FileInputResourceStringsEN,
67
- });
68
- this._formValue = createFormValueState(this, {
69
- initialValue: null,
70
- transformers: FormValueFileListTransformers,
71
- });
72
- this._hasActivation = false;
73
- this.multiple = false;
74
- this.accept = '';
75
- this.readOnly = false;
76
- addThemingController(this, all);
83
+ return this._input?.files ?? new DataTransfer().files;
77
84
  }
78
85
  _restoreDefaultValue() {
79
- this.input.value = '';
86
+ if (this._input) {
87
+ this._input.value = '';
88
+ }
80
89
  super._restoreDefaultValue();
81
90
  }
82
- setSelectionRange() { }
83
- setRangeText() { }
84
91
  _handleChange() {
85
- this._hasActivation = false;
92
+ this._filePickerActive = false;
86
93
  this._setTouchedState();
87
94
  this._formValue.setValueAndFormState(this.files);
88
95
  this.requestUpdate();
89
96
  this.emitEvent('igcChange', { detail: this.files });
90
97
  }
91
98
  _handleCancel() {
92
- this._hasActivation = false;
99
+ this._filePickerActive = false;
93
100
  this._setTouchedState();
94
101
  this._validate();
95
- this.emitEvent('igcCancel', {
96
- detail: this.files,
97
- });
102
+ this.emitEvent('igcCancel', { detail: this.files });
98
103
  }
99
104
  _handleBlur() {
100
- this._hasActivation ? this._validate() : super._handleBlur();
105
+ this._filePickerActive ? this._validate() : super._handleBlur();
101
106
  }
102
107
  _handleClick() {
103
- this._hasActivation = true;
108
+ this._filePickerActive = true;
104
109
  }
105
- renderFileParts() {
110
+ _renderFileParts() {
106
111
  const emptyText = this.placeholder ?? this.resourceStrings.file_input_placeholder;
107
112
  return html `
108
113
  <div part="file-parts">
@@ -122,13 +127,13 @@ export default class IgcFileInputComponent extends EventEmitterMixin(IgcInputBas
122
127
  </div>
123
128
  `;
124
129
  }
125
- renderInput() {
130
+ _renderInput() {
126
131
  const hasNegativeTabIndex = this.getAttribute('tabindex') === '-1';
127
- const hasHelperText = !isEmpty(this._helperText);
132
+ const hasHelperText = this._slots.hasAssignedElements('helper-text');
128
133
  return html `
129
134
  <input
130
- id=${this.inputId}
131
- part=${partMap(this.resolvePartNames('input'))}
135
+ id=${this._inputId}
136
+ part=${partMap(this._resolvePartNames('input'))}
132
137
  type="file"
133
138
  ?disabled=${this.disabled}
134
139
  ?required=${this.required}
@@ -147,7 +152,7 @@ export default class IgcFileInputComponent extends EventEmitterMixin(IgcInputBas
147
152
  }
148
153
  __decorate([
149
154
  state()
150
- ], IgcFileInputComponent.prototype, "_hasActivation", void 0);
155
+ ], IgcFileInputComponent.prototype, "_filePickerActive", void 0);
151
156
  __decorate([
152
157
  property()
153
158
  ], IgcFileInputComponent.prototype, "value", null);
@@ -158,15 +163,12 @@ __decorate([
158
163
  property()
159
164
  ], IgcFileInputComponent.prototype, "locale", null);
160
165
  __decorate([
161
- property({ type: Boolean })
166
+ property({ type: Boolean, reflect: true })
162
167
  ], IgcFileInputComponent.prototype, "multiple", void 0);
163
168
  __decorate([
164
- property({ type: String })
169
+ property()
165
170
  ], IgcFileInputComponent.prototype, "accept", void 0);
166
171
  __decorate([
167
172
  property({ type: Boolean })
168
173
  ], IgcFileInputComponent.prototype, "autofocus", void 0);
169
- __decorate([
170
- property({ type: Boolean, attribute: false, noAccessor: true })
171
- ], IgcFileInputComponent.prototype, "readOnly", void 0);
172
174
  //# sourceMappingURL=file-input.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file-input.js","sourceRoot":"","sources":["../../../src/components/file-input/file-input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,0BAA0B,GAE3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,O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,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEjD,OAAO,IAAI,CAAA;;aAEF,IAAI,CAAC,OAAO;eACV,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;;oBAElC,IAAI,CAAC,QAAQ;oBACb,IAAI,CAAC,QAAQ;qBACZ,IAAI,CAAC,SAAS;oBACf,IAAI,CAAC,QAAQ;mBACd,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC;iBACjC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;2BACtB,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC;iBAC9C,IAAI,CAAC,YAAY;kBAChB,IAAI,CAAC,aAAa;kBAClB,IAAI,CAAC,aAAa;gBACpB,IAAI,CAAC,WAAW;;KAE3B,CAAC;IACJ,CAAC;;AA9KO;IADP,KAAK,EAAE;6DACuB;AAgB/B;IADC,QAAQ,EAAE;kDAKV;AAUD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4DAG9B;AAWD;IADC,QAAQ,EAAE;mDAGV;AAYM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDACJ;AAQjB;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACR;AAOH;IADf,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDACQ;AAIX;IADxB,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;uDACtB","sourcesContent":["import {\n FileInputResourceStringsEN,\n type IFileInputResourceStrings,\n} from 'igniteui-i18n-core';\nimport { html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport IgcButtonComponent from '../button/button.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport { addI18nController } from '../common/i18n/i18n-controller.js';\nimport type { AbstractConstructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport { FormValueFileListTransformers } from '../common/mixins/forms/form-transformers.js';\nimport { createFormValueState } from '../common/mixins/forms/form-value.js';\nimport { partMap } from '../common/part-map.js';\nimport { bindIf, hasFiles, isEmpty } from '../common/util.js';\nimport {\n IgcInputBaseComponent,\n type IgcInputComponentEventMap,\n} from '../input/input-base.js';\nimport IgcValidationContainerComponent from '../validation-container/validation-container.js';\nimport { styles } from './themes/file-input.base.css.js';\nimport { all } from './themes/themes.js';\nimport { fileValidators } from './validators.js';\n\nexport interface IgcFileInputComponentEventMap extends Omit<\n IgcInputComponentEventMap,\n 'igcChange' | 'igcInput'\n> {\n igcCancel: CustomEvent<FileList>;\n igcChange: CustomEvent<FileList>;\n}\n\n/* blazorSuppress */\n/**\n * @element igc-file-input\n *\n * @slot prefix - Renders content before the input.\n * @slot suffix - Renders content after input.\n * @slot helper-text - Renders content below the input.\n * @slot file-selector-text - Renders content for the browse button when input type is file.\n * @slot file-missing-text - Renders content when input type is file and no file is chosen.\n * @slot value-missing - Renders content when the required validation fails.\n * @slot custom-error - Renders content when setCustomValidity(message) is set.\n * @slot invalid - Renders content when the component is in invalid state (validity.valid = false).\n *\n * @fires igcChange - Emitted when the control's checked state changes.\n * @fires igcCancel - Emitted when the control's file picker dialog is canceled.\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 file-names - The file names wrapper when input type is 'file'.\n * @csspart file-selector-button - The browse button when input type is 'file'.\n * @csspart prefix - The prefix wrapper.\n * @csspart suffix - The suffix wrapper.\n * @csspart helper-text - The helper text wrapper.\n */\nexport default class IgcFileInputComponent extends EventEmitterMixin<\n IgcFileInputComponentEventMap,\n AbstractConstructor<IgcInputBaseComponent>\n>(IgcInputBaseComponent) {\n public static readonly tagName = 'igc-file-input';\n public static styles = [...IgcInputBaseComponent.styles, styles];\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(\n IgcFileInputComponent,\n IgcValidationContainerComponent,\n IgcButtonComponent\n );\n }\n\n protected readonly _i18nController =\n addI18nController<IFileInputResourceStrings>(this, {\n defaultEN: FileInputResourceStringsEN,\n });\n\n protected override get __validators() {\n return fileValidators;\n }\n\n protected override readonly _formValue = createFormValueState(this, {\n initialValue: null,\n transformers: FormValueFileListTransformers,\n });\n\n @state()\n private _hasActivation = false;\n\n private get _fileNames(): string | null {\n return hasFiles(this)\n ? Array.from(this.files!)\n .map((file) => file.name)\n .join(', ')\n : null;\n }\n\n /* @tsTwoWayProperty(true, \"igcChange\", \"detail\", false) */\n /**\n * The value of the control.\n * @attr\n */\n @property()\n public set value(value: string) {\n if (value === '' && this.input) {\n this.input.value = value;\n }\n }\n\n public get value(): string {\n return this.input?.value ?? '';\n }\n\n /**\n * The resource strings for localization.\n */\n @property({ attribute: false })\n public set resourceStrings(value: IFileInputResourceStrings) {\n this._i18nController.resourceStrings = value;\n }\n\n public get resourceStrings(): IFileInputResourceStrings {\n return this._i18nController.resourceStrings;\n }\n\n /**\n * Gets/Sets the locale used for getting language, affecting resource strings.\n * @attr locale\n */\n @property()\n public set locale(value: string) {\n this._i18nController.locale = value;\n }\n\n public get locale() {\n return this._i18nController.locale;\n }\n\n /**\n * The multiple attribute of the control.\n * Used to indicate that a file input allows the user to select more than one file.\n * @attr\n */\n @property({ type: Boolean })\n public multiple = false;\n\n /**\n * The accept attribute of the control.\n * Defines the file types as a list of comma-separated values that the file input should accept.\n * @attr\n */\n @property({ type: String })\n public accept = '';\n\n /**\n * The autofocus attribute of the control.\n * @attr\n */\n @property({ type: Boolean })\n public override autofocus!: boolean;\n\n /** @hidden */\n @property({ type: Boolean, attribute: false, noAccessor: true })\n public override readonly readOnly = false;\n\n /** Returns the selected files, if any; otherwise returns null. */\n public get files(): FileList | null {\n return this.input?.files ?? null;\n }\n\n constructor() {\n super();\n addThemingController(this, all);\n }\n\n protected override _restoreDefaultValue(): void {\n this.input.value = '';\n super._restoreDefaultValue();\n }\n\n /* c8 ignore next 2 */\n /** @hidden */\n public override setSelectionRange(): void {}\n\n /* c8 ignore next 2 */\n /** @hidden */\n public override setRangeText(): void {}\n\n private _handleChange(): void {\n this._hasActivation = false;\n this._setTouchedState();\n this._formValue.setValueAndFormState(this.files);\n\n this.requestUpdate();\n this.emitEvent('igcChange', { detail: this.files! });\n }\n\n private _handleCancel(): void {\n this._hasActivation = false;\n this._setTouchedState();\n this._validate();\n\n this.emitEvent('igcCancel', {\n detail: this.files!,\n });\n }\n\n protected override _handleBlur(): void {\n this._hasActivation ? this._validate() : super._handleBlur();\n }\n\n /* c8 ignore next 3 */\n protected _handleClick(): void {\n this._hasActivation = true;\n }\n\n protected override renderFileParts() {\n const emptyText =\n this.placeholder ?? this.resourceStrings.file_input_placeholder!;\n\n return html`\n <div part=\"file-parts\">\n <div part=\"file-selector-button\">\n <igc-button variant=\"flat\" ?disabled=${this.disabled} tabindex=\"-1\">\n <slot name=\"file-selector-text\"\n >${this.resourceStrings.file_input_upload_button}</slot\n >\n </igc-button>\n </div>\n <div part=\"file-names\">\n <span>\n ${this._fileNames ??\n html`<slot name=\"file-missing-text\">${emptyText}</slot>`}\n </span>\n </div>\n </div>\n `;\n }\n\n protected renderInput() {\n const hasNegativeTabIndex = this.getAttribute('tabindex') === '-1';\n const hasHelperText = !isEmpty(this._helperText);\n\n return html`\n <input\n id=${this.inputId}\n part=${partMap(this.resolvePartNames('input'))}\n type=\"file\"\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?autofocus=${this.autofocus}\n ?multiple=${this.multiple}\n tabindex=${bindIf(hasNegativeTabIndex, -1)}\n accept=${bindIf(this.accept, this.accept)}\n aria-describedby=${bindIf(hasHelperText, 'helper-text')}\n @click=${this._handleClick}\n @change=${this._handleChange}\n @cancel=${this._handleCancel}\n @blur=${this._handleBlur}\n />\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-file-input': IgcFileInputComponent;\n }\n}\n"]}
1
+ {"version":3,"file":"file-input.js","sourceRoot":"","sources":["../../../src/components/file-input/file-input.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EACL,0BAA0B,GAE3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,kBAAkB,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EACL,qBAAqB,GAEtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,+BAA+B,MAAM,iDAAiD,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAUjD,MAAM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CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;2BACtB,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC;iBAC9C,IAAI,CAAC,YAAY;kBAChB,IAAI,CAAC,aAAa;kBAClB,IAAI,CAAC,aAAa;gBACpB,IAAI,CAAC,WAAW;;KAE3B,CAAC;IACJ,CAAC;;AAtKO;IADP,KAAK,EAAE;gEAC0B;AAalC;IADC,QAAQ,EAAE;kDAKV;AAUD;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;4DAG9B;AAWD;IADC,QAAQ,EAAE;mDAGV;AAcM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDACnB;AAQjB;IADN,QAAQ,EAAE;qDACQ;AAOH;IADf,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wDACQ","sourcesContent":["import {\n FileInputResourceStringsEN,\n type IFileInputResourceStrings,\n} from 'igniteui-i18n-core';\nimport { html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { addThemingController } from '../../theming/theming-controller.js';\nimport IgcButtonComponent from '../button/button.js';\nimport { addSlotController, setSlots } from '../common/controllers/slot.js';\nimport { registerComponent } from '../common/definitions/register.js';\nimport { addI18nController } from '../common/i18n/i18n-controller.js';\nimport type { AbstractConstructor } from '../common/mixins/constructor.js';\nimport { EventEmitterMixin } from '../common/mixins/event-emitter.js';\nimport { FormValueFileListTransformers } from '../common/mixins/forms/form-transformers.js';\nimport { createFormValueState } from '../common/mixins/forms/form-value.js';\nimport { partMap } from '../common/part-map.js';\nimport { bindIf, hasFiles } from '../common/util.js';\nimport {\n IgcInputBaseComponent,\n type IgcInputComponentEventMap,\n} from '../input/input-base.js';\nimport { styles as baseStyle } from '../input/themes/input.base.css.js';\nimport { styles as shared } from '../input/themes/shared/input.common.css.js';\nimport IgcValidationContainerComponent from '../validation-container/validation-container.js';\nimport { styles } from './themes/file-input.base.css.js';\nimport { all } from './themes/themes.js';\nimport { fileValidators } from './validators.js';\n\nexport interface IgcFileInputComponentEventMap extends Omit<\n IgcInputComponentEventMap,\n 'igcChange' | 'igcInput'\n> {\n igcCancel: CustomEvent<FileList>;\n igcChange: CustomEvent<FileList>;\n}\n\nconst Slots = setSlots(\n 'prefix',\n 'suffix',\n 'helper-text',\n 'file-selector-text',\n 'file-missing-text',\n 'value-missing',\n 'custom-error',\n 'invalid'\n);\n\n/* blazorSuppress */\n/**\n * @element igc-file-input\n *\n * @slot prefix - Renders content before the input.\n * @slot suffix - Renders content after input.\n * @slot helper-text - Renders content below the input.\n * @slot file-selector-text - Renders content for the browse button when input type is file.\n * @slot file-missing-text - Renders content when input type is file and no file is chosen.\n * @slot value-missing - Renders content when the required validation fails.\n * @slot custom-error - Renders content when setCustomValidity(message) is set.\n * @slot invalid - Renders content when the component is in invalid state (validity.valid = false).\n *\n * @fires igcChange - Emitted when the control's checked state changes.\n * @fires igcCancel - Emitted when the control's file picker dialog is canceled.\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 file-names - The file names wrapper when input type is 'file'.\n * @csspart file-selector-button - The browse button when input type is 'file'.\n * @csspart prefix - The prefix wrapper.\n * @csspart suffix - The suffix wrapper.\n * @csspart helper-text - The helper text wrapper.\n */\nexport default class IgcFileInputComponent extends EventEmitterMixin<\n IgcFileInputComponentEventMap,\n AbstractConstructor<IgcInputBaseComponent>\n>(IgcInputBaseComponent) {\n public static readonly tagName = 'igc-file-input';\n public static styles = [baseStyle, shared, styles];\n\n /* blazorSuppress */\n public static register(): void {\n registerComponent(\n IgcFileInputComponent,\n IgcValidationContainerComponent,\n IgcButtonComponent\n );\n }\n\n //#region Internal attributes and properties\n\n protected override readonly _themes = addThemingController(this, all);\n\n protected override readonly _slots = addSlotController(this, {\n slots: Slots,\n });\n\n protected override readonly _formValue = createFormValueState(this, {\n initialValue: null,\n transformers: FormValueFileListTransformers,\n });\n\n protected readonly _i18nController = addI18nController(this, {\n defaultEN: FileInputResourceStringsEN,\n });\n\n protected override get __validators() {\n return fileValidators;\n }\n\n private get _fileNames(): string | null {\n if (!hasFiles(this)) {\n return null;\n }\n\n return Array.from(this.files)\n .map((file) => file.name || 'unnamed')\n .join(', ');\n }\n\n /**\n * Indicates whether the file picker dialog is currently active.\n * Used to manage validation on blur.\n */\n @state()\n private _filePickerActive = false;\n\n //#endregion\n\n //#region Public attributes and properties\n\n /* @tsTwoWayProperty(true, \"igcChange\", \"detail\", false) */\n /**\n * The value of the control.\n * Similar to native file input, this property is read-only and cannot be set programmatically.\n * @attr\n */\n @property()\n public set value(value: string) {\n if (value === '' && this._input) {\n this._input.value = value;\n }\n }\n\n public get value(): string {\n return this._input?.value ?? '';\n }\n\n /**\n * The resource strings for localization.\n */\n @property({ attribute: false })\n public set resourceStrings(value: IFileInputResourceStrings) {\n this._i18nController.resourceStrings = value;\n }\n\n public get resourceStrings(): IFileInputResourceStrings {\n return this._i18nController.resourceStrings;\n }\n\n /**\n * Gets/Sets the locale used for getting language, affecting resource strings.\n * @attr locale\n */\n @property()\n public set locale(value: string) {\n this._i18nController.locale = value;\n }\n\n public get locale(): string {\n return this._i18nController.locale;\n }\n\n /**\n * The multiple attribute of the control.\n * Used to indicate that a file input allows the user to select more than one file.\n *\n * @attr\n * @default false\n */\n @property({ type: Boolean, reflect: true })\n public multiple = false;\n\n /**\n * The accept attribute of the control.\n * Defines the file types as a list of comma-separated values that the file input should accept.\n * @attr\n */\n @property()\n public accept = '';\n\n /**\n * The autofocus attribute of the control.\n * @attr\n */\n @property({ type: Boolean })\n public override autofocus!: boolean;\n\n /** Returns the list of selected files. */\n public get files(): FileList {\n return this._input?.files ?? new DataTransfer().files;\n }\n\n //#endregion\n\n //#region Internal methods\n\n protected override _restoreDefaultValue(): void {\n if (this._input) {\n this._input.value = '';\n }\n super._restoreDefaultValue();\n }\n\n //#endregion\n\n //#region Event Handlers\n\n private _handleChange(): void {\n this._filePickerActive = false;\n this._setTouchedState();\n this._formValue.setValueAndFormState(this.files);\n\n this.requestUpdate();\n this.emitEvent('igcChange', { detail: this.files });\n }\n\n private _handleCancel(): void {\n this._filePickerActive = false;\n this._setTouchedState();\n this._validate();\n\n this.emitEvent('igcCancel', { detail: this.files });\n }\n\n protected override _handleBlur(): void {\n this._filePickerActive ? this._validate() : super._handleBlur();\n }\n\n /* c8 ignore next 3 */\n protected _handleClick(): void {\n this._filePickerActive = true;\n }\n\n //#endregion\n\n protected override _renderFileParts() {\n const emptyText =\n this.placeholder ?? this.resourceStrings.file_input_placeholder;\n\n return html`\n <div part=\"file-parts\">\n <div part=\"file-selector-button\">\n <igc-button variant=\"flat\" ?disabled=${this.disabled} tabindex=\"-1\">\n <slot name=\"file-selector-text\"\n >${this.resourceStrings.file_input_upload_button}</slot\n >\n </igc-button>\n </div>\n <div part=\"file-names\">\n <span>\n ${this._fileNames ??\n html`<slot name=\"file-missing-text\">${emptyText}</slot>`}\n </span>\n </div>\n </div>\n `;\n }\n\n protected override _renderInput() {\n const hasNegativeTabIndex = this.getAttribute('tabindex') === '-1';\n const hasHelperText = this._slots.hasAssignedElements('helper-text');\n\n return html`\n <input\n id=${this._inputId}\n part=${partMap(this._resolvePartNames('input'))}\n type=\"file\"\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?autofocus=${this.autofocus}\n ?multiple=${this.multiple}\n tabindex=${bindIf(hasNegativeTabIndex, -1)}\n accept=${bindIf(this.accept, this.accept)}\n aria-describedby=${bindIf(hasHelperText, 'helper-text')}\n @click=${this._handleClick}\n @change=${this._handleChange}\n @cancel=${this._handleCancel}\n @blur=${this._handleBlur}\n />\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'igc-file-input': IgcFileInputComponent;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { LitElement, nothing, type TemplateResult } from 'lit';
2
+ import type { ThemingController } from '../../theming/theming-controller.js';
3
+ import type { SlotController } from '../common/controllers/slot.js';
2
4
  import type { Constructor } from '../common/mixins/constructor.js';
3
- import type { RangeTextSelectMode, SelectionRangeDirection } from '../types.js';
4
5
  export interface IgcInputComponentEventMap {
5
6
  igcInput: CustomEvent<string>;
6
7
  igcChange: CustomEvent<string>;
@@ -9,26 +10,21 @@ export interface IgcInputComponentEventMap {
9
10
  }
10
11
  declare const IgcInputBaseComponent_base: Constructor<import("../common/mixins/forms/types.js").FormRequiredInterface & import("../common/mixins/forms/types.js").FormAssociatedElementInterface> & Constructor<import("../common/mixins/event-emitter.js").EventEmitterInterface<IgcInputComponentEventMap>> & Constructor<LitElement>;
11
12
  export declare abstract class IgcInputBaseComponent extends IgcInputBaseComponent_base {
12
- static styles: import("lit").CSSResult[];
13
- private static readonly increment;
14
- protected readonly _themes: import("../../theming/theming-controller.js").ThemingController;
15
- protected inputId: string;
16
- /** The value attribute of the control. */
13
+ protected abstract readonly _themes: ThemingController;
14
+ protected abstract readonly _slots: SlotController<any>;
15
+ protected readonly _inputId: string;
16
+ protected readonly _input?: HTMLInputElement;
17
+ /** The value attribute of the control.
18
+ * Type varies based on the input type and can be string, Date or null.
19
+ */
17
20
  abstract value: string | Date | null;
18
- protected input: HTMLInputElement;
19
- protected _helperText: Array<HTMLElement>;
20
- protected prefixes: Array<HTMLElement>;
21
- protected suffixes: Array<HTMLElement>;
22
21
  /**
23
22
  * Whether the control will have outlined appearance.
23
+ *
24
24
  * @attr
25
+ * @default false
25
26
  */
26
27
  outlined: boolean;
27
- /**
28
- * Makes the control a readonly field.
29
- * @attr readonly
30
- */
31
- readOnly: boolean;
32
28
  /**
33
29
  * The placeholder attribute of the control.
34
30
  * @attr
@@ -39,29 +35,30 @@ export declare abstract class IgcInputBaseComponent extends IgcInputBaseComponen
39
35
  * @attr
40
36
  */
41
37
  label: string;
42
- protected createRenderRoot(): HTMLElement | DocumentFragment;
43
- /** Sets focus on the control. */
44
- focus(options?: FocusOptions): void;
45
- /** Removes focus from the control. */
46
- blur(): void;
47
- protected abstract renderInput(): TemplateResult;
48
- protected renderValidatorContainer(): TemplateResult;
49
- protected resolvePartNames(base: string): {
38
+ /**
39
+ * Resolves the part names for the container based on the current state.
40
+ * Used to apply conditional styling via CSS parts.
41
+ */
42
+ protected _resolvePartNames(base: string): {
50
43
  [x: string]: boolean;
51
44
  prefixed: boolean;
52
45
  suffixed: boolean;
53
46
  filled: boolean;
54
47
  };
55
- protected renderFileParts(): TemplateResult | typeof nothing;
56
- /** Sets the text selection range of the control */
57
- setSelectionRange(start: number, end: number, direction?: SelectionRangeDirection): void;
58
- /** Replaces the selected text in the input. */
59
- setRangeText(replacement: string, start: number, end: number, selectMode?: RangeTextSelectMode): void;
60
- private renderPrefix;
61
- private renderSuffix;
62
- private renderLabel;
63
- private renderMaterial;
64
- private renderStandard;
65
- protected render(): TemplateResult<1>;
48
+ /** Selects all the text inside the input. */
49
+ select(): void;
50
+ /** Sets focus on the control. */
51
+ focus(options?: FocusOptions): void;
52
+ /** Removes focus from the control. */
53
+ blur(): void;
54
+ protected abstract _renderInput(): TemplateResult;
55
+ protected _renderFileParts(): TemplateResult | typeof nothing;
56
+ private _renderValidatorContainer;
57
+ private _renderPrefix;
58
+ private _renderSuffix;
59
+ private _renderLabel;
60
+ private _renderMaterial;
61
+ private _renderStandard;
62
+ protected render(): import("lit-html/directive.js").DirectiveResult<typeof import("lit-html/directives/cache.js").CacheDirective>;
66
63
  }
67
64
  export {};
@@ -4,139 +4,114 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
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
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- var IgcInputBaseComponent_1;
8
7
  import { html, LitElement, nothing } from 'lit';
9
- import { property, query, queryAssignedElements } from 'lit/decorators.js';
10
- import { addThemingController } from '../../theming/theming-controller.js';
8
+ import { property, query } from 'lit/decorators.js';
9
+ import { cache } from 'lit/directives/cache.js';
11
10
  import { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';
12
11
  import { shadowOptions } from '../common/decorators/shadow-options.js';
13
12
  import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
14
13
  import { FormAssociatedRequiredMixin } from '../common/mixins/forms/associated-required.js';
15
14
  import { partMap } from '../common/part-map.js';
16
- import { createCounter } from '../common/util.js';
17
15
  import IgcValidationContainerComponent from '../validation-container/validation-container.js';
18
- import { styles } from './themes/input.base.css.js';
19
- import { styles as shared } from './themes/shared/input.common.css.js';
20
- import { all } from './themes/themes.js';
16
+ let nextId = 1;
21
17
  let IgcInputBaseComponent = class IgcInputBaseComponent extends FormAssociatedRequiredMixin(EventEmitterMixin(LitElement)) {
22
18
  constructor() {
23
19
  super(...arguments);
24
- this._themes = addThemingController(this, all);
25
- this.inputId = `input-${IgcInputBaseComponent_1.increment()}`;
20
+ this._inputId = `input-${nextId++}`;
26
21
  this.outlined = false;
27
- this.readOnly = false;
28
22
  }
29
- static { IgcInputBaseComponent_1 = this; }
30
- static { this.styles = [styles, shared]; }
31
- static { this.increment = createCounter(); }
32
- createRenderRoot() {
33
- const root = super.createRenderRoot();
34
- root.addEventListener('slotchange', () => this.requestUpdate());
35
- return root;
36
- }
37
- focus(options) {
38
- this.input.focus(options);
39
- }
40
- blur() {
41
- this.input.blur();
42
- }
43
- renderValidatorContainer() {
44
- return IgcValidationContainerComponent.create(this);
45
- }
46
- resolvePartNames(base) {
23
+ _resolvePartNames(base) {
47
24
  return {
48
25
  [base]: true,
49
- prefixed: this.prefixes.length > 0,
50
- suffixed: this.suffixes.length > 0,
26
+ prefixed: this._slots.hasAssignedElements('prefix', {
27
+ selector: '[slot="prefix"]:not([hidden])',
28
+ }),
29
+ suffixed: this._slots.hasAssignedElements('suffix', {
30
+ selector: '[slot="suffix"]:not([hidden])',
31
+ }),
51
32
  filled: !!this.value,
52
33
  };
53
34
  }
54
- renderFileParts() {
55
- return nothing;
35
+ select() {
36
+ this._input?.select();
37
+ }
38
+ focus(options) {
39
+ this._input?.focus(options);
56
40
  }
57
- setSelectionRange(start, end, direction = 'none') {
58
- this.input.setSelectionRange(start, end, direction);
41
+ blur() {
42
+ this._input?.blur();
43
+ }
44
+ _renderFileParts() {
45
+ return nothing;
59
46
  }
60
- setRangeText(replacement, start, end, selectMode = 'preserve') {
61
- this.input.setRangeText(replacement, start, end, selectMode);
47
+ _renderValidatorContainer() {
48
+ return IgcValidationContainerComponent.create(this);
62
49
  }
63
- renderPrefix() {
64
- return html `<div part="prefix">
65
- <slot name="prefix"></slot>
66
- </div>`;
50
+ _renderPrefix() {
51
+ return html `
52
+ <div part="prefix">
53
+ <slot name="prefix"></slot>
54
+ </div>
55
+ `;
67
56
  }
68
- renderSuffix() {
69
- return html `<div part="suffix">
70
- <slot name="suffix"></slot>
71
- </div>`;
57
+ _renderSuffix() {
58
+ return html `
59
+ <div part="suffix">
60
+ <slot name="suffix"></slot>
61
+ </div>
62
+ `;
72
63
  }
73
- renderLabel() {
64
+ _renderLabel() {
74
65
  return this.label
75
- ? html `<label part="label" for=${this.inputId}> ${this.label} </label>`
66
+ ? html `<label part="label" for=${this._inputId}>${this.label}</label>`
76
67
  : nothing;
77
68
  }
78
- renderMaterial() {
69
+ _renderMaterial() {
79
70
  return html `
80
71
  <div
81
72
  part=${partMap({
82
- ...this.resolvePartNames('container'),
73
+ ...this._resolvePartNames('container'),
83
74
  labelled: !!this.label,
84
75
  })}
85
76
  >
86
- <div part="start">${this.renderPrefix()}</div>
87
- ${this.renderInput()} ${this.renderFileParts()}
88
- <div part="notch">${this.renderLabel()}</div>
77
+ <div part="start">${this._renderPrefix()}</div>
78
+ ${this._renderInput()} ${this._renderFileParts()}
79
+ <div part="notch">${this._renderLabel()}</div>
89
80
  <div part="filler"></div>
90
- <div part="end">${this.renderSuffix()}</div>
81
+ <div part="end">${this._renderSuffix()}</div>
91
82
  </div>
92
- ${this.renderValidatorContainer()}
83
+ ${this._renderValidatorContainer()}
93
84
  `;
94
85
  }
95
- renderStandard() {
96
- return html `${this.renderLabel()}
97
- <div part=${partMap(this.resolvePartNames('container'))}>
98
- ${this.renderPrefix()} ${this.renderFileParts()} ${this.renderInput()}
99
- ${this.renderSuffix()}
86
+ _renderStandard() {
87
+ return html `
88
+ ${this._renderLabel()}
89
+ <div part=${partMap(this._resolvePartNames('container'))}>
90
+ ${this._renderPrefix()}${this._renderFileParts()}
91
+ ${this._renderInput()}${this._renderSuffix()}
100
92
  </div>
101
- ${this.renderValidatorContainer()}`;
93
+ ${this._renderValidatorContainer()}
94
+ `;
102
95
  }
103
96
  render() {
104
- return this._themes.theme === 'material'
105
- ? this.renderMaterial()
106
- : this.renderStandard();
97
+ return cache(this._themes.theme === 'material'
98
+ ? this._renderMaterial()
99
+ : this._renderStandard());
107
100
  }
108
101
  };
109
102
  __decorate([
110
103
  query('input')
111
- ], IgcInputBaseComponent.prototype, "input", void 0);
112
- __decorate([
113
- queryAssignedElements({ slot: 'helper-text' })
114
- ], IgcInputBaseComponent.prototype, "_helperText", void 0);
104
+ ], IgcInputBaseComponent.prototype, "_input", void 0);
115
105
  __decorate([
116
- queryAssignedElements({
117
- slot: 'prefix',
118
- selector: '[slot="prefix"]:not([hidden])',
119
- })
120
- ], IgcInputBaseComponent.prototype, "prefixes", void 0);
121
- __decorate([
122
- queryAssignedElements({
123
- slot: 'suffix',
124
- selector: '[slot="suffix"]:not([hidden])',
125
- })
126
- ], IgcInputBaseComponent.prototype, "suffixes", void 0);
127
- __decorate([
128
- property({ reflect: true, type: Boolean })
106
+ property({ type: Boolean, reflect: true })
129
107
  ], IgcInputBaseComponent.prototype, "outlined", void 0);
130
- __decorate([
131
- property({ type: Boolean, reflect: true, attribute: 'readonly' })
132
- ], IgcInputBaseComponent.prototype, "readOnly", void 0);
133
108
  __decorate([
134
109
  property()
135
110
  ], IgcInputBaseComponent.prototype, "placeholder", void 0);
136
111
  __decorate([
137
112
  property()
138
113
  ], IgcInputBaseComponent.prototype, "label", void 0);
139
- IgcInputBaseComponent = IgcInputBaseComponent_1 = __decorate([
114
+ IgcInputBaseComponent = __decorate([
140
115
  blazorDeepImport,
141
116
  shadowOptions({ delegatesFocus: true })
142
117
  ], IgcInputBaseComponent);