@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.
@@ -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: TypedEvent<Select, {
8
- value: string;
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 };