@momentum-design/components 0.85.9 → 0.86.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.
@@ -77,6 +77,8 @@ 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;
@@ -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
  /**
@@ -90,6 +90,8 @@ 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;
@@ -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);
@@ -62,7 +62,7 @@ declare class MenuItemCheckbox extends MenuItem {
62
62
  * If the menuitemcheckbox is disabled, it does nothing.
63
63
  * If the menuitemcheckbox is not disabled, it toggles the `checked` state between `true` and `false`.
64
64
  */
65
- private menuitemcheckboxHandleClick;
65
+ private handleMouseClick;
66
66
  update(changedProperties: PropertyValues): void;
67
67
  /**
68
68
  * Returns a static checkbox element if the indicator is set to checkbox.
@@ -76,14 +76,14 @@ class MenuItemCheckbox extends MenuItem {
76
76
  * If the menuitemcheckbox is disabled, it does nothing.
77
77
  * If the menuitemcheckbox is not disabled, it toggles the `checked` state between `true` and `false`.
78
78
  */
79
- this.menuitemcheckboxHandleClick = (event) => {
79
+ this.handleMouseClick = (event) => {
80
80
  event.stopPropagation();
81
81
  if (this.disabled)
82
82
  return;
83
83
  this.checked = !this.checked;
84
84
  this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
85
85
  };
86
- this.addEventListener('click', this.menuitemcheckboxHandleClick);
86
+ this.addEventListener('click', this.handleMouseClick);
87
87
  }
