@momentum-design/components 0.95.2 → 0.95.4
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 +3 -3
- package/dist/components/select/select.component.d.ts +7 -0
- package/dist/components/select/select.component.js +16 -0
- package/dist/components/select/select.types.d.ts +9 -7
- package/dist/custom-elements.json +468 -457
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/select/index.d.ts +2 -6
- package/package.json +1 -1
@@ -187,6 +187,13 @@ declare class Select extends Select_base implements AssociatedFormControl {
|
|
187
187
|
* @internal
|
188
188
|
*/
|
189
189
|
private handleNativeInputFocus;
|
190
|
+
/**
|
191
|
+
* Updates the state of the select component.
|
192
|
+
* This public method should be fired when the selected on the option components is updated from the outside.
|
193
|
+
* It ensures that the selected attribute is set correctly on the options
|
194
|
+
* and that the aria-selected attribute is updated accordingly.
|
195
|
+
*/
|
196
|
+
updateState(): void;
|
190
197
|
render(): import("lit-html").TemplateResult<1>;
|
191
198
|
static styles: Array<CSSResult>;
|
192
199
|
}
|
@@ -419,6 +419,22 @@ class Select extends FormInternalsMixin(DataAriaLabelMixin(FormfieldWrapper)) {
|
|
419
419
|
handleNativeInputFocus() {
|
420
420
|
this.visualCombobox.focus();
|
421
421
|
}
|
422
|
+
/**
|
423
|
+
* Updates the state of the select component.
|
424
|
+
* This public method should be fired when the selected on the option components is updated from the outside.
|
425
|
+
* It ensures that the selected attribute is set correctly on the options
|
426
|
+
* and that the aria-selected attribute is updated accordingly.
|
427
|
+
*/
|
428
|
+
updateState() {
|
429
|
+
var _a;
|
430
|
+
const newSelectedOption = this.getFirstSelectedOption();
|
431
|
+
if (!newSelectedOption) {
|
432
|
+
this.setSelectedOption(this.placeholder ? null : this.getFirstValidOption());
|
433
|
+
}
|
434
|
+
else if (((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.value) !== newSelectedOption.value) {
|
435
|
+
this.setSelectedOption(newSelectedOption);
|
436
|
+
}
|
437
|
+
}
|
422
438
|
render() {
|
423
439
|
var _a, _b, _c, _d, _e, _f;
|
424
440
|
return html `
|
@@ -2,17 +2,19 @@ import type { ValueOf, TypedEvent } from '../../utils/types';
|
|
2
2
|
import type { PopoverPlacement } from '../popover/popover.types';
|
3
3
|
import type Select from './select.component';
|
4
4
|
import { ARROW_ICON } from './select.constants';
|
5
|
+
type SelectChangeEvent = TypedEvent<Select, {
|
6
|
+
value: string;
|
7
|
+
}>;
|
8
|
+
type SelectInputEvent = TypedEvent<Select, {
|
9
|
+
value: string;
|
10
|
+
}>;
|
5
11
|
interface Events {
|
6
12
|
onClickEvent: MouseEvent;
|
7
|
-
onChangeEvent:
|
8
|
-
|
9
|
-
}>;
|
10
|
-
onInputEvent: TypedEvent<Select, {
|
11
|
-
value: string;
|
12
|
-
}>;
|
13
|
+
onChangeEvent: SelectChangeEvent;
|
14
|
+
onInputEvent: SelectInputEvent;
|
13
15
|
onKeyDownEvent: KeyboardEvent;
|
14
16
|
onFocusEvent: FocusEvent;
|
15
17
|
}
|
16
18
|
type Placement = Extract<PopoverPlacement, 'bottom-start' | 'top-start'>;
|
17
19
|
type ArrowIcon = ValueOf<typeof ARROW_ICON>;
|
18
|
-
export type { Events, ArrowIcon, Placement };
|
20
|
+
export type { Events, ArrowIcon, Placement, SelectChangeEvent, SelectInputEvent };
|