@momentum-design/components 0.112.6 → 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 (29) hide show
  1. package/dist/browser/index.js +619 -388
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/combobox/combobox.component.d.ts +261 -7
  4. package/dist/components/combobox/combobox.component.js +737 -9
  5. package/dist/components/combobox/combobox.constants.d.ts +8 -1
  6. package/dist/components/combobox/combobox.constants.js +8 -1
  7. package/dist/components/combobox/combobox.events.d.ts +27 -0
  8. package/dist/components/combobox/combobox.events.js +35 -0
  9. package/dist/components/combobox/combobox.styles.js +122 -1
  10. package/dist/components/combobox/combobox.types.d.ts +22 -1
  11. package/dist/components/combobox/combobox.types.js +0 -1
  12. package/dist/components/combobox/index.d.ts +5 -0
  13. package/dist/components/combobox/index.js +5 -0
  14. package/dist/components/divider/divider.styles.js +4 -0
  15. package/dist/components/input/input.styles.js +10 -10
  16. package/dist/components/optgroup/optgroup.styles.js +3 -0
  17. package/dist/components/option/option.styles.d.ts +2 -2
  18. package/dist/components/option/option.styles.js +36 -23
  19. package/dist/components/popover/popover.component.d.ts +2 -2
  20. package/dist/components/popover/popover.component.js +1 -1
  21. package/dist/components/popover/popover.constants.d.ts +5 -1
  22. package/dist/components/popover/popover.constants.js +7 -2
  23. package/dist/components/popover/popover.types.d.ts +3 -2
  24. package/dist/custom-elements.json +8370 -7219
  25. package/dist/react/combobox/index.d.ts +71 -4
  26. package/dist/react/combobox/index.js +60 -4
  27. package/dist/react/index.d.ts +6 -6
  28. package/dist/react/index.js +6 -6
  29. package/package.json +1 -1
@@ -1,2 +1,9 @@
1
1
  declare const TAG_NAME: "mdc-combobox";
2
- export { TAG_NAME };
2
+ declare const ICON_NAME: {
3
+ readonly ARROW_UP: "arrow-up-bold";
4
+ readonly ARROW_DOWN: "arrow-down-bold";
5
+ };
6
+ declare const AUTOCOMPLETE_LIST = "list";
7
+ declare const LISTBOX_ID = "combobox-listbox-id";
8
+ declare const TRIGGER_ID = "combobox-trigger-id";
9
+ export { TAG_NAME, ICON_NAME, TRIGGER_ID, LISTBOX_ID, AUTOCOMPLETE_LIST };
@@ -1,3 +1,10 @@
1
1
  import utils from '../../utils/tag-name';
2
2
  const TAG_NAME = utils.constructTagName('combobox');
