@vaadin/dialog 25.1.0-alpha9 → 25.1.0-beta1
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/custom-elements.json +74 -42
- package/package.json +11 -11
- package/src/styles/vaadin-dialog-overlay-base-styles.js +4 -1
- package/src/vaadin-dialog-base-mixin.d.ts +10 -0
- package/src/vaadin-dialog-base-mixin.js +15 -0
- package/src/vaadin-dialog-draggable-mixin.d.ts +0 -8
- package/src/vaadin-dialog-draggable-mixin.js +7 -22
- package/src/vaadin-dialog-overlay-mixin.d.ts +5 -0
- package/src/vaadin-dialog-overlay-mixin.js +73 -0
- package/src/vaadin-dialog.js +1 -0
- package/web-types.json +3 -3
- package/web-types.lit.json +2 -2
package/custom-elements.json
CHANGED
|
@@ -26,6 +26,16 @@
|
|
|
26
26
|
"description": "",
|
|
27
27
|
"name": "DialogBaseMixin",
|
|
28
28
|
"members": [
|
|
29
|
+
{
|
|
30
|
+
"kind": "field",
|
|
31
|
+
"name": "keepInViewport",
|
|
32
|
+
"privacy": "public",
|
|
33
|
+
"type": {
|
|
34
|
+
"text": "boolean"
|
|
35
|
+
},
|
|
36
|
+
"description": "Set to true to prevent the dialog from moving outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible, for example\nwhen dragging the dialog or when the viewport is resized. Note that the\ndialog will also adjust any programmatically configured size and position\nso that it stays within the viewport.",
|
|
37
|
+
"attribute": "keep-in-viewport"
|
|
38
|
+
},
|
|
29
39
|
{
|
|
30
40
|
"kind": "field",
|
|
31
41
|
"name": "left",
|
|
@@ -117,6 +127,14 @@
|
|
|
117
127
|
}
|
|
118
128
|
],
|
|
119
129
|
"attributes": [
|
|
130
|
+
{
|
|
131
|
+
"name": "keep-in-viewport",
|
|
132
|
+
"type": {
|
|
133
|
+
"text": "boolean"
|
|
134
|
+
},
|
|
135
|
+
"description": "Set to true to prevent the dialog from moving outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible, for example\nwhen dragging the dialog or when the viewport is resized. Note that the\ndialog will also adjust any programmatically configured size and position\nso that it stays within the viewport.",
|
|
136
|
+
"fieldName": "keepInViewport"
|
|
137
|
+
},
|
|
120
138
|
{
|
|
121
139
|
"name": "left",
|
|
122
140
|
"type": {
|
|
@@ -219,16 +237,6 @@
|
|
|
219
237
|
},
|
|
220
238
|
"description": "Set to true to enable repositioning the dialog by clicking and dragging.\n\nBy default, only the overlay area can be used to drag the element. But,\na child element can be marked as a draggable area by adding a\n\"`draggable`\" class to it, this will by default make all of its children draggable also.\nIf you want a child element to be draggable\nbut still have its children non-draggable (by default), mark it with\n\"`draggable-leaf-only`\" class name.",
|
|
221
239
|
"attribute": "draggable"
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
"kind": "field",
|
|
225
|
-
"name": "keepInViewport",
|
|
226
|
-
"privacy": "public",
|
|
227
|
-
"type": {
|
|
228
|
-
"text": "boolean"
|
|
229
|
-
},
|
|
230
|
-
"description": "Set to true to prevent dragging the dialog outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible during dragging.\nThe dialog may still become partially hidden when the viewport is resized.",
|
|
231
|
-
"attribute": "keep-in-viewport"
|
|
232
240
|
}
|
|
233
241
|
],
|
|
234
242
|
"events": [
|
|
@@ -253,14 +261,6 @@
|
|
|
253
261
|
},
|
|
254
262
|
"description": "Set to true to enable repositioning the dialog by clicking and dragging.\n\nBy default, only the overlay area can be used to drag the element. But,\na child element can be marked as a draggable area by adding a\n\"`draggable`\" class to it, this will by default make all of its children draggable also.\nIf you want a child element to be draggable\nbut still have its children non-draggable (by default), mark it with\n\"`draggable-leaf-only`\" class name.",
|
|
255
263
|
"fieldName": "draggable"
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
"name": "keep-in-viewport",
|
|
259
|
-
"type": {
|
|
260
|
-
"text": "boolean"
|
|
261
|
-
},
|
|
262
|
-
"description": "Set to true to prevent dragging the dialog outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible during dragging.\nThe dialog may still become partially hidden when the viewport is resized.",
|
|
263
|
-
"fieldName": "keepInViewport"
|
|
264
264
|
}
|
|
265
265
|
],
|
|
266
266
|
"parameters": [
|
|
@@ -383,6 +383,16 @@
|
|
|
383
383
|
"package": "@vaadin/overlay/src/vaadin-overlay-mixin.js"
|
|
384
384
|
}
|
|
385
385
|
},
|
|
386
|
+
{
|
|
387
|
+
"kind": "field",
|
|
388
|
+
"name": "keepInViewport",
|
|
389
|
+
"privacy": "public",
|
|
390
|
+
"type": {
|
|
391
|
+
"text": "boolean"
|
|
392
|
+
},
|
|
393
|
+
"description": "Whether to keep the overlay within the viewport.",
|
|
394
|
+
"attribute": "keep-in-viewport"
|
|
395
|
+
},
|
|
386
396
|
{
|
|
387
397
|
"kind": "field",
|
|
388
398
|
"name": "model",
|
|
@@ -495,20 +505,14 @@
|
|
|
495
505
|
"name": "setBounds",
|
|
496
506
|
"parameters": [
|
|
497
507
|
{
|
|
498
|
-
"name": "bounds"
|
|
499
|
-
"type": {
|
|
500
|
-
"text": "!OverlayBoundsParam"
|
|
501
|
-
}
|
|
508
|
+
"name": "bounds"
|
|
502
509
|
},
|
|
503
510
|
{
|
|
504
511
|
"name": "absolute",
|
|
505
|
-
"default": "true"
|
|
506
|
-
"type": {
|
|
507
|
-
"text": "boolean"
|
|
508
|
-
}
|
|
512
|
+
"default": "true"
|
|
509
513
|
}
|
|
510
514
|
],
|
|
511
|
-
"description": "
|
|
515
|
+
"description": "Override method from OverlayMixin to adjust the position of the overlay if `keepInViewport` is true.",
|
|
512
516
|
"inheritedFrom": {
|
|
513
517
|
"name": "OverlayMixin",
|
|
514
518
|
"package": "@vaadin/overlay/src/vaadin-overlay-mixin.js"
|
|
@@ -562,6 +566,14 @@
|
|
|
562
566
|
"package": "@vaadin/overlay/src/vaadin-overlay-mixin.js"
|
|
563
567
|
}
|
|
564
568
|
},
|
|
569
|
+
{
|
|
570
|
+
"name": "keep-in-viewport",
|
|
571
|
+
"type": {
|
|
572
|
+
"text": "boolean"
|
|
573
|
+
},
|
|
574
|
+
"description": "Whether to keep the overlay within the viewport.",
|
|
575
|
+
"fieldName": "keepInViewport"
|
|
576
|
+
},
|
|
565
577
|
{
|
|
566
578
|
"name": "modeless",
|
|
567
579
|
"type": {
|
|
@@ -811,6 +823,20 @@
|
|
|
811
823
|
"package": "@vaadin/overlay/src/vaadin-overlay-mixin.js"
|
|
812
824
|
}
|
|
813
825
|
},
|
|
826
|
+
{
|
|
827
|
+
"kind": "field",
|
|
828
|
+
"name": "keepInViewport",
|
|
829
|
+
"privacy": "public",
|
|
830
|
+
"type": {
|
|
831
|
+
"text": "boolean"
|
|
832
|
+
},
|
|
833
|
+
"description": "Whether to keep the overlay within the viewport.",
|
|
834
|
+
"attribute": "keep-in-viewport",
|
|
835
|
+
"inheritedFrom": {
|
|
836
|
+
"name": "DialogOverlayMixin",
|
|
837
|
+
"module": "src/vaadin-dialog-overlay-mixin.js"
|
|
838
|
+
}
|
|
839
|
+
},
|
|
814
840
|
{
|
|
815
841
|
"kind": "field",
|
|
816
842
|
"name": "model",
|
|
@@ -923,20 +949,14 @@
|
|
|
923
949
|
"name": "setBounds",
|
|
924
950
|
"parameters": [
|
|
925
951
|
{
|
|
926
|
-
"name": "bounds"
|
|
927
|
-
"type": {
|
|
928
|
-
"text": "!OverlayBoundsParam"
|
|
929
|
-
}
|
|
952
|
+
"name": "bounds"
|
|
930
953
|
},
|
|
931
954
|
{
|
|
932
955
|
"name": "absolute",
|
|
933
|
-
"default": "true"
|
|
934
|
-
"type": {
|
|
935
|
-
"text": "boolean"
|
|
936
|
-
}
|
|
956
|
+
"default": "true"
|
|
937
957
|
}
|
|
938
958
|
],
|
|
939
|
-
"description": "
|
|
959
|
+
"description": "Override method from OverlayMixin to adjust the position of the overlay if `keepInViewport` is true.",
|
|
940
960
|
"inheritedFrom": {
|
|
941
961
|
"name": "OverlayMixin",
|
|
942
962
|
"package": "@vaadin/overlay/src/vaadin-overlay-mixin.js"
|
|
@@ -1022,6 +1042,18 @@
|
|
|
1022
1042
|
"package": "@vaadin/overlay/src/vaadin-overlay-mixin.js"
|
|
1023
1043
|
}
|
|
1024
1044
|
},
|
|
1045
|
+
{
|
|
1046
|
+
"name": "keep-in-viewport",
|
|
1047
|
+
"type": {
|
|
1048
|
+
"text": "boolean"
|
|
1049
|
+
},
|
|
1050
|
+
"description": "Whether to keep the overlay within the viewport.",
|
|
1051
|
+
"fieldName": "keepInViewport",
|
|
1052
|
+
"inheritedFrom": {
|
|
1053
|
+
"name": "DialogOverlayMixin",
|
|
1054
|
+
"module": "src/vaadin-dialog-overlay-mixin.js"
|
|
1055
|
+
}
|
|
1056
|
+
},
|
|
1025
1057
|
{
|
|
1026
1058
|
"name": "modeless",
|
|
1027
1059
|
"type": {
|
|
@@ -1516,11 +1548,11 @@
|
|
|
1516
1548
|
"type": {
|
|
1517
1549
|
"text": "boolean"
|
|
1518
1550
|
},
|
|
1519
|
-
"description": "Set to true to prevent
|
|
1551
|
+
"description": "Set to true to prevent the dialog from moving outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible, for example\nwhen dragging the dialog or when the viewport is resized. Note that the\ndialog will also adjust any programmatically configured size and position\nso that it stays within the viewport.",
|
|
1520
1552
|
"attribute": "keep-in-viewport",
|
|
1521
1553
|
"inheritedFrom": {
|
|
1522
|
-
"name": "
|
|
1523
|
-
"module": "src/vaadin-dialog-
|
|
1554
|
+
"name": "DialogBaseMixin",
|
|
1555
|
+
"module": "src/vaadin-dialog-base-mixin.js"
|
|
1524
1556
|
}
|
|
1525
1557
|
},
|
|
1526
1558
|
{
|
|
@@ -1855,11 +1887,11 @@
|
|
|
1855
1887
|
"type": {
|
|
1856
1888
|
"text": "boolean"
|
|
1857
1889
|
},
|
|
1858
|
-
"description": "Set to true to prevent
|
|
1890
|
+
"description": "Set to true to prevent the dialog from moving outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible, for example\nwhen dragging the dialog or when the viewport is resized. Note that the\ndialog will also adjust any programmatically configured size and position\nso that it stays within the viewport.",
|
|
1859
1891
|
"fieldName": "keepInViewport",
|
|
1860
1892
|
"inheritedFrom": {
|
|
1861
|
-
"name": "
|
|
1862
|
-
"module": "src/vaadin-dialog-
|
|
1893
|
+
"name": "DialogBaseMixin",
|
|
1894
|
+
"module": "src/vaadin-dialog-base-mixin.js"
|
|
1863
1895
|
}
|
|
1864
1896
|
},
|
|
1865
1897
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/dialog",
|
|
3
|
-
"version": "25.1.0-
|
|
3
|
+
"version": "25.1.0-beta1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -37,19 +37,19 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/component-base": "25.1.0-
|
|
41
|
-
"@vaadin/lit-renderer": "25.1.0-
|
|
42
|
-
"@vaadin/overlay": "25.1.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "25.1.0-
|
|
40
|
+
"@vaadin/component-base": "25.1.0-beta1",
|
|
41
|
+
"@vaadin/lit-renderer": "25.1.0-beta1",
|
|
42
|
+
"@vaadin/overlay": "25.1.0-beta1",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "25.1.0-beta1",
|
|
44
44
|
"lit": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@vaadin/a11y-base": "25.1.0-
|
|
48
|
-
"@vaadin/aura": "25.1.0-
|
|
49
|
-
"@vaadin/chai-plugins": "25.1.0-
|
|
50
|
-
"@vaadin/test-runner-commands": "25.1.0-
|
|
47
|
+
"@vaadin/a11y-base": "25.1.0-beta1",
|
|
48
|
+
"@vaadin/aura": "25.1.0-beta1",
|
|
49
|
+
"@vaadin/chai-plugins": "25.1.0-beta1",
|
|
50
|
+
"@vaadin/test-runner-commands": "25.1.0-beta1",
|
|
51
51
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
52
|
-
"@vaadin/vaadin-lumo-styles": "25.1.0-
|
|
52
|
+
"@vaadin/vaadin-lumo-styles": "25.1.0-beta1",
|
|
53
53
|
"sinon": "^21.0.0"
|
|
54
54
|
},
|
|
55
55
|
"customElements": "custom-elements.json",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"web-types.json",
|
|
58
58
|
"web-types.lit.json"
|
|
59
59
|
],
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "0ccf77c385fc6a92ac2a6344ce8804b94956226d"
|
|
61
61
|
}
|
|
@@ -124,6 +124,9 @@ const dialogResizableOverlay = css`
|
|
|
124
124
|
|
|
125
125
|
:host([has-bounds-set]) [part='overlay'] {
|
|
126
126
|
min-width: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:host([has-bounds-set]:not([keep-in-viewport])) [part='overlay'] {
|
|
127
130
|
max-width: none;
|
|
128
131
|
max-height: none;
|
|
129
132
|
}
|
|
@@ -138,7 +141,7 @@ const dialogResizableOverlay = css`
|
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
[part='header'],
|
|
141
|
-
:host(:not([has-header])) [part='content'] {
|
|
144
|
+
:host(:not([has-title], [has-header])) [part='content'] {
|
|
142
145
|
border-top-left-radius: inherit;
|
|
143
146
|
border-top-right-radius: inherit;
|
|
144
147
|
}
|
|
@@ -63,4 +63,14 @@ export declare class DialogBaseMixinClass {
|
|
|
63
63
|
* additional spacing, which can be overridden by the theme.
|
|
64
64
|
*/
|
|
65
65
|
left: string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Set to true to prevent the dialog from moving outside the viewport bounds.
|
|
69
|
+
* When enabled, all four edges of the dialog will remain visible, for example
|
|
70
|
+
* when dragging the dialog or when the viewport is resized. Note that the
|
|
71
|
+
* dialog will also adjust any programmatically configured size and position
|
|
72
|
+
* so that it stays within the viewport.
|
|
73
|
+
* @attr {boolean} keep-in-viewport
|
|
74
|
+
*/
|
|
75
|
+
keepInViewport: boolean;
|
|
66
76
|
}
|
|
@@ -93,6 +93,21 @@ export const DialogBaseMixin = (superClass) =>
|
|
|
93
93
|
overlayRole: {
|
|
94
94
|
type: String,
|
|
95
95
|
},
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Set to true to prevent the dialog from moving outside the viewport bounds.
|
|
99
|
+
* When enabled, all four edges of the dialog will remain visible, for example
|
|
100
|
+
* when dragging the dialog or when the viewport is resized. Note that the
|
|
101
|
+
* dialog will also adjust any programmatically configured size and position
|
|
102
|
+
* so that it stays within the viewport.
|
|
103
|
+
* @attr {boolean} keep-in-viewport
|
|
104
|
+
* @type {boolean}
|
|
105
|
+
*/
|
|
106
|
+
keepInViewport: {
|
|
107
|
+
type: Boolean,
|
|
108
|
+
value: false,
|
|
109
|
+
reflectToAttribute: true,
|
|
110
|
+
},
|
|
96
111
|
};
|
|
97
112
|
}
|
|
98
113
|
|
|
@@ -21,12 +21,4 @@ export declare class DialogDraggableMixinClass {
|
|
|
21
21
|
* "`draggable-leaf-only`" class name.
|
|
22
22
|
*/
|
|
23
23
|
draggable: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Set to true to prevent dragging the dialog outside the viewport bounds.
|
|
27
|
-
* When enabled, all four edges of the dialog will remain visible during dragging.
|
|
28
|
-
* The dialog may still become partially hidden when the viewport is resized.
|
|
29
|
-
* @attr {boolean} keep-in-viewport
|
|
30
|
-
*/
|
|
31
|
-
keepInViewport: boolean;
|
|
32
24
|
}
|
|
@@ -31,19 +31,6 @@ export const DialogDraggableMixin = (superClass) =>
|
|
|
31
31
|
reflectToAttribute: true,
|
|
32
32
|
},
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Set to true to prevent dragging the dialog outside the viewport bounds.
|
|
36
|
-
* When enabled, all four edges of the dialog will remain visible during dragging.
|
|
37
|
-
* The dialog may still become partially hidden when the viewport is resized.
|
|
38
|
-
* @attr {boolean} keep-in-viewport
|
|
39
|
-
* @type {boolean}
|
|
40
|
-
*/
|
|
41
|
-
keepInViewport: {
|
|
42
|
-
type: Boolean,
|
|
43
|
-
value: false,
|
|
44
|
-
reflectToAttribute: true,
|
|
45
|
-
},
|
|
46
|
-
|
|
47
34
|
/** @private */
|
|
48
35
|
_touchDevice: {
|
|
49
36
|
type: Boolean,
|
|
@@ -132,16 +119,14 @@ export const DialogDraggableMixin = (superClass) =>
|
|
|
132
119
|
let left = this._originalBounds.left + (event.pageX - this._originalMouseCoords.left);
|
|
133
120
|
|
|
134
121
|
if (this.keepInViewport) {
|
|
122
|
+
// Constrain the dialog position so that it stays within the overlay host bounds,
|
|
123
|
+
// respecting the `--vaadin-overlay-viewport-inset` (offset from the viewport edges).
|
|
135
124
|
const { width, height } = this._originalBounds;
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const minTop = -containerBounds.top;
|
|
142
|
-
const maxTop = window.innerHeight - containerBounds.top - height;
|
|
143
|
-
left = Math.max(minLeft, Math.min(left, maxLeft));
|
|
144
|
-
top = Math.max(minTop, Math.min(top, maxTop));
|
|
125
|
+
const overlayHostBounds = this.$.overlay.getBoundingClientRect();
|
|
126
|
+
const maxLeft = overlayHostBounds.right - overlayHostBounds.left - width;
|
|
127
|
+
const maxTop = overlayHostBounds.bottom - overlayHostBounds.top - height;
|
|
128
|
+
left = Math.max(0, Math.min(left, maxLeft));
|
|
129
|
+
top = Math.max(0, Math.min(top, maxTop));
|
|
145
130
|
}
|
|
146
131
|
|
|
147
132
|
this.top = top;
|
|
@@ -35,6 +35,14 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
35
35
|
footerRenderer: {
|
|
36
36
|
type: Object,
|
|
37
37
|
},
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether to keep the overlay within the viewport.
|
|
41
|
+
*/
|
|
42
|
+
keepInViewport: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
reflectToAttribute: true,
|
|
45
|
+
},
|
|
38
46
|
};
|
|
39
47
|
}
|
|
40
48
|
|
|
@@ -77,6 +85,7 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
77
85
|
// Update overflow attribute on resize
|
|
78
86
|
this.__resizeObserver = new ResizeObserver(() => {
|
|
79
87
|
requestAnimationFrame(() => {
|
|
88
|
+
this.__adjustPosition();
|
|
80
89
|
this.__updateOverflow();
|
|
81
90
|
});
|
|
82
91
|
});
|
|
@@ -104,6 +113,20 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
104
113
|
setOverlayStateAttribute(this, 'has-footer', currentNodes.length > 0);
|
|
105
114
|
this.__updateOverflow();
|
|
106
115
|
});
|
|
116
|
+
|
|
117
|
+
this.__handleWindowResize = this.__handleWindowResize.bind(this);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
updated(props) {
|
|
121
|
+
super.updated(props);
|
|
122
|
+
|
|
123
|
+
if (props.has('opened') || props.has('keepInViewport')) {
|
|
124
|
+
if (this.opened && this.keepInViewport) {
|
|
125
|
+
window.addEventListener('resize', this.__handleWindowResize);
|
|
126
|
+
} else {
|
|
127
|
+
window.removeEventListener('resize', this.__handleWindowResize);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
107
130
|
}
|
|
108
131
|
|
|
109
132
|
/** @private */
|
|
@@ -233,6 +256,15 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
233
256
|
return { top, left, width, height };
|
|
234
257
|
}
|
|
235
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Override method from OverlayMixin to adjust the position of the overlay if `keepInViewport` is true.
|
|
261
|
+
* @override
|
|
262
|
+
*/
|
|
263
|
+
setBounds(bounds, absolute = true) {
|
|
264
|
+
super.setBounds(bounds, absolute);
|
|
265
|
+
this.__adjustPosition();
|
|
266
|
+
}
|
|
267
|
+
|
|
236
268
|
/** @private */
|
|
237
269
|
__updateOverflow() {
|
|
238
270
|
let overflow = '';
|
|
@@ -254,4 +286,45 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
254
286
|
setOverlayStateAttribute(this, 'overflow', null);
|
|
255
287
|
}
|
|
256
288
|
}
|
|
289
|
+
|
|
290
|
+
/** @private */
|
|
291
|
+
__handleWindowResize() {
|
|
292
|
+
this.__adjustPosition();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Adjusts the position of the overlay to keep it within the viewport if `keepInViewport` is true.
|
|
297
|
+
* @private
|
|
298
|
+
*/
|
|
299
|
+
__adjustPosition() {
|
|
300
|
+
if (!this.opened || !this.keepInViewport) {
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Centered dialogs do not use absolute positioning and automatically adjust their position / size to fit the viewport
|
|
305
|
+
const style = getComputedStyle(this.$.overlay);
|
|
306
|
+
if (style.position !== 'absolute') {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const overlayHostBounds = this.getBoundingClientRect();
|
|
311
|
+
const bounds = this.getBounds();
|
|
312
|
+
// Prefer dimensions from getComputedStyle, as bounding rect is affected
|
|
313
|
+
// by scale transform applied by opening animation in Lumo
|
|
314
|
+
const width = parseFloat(style.width) || bounds.width;
|
|
315
|
+
const height = parseFloat(style.height) || bounds.height;
|
|
316
|
+
|
|
317
|
+
const maxLeft = overlayHostBounds.right - overlayHostBounds.left - width;
|
|
318
|
+
const maxTop = overlayHostBounds.bottom - overlayHostBounds.top - height;
|
|
319
|
+
|
|
320
|
+
if (bounds.left > maxLeft || bounds.top > maxTop) {
|
|
321
|
+
const left = Math.max(0, Math.min(bounds.left, maxLeft));
|
|
322
|
+
const top = Math.max(0, Math.min(bounds.top, maxTop));
|
|
323
|
+
|
|
324
|
+
Object.assign(this.$.overlay.style, {
|
|
325
|
+
left: `${left}px`,
|
|
326
|
+
top: `${top}px`,
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
257
330
|
};
|
package/src/vaadin-dialog.js
CHANGED
|
@@ -148,6 +148,7 @@ class Dialog extends DialogSizeMixin(
|
|
|
148
148
|
.renderer="${this.renderer}"
|
|
149
149
|
.headerRenderer="${this.headerRenderer}"
|
|
150
150
|
.footerRenderer="${this.footerRenderer}"
|
|
151
|
+
.keepInViewport="${this.keepInViewport}"
|
|
151
152
|
@opened-changed="${this._onOverlayOpened}"
|
|
152
153
|
@mousedown="${this._bringOverlayToFront}"
|
|
153
154
|
@touchstart="${this._bringOverlayToFront}"
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/dialog",
|
|
4
|
-
"version": "25.1.0-
|
|
4
|
+
"version": "25.1.0-beta1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"name": "keep-in-viewport",
|
|
46
|
-
"description": "Set to true to prevent
|
|
46
|
+
"description": "Set to true to prevent the dialog from moving outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible, for example\nwhen dragging the dialog or when the viewport is resized. Note that the\ndialog will also adjust any programmatically configured size and position\nso that it stays within the viewport.",
|
|
47
47
|
"value": {
|
|
48
48
|
"type": [
|
|
49
49
|
"boolean"
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
"name": "keepInViewport",
|
|
218
|
-
"description": "Set to true to prevent
|
|
218
|
+
"description": "Set to true to prevent the dialog from moving outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible, for example\nwhen dragging the dialog or when the viewport is resized. Note that the\ndialog will also adjust any programmatically configured size and position\nso that it stays within the viewport.",
|
|
219
219
|
"value": {
|
|
220
220
|
"type": [
|
|
221
221
|
"boolean"
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/dialog",
|
|
4
|
-
"version": "25.1.0-
|
|
4
|
+
"version": "25.1.0-beta1",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"name": "?keepInViewport",
|
|
31
|
-
"description": "Set to true to prevent
|
|
31
|
+
"description": "Set to true to prevent the dialog from moving outside the viewport bounds.\nWhen enabled, all four edges of the dialog will remain visible, for example\nwhen dragging the dialog or when the viewport is resized. Note that the\ndialog will also adjust any programmatically configured size and position\nso that it stays within the viewport.",
|
|
32
32
|
"value": {
|
|
33
33
|
"kind": "expression"
|
|
34
34
|
}
|