@momentum-design/components 0.85.8 → 0.85.10

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.
@@ -5,7 +5,7 @@ declare const Dialog_base: import("../../utils/mixins/index.types").Constructor<
5
5
  /**
6
6
  * Dialog component is a modal dialog that can be used to display information or prompt the user for input.
7
7
  * It can be used to create custom dialogs where content for the body and footer actions is provided by the consumer.
8
- * The dialog is available in three sizes: small, medium, and large. It may also receive custom styling/sizing.
8
+ * The dialog is available in 5 sizes: small, medium, large, xlarge and fullscreen. It may also receive custom styling/sizing.
9
9
  * The dialog interrupts the user and will block interaction with the rest of the application until it is closed.
10
10
  *
11
11
  * The dialog can be controlled solely through the `visible` property, no trigger element is required.
@@ -77,11 +77,13 @@ declare class Dialog extends Dialog_base {
77
77
  visible: boolean;
78
78
  /**
79
79
  * The z-index of the dialog
80
+ *
81
+ * The backdrop will have z-index of `zIndex - 1`
80
82
  * @default 1000
81
83
  */
82
84
  zIndex: number;
83
85
  /**
84
- * The size of the dialog, can be 'small' (432px width), 'medium' (656px width), or 'large' (992px width)
86
+ * The size of the dialog, can be 'small' (432px width), 'medium' (656px width), 'large' (992px width), 'xlarge' (90% width) or 'fullscreen' (100% width).
85
87
  * @default small
86
88
  */
87
89
  size: DialogSize;
