@vaadin/overlay 25.0.0-alpha8 → 25.0.0-alpha9
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/overlay",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
40
|
-
"@vaadin/component-base": "25.0.0-
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
42
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-
|
|
39
|
+
"@vaadin/a11y-base": "25.0.0-alpha9",
|
|
40
|
+
"@vaadin/component-base": "25.0.0-alpha9",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha9",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha9",
|
|
43
43
|
"lit": "^3.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
47
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
46
|
+
"@vaadin/chai-plugins": "25.0.0-alpha9",
|
|
47
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha9",
|
|
48
48
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
49
49
|
"sinon": "^18.0.0"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "bbe4720721e0955ffc87a79b412bee38b1f0eb1e"
|
|
52
52
|
}
|
|
@@ -117,8 +117,11 @@ export const OverlayMixin = (superClass) =>
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
/** @protected */
|
|
120
|
-
|
|
121
|
-
super.
|
|
120
|
+
firstUpdated() {
|
|
121
|
+
super.firstUpdated();
|
|
122
|
+
|
|
123
|
+
// Set popover in firstUpdated before opened observers are called
|
|
124
|
+
this.popover = 'manual';
|
|
122
125
|
|
|
123
126
|
// Need to add dummy click listeners to this and the backdrop or else
|
|
124
127
|
// the document click event listener (_outsideClickListener) may never
|
|
@@ -175,13 +178,17 @@ export const OverlayMixin = (superClass) =>
|
|
|
175
178
|
* @param {Event=} sourceEvent
|
|
176
179
|
*/
|
|
177
180
|
close(sourceEvent) {
|
|
178
|
-
|
|
181
|
+
// Dispatch the event on the overlay. Not using composed, as propagating the event through shadow roots could have
|
|
182
|
+
// side effects when nesting overlays
|
|
183
|
+
const event = new CustomEvent('vaadin-overlay-close', {
|
|
179
184
|
bubbles: true,
|
|
180
185
|
cancelable: true,
|
|
181
186
|
detail: { sourceEvent },
|
|
182
187
|
});
|
|
183
|
-
this.dispatchEvent(
|
|
184
|
-
|
|
188
|
+
this.dispatchEvent(event);
|
|
189
|
+
// To allow listening for the event globally, also dispatch it on the document body
|
|
190
|
+
document.body.dispatchEvent(event);
|
|
191
|
+
if (!event.defaultPrevented) {
|
|
185
192
|
this.opened = false;
|
|
186
193
|
}
|
|
187
194
|
}
|
|
@@ -308,7 +315,12 @@ export const OverlayMixin = (superClass) =>
|
|
|
308
315
|
setTimeout(() => {
|
|
309
316
|
this._trapFocus();
|
|
310
317
|
|
|
311
|
-
|
|
318
|
+
// Dispatch the event on the overlay. Not using composed, as propagating the event through shadow roots
|
|
319
|
+
// could have side effects when nesting overlays
|
|
320
|
+
const event = new CustomEvent('vaadin-overlay-open', { bubbles: true });
|
|
321
|
+
this.dispatchEvent(event);
|
|
322
|
+
// To allow listening for the event globally, also dispatch it on the document body
|
|
323
|
+
document.body.dispatchEvent(event);
|
|
312
324
|
});
|
|
313
325
|
});
|
|
314
326
|
|
|
@@ -407,9 +419,7 @@ export const OverlayMixin = (superClass) =>
|
|
|
407
419
|
|
|
408
420
|
/** @private */
|
|
409
421
|
_attachOverlay() {
|
|
410
|
-
this.
|
|
411
|
-
this.parentNode.insertBefore(this._placeholder, this);
|
|
412
|
-
document.body.appendChild(this);
|
|
422
|
+
this.showPopover();
|
|
413
423
|
}
|
|
414
424
|
|
|
415
425
|
/** @private */
|
|
@@ -448,8 +458,7 @@ export const OverlayMixin = (superClass) =>
|
|
|
448
458
|
|
|
449
459
|
/** @private */
|
|
450
460
|
_detachOverlay() {
|
|
451
|
-
this.
|
|
452
|
-
this._placeholder.parentNode.removeChild(this._placeholder);
|
|
461
|
+
this.hidePopover();
|
|
453
462
|
}
|
|
454
463
|
|
|
455
464
|
/** @private */
|
|
@@ -493,7 +502,6 @@ export const OverlayMixin = (superClass) =>
|
|
|
493
502
|
}
|
|
494
503
|
|
|
495
504
|
const evt = new CustomEvent('vaadin-overlay-outside-click', {
|
|
496
|
-
bubbles: true,
|
|
497
505
|
cancelable: true,
|
|
498
506
|
detail: { sourceEvent: event },
|
|
499
507
|
});
|
|
@@ -520,7 +528,6 @@ export const OverlayMixin = (superClass) =>
|
|
|
520
528
|
|
|
521
529
|
if (event.key === 'Escape') {
|
|
522
530
|
const evt = new CustomEvent('vaadin-overlay-escape-press', {
|
|
523
|
-
bubbles: true,
|
|
524
531
|
cancelable: true,
|
|
525
532
|
detail: { sourceEvent: event },
|
|
526
533
|
});
|
|
@@ -11,17 +11,7 @@ const attachedInstances = new Set();
|
|
|
11
11
|
* Returns all attached overlays in visual stacking order.
|
|
12
12
|
* @private
|
|
13
13
|
*/
|
|
14
|
-
const getAttachedInstances = () =>
|
|
15
|
-
[...attachedInstances].filter(
|
|
16
|
-
(el) => el instanceof HTMLElement && el._hasOverlayStackMixin && !el.hasAttribute('closing'),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Returns all attached overlay instances excluding notification container,
|
|
21
|
-
* which only needs to be in the stack for zIndex but not pointer-events.
|
|
22
|
-
* @private
|
|
23
|
-
*/
|
|
24
|
-
const getOverlayInstances = () => getAttachedInstances().filter((el) => el.$.overlay);
|
|
14
|
+
const getAttachedInstances = () => [...attachedInstances].filter((el) => !el.hasAttribute('closing'));
|
|
25
15
|
|
|
26
16
|
/**
|
|
27
17
|
* Returns true if all the instances on top of the overlay are nested overlays.
|
|
@@ -49,38 +39,15 @@ const hasOnlyNestedOverlays = (overlay) => {
|
|
|
49
39
|
* @protected
|
|
50
40
|
*/
|
|
51
41
|
export const isLastOverlay = (overlay, filter = (_overlay) => true) => {
|
|
52
|
-
const filteredOverlays =
|
|
42
|
+
const filteredOverlays = getAttachedInstances().filter(filter);
|
|
53
43
|
return overlay === filteredOverlays.pop();
|
|
54
44
|
};
|
|
55
45
|
|
|
56
|
-
const overlayMap = new WeakMap();
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Stores the reference to the nested overlay for given parent,
|
|
60
|
-
* or removes it when the nested overlay is null.
|
|
61
|
-
* @param {HTMLElement} parent
|
|
62
|
-
* @param {HTMLElement} nested
|
|
63
|
-
* @protected
|
|
64
|
-
*/
|
|
65
|
-
export const setNestedOverlay = (parent, nested) => {
|
|
66
|
-
if (nested != null) {
|
|
67
|
-
overlayMap.set(parent, nested);
|
|
68
|
-
} else {
|
|
69
|
-
overlayMap.delete(parent);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
46
|
/**
|
|
74
47
|
* @polymerMixin
|
|
75
48
|
*/
|
|
76
49
|
export const OverlayStackMixin = (superClass) =>
|
|
77
50
|
class OverlayStackMixin extends superClass {
|
|
78
|
-
constructor() {
|
|
79
|
-
super();
|
|
80
|
-
|
|
81
|
-
this._hasOverlayStackMixin = true;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
51
|
/**
|
|
85
52
|
* Returns true if this is the last one in the opened overlays stack.
|
|
86
53
|
*
|
|
@@ -105,18 +72,6 @@ export const OverlayStackMixin = (superClass) =>
|
|
|
105
72
|
* Brings the overlay as visually the frontmost one.
|
|
106
73
|
*/
|
|
107
74
|
bringToFront() {
|
|
108
|
-
// Update z-index to be the highest among all attached overlays
|
|
109
|
-
// TODO: Can be removed after switching all overlays to be based on native popover
|
|
110
|
-
let zIndex = '';
|
|
111
|
-
const frontmost = getAttachedInstances()
|
|
112
|
-
.filter((o) => o !== this)
|
|
113
|
-
.pop();
|
|
114
|
-
if (frontmost) {
|
|
115
|
-
const frontmostZIndex = parseFloat(getComputedStyle(frontmost).zIndex);
|
|
116
|
-
zIndex = frontmostZIndex + 1;
|
|
117
|
-
}
|
|
118
|
-
this.style.zIndex = zIndex;
|
|
119
|
-
|
|
120
75
|
// If the overlay is the last one, or if all other overlays shown above
|
|
121
76
|
// are nested overlays (e.g. date-picker inside a dialog), do not call
|
|
122
77
|
// `showPopover()` unnecessarily to avoid scroll position being reset.
|
|
@@ -133,11 +88,6 @@ export const OverlayStackMixin = (superClass) =>
|
|
|
133
88
|
// Update order of attached instances
|
|
134
89
|
this._removeAttachedInstance();
|
|
135
90
|
this._appendAttachedInstance();
|
|
136
|
-
|
|
137
|
-
// If there is a nested overlay, call `bringToFront()` for it as well.
|
|
138
|
-
if (overlayMap.has(this)) {
|
|
139
|
-
overlayMap.get(this).bringToFront();
|
|
140
|
-
}
|
|
141
91
|
}
|
|
142
92
|
|
|
143
93
|
/** @protected */
|
|
@@ -150,7 +100,7 @@ export const OverlayStackMixin = (superClass) =>
|
|
|
150
100
|
}
|
|
151
101
|
|
|
152
102
|
// Disable pointer events in other attached overlays
|
|
153
|
-
|
|
103
|
+
getAttachedInstances().forEach((el) => {
|
|
154
104
|
if (el !== this) {
|
|
155
105
|
el.$.overlay.style.pointerEvents = 'none';
|
|
156
106
|
}
|
|
@@ -166,7 +116,7 @@ export const OverlayStackMixin = (superClass) =>
|
|
|
166
116
|
}
|
|
167
117
|
|
|
168
118
|
// Restore pointer events in the previous overlay(s)
|
|
169
|
-
const instances =
|
|
119
|
+
const instances = getAttachedInstances();
|
|
170
120
|
|
|
171
121
|
let el;
|
|
172
122
|
// Use instances.pop() to ensure the reverse order
|