@momentum-design/components 0.112.5 → 0.112.7

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.
Files changed (35) hide show
  1. package/dist/browser/index.js +624 -438
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/buttonlink/buttonlink.component.d.ts +1 -1
  4. package/dist/components/buttonlink/buttonlink.component.js +6 -31
  5. package/dist/components/combobox/combobox.component.d.ts +261 -7
  6. package/dist/components/combobox/combobox.component.js +737 -9
  7. package/dist/components/combobox/combobox.constants.d.ts +8 -1
  8. package/dist/components/combobox/combobox.constants.js +8 -1
  9. package/dist/components/combobox/combobox.events.d.ts +27 -0
  10. package/dist/components/combobox/combobox.events.js +35 -0
  11. package/dist/components/combobox/combobox.styles.js +122 -1
  12. package/dist/components/combobox/combobox.types.d.ts +22 -1
  13. package/dist/components/combobox/combobox.types.js +0 -1
  14. package/dist/components/combobox/index.d.ts +5 -0
  15. package/dist/components/combobox/index.js +5 -0
  16. package/dist/components/divider/divider.styles.js +4 -0
  17. package/dist/components/input/input.styles.js +10 -10
  18. package/dist/components/link/link.component.d.ts +1 -1
  19. package/dist/components/link/link.component.js +5 -29
  20. package/dist/components/linksimple/linksimple.component.d.ts +7 -2
  21. package/dist/components/linksimple/linksimple.component.js +11 -8
  22. package/dist/components/optgroup/optgroup.styles.js +3 -0
  23. package/dist/components/option/option.styles.d.ts +2 -2
  24. package/dist/components/option/option.styles.js +36 -23
  25. package/dist/components/popover/popover.component.d.ts +2 -2
  26. package/dist/components/popover/popover.component.js +1 -1
  27. package/dist/components/popover/popover.constants.d.ts +5 -1
  28. package/dist/components/popover/popover.constants.js +7 -2
  29. package/dist/components/popover/popover.types.d.ts +3 -2
  30. package/dist/custom-elements.json +7601 -6446
  31. package/dist/react/combobox/index.d.ts +71 -4
  32. package/dist/react/combobox/index.js +60 -4
  33. package/dist/react/index.d.ts +5 -5
  34. package/dist/react/index.js +5 -5
  35. package/package.json +1 -1
@@ -58,7 +58,7 @@ declare class ButtonLink extends ButtonLink_base {
58
58
  */
59
59
  private setSoftDisabled;
60
60
  update(changedProperties: PropertyValues): void;
61
- render(): import("lit-html").TemplateResult<1>;
61
+ protected renderAnchorContent(): import("lit-html").TemplateResult<1>;
62
62
  static styles: Array<CSSResult>;
63
63
  }
64
64
  export default ButtonLink;
@@ -9,7 +9,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  import { html } from 'lit';
11
11
  import { property } from 'lit/decorators.js';
12
- import { ifDefined } from 'lit/directives/if-defined.js';
13
12
  import Button from '../button/button.component';
14
13
  import { ButtonComponentMixin } from '../../utils/mixins/ButtonComponentMixin';
15
14
  import { DEFAULTS } from '../button/button.constants';
@@ -91,39 +90,15 @@ class ButtonLink extends ButtonComponentMixin(Linksimple) {
91
90
  this.inferButtonType();
92
91
  }
93
92
  }
94
- render() {
95
- var _a;
93
+ renderAnchorContent() {
96
94
  return html `
97
- <a
98
- class="mdc-focus-ring"
99
- part="anchor"
100
- href="${this.href}"
101
- target="${this.target}"
102
- rel="${ifDefined(this.rel)}"
103
- download="${ifDefined(this.download)}"
104
- ping="${ifDefined(this.ping)}"
105
- hreflang="${ifDefined(this.hreflang)}"
106
- type="${ifDefined(this.type)}"
107
- referrerpolicy="${ifDefined(this.referrerpolicy)}"
108
- aria-label="${(_a = this.dataAriaLabel) !== null && _a !== void 0 ? _a : ''}"
109
- tabindex="${this.disabled ? -1 : 0}"
110
- >
111
- ${this.prefixIcon
112
- ? html `<mdc-icon
113
- name="${this.prefixIcon}"
114
- part="prefix-icon"
115
- length-unit="rem"
116
- ></mdc-icon>`
95
+ ${this.prefixIcon
96
+ ? html `<mdc-icon name="${this.prefixIcon}" part="prefix-icon" length-unit="rem"></mdc-icon>`
117
97
  : ''}
118
- <slot @slotchange="${this.inferButtonType}" part="button-text"></slot>
119
- ${this.postfixIcon
120
- ? html `<mdc-icon
121
- name="${this.postfixIcon}"
122
- part="postfix-icon"
123
- length-unit="rem"
124
- ></mdc-icon>`
98
+ <slot @slotchange="${this.inferButtonType}" part="button-text"></slot>
99
+ ${this.postfixIcon
100
+ ? html `<mdc-icon name="${this.postfixIcon}" part="postfix-icon" length-unit="rem"></mdc-icon>`
125
101
  : ''}
126
- </a>
127
102
  `;
128
103
  }
129
104
  }