@@ -165,6 +167,13 @@ declare class Dialog extends Dialog_base {
165
167
  protected lastActiveElement: HTMLElement | null;
166
168
  connectedCallback(): void;
167
169
  disconnectedCallback(): void;
170
+ /**
171
+ * Applies the z-index to the dialog and backdrop elements.
172
+ * The dialog will have a z-index of `zIndex` and the backdrop will have a z-index of `zIndex - 1`.
173
+ *
174
+ * @internal
175
+ */
176
+ private applyZIndex;
168
177
  protected firstUpdated(changedProperties: PropertyValues): Promise<void>;
169
178
  protected updated(changedProperties: PropertyValues): Promise<void>;
170
179
  /**
@@ -22,7 +22,7 @@ import styles from './dialog.styles';
22
22
  /**
23
23
  * Dialog component is a modal dialog that can be used to display information or prompt the user for input.
24
24
  * It can be used to create custom dialogs where content for the body and footer actions is provided by the consumer.
25
- * The dialog is available in three sizes: small, medium, and large. It may also receive custom styling/sizing.
25
+ * The dialog is available in 5 sizes: small, medium, large, xlarge and fullscreen. It may also receive custom styling/sizing.
26
26
  * The dialog interrupts the user and will block interaction with the rest of the application until it is closed.
27
27
  *
28
28
  * The dialog can be controlled solely through the `visible` property, no trigger element is required.
@@ -90,11 +90,13 @@ class Dialog extends PreventScrollMixin(FocusTrapMixin(CardAndDialogFooterMixin(
90
90
  this.visible = DEFAULTS.VISIBLE;
91
91
  /**
92
92
  * The z-index of the dialog
93
+ *
94
+ * The backdrop will have z-index of `zIndex - 1`
93
95
  * @default 1000
94
96
  */
95
97
  this.zIndex = DEFAULTS.Z_INDEX;
96
98
  /**
97
- * The size of the dialog, can be 'small' (432px width), 'medium' (656px width), or 'large' (992px width)
99
+ * The size of the dialog, can be 'small' (432px width), 'medium' (656px width), 'large' (992px width), 'xlarge' (90% width) or 'fullscreen' (100% width).
98
100
  * @default small
99
101
  */
100
102
  this.size = DEFAULTS.SIZE;
@@ -203,11 +205,22 @@ class Dialog extends PreventScrollMixin(FocusTrapMixin(CardAndDialogFooterMixin(
203
205
  this.focusBackToTrigger();
204
206
  DialogEventManager.onDestroyedDialog(this);
205
207
  }
208
+ /**
209
+ * Applies the z-index to the dialog and backdrop elements.
210
+ * The dialog will have a z-index of `zIndex` and the backdrop will have a z-index of `zIndex - 1`.
211
+ *
212
+ * @internal
213
+ */
214
+ applyZIndex() {
215
+ var _a;
216
+ this.style.setProperty('z-index', `${this.zIndex}`);
217
+ (_a = this.backdropElement) === null || _a === void 0 ? void 0 : _a.style.setProperty('z-index', `${this.zIndex - 1}`);
218
+ }
206
219
  async firstUpdated(changedProperties) {
207
220
  super.firstUpdated(changedProperties);
208
221
  this.setAttribute('aria-modal', 'true');
209
222
  this.setupAriaLabelledDescribedBy();
210
- this.style.zIndex = `${this.zIndex}`;
223
+ this.applyZIndex();
211
224
  DialogEventManager.onCreatedDialog(this);
212
225
  }
213
226
  async updated(changedProperties) {
@@ -221,7 +234,12 @@ class Dialog extends PreventScrollMixin(FocusTrapMixin(CardAndDialogFooterMixin(
221
234
  await this.isOpenUpdated(oldValue, this.visible);
222
235
  }
223
236
  if (changedProperties.has('zIndex')) {
224
- this.setAttribute('z-index', `${this.zIndex}`);
237
+ // If zIndex is not set, use the default value
238
+ // This is to ensure that the dialog has always a z-index set even if not explicitly defined
239
+ if (this.zIndex === null) {
240
+ this.zIndex = DEFAULTS.Z_INDEX;
241
+ }
242
+ this.applyZIndex();
225
243
  }
226
244
  if (changedProperties.has('variant')) {
227
245
  this.updateFooterButtonColors(this.variant);
@@ -15,6 +15,6 @@ declare const DEFAULTS: {
15
15
  readonly DISABLE_ARIA_HAS_POPUP: false;
16
16
  readonly FOCUS_TRAP: true;
17
17
  };
18
- declare const DIALOG_SIZE: readonly ["small", "medium", "large"];
18
+ declare const DIALOG_SIZE: readonly ["small", "medium", "large", "xlarge", "fullscreen"];
19
19
  declare const DIALOG_ROLE: readonly ["dialog", "alertdialog"];
20
20
  export { TAG_NAME, DEFAULTS, DIALOG_SIZE, DIALOG_ROLE, DIALOG_VARIANT };
@@ -16,6 +16,6 @@ const DEFAULTS = {
16
16
  DISABLE_ARIA_HAS_POPUP: false,
17
17
  FOCUS_TRAP: true,
18
18
  };
19
- const DIALOG_SIZE = ['small', 'medium', 'large'];
19
+ const DIALOG_SIZE = ['small', 'medium', 'large', 'xlarge', 'fullscreen'];
20
20
  const DIALOG_ROLE = ['dialog', 'alertdialog'];
21
21
  export { TAG_NAME, DEFAULTS, DIALOG_SIZE, DIALOG_ROLE, DIALOG_VARIANT };
@@ -7,13 +7,14 @@ const styles = css `
7
7
  --mdc-dialog-description-text-color: var(--mds-color-theme-text-secondary-normal);
8
8
  --mdc-dialog-elevation-3: var(--mds-elevation-3);
9
9
  --mdc-dialog-width: 27rem; /* Default to small */
10
+ --mdc-dialog-padding: 1.5rem;
10
11
 
11
12
  background-color: var(--mdc-dialog-primary-background-color);
12
13
  border: 0.0625rem solid var(--mdc-dialog-border-color);
13
14
  border-radius: 0.5rem;
14
15
  filter: var(--mdc-dialog-elevation-3);
15
16
  display: none;
16
- padding: 1rem;
17
+ padding: var(--mdc-dialog-padding);
17
18
  flex-direction: column;
18
19
  justify-content: center;
19
20
  align-items: center;
@@ -40,6 +41,23 @@ const styles = css `
40
41
  --mdc-dialog-width: 62rem;
41
42
  }
42
43
 
44
+ :host([size='xlarge']) {
45
+ --mdc-dialog-width: 90%;
46
+ }
47
+
48
+ @media (max-width: 62rem) {
49
+ :host([size='xlarge']) {
50
+ --mdc-dialog-width: 100%;
51
+ }
52
+ }
53
+
54
+ :host([size='fullscreen']) {
55
+ --mdc-dialog-width: 100%;
56
+ height: 100%;
57
+ border: none;
58
+ border-radius: 0;
59
+ }
60
+
43
61
  :host {
44
62
  width: var(--mdc-dialog-width);
45
63
  max-width: 100%;
@@ -91,14 +109,13 @@ const styles = css `
91
109
 
92
110
  :host::part(dialog-close-btn) {
93
111
  position: absolute;
94
- top: 1rem;
95
- right: 1rem;
96
- cursor: pointer;
112
+ top: var(--mdc-dialog-padding);
113
+ right: var(--mdc-dialog-padding);
97
114
  }
98
115
 
99
116
  :host(:dir(rtl))::part(dialog-close-btn) {
100
117
  right: auto;
101
- left: 1rem;
118
+ left: var(--mdc-dialog-padding);
102
119
  }
103
120
 
104
121
  mdc-text::part(text) {