88
88
  connectedCallback() {
89
89
  super.connectedCallback();
@@ -101,16 +101,16 @@ class MenuItemCheckbox extends MenuItem {
101
101
  * @returns TemplateResult | typeof nothing
102
102
  */
103
103
  staticCheckbox() {
104
- if (this.indicator !== INDICATOR.CHECKBOX) {
105
- return nothing;
104
+ if (this.indicator === INDICATOR.CHECKBOX) {
105
+ return html `
106
+ <mdc-staticcheckbox
107
+ slot="leading-controls"
108
+ ?checked="${this.checked}"
109
+ ?disabled="${this.disabled}"
110
+ ></mdc-staticcheckbox>
111
+ `;
106
112
  }
107
- return html `
108
- <mdc-staticcheckbox
109
- slot="leading-controls"
110
- ?checked="${this.checked}"
111
- ?disabled="${this.disabled}"
112
- ></mdc-staticcheckbox>
113
- `;
113
+ return nothing;
114
114
  }
115
115
  /**
116
116
  * Returns a static toggle element if the indicator is set to toggle.
@@ -120,17 +120,17 @@ class MenuItemCheckbox extends MenuItem {
120
120
  * @returns TemplateResult | typeof nothing
121
121
  */
122
122
  staticToggle() {
123
- if (this.indicator !== INDICATOR.TOGGLE) {
124
- return nothing;
123
+ if (this.indicator === INDICATOR.TOGGLE) {
124
+ return html `
125
+ <mdc-statictoggle
126
+ slot="trailing-controls"
127
+ ?checked="${this.checked}"
128
+ ?disabled="${this.disabled}"
129
+ size="${TOGGLE_SIZE.COMPACT}"
130
+ ></mdc-statictoggle>
131
+ `;
125
132
  }
126
- return html `
127
- <mdc-statictoggle
128
- slot="trailing-controls"
129
- ?checked="${this.checked}"
130
- ?disabled="${this.disabled}"
131
- size="${TOGGLE_SIZE.COMPACT}"
132
- ></mdc-statictoggle>
133
- `;
133
+ return nothing;
134
134
  }
135
135
  /**
136
136
  * Returns a checkmark icon if the indicator is set to checkmark and the checked state is true.
@@ -1,3 +1,4 @@
1
+ import '../icon';
1
2
  import '../staticradio';
2
3
  import '../text';
3
4
  import '../tooltip';
@@ -1,3 +1,4 @@
1
+ import '../icon';
1
2
  import '../staticradio';
2
3
  import '../text';
3
4
  import '../tooltip';
@@ -27,8 +27,10 @@ import { Indicator } from './menuitemradio.types';
27
27
  * For example, you can use a custom icon or a different visual element to indicate the state of the menu item.
28
28
  * Make sure the new indicator is accessible.
29
29
  *
30
+ * @dependency mdc-icon
30
31
  * @dependency mdc-staticradio
31
32
  * @dependency mdc-text
33
+ * @dependency mdc-tooltip
32
34
  *
33
35
  * @tagname mdc-menuitemradio
34
36
  *
@@ -72,7 +74,7 @@ declare class MenuItemRadio extends MenuItem {
72
74
  * If the menuitemradio is not checked, it sets its checked state to `true`
73
75
  * and sets all other menuitemradio elements of the same group with checked state to `false`.
74
76
  */
75
- private radioHandleClick;
77
+ private handleMouseClick;
76
78
  update(changedProperties: PropertyValues): void;
77
79
  /**
78
80
  * Returns a static checkbox element if the indicator is set to checkbox.
@@ -42,8 +42,10 @@ import styles from './menuitemradio.styles';
42
42
  * For example, you can use a custom icon or a different visual element to indicate the state of the menu item.
43
43
  * Make sure the new indicator is accessible.
44
44
  *
45
+ * @dependency mdc-icon
45
46
  * @dependency mdc-staticradio
46
47
  * @dependency mdc-text
48
+ * @dependency mdc-tooltip
47
49
  *
48
50
  * @tagname mdc-menuitemradio
49
51
  *
@@ -77,7 +79,7 @@ class MenuItemRadio extends MenuItem {
77
79
  * If the menuitemradio is not checked, it sets its checked state to `true`
78
80
  * and sets all other menuitemradio elements of the same group with checked state to `false`.
79
81
  */
80
- this.radioHandleClick = (event) => {
82
+ this.handleMouseClick = (event) => {
81
83
  event.stopPropagation();
82
84
  if (this.disabled || this.checked)
83
85
  return;
@@ -85,7 +87,7 @@ class MenuItemRadio extends MenuItem {
85
87
  this.checked = true;
86
88
  this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
87
89
  };
88
- this.addEventListener('click', this.radioHandleClick);
90
+ this.addEventListener('click', this.handleMouseClick);
89
91
  }
90
92
  connectedCallback() {
91
93
  super.connectedCallback();
@@ -108,9 +110,9 @@ class MenuItemRadio extends MenuItem {
108
110
  updateOtherRadiosCheckedState() {
109
111
  const radios = this.getAllRadiosWithinSameGroup();
110
112
  radios.forEach(radio => {
111
- // eslint-disable-next-line no-param-reassign
112
- if (radio !== this)
113
- radio.checked = false;
113
+ if (radio !== this) {
114
+ radio.removeAttribute('checked');
115
+ }
114
116
  });
115
117
  }
116
118
  update(changedProperties) {
@@ -128,16 +130,16 @@ class MenuItemRadio extends MenuItem {
128
130
  * @returns TemplateResult | typeof nothing
129
131
  */
130
132
  renderStaticRadio() {
131
- if (this.indicator !== INDICATOR.RADIO) {
132
- return nothing;
133
+ if (this.indicator === INDICATOR.RADIO) {
134
+ return html `
135
+ <mdc-staticradio
136
+ slot="leading-controls"
137
+ ?checked="${this.checked}"
138
+ ?disabled="${this.disabled}"
139
+ ></mdc-staticradio>
140
+ `;
133
141
  }
134
- return html `
135
- <mdc-staticradio
136
- slot="leading-controls"
137
- ?checked="${this.checked}"
138
- ?disabled="${this.disabled}"
139
- ></mdc-staticradio>
140
- `;
142
+ return nothing;
141
143
  }
142
144
  /**
143
145
  * Returns a checkmark icon if the indicator is set to checkmark and the checked state is true.
@@ -75,7 +75,7 @@ __decorate([
75
75
  __metadata("design:type", Object)
76
76
  ], MenuSection.prototype, "ariaLabel", void 0);
77
77
  __decorate([
78
- property({ type: String, reflect: true }),
78
+ property({ type: String, reflect: true, attribute: 'header-text' }),
79
79
  __metadata("design:type", Object)
80
80
  ], MenuSection.prototype, "headerText", void 0);
81
81
  export default MenuSection;