@momentum-design/components 0.27.6 → 0.28.1

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 (41) hide show
  1. package/dist/browser/index.js +314 -131
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/button/button.styles.js +1 -0
  4. package/dist/components/buttonsimple/buttonsimple.component.d.ts +5 -0
  5. package/dist/components/buttonsimple/buttonsimple.component.js +10 -0
  6. package/dist/components/modalcontainer/modalcontainer.component.d.ts +9 -3
  7. package/dist/components/modalcontainer/modalcontainer.component.js +26 -15
  8. package/dist/components/modalcontainer/modalcontainer.constants.d.ts +2 -5
  9. package/dist/components/modalcontainer/modalcontainer.constants.js +3 -6
  10. package/dist/components/modalcontainer/modalcontainer.styles.js +6 -6
  11. package/dist/components/modalcontainer/modalcontainer.types.d.ts +1 -2
  12. package/dist/components/popover/index.d.ts +9 -0
  13. package/dist/components/popover/index.js +6 -0
  14. package/dist/components/popover/popover.component.d.ts +256 -0
  15. package/dist/components/popover/popover.component.js +675 -0
  16. package/dist/components/popover/popover.constants.d.ts +44 -0
  17. package/dist/components/popover/popover.constants.js +46 -0
  18. package/dist/components/popover/popover.events.d.ts +34 -0
  19. package/dist/components/popover/popover.events.js +47 -0
  20. package/dist/components/popover/popover.stack.d.ts +45 -0
  21. package/dist/components/popover/popover.stack.js +55 -0
  22. package/dist/components/popover/popover.styles.d.ts +2 -0
  23. package/dist/components/popover/popover.styles.js +109 -0
  24. package/dist/components/popover/popover.types.d.ts +4 -0
  25. package/dist/components/popover/popover.types.js +1 -0
  26. package/dist/components/popover/popover.utils.d.ts +48 -0
  27. package/dist/components/popover/popover.utils.js +156 -0
  28. package/dist/custom-elements.json +4135 -2187
  29. package/dist/index.d.ts +2 -1
  30. package/dist/index.js +2 -1
  31. package/dist/react/index.d.ts +2 -1
  32. package/dist/react/index.js +2 -1
  33. package/dist/react/popover/index.d.ts +24 -0
  34. package/dist/react/popover/index.js +33 -0
  35. package/dist/utils/mixins/DataAriaDescribedbyMixin.d.ts +6 -0
  36. package/dist/utils/mixins/DataAriaDescribedbyMixin.js +30 -0
  37. package/dist/utils/mixins/DataAriaLabelledbyMixin.d.ts +6 -0
  38. package/dist/utils/mixins/DataAriaLabelledbyMixin.js +29 -0
  39. package/dist/utils/mixins/FocusTrapMixin.d.ts +9 -0
  40. package/dist/utils/mixins/FocusTrapMixin.js +323 -0
  41. package/package.json +2 -1
