@momentum-design/components 0.66.4 → 0.68.0

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 (31) hide show
  1. package/dist/browser/index.js +369 -211
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/components/card/card.component.d.ts +4 -35
  4. package/dist/components/card/card.component.js +9 -79
  5. package/dist/components/dialog/dialog.component.d.ts +150 -0
  6. package/dist/components/dialog/dialog.component.js +340 -0
  7. package/dist/components/dialog/dialog.constants.d.ts +18 -0
  8. package/dist/components/dialog/dialog.constants.js +19 -0
  9. package/dist/components/dialog/dialog.events.d.ts +34 -0
  10. package/dist/components/dialog/dialog.events.js +47 -0
  11. package/dist/components/dialog/dialog.styles.d.ts +2 -0
  12. package/dist/components/dialog/dialog.styles.js +108 -0
  13. package/dist/components/dialog/dialog.types.d.ts +12 -0
  14. package/dist/components/dialog/dialog.types.js +1 -0
  15. package/dist/components/dialog/dialog.utils.d.ts +7 -0
  16. package/dist/components/dialog/dialog.utils.js +33 -0
  17. package/dist/components/dialog/index.d.ts +9 -0
  18. package/dist/components/dialog/index.js +6 -0
  19. package/dist/components/popover/popover.styles.js +5 -0
  20. package/dist/components/toggletip/toggletip.styles.js +8 -0
  21. package/dist/custom-elements.json +1211 -105
  22. package/dist/index.d.ts +4 -3
  23. package/dist/index.js +4 -3
  24. package/dist/react/dialog/index.d.ts +51 -0
  25. package/dist/react/dialog/index.js +59 -0
  26. package/dist/react/index.d.ts +1 -0
  27. package/dist/react/index.js +1 -0
  28. package/dist/utils/mixins/CardAndDialogFooterMixin.d.ts +11 -0
  29. package/dist/utils/mixins/CardAndDialogFooterMixin.js +102 -0
  30. package/dist/utils/mixins/FocusTrapMixin.js +4 -5
  31. package/package.json +1 -1