3
- export { TAG_NAME };
3
+ const ICON_NAME = {
4
+ ARROW_UP: 'arrow-up-bold',
5
+ ARROW_DOWN: 'arrow-down-bold',
6
+ };
7
+ const AUTOCOMPLETE_LIST = 'list';
8
+ const LISTBOX_ID = 'combobox-listbox-id';
9
+ const TRIGGER_ID = 'combobox-trigger-id';
10
+ export { TAG_NAME, ICON_NAME, TRIGGER_ID, LISTBOX_ID, AUTOCOMPLETE_LIST };
@@ -0,0 +1,27 @@
1
+ import type Option from '../option/option.component';
2
+ import type Combobox from './combobox.component';
3
+ export declare class ComboboxEventManager {
4
+ /**
5
+ * Dispatches a custom event for the Combobox.
6
+ *
7
+ * @param instance - The combobox instance.
8
+ * @param eventName - The name of the event.
9
+ * @param option - The option that triggered the event.
10
+ * @param bubbles - Whether the event should bubble up the DOM tree.
11
+ */
12
+ static dispatchComboboxEvent(instance: Combobox, eventName: string, option: Option, bubbles?: boolean): void;
13
+ /**
14
+ * Dispatches a custom event for the Combobox when the input value changes.
15
+ *
16
+ * @param instance - The combobox instance.
17
+ * @param option - The value and label of the selected option.
18
+ */
19
+ static onInputCombobox(instance: Combobox, option: Option): void;
20
+ /**
21
+ * Dispatches a custom event for the Combobox when the selected option changes.
22
+ *
23
+ * @param instance - The combobox instance.
24
+ * @param option - The value and label of the selected option.
25
+ */
26
+ static onChangeCombobox(instance: Combobox, option: Option): void;
27
+ }
@@ -0,0 +1,35 @@
1
+ export class ComboboxEventManager {
2
+ /**
3
+ * Dispatches a custom event for the Combobox.
4
+ *
5
+ * @param instance - The combobox instance.
6
+ * @param eventName - The name of the event.
7
+ * @param option - The option that triggered the event.
8
+ * @param bubbles - Whether the event should bubble up the DOM tree.
9
+ */
10
+ static dispatchComboboxEvent(instance, eventName, option, bubbles = true) {
11
+ instance.dispatchEvent(new CustomEvent(eventName, {
12
+ detail: { value: option === null || option === void 0 ? void 0 : option.value, label: option === null || option === void 0 ? void 0 : option.label },
13
+ composed: true,
14
+ bubbles,
15
+ }));
16
+ }
17
+ /**
18
+ * Dispatches a custom event for the Combobox when the input value changes.
19
+ *
20
+ * @param instance - The combobox instance.
21
+ * @param option - The value and label of the selected option.
22
+ */
23
+ static onInputCombobox(instance, option) {
24
+ this.dispatchComboboxEvent(instance, 'input', option);
25
+ }
26
+ /**
27
+ * Dispatches a custom event for the Combobox when the selected option changes.
28
+ *
29
+ * @param instance - The combobox instance.
30
+ * @param option - The value and label of the selected option.
31
+ */
32
+ static onChangeCombobox(instance, option) {
33
+ this.dispatchComboboxEvent(instance, 'change', option);
34
+ }
35
+ }
@@ -1,7 +1,128 @@
1
1
  import { css } from 'lit';
