@momentum-design/components 0.117.1 → 0.117.3

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 (98) hide show
  1. package/dist/browser/index.js +275 -269
  2. package/dist/browser/index.js.map +3 -3
  3. package/dist/components/accordionbutton/accordionbutton.constants.d.ts +3 -2
  4. package/dist/components/animation/animation.component.js +1 -1
  5. package/dist/components/badge/badge.component.d.ts +1 -1
  6. package/dist/components/cardcheckbox/cardcheckbox.constants.d.ts +3 -2
  7. package/dist/components/checkbox/checkbox.component.d.ts +1 -1
  8. package/dist/components/checkbox/checkbox.constants.d.ts +3 -2
  9. package/dist/components/checkbox/checkbox.styles.js +5 -0
  10. package/dist/components/combobox/combobox.component.d.ts +1 -1
  11. package/dist/components/combobox/combobox.constants.d.ts +3 -2
  12. package/dist/components/dialog/dialog.constants.d.ts +2 -1
  13. package/dist/components/filterchip/filterchip.constants.d.ts +4 -2
  14. package/dist/components/formfieldwrapper/formfieldwrapper.component.js +1 -0
  15. package/dist/components/formfieldwrapper/formfieldwrapper.constants.d.ts +2 -1
  16. package/dist/components/formfieldwrapper/formfieldwrapper.styles.js +4 -0
  17. package/dist/components/formfieldwrapper/formfieldwrapper.utils.d.ts +1 -1
  18. package/dist/components/input/input.component.d.ts +1 -1
  19. package/dist/components/input/input.constants.d.ts +2 -1
  20. package/dist/components/inputchip/inputchip.constants.d.ts +2 -1
  21. package/dist/components/menuitem/menuitem.constants.d.ts +3 -2
  22. package/dist/components/navmenuitem/navmenuitem.constants.d.ts +2 -1
  23. package/dist/components/option/option.component.js +4 -7
  24. package/dist/components/password/password.constants.d.ts +3 -2
  25. package/dist/components/presence/presence.utils.d.ts +1 -1
  26. package/dist/components/progressspinner/progressspinner.constants.d.ts +3 -2
  27. package/dist/components/progressspinner/progressspinner.constants.js +2 -2
  28. package/dist/components/radio/radio.component.d.ts +1 -1
  29. package/dist/components/radio/radio.styles.js +3 -0
  30. package/dist/components/searchfield/searchfield.constants.d.ts +2 -1
  31. package/dist/components/select/select.component.d.ts +39 -46
  32. package/dist/components/select/select.component.js +155 -156
  33. package/dist/components/select/select.constants.d.ts +3 -2
  34. package/dist/components/statictoggle/statictoggle.constants.d.ts +3 -2
  35. package/dist/components/stepperitem/stepperitem.constants.d.ts +4 -3
  36. package/dist/components/textarea/textarea.component.d.ts +1 -1
  37. package/dist/components/textarea/textarea.styles.js +1 -0
  38. package/dist/components/toast/toast.component.js +16 -21
  39. package/dist/components/toast/toast.constants.d.ts +7 -6
  40. package/dist/components/toggle/toggle.component.d.ts +1 -1
  41. package/dist/components/toggle/toggle.constants.d.ts +3 -2
  42. package/dist/components/toggle/toggle.styles.js +5 -0
  43. package/dist/custom-elements.json +116 -84
  44. package/dist/react/accordion/index.d.ts +2 -3
  45. package/dist/react/accordionbutton/index.d.ts +2 -3
  46. package/dist/react/alertchip/index.d.ts +5 -4
  47. package/dist/react/animation/index.d.ts +4 -9
  48. package/dist/react/avatarbutton/index.d.ts +5 -4
  49. package/dist/react/brandvisual/index.d.ts +3 -6
  50. package/dist/react/button/index.d.ts +5 -4
  51. package/dist/react/buttonlink/index.d.ts +5 -4
  52. package/dist/react/buttonsimple/index.d.ts +5 -4
  53. package/dist/react/cardbutton/index.d.ts +5 -4
  54. package/dist/react/cardcheckbox/index.d.ts +6 -7
  55. package/dist/react/cardradio/index.d.ts +6 -7
  56. package/dist/react/checkbox/index.d.ts +3 -2
  57. package/dist/react/chip/index.d.ts +5 -4
  58. package/dist/react/coachmark/index.d.ts +5 -12
  59. package/dist/react/combobox/index.d.ts +6 -15
  60. package/dist/react/dialog/index.d.ts +6 -15
  61. package/dist/react/filterchip/index.d.ts +5 -4
  62. package/dist/react/input/index.d.ts +6 -5
  63. package/dist/react/inputchip/index.d.ts +2 -1
  64. package/dist/react/link/index.d.ts +5 -4
  65. package/dist/react/linkbutton/index.d.ts +5 -4
  66. package/dist/react/linksimple/index.d.ts +5 -4
  67. package/dist/react/listbox/index.d.ts +2 -1
  68. package/dist/react/listitem/index.d.ts +9 -8
  69. package/dist/react/menuitem/index.d.ts +9 -8
  70. package/dist/react/menuitemcheckbox/index.d.ts +11 -9
  71. package/dist/react/menuitemradio/index.d.ts +11 -9
  72. package/dist/react/menupopover/index.d.ts +8 -14
  73. package/dist/react/menusection/index.d.ts +3 -2
  74. package/dist/react/navmenuitem/index.d.ts +11 -12
  75. package/dist/react/option/index.d.ts +9 -8
  76. package/dist/react/password/index.d.ts +6 -5
  77. package/dist/react/popover/index.d.ts +5 -12
  78. package/dist/react/radio/index.d.ts +3 -2
  79. package/dist/react/searchfield/index.d.ts +6 -5
  80. package/dist/react/select/index.d.ts +7 -5
  81. package/dist/react/select/index.js +1 -0
  82. package/dist/react/sidenavigation/index.d.ts +3 -11
  83. package/dist/react/slider/index.d.ts +3 -4
  84. package/dist/react/stepperitem/index.d.ts +4 -3
  85. package/dist/react/tab/index.d.ts +7 -8
  86. package/dist/react/tablist/index.d.ts +2 -3
  87. package/dist/react/textarea/index.d.ts +6 -5
  88. package/dist/react/toast/index.d.ts +2 -1
  89. package/dist/react/toggle/index.d.ts +3 -2
  90. package/dist/react/toggletip/index.d.ts +5 -12
  91. package/dist/react/tooltip/index.d.ts +5 -12
  92. package/dist/react/typewriter/index.d.ts +3 -2
  93. package/dist/react/virtualizedlist/index.d.ts +2 -1
  94. package/dist/utils/controllers/ElementStore.d.ts +1 -1
  95. package/dist/utils/mixins/ListNavigationMixin.js +2 -1
  96. package/dist/utils/provider/index.d.ts +2 -4
  97. package/dist/utils/tag-name/index.d.ts +3 -1
  98. package/package.json +1 -1