@@ -0,0 +1,18 @@
1
+ declare const TAG_NAME: "mdc-dialog";
2
+ declare const DIALOG_VARIANT: {
3
+ readonly DEFAULT: "default";
4
+ readonly PROMOTIONAL: "promotional";
5
+ };
6
+ declare const DEFAULTS: {
7
+ readonly VISIBLE: false;
8
+ readonly Z_INDEX: 1000;
9
+ readonly ROLE: "dialog";
10
+ readonly SIZE: "small";
11
+ readonly HEADER_TAG_NAME: "h2";
12
+ readonly DESCRIPTION_TAG_NAME: "p";
13
+ readonly CANCEL_ICON: "cancel-bold";
14
+ readonly VARIANT: "default";
15
+ };
16
+ declare const DIALOG_SIZE: readonly ["small", "medium", "large"];
17
+ declare const DIALOG_ROLE: readonly ["dialog", "alertdialog"];
18
+ export { TAG_NAME, DEFAULTS, DIALOG_SIZE, DIALOG_ROLE, DIALOG_VARIANT };
@@ -0,0 +1,19 @@
1
+ import utils from '../../utils/tag-name';
2
+ const TAG_NAME = utils.constructTagName('dialog');
3
+ const DIALOG_VARIANT = {
4
+ DEFAULT: 'default',
5
+ PROMOTIONAL: 'promotional',
6
+ };
7
+ const DEFAULTS = {
8
+ VISIBLE: false,
9
+ Z_INDEX: 1000,
10
+ ROLE: 'dialog',
11
+ SIZE: 'small',
12
+ HEADER_TAG_NAME: 'h2',
13
+ DESCRIPTION_TAG_NAME: 'p',
14
+ CANCEL_ICON: 'cancel-bold',
15
+ VARIANT: DIALOG_VARIANT.DEFAULT,
16
+ };
17
+ const DIALOG_SIZE = ['small', 'medium', 'large'];
18
+ const DIALOG_ROLE = ['dialog', 'alertdialog'];
19
+ export { TAG_NAME, DEFAULTS, DIALOG_SIZE, DIALOG_ROLE, DIALOG_VARIANT };
@@ -0,0 +1,34 @@
1
+ import type Dialog from './dialog.component';
2
+ export declare class DialogEventManager {
3
+ /**
4
+ * Dispatches a custom event for the dialog.
5
+ *
6
+ * @param eventName - The name of the event.
7
+ * @param instance - The dialog instance.
8
+ */
9
+ static dispatchDialogEvent(eventName: string, instance: Dialog): void;
10
+ /**
11
+ * Custom event that is fired when the dialog is shown.
12
+ *
13
+ * @param instance - The dialog instance.
14
+ */
15
+ static onShowDialog(instance: Dialog): void;
16
+ /**
17
+ * Custom event that is fired when the dialog is hidden.
18
+ *
19
+ * @param instance - The dialog instance.
20
+ */
21
+ static onHideDialog(instance: Dialog): void;
22
+ /**
23
+ * Custom event that is fired when the dialog is created.
24
+ *
25
+ * @param instance - The dialog instance.
26
+ */
27
+ static onCreatedDialog(instance: Dialog): void;
28
+ /**
29
+ * Custom event that is fired when the dialog is destroyed.
30
+ *
31
+ * @param instance - The dialog instance.
32
+ */
33
+ static onDestroyedDialog(instance: Dialog): void;
34
+ }
@@ -0,0 +1,47 @@
1
+ export class DialogEventManager {
2
+ /**
3
+ * Dispatches a custom event for the dialog.
4
+ *
5
+ * @param eventName - The name of the event.
6
+ * @param instance - The dialog instance.
7
+ */
8
+ static dispatchDialogEvent(eventName, instance) {
9
+ instance.dispatchEvent(new CustomEvent(eventName, {
10
+ detail: { show: instance.visible },
11
+ composed: true,
12
+ bubbles: true,
13
+ }));
14
+ }
15
+ /**
16
+ * Custom event that is fired when the dialog is shown.
17
+ *
18
+ * @param instance - The dialog instance.
19
+ */
20
+ static onShowDialog(instance) {
21
+ this.dispatchDialogEvent('shown', instance);
22
+ }
23
+ /**
24
+ * Custom event that is fired when the dialog is hidden.
25
+ *
26
+ * @param instance - The dialog instance.
27
+ */
28
+ static onHideDialog(instance) {
29
+ this.dispatchDialogEvent('hidden', instance);
30
+ }
31
+ /**
32
+ * Custom event that is fired when the dialog is created.
33
+ *
34
+ * @param instance - The dialog instance.
35
+ */
36
+ static onCreatedDialog(instance) {
37
+ this.dispatchDialogEvent('created', instance);
38
+ }
39
+ /**
40
+ * Custom event that is fired when the dialog is destroyed.
41
+ *
42
+ * @param instance - The dialog instance.
43
+ */
44
+ static onDestroyedDialog(instance) {
45
+ this.dispatchDialogEvent('destroyed', instance);
46
+ }
47
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult[];
2
+ export default _default;
@@ -0,0 +1,108 @@
1
+ import { css } from 'lit';
2
+ const styles = css `
3
+ :host {
4
+ --mdc-dialog-primary-background-color: var(--mds-color-theme-background-solid-primary-normal);
5
+ --mdc-dialog-border-color: var(--mds-color-theme-outline-secondary-normal);
6
+ --mdc-dialog-header-text-color: var(--mds-color-theme-text-primary-normal);
7
+ --mdc-dialog-description-text-color: var(--mds-color-theme-text-secondary-normal);
8
+ --mdc-dialog-elevation-3: var(--mds-elevation-3);
9
+ --mdc-dialog-width: 27rem; /* Default to small */
10
+
11
+ background-color: var(--mdc-dialog-primary-background-color);
12
+ border: 0.0625rem solid var(--mdc-dialog-border-color);
13
+ border-radius: 0.5rem;
14
+ filter: var(--mdc-dialog-elevation-3);
15
+ display: none;
16
+ padding: 1rem;
17
+ flex-direction: column;
18
+ justify-content: center;
19
+ align-items: center;
20
+ gap: 1rem;
21
+ position: absolute;
22
+ right: 50%;
23
+ bottom: 50%;
24
+ transform: translate(50%,50%);
25
+ }
26
+
27
+
28
+ :host([variant='promotional']){
29
+ --mdc-dialog-border-color: var(--mds-color-theme-outline-promotion-normal);
30
+ }
31
+
32
+ :host([visible]) {
33
+ display: flex;
34
+
35
+ }
36
+
37
+ :host([size='medium']) {
38
+ --mdc-dialog-width: 41rem;
39
+ }
40
+
41
+ :host([size='large']) {
42
+ --mdc-dialog-width: 62rem;
43
+ }
44
+
45
+ :host {
46
+ width: var(--mdc-dialog-width);
47
+ max-width: 100%;
48
+ }
49
+
50
+ :host::part(header),
51
+ :host::part(body),
52
+ :host::part(footer) {
53
+ display: flex;
54
+ align-self: stretch;
55
+ }
56
+
57
+ :host::part(header) {
58
+ flex-direction: column;
59
+ align-items: flex-start;
60
+ gap: 0.5rem;
61
+ }
62
+
63
+ :host::part(header-text) {
64
+ width: 23.625rem;
65
+ color: var(--mdc-dialog-header-text-color);
66
+ }
67
+
68
+ :host::part(description-text) {
69
+ color: var(--mdc-dialog-description-text-color);
70
+ }
71
+
72
+ :host::part(body) {
73
+ flex-direction: column;
74
+ justify-content: center;
75
+ align-items: center;
76
+ height: 100%
77
+ }
78
+
79
+ :host::part(footer) {
80
+ display: flex;
81
+ gap: 0.5rem;
82
+ align-items: center;
83
+ justify-content: flex-end;
84
+ }
85
+
86
+ ::slotted([slot='footer-link']),
87
+ ::slotted([slot='footer-button-primary']),
88
+ ::slotted([slot='footer-button-secondary']){
89
+ margin-bottom: 0.5rem;
90
+ }
91
+
92
+ :host::part(dialog-close-btn) {
93
+ position: absolute;
94
+ top: 1rem;
95
+ right: 1rem;
96
+ cursor: pointer;
97
+ }
98
+
99
+ :host(:dir(rtl))::part(dialog-close-btn) {
100
+ right: auto;
101
+ left: 1rem;
102
+ }
103
+
104
+ mdc-text::part(text) {
105
+ margin: 0;
106
+ }
107
+ `;
108
+ export default [styles];
@@ -0,0 +1,12 @@
1
+ import type { ValueOf } from '../../utils/types';
2
+ import { DIALOG_ROLE, DIALOG_SIZE, DIALOG_VARIANT } from './dialog.constants';
3
+ type DialogRole = (typeof DIALOG_ROLE)[number];
4
+ type DialogSize = ValueOf<typeof DIALOG_SIZE>;
5
+ type DialogVariant = ValueOf<typeof DIALOG_VARIANT>;
6
+ interface Events {
7
+ onShownEvent: Event;
8
+ onHiddenEvent: Event;
9
+ onCreatedEvent: Event;
10
+ onDestroyedEvent: Event;
11
+ }
12
+ export type { DialogSize, DialogRole, DialogVariant, Events };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type Dialog from './dialog.component';
2
+ export declare class DialogUtils {
3
+ private dialog;
4
+ constructor(dialog: Dialog);
5
+ setupAriaAttributes(): void;
6
+ createBackdrop(): void;
7
+ }
@@ -0,0 +1,33 @@
1
+ export class DialogUtils {
2
+ constructor(dialog) {
3
+ this.dialog = dialog;
4
+ }
5
+ setupAriaAttributes() {
6
+ if (this.dialog.headerText && !this.dialog.ariaLabel && !this.dialog.ariaLabelledby) {
7
+ this.dialog.setAttribute('aria-labelledby', this.dialog.headerText);
8
+ }
9
+ else if (!this.dialog.headerText && !this.dialog.ariaLabel && !this.dialog.ariaLabelledby) {
10
+ this.dialog.setAttribute('aria-labelledby', this.dialog.triggerId);
11
+ }
12
+ }
13
+ createBackdrop() {
14
+ var _a;
15
+ const backdrop = document.createElement('div');
16
+ backdrop.classList.add('dialog-backdrop');
17
+ const styleElement = document.createElement('style');
18
+ styleElement.textContent = `
19
+ .dialog-backdrop {
20
+ position: fixed;
21
+ top: 0;
22
+ left: 0;
23
+ width: 100%;
24
+ height: 100%;
25
+ background: var(--mds-color-theme-common-overlays-secondary-normal);
26
+ z-index: ${this.dialog.zIndex - 1};
27
+ }
28
+ `;
29
+ backdrop.appendChild(styleElement);
30
+ (_a = this.dialog.parentElement) === null || _a === void 0 ? void 0 : _a.appendChild(backdrop);
31
+ this.dialog.backdropElement = backdrop;
32
+ }
33
+ }
@@ -0,0 +1,9 @@
1
+ import '../button';
2
+ import '../text';
3
+ import Dialog from './dialog.component';
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ ['mdc-dialog']: Dialog;
7
+ }
8
+ }
9
+ export default Dialog;
@@ -0,0 +1,6 @@
1
+ import '../button';
2
+ import '../text';
3
+ import Dialog from './dialog.component';
4
+ import { TAG_NAME } from './dialog.constants';
5
+ Dialog.register(TAG_NAME);
6
+ export default Dialog;
@@ -81,6 +81,11 @@ const styles = css `
81
81
  z-index: 9999;
82
82
  }
83
83
 
84
+ :host(:dir(rtl)) .popover-close {
85
+ right: auto;
86
+ left: 0.75rem;
87
+ }
88
+
84
89
  .popover-arrow[data-side='top'] {
85
90
  border-top: none;
86
91
  border-left: none;
@@ -21,5 +21,13 @@ const styles = css `
21
21
  :host([color='contrast'])::part(popover-content) {
22
22
  color: var(--mdc-toggletip-text-color-contrast);
23
23
  }
24
+
25
+ :host(:dir(ltr))::part(popover-content) {
26
+ margin-right: 2rem;
27
+ }
28
+
29
+ :host(:dir(rtl))::part(popover-content) {
30
+ margin-left: 2rem;
31
+ }
24
32
  `;
25
33
  export default [styles];