@vaadin/confirm-dialog 24.8.4 → 25.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/README.md +0 -23
- package/package.json +15 -16
- package/src/{vaadin-confirm-dialog-overlay-styles.d.ts → styles/vaadin-confirm-dialog-overlay-base-styles.d.ts} +1 -1
- package/src/styles/vaadin-confirm-dialog-overlay-base-styles.js +44 -0
- package/src/styles/vaadin-confirm-dialog-overlay-core-styles.d.ts +8 -0
- package/src/styles/vaadin-confirm-dialog-overlay-core-styles.js +31 -0
- package/src/vaadin-confirm-dialog-mixin.d.ts +5 -11
- package/src/vaadin-confirm-dialog-mixin.js +65 -93
- package/src/vaadin-confirm-dialog-overlay.js +44 -54
- package/src/vaadin-confirm-dialog.d.ts +6 -10
- package/src/vaadin-confirm-dialog.js +54 -39
- package/theme/lumo/vaadin-confirm-dialog-styles.js +5 -3
- package/web-types.json +70 -26
- package/web-types.lit.json +24 -10
- package/src/vaadin-confirm-dialog-base-mixin.d.ts +0 -29
- package/src/vaadin-confirm-dialog-base-mixin.js +0 -71
- package/src/vaadin-confirm-dialog-overlay-styles.js +0 -31
- package/src/vaadin-lit-confirm-dialog-overlay.js +0 -122
- package/src/vaadin-lit-confirm-dialog.js +0 -78
- package/theme/lumo/vaadin-lit-confirm-dialog.d.ts +0 -3
- package/theme/lumo/vaadin-lit-confirm-dialog.js +0 -3
- package/theme/material/vaadin-confirm-dialog-styles.d.ts +0 -1
- package/theme/material/vaadin-confirm-dialog-styles.js +0 -41
- package/theme/material/vaadin-confirm-dialog.d.ts +0 -3
- package/theme/material/vaadin-confirm-dialog.js +0 -3
- package/theme/material/vaadin-lit-confirm-dialog.d.ts +0 -3
- package/theme/material/vaadin-lit-confirm-dialog.js +0 -3
- package/vaadin-lit-confirm-dialog.d.ts +0 -1
- package/vaadin-lit-confirm-dialog.js +0 -2
package/README.md
CHANGED
|
@@ -28,29 +28,6 @@ Once installed, import the component in your application:
|
|
|
28
28
|
import '@vaadin/confirm-dialog';
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
## Themes
|
|
32
|
-
|
|
33
|
-
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
|
|
34
|
-
The [main entrypoint](https://github.com/vaadin/web-components/blob/main/packages/confirm-dialog/vaadin-confirm-dialog.js) of the package uses the Lumo theme.
|
|
35
|
-
|
|
36
|
-
To use the Material theme, import the component from the `theme/material` folder:
|
|
37
|
-
|
|
38
|
-
```js
|
|
39
|
-
import '@vaadin/confirm-dialog/theme/material/vaadin-confirm-dialog.js';
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
You can also import the Lumo version of the component explicitly:
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
import '@vaadin/confirm-dialog/theme/lumo/vaadin-confirm-dialog.js';
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Finally, you can import the un-themed component from the `src` folder to get a minimal starting point:
|
|
49
|
-
|
|
50
|
-
```js
|
|
51
|
-
import '@vaadin/confirm-dialog/src/vaadin-confirm-dialog.js';
|
|
52
|
-
```
|
|
53
|
-
|
|
54
31
|
## Contributing
|
|
55
32
|
|
|
56
33
|
Read the [contributing guide](https://vaadin.com/docs/latest/contributing) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/confirm-dialog",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.0.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"type": "module",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
|
+
"!src/styles/*-base-styles.d.ts",
|
|
25
|
+
"!src/styles/*-base-styles.js",
|
|
24
26
|
"theme",
|
|
25
27
|
"vaadin-*.d.ts",
|
|
26
28
|
"vaadin-*.js",
|
|
@@ -31,31 +33,28 @@
|
|
|
31
33
|
"Vaadin",
|
|
32
34
|
"vaadin-confirm-dialog",
|
|
33
35
|
"web-components",
|
|
34
|
-
"web-component"
|
|
35
|
-
"polymer"
|
|
36
|
+
"web-component"
|
|
36
37
|
],
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
39
|
-
"@
|
|
40
|
-
"@vaadin/
|
|
41
|
-
"@vaadin/
|
|
42
|
-
"@vaadin/
|
|
43
|
-
"@vaadin/
|
|
44
|
-
"@vaadin/vaadin-
|
|
45
|
-
"@vaadin/vaadin-material-styles": "~24.8.4",
|
|
46
|
-
"@vaadin/vaadin-themable-mixin": "~24.8.4",
|
|
40
|
+
"@vaadin/button": "25.0.0-alpha10",
|
|
41
|
+
"@vaadin/component-base": "25.0.0-alpha10",
|
|
42
|
+
"@vaadin/dialog": "25.0.0-alpha10",
|
|
43
|
+
"@vaadin/overlay": "25.0.0-alpha10",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha10",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha10",
|
|
47
46
|
"lit": "^3.0.0"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|
|
50
|
-
"@vaadin/a11y-base": "
|
|
51
|
-
"@vaadin/chai-plugins": "
|
|
52
|
-
"@vaadin/test-runner-commands": "
|
|
53
|
-
"@vaadin/testing-helpers": "^
|
|
49
|
+
"@vaadin/a11y-base": "25.0.0-alpha10",
|
|
50
|
+
"@vaadin/chai-plugins": "25.0.0-alpha10",
|
|
51
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha10",
|
|
52
|
+
"@vaadin/testing-helpers": "^2.0.0",
|
|
54
53
|
"sinon": "^18.0.0"
|
|
55
54
|
},
|
|
56
55
|
"web-types": [
|
|
57
56
|
"web-types.json",
|
|
58
57
|
"web-types.lit.json"
|
|
59
58
|
],
|
|
60
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "6cc6c94079e805fa5b2f0af4dbf3b2a7485e57d0"
|
|
61
60
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
import { dialogOverlayBase } from '@vaadin/dialog/src/styles/vaadin-dialog-overlay-base-styles.js';
|
|
8
|
+
import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-base-styles.js';
|
|
9
|
+
|
|
10
|
+
const confirmDialogOverlay = css`
|
|
11
|
+
:host {
|
|
12
|
+
--vaadin-dialog-min-width: var(--vaadin-confirm-dialog-min-width, 15em);
|
|
13
|
+
--vaadin-dialog-max-width: var(--vaadin-confirm-dialog-max-width, 25em);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
::slotted([slot='header']) {
|
|
17
|
+
display: contents;
|
|
18
|
+
font: inherit !important;
|
|
19
|
+
color: inherit !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
[part='header'] {
|
|
23
|
+
color: var(--vaadin-dialog-title-color, var(--vaadin-color));
|
|
24
|
+
font-weight: var(--vaadin-dialog-title-font-weight, 600);
|
|
25
|
+
font-size: var(--vaadin-dialog-title-font-size, 1em);
|
|
26
|
+
line-height: var(--vaadin-dialog-title-line-height, inherit);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[part='overlay'] {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
[part='content'] {
|
|
35
|
+
flex: 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* TODO remove this wrapper element */
|
|
39
|
+
#resizerContainer {
|
|
40
|
+
display: contents;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const confirmDialogOverlayStyles = [overlayStyles, dialogOverlayBase, confirmDialogOverlay];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { css } from 'lit';
|
|
7
|
+
import { dialogOverlayBase } from '@vaadin/dialog/src/styles/vaadin-dialog-overlay-core-styles.js';
|
|
8
|
+
import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-core-styles.js';
|
|
9
|
+
|
|
10
|
+
const confirmDialogOverlay = css`
|
|
11
|
+
#resizerContainer {
|
|
12
|
+
height: 100%;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
[part='header'] {
|
|
16
|
+
pointer-events: auto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
::slotted([slot='header']) {
|
|
20
|
+
display: contents !important;
|
|
21
|
+
font: inherit !important;
|
|
22
|
+
color: inherit !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/* Make buttons clickable */
|
|
26
|
+
[part='footer'] > * {
|
|
27
|
+
pointer-events: all;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
export const confirmDialogOverlayStyles = [overlayStyles, dialogOverlayBase, confirmDialogOverlay];
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
8
|
+
import type { DialogSizeMixinClass } from '@vaadin/dialog/src/vaadin-dialog-size-mixin.js';
|
|
7
9
|
|
|
8
10
|
/*
|
|
9
11
|
* Fired when the `opened` property changes.
|
|
@@ -31,14 +33,14 @@ export type ConfirmDialogEventMap = ConfirmDialogCustomEventMap & HTMLElementEve
|
|
|
31
33
|
|
|
32
34
|
export declare function ConfirmDialogMixin<T extends Constructor<HTMLElement>>(
|
|
33
35
|
base: T,
|
|
34
|
-
): Constructor<ConfirmDialogMixinClass> & T;
|
|
36
|
+
): Constructor<ConfirmDialogMixinClass> & Constructor<DialogSizeMixinClass> & Constructor<OverlayClassMixinClass> & T;
|
|
35
37
|
|
|
36
38
|
export declare class ConfirmDialogMixinClass {
|
|
37
39
|
/**
|
|
38
40
|
* Sets the `aria-describedby` attribute of the overlay element.
|
|
39
41
|
*
|
|
40
|
-
* By default, all elements inside the message area
|
|
41
|
-
*
|
|
42
|
+
* By default, the text contents of all elements inside the message area
|
|
43
|
+
* are combined into the `aria-description` attribute. However, there are
|
|
42
44
|
* cases where this can confuse screen reader users (e.g. the dialog
|
|
43
45
|
* may present a password confirmation form). For these cases,
|
|
44
46
|
* it's better to associate only the elements that will help describe
|
|
@@ -121,12 +123,4 @@ export declare class ConfirmDialogMixinClass {
|
|
|
121
123
|
* @attr {string} cancel-theme
|
|
122
124
|
*/
|
|
123
125
|
cancelTheme: string;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* A space-delimited list of CSS class names
|
|
127
|
-
* to set on the underlying overlay element.
|
|
128
|
-
*
|
|
129
|
-
* @attr {string} overlay-class
|
|
130
|
-
*/
|
|
131
|
-
overlayClass: string;
|
|
132
126
|
}
|
|
@@ -4,21 +4,24 @@
|
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { setAriaIDReference } from '@vaadin/a11y-base/src/aria-id-reference.js';
|
|
7
|
+
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
7
8
|
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
8
|
-
import {
|
|
9
|
+
import { DialogSizeMixin } from '@vaadin/dialog/src/vaadin-dialog-size-mixin.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @polymerMixin
|
|
13
|
+
* @mixes DialogSizeMixin
|
|
14
|
+
* @mixes OverlayClassMixin
|
|
12
15
|
*/
|
|
13
16
|
export const ConfirmDialogMixin = (superClass) =>
|
|
14
|
-
class ConfirmDialogMixinClass extends superClass {
|
|
17
|
+
class ConfirmDialogMixinClass extends OverlayClassMixin(DialogSizeMixin(superClass)) {
|
|
15
18
|
static get properties() {
|
|
16
19
|
return {
|
|
17
20
|
/**
|
|
18
21
|
* Sets the `aria-describedby` attribute of the overlay element.
|
|
19
22
|
*
|
|
20
|
-
* By default, all elements inside the message area
|
|
21
|
-
*
|
|
23
|
+
* By default, the text contents of all elements inside the message area
|
|
24
|
+
* are combined into the `aria-description` attribute. However, there are
|
|
22
25
|
* cases where this can confuse screen reader users (e.g. the dialog
|
|
23
26
|
* may present a password confirmation form). For these cases,
|
|
24
27
|
* it's better to associate only the elements that will help describe
|
|
@@ -34,6 +37,7 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
34
37
|
*/
|
|
35
38
|
opened: {
|
|
36
39
|
type: Boolean,
|
|
40
|
+
reflectToAttribute: true,
|
|
37
41
|
value: false,
|
|
38
42
|
notify: true,
|
|
39
43
|
sync: true,
|
|
@@ -154,16 +158,6 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
154
158
|
value: 'tertiary',
|
|
155
159
|
},
|
|
156
160
|
|
|
157
|
-
/**
|
|
158
|
-
* A space-delimited list of CSS class names
|
|
159
|
-
* to set on the underlying overlay element.
|
|
160
|
-
*
|
|
161
|
-
* @attr {string} overlay-class
|
|
162
|
-
*/
|
|
163
|
-
overlayClass: {
|
|
164
|
-
type: String,
|
|
165
|
-
},
|
|
166
|
-
|
|
167
161
|
/**
|
|
168
162
|
* A reference to the "Cancel" button which will be teleported to the overlay.
|
|
169
163
|
* @private
|
|
@@ -197,15 +191,6 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
197
191
|
value: () => [],
|
|
198
192
|
},
|
|
199
193
|
|
|
200
|
-
/**
|
|
201
|
-
* A reference to the overlay element.
|
|
202
|
-
* @private
|
|
203
|
-
*/
|
|
204
|
-
_overlayElement: {
|
|
205
|
-
type: Object,
|
|
206
|
-
sync: true,
|
|
207
|
-
},
|
|
208
|
-
|
|
209
194
|
/**
|
|
210
195
|
* A reference to the "Reject" button which will be teleported to the overlay.
|
|
211
196
|
* @private
|
|
@@ -213,22 +198,6 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
213
198
|
_rejectButton: {
|
|
214
199
|
type: Object,
|
|
215
200
|
},
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Height to be set on the overlay content.
|
|
219
|
-
* @protected
|
|
220
|
-
*/
|
|
221
|
-
_contentHeight: {
|
|
222
|
-
type: String,
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Width to be set on the overlay content.
|
|
227
|
-
* @protected
|
|
228
|
-
*/
|
|
229
|
-
_contentWidth: {
|
|
230
|
-
type: String,
|
|
231
|
-
},
|
|
232
201
|
};
|
|
233
202
|
}
|
|
234
203
|
|
|
@@ -239,7 +208,7 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
239
208
|
'__updateHeaderNode(_headerNode, header)',
|
|
240
209
|
'__updateMessageNodes(_messageNodes, message)',
|
|
241
210
|
'__updateRejectButton(_rejectButton, rejectText, rejectTheme, rejectButtonVisible)',
|
|
242
|
-
'__accessibleDescriptionRefChanged(
|
|
211
|
+
'__accessibleDescriptionRefChanged(_messageNodes, accessibleDescriptionRef)',
|
|
243
212
|
];
|
|
244
213
|
}
|
|
245
214
|
|
|
@@ -251,14 +220,35 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
251
220
|
this.__reject = this.__reject.bind(this);
|
|
252
221
|
}
|
|
253
222
|
|
|
254
|
-
|
|
255
|
-
|
|
223
|
+
/** @protected */
|
|
224
|
+
connectedCallback() {
|
|
225
|
+
super.connectedCallback();
|
|
226
|
+
// Restore opened state if overlay was opened when disconnecting
|
|
227
|
+
if (this.__restoreOpened) {
|
|
228
|
+
this.opened = true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** @protected */
|
|
233
|
+
disconnectedCallback() {
|
|
234
|
+
super.disconnectedCallback();
|
|
235
|
+
// Automatically close the overlay when dialog is removed from DOM
|
|
236
|
+
// Using a timeout to avoid toggling opened state, and dispatching change
|
|
237
|
+
// events, when just moving the dialog in the DOM
|
|
238
|
+
setTimeout(() => {
|
|
239
|
+
if (!this.isConnected) {
|
|
240
|
+
this.__restoreOpened = this.opened;
|
|
241
|
+
this.opened = false;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
256
244
|
}
|
|
257
245
|
|
|
258
246
|
/** @protected */
|
|
259
247
|
ready() {
|
|
260
248
|
super.ready();
|
|
261
249
|
|
|
250
|
+
this.role = 'alertdialog';
|
|
251
|
+
|
|
262
252
|
this._headerController = new SlotController(this, 'header', 'h3', {
|
|
263
253
|
initializer: (node) => {
|
|
264
254
|
this._headerNode = node;
|
|
@@ -271,13 +261,7 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
271
261
|
multiple: true,
|
|
272
262
|
observe: false,
|
|
273
263
|
initializer: (node) => {
|
|
274
|
-
|
|
275
|
-
wrapper.style.display = 'contents';
|
|
276
|
-
const wrapperId = `confirm-dialog-message-${generateUniqueId()}`;
|
|
277
|
-
wrapper.id = wrapperId;
|
|
278
|
-
this.appendChild(wrapper);
|
|
279
|
-
wrapper.appendChild(node);
|
|
280
|
-
this._messageNodes = [...this._messageNodes, wrapper];
|
|
264
|
+
this._messageNodes = [...this._messageNodes, node];
|
|
281
265
|
},
|
|
282
266
|
});
|
|
283
267
|
this.addController(this._messageController);
|
|
@@ -304,59 +288,47 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
304
288
|
});
|
|
305
289
|
this.addController(this._confirmController);
|
|
306
290
|
|
|
307
|
-
this._overlayElement = this.$.
|
|
308
|
-
|
|
309
|
-
this._initOverlay(this._overlayElement);
|
|
291
|
+
this._overlayElement = this.$.overlay;
|
|
310
292
|
}
|
|
311
293
|
|
|
312
294
|
/** @protected */
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
295
|
+
updated(props) {
|
|
296
|
+
super.updated(props);
|
|
297
|
+
|
|
298
|
+
if (props.has('header')) {
|
|
299
|
+
this.ariaLabel = this.header || 'confirmation';
|
|
300
|
+
}
|
|
318
301
|
}
|
|
319
302
|
|
|
320
|
-
/** @
|
|
303
|
+
/** @protected */
|
|
321
304
|
__onDialogOpened() {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
// Teleport slotted nodes to the overlay element.
|
|
325
|
-
this.__slottedNodes.forEach((node) => {
|
|
326
|
-
overlay.appendChild(node);
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
const confirmButton = overlay.querySelector('[slot="confirm-button"]');
|
|
330
|
-
if (confirmButton) {
|
|
331
|
-
confirmButton.focus();
|
|
305
|
+
if (this._confirmButton) {
|
|
306
|
+
this._confirmButton.focus();
|
|
332
307
|
}
|
|
333
308
|
}
|
|
334
309
|
|
|
335
|
-
/** @
|
|
310
|
+
/** @protected */
|
|
336
311
|
__onDialogClosed() {
|
|
337
|
-
// Move nodes from the overlay back to the host.
|
|
338
|
-
this.__slottedNodes.forEach((node) => {
|
|
339
|
-
this.appendChild(node);
|
|
340
|
-
});
|
|
341
312
|
this.dispatchEvent(new CustomEvent('closed'));
|
|
342
313
|
}
|
|
343
314
|
|
|
344
315
|
/** @private */
|
|
345
|
-
__accessibleDescriptionRefChanged(
|
|
346
|
-
if (!
|
|
316
|
+
__accessibleDescriptionRefChanged(messageNodes, accessibleDescriptionRef) {
|
|
317
|
+
if (!messageNodes) {
|
|
347
318
|
return;
|
|
348
319
|
}
|
|
349
320
|
|
|
350
|
-
if (accessibleDescriptionRef
|
|
351
|
-
|
|
321
|
+
if (accessibleDescriptionRef) {
|
|
322
|
+
this.removeAttribute('aria-description');
|
|
323
|
+
setAriaIDReference(this, 'aria-describedby', {
|
|
352
324
|
newId: accessibleDescriptionRef,
|
|
353
325
|
oldId: this.__oldAccessibleDescriptionRef,
|
|
354
326
|
fromUser: true,
|
|
355
327
|
});
|
|
356
328
|
} else {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
329
|
+
this.removeAttribute('aria-describedby');
|
|
330
|
+
const ariaDescription = messageNodes.map((node) => node.textContent.trim()).join(' ');
|
|
331
|
+
this.setAttribute('aria-description', ariaDescription);
|
|
360
332
|
}
|
|
361
333
|
|
|
362
334
|
this.__oldAccessibleDescriptionRef = accessibleDescriptionRef;
|
|
@@ -405,11 +377,9 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
405
377
|
/** @private */
|
|
406
378
|
__updateMessageNodes(nodes, message) {
|
|
407
379
|
if (nodes && nodes.length > 0) {
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
if (defaultWrapperNode) {
|
|
412
|
-
defaultWrapperNode.firstChild.textContent = message;
|
|
380
|
+
const defaultNode = nodes.find((node) => node === this._messageController.defaultNode);
|
|
381
|
+
if (defaultNode) {
|
|
382
|
+
defaultNode.textContent = message;
|
|
413
383
|
}
|
|
414
384
|
}
|
|
415
385
|
}
|
|
@@ -425,13 +395,20 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
425
395
|
}
|
|
426
396
|
}
|
|
427
397
|
|
|
428
|
-
/** @
|
|
429
|
-
|
|
430
|
-
if (
|
|
398
|
+
/** @protected */
|
|
399
|
+
_onOverlayEscapePress(event) {
|
|
400
|
+
if (this.noCloseOnEsc) {
|
|
401
|
+
event.preventDefault();
|
|
402
|
+
} else {
|
|
431
403
|
this.__cancel();
|
|
432
404
|
}
|
|
433
405
|
}
|
|
434
406
|
|
|
407
|
+
/** @protected */
|
|
408
|
+
_onOverlayOutsideClick(event) {
|
|
409
|
+
event.preventDefault();
|
|
410
|
+
}
|
|
411
|
+
|
|
435
412
|
/** @private */
|
|
436
413
|
__confirm() {
|
|
437
414
|
this.dispatchEvent(new CustomEvent('confirm'));
|
|
@@ -450,11 +427,6 @@ export const ConfirmDialogMixin = (superClass) =>
|
|
|
450
427
|
this.opened = false;
|
|
451
428
|
}
|
|
452
429
|
|
|
453
|
-
/** @private */
|
|
454
|
-
_getAriaLabel(header) {
|
|
455
|
-
return header || 'confirmation';
|
|
456
|
-
}
|
|
457
|
-
|
|
458
430
|
/**
|
|
459
431
|
* Fired when the confirm dialog is closed.
|
|
460
432
|
*
|
|
@@ -3,22 +3,14 @@
|
|
|
3
3
|
* Copyright (c) 2018 - 2025 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { html,
|
|
6
|
+
import { html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
|
-
import {
|
|
10
|
-
import { DialogBaseMixin } from '@vaadin/dialog/src/vaadin-dialog-base-mixin.js';
|
|
11
|
-
import { dialogOverlay } from '@vaadin/dialog/src/vaadin-dialog-styles.js';
|
|
9
|
+
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
12
10
|
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { ConfirmDialogBaseMixin } from './vaadin-confirm-dialog-base-mixin.js';
|
|
17
|
-
import { confirmDialogOverlay } from './vaadin-confirm-dialog-overlay-styles.js';
|
|
18
|
-
|
|
19
|
-
registerStyles('vaadin-confirm-dialog-overlay', [overlayStyles, dialogOverlay, confirmDialogOverlay], {
|
|
20
|
-
moduleId: 'vaadin-confirm-dialog-overlay-styles',
|
|
21
|
-
});
|
|
11
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
12
|
+
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
|
+
import { confirmDialogOverlayStyles } from './styles/vaadin-confirm-dialog-overlay-core-styles.js';
|
|
22
14
|
|
|
23
15
|
/**
|
|
24
16
|
* An element used internally by `<vaadin-confirm-dialog>`. Not intended to be used separately.
|
|
@@ -30,14 +22,33 @@ registerStyles('vaadin-confirm-dialog-overlay', [overlayStyles, dialogOverlay, c
|
|
|
30
22
|
* @mixes ThemableMixin
|
|
31
23
|
* @private
|
|
32
24
|
*/
|
|
33
|
-
class ConfirmDialogOverlay extends OverlayMixin(DirMixin(ThemableMixin(
|
|
25
|
+
class ConfirmDialogOverlay extends OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
|
|
34
26
|
static get is() {
|
|
35
27
|
return 'vaadin-confirm-dialog-overlay';
|
|
36
28
|
}
|
|
37
29
|
|
|
38
|
-
static get
|
|
30
|
+
static get styles() {
|
|
31
|
+
return confirmDialogOverlayStyles;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static get properties() {
|
|
35
|
+
return {
|
|
36
|
+
cancelButtonVisible: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
value: false,
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
rejectButtonVisible: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
value: false,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** @protected */
|
|
49
|
+
render() {
|
|
39
50
|
return html`
|
|
40
|
-
<div part="backdrop" id="backdrop" hidden
|
|
51
|
+
<div part="backdrop" id="backdrop" ?hidden="${!this.withBackdrop}"></div>
|
|
41
52
|
<div part="overlay" id="overlay" tabindex="0">
|
|
42
53
|
<section id="resizerContainer" class="resizer-container">
|
|
43
54
|
<header part="header"><slot name="header"></slot></header>
|
|
@@ -45,10 +56,10 @@ class ConfirmDialogOverlay extends OverlayMixin(DirMixin(ThemableMixin(PolymerEl
|
|
|
45
56
|
<div part="message"><slot></slot></div>
|
|
46
57
|
</div>
|
|
47
58
|
<footer part="footer" role="toolbar">
|
|
48
|
-
<div part="cancel-button">
|
|
59
|
+
<div part="cancel-button" ?hidden="${!this.cancelButtonVisible}">
|
|
49
60
|
<slot name="cancel-button"></slot>
|
|
50
61
|
</div>
|
|
51
|
-
<div part="reject-button">
|
|
62
|
+
<div part="reject-button" ?hidden="${!this.rejectButtonVisible}">
|
|
52
63
|
<slot name="reject-button"></slot>
|
|
53
64
|
</div>
|
|
54
65
|
<div part="confirm-button">
|
|
@@ -71,45 +82,24 @@ class ConfirmDialogOverlay extends OverlayMixin(DirMixin(ThemableMixin(PolymerEl
|
|
|
71
82
|
this.setAttribute('has-header', '');
|
|
72
83
|
this.setAttribute('has-footer', '');
|
|
73
84
|
}
|
|
74
|
-
}
|
|
75
85
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
DialogBaseMixin(OverlayClassMixin(ThemePropertyMixin(PolymerElement))),
|
|
84
|
-
) {
|
|
85
|
-
static get is() {
|
|
86
|
-
return 'vaadin-confirm-dialog-dialog';
|
|
86
|
+
/**
|
|
87
|
+
* Override method from OverlayFocusMixin to use owner as content root
|
|
88
|
+
* @protected
|
|
89
|
+
* @override
|
|
90
|
+
*/
|
|
91
|
+
get _contentRoot() {
|
|
92
|
+
return this.owner;
|
|
87
93
|
}
|
|
88
94
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
<vaadin-confirm-dialog-overlay
|
|
98
|
-
id="overlay"
|
|
99
|
-
opened="[[opened]]"
|
|
100
|
-
on-opened-changed="_onOverlayOpened"
|
|
101
|
-
on-mousedown="_bringOverlayToFront"
|
|
102
|
-
on-touchstart="_bringOverlayToFront"
|
|
103
|
-
theme$="[[_theme]]"
|
|
104
|
-
modeless="[[modeless]]"
|
|
105
|
-
with-backdrop="[[!modeless]]"
|
|
106
|
-
resizable$="[[resizable]]"
|
|
107
|
-
aria-label$="[[ariaLabel]]"
|
|
108
|
-
restore-focus-on-close
|
|
109
|
-
focus-trap
|
|
110
|
-
></vaadin-confirm-dialog-overlay>
|
|
111
|
-
`;
|
|
95
|
+
/**
|
|
96
|
+
* Override method from OverlayFocusMixin to use owner as modal root
|
|
97
|
+
* @protected
|
|
98
|
+
* @override
|
|
99
|
+
*/
|
|
100
|
+
get _modalRoot() {
|
|
101
|
+
return this.owner;
|
|
112
102
|
}
|
|
113
103
|
}
|
|
114
104
|
|
|
115
|
-
defineCustomElement(
|
|
105
|
+
defineCustomElement(ConfirmDialogOverlay);
|