2
2
  const styles = css `
3
3
  :host {
4
- display: block;
4
+ --mdc-combobox-border-color: var(--mds-color-theme-outline-input-normal);
5
+ --mdc-combobox-icon-color: var(--mds-color-theme-text-primary-normal);
6
+ --mdc-combobox-width: 100%;
7
+ --mdc-combobox-listbox-width: var(--mdc-combobox-width);
8
+ --mdc-combobox-listbox-height: auto;
9
+ --mdc-combobox-text-color-disabled: var(--mds-color-theme-text-primary-disabled);
10
+ --mdc-combobox-hover-background-color: var(--mds-color-theme-background-primary-hover);
11
+ --mdc-combobox-error-border-color: var(--mds-color-theme-text-error-normal);
12
+ --mdc-combobox-warning-border-color: var(--mds-color-theme-text-warning-normal);
13
+ --mdc-combobox-success-border-color: var(--mds-color-theme-text-success-normal);
14
+ --mdc-combobox-primary-border-color: var(--mds-color-theme-text-accent-normal);
15
+ --mdc-combobox-focused-background-color: var(--mds-color-theme-background-primary-ghost);
16
+ --mdc-combobox-focused-border-color: var(--mds-color-theme-outline-input-active);
17
+
18
+ display: flex;
19
+ flex-direction: column;
20
+ row-gap: 0.5rem;
21
+ width: var(--mdc-combobox-width);
22
+ }
23
+ :host::part(combobox__base) {
24
+ width: 100%;
25
+ display: flex;
26
+ position: relative;
27
+ border-radius: 0.5rem;
28
+ }
29
+ :host(:dir(ltr))::part(combobox__button) {
30
+ background-color: unset;
31
+ border-radius: 0 0.5rem 0.5rem 0;
32
+ border-left: 1px solid var(--mdc-combobox-border-color);
33
+ position: absolute;
34
+ padding: 0.5rem;
35
+ right: 0;
36
+ }
37
+ :host(:dir(rtl))::part(combobox__button) {
38
+ background-color: unset;
39
+ border-radius: 0.5rem 0 0 0.5rem;
40
+ border-right: 1px solid var(--mdc-combobox-border-color);
41
+ position: absolute;
42
+ padding: 0.5rem;
43
+ left: 0;
44
+ }
45
+ :host([disabled])::part(combobox__button) {
46
+ cursor: unset;
47
+ }
48
+ :host mdc-input {
49
+ --mdc-input-error-border-color: var(--mdc-combobox-error-border-color);
50
+ --mdc-input-warning-border-color: var(--mdc-combobox-warning-border-color);
51
+ --mdc-input-success-border-color: var(--mdc-combobox-success-border-color);
52
+ --mdc-input-primary-border-color: var(--mdc-combobox-primary-border-color);
53
+ --mdc-input-focused-border-color: var(--mdc-combobox-focused-border-color);
54
+ --mdc-input-focused-background-color: var(--mdc-combobox-focused-background-color);
55
+ }
56
+ :host(:focus-within)::part(combobox__button) {
57
+ border-left: 1px solid var(--mdc-combobox-focused-border-color);
58
+ }
59
+ :host(:not([disabled]))::part(combobox__base):hover {
60
+ background-color: var(--mdc-combobox-hover-background-color);
61
+ }
62
+ :host([help-text-type='error'])::part(combobox__button) {
63
+ border-color: var(--mdc-combobox-error-border-color);
64
+ }
65
+ :host([help-text-type='warning'])::part(combobox__button) {
66
+ border-color: var(--mdc-combobox-warning-border-color);
67
+ }
68
+ :host([help-text-type='success'])::part(combobox__button) {
69
+ border-color: var(--mdc-combobox-success-border-color);
70
+ }
71
+ :host([help-text-type='priority'])::part(combobox__button) {
72
+ border-color: var(--mdc-combobox-primary-border-color);
73
+ }
74
+ :host([disabled])::part(combobox__button) {
75
+ border-left: 1px solid var(--mdc-combobox-text-color-disabled);
76
+ }
77
+ :host::part(mdc-input) {
78
+ width: calc(100% - 1.5rem);
79
+ }
80
+ :host::part(combobox__button-icon) {
81
+ --mdc-icon-fill-color: var(--mdc-combobox-icon-color);
82
+ }
83
+ :host([disabled])::part(combobox__button-icon) {
84
+ --mdc-icon-fill-color: var(--mdc-combobox-text-color-disabled);
85
+ }
86
+ :host::part(no-result-text) {
87
+ pointer-events: none;
88
+ }
89
+ :host([disabled]) input,
90
+ :host([disabled]) mdc-input {
91
+ user-select: none;
92
+ pointer-events: none;
93
+ }
94
+ :host::part(internal-native-input) {
95
+ margin: 0;
96
+ opacity: 0.1%;
97
+ overflow: visible;
98
+ padding: 0;
99
+ position: absolute;
100
+ width: 100%;
101
+ height: 100%;
102
+ top: 0;
103
+ left: 0;
104
+ z-index: -1;
105
+ }
106
+ :host ::slotted(mdc-selectlistbox) {
107
+ display: flex;
108
+ flex-direction: column;
109
+ width: 100%;
110
+ max-height: var(--mdc-popover-internal-available-height);
111
+ }
112
+ /* Popover height & width overrides */
113
+ :host mdc-popover {
114
+ --mdc-popover-max-height: var(--mdc-combobox-listbox-height);
115
+ --mdc-popover-max-width: var(--mdc-combobox-listbox-width);
116
+ }
117
+ :host mdc-popover::part(popover-content) {
118
+ max-height: var(--mdc-popover-max-height);
119
+ outline: none;
120
+ }
121
+ /* High Contrast Mode */
122
+ @media (forced-colors: active) {
123
+ :host::part(combobox__button-icon) {
124
+ --mdc-icon-fill-color: ButtonText;
125
+ }
5
126
  }
6
127
  `;
7
128
  export default [styles];
