@momentum-design/components 0.87.0 → 0.87.1
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 +1 -1
- package/dist/browser/index.js.map +2 -2
- package/dist/components/select/select.component.d.ts +4 -1
- package/dist/components/select/select.component.js +15 -7
- package/dist/components/select/select.types.d.ts +1 -0
- package/dist/custom-elements.json +1264 -1238
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/select/index.d.ts +4 -0
- package/dist/react/select/index.js +4 -0
- package/package.json +1 -1
@@ -10,6 +10,8 @@ declare const Select_base: import("../../utils/mixins/index.types").Constructor<
|
|
10
10
|
* The component ensures accessibility and usability while handling various use cases,
|
11
11
|
* including long text truncation with tooltip support.
|
12
12
|
*
|
13
|
+
* To set a default option, use the `selected` attribute on the `mdc-option` element.
|
14
|
+
*
|
13
15
|
* @dependency mdc-button
|
14
16
|
* @dependency mdc-icon
|
15
17
|
* @dependency mdc-popover
|
@@ -22,6 +24,7 @@ declare const Select_base: import("../../utils/mixins/index.types").Constructor<
|
|
22
24
|
*
|
23
25
|
* @event click - (React: onClick) This event is dispatched when the select is clicked.
|
24
26
|
* @event change - (React: onChange) This event is dispatched when the select is changed.
|
27
|
+
* @event input - (React: onInput) This event is dispatched when the select is changed.
|
25
28
|
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the select.
|
26
29
|
* @event focus - (React: onFocus) This event is dispatched when the select receives focus.
|
27
30
|
*/
|
@@ -60,7 +63,6 @@ declare class Select extends Select_base implements AssociatedFormControl {
|
|
60
63
|
* The native select element
|
61
64
|
*/
|
62
65
|
inputElement: HTMLInputElement;
|
63
|
-
connectedCallback(): void;
|
64
66
|
/**
|
65
67
|
* A helper function which returns a flattened array of all valid options from the assigned slot.
|
66
68
|
* It takes care of the edge cases where the option is either a direct child or a
|
@@ -106,6 +108,7 @@ declare class Select extends Select_base implements AssociatedFormControl {
|
|
106
108
|
/** @internal */
|
107
109
|
formStateRestoreCallback(state: string): void;
|
108
110
|
private dispatchChange;
|
111
|
+
private dispatchInput;
|
109
112
|
/**
|
110
113
|
* Handles the keydown event on the select element when the popover is open.
|
111
114
|
* The options are as follows:
|
@@ -28,6 +28,8 @@ import styles from './select.styles';
|
|
28
28
|
* The component ensures accessibility and usability while handling various use cases,
|
29
29
|
* including long text truncation with tooltip support.
|
30
30
|
*
|
31
|
+
* To set a default option, use the `selected` attribute on the `mdc-option` element.
|
32
|
+
*
|
31
33
|
* @dependency mdc-button
|
32
34
|
* @dependency mdc-icon
|
33
35
|
* @dependency mdc-popover
|
@@ -40,6 +42,7 @@ import styles from './select.styles';
|
|
40
42
|
*
|
41
43
|
* @event click - (React: onClick) This event is dispatched when the select is clicked.
|
42
44
|
* @event change - (React: onChange) This event is dispatched when the select is changed.
|
45
|
+
* @event input - (React: onInput) This event is dispatched when the select is changed.
|
43
46
|
* @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the select.
|
44
47
|
* @event focus - (React: onFocus) This event is dispatched when the select receives focus.
|
45
48
|
*/
|
@@ -66,11 +69,6 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
66
69
|
/** @internal */
|
67
70
|
this.activeDescendant = '';
|
68
71
|
}
|
69
|
-
connectedCallback() {
|
70
|
-
super.connectedCallback();
|
71
|
-
// select will only contain name and value will be defined in the options.
|
72
|
-
this.value = undefined;
|
73
|
-
}
|
74
72
|
/**
|
75
73
|
* A helper function which returns a flattened array of all valid options from the assigned slot.
|
76
74
|
* It takes care of the edge cases where the option is either a direct child or a
|
@@ -142,10 +140,12 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
142
140
|
this.selectedValueText = (_b = (_a = option === null || option === void 0 ? void 0 : option.getAttribute('label')) !== null && _a !== void 0 ? _a : option === null || option === void 0 ? void 0 : option.textContent) !== null && _b !== void 0 ? _b : '';
|
143
141
|
this.selectedIcon = option === null || option === void 0 ? void 0 : option.getAttribute('prefix-icon');
|
144
142
|
this.selectedValue = (_d = (_c = option === null || option === void 0 ? void 0 : option.getAttribute('value')) !== null && _c !== void 0 ? _c : option === null || option === void 0 ? void 0 : option.textContent) !== null && _d !== void 0 ? _d : '';
|
143
|
+
this.value = this.selectedValue;
|
145
144
|
// Set form value
|
146
145
|
this.internals.setFormValue(this.selectedValue);
|
147
146
|
this.manageRequired();
|
148
147
|
// dispatch a change event when a value is selected
|
148
|
+
this.dispatchInput(this.selectedValue);
|
149
149
|
this.dispatchChange(this.selectedValue);
|
150
150
|
}
|
151
151
|
/**
|
@@ -196,6 +196,16 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
196
196
|
bubbles: true,
|
197
197
|
}));
|
198
198
|
}
|
199
|
+
dispatchInput(value) {
|
200
|
+
if (!value) {
|
201
|
+
return;
|
202
|
+
}
|
203
|
+
this.dispatchEvent(new CustomEvent('input', {
|
204
|
+
detail: { value },
|
205
|
+
composed: true,
|
206
|
+
bubbles: true,
|
207
|
+
}));
|
208
|
+
}
|
199
209
|
/**
|
200
210
|
* Handles the keydown event on the select element when the popover is open.
|
201
211
|
* The options are as follows:
|
@@ -215,12 +225,10 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
215
225
|
break;
|
216
226
|
}
|
217
227
|
case KEYS.SPACE:
|
218
|
-
this.updateTabIndexForAllOptions(event.target);
|
219
228
|
this.closePopover();
|
220
229
|
event.preventDefault();
|
221
230
|
break;
|
222
231
|
case KEYS.ENTER:
|
223
|
-
this.updateTabIndexForAllOptions(event.target);
|
224
232
|
this.closePopover();
|
225
233
|
event.preventDefault();
|
226
234
|
// if the popover is closed, then we submit the form.
|