@@ -1,16 +1,270 @@
1
- import { CSSResult } from 'lit';
2
- import { Component } from '../../models';
1
+ import type { CSSResult, PropertyValues, TemplateResult } from 'lit';
2
+ import { AssociatedFormControl } from '../../utils/mixins/FormInternalsMixin';
3
+ import FormfieldWrapper from '../formfieldwrapper/formfieldwrapper.component';
4
+ import type Option from '../option/option.component';
5
+ import type { PopoverStrategy } from '../popover/popover.types';
6
+ import type { Placement } from './combobox.types';
7
+ declare const Combobox_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/lifecycle/CaptureDestroyEventForChildElement").CaptureDestroyEventForChildElementInterface> & import("../../utils/mixins/index.types").Constructor<import("../../models/component/component.component").default & import("../../utils/mixins/AutoFocusOnMountMixin").AutoFocusOnMountMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/FormInternalsMixin").FormInternalsMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & typeof FormfieldWrapper;
3
8
  /**
4
- * combobox component, which ...
9
+ * The Combobox component is a text-based dropdown control that allows users to select an option from a predefined list.
10
+ * Users can type text to filter the options and select their desired choice.
11
+ *
12
+ * When the user starts typing, the filter uses a "starts with" search and displays options based on the text entered by the user.
13
+ * If the user entered text that doesn't match with any of the options, then the text in the `no-result-text` attribute will be displayed.
14
+ *
15
+ * If there is no text in the `no-result-text` attribute then nothing will be shown.
16
+ *
17
+ * Combobox is designed to work with `mdc-option` for individual options and `mdc-optgroup` for grouping related options.
18
+ * The component ensures accessibility and usability while handling various use cases, including long text truncation with tooltip support.
19
+ *
20
+ * Every mdc-option should have a `value` attribute set to ensure proper form submission.
21
+ *
22
+ * To set a default option, use the `selected` attribute on the `mdc-option` element.
23
+ *
24
+ * **Note:** Make sure to add `mdc-selectlistbox` as a child of `mdc-combobox` and wrap options/optgroup in it to ensure proper accessibility functionality. Read more about it in SelectListBox documentation.
25
+ *
26
+ * If you need to use `mdc-tooltip` with any options, make sure to place the tooltip component outside the `mdc-selectlistbox` element. Read more about it in Options documentation.
27
+ *
28
+ * To understand more about combobox and its patterns, refer to this [WCAG example](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-autocomplete-list/).
29
+ *
30
+ * @dependency mdc-buttonsimple
31
+ * @dependency mdc-icon
32
+ * @dependency mdc-input
33
+ * @dependency mdc-listitem
34
+ * @dependency mdc-popover
5
35
  *
6
36
  * @tagname mdc-combobox
7
37
  *
8
- * @slot default - This is a default/unnamed slot
38
+ * @slot default - This is a default/unnamed slot for Selectlistbox including options and/or option group.
39
+ *
40
+ * @event click - (React: onClick) This event is dispatched when the combobox is clicked.
41
+ * @event change - (React: onChange) This event is dispatched when the combobox is changed.
42
+ * @event input - (React: onInput) This event is dispatched when the combobox is changed.
43
+ * @event keydown - (React: onKeyDown) This event is dispatched when a key is pressed down on the combobox.
44
+ * @event focus - (React: onFocus) This event is dispatched when the combobox receives focus.
45
+ *
46
+ * @cssproperty --mdc-combobox-border-color - The border color of the combobox
47
+ * @cssproperty --mdc-combobox-icon-color - The icon color of the combobox
48
+ * @cssproperty --mdc-combobox-listbox-height - The height of the listbox inside the combobox
49
+ * @cssproperty --mdc-combobox-listbox-width - The width of the listbox inside the combobox
50
+ * @cssproperty --mdc-combobox-width - The width of the combobox
51
+ * @cssproperty --mdc-combobox-hover-background-color - The background color of the combobox when hovered
52
+ * @cssproperty --mdc-combobox-focused-background-color - The background color of the combobox when focused
53
+ * @cssproperty --mdc-combobox-error-border-color - The border color of the combobox when in error state
54
+ * @cssproperty --mdc-combobox-warning-border-color - The border color of the combobox when in warning state
55
+ * @cssproperty --mdc-combobox-success-border-color - The border color of the combobox when in success state
56
+ * @cssproperty --mdc-combobox-primary-border-color - The border color of the combobox when in primary state
57
+ * @cssproperty --mdc-combobox-text-color-disabled - The text color of the combobox when disabled
58
+ * @cssproperty --mdc-combobox-focused-border-color - The border color of the combobox when focused
9
59
  *
10
- * @cssproperty --custom-property-name - Description of the CSS custom property
60
+ * @csspart internal-native-input - The internal native input element of the combobox.
61
+ * @csspart mdc-input - The input element of the combobox.
62
+ * @csspart no-result-text - The no result text element of the combobox.
63
+ * @csspart combobox__base - The base container element of the combobox.
64
+ * @csspart combobox__button - The button element of the combobox.
65
+ * @csspart combobox__button-icon - The icon element of the button of the combobox.
11
66
  */