@@ -1,3 +1,24 @@
1
+ import type { OverrideEventTarget, TypedCustomEvent, ValueOf } from '../../utils/types';
2
+ import type { PopoverHiddenEvent, PopoverPlacement, PopoverShownEvent } from '../popover/popover.types';
3
+ import type Combobox from './combobox.component';
4
+ import { ICON_NAME } from './combobox.constants';
5
+ type ComboboxChangeEvent = TypedCustomEvent<Combobox, {
6
+ value: string;
7
+ label?: string;
8
+ }>;
9
+ type ComboboxInputEvent = TypedCustomEvent<Combobox, {
10
+ value: string;
11
+ label?: string;
12
+ }>;
1
13
  interface Events {
14
+ onClickEvent: OverrideEventTarget<MouseEvent, Combobox>;
15
+ onChangeEvent: ComboboxChangeEvent;
16
+ onInputEvent: ComboboxInputEvent;
17
+ onKeyDownEvent: OverrideEventTarget<KeyboardEvent, Combobox>;
18
+ onFocusEvent: OverrideEventTarget<FocusEvent, Combobox>;
19
+ onShownEvent: PopoverShownEvent;
20
+ onHiddenEvent: PopoverHiddenEvent;
2
21
  }
3
- export type { Events };
22
+ type Placement = Extract<PopoverPlacement, 'bottom-start' | 'top-start'>;
23
+ type IconName = ValueOf<typeof ICON_NAME>;
24
+ export type { Events, IconName, Placement };
@@ -1,2 +1 @@
1
- // import type { ValueOf } from '../../utils/types';
2
1
  export {};
@@ -1,3 +1,8 @@
1
+ import '../buttonsimple';
2
+ import '../icon';
3
+ import '../input';
4
+ import '../listitem';
5
+ import '../popover';
1
6
  import Combobox from './combobox.component';