@@ -8,17 +8,21 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { html, nothing } from 'lit';
11
- import { property, query, queryAssignedElements, state } from 'lit/decorators.js';
11
+ import { property, query, state } from 'lit/decorators.js';
12
12
  import { ifDefined } from 'lit/directives/if-defined.js';
13
+ import { ElementStore } from '../../utils/controllers/ElementStore';
13
14
  import { KEYS } from '../../utils/keys';
14
- import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
15
15
  import { AutoFocusOnMountMixin } from '../../utils/mixins/AutoFocusOnMountMixin';
16
+ import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
16
17
  import { FormInternalsMixin } from '../../utils/mixins/FormInternalsMixin';
18
+ import { CaptureDestroyEventForChildElement } from '../../utils/mixins/lifecycle/CaptureDestroyEventForChildElement';
19
+ import { LIFE_CYCLE_EVENTS } from '../../utils/mixins/lifecycle/lifecycle.contants';
20
+ import { ListNavigationMixin } from '../../utils/mixins/ListNavigationMixin';
17
21
  import { ROLE } from '../../utils/roles';
18
22
  import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
19
23
  import { DEFAULTS as FORMFIELD_DEFAULTS, VALIDATION } from '../formfieldwrapper/formfieldwrapper.constants';
20
24
  import { TAG_NAME as OPTION_TAG_NAME } from '../option/option.constants';
21
- import { POPOVER_PLACEMENT, DEFAULTS as POPOVER_DEFAULTS } from '../popover/popover.constants';
25
+ import { DEFAULTS as POPOVER_DEFAULTS, POPOVER_PLACEMENT } from '../popover/popover.constants';
22
26
  import { TYPE, VALID_TEXT_TAGS } from '../text/text.constants';
23
27
  import { ARROW_ICON, LISTBOX_ID, TRIGGER_ID } from './select.constants';
24
28
  import styles from './select.styles';
@@ -29,6 +33,7 @@ import styles from './select.styles';
29
33
  * Every mdc-option should have a `value` attribute set to ensure proper form submission.
30
34
  *
31
35
  * To set a default option, use the `selected` attribute on the `mdc-option` element.
36
+ * You can also set the `value` attribute on the `mdc-select` element to match the value of the desired option. The component will select the corresponding option automatically.
32
37
  *