@@ -124,6 +124,7 @@ const styles = css `
124
124
  }
125
125
  :host([size="20"]){
126
126
  padding: 0.0625rem;
127
+ aspect-ratio: 1;
127
128
  }
128
129
 
129
130
  :host([color="accent"]){
@@ -95,6 +95,11 @@ declare class Buttonsimple extends Buttonsimple_base {
95
95
  */
96
96
  private setDisabled;
97
97
  private triggerClickEvent;
98
+ /**
99
+ * In case the button is pressed and the focus is lost while pressing,
100
+ * the pressed class is removed.
101
+ */
102
+ private handleBlur;
98
103
  /**
99
104
  * Handles the keydown event on the button.
100
105
  * If the key is 'Enter' or 'Space', the button is pressed.
@@ -80,6 +80,7 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
80
80
  this.addEventListener('click', this.executeAction.bind(this));
81
81
  this.addEventListener('keydown', this.handleKeyDown.bind(this));
82
82
  this.addEventListener('keyup', this.handleKeyUp.bind(this));
83
+ this.addEventListener('blur', this.handleBlur.bind(this));
83
84
  /** @internal */
84
85
  this.internals = this.attachInternals();
85
86
  }
@@ -162,6 +163,15 @@ class Buttonsimple extends TabIndexMixin(DisabledMixin(Component)) {
162
163
  });
163
164
  this.dispatchEvent(clickEvent);
164
165
  }
166
+ /**
167
+ * In case the button is pressed and the focus is lost while pressing,
168
+ * the pressed class is removed.
169
+ */
170
+ handleBlur() {
171
+ if (this.classList.contains('pressed')) {
172
+ this.classList.remove('pressed');
173
+ }
174
+ }
165
175
  /**
166
176
  * Handles the keydown event on the button.
167
177
  * If the key is 'Enter' or 'Space', the button is pressed.
@@ -1,6 +1,7 @@
1
1
  import { CSSResult } from 'lit';
2
2
  import { Component } from '../../models';
3
- import type { ModalContainerColor, ModalContainerElevation, ModalContainerRole } from './modalcontainer.types';
3
+ import type { ModalContainerColor, ModalContainerElevation } from './modalcontainer.types';
4
+ declare const Modalcontainer_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelledbyMixin").DataAriaLabelledbyMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaDescribedbyMixin").DataAriaDescribedbyMixinInterface> & typeof Component;
4
5
  /**
5
6
  * The `mdc-modalcontainer` component is an element used to
6
7
  * display a modal container that can further be used in popover.
@@ -15,7 +16,7 @@ import type { ModalContainerColor, ModalContainerElevation, ModalContainerRole }
15
16
  *
16
17
  * @slot - Default slot for modal container
17
18
  */
18
- declare class Modalcontainer extends Component {
19
+ declare class Modalcontainer extends Modalcontainer_base {
19
20
  /**
20
21
  * Color of the modalcontainer
21
22
  * - **tonal**
@@ -37,7 +38,12 @@ declare class Modalcontainer extends Component {
37
38
  * Role of the modalcontainer
38
39
  * @default dialog
39
40
  */
40
- role: ModalContainerRole;
41
+ dataRole: HTMLElement['role'];
42
+ /**
43
+ * Aria modal of the modalcontainer
44
+ * @default false
45
+ */
46
+ dataAriaModal: boolean;
41
47
  render(): import("lit-html").TemplateResult<1>;
42
48
  static styles: Array<CSSResult>;
43
49
  }
@@ -13,6 +13,9 @@ import { ifDefined } from 'lit/directives/if-defined.js';
13
13
  import styles from './modalcontainer.styles';
14
14
  import { Component } from '../../models';
15
15
  import { DEFAULTS } from './modalcontainer.constants';
16
+ import { DataAriaLabelMixin } from '../../utils/mixins/DataAriaLabelMixin';
17
+ import { DataAriaDescribedbyMixin } from '../../utils/mixins/DataAriaDescribedbyMixin';
18
+ import { DataAriaLabelledbyMixin } from '../../utils/mixins/DataAriaLabelledbyMixin';
16
19
  /**
17
20
  * The `mdc-modalcontainer` component is an element used to
18
21
  * display a modal container that can further be used in popover.
@@ -27,7 +30,7 @@ import { DEFAULTS } from './modalcontainer.constants';
27
30
  *
28
31
  * @slot - Default slot for modal container
29
32
  */
30
- class Modalcontainer extends Component {
33
+ class Modalcontainer extends DataAriaLabelMixin(DataAriaLabelledbyMixin(DataAriaDescribedbyMixin(Component))) {
31
34
  constructor() {
32
35
  super(...arguments);
33
36
  /**
@@ -51,22 +54,26 @@ class Modalcontainer extends Component {
51
54
  * Role of the modalcontainer
52
55
  * @default dialog
53
56
  */
54
- this.role = DEFAULTS.ROLE;
57
+ this.dataRole = DEFAULTS.ROLE;
58
+ /**
59
+ * Aria modal of the modalcontainer
60
+ * @default false
61
+ */
62
+ this.dataAriaModal = DEFAULTS.ARIA_MODAL;
55
63
  }
56
64
  render() {
57
65
  return html `