12
- declare class Combobox extends Component {
13
- render(): import("lit-html").TemplateResult<1>;
67
+ declare class Combobox extends Combobox_base implements AssociatedFormControl {
68
+ /** @internal */
69
+ private itemsStore;
70
+ /**
71
+ * The placeholder text which will be shown on the text if provided.
72
+ */
73
+ placeholder?: string;
74
+ /**
75
+ * readonly attribute of the combobox field. If true, the combobox is read-only.
76
+ * @default false
77
+ */
78
+ readonly: boolean;
79
+ /**
80
+ * The placement of the popover within Combobox.
81
+ * This defines the position of the popover relative to the combobox input field.
82
+ *
83
+ * Possible values:
84
+ * - 'top-start'
85
+ * - 'bottom-start'
86
+ * @default 'bottom-start'
87
+ */
88
+ placement: Placement;
89
+ /**
90
+ * Text to be displayed when no results are found.
91
+ * @default undefined
92
+ */
93
+ noResultText?: string;
94
+ /**
95
+ * Text to be displayed when no a custom values are selected, without selecting any option from the dropdown
96
+ * @default undefined
97
+ */
98
+ invalidCustomValueText?: string;
99
+ /**
100
+ * This describes the clipping element(s) or area relative to which the overflow of the popover will be checked.
101
+ * The default is 'clippingAncestors', which are the overflow ancestors that can cause the element to be clipped.
102
+ * Possible values:
103
+ * - 'clippingAncestors'
104
+ * - any css selector
105
+ *
106
+ * @default 'clippingAncestors'
107
+ *
108
+ * @see [Floating UI - boundary](https://floating-ui.com/docs/detectOverflow#boundary)
109
+ */
110
+ boundary: 'clippingAncestors' | string;
111
+ /**
112
+ * The strategy of the popover within Combobox.
113
+ * This determines how the popover is positioned in the DOM.
114
+ *
115
+ * In case `boundary` is set to something other than 'clippingAncestors',
116
+ * it might be necessary to set the `strategy` to 'fixed' to ensure that the popover
117
+ * is not getting clipped by scrollable containers enclosing the combobox.
118
+ *
119
+ * @default absolute
120
+ * @see [Floating UI - strategy](https://floating-ui.com/docs/computePosition#strategy)
121
+ */
122
+ strategy: PopoverStrategy;
123
+ /**
124
+ * The z-index of the popover within Combobox.
125
+ *
126
+ * Override this to make sure this stays on top of other components.
127
+ * @default 1000
128
+ */
129
+ popoverZIndex: number;
130
+ /**
131
+ * ID of the element where the backdrop will be appended to.
132
+ * This is useful to ensure that the backdrop is appended to the correct element in the DOM.
133
+ * If not set, the backdrop will be appended to the parent element of the combobox.
134
+ */
135
+ backdropAppendTo?: string;
136
+ /** @internal */
137
+ private visualCombobox;
138
+ /** @internal */
139
+ private dropDownButton;
140
+ /** @internal */
141
+ slottedListboxes: Array<HTMLElement>;
142
+ /** @internal */
143
+ private isOpen;
144
+ /** @internal */
145
+ private filteredValue;
146
+ /** @internal */
147
+ private initialSelectedOption;
148
+ /** @internal */
149
+ get navItems(): Option[];
150
+ constructor();
151
+ connectedCallback(): void;
152
+ private isValidItem;
153
+ private openPopover;
154
+ private closePopover;
155
+ private toggleDropdown;
156
+ private compareOptionWithValue;
157
+ private getFirstSelectedOption;
158
+ private getVisibleOptions;
159
+ private handleUpdateError;
160
+ /**
161
+ * Update the focus when an item is removed.
162
+ * If there is a next item, focus it. If not, focus the previous item.
163
+ *
164
+ * @internal
165
+ */
166
+ private handleDestroyEvent;
167
+ private setSelectedValue;
168
+ /**
169
+ * Resets the selected value to an empty string and clears the form value.
170
+ * This method is called when there is a change on the input.
171
+ */
172
+ private resetSelectedValue;
173
+ private resetHelpText;
174
+ /**
175
+ * This function is called when the attribute changes.
176
+ * It updates the validity of the input field based on the input field's validity.
177
+ *
178
+ * @param name - attribute name
179
+ * @param old - old value
180
+ * @param value - new value
181
+ */
182
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
183
+ protected firstUpdated(_changedProperties: PropertyValues): Promise<void>;
184
+ updated(changedProperties: PropertyValues): void;
185
+ /**
186
+ * Sets the validity of the input element based on the selected option.
187
+ * If the selected option is not set and the combobox is required,
188
+ * it sets a custom validation message.
189
+ * If the selected option is set or the combobox is not required,
190
+ * it clears the custom validation message.
191
+ * This method is called to ensure that the combobox component behaves correctly
192
+ * in form validation scenarios, especially when the combobox is required.
193
+ * @internal
194
+ */
195
+ private setInputValidity;
196
+ /**
197
+ * Resets the combobox to its initially selected option.
198
+ * @internal
199
+ */
200
+ formResetCallback(): void;
201
+ /** @internal */
202
+ formStateRestoreCallback(state: string): void;
203
+ /**
204
+ * When the native input is focused, visually highlight the dropdown options (the "visual combobox"),
205
+ * so users can see which option is active, even though the actual DOM focus remains on the input box.
206
+ * This ensures that after actions like form submission, users can still interact with the dropdown options
207
+ * through visual cues, while keyboard focus stays on the input field.
208
+ * @internal
209
+ */
210
+ private handleNativeInputFocus;
211
+ /**
212
+ * Resets the focused option in the dropdown list.
213
+ * This method removes the 'data-focused' attribute from all options that currently have it,
214
+ * effectively clearing any visual indication of focus within the dropdown.
215
+ * It is typically called when the user navigates away from the dropdown or when the dropdown is closed,
216
+ * ensuring that no option remains visually highlighted as focused.
217
+ * @internal
218
+ */
219
+ private resetFocusedOption;
220
+ private updateSelectedOption;
221
+ /**
222
+ * Updates the visual focus state of a specific option in the dropdown list based on 'data-focused' attribute.
223
+ * It also updates the 'aria-selected' attribute for a11y purposes.
224
+ *
225
+ * @param option - The option element to update focus state for.
226
+ * @param value - The new focus state to set (true for focused, false for unfocused).
227
+ */
228
+ private updateOptionAttributes;
229
+ /**
230
+ * Handles the blur event of the combobox.
231
+ * This method is called when the combobox loses focus.
232
+ * It checks if the combobox has a focused option and sets the selected value to that option and closes the popover.
233
+ * If the combobox does not have a focused option and the filtered value is not empty,
234
+ * it sets the help text to the invalid custom value text and closes the popover.
235
+ * It also updates the input validity.
236
+ */
237
+ private handleBlurChange;
238
+ private updateFocusAndScrollIntoView;
239
+ private handleInputKeydown;
240
+ /**
241
+ * Updates the hidden state of options based on the current filtered value.
242
+ * If an option does not match the current filtered value, it is hidden.
243
+ * Otherwise, it is made visible.
244
+ * Additionally, it updates the hidden state of option groups and dividers based on the current filtered value.
245
+ */
246
+ private updateHiddenOptions;
247
+ private hideOptionGroupAndDivider;
248
+ private showOptionGroupAndDivider;
249
+ private handleInputChange;
250
+ private handleOptionsClick;
251
+ private shouldDisplayPopover;
252
+ /**
253
+ * Renders the native input element.
254
+ * This input is hidden and is used for internal purposes only.
255
+ * The value of the selected option is set as the value of this input.
256
+ * @internal
257
+ */
258
+ private renderNativeInput;
259
+ /**
260
+ * Renders the base input element with accessibility.
261
+ * This input is displayed on the screen and is used for user interaction only.
262
+ * The label of the selected option is set as the value of this input.
263
+ * @internal
264
+ */
265
+ private renderBaseInput;
266
+ private renderNoResultsText;
267
+ render(): TemplateResult<1>;
14
268
  static styles: Array<CSSResult>;
15
269
  }
16
270
  export default Combobox;