@momentum-design/components 0.143.1 → 0.143.3

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.
@@ -183,7 +183,9 @@ class Dialog extends KeyDownHandledMixin(KeyToActionMixin(BackdropMixin(PreventS
183
183
  * @param event - The keyboard event.
184
184
  */
185
185
  this.onEscapeKeydown = (event) => {
186
- if (!this.visible || this.getActionForKeyEvent(event) !== ACTIONS.ESCAPE || !this.depthManager.isHostOnTop()) {
186
+ if (!this.visible ||
187
+ this.getActionForKeyEvent(event) !== ACTIONS.ESCAPE ||
188
+ !this.depthManager.isHostEscapeTarget()) {
187
189
  return;
188
190
  }
189
191
  event.preventDefault();
@@ -142,6 +142,16 @@ const styles = [
142
142
  :host([disabled])::part(character-counter) {
143
143
  color: var(--mds-color-theme-text-primary-disabled);
144
144
  }
145
+
146
+ input[part='input-text']::-webkit-contacts-auto-fill-button {
147
+ background-color: var(--mdc-input-text-color);
148
+ }
149
+
150
+ /* On hover, and on Safari's yellow autofilled background, use Safari's own icon color. */
151
+ input[part='input-text']::-webkit-contacts-auto-fill-button:hover,
152
+ input[part='input-text']:-webkit-autofill::-webkit-contacts-auto-fill-button {
153
+ background-color: revert;
154
+ }
145
155
  `,
146
156
  ...hostFocusRingStyles(true),
147
157
  ];
@@ -2,11 +2,13 @@ import { css } from 'lit';
2
2
  import { hostFitContentStyles } from '../../utils/styles';
3
3
  const styles = css `
4
4
  :host {
5
- height: 1.5rem;
6
- gap: 0.25rem;
7
- padding: 0 0.25rem 0 0.5rem;
8
- border-radius: 0.25rem;
9
- border: 1px solid;
5
+ height: var(--mds-size-theme-md-24);
6
+ gap: var(--mds-spacing-theme-gap-2xs);
7
+ padding: var(--mds-spacing-theme-pad-none) var(--mds-spacing-theme-pad-h-2xs) var(--mds-spacing-theme-pad-none)
8
+ var(--mds-spacing-theme-pad-h-xs);
9
+ border-radius: var(--mds-radius-theme-xs);
10
+ border-style: solid;
11
+ border-width: var(--mds-border-theme-default);
10
12
  white-space: nowrap;
11
13
 
12
14
  --mdc-chip-color: var(--mds-color-theme-text-primary-normal);
@@ -32,9 +34,9 @@ const styles = css `
32
34
  cursor: auto;
33
35
  }
34
36
 
35
- ::slotted(mdc-avatar[slot='prefix']){
36
- width: 1.25rem;
37
- height: 1.25rem;
37
+ ::slotted(mdc-avatar[slot='prefix']) {
38
+ width: var(--mds-size-theme-md-20);
39
+ height: var(--mds-size-theme-md-20);
38
40
  }
39
41
  `;
40
42
  export default [hostFitContentStyles, styles];
@@ -96,7 +96,7 @@ declare class MenuPopover extends Popover {
96
96
  * Handles outside click events to close the popover.
97
97
  * This method checks if the click occurred outside the popover and its trigger element.
98
98
  * If so, it closes the popover by calling `closeAllMenuPopovers`.
99
- * It also checks if the click was on the backdrop element (if present) to close the popover.
99
+ * A click on its own backdrop closes this menu and later same-group overlays, even when it is not on top.
100
100
  * @param event - The mouse event that triggered the outside click.
101
101
  */
102
102
  onOutsidePopoverClick: (event: MouseEvent) => void;
@@ -60,20 +60,21 @@ class MenuPopover extends Popover {
60
60
  * Handles outside click events to close the popover.
61
61
  * This method checks if the click occurred outside the popover and its trigger element.
62
62
  * If so, it closes the popover by calling `closeAllMenuPopovers`.
63
- * It also checks if the click was on the backdrop element (if present) to close the popover.
63
+ * A click on its own backdrop closes this menu and later same-group overlays, even when it is not on top.
64
64
  * @param event - The mouse event that triggered the outside click.
65
65
  */
66
66
  this.onOutsidePopoverClick = (event) => {
67
+ const path = event.composedPath();
68
+ if (path[0] === this.backdropElement && this.depthManager.has(this)) {
69
+ this.depthManager.popHost();
70
+ event.stopPropagation();
71
+ return;
72
+ }
67
73
  if (!this.depthManager.isHostOnTop())
68
74
  return;
69
- const path = event.composedPath();
70
75
  const insidePopoverClick = this.contains(event.target) || path.includes(this.triggerElement) || path.includes(this);
71
- const clickedOnBackdrop = this.backdropElement ? path.includes(this.backdropElement) : false;
72
- if (!insidePopoverClick || clickedOnBackdrop) {
76
+ if (!insidePopoverClick) {
73
77
  this.closeAllMenuPopovers();
74
- if (clickedOnBackdrop) {
75
- event.stopPropagation();
76
- }
77
78
  }
78
79
  };
79
80
  /**
@@ -195,7 +196,7 @@ class MenuPopover extends Popover {
195
196
  break;
196
197
  }
197
198
  case ACTIONS.ESCAPE: {
198
- if (this.depthManager.isHostOnTop()) {
199
+ if (this.depthManager.isHostEscapeTarget()) {
199
200
  this.resetTabIndexAndSetFocus(0, currentIndex);
200
201
  isKeyHandled = true;
201
202
  }
@@ -466,17 +466,20 @@ class Popover extends KeyDownHandledMixin(KeyToActionMixin(BackdropMixin(Prevent
466
466
  * @internal
467
467
  */
468
468
  this.onOutsidePopoverClick = (event) => {
469
+ const path = event.composedPath();
470
+ // A backdrop click closes its owner even when a later overlay is on top.
471
+ if (path[0] === this.backdropElement && this.depthManager.has(this)) {
472
+ this.hide();
473
+ PopoverEventManager.onClickOutside(this);
474
+ event.stopPropagation();
475
+ return;
476
+ }
469
477
  if (!this.depthManager.isHostOnTop())
470
478
  return;
471
- const path = event.composedPath();
472
479
  const insidePopoverClick = this.contains(event.target) || path.includes(this.triggerElement) || path.includes(this);
473
- const clickedOnBackdrop = this.backdropElement ? path.includes(this.backdropElement) : false;
474
- if (!insidePopoverClick || clickedOnBackdrop) {
480
+ if (!insidePopoverClick) {
475
481
  this.hide();
476
482
  PopoverEventManager.onClickOutside(this);
477
- if (clickedOnBackdrop) {
478
- event.stopPropagation();
479
- }
480
483
  }
481
484
  };
482
485
  /**
@@ -488,7 +491,9 @@ class Popover extends KeyDownHandledMixin(KeyToActionMixin(BackdropMixin(Prevent
488
491
  * @internal
489
492
  */
490
493
  this.onEscapeKeydown = (event) => {
491
- if (!this.visible || this.getActionForKeyEvent(event) !== ACTIONS.ESCAPE || !this.depthManager.isHostOnTop()) {
494
+ if (!this.visible ||
495
+ this.getActionForKeyEvent(event) !== ACTIONS.ESCAPE ||
496
+ !this.depthManager.isHostEscapeTarget()) {
492
497
  return;
493
498
  }
494
499
  if (!this.propagateEventOnEscape) {
@@ -5272,8 +5272,8 @@
5272
5272
  "attribute": "auto-focus-on-mount",
5273
5273
  "reflects": true,
5274
5274
  "inheritedFrom": {
5275
- "name": "Buttonsimple",
5276
- "module": "components/buttonsimple/buttonsimple.component.js"
5275
+ "name": "AutoFocusOnMountMixin",
5276
+ "module": "utils/mixins/AutoFocusOnMountMixin.js"
5277
5277
  }
5278
5278
  },
5279
5279
  {
@@ -5301,8 +5301,8 @@
5301
5301
  "attribute": "disabled",
5302
5302
  "reflects": true,
5303
5303
  "inheritedFrom": {
5304
- "name": "Buttonsimple",
5305
- "module": "components/buttonsimple/buttonsimple.component.js"
5304
+ "name": "DisabledMixin",
5305
+ "module": "utils/mixins/DisabledMixin.js"
5306
5306
  }
5307
5307
  },
5308
5308
  {
@@ -5669,8 +5669,8 @@
5669
5669
  "attribute": "tabIndex",
5670
5670
  "reflects": true,
5671
5671
  "inheritedFrom": {
5672
- "name": "Buttonsimple",
5673
- "module": "components/buttonsimple/buttonsimple.component.js"
5672
+ "name": "TabIndexMixin",
5673
+ "module": "utils/mixins/TabIndexMixin.js"
5674
5674
  }
5675
5675
  },
5676
5676
  {
@@ -5821,8 +5821,8 @@
5821
5821
  "description": "This property indicates whether the element should receive focus automatically when it is mounted.\n\nIt will not focus if the element is re-attached to the DOM after being removed.",
5822
5822
  "fieldName": "autoFocusOnMount",
5823
5823
  "inheritedFrom": {
5824
- "name": "Buttonsimple",
5825
- "module": "src/components/buttonsimple/buttonsimple.component.ts"
5824
+ "name": "AutoFocusOnMountMixin",
5825
+ "module": "src/utils/mixins/AutoFocusOnMountMixin.ts"
5826
5826
  }
5827
5827
  },
5828
5828
  {
@@ -5834,8 +5834,8 @@
5834
5834
  "description": "This property specifies the tab order of the element.",
5835
5835
  "fieldName": "tabIndex",
5836
5836
  "inheritedFrom": {
5837
- "name": "Buttonsimple",
5838
- "module": "src/components/buttonsimple/buttonsimple.component.ts"
5837
+ "name": "TabIndexMixin",
5838
+ "module": "src/utils/mixins/TabIndexMixin.ts"
5839
5839
  }
5840
5840
  },
5841
5841
  {
@@ -5847,8 +5847,8 @@
5847
5847
  "default": "undefined",
5848
5848
  "fieldName": "disabled",
5849
5849
  "inheritedFrom": {
5850
- "name": "Buttonsimple",
5851
- "module": "src/components/buttonsimple/buttonsimple.component.ts"
5850
+ "name": "DisabledMixin",
5851
+ "module": "src/utils/mixins/DisabledMixin.ts"
5852
5852
  }
5853
5853
  },
5854
5854
  {
@@ -30312,7 +30312,7 @@
30312
30312
  {
30313
30313
  "kind": "field",
30314
30314
  "name": "onOutsidePopoverClick",
30315
- "description": "Handles outside click events to close the popover.\nThis method checks if the click occurred outside the popover and its trigger element.\nIf so, it closes the popover by calling `closeAllMenuPopovers`.\nIt also checks if the click was on the backdrop element (if present) to close the popover.",
30315
+ "description": "Handles outside click events to close the popover.\nThis method checks if the click occurred outside the popover and its trigger element.\nIf so, it closes the popover by calling `closeAllMenuPopovers`.\nA click on its own backdrop closes this menu and later same-group overlays, even when it is not on top.",
30316
30316
  "parameters": [
30317
30317
  {
30318
30318
  "description": "The mouse event that triggered the outside click.",
@@ -41,6 +41,7 @@ type PopPredicateFn = (item: StackedOverlayComponent, idx: number) => true | fal
41
41
  export declare const OVERLAY_BACKDROP_Z_INDEX_OFFSET = -2;
42
42
  export declare const OVERLAY_TRIGGER_Z_INDEX_OFFSET = -1;
43
43
  /**
44
+ * @remarks
44
45
  * DepthManager is a controller that manages a stack of elements to control their depth (z-index).
45
46
  *
46
47
  * It uses a global stack to keep track of the order of elements, allowing for proper layering of overlays.
@@ -199,6 +200,13 @@ export declare class DepthManager implements ReactiveController {
199
200
  * @returns True if host is on top, false otherwise
200
201
  */
201
202
  isHostOnTop(): boolean;
203
+ /**
204
+ * Checks whether the nearest overlay or trigger containing focus belongs to the host.
205
+ * Falls back to the top of the stack when focus is outside all registered overlays and triggers.
206
+ *
207
+ * @returns True if the host should handle Escape
208
+ */
209
+ isHostEscapeTarget(): boolean;
202
210
  /**
203
211
  * Clears the stack
204
212
  *
@@ -1,3 +1,4 @@
1
+ import { getDomActiveElement } from '../dom';
1
2
  /**
2
3
  * Global stack of elements managed by DepthManager
3
4
  * @internal
@@ -18,6 +19,7 @@ const NUMBER_OF_Z_INDEX_LEVELS_PER_ELEMENT = 3;
18
19
  export const OVERLAY_BACKDROP_Z_INDEX_OFFSET = -2;
19
20
  export const OVERLAY_TRIGGER_Z_INDEX_OFFSET = -1;
20
21
  /**
22
+ * @remarks
21
23
  * DepthManager is a controller that manages a stack of elements to control their depth (z-index).
22
24
  *
23
25
  * It uses a global stack to keep track of the order of elements, allowing for proper layering of overlays.
@@ -258,6 +260,36 @@ export class DepthManager {
258
260
  isHostOnTop() {
259
261
  return this.peek() === this.host;
260
262
  }
263
+ /**
264
+ * Checks whether the nearest overlay or trigger containing focus belongs to the host.
265
+ * Falls back to the top of the stack when focus is outside all registered overlays and triggers.
266
+ *
267
+ * @returns True if the host should handle Escape
268
+ */
269
+ isHostEscapeTarget() {
270
+ const latestFirst = [...elementStack].reverse();
271
+ let focused = getDomActiveElement();
272
+ while (focused) {
273
+ const target = focused;
274
+ const overlay = latestFirst.find(element => element === target ||
275
+ (target instanceof Element &&
276
+ !!element.triggerID &&
277
+ target.id === element.triggerID &&
278
+ target.getRootNode() === element.getRootNode()));
279
+ if (overlay)
280
+ return overlay === this.host;
281
+ if (focused instanceof Element && focused.assignedSlot) {
282
+ focused = focused.assignedSlot;
283
+ }
284
+ else if (focused instanceof ShadowRoot) {
285
+ focused = focused.host;
286
+ }
287
+ else {
288
+ focused = focused.parentNode;
289
+ }
290
+ }
291
+ return this.isHostOnTop();
292
+ }
261
293
  /**
262
294
  * Clears the stack
263
295
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@momentum-design/components",
3
- "packageManager": "yarn@3.2.4",
4
- "version": "0.143.1",
3
+ "packageManager": "yarn@4.18.1",
4
+ "version": "0.143.3",
5
5
  "engines": {
6
6
  "node": ">=24.0.0",
7
7
  "npm": ">=8.0.0"