@vaadin/dialog 25.0.0-alpha2 → 25.0.0-alpha21
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 +11 -12
- package/src/lit/renderer-directives.d.ts +0 -1
- package/src/{vaadin-dialog-styles.d.ts → styles/vaadin-dialog-overlay-base-styles.d.ts} +3 -3
- package/src/styles/vaadin-dialog-overlay-base-styles.js +215 -0
- package/src/vaadin-dialog-base-mixin.d.ts +9 -22
- package/src/vaadin-dialog-base-mixin.js +34 -28
- package/src/vaadin-dialog-draggable-mixin.js +2 -1
- package/src/vaadin-dialog-overlay-mixin.d.ts +0 -14
- package/src/vaadin-dialog-overlay-mixin.js +32 -41
- package/src/vaadin-dialog-overlay.d.ts +1 -1
- package/src/vaadin-dialog-overlay.js +16 -5
- package/src/vaadin-dialog-renderer-mixin.d.ts +3 -3
- package/src/vaadin-dialog-renderer-mixin.js +3 -3
- package/src/vaadin-dialog-resizable-mixin.js +2 -14
- package/src/vaadin-dialog-size-mixin.d.ts +24 -0
- package/src/vaadin-dialog-size-mixin.js +40 -0
- package/src/vaadin-dialog.d.ts +9 -24
- package/src/vaadin-dialog.js +41 -33
- package/vaadin-dialog.js +1 -1
- package/web-types.json +22 -66
- package/web-types.lit.json +13 -27
- package/src/vaadin-dialog-styles.js +0 -181
- package/theme/lumo/vaadin-dialog-styles.d.ts +0 -3
- package/theme/lumo/vaadin-dialog-styles.js +0 -109
- package/theme/lumo/vaadin-dialog.d.ts +0 -2
- package/theme/lumo/vaadin-dialog.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/dialog",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha21",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"lit.d.ts",
|
|
24
24
|
"lit.js",
|
|
25
25
|
"src",
|
|
26
|
-
"theme",
|
|
27
26
|
"vaadin-*.d.ts",
|
|
28
27
|
"vaadin-*.js",
|
|
29
28
|
"web-types.json",
|
|
@@ -37,23 +36,23 @@
|
|
|
37
36
|
],
|
|
38
37
|
"dependencies": {
|
|
39
38
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
|
-
"@vaadin/component-base": "25.0.0-
|
|
41
|
-
"@vaadin/lit-renderer": "25.0.0-
|
|
42
|
-
"@vaadin/overlay": "25.0.0-
|
|
43
|
-
"@vaadin/vaadin-
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha2",
|
|
39
|
+
"@vaadin/component-base": "25.0.0-alpha21",
|
|
40
|
+
"@vaadin/lit-renderer": "25.0.0-alpha21",
|
|
41
|
+
"@vaadin/overlay": "25.0.0-alpha21",
|
|
42
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha21",
|
|
45
43
|
"lit": "^3.0.0"
|
|
46
44
|
},
|
|
47
45
|
"devDependencies": {
|
|
48
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
49
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
50
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
46
|
+
"@vaadin/a11y-base": "25.0.0-alpha21",
|
|
47
|
+
"@vaadin/chai-plugins": "25.0.0-alpha21",
|
|
48
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha21",
|
|
51
49
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
52
|
-
"
|
|
50
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha21",
|
|
51
|
+
"sinon": "^21.0.0"
|
|
53
52
|
},
|
|
54
53
|
"web-types": [
|
|
55
54
|
"web-types.json",
|
|
56
55
|
"web-types.lit.json"
|
|
57
56
|
],
|
|
58
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "8fb9e9710c01449edf623a1aaac4655cdc11a933"
|
|
59
58
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
/* eslint-disable max-classes-per-file */
|
|
7
6
|
import type { DirectiveResult } from 'lit/directive.js';
|
|
8
7
|
import type { LitRendererResult } from '@vaadin/lit-renderer';
|
|
9
8
|
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2017 - 2025 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 type { CSSResult } from 'lit';
|
|
7
7
|
|
|
8
|
-
export const
|
|
8
|
+
export const dialogOverlayBase: CSSResult;
|
|
9
9
|
|
|
10
|
-
export const
|
|
10
|
+
export const dialogOverlayStyles: CSSResult;
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import '@vaadin/component-base/src/styles/style-props.js';
|
|
7
|
+
import { css } from 'lit';
|
|
8
|
+
import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-base-styles.js';
|
|
9
|
+
|
|
10
|
+
export const dialogOverlayBase = css`
|
|
11
|
+
/* Optical centering */
|
|
12
|
+
:host::before,
|
|
13
|
+
:host::after {
|
|
14
|
+
content: '';
|
|
15
|
+
flex-basis: 0;
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host::after {
|
|
20
|
+
flex-grow: 1.1;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host {
|
|
24
|
+
cursor: default;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[part='overlay']:focus-visible {
|
|
28
|
+
outline: var(--vaadin-focus-ring-width) solid var(--vaadin-focus-ring-color);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[part='overlay'] {
|
|
32
|
+
background: var(--vaadin-dialog-background, var(--vaadin-overlay-background, var(--vaadin-background-color)));
|
|
33
|
+
background-origin: border-box;
|
|
34
|
+
border: var(--vaadin-dialog-border-width, var(--vaadin-overlay-border-width, 1px)) solid
|
|
35
|
+
var(--vaadin-dialog-border-color, var(--vaadin-overlay-border-color, var(--vaadin-border-color-secondary)));
|
|
36
|
+
box-shadow: var(--vaadin-dialog-shadow, var(--vaadin-overlay-shadow, 0 8px 24px -4px rgba(0, 0, 0, 0.3)));
|
|
37
|
+
border-radius: var(--vaadin-dialog-border-radius, var(--vaadin-radius-l));
|
|
38
|
+
width: max-content;
|
|
39
|
+
min-width: min(var(--vaadin-dialog-min-width, 4em), 100%);
|
|
40
|
+
max-width: min(var(--vaadin-dialog-max-width, 100%), 100%);
|
|
41
|
+
max-height: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
[part='header'],
|
|
45
|
+
[part='header-content'],
|
|
46
|
+
[part='footer'] {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
flex-wrap: wrap;
|
|
50
|
+
flex: none;
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
z-index: 1;
|
|
53
|
+
gap: var(--vaadin-dialog-toolbar-gap, var(--vaadin-gap-s));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
::slotted(*) {
|
|
57
|
+
pointer-events: auto;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[part='header'],
|
|
61
|
+
[part='content'],
|
|
62
|
+
[part='footer'] {
|
|
63
|
+
padding: var(--vaadin-dialog-padding, var(--vaadin-padding-l));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
:host([theme~='no-padding']) [part='content'] {
|
|
67
|
+
padding: 0 !important;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:host(:is([has-header], [has-title])) [part='content'] {
|
|
71
|
+
padding-top: 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:host([has-footer]) [part='content'] {
|
|
75
|
+
padding-bottom: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[part='header'] {
|
|
79
|
+
flex-wrap: nowrap;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
::slotted([slot='header-content']),
|
|
83
|
+
::slotted([slot='title']),
|
|
84
|
+
::slotted([slot='footer']) {
|
|
85
|
+
display: contents;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
::slotted([slot='title']) {
|
|
89
|
+
font: inherit !important;
|
|
90
|
+
color: inherit !important;
|
|
91
|
+
overflow-wrap: anywhere;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[part='title'] {
|
|
95
|
+
color: var(--vaadin-dialog-title-color, var(--vaadin-text-color));
|
|
96
|
+
font-weight: var(--vaadin-dialog-title-font-weight, 600);
|
|
97
|
+
font-size: var(--vaadin-dialog-title-font-size, 1em);
|
|
98
|
+
line-height: var(--vaadin-dialog-title-line-height, inherit);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[part='header-content'] {
|
|
102
|
+
flex: 1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
:host([has-title]) [part='header-content'],
|
|
106
|
+
[part='footer'] {
|
|
107
|
+
justify-content: flex-end;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:host(:not([has-title]):not([has-header])) [part='header'],
|
|
111
|
+
:host(:not([has-header])) [part='header-content'],
|
|
112
|
+
:host(:not([has-title])) [part='title'],
|
|
113
|
+
:host(:not([has-footer])) [part='footer'] {
|
|
114
|
+
display: none !important;
|
|
115
|
+
}
|
|
116
|
+
`;
|
|
117
|
+
|
|
118
|
+
const dialogResizableOverlay = css`
|
|
119
|
+
[part='overlay'] {
|
|
120
|
+
position: relative;
|
|
121
|
+
overflow: visible;
|
|
122
|
+
display: flex;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:host([has-bounds-set]) [part='overlay'] {
|
|
126
|
+
min-width: 0;
|
|
127
|
+
max-width: none;
|
|
128
|
+
max-height: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* Content part scrolls by default */
|
|
132
|
+
[part='content'] {
|
|
133
|
+
flex: 1;
|
|
134
|
+
min-height: 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
:host([overflow]) [part='content'] {
|
|
138
|
+
overflow: auto;
|
|
139
|
+
overscroll-behavior: contain;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.resizer-container {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
flex-grow: 1;
|
|
146
|
+
border-radius: inherit;
|
|
147
|
+
max-width: 100%;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
:host(:not([resizable])) .resizer {
|
|
151
|
+
display: none;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.resizer {
|
|
155
|
+
position: absolute;
|
|
156
|
+
height: 16px;
|
|
157
|
+
width: 16px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.resizer.edge {
|
|
161
|
+
height: 8px;
|
|
162
|
+
width: 8px;
|
|
163
|
+
inset: -4px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.resizer.edge.n {
|
|
167
|
+
width: auto;
|
|
168
|
+
bottom: auto;
|
|
169
|
+
cursor: ns-resize;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.resizer.ne {
|
|
173
|
+
top: -4px;
|
|
174
|
+
right: -4px;
|
|
175
|
+
cursor: nesw-resize;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.resizer.edge.e {
|
|
179
|
+
height: auto;
|
|
180
|
+
left: auto;
|
|
181
|
+
cursor: ew-resize;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.resizer.se {
|
|
185
|
+
bottom: -4px;
|
|
186
|
+
right: -4px;
|
|
187
|
+
cursor: nwse-resize;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.resizer.edge.s {
|
|
191
|
+
width: auto;
|
|
192
|
+
top: auto;
|
|
193
|
+
cursor: ns-resize;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.resizer.sw {
|
|
197
|
+
bottom: -4px;
|
|
198
|
+
left: -4px;
|
|
199
|
+
cursor: nesw-resize;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.resizer.edge.w {
|
|
203
|
+
height: auto;
|
|
204
|
+
right: auto;
|
|
205
|
+
cursor: ew-resize;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.resizer.nw {
|
|
209
|
+
top: -4px;
|
|
210
|
+
left: -4px;
|
|
211
|
+
cursor: nwse-resize;
|
|
212
|
+
}
|
|
213
|
+
`;
|
|
214
|
+
|
|
215
|
+
export const dialogOverlayStyles = [overlayStyles, dialogOverlayBase, dialogResizableOverlay];
|
|
@@ -11,7 +11,7 @@ export declare function DialogBaseMixin<T extends Constructor<HTMLElement>>(
|
|
|
11
11
|
|
|
12
12
|
export declare class DialogBaseMixinClass {
|
|
13
13
|
/**
|
|
14
|
-
* True if the
|
|
14
|
+
* True if the dialog is visible and available for interaction.
|
|
15
15
|
*/
|
|
16
16
|
opened: boolean;
|
|
17
17
|
|
|
@@ -33,41 +33,28 @@ export declare class DialogBaseMixinClass {
|
|
|
33
33
|
modeless: boolean;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* The `role` attribute value to be set on the
|
|
36
|
+
* The `role` attribute value to be set on the dialog. Defaults to "dialog".
|
|
37
37
|
*
|
|
38
38
|
* @attr {string} overlay-role
|
|
39
|
+
* @deprecated Use standard `role` attribute on the dialog instead
|
|
39
40
|
*/
|
|
40
41
|
overlayRole: string;
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
|
-
* Set the distance of the
|
|
44
|
+
* Set the distance of the dialog from the top of the viewport.
|
|
44
45
|
* If a unitless number is provided, pixels are assumed.
|
|
45
46
|
*
|
|
46
|
-
* Note that the
|
|
47
|
-
*
|
|
48
|
-
* overlay from stretching all the way to the top of the viewport).
|
|
47
|
+
* Note that the dialog uses an internal container that has some
|
|
48
|
+
* additional spacing, which can be overridden by the theme.
|
|
49
49
|
*/
|
|
50
50
|
top: string;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* Set the distance of the
|
|
53
|
+
* Set the distance of the dialog from the left of the viewport.
|
|
54
54
|
* If a unitless number is provided, pixels are assumed.
|
|
55
55
|
*
|
|
56
|
-
* Note that the
|
|
57
|
-
*
|
|
58
|
-
* overlay from stretching all the way to the left of the viewport).
|
|
56
|
+
* Note that the dialog uses an internal container that has some
|
|
57
|
+
* additional spacing, which can be overridden by the theme.
|
|
59
58
|
*/
|
|
60
59
|
left: string;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Set the width of the overlay.
|
|
64
|
-
* If a unitless number is provided, pixels are assumed.
|
|
65
|
-
*/
|
|
66
|
-
width: string;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Set the height of the overlay.
|
|
70
|
-
* If a unitless number is provided, pixels are assumed.
|
|
71
|
-
*/
|
|
72
|
-
height: string;
|
|
73
60
|
}
|
|
@@ -12,11 +12,12 @@ export const DialogBaseMixin = (superClass) =>
|
|
|
12
12
|
static get properties() {
|
|
13
13
|
return {
|
|
14
14
|
/**
|
|
15
|
-
* True if the
|
|
15
|
+
* True if the dialog is visible and available for interaction.
|
|
16
16
|
* @type {boolean}
|
|
17
17
|
*/
|
|
18
18
|
opened: {
|
|
19
19
|
type: Boolean,
|
|
20
|
+
reflectToAttribute: true,
|
|
20
21
|
value: false,
|
|
21
22
|
notify: true,
|
|
22
23
|
sync: true,
|
|
@@ -52,59 +53,41 @@ export const DialogBaseMixin = (superClass) =>
|
|
|
52
53
|
},
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
* Set the distance of the
|
|
56
|
+
* Set the distance of the dialog from the top of the viewport.
|
|
56
57
|
* If a unitless number is provided, pixels are assumed.
|
|
57
58
|
*
|
|
58
|
-
* Note that the
|
|
59
|
-
*
|
|
60
|
-
* overlay from stretching all the way to the top of the viewport).
|
|
59
|
+
* Note that the dialog uses an internal container that has some
|
|
60
|
+
* additional spacing, which can be overridden by the theme.
|
|
61
61
|
*/
|
|
62
62
|
top: {
|
|
63
63
|
type: String,
|
|
64
64
|
},
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* Set the distance of the
|
|
67
|
+
* Set the distance of the dialog from the left of the viewport.
|
|
68
68
|
* If a unitless number is provided, pixels are assumed.
|
|
69
69
|
*
|
|
70
|
-
* Note that the
|
|
71
|
-
*
|
|
72
|
-
* overlay from stretching all the way to the left of the viewport).
|
|
70
|
+
* Note that the dialog uses an internal container that has some
|
|
71
|
+
* additional spacing, which can be overridden by the theme.
|
|
73
72
|
*/
|
|
74
73
|
left: {
|
|
75
74
|
type: String,
|
|
76
75
|
},
|
|
77
76
|
|
|
78
77
|
/**
|
|
79
|
-
*
|
|
80
|
-
* If a unitless number is provided, pixels are assumed.
|
|
81
|
-
*/
|
|
82
|
-
width: {
|
|
83
|
-
type: String,
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Set the height of the overlay.
|
|
88
|
-
* If a unitless number is provided, pixels are assumed.
|
|
89
|
-
*/
|
|
90
|
-
height: {
|
|
91
|
-
type: String,
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* The `role` attribute value to be set on the overlay. Defaults to "dialog".
|
|
78
|
+
* The `role` attribute value to be set on the dialog. Defaults to "dialog".
|
|
96
79
|
*
|
|
97
80
|
* @attr {string} overlay-role
|
|
81
|
+
* @deprecated Use standard `role` attribute on the dialog instead
|
|
98
82
|
*/
|
|
99
83
|
overlayRole: {
|
|
100
84
|
type: String,
|
|
101
|
-
value: 'dialog',
|
|
102
85
|
},
|
|
103
86
|
};
|
|
104
87
|
}
|
|
105
88
|
|
|
106
89
|
static get observers() {
|
|
107
|
-
return ['__positionChanged(top, left)'
|
|
90
|
+
return ['__positionChanged(top, left)'];
|
|
108
91
|
}
|
|
109
92
|
|
|
110
93
|
/** @protected */
|
|
@@ -118,6 +101,29 @@ export const DialogBaseMixin = (superClass) =>
|
|
|
118
101
|
overlay.addEventListener('vaadin-overlay-closed', this.__handleOverlayClosed.bind(this));
|
|
119
102
|
|
|
120
103
|
this._overlayElement = overlay;
|
|
104
|
+
|
|
105
|
+
if (!this.hasAttribute('role')) {
|
|
106
|
+
this.role = 'dialog';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
this.setAttribute('tabindex', '0');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** @protected */
|
|
113
|
+
updated(props) {
|
|
114
|
+
super.updated(props);
|
|
115
|
+
|
|
116
|
+
if (props.has('overlayRole')) {
|
|
117
|
+
this.role = this.overlayRole || 'dialog';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (props.has('modeless')) {
|
|
121
|
+
if (!this.modeless) {
|
|
122
|
+
this.setAttribute('aria-modal', 'true');
|
|
123
|
+
} else {
|
|
124
|
+
this.removeAttribute('aria-modal');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
/** @private */
|
|
@@ -95,7 +95,8 @@ export const DialogDraggableMixin = (superClass) =>
|
|
|
95
95
|
window.addEventListener('touchmove', this._drag);
|
|
96
96
|
if (this.$.overlay.$.overlay.style.position !== 'absolute') {
|
|
97
97
|
const { top, left } = this._originalBounds;
|
|
98
|
-
this
|
|
98
|
+
this.top = top;
|
|
99
|
+
this.left = left;
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -14,15 +14,6 @@ export type DialogOverlayBounds = {
|
|
|
14
14
|
height: number;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export type DialogOverlayBoundsParam =
|
|
18
|
-
| DialogOverlayBounds
|
|
19
|
-
| {
|
|
20
|
-
top?: number | string;
|
|
21
|
-
left?: number | string;
|
|
22
|
-
width?: number | string;
|
|
23
|
-
height?: number | string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
17
|
export declare function DialogOverlayMixin<T extends Constructor<HTMLElement>>(
|
|
27
18
|
base: T,
|
|
28
19
|
): Constructor<DialogOverlayMixinClass> & Constructor<OverlayMixinClass> & T;
|
|
@@ -48,9 +39,4 @@ export declare class DialogOverlayMixinClass {
|
|
|
48
39
|
* Retrieves the coordinates of the overlay.
|
|
49
40
|
*/
|
|
50
41
|
getBounds(): DialogOverlayBounds;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Updates the coordinates of the overlay.
|
|
54
|
-
*/
|
|
55
|
-
setBounds(bounds: DialogOverlayBoundsParam, absolute: boolean): void;
|
|
56
42
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
7
|
+
import { setOverlayStateAttribute } from '@vaadin/overlay/src/vaadin-overlay-utils.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @polymerMixin
|
|
@@ -43,13 +44,24 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
43
44
|
];
|
|
44
45
|
}
|
|
45
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Override method from OverlayFocusMixin to use owner as content root
|
|
49
|
+
* @protected
|
|
50
|
+
* @override
|
|
51
|
+
*/
|
|
52
|
+
get _contentRoot() {
|
|
53
|
+
return this.owner;
|
|
54
|
+
}
|
|
55
|
+
|
|
46
56
|
/** @protected */
|
|
47
57
|
ready() {
|
|
48
58
|
super.ready();
|
|
49
59
|
|
|
50
60
|
// Update overflow attribute on resize
|
|
51
61
|
this.__resizeObserver = new ResizeObserver(() => {
|
|
52
|
-
|
|
62
|
+
requestAnimationFrame(() => {
|
|
63
|
+
this.__updateOverflow();
|
|
64
|
+
});
|
|
53
65
|
});
|
|
54
66
|
this.__resizeObserver.observe(this.$.resizerContainer);
|
|
55
67
|
|
|
@@ -57,6 +69,11 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
57
69
|
this.$.content.addEventListener('scroll', () => {
|
|
58
70
|
this.__updateOverflow();
|
|
59
71
|
});
|
|
72
|
+
|
|
73
|
+
// Update overflow attribute on content change
|
|
74
|
+
this.shadowRoot.addEventListener('slotchange', () => {
|
|
75
|
+
this.__updateOverflow();
|
|
76
|
+
});
|
|
60
77
|
}
|
|
61
78
|
|
|
62
79
|
/** @private */
|
|
@@ -99,8 +116,8 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
99
116
|
this._oldOpenedFooterHeader = opened;
|
|
100
117
|
|
|
101
118
|
// Set attributes here to update styles before detecting content overflow
|
|
102
|
-
this
|
|
103
|
-
this
|
|
119
|
+
setOverlayStateAttribute(this, 'has-header', !!headerRenderer);
|
|
120
|
+
setOverlayStateAttribute(this, 'has-footer', !!footerRenderer);
|
|
104
121
|
|
|
105
122
|
if (headerRendererChanged) {
|
|
106
123
|
if (headerRenderer) {
|
|
@@ -134,7 +151,7 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
134
151
|
|
|
135
152
|
/** @private */
|
|
136
153
|
_headerTitleChanged(headerTitle, opened) {
|
|
137
|
-
this
|
|
154
|
+
setOverlayStateAttribute(this, 'has-title', !!headerTitle);
|
|
138
155
|
|
|
139
156
|
if (opened && (headerTitle || this._oldHeaderTitle)) {
|
|
140
157
|
this.requestContentUpdate();
|
|
@@ -150,7 +167,7 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
150
167
|
this.headerTitleElement.setAttribute('slot', 'title');
|
|
151
168
|
this.headerTitleElement.classList.add('draggable');
|
|
152
169
|
}
|
|
153
|
-
this.appendChild(this.headerTitleElement);
|
|
170
|
+
this.owner.appendChild(this.headerTitleElement);
|
|
154
171
|
this.headerTitleElement.textContent = this.headerTitle;
|
|
155
172
|
} else if (this.headerTitleElement) {
|
|
156
173
|
this.headerTitleElement.remove();
|
|
@@ -167,7 +184,7 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
167
184
|
if (this.headerContainer) {
|
|
168
185
|
// If a new renderer has been set, make sure to reattach the container
|
|
169
186
|
if (!this.headerContainer.parentElement) {
|
|
170
|
-
this.appendChild(this.headerContainer);
|
|
187
|
+
this.owner.appendChild(this.headerContainer);
|
|
171
188
|
}
|
|
172
189
|
|
|
173
190
|
if (this.headerRenderer) {
|
|
@@ -179,7 +196,7 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
179
196
|
if (this.footerContainer) {
|
|
180
197
|
// If a new renderer has been set, make sure to reattach the container
|
|
181
198
|
if (!this.footerContainer.parentElement) {
|
|
182
|
-
this.appendChild(this.footerContainer);
|
|
199
|
+
this.owner.appendChild(this.footerContainer);
|
|
183
200
|
}
|
|
184
201
|
|
|
185
202
|
if (this.footerRenderer) {
|
|
@@ -193,28 +210,6 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
193
210
|
this.__updateOverflow();
|
|
194
211
|
}
|
|
195
212
|
|
|
196
|
-
/**
|
|
197
|
-
* Updates the coordinates of the overlay.
|
|
198
|
-
* @param {!DialogOverlayBoundsParam} bounds
|
|
199
|
-
* @param {boolean} absolute
|
|
200
|
-
*/
|
|
201
|
-
setBounds(bounds, absolute = true) {
|
|
202
|
-
const overlay = this.$.overlay;
|
|
203
|
-
const parsedBounds = { ...bounds };
|
|
204
|
-
|
|
205
|
-
if (absolute && overlay.style.position !== 'absolute') {
|
|
206
|
-
overlay.style.position = 'absolute';
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
Object.keys(parsedBounds).forEach((arg) => {
|
|
210
|
-
if (!isNaN(parsedBounds[arg])) {
|
|
211
|
-
parsedBounds[arg] = `${parsedBounds[arg]}px`;
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
Object.assign(overlay.style, parsedBounds);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
213
|
/**
|
|
219
214
|
* Retrieves the coordinates of the overlay.
|
|
220
215
|
* @return {!DialogOverlayBounds}
|
|
@@ -233,25 +228,21 @@ export const DialogOverlayMixin = (superClass) =>
|
|
|
233
228
|
__updateOverflow() {
|
|
234
229
|
let overflow = '';
|
|
235
230
|
|
|
236
|
-
|
|
237
|
-
// Check for state attributes as extending components might not use renderers.
|
|
238
|
-
if (this.hasAttribute('has-header') || this.hasAttribute('has-footer') || this.headerTitle) {
|
|
239
|
-
const content = this.$.content;
|
|
231
|
+
const content = this.$.content;
|
|
240
232
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
233
|
+
if (content.scrollTop > 0) {
|
|
234
|
+
overflow += ' top';
|
|
235
|
+
}
|
|
244
236
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
237
|
+
if (content.scrollTop < content.scrollHeight - content.clientHeight) {
|
|
238
|
+
overflow += ' bottom';
|
|
248
239
|
}
|
|
249
240
|
|
|
250
241
|
const value = overflow.trim();
|
|
251
242
|
if (value.length > 0 && this.getAttribute('overflow') !== value) {
|
|
252
|
-
this
|
|
243
|
+
setOverlayStateAttribute(this, 'overflow', value);
|
|
253
244
|
} else if (value.length === 0 && this.hasAttribute('overflow')) {
|
|
254
|
-
this
|
|
245
|
+
setOverlayStateAttribute(this, 'overflow', null);
|
|
255
246
|
}
|
|
256
247
|
}
|
|
257
248
|
};
|
|
@@ -7,7 +7,7 @@ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
|
7
7
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
8
8
|
import { DialogOverlayMixin } from './vaadin-dialog-overlay-mixin.js';
|
|
9
9
|
|
|
10
|
-
export { DialogOverlayBounds
|
|
10
|
+
export { DialogOverlayBounds } from './vaadin-dialog-overlay-mixin.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* An element used internally by `<vaadin-dialog>`. Not intended to be used separately.
|