58
- <div
59
- id='mdc-modal-container'
60
- class='mdc-modal-container'
61
- ?contrast="${this.color === 'contrast'}"
62
- role="${this.role}"
63
- aria-modal='true'
64
- aria-label=${ifDefined(this.ariaLabel)}
65
- data-elevation="${this.elevation}"
66
- >
66
+ <div
67
+ role="${ifDefined(this.dataRole)}"
68
+ aria-modal=${ifDefined(this.dataAriaModal === true ? 'true' : undefined)}
69
+ aria-label="${ifDefined(this.dataAriaLabel)}"
70
+ aria-labelledby="${ifDefined(this.dataAriaLabelledby)}"
71
+ aria-describedby="${ifDefined(this.dataAriaDescribedby)}"
72
+ part="container"
73
+ >
67
74
  <slot></slot>
68
75
  </div>
69
- `;
76
+ `;
70
77
  }
71
78
  }
72
79
  Modalcontainer.styles = [...Component.styles, ...styles];
@@ -79,7 +86,11 @@ __decorate([
79
86
  __metadata("design:type", Number)
80
87
  ], Modalcontainer.prototype, "elevation", void 0);
81
88
  __decorate([
82
- property({ type: String }),
83
- __metadata("design:type", String)
84
- ], Modalcontainer.prototype, "role", void 0);
89
+ property({ type: String, reflect: true, attribute: 'data-role' }),
90
+ __metadata("design:type", Object)
91
+ ], Modalcontainer.prototype, "dataRole", void 0);
92
+ __decorate([
93
+ property({ type: Boolean, reflect: true, attribute: 'data-aria-modal' }),
94
+ __metadata("design:type", Boolean)
95
+ ], Modalcontainer.prototype, "dataAriaModal", void 0);
85
96
  export default Modalcontainer;
@@ -10,14 +10,11 @@ declare const ELEVATION: {
10
10
  readonly 3: 3;
11
11
  readonly 4: 4;
12
12
  };
13
- declare const ROLE: {
14
- readonly DIALOG: "dialog";
15
- readonly ALERT_DIALOG: "alertdialog";
16
- };
17
13
  declare const DEFAULTS: {
18
14
  readonly COLOR: "tonal";
19
15
  readonly ELEVATION: 0;
20
16
  readonly ROLE: "dialog";
17
+ readonly ARIA_MODAL: false;
21
18
  readonly CHILDREN: "Lorem ipsum dolor sit amet";
22
19
  };
23
- export { TAG_NAME, COLOR, DEFAULTS, ELEVATION, ROLE };
20
+ export { TAG_NAME, COLOR, DEFAULTS, ELEVATION };
@@ -11,14 +11,11 @@ const ELEVATION = {
11
11
  3: 3,
12
12
  4: 4,
13
13
  };
14
- const ROLE = {
15
- DIALOG: 'dialog',
16
- ALERT_DIALOG: 'alertdialog',
17
- };
18
14
  const DEFAULTS = {
19
15
  COLOR: COLOR.TONAL,
20
16
  ELEVATION: ELEVATION[0],
21
- ROLE: ROLE.DIALOG,
17
+ ROLE: 'dialog',
18
+ ARIA_MODAL: false,
22
19
  CHILDREN: 'Lorem ipsum dolor sit amet',
23
20
  };
24
- export { TAG_NAME, COLOR, DEFAULTS, ELEVATION, ROLE };
21
+ export { TAG_NAME, COLOR, DEFAULTS, ELEVATION };
@@ -15,29 +15,29 @@ const styles = [
15
15
  --mdc-modalcontainer-elevation-4: var(--mds-elevation-4);
16
16
  }
