@momentum-design/components 0.95.3 → 0.95.5

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.
@@ -1,5 +1,4 @@
1
- import type { CSSResult, PropertyValues, TemplateResult } from 'lit';
2
- import { nothing } from 'lit';
1
+ import { CSSResult, PropertyValues, TemplateResult } from 'lit';
3
2
  import { Component } from '../../models';
4
3
  import type { PopoverPlacement } from '../popover/popover.types';
5
4
  import type { TextType } from '../text/text.types';
@@ -146,7 +145,7 @@ declare class ListItem extends ListItem_base {
146
145
  * @param content - The text content to be displayed within the slot.
147
146
  * @returns A TemplateResult containing a slot with an `mdc-text` element of type BODY_SMALL_REGULAR.
148
147
  */
149
- protected getText(slotName: string, type: TextType, content?: string): TemplateResult | typeof nothing;
148
+ protected getText(slotName: string, type: TextType, content?: string): TemplateResult;
150
149
  /**
151
150
  * Disable or enable all slotted elements in the leading and trailing slots.
152
151
  * This is useful when the list item is disabled, to prevent the user from interacting with the controls.
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  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
- import { html, nothing } from 'lit';
10
+ import { nothing, html } from 'lit';
11
11
  import { property, queryAssignedElements } from 'lit/decorators.js';
12
12
  import { Component } from '../../models';
13
13
  import { KEYS } from '../../utils/keys';
@@ -176,12 +176,11 @@ class ListItem extends DisabledMixin(TabIndexMixin(Component)) {
176
176
  * @returns A TemplateResult containing a slot with an `mdc-text` element of type BODY_SMALL_REGULAR.
177
177
  */
178
178
  getText(slotName, type, content) {
179
- if (!content) {
180
- return nothing;
181
- }
182
179
  return html `
183
180
  <slot name="${slotName}">
184
- <mdc-text part="${slotName}" type="${type}" tagname="${VALID_TEXT_TAGS.SPAN}">${content}</mdc-text>
181
+ ${content
182
+ ? html `<mdc-text part="${slotName}" type="${type}" tagname="${VALID_TEXT_TAGS.SPAN}">${content}</mdc-text>`
183
+ : nothing}
185
184
  </slot>
186
185
  `;
187
186
  }
@@ -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 `