@momentum-design/components 0.102.6 → 0.102.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +3 -3
- package/dist/components/radio/radio.component.d.ts +0 -7
- package/dist/components/radio/radio.component.js +7 -17
- package/dist/components/select/select.component.js +12 -14
- package/dist/custom-elements.json +1778 -1814
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/package.json +1 -1
@@ -54,12 +54,6 @@ declare class Radio extends Radio_base implements AssociatedFormControl {
|
|
54
54
|
* Returns all radios within the same group (name).
|
55
55
|
*/
|
56
56
|
private getAllRadiosWithinSameGroup;
|
57
|
-
/**
|
58
|
-
* The 'change' event does not bubble up through the shadow DOM as it was not composed.
|
59
|
-
* Therefore, we need to re-dispatch the same event to ensure it is propagated correctly.
|
60
|
-
* Read more: https://developer.mozilla.org/en-US/docs/Web/API/Event/composed
|
61
|
-
*/
|
62
|
-
private dispatchChangeEvent;
|
63
57
|
/** @internal */
|
64
58
|
formResetCallback(): void;
|
65
59
|
/** @internal */
|
@@ -92,7 +86,6 @@ declare class Radio extends Radio_base implements AssociatedFormControl {
|
|
92
86
|
*
|
93
87
|
* @param enabledRadios - An array of enabled radio buttons within the same group.
|
94
88
|
* @param index - The index of the radio button to be updated within the enabled radios array.
|
95
|
-
* @param event - The event that triggered the update.
|
96
89
|
*/
|
97
90
|
private updateRadio;
|
98
91
|
/**
|
@@ -86,15 +86,6 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
86
86
|
getAllRadiosWithinSameGroup() {
|
87
87
|
return Array.from(document.querySelectorAll(`mdc-radio[name="${this.name}"]`));
|
88
88
|
}
|
89
|
-
/**
|
90
|
-
* The 'change' event does not bubble up through the shadow DOM as it was not composed.
|
91
|
-
* Therefore, we need to re-dispatch the same event to ensure it is propagated correctly.
|
92
|
-
* Read more: https://developer.mozilla.org/en-US/docs/Web/API/Event/composed
|
93
|
-
*/
|
94
|
-
dispatchChangeEvent(event) {
|
95
|
-
const EventConstructor = event.constructor;
|
96
|
-
this.dispatchEvent(new EventConstructor(event.type, event));
|
97
|
-
}
|
98
89
|
/** @internal */
|
99
90
|
formResetCallback() {
|
100
91
|
const radios = this.getAllRadiosWithinSameGroup();
|
@@ -183,7 +174,7 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
183
174
|
* This will toggle the state of the radio element.
|
184
175
|
* Dispatches the change event.
|
185
176
|
*/
|
186
|
-
handleChange(
|
177
|
+
handleChange() {
|
187
178
|
var _a;
|
188
179
|
if (this.disabled || this.readonly)
|
189
180
|
return;
|
@@ -204,7 +195,7 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
204
195
|
if (inputElement) {
|
205
196
|
inputElement.checked = true;
|
206
197
|
}
|
207
|
-
this.
|
198
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
208
199
|
}
|
209
200
|
/**
|
210
201
|
* Updates the state of the radio button at the specified index within the enabled radios.
|
@@ -212,12 +203,11 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
212
203
|
*
|
213
204
|
* @param enabledRadios - An array of enabled radio buttons within the same group.
|
214
205
|
* @param index - The index of the radio button to be updated within the enabled radios array.
|
215
|
-
* @param event - The event that triggered the update.
|
216
206
|
*/
|
217
|
-
updateRadio(enabledRadios, index
|
207
|
+
updateRadio(enabledRadios, index) {
|
218
208
|
var _a, _b;
|
219
209
|
(_b = (_a = enabledRadios[index].shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('input')) === null || _b === void 0 ? void 0 : _b.focus();
|
220
|
-
enabledRadios[index].handleChange(
|
210
|
+
enabledRadios[index].handleChange();
|
221
211
|
}
|
222
212
|
/**
|
223
213
|
* Handles the keydown event (Arrow Up/Down/Left/Right) on the radio element.
|
@@ -232,15 +222,15 @@ class Radio extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
232
222
|
if (['ArrowDown', 'ArrowRight'].includes(event.key)) {
|
233
223
|
// Move focus to the next radio
|
234
224
|
const nextIndex = (currentIndex + 1) % enabledRadios.length;
|
235
|
-
this.updateRadio(enabledRadios, nextIndex
|
225
|
+
this.updateRadio(enabledRadios, nextIndex);
|
236
226
|
}
|
237
227
|
else if (['ArrowUp', 'ArrowLeft'].includes(event.key)) {
|
238
228
|
// Move focus to the previous radio
|
239
229
|
const prevIndex = (currentIndex - 1 + enabledRadios.length) % enabledRadios.length;
|
240
|
-
this.updateRadio(enabledRadios, prevIndex
|
230
|
+
this.updateRadio(enabledRadios, prevIndex);
|
241
231
|
}
|
242
232
|
else if (event.key === KEYS.SPACE) {
|
243
|
-
this.updateRadio(enabledRadios, currentIndex
|
233
|
+
this.updateRadio(enabledRadios, currentIndex);
|
244
234
|
}
|
245
235
|
this.updateTabIndex();
|
246
236
|
if (event.key === KEYS.ENTER) {
|
@@ -349,54 +349,52 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
349
349
|
* @param event - The keyboard event.
|
350
350
|
*/
|
351
351
|
handlePopoverKeydown(event) {
|
352
|
+
let optionToFocus = null;
|
352
353
|
switch (event.key) {
|
353
354
|
case KEYS.HOME: {
|
354
|
-
|
355
|
-
this.focusAndUpdateTabIndexes(firstOption);
|
356
|
-
event.preventDefault();
|
355
|
+
optionToFocus = this.getFirstValidOption();
|
357
356
|
break;
|
358
357
|
}
|
359
358
|
case KEYS.END: {
|
360
|
-
|
361
|
-
this.focusAndUpdateTabIndexes(lastOption);
|
362
|
-
event.preventDefault();
|
359
|
+
optionToFocus = this.getLastValidOption();
|
363
360
|
break;
|
364
361
|
}
|
365
362
|
case KEYS.ARROW_DOWN: {
|
366
363
|
const options = this.getAllValidOptions();
|
367
364
|
const currentIndex = options.findIndex(option => option === event.target);
|
368
365
|
const newIndex = Math.min(currentIndex + 1, options.length - 1);
|
369
|
-
|
370
|
-
event.preventDefault();
|
366
|
+
optionToFocus = options[newIndex];
|
371
367
|
break;
|
372
368
|
}
|
373
369
|
case KEYS.ARROW_UP: {
|
374
370
|
const options = this.getAllValidOptions();
|
375
371
|
const currentIndex = options.findIndex(option => option === event.target);
|
376
372
|
const newIndex = Math.max(currentIndex - 1, 0);
|
377
|
-
|
378
|
-
event.preventDefault();
|
373
|
+
optionToFocus = options[newIndex];
|
379
374
|
break;
|
380
375
|
}
|
381
376
|
case KEYS.PAGE_DOWN: {
|
382
377
|
const options = this.getAllValidOptions();
|
383
378
|
const currentIndex = options.findIndex(option => option === event.target);
|
384
379
|
const newIndex = Math.min(currentIndex + 10, options.length - 1);
|
385
|
-
|
386
|
-
event.preventDefault();
|
380
|
+
optionToFocus = options[newIndex];
|
387
381
|
break;
|
388
382
|
}
|
389
383
|
case KEYS.PAGE_UP: {
|
390
384
|
const options = this.getAllValidOptions();
|
391
385
|
const currentIndex = options.findIndex(option => option === event.target);
|
392
386
|
const newIndex = Math.max(currentIndex - 10, 0);
|
393
|
-
|
394
|
-
event.preventDefault();
|
387
|
+
optionToFocus = options[newIndex];
|
395
388
|
break;
|
396
389
|
}
|
397
390
|
default:
|
398
391
|
break;
|
399
392
|
}
|
393
|
+
if (optionToFocus) {
|
394
|
+
this.focusAndUpdateTabIndexes(optionToFocus);
|
395
|
+
event.preventDefault();
|
396
|
+
event.stopPropagation();
|
397
|
+
}
|
400
398
|
}
|
401
399
|
/**
|
402
400
|
* Focuses the given option and updates the tabindex for all options.
|