2
7
  declare global {
3
8
  interface HTMLElementTagNameMap {
@@ -1,3 +1,8 @@
1
+ import '../buttonsimple';
2
+ import '../icon';
3
+ import '../input';
4
+ import '../listitem';
5
+ import '../popover';
1
6
  import Combobox from './combobox.component';
2
7
  import { TAG_NAME } from './combobox.constants';
3
8
  Combobox.register(TAG_NAME);
@@ -203,6 +203,10 @@ const styles = [
203
203
  line-height: var(--mdc-divider-text-line-height);
204
204
  flex-shrink: 0;
205
205
  }
206
+
207
+ :host([data-hidden]) {
208
+ display: none;
209
+ }
206
210
  `,
207
211
  ];
208
212
  export default styles;
@@ -31,6 +31,16 @@ const styles = [
31
31
  font-family: inherit;
32
32
  }
33
33
 
34
+ :host .input-container:hover {
35
+ background-color: var(--mdc-input-hover-background-color);
36
+ }
37
+
38
+ :host .input-container:active,
39
+ :host .input-container:focus-within {
40
+ background-color: var(--mdc-input-focused-background-color);
41
+ border-color: var(--mdc-input-focused-border-color);
42
+ }
43
+
34
44
  :host([readonly]) .leading-icon {
35
45
  color: var(--mdc-input-support-text-color);
36
46
  }
@@ -89,16 +99,6 @@ const styles = [
89
99
  white-space: nowrap; /* restrict prefix text to be in one line */
90
100
  }
91
101
 
92
- :host(:not([disabled])) .input-container:hover {
93
- background-color: var(--mdc-input-hover-background-color);
94
- }
95
-
96
- :host(:not([disabled])) .input-container:active,
97
- :host(:not([disabled])) .input-container:focus-within {
98
- background-color: var(--mdc-input-focused-background-color);
99
- border-color: var(--mdc-input-focused-border-color);
100
- }
101
-
102
102
  .input::placeholder {
103
103
  color: var(--mdc-input-support-text-color);
104
104
  }
@@ -12,5 +12,8 @@ const styles = css `
12
12
  color: var(--mdc-optgroup-disabled-color);
13
13
  cursor: default;
14
14
  }
15
+ :host([data-hidden]) {
16
+ display: none;
17
+ }
15
18
  `;
16
19
  export default [styles];
@@ -1,2 +1,2 @@
1
- declare const _default: import("lit").CSSResult[];
2
- export default _default;
1
+ declare const styles: import("lit").CSSResult[];
2
+ export default styles;
@@ -1,27 +1,40 @@
1
1
  import { css } from 'lit';
2
- const styles = css `
3
- :host {
4
- --mdc-listitem-column-gap: 0.75rem;
5
- --mdc-option-icon-width: 1rem;
6
- flex-shrink: 0;
7
- }
2
+ import { baseHostStyleVariables, focusRingBoxShadow } from '../../utils/styles';
3
+ const styles = [
4
+ baseHostStyleVariables,
5
+ css `
6
+ :host {
7
+ --mdc-listitem-column-gap: 0.75rem;
8
+ --mdc-option-icon-width: 1rem;
9
+ flex-shrink: 0;
10
+ }
8
11
 
9
- :host::part(leading-icon),
10
- :host::part(trailing) {
11
- display: flex;
12
- align-items: center;
13
- width: var(--mdc-option-icon-width);
14
- }
12
+ :host::part(leading-icon),
13
+ :host::part(trailing) {
14
+ display: flex;
15
+ align-items: center;
16
+ width: var(--mdc-option-icon-width);
17
+ }
15
18
 
16
- :host::part(leading-text) {
17
- flex: 1;
18
- }
19
+ :host::part(leading-text) {
20
+ flex: 1;
21
+ }
19
22
 
20
- :host::part(leading-icon) {
21
- margin-inline-end: var(--mdc-listitem-column-gap);
22
- }
23
- :host::part(trailing) {
24
- margin-inline-start: var(--mdc-listitem-column-gap);
25
- }
26
- `;
27
- export default [styles];
23
+ :host::part(leading-icon) {
24
+ margin-inline-end: var(--mdc-listitem-column-gap);
25
+ }
26
+ :host::part(trailing) {
27
+ margin-inline-start: var(--mdc-listitem-column-gap);
28
+ }
29
+
30
+ :host([data-focused]) {
31
+ outline: none;
32
+ position: relative;
33
+ box-shadow: ${focusRingBoxShadow};
34
+ }
35
+ :host([data-hidden]) {
36
+ display: none;
37
+ }
38
+ `,
39
+ ];
40
+ export default styles;
@@ -1,6 +1,6 @@
1
1
  import { CSSResult, PropertyValues } from 'lit';
2
2
  import { Component } from '../../models';
3
- import type { PopoverColor, PopoverPlacement, PopoverTrigger } from './popover.types';
3
+ import type { PopoverColor, PopoverPlacement, PopoverStrategy, PopoverTrigger } from './popover.types';
4
4
  declare const Popover_base: import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/BackdropMixin").BackdropMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/PreventScrollMixin").PreventScrollMixinInterface> & import("../../utils/mixins/index.types").Constructor<Component & import("../../utils/mixins/FocusTrapMixin").FocusTrapClassInterface> & typeof Component;
5
5
  /**
6
6
  * Popover component is a lightweight floating UI element that displays additional content when triggered.
@@ -250,7 +250,7 @@ declare class Popover extends Popover_base {
250
250
  * @default absolute
251
251
  * @see [Floating UI - strategy](https://floating-ui.com/docs/computePosition#strategy)
252
252
  */
253
- strategy: 'absolute' | 'fixed';
253
+ strategy: PopoverStrategy;
254
254
  /**
255
255
  * Role of the popover
256
256
  * @default dialog
@@ -953,7 +953,7 @@ __decorate([
953
953
  __metadata("design:type", Object)
954
954
  ], Popover.prototype, "closeButtonAriaLabel", void 0);
955
955
  __decorate([
956
- property({ type: String, reflect: true, attribute: 'strategy' }),
956
+ property({ type: String, reflect: true }),
957
957
  __metadata("design:type", String)
958
958
  ], Popover.prototype, "strategy", void 0);
959
959
  __decorate([
@@ -23,6 +23,10 @@ declare const COLOR: {
23
23
  readonly TONAL: "tonal";
24
24
  readonly CONTRAST: "contrast";
25
25
  };
26
+ declare const STRATEGY: {
27
+ readonly ABSOLUTE: "absolute";
28
+ readonly FIXED: "fixed";
29
+ };
26
30
  declare const DEFAULTS: {
27
31
  readonly PLACEMENT: "bottom";
28
32
  readonly TRIGGER: "click";
@@ -53,4 +57,4 @@ declare const DEFAULTS: {
53
57
  readonly STRATEGY: "absolute";
54
58
  readonly IS_BACKDROP_INVISIBLE: true;
55
59
  };
56
- export { TAG_NAME, POPOVER_PLACEMENT, COLOR, TRIGGER, DEFAULTS };
60
+ export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, DEFAULTS };
@@ -1,4 +1,5 @@
1
1
  import utils from '../../utils/tag-name';
2
+ import { ROLE } from '../../utils/roles';
2
3
  const TAG_NAME = utils.constructTagName('popover');
3
4
  const POPOVER_PLACEMENT = {
4
5
  LEFT_START: 'left-start',
@@ -24,6 +25,10 @@ const COLOR = {
24
25
  TONAL: 'tonal',
25
26
  CONTRAST: 'contrast',
26
27
  };
28
+ const STRATEGY = {
29
+ ABSOLUTE: 'absolute',
30
+ FIXED: 'fixed',
31
+ };
27
32
  const DEFAULTS = {
28
33
  PLACEMENT: POPOVER_PLACEMENT.BOTTOM,
29
34
  TRIGGER: TRIGGER.CLICK,
@@ -46,7 +51,7 @@ const DEFAULTS = {
46
51
  FLIP: true,
47
52
  SIZE: false,
48
53
  DELAY: '0,0',
49
- ROLE: 'dialog',
54
+ ROLE: ROLE.DIALOG,
50
55
  Z_INDEX: 1000,
51
56
  DISABLE_ARIA_EXPANDED: false,
52
57
  PROPAGATE_EVENT_ON_ESCAPE: false,
@@ -54,4 +59,4 @@ const DEFAULTS = {
54
59
  STRATEGY: 'absolute',
55
60
  IS_BACKDROP_INVISIBLE: true,
56
61
  };
57
- export { TAG_NAME, POPOVER_PLACEMENT, COLOR, TRIGGER, DEFAULTS };
62
+ export { TAG_NAME, POPOVER_PLACEMENT, COLOR, STRATEGY, TRIGGER, DEFAULTS };
@@ -1,8 +1,9 @@
1
1
  import type { ValueOf, TypedCustomEvent } from '../../utils/types';
2
2
  import type Popover from './popover.component';
3
- import { POPOVER_PLACEMENT, TRIGGER, COLOR } from './popover.constants';
3
+ import { POPOVER_PLACEMENT, TRIGGER, COLOR, STRATEGY } from './popover.constants';
4
4
  type PopoverPlacement = ValueOf<typeof POPOVER_PLACEMENT>;
5
5
  type PopoverColor = ValueOf<typeof COLOR>;
6
+ type PopoverStrategy = ValueOf<typeof STRATEGY>;
6
7
  type PopoverTrigger = ValueOf<typeof TRIGGER> | `${ValueOf<typeof TRIGGER>} ${ValueOf<typeof TRIGGER>}`;
7
8
  type PopoverShownEvent = TypedCustomEvent<Popover, {
8
9
  show: boolean;
@@ -22,4 +23,4 @@ interface Events {
22
23
  onCreatedEvent: PopoverCreatedEvent;
23
24
  onDestroyedEvent: PopoverDestroyedEvent;
24
25
  }
25
- export type { PopoverPlacement, PopoverColor, PopoverTrigger, Events, PopoverShownEvent, PopoverHiddenEvent };
26
+ export type { PopoverPlacement, PopoverColor, PopoverStrategy, PopoverTrigger, Events, PopoverShownEvent, PopoverHiddenEvent, };