33
38
  * **Note:** Make sure to add `mdc-selectlistbox` as a child of `mdc-select` and wrap options/optgroup in it to ensure proper accessibility functionality. Read more about it in SelectListBox documentation.
34
39
  *
@@ -66,16 +71,22 @@ import styles from './select.styles';
66
71
  * @cssproperty --mdc-select-listbox-height - The height of the listbox inside the select.
67
72
  * @cssproperty --mdc-select-listbox-width - The width of the listbox inside the select (default: `--mdc-select-width`).
68
73
  */
69
- class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))) {
74
+ class Select extends ListNavigationMixin(CaptureDestroyEventForChildElement(AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper))))) {
70
75
  constructor() {
71
- super(...arguments);
76
+ super();
72
77
  /**
73
78
  * readonly attribute of the select field. If true, the select is read-only.
74
79
  * @default false
75
80
  */
76
81
  this.readonly = false;
77
82
  /**
78
- * The placeholder text which will be shown on the text if provided.
83
+ * The placement of the popover within Select component.
84
+ * This defines the position of the popover relative to the select input field.
85
+ *
86
+ * Possible values:
87
+ * - 'top-start'
88
+ * - 'bottom-start'
89
+ * @default 'bottom-start'
79
90
  */
80
91
  this.placement = POPOVER_PLACEMENT.BOTTOM_START;
81
92
  /**
@@ -115,22 +126,141 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
115
126
  this.displayPopover = false;
116
127
  /** @internal */
117
128
  this.initialSelectedOption = null;
129
+ /** @internal */
130
+ this.itemsStore = new ElementStore(this, {
131
+ isValidItem: this.isValidItem,
132
+ onStoreUpdate: this.onStoreUpdate,
133
+ });
134
+ this.addEventListener(LIFE_CYCLE_EVENTS.MODIFIED, this.handleModifiedEvent);
118
135
  }
119
- getAllValidOptions() {
120
- var _a;
121
- return Array.from(((_a = this.slottedListboxes[0]) === null || _a === void 0 ? void 0 : _a.querySelectorAll(`${OPTION_TAG_NAME}:not([disabled])`)) || []);
136
+ connectedCallback() {
137
+ super.connectedCallback();
138
+ this.loop = 'false';
139
+ this.initialFocus = 0;
122
140
  }
123
- getFirstValidOption() {
141
+ /** @internal */
142
+ get navItems() {
143
+ return this.itemsStore.items;
144
+ }
145
+ /**
146
+ * This function is called when the value attribute changes.
147
+ * It updates the selected option based on the value attribute.
148
+ *
149
+ * @param name - attribute name
150
+ * @param old - old value
151
+ * @param value - new value
152
+ */
153
+ attributeChangedCallback(name, oldValue, newValue) {
124
154
  var _a;
125
- return (_a = this.slottedListboxes[0]) === null || _a === void 0 ? void 0 : _a.querySelector(`${OPTION_TAG_NAME}:not([disabled])`);
155
+ super.attributeChangedCallback(name, oldValue, newValue);
156
+ if (name === 'value' &&
157
+ newValue !== '' &&
158
+ newValue !== oldValue &&
159
+ newValue !== ((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value) &&
160
+ this.navItems.length) {
161
+ const firstSelectedOption = this.getFirstSelectedOption();
162
+ const firstValidOption = this.getFirstOption();
163
+ const valueBasedOption = this.navItems.find(option => option.value === newValue);
164
+ let optionToSelect = null;
165
+ if (valueBasedOption) {
166
+ optionToSelect = valueBasedOption;
167
+ }
168
+ else if (this.placeholder) {
169
+ optionToSelect = null;
170
+ }
171
+ else if (firstValidOption) {
172
+ optionToSelect = firstValidOption;
173
+ }
174
+ else if (firstSelectedOption) {
175
+ optionToSelect = firstSelectedOption;
176
+ }
177
+ else {
178
+ return;
179
+ }
180
+ this.updateComplete
181
+ .then(() => {
182
+ this.setSelectedOption(optionToSelect);
183
+ })
184
+ .catch(error => {
185
+ if (this.onerror) {
186
+ this.onerror(error);
187
+ }
188
+ });
189
+ }
126
190
  }
127
- getLastValidOption() {
128
- const options = this.getAllValidOptions();
129
- return options.length > 0 ? options[options.length - 1] : null;
191
+ /** @internal */
192
+ onStoreUpdate(option, changeType, index) {
193
+ switch (changeType) {
194
+ case 'added':
195
+ option.setAttribute('tabindex', '-1');
196
+ break;
197
+ case 'removed': {
198
+ if (index === -1 || option.tabIndex !== 0) {
199
+ return;
200
+ }
201
+ let newIndex = index + 1;
202
+ if (newIndex >= this.navItems.length) {
203
+ newIndex = index - 1;
204
+ }
205
+ if (newIndex === -1) {
206
+ this.displayPopover = false;
207
+ this.handleNativeInputFocus();
208
+ return;
209
+ }
210
+ this.resetTabIndexes(newIndex);
211
+ break;
212
+ }
213
+ default:
214
+ break;
215
+ }
216
+ }
217
+ /** @internal */
218
+ isValidItem(item) {
219
+ return item.matches(`${OPTION_TAG_NAME}:not([disabled])`);
130
220
  }
221
+ /** @internal */
131
222
  getFirstSelectedOption() {
132
- var _a;
133
- return (_a = this.slottedListboxes[0]) === null || _a === void 0 ? void 0 : _a.querySelector(`${OPTION_TAG_NAME}[selected]:not([disabled])`);
223
+ return this.navItems.find(option => option.hasAttribute('selected'));
224
+ }
225
+ /** @internal */
226
+ getFirstOption() {
227
+ return this.navItems[0];
228
+ }
229
+ /**
230
+ * Update the selected option when an option is modified.
231
+ *
232
+ * @internal
233
+ */
234
+ handleModifiedEvent(event) {
235
+ const option = event.target;
236
+ const firstSelectedOption = this.getFirstSelectedOption();
237
+ switch (event.detail.change) {
238
+ case 'selected': {
239
+ // when selected, check if there is any other option is a selected option,
240
+ // first preference should always be given to the `selected` attribute.
241
+ // if there is no selected option, then reset it to placeholder or first option
242
+ if (firstSelectedOption) {
243
+ this.setSelectedOption(firstSelectedOption);
244
+ }
245
+ else {
246
+ this.setSelectedOption(option);
247
+ }
248
+ break;
249
+ }
250
+ case 'unselected': {
251
+ // when unselected, check if there is any other option is a selected option,
252
+ // if there is no selected option, then reset it to placeholder or first option
253
+ if (firstSelectedOption) {
254
+ this.setSelectedOption(firstSelectedOption);
255
+ }
256
+ else {
257
+ this.setSelectedOption(this.placeholder ? null : this.getFirstOption());
258
+ }
259
+ break;
260
+ }
261
+ default:
262
+ break;
263
+ }
134
264
  }
135
265
  /**
136
266
  * Handles the first updated lifecycle event.
@@ -139,7 +269,6 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
139
269
  */
140
270
  async firstUpdated(_changedProperties) {
141
271
  await this.updateComplete;
142
- this.modifyListBoxWrapper();
143
272
  const firstSelectedOption = this.getFirstSelectedOption();
144
273
  if (firstSelectedOption) {
145
274
  this.initialSelectedOption = firstSelectedOption;
@@ -148,7 +277,7 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
148
277
  this.setSelectedOption(firstSelectedOption);
149
278
  }
150
279
  else if (!this.placeholder) {
151
- const firstValidOption = this.getFirstValidOption();
280
+ const firstValidOption = this.getFirstOption();
152
281
  // We will show the first option as selected & fire
153
282
  // and event since the selected option changed
154
283
  this.setSelectedOption(firstValidOption);
@@ -178,26 +307,6 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
178
307
  this.displayPopover = false;
179
308
  }
180
309
  }
181
- if (changedProperties.has('dataAriaLabel')) {
182
- this.modifyListBoxWrapper();
183
- }
184
- }
185
- /**
186
- * Modifies the listbox wrapper to ensure it has the correct attributes
187
- * and IDs for accessibility.
188
- *
189
- * Once [ariaOwnsElements](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/ariaOwnsElements) is supported in browsers,
190
- * this an be removed and mdc-option can be used directly in the select component with a listbox in a different
191
- * shadow root and aria-owns attribute to connect them.
192
- */
193
- modifyListBoxWrapper() {
194
- const slottedListBox = this.slottedListboxes[0];
195
- if (!slottedListBox) {
196
- return;
197
- }
198
- slottedListBox.setAttribute('id', LISTBOX_ID);
199
- slottedListBox.setAttribute('aria-label', this.dataAriaLabel || '');
200
- slottedListBox.setAttribute('aria-labelledby', TRIGGER_ID);
201
310
  }
202
311
  /**
203
312
  * A private method which is called when an option is clicked.
@@ -227,10 +336,13 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
227
336
  */
228
337
  setSelectedOption(option) {
229
338
  var _a, _b, _c;
339
+ // if the options is already selected, return
340
+ if (option === this.selectedOption)
341
+ return;
230
342
  // set the attribute 'selected' on the option in HTML and remove it from others
231
343
  this.updateSelectedInChildOptions(option);
232
344
  // update the tabindex for all options
233
- this.updateTabIndexForAllOptions(option);
345
+ this.resetTabIndexes(this.navItems.indexOf(option));
234
346
  // set the selected option in the component state
235
347
  this.selectedOption = option;
236
348
  // update all form related values
@@ -239,27 +351,13 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
239
351
  (_c = this.inputElement) === null || _c === void 0 ? void 0 : _c.setAttribute('value', this.value);
240
352
  this.setInputValidity();
241
353
  }
242
- /**
243
- * Updates the tabindex of all options.
244
- * Sets the tabindex of the selected option to '0' and others to '-1'.
245
- *
246
- * @param option - The option which tabIndex should be set to 0.
247
- */
248
- updateTabIndexForAllOptions(option) {
249
- const options = this.getAllValidOptions();
250
- const optionToGetTabIndex0 = option || options[0];
251
- options.forEach(option => {
252
- option.setAttribute('tabindex', option === optionToGetTabIndex0 ? '0' : '-1');
253
- });
254
- }
255
354
  /**
256
355
  * Sets selected attribute on the selected option and removes it from all options
257
356
  * @param selectedOption - The option which gets selected
258
357
  */
259
358
  updateSelectedInChildOptions(selectedOption) {
260
359
  selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.setAttribute('selected', 'true');
261
- const options = this.getAllValidOptions();
262
- options.forEach(option => {
360
+ this.navItems.forEach(option => {
263
361
  if (option !== selectedOption) {
264
362
  option.removeAttribute('selected');
265
363
  }
@@ -309,7 +407,7 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
309
407
  /** @internal */
310
408
  formStateRestoreCallback(state) {
311
409
  var _a;
312
- const optionToRestoreTo = this.getAllValidOptions().find(option => option.value === state || option.label === state);
410
+ const optionToRestoreTo = this.navItems.find(option => option.value === state || option.label === state);
313
411
  if (((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value) !== (optionToRestoreTo === null || optionToRestoreTo === void 0 ? void 0 : optionToRestoreTo.value)) {
314
412
  this.setSelectedOption(optionToRestoreTo || null);
315
413
  // fire events to notify the change in case of restore
@@ -376,21 +474,13 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
376
474
  break;
377
475
  case KEYS.HOME: {
378
476
  this.displayPopover = true;
379
- const firstOption = this.getFirstValidOption();
380
- if (firstOption) {
381
- firstOption === null || firstOption === void 0 ? void 0 : firstOption.focus();
382
- this.updateTabIndexForAllOptions(firstOption);
383
- }
477
+ this.resetTabIndexAndSetFocus(0);
384
478
  event.preventDefault();
385
479
  break;
386
480
  }
387
481
  case KEYS.END: {
388
482
  this.displayPopover = true;
389
- const lastOption = this.getLastValidOption();
390
- if (lastOption) {
391
- lastOption.focus();
392
- this.updateTabIndexForAllOptions(lastOption);
393
- }
483
+ this.resetTabIndexAndSetFocus(this.navItems.length - 1);
394
484
  event.preventDefault();
395
485
  break;
396
486
  }
@@ -398,73 +488,6 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
398
488
  break;
399
489
  }
400
490
  }
401
- /**
402
- * Handles the keydown event on the select element when the popover is open.
403
- * The options are as follows:
404
- * - HOME: Sets focus and tabindex on the first option.
405
- * - END: Sets focus and tabindex on the last option.
406
- * - ARROW_DOWN, ARROW_UP, PAGE_DOWN, PAGE_UP: Handles navigation between options.
407
- * @param event - The keyboard event.
408
- */
409
- handlePopoverKeydown(event) {
410
- let optionToFocus = null;
411
- switch (event.key) {
412
- case KEYS.HOME: {
413
- optionToFocus = this.getFirstValidOption();
414
- break;
415
- }
416
- case KEYS.END: {
417
- optionToFocus = this.getLastValidOption();
418
- break;
419
- }
420
- case KEYS.ARROW_DOWN: {
421
- const options = this.getAllValidOptions();
422
- const currentIndex = options.findIndex(option => option === event.target);
423
- const newIndex = Math.min(currentIndex + 1, options.length - 1);
424
- optionToFocus = options[newIndex];
425
- break;
426
- }
427
- case KEYS.ARROW_UP: {
428
- const options = this.getAllValidOptions();
429
- const currentIndex = options.findIndex(option => option === event.target);
430
- const newIndex = Math.max(currentIndex - 1, 0);
431
- optionToFocus = options[newIndex];
432
- break;
433
- }
434
- case KEYS.PAGE_DOWN: {
435
- const options = this.getAllValidOptions();
436
- const currentIndex = options.findIndex(option => option === event.target);
437
- const newIndex = Math.min(currentIndex + 10, options.length - 1);
438
- optionToFocus = options[newIndex];
439
- break;
440
- }
441
- case KEYS.PAGE_UP: {
442
- const options = this.getAllValidOptions();
443
- const currentIndex = options.findIndex(option => option === event.target);
444
- const newIndex = Math.max(currentIndex - 10, 0);
445
- optionToFocus = options[newIndex];
446
- break;
447
- }
448
- default:
449
- break;
450
- }
451
- if (optionToFocus) {
452
- this.focusAndUpdateTabIndexes(optionToFocus);
453
- event.preventDefault();
454
- event.stopPropagation();
455
- }
456
- }
457
- /**
458
- * Focuses the given option and updates the tabindex for all options.
459
- * @param option - The option to focus.
460
- * @internal
461
- */
462
- focusAndUpdateTabIndexes(option) {
463
- if (option) {
464
- option.focus();
465
- this.updateTabIndexForAllOptions(option);
466
- }
467
- }
468
491
  /**
469
492
  * If the native input is focused, it will focus the visual combobox.
470
493
  * This is to ensure that the visual combobox is focused when the native input is focused.
@@ -476,25 +499,6 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
476
499
  handleNativeInputFocus() {
477
500
  this.visualCombobox.focus();
478
501
  }
479
- /**
480
- * Updates the state of the select component.
481
- * This public method should be fired when the selected on the option components is updated from the outside.
482
- * It ensures that the selected attribute is set correctly on the options
483
- * and that the aria-selected attribute is updated accordingly.
484
- */
485
- updateState() {
486
- var _a;
487
- const newSelectedOption = this.getFirstSelectedOption();
488
- if (!this.inputElement) {
489
- return;
490
- }
491
- if (!newSelectedOption) {
492
- this.setSelectedOption(this.placeholder ? null : this.getFirstValidOption());
493
- }
494
- else if (((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value) !== newSelectedOption.value) {
495
- this.setSelectedOption(newSelectedOption);
496
- }
497
- }
498
502
  render() {
499
503
  var _a, _b, _c, _d, _e, _f;
500
504
  return html `
@@ -558,7 +562,6 @@ class Select extends AutoFocusOnMountMixin(FormInternalsMixin(DataAriaLabelMixin
558
562
  <mdc-popover
559
563
  trigger="manual"
560
564
  triggerid="${TRIGGER_ID}"
561
- @keydown="${this.handlePopoverKeydown}"
562
565
  interactive
563
566
  ?visible="${this.displayPopover}"
564
567
  role=""
@@ -621,10 +624,6 @@ __decorate([
621
624
  property({ type: String, reflect: true, attribute: 'backdrop-append-to' }),
622
625
  __metadata("design:type", String)
623
626
  ], Select.prototype, "backdropAppendTo", void 0);
624
- __decorate([
625
- queryAssignedElements({ selector: 'mdc-selectlistbox' }),
626
- __metadata("design:type", Array)
627
- ], Select.prototype, "slottedListboxes", void 0);
628
627
  __decorate([
629
628
  query(`[id="${TRIGGER_ID}"]`),
630
629
  __metadata("design:type", HTMLDivElement)
@@ -1,7 +1,8 @@
1
+ import type { IconNames } from '../icon/icon.types';
1
2
  declare const TAG_NAME: "mdc-select";
2
3
  declare const ARROW_ICON: {
3
- readonly ARROW_UP: "arrow-up-bold";
4
- readonly ARROW_DOWN: "arrow-down-bold";
4
+ readonly ARROW_UP: Extract<IconNames, "arrow-up-bold">;
5
+ readonly ARROW_DOWN: Extract<IconNames, "arrow-down-bold">;
5
6
  };
6
7
  declare const TRIGGER_ID = "select-base-triggerid";
7
8
  declare const LISTBOX_ID = "select-listbox";
@@ -1,11 +1,12 @@
1
+ import type { IconNames } from '../icon/icon.types';
1
2
  declare const TAG_NAME: "mdc-statictoggle";
2
3
  declare const TOGGLE_SIZE: {
3
4
  readonly DEFAULT: "default";
4
5
  readonly COMPACT: "compact";
5
6
  };
6
7
  declare const ICON_NAME: {
7
- readonly CHECKED: "check-bold";
8
- readonly UNCHECKED: "cancel-bold";
8
+ readonly CHECKED: Extract<IconNames, "check-bold">;
9
+ readonly UNCHECKED: Extract<IconNames, "cancel-bold">;
9
10
  };
10
11
  declare const ICON_SIZE_IN_REM: {
11
12
  readonly compact: 0.75;
@@ -1,3 +1,4 @@
1
+ import type { IconNames } from '../icon/icon.types';
1
2
  declare const TAG_NAME: "mdc-stepperitem";
2
3
  declare const VARIANT: {
3
4
  readonly INLINE: "inline";
@@ -11,9 +12,9 @@ declare const STATUS: {
11
12
  readonly NOT_STARTED: "not-started";
12
13
  };
13
14
  declare const STATUS_ICON: {
14
- readonly COMPLETED: "check-bold";
15
- readonly ERROR: "error-legacy-badge-filled";
16
- readonly PENCIL: "edit-bold";
15
+ readonly COMPLETED: Extract<IconNames, "check-bold">;
16
+ readonly ERROR: Extract<IconNames, "error-legacy-badge-filled">;
17
+ readonly PENCIL: Extract<IconNames, "edit-bold">;
17
18
  };
18
19
  declare const DEFAULT: {
19
20
  VARIANT: "inline";
@@ -2,7 +2,7 @@ import { CSSResult, nothing, PropertyValueMap } from 'lit';
2
2
  import FormfieldWrapper from '../formfieldwrapper';
3
3
  import type { AutoCapitalizeType } from '../input/input.types';
4
4
  import type { WrapType, AutoCompleteType } from './textarea.types';
5
- declare const Textarea_base: import("../../utils/mixins/index.types").Constructor<import("../../models/component/component.component").default & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
5
+ declare const Textarea_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
6
6
  /**
7
7
  * mdc-textarea component, which is used to get the multi-line text input from the user.
8
8
  * It contains:
@@ -51,6 +51,7 @@ const styles = [
51
51
  border: none;
52
52
  outline: none;
53
53
  box-sizing: border-box;
54
+ width: 100%;
54
55
  }
55
56
 
56
57
  :host::part(textarea-container) {
@@ -96,13 +96,16 @@ class Toast extends FooterMixin(Component) {
96
96
  }
97
97
  updateDetailedSlotPresence() {
98
98
  var _a, _b;
99
- this.hasDetailedSlot = (_b = (_a = this.detailedElements) === null || _a === void 0 ? void 0 : _a.some((el) => { var _a; return (_a = el.textContent) === null || _a === void 0 ? void 0 : _a.trim(); })) !== null && _b !== void 0 ? _b : false;
99
+ this.hasDetailedSlot = (_b = (_a = this.detailedElements) === null || _a === void 0 ? void 0 : _a.some(el => { var _a; return (_a = el.textContent) === null || _a === void 0 ? void 0 : _a.trim(); })) !== null && _b !== void 0 ? _b : false;
100
100
  }
101
101
  updateFooterButtonsPresence() {
102
102
  var _a, _b, _c, _d;
103
- this.hasFooterButtons = ((_b = (_a = this.footerButtonPrimary) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ||
104
- ((_d = (_c = this.footerButtonSecondary) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0 ||
105
- this.shouldRenderToggleButton() ? 'has-footer-buttons' : '';
103
+ this.hasFooterButtons =
104
+ ((_b = (_a = this.footerButtonPrimary) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 ||
105
+ ((_d = (_c = this.footerButtonSecondary) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0 ||
106
+ this.shouldRenderToggleButton()
107
+ ? 'has-footer-buttons'
108
+ : '';
106
109
  }
107
110
  firstUpdated(changedProperties) {
108
111
  super.firstUpdated(changedProperties);
@@ -112,11 +115,7 @@ class Toast extends FooterMixin(Component) {
112
115
  if (!iconName)
113
116
  return nothing;
114
117
  return html `
115
- <mdc-icon
116
- name="${iconName}"
117
- size="${DEFAULTS.PREFIX_ICON_SIZE}"
118
- part="toast-prefix-icon"
119
- ></mdc-icon>
118
+ <mdc-icon name="${iconName}" size="${DEFAULTS.PREFIX_ICON_SIZE}" part="toast-prefix-icon"></mdc-icon>
120
119
  `;
121
120
  }
122
121
  shouldRenderToggleButton() {
@@ -139,11 +138,7 @@ class Toast extends FooterMixin(Component) {
139
138
  renderHeader() {
140
139
  return this.headerText
141
140
  ? html `
142
- <mdc-text
143
- part="toast-header"
144
- tagname="${this.headerTagName}"
145
- type="${TYPE.BODY_LARGE_BOLD}"
146
- >
141
+ <mdc-text part="toast-header" tagname="${this.headerTagName}" type="${TYPE.BODY_LARGE_BOLD}">
147
142
  ${this.headerText}
148
143
  </mdc-text>
149
144
  `
@@ -184,13 +179,13 @@ class Toast extends FooterMixin(Component) {
184
179
  </div>
185
180
  </div>
186
181
  <mdc-button
187
- part="toast-close-btn"
188
- prefix-icon="${DEFAULTS.CANCEL_ICON}"
189
- variant="${DEFAULTS.TERTIARY_BUTTON}"
190
- size="${DEFAULTS.CLOSE_ICON_SIZE}"
191
- aria-label="${ifDefined(this.closeButtonAriaLabel)}"
192
- @click="${this.closeToast}"
193
- ></mdc-button>
182
+ part="toast-close-btn"
183
+ prefix-icon="${DEFAULTS.CANCEL_ICON}"
184
+ variant="${DEFAULTS.TERTIARY_BUTTON}"
185
+ size="${DEFAULTS.CLOSE_ICON_SIZE}"
186
+ aria-label="${ifDefined(this.closeButtonAriaLabel)}"
187
+ @click="${this.closeToast}"
188
+ ></mdc-button>
194
189
  </div>
195
190
  ${this.renderFooter()}
196
191
  `;
@@ -1,3 +1,4 @@
1
+ import type { IconNames } from '../icon/icon.types';
1
2
  declare const TAG_NAME: "mdc-toast";
2
3
  declare const TOAST_VARIANT: {
3
4
  readonly CUSTOM: "custom";
@@ -6,15 +7,15 @@ declare const TOAST_VARIANT: {
6
7
  readonly ERROR: "error";
7
8
  };
8
9
  declare const VARIANT_ICON_NAMES: {
9
- readonly SUCCESS_ICON_NAME: "check-circle-bold";
10
- readonly WARNING_ICON_NAME: "warning-bold";
11
- readonly ERROR_ICON_NAME: "error-legacy-bold";
10
+ readonly SUCCESS_ICON_NAME: Extract<IconNames, "check-circle-bold">;
11
+ readonly WARNING_ICON_NAME: Extract<IconNames, "warning-bold">;
12
+ readonly ERROR_ICON_NAME: Extract<IconNames, "error-legacy-bold">;
12
13
  };
13
14
  declare const DEFAULTS: {
14
15
  readonly HEADER_TAG_NAME: "h2";
15
- readonly CANCEL_ICON: "cancel-bold";
16
- readonly ARROW_UP_BOLD: "arrow-up-bold";
17
- readonly ARROW_DOWN_BOLD: "arrow-down-bold";
16
+ readonly CANCEL_ICON: Extract<IconNames, "cancel-bold">;
17
+ readonly ARROW_UP_BOLD: Extract<IconNames, "arrow-up-bold">;
18
+ readonly ARROW_DOWN_BOLD: Extract<IconNames, "arrow-down-bold">;
18
19
  readonly PREFIX_ICON_SIZE: 1.5;
19
20
  readonly CLOSE_ICON_SIZE: 20;
20
21
  readonly BUTTON: "mdc-button";
@@ -2,7 +2,7 @@ import { CSSResult, PropertyValueMap } from 'lit';
2
2
  import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
3
3
  import FormfieldWrapper from '../formfieldwrapper';
4
4
  import type { ToggleSize } from './toggle.types';
5
- declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<import("../../models/component/component.component").default & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
5
+ declare const Toggle_base: import("../../utils/mixins/index.types").Constructor<import("../../models").Component & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
6
6
  /**
7
7
  * Toggle Component is an interactive control used to switch between two mutually exclusive options,
8
8
  * such as On/Off, Active/Inactive. These are commonly used in settings panels, forms, and preference selections
@@ -1,11 +1,12 @@
1
+ import type { IconNames } from '../icon/icon.types';
1
2
  declare const TAG_NAME: "mdc-toggle";
2
3
  declare const TOGGLE_SIZE: {
3
4
  readonly DEFAULT: "default";
4
5
  readonly COMPACT: "compact";
5
6
  };
6
7
  declare const ICON_NAME: {
7
- readonly CHECKED: "check-bold";
8
- readonly UNCHECKED: "cancel-bold";
8
+ readonly CHECKED: Extract<IconNames, "check-bold">;
9
+ readonly UNCHECKED: Extract<IconNames, "cancel-bold">;
9
10
  };
10
11
  declare const ICON_SIZE_IN_REM: {
11
12
  compact: number;
@@ -59,6 +59,11 @@ const styles = [
59
59
  cursor: pointer;
60
60
  }
61
61
 
62
+ .mdc-label {
63
+ word-break: break-word;
64
+ white-space: normal;
65
+ }
66
+
62
67
  :host([disabled]) .mdc-label,
63
68
  :host([disabled])::part(toggle-input) {
64
69
  cursor: default;