@vaadin/overlay 24.0.0-alpha1 → 24.0.0-alpha10
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": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,21 +34,18 @@
|
|
|
34
34
|
"polymer"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
37
38
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/component-base": "24.0.0-
|
|
39
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
40
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
41
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
39
|
+
"@vaadin/component-base": "24.0.0-alpha10",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha10",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha10",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha10"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@esm-bundle/chai": "^4.3.4",
|
|
45
|
-
"@vaadin/button": "24.0.0-alpha1",
|
|
46
|
-
"@vaadin/polymer-legacy-adapter": "24.0.0-alpha1",
|
|
47
|
-
"@vaadin/radio-group": "24.0.0-alpha1",
|
|
48
46
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
49
|
-
"@vaadin/text-field": "24.0.0-alpha1",
|
|
50
47
|
"lit": "^2.0.0",
|
|
51
48
|
"sinon": "^13.0.2"
|
|
52
49
|
},
|
|
53
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "2e04534d8b47bcd216f89b5f849bafef1a73b174"
|
|
54
51
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
|
|
8
|
+
export declare function PositionMixin<T extends Constructor<HTMLElement>>(base: T): Constructor<PositionMixinClass> & T;
|
|
9
|
+
|
|
10
|
+
export declare class PositionMixinClass {
|
|
11
|
+
/**
|
|
12
|
+
* The element next to which this overlay should be aligned.
|
|
13
|
+
* The position of the overlay relative to the positionTarget can be adjusted
|
|
14
|
+
* with properties `horizontalAlign`, `verticalAlign`, `noHorizontalOverlap`
|
|
15
|
+
* and `noVerticalOverlap`.
|
|
16
|
+
*/
|
|
17
|
+
positionTarget: HTMLElement;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* When `positionTarget` is set, this property defines whether to align the overlay's
|
|
21
|
+
* left or right side to the target element by default.
|
|
22
|
+
* Possible values are `start` and `end`.
|
|
23
|
+
* RTL is taken into account when interpreting the value.
|
|
24
|
+
* The overlay is automatically flipped to the opposite side when it doesn't fit into
|
|
25
|
+
* the default side defined by this property.
|
|
26
|
+
*
|
|
27
|
+
* @attr {start|end} horizontal-align
|
|
28
|
+
*/
|
|
29
|
+
horizontalAlign: 'end' | 'start';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* When `positionTarget` is set, this property defines whether to align the overlay's
|
|
33
|
+
* top or bottom side to the target element by default.
|
|
34
|
+
* Possible values are `top` and `bottom`.
|
|
35
|
+
* The overlay is automatically flipped to the opposite side when it doesn't fit into
|
|
36
|
+
* the default side defined by this property.
|
|
37
|
+
*
|
|
38
|
+
* @attr {top|bottom} vertical-align
|
|
39
|
+
*/
|
|
40
|
+
verticalAlign: 'bottom' | 'top';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* When `positionTarget` is set, this property defines whether the overlay should overlap
|
|
44
|
+
* the target element in the x-axis, or be positioned right next to it.
|
|
45
|
+
*
|
|
46
|
+
* @attr {boolean} no-horizontal-overlap
|
|
47
|
+
*/
|
|
48
|
+
noHorizontalOverlap: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* When `positionTarget` is set, this property defines whether the overlay should overlap
|
|
52
|
+
* the target element in the y-axis, or be positioned right above/below it.
|
|
53
|
+
*
|
|
54
|
+
* @attr {boolean} no-vertical-overlap
|
|
55
|
+
*/
|
|
56
|
+
noVerticalOverlap: boolean;
|
|
57
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2017 -
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { getAncestorRootNodes } from '@vaadin/component-base/src/dom-utils.js';
|
|
@@ -50,6 +50,8 @@ export const PositionMixin = (superClass) =>
|
|
|
50
50
|
* RTL is taken into account when interpreting the value.
|
|
51
51
|
* The overlay is automatically flipped to the opposite side when it doesn't fit into
|
|
52
52
|
* the default side defined by this property.
|
|
53
|
+
*
|
|
54
|
+
* @attr {start|end} horizontal-align
|
|
53
55
|
*/
|
|
54
56
|
horizontalAlign: {
|
|
55
57
|
type: String,
|
|
@@ -62,6 +64,8 @@ export const PositionMixin = (superClass) =>
|
|
|
62
64
|
* Possible values are `top` and `bottom`.
|
|
63
65
|
* The overlay is automatically flipped to the opposite side when it doesn't fit into
|
|
64
66
|
* the default side defined by this property.
|
|
67
|
+
*
|
|
68
|
+
* @attr {top|bottom} vertical-align
|
|
65
69
|
*/
|
|
66
70
|
verticalAlign: {
|
|
67
71
|
type: String,
|
|
@@ -71,6 +75,8 @@ export const PositionMixin = (superClass) =>
|
|
|
71
75
|
/**
|
|
72
76
|
* When `positionTarget` is set, this property defines whether the overlay should overlap
|
|
73
77
|
* the target element in the x-axis, or be positioned right next to it.
|
|
78
|
+
*
|
|
79
|
+
* @attr {boolean} no-horizontal-overlap
|
|
74
80
|
*/
|
|
75
81
|
noHorizontalOverlap: {
|
|
76
82
|
type: Boolean,
|
|
@@ -80,6 +86,8 @@ export const PositionMixin = (superClass) =>
|
|
|
80
86
|
/**
|
|
81
87
|
* When `positionTarget` is set, this property defines whether the overlay should overlap
|
|
82
88
|
* the target element in the y-axis, or be positioned right above/below it.
|
|
89
|
+
*
|
|
90
|
+
* @attr {boolean} no-vertical-overlap
|
|
83
91
|
*/
|
|
84
92
|
noVerticalOverlap: {
|
|
85
93
|
type: Boolean,
|
|
@@ -170,10 +178,6 @@ export const PositionMixin = (superClass) =>
|
|
|
170
178
|
}
|
|
171
179
|
}
|
|
172
180
|
|
|
173
|
-
get __isRTL() {
|
|
174
|
-
return this.getAttribute('dir') === 'rtl';
|
|
175
|
-
}
|
|
176
|
-
|
|
177
181
|
__positionSettingsChanged() {
|
|
178
182
|
this._updatePosition();
|
|
179
183
|
}
|
|
@@ -197,9 +201,9 @@ export const PositionMixin = (superClass) =>
|
|
|
197
201
|
const shouldAlignStartVertically = this.__shouldAlignStartVertically(targetRect);
|
|
198
202
|
this.style.justifyContent = shouldAlignStartVertically ? 'flex-start' : 'flex-end';
|
|
199
203
|
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
|
|
204
|
+
const isRTL = this.__isRTL;
|
|
205
|
+
const shouldAlignStartHorizontally = this.__shouldAlignStartHorizontally(targetRect, isRTL);
|
|
206
|
+
const flexStart = (!isRTL && shouldAlignStartHorizontally) || (isRTL && !shouldAlignStartHorizontally);
|
|
203
207
|
this.style.alignItems = flexStart ? 'flex-start' : 'flex-end';
|
|
204
208
|
|
|
205
209
|
// Get the overlay rect after possible overlay alignment changes
|
package/src/vaadin-overlay.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2017 -
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
package/src/vaadin-overlay.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2017 -
|
|
3
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
@@ -279,6 +279,16 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
279
279
|
return ['_rendererOrDataChanged(renderer, owner, model, opened)'];
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
+
/**
|
|
283
|
+
* Returns all attached overlays in visual stacking order.
|
|
284
|
+
* @private
|
|
285
|
+
*/
|
|
286
|
+
static get __attachedInstances() {
|
|
287
|
+
return Array.from(document.body.children)
|
|
288
|
+
.filter((el) => el instanceof Overlay && !el.hasAttribute('closing'))
|
|
289
|
+
.sort((a, b) => a.__zIndex - b.__zIndex || 0);
|
|
290
|
+
}
|
|
291
|
+
|
|
282
292
|
constructor() {
|
|
283
293
|
super();
|
|
284
294
|
this._boundMouseDownListener = this._mouseDownListener.bind(this);
|
|
@@ -294,6 +304,15 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
294
304
|
this.__focusTrapController = new FocusTrapController(this);
|
|
295
305
|
}
|
|
296
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Returns true if this is the last one in the opened overlays stack
|
|
309
|
+
* @return {boolean}
|
|
310
|
+
* @protected
|
|
311
|
+
*/
|
|
312
|
+
get _last() {
|
|
313
|
+
return this === Overlay.__attachedInstances.pop();
|
|
314
|
+
}
|
|
315
|
+
|
|
297
316
|
/** @protected */
|
|
298
317
|
ready() {
|
|
299
318
|
super.ready();
|
|
@@ -633,25 +652,6 @@ class Overlay extends ThemableMixin(DirMixin(ControllerMixin(PolymerElement))) {
|
|
|
633
652
|
this._placeholder.parentNode.removeChild(this._placeholder);
|
|
634
653
|
}
|
|
635
654
|
|
|
636
|
-
/**
|
|
637
|
-
* Returns all attached overlays in visual stacking order.
|
|
638
|
-
* @private
|
|
639
|
-
*/
|
|
640
|
-
static get __attachedInstances() {
|
|
641
|
-
return Array.from(document.body.children)
|
|
642
|
-
.filter((el) => el instanceof Overlay && !el.hasAttribute('closing'))
|
|
643
|
-
.sort((a, b) => a.__zIndex - b.__zIndex || 0);
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
/**
|
|
647
|
-
* Returns true if this is the last one in the opened overlays stack
|
|
648
|
-
* @return {boolean}
|
|
649
|
-
* @protected
|
|
650
|
-
*/
|
|
651
|
-
get _last() {
|
|
652
|
-
return this === Overlay.__attachedInstances.pop();
|
|
653
|
-
}
|
|
654
|
-
|
|
655
655
|
/** @private */
|
|
656
656
|
_modelessChanged(modeless) {
|
|
657
657
|
if (!modeless) {
|