17
17
 
18
- .mdc-modal-container {
18
+ :host::part(container) {
19
19
  padding: 0.75rem;
20
20
  background-color: var(--mdc-modalcontainer-primary-background-color);
21
21
  border-radius: 0.5rem;
22
22
  border: 0.0625rem solid var(--mdc-modalcontainer-border-color);
23
23
  }
24
24
 
25
- .mdc-modal-container[contrast] {
25
+ :host([color='contrast'])::part(container) {
26
26
  background-color: var(--mdc-modalcontainer-inverted-background-color);
27
27
  border: 0.0625rem solid var(--mdc-modalcontainer-inverted-border-color);
28
28
  color: var(--mdc-modalcontainer-inverted-text-color);
29
29
  }
30
30
 
31
- .mdc-modal-container[data-elevation='1'] {
31
+ :host([elevation='1'])::part(container) {
32
32
  filter: var(--mdc-modalcontainer-elevation-1);
33
33
  }
34
- .mdc-modal-container[data-elevation='2'] {
34
+ :host([elevation='2'])::part(container) {
35
35
  filter: var(--mdc-modalcontainer-elevation-2);
36
36
  }
37
- .mdc-modal-container[data-elevation='3'] {
37
+ :host([elevation='3'])::part(container) {
38
38
  filter: var(--mdc-modalcontainer-elevation-3);
39
39
  }
40
- .mdc-modal-container[data-elevation='4'] {
40
+ :host([elevation='4'])::part(container) {
41
41
  filter: var(--mdc-modalcontainer-elevation-4);
42
42
  }
43
43
  `,
@@ -1,5 +1,4 @@
1
1
  import type { ValueOf } from '../../utils/types';
2
- import { COLOR, ELEVATION, ROLE } from './modalcontainer.constants';
2
+ import { COLOR, ELEVATION } from './modalcontainer.constants';
3
3
  export type ModalContainerColor = ValueOf<typeof COLOR>;
4
4
  export type ModalContainerElevation = ValueOf<typeof ELEVATION>;
5
- export type ModalContainerRole = ValueOf<typeof ROLE>;
@@ -0,0 +1,9 @@
1
+ import Popover from './popover.component';
2
+ import '../button';
3
+ import '../modalcontainer';
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ ['mdc-popover']: Popover;
7
+ }
8
+ }
9
+ export default Popover;
@@ -0,0 +1,6 @@
1
+ import Popover from './popover.component';
2
+ import { TAG_NAME } from './popover.constants';
3
+ import '../button';
4
+ import '../modalcontainer';
5
+ Popover.register(TAG_NAME);
6
+ export default Popover;
@@ -0,0 +1,256 @@
1
+ import { CSSResult, PropertyValues } from 'lit';
2
+ import { Component } from '../../models';
3
+ import type { PopoverPlacement, PopoverTrigger } from './popover.types';
4
+ import type { ModalContainerColor } from '../modalcontainer/modalcontainer.types';
5
+ declare const Popover_base: import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelMixin").DataAriaLabelMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaLabelledbyMixin").DataAriaLabelledbyMixinInterface> & import("../../utils/mixins/index.types").Constructor<import("../../utils/mixins/DataAriaDescribedbyMixin").DataAriaDescribedbyMixinInterface> & import("../../utils/mixins/index.types").Constructor<HTMLElement & import("../../utils/mixins/FocusTrapMixin").FocusTrapClassInterface> & typeof Component;
6
+ /**
7
+ * Popover component is a lightweight floating UI element that displays additional content when triggered.
8
+ * It can be used for tooltips, dropdowns, or contextual menus.
9
+ * The popover automatically positions itself based on available space and
10
+ * supports dynamic height adjustments with scrollable content when needed。
11
+ *
12
+ * @dependency mdc-button
13
+ * @dependency mdc-modalcontainer
14
+ *
15
+ * @tagname mdc-popover
16
+ *
17
+ * @cssproperty --mdc-popover-arrow-border-radius - radius of the arrow border
18
+ * @cssproperty --mdc-popover-arrow-border - border of the arrow
19
+ * @cssproperty --mdc-popover-primary-background-color - primary background color of the popover
20
+ * @cssproperty --mdc-popover-inverted-background-color - inverted background color of the popover
21
+ * @cssproperty --mdc-popover-inverted-border-color - inverted border color of the popover
22
+ * @cssproperty --mdc-popover-inverted-text-color - inverted text color of the popover
23
+ *
24
+ * @slot - Default slot for modal container
25
+ *
26
+ */
27
+ declare class Popover extends Popover_base {
28
+ /**
29
+ * The unique ID of the popover.
30
+ */
31
+ id: string;
32
+ /**
33
+ * The ID of the element that triggers the popover.
34
+ * This attribute is required for the popover to work.
35
+ */
36
+ triggerID: string;
37
+ /**
38
+ * Determines the events that cause the Popover to show.
39
+ * Multiple event names should be separated by spaces.
40
+ * For example to allow both click and hover, use 'click mouseenter' as the trigger.
41
+ * - **click**
42
+ * - **mouseenter**
43
+ * - **focusin**
44
+ * - **manual**
45
+ * @default click
46
+ */
47
+ trigger: PopoverTrigger;
48
+ /**
49
+ * The placement of the popover.
50
+ * - **top**
51
+ * - **top-start**
52
+ * - **top-end**
53
+ * - **bottom**
54
+ * - **bottom-start**
55
+ * - **bottom-end**
56
+ * - **left**
57
+ * - **left-start**
58
+ * - **left-end**
59
+ * - **right**
60
+ * - **right-start**
61
+ * - **right-end**
62
+ * @default bottom
63
+ */
64
+ placement: PopoverPlacement;
65
+ /**
66
+ * Color of the popover
67
+ * - **tonal**
68
+ * - **contrast**
69
+ * @default tonal
70
+ */
71
+ color: ModalContainerColor;
72
+ /**
73
+ * The visibility of the popover.
74
+ * @default false
75
+ */
76
+ visible: boolean;
77
+ /**
78
+ * The offset of the popover.
79
+ * @default 4
80
+ */
81
+ offset: number;
82
+ /**
83
+ * Determines whether the focus trap is enabled.
84
+ * If true, focus will be restricted to the content within this component.
85
+ * @default false
86
+ */
87
+ focusTrap: boolean;
88
+ /**
89
+ * Prevent outside scrolling when popover show.
90
+ * @default false
91
+ */
92
+ preventScroll: boolean;
93
+ /**
94
+ * The arrow visibility of the popover.
95
+ * @default false
96
+ */
97
+ showArrow: boolean;
98
+ /**
99
+ * The close button visibility of the popover.
100
+ * @default false
101
+ */
102
+ closeButton: boolean;
103
+ /**
104
+ * Determines whether the popover is interactive。
105
+ * @default false
106
+ */
107
+ interactive: boolean;
108
+ /**
109
+ * The delay of the show/hide popover.
110
+ * @default 0,0
111
+ */
112
+ delay: string;
113
+ /**
114
+ * Hide popover on escape key press.
115
+ * @default false
116
+ */
117
+ hideOnEscape: boolean;
118
+ /**
119
+ * Hide popover on blur.
120
+ * @default false
121
+ */
122
+ hideOnBlur: boolean;
123
+ /**
124
+ * Hide on outside click of the popover.
125
+ * @default false
126
+ */
127
+ hideOnOutsideClick: boolean;
128
+ /**
129
+ * The focus back to trigger after the popover hide.
130
+ * @default false
131
+ */
132
+ focusBackToTrigger: boolean;
133
+ /**
134
+ * Determines whether the popover with backdrop.
135
+ * Other than popover and trigger element, the rest of the screen will be covered with a backdrop.
136
+ * @default false
137
+ */
138
+ backdrop: boolean;
139
+ /**
140
+ * Changes the placement of popover to keep it in view when scrolling.
141
+ * @default true
142
+ */
143
+ flip: boolean;
144
+ /**
145
+ * Changes the size of popover to keep it in view when scrolling.
146
+ * @default false
147
+ */
148
+ size: boolean;
149
+ /**
150
+ * The z-index of the popover.
151
+ * @default 1000
152
+ */
153
+ zIndex: number;
154
+ /**
155
+ * Element ID that the popover append to.
156
+ * @default ''
157
+ */
158
+ appendTo: string;
159
+ /**
160
+ * aria-label attribute to be set for close button accessibility.
161
+ * @default null
162
+ */
163
+ closeButtonAriaLabel: string | null;
164
+ /**
165
+ * Role of the popover
166
+ * @default dialog
167
+ */
168
+ dataRole: HTMLElement['role'];
169
+ arrowElement: HTMLElement | null;
170
+ /** @internal */
171
+ triggerElement: HTMLElement | null;
172
+ /** @internal */
173
+ containerElement: HTMLElement | null;
174
+ /** @internal */
175
+ private hoverTimer;
176
+ /** @internal */
177
+ private isTriggerClicked;
178
+ /** @internal */
179
+ private openDelay;
180
+ /** @internal */
181
+ private closeDelay;
182
+ /** @internal */
183
+ private utils;
184
+ constructor();
185
+ protected firstUpdated(changedProperties: PropertyValues): Promise<void>;
186
+ disconnectedCallback(): Promise<void>;
187
+ /**
188
+ * Sets up the trigger event listeners based on the trigger type.
189
+ */
190
+ private setupTriggerListener;
191
+ /**
192
+ * Removes the trigger event listeners.
193
+ */
194
+ private removeEventListeners;
195
+ protected updated(changedProperties: PropertyValues): Promise<void>;
196
+ /**
197
+ * Handles the outside click event to close the popover.
198
+ *
199
+ * @param event - The mouse event.
200
+ */
201
+ private onOutsidePopoverClick;
202
+ /**
203
+ * Handles the escape keydown event to close the popover.
204
+ *
205
+ * @param event - The keyboard event.
206
+ */
207
+ private onEscapeKeydown;
208
+ /**
209
+ * Handles the popover focus out event.
210
+ *
211
+ * @param event - The focus event.
212
+ */
213
+ private onPopoverFocusOut;
214
+ /**
215
+ * Handles the popover visibility change and position the popover.
216
+ * Handles the exit event to close the popover.
217
+ *
218
+ * @param oldValue - The old value of the visible property.
219
+ * @param newValue - The new value of the visible property.
220
+ */
221
+ private isOpenUpdated;
222
+ /**
223
+ * Starts the close delay timer.
224
+ * If the popover is not interactive, it will close the popover after the delay.
225
+ */
226
+ private startCloseDelay;
227
+ /**
228
+ * Cancels the close delay timer.
229
+ */
230
+ private cancelCloseDelay;
231
+ /**
232
+ * Shows the popover.
233
+ */
234
+ showPopover: () => void;
235
+ /**
236
+ * Hides the popover.
237
+ */
238
+ hidePopover: () => void;
239
+ /**
240
+ * Toggles the popover visibility.
241
+ */
242
+ togglePopoverVisible: () => void;
243
+ /**
244
+ * Sets the focusable elements inside the popover.
245
+ */
246
+ private handleCreatePopoverFirstUpdate;
247
+ /**
248
+ * Positions the popover based on the trigger element.
249
+ * It also handles the flip, size and arrow placement.
250
+ * It uses the floating-ui/dom library to calculate the position.
251
+ */
252
+ private positionPopover;
253
+ render(): import("lit-html").TemplateResult<1>;
254
+ static styles: Array<CSSResult>;
255
+ }
256
+ export default Popover;