@vaadin/confirm-dialog 24.2.0-dev.f254716fe → 24.3.0-alpha2
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 +15 -11
- package/src/vaadin-confirm-dialog-base-mixin.d.ts +29 -0
- package/src/vaadin-confirm-dialog-base-mixin.js +71 -0
- package/src/vaadin-confirm-dialog-mixin.d.ts +125 -0
- package/src/vaadin-confirm-dialog-mixin.js +451 -0
- package/src/vaadin-confirm-dialog-overlay-styles.d.ts +8 -0
- package/src/vaadin-confirm-dialog-overlay-styles.js +27 -0
- package/src/vaadin-confirm-dialog-overlay.js +10 -81
- package/src/vaadin-confirm-dialog.d.ts +3 -113
- package/src/vaadin-confirm-dialog.js +8 -415
- package/theme/lumo/vaadin-confirm-dialog-styles.js +1 -0
- package/theme/material/vaadin-confirm-dialog-styles.js +1 -0
- package/web-types.json +315 -0
- package/web-types.lit.json +153 -0
|
@@ -6,23 +6,9 @@
|
|
|
6
6
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
7
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
8
8
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
9
|
+
import { type ConfirmDialogEventMap, ConfirmDialogMixin } from './vaadin-confirm-dialog-mixin.js';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
* Fired when the `opened` property changes.
|
|
12
|
-
*/
|
|
13
|
-
export type ConfirmDialogOpenedChangedEvent = CustomEvent<{ value: boolean }>;
|
|
14
|
-
|
|
15
|
-
export interface ConfirmDialogCustomEventMap {
|
|
16
|
-
'opened-changed': ConfirmDialogOpenedChangedEvent;
|
|
17
|
-
|
|
18
|
-
confirm: Event;
|
|
19
|
-
|
|
20
|
-
cancel: Event;
|
|
21
|
-
|
|
22
|
-
reject: Event;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type ConfirmDialogEventMap = ConfirmDialogCustomEventMap & HTMLElementEventMap;
|
|
11
|
+
export * from './vaadin-confirm-dialog-mixin.js';
|
|
26
12
|
|
|
27
13
|
/**
|
|
28
14
|
* `<vaadin-confirm-dialog>` is a Web Component for showing alerts and asking for user confirmation.
|
|
@@ -72,103 +58,7 @@ export type ConfirmDialogEventMap = ConfirmDialogCustomEventMap & HTMLElementEve
|
|
|
72
58
|
* @fires {Event} reject - Fired when Reject button was pressed.
|
|
73
59
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
74
60
|
*/
|
|
75
|
-
declare class ConfirmDialog extends ElementMixin(ThemePropertyMixin(ControllerMixin(HTMLElement))) {
|
|
76
|
-
/**
|
|
77
|
-
* Sets the `aria-describedby` attribute of the overlay element.
|
|
78
|
-
*
|
|
79
|
-
* By default, all elements inside the message area are linked
|
|
80
|
-
* through the `aria-describedby` attribute. However, there are
|
|
81
|
-
* cases where this can confuse screen reader users (e.g. the dialog
|
|
82
|
-
* may present a password confirmation form). For these cases,
|
|
83
|
-
* it's better to associate only the elements that will help describe
|
|
84
|
-
* the confirmation dialog through this API.
|
|
85
|
-
* @attr {string} accessible-description-ref
|
|
86
|
-
*/
|
|
87
|
-
accessibleDescriptionRef: string | null | undefined;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* True if the overlay is currently displayed.
|
|
91
|
-
*/
|
|
92
|
-
opened: boolean;
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Set the confirmation dialog title.
|
|
96
|
-
*/
|
|
97
|
-
header: string;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Set the message or confirmation question.
|
|
101
|
-
*/
|
|
102
|
-
message: string | null | undefined;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Text displayed on confirm-button.
|
|
106
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
107
|
-
* @attr {string} confirm-text
|
|
108
|
-
*/
|
|
109
|
-
confirmText: string;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Theme for a confirm-button.
|
|
113
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
114
|
-
* @attr {string} confirm-theme
|
|
115
|
-
*/
|
|
116
|
-
confirmTheme: string;
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Set to true to disable closing dialog on Escape press
|
|
120
|
-
* @attr {boolean} no-close-on-esc
|
|
121
|
-
*/
|
|
122
|
-
noCloseOnEsc: boolean;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Whether to show reject button or not.
|
|
126
|
-
* @attr {boolean} reject-button-visible
|
|
127
|
-
*/
|
|
128
|
-
rejectButtonVisible: boolean;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Text displayed on reject-button.
|
|
132
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
133
|
-
* @attr {string} reject-text
|
|
134
|
-
*/
|
|
135
|
-
rejectText: string;
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Theme for a reject-button.
|
|
139
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
140
|
-
* @attr {string} reject-theme
|
|
141
|
-
*/
|
|
142
|
-
rejectTheme: string;
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Whether to show cancel button or not.
|
|
146
|
-
* @attr {boolean} cancel-button-visible
|
|
147
|
-
*/
|
|
148
|
-
cancelButtonVisible: boolean;
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Text displayed on cancel-button.
|
|
152
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
153
|
-
* @attr {string} cancel-text
|
|
154
|
-
*/
|
|
155
|
-
cancelText: string;
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Theme for a cancel-button.
|
|
159
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
160
|
-
* @attr {string} cancel-theme
|
|
161
|
-
*/
|
|
162
|
-
cancelTheme: string;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* A space-delimited list of CSS class names
|
|
166
|
-
* to set on the underlying overlay element.
|
|
167
|
-
*
|
|
168
|
-
* @attr {string} overlay-class
|
|
169
|
-
*/
|
|
170
|
-
overlayClass: string;
|
|
171
|
-
|
|
61
|
+
declare class ConfirmDialog extends ConfirmDialogMixin(ElementMixin(ThemePropertyMixin(ControllerMixin(HTMLElement)))) {
|
|
172
62
|
addEventListener<K extends keyof ConfirmDialogEventMap>(
|
|
173
63
|
type: K,
|
|
174
64
|
listener: (this: ConfirmDialog, ev: ConfirmDialogEventMap[K]) => void,
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Copyright (c) 2018 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
+
import '@vaadin/button/src/vaadin-button.js';
|
|
6
7
|
import './vaadin-confirm-dialog-overlay.js';
|
|
7
8
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
|
-
import { setAriaIDReference } from '@vaadin/a11y-base/src/aria-id-reference.js';
|
|
9
9
|
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
10
|
+
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
10
11
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
11
|
-
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
12
|
-
import { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
|
|
13
12
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
13
|
+
import { ConfirmDialogMixin } from './vaadin-confirm-dialog-mixin.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* `<vaadin-confirm-dialog>` is a Web Component for showing alerts and asking for user confirmation.
|
|
@@ -60,12 +60,14 @@ import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-p
|
|
|
60
60
|
* @fires {Event} reject - Fired when Reject button was pressed.
|
|
61
61
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
62
62
|
*
|
|
63
|
+
* @customElement
|
|
63
64
|
* @extends HTMLElement
|
|
65
|
+
* @mixes ConfirmDialogMixin
|
|
64
66
|
* @mixes ControllerMixin
|
|
65
67
|
* @mixes ElementMixin
|
|
66
68
|
* @mixes ThemePropertyMixin
|
|
67
69
|
*/
|
|
68
|
-
class ConfirmDialog extends ElementMixin(ThemePropertyMixin(ControllerMixin(PolymerElement))) {
|
|
70
|
+
class ConfirmDialog extends ConfirmDialogMixin(ElementMixin(ThemePropertyMixin(ControllerMixin(PolymerElement)))) {
|
|
69
71
|
static get template() {
|
|
70
72
|
return html`
|
|
71
73
|
<style>
|
|
@@ -101,422 +103,13 @@ class ConfirmDialog extends ElementMixin(ThemePropertyMixin(ControllerMixin(Poly
|
|
|
101
103
|
return 'vaadin-confirm-dialog';
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
static get properties() {
|
|
105
|
-
return {
|
|
106
|
-
/**
|
|
107
|
-
* Sets the `aria-describedby` attribute of the overlay element.
|
|
108
|
-
*
|
|
109
|
-
* By default, all elements inside the message area are linked
|
|
110
|
-
* through the `aria-describedby` attribute. However, there are
|
|
111
|
-
* cases where this can confuse screen reader users (e.g. the dialog
|
|
112
|
-
* may present a password confirmation form). For these cases,
|
|
113
|
-
* it's better to associate only the elements that will help describe
|
|
114
|
-
* the confirmation dialog through this API.
|
|
115
|
-
*/
|
|
116
|
-
accessibleDescriptionRef: {
|
|
117
|
-
type: String,
|
|
118
|
-
},
|
|
119
|
-
/**
|
|
120
|
-
* True if the overlay is currently displayed.
|
|
121
|
-
* @type {boolean}
|
|
122
|
-
*/
|
|
123
|
-
opened: {
|
|
124
|
-
type: Boolean,
|
|
125
|
-
value: false,
|
|
126
|
-
notify: true,
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Set the confirmation dialog title.
|
|
131
|
-
* @type {string}
|
|
132
|
-
*/
|
|
133
|
-
header: {
|
|
134
|
-
type: String,
|
|
135
|
-
value: '',
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Set the message or confirmation question.
|
|
140
|
-
*/
|
|
141
|
-
message: {
|
|
142
|
-
type: String,
|
|
143
|
-
value: '',
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Text displayed on confirm-button.
|
|
148
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
149
|
-
* @attr {string} confirm-text
|
|
150
|
-
* @type {string}
|
|
151
|
-
*/
|
|
152
|
-
confirmText: {
|
|
153
|
-
type: String,
|
|
154
|
-
value: 'Confirm',
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Theme for a confirm-button.
|
|
159
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
160
|
-
* @attr {string} confirm-theme
|
|
161
|
-
* @type {string}
|
|
162
|
-
*/
|
|
163
|
-
confirmTheme: {
|
|
164
|
-
type: String,
|
|
165
|
-
value: 'primary',
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Set to true to disable closing dialog on Escape press
|
|
170
|
-
* @attr {boolean} no-close-on-esc
|
|
171
|
-
* @type {boolean}
|
|
172
|
-
*/
|
|
173
|
-
noCloseOnEsc: {
|
|
174
|
-
type: Boolean,
|
|
175
|
-
value: false,
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Whether to show reject button or not.
|
|
180
|
-
* @attr {boolean} reject-button-visible
|
|
181
|
-
* @type {boolean}
|
|
182
|
-
*/
|
|
183
|
-
rejectButtonVisible: {
|
|
184
|
-
type: Boolean,
|
|
185
|
-
reflectToAttribute: true,
|
|
186
|
-
value: false,
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Text displayed on reject-button.
|
|
191
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
192
|
-
* @attr {string} reject-text
|
|
193
|
-
* @type {string}
|
|
194
|
-
*/
|
|
195
|
-
rejectText: {
|
|
196
|
-
type: String,
|
|
197
|
-
value: 'Reject',
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Theme for a reject-button.
|
|
202
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
203
|
-
* @attr {string} reject-theme
|
|
204
|
-
* @type {string}
|
|
205
|
-
*/
|
|
206
|
-
rejectTheme: {
|
|
207
|
-
type: String,
|
|
208
|
-
value: 'error tertiary',
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Whether to show cancel button or not.
|
|
213
|
-
* @attr {boolean} cancel-button-visible
|
|
214
|
-
* @type {boolean}
|
|
215
|
-
*/
|
|
216
|
-
cancelButtonVisible: {
|
|
217
|
-
type: Boolean,
|
|
218
|
-
reflectToAttribute: true,
|
|
219
|
-
value: false,
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Text displayed on cancel-button.
|
|
224
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
225
|
-
* @attr {string} cancel-text
|
|
226
|
-
* @type {string}
|
|
227
|
-
*/
|
|
228
|
-
cancelText: {
|
|
229
|
-
type: String,
|
|
230
|
-
value: 'Cancel',
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Theme for a cancel-button.
|
|
235
|
-
* This only affects the default button, custom slotted buttons will not be altered.
|
|
236
|
-
* @attr {string} cancel-theme
|
|
237
|
-
* @type {string}
|
|
238
|
-
*/
|
|
239
|
-
cancelTheme: {
|
|
240
|
-
type: String,
|
|
241
|
-
value: 'tertiary',
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* A space-delimited list of CSS class names
|
|
246
|
-
* to set on the underlying overlay element.
|
|
247
|
-
*
|
|
248
|
-
* @attr {string} overlay-class
|
|
249
|
-
*/
|
|
250
|
-
overlayClass: {
|
|
251
|
-
type: String,
|
|
252
|
-
},
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* A reference to the "Cancel" button which will be teleported to the overlay.
|
|
256
|
-
* @private
|
|
257
|
-
*/
|
|
258
|
-
_cancelButton: {
|
|
259
|
-
type: Object,
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* A reference to the "Confirm" button which will be teleported to the overlay.
|
|
264
|
-
* @private
|
|
265
|
-
*/
|
|
266
|
-
_confirmButton: {
|
|
267
|
-
type: Object,
|
|
268
|
-
},
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* A reference to the "header" node which will be teleported to the overlay.
|
|
272
|
-
* @private
|
|
273
|
-
*/
|
|
274
|
-
_headerNode: {
|
|
275
|
-
type: Object,
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* A list of message nodes which will be placed in the overlay default slot.
|
|
280
|
-
* @private
|
|
281
|
-
*/
|
|
282
|
-
_messageNodes: {
|
|
283
|
-
type: Array,
|
|
284
|
-
value: () => [],
|
|
285
|
-
},
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* A reference to the "Reject" button which will be teleported to the overlay.
|
|
289
|
-
* @private
|
|
290
|
-
*/
|
|
291
|
-
_rejectButton: {
|
|
292
|
-
type: Object,
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Height to be set on the overlay content.
|
|
297
|
-
* @protected
|
|
298
|
-
*/
|
|
299
|
-
_contentHeight: {
|
|
300
|
-
type: String,
|
|
301
|
-
},
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Width to be set on the overlay content.
|
|
305
|
-
* @protected
|
|
306
|
-
*/
|
|
307
|
-
_contentWidth: {
|
|
308
|
-
type: String,
|
|
309
|
-
},
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
static get observers() {
|
|
314
|
-
return [
|
|
315
|
-
'__updateConfirmButton(_confirmButton, confirmText, confirmTheme)',
|
|
316
|
-
'__updateCancelButton(_cancelButton, cancelText, cancelTheme, cancelButtonVisible)',
|
|
317
|
-
'__updateHeaderNode(_headerNode, header)',
|
|
318
|
-
'__updateMessageNodes(_messageNodes, message)',
|
|
319
|
-
'__updateRejectButton(_rejectButton, rejectText, rejectTheme, rejectButtonVisible)',
|
|
320
|
-
'__accessibleDescriptionRefChanged(_overlayElement, accessibleDescriptionRef)',
|
|
321
|
-
];
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
constructor() {
|
|
325
|
-
super();
|
|
326
|
-
|
|
327
|
-
this.__cancel = this.__cancel.bind(this);
|
|
328
|
-
this.__confirm = this.__confirm.bind(this);
|
|
329
|
-
this.__reject = this.__reject.bind(this);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
get __slottedNodes() {
|
|
333
|
-
return [this._headerNode, ...this._messageNodes, this._cancelButton, this._confirmButton, this._rejectButton];
|
|
334
|
-
}
|
|
335
|
-
|
|
336
106
|
/** @protected */
|
|
337
107
|
ready() {
|
|
338
108
|
super.ready();
|
|
339
109
|
|
|
340
110
|
this._overlayElement = this.$.dialog.$.overlay;
|
|
341
|
-
this._overlayElement.addEventListener('vaadin-overlay-escape-press', this._escPressed.bind(this));
|
|
342
|
-
this._overlayElement.addEventListener('vaadin-overlay-open', () => this.__onDialogOpened());
|
|
343
|
-
this._overlayElement.addEventListener('vaadin-overlay-closed', () => this.__onDialogClosed());
|
|
344
|
-
this._overlayElement.setAttribute('role', 'alertdialog');
|
|
345
|
-
|
|
346
|
-
this._headerController = new SlotController(this, 'header', 'h3', {
|
|
347
|
-
initializer: (node) => {
|
|
348
|
-
this._headerNode = node;
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
this.addController(this._headerController);
|
|
352
|
-
|
|
353
|
-
this._messageController = new SlotController(this, '', 'div', {
|
|
354
|
-
// Allow providing multiple custom nodes in the default slot
|
|
355
|
-
multiple: true,
|
|
356
|
-
observe: false,
|
|
357
|
-
initializer: (node) => {
|
|
358
|
-
const wrapper = document.createElement('div');
|
|
359
|
-
wrapper.style.display = 'contents';
|
|
360
|
-
const wrapperId = `confirm-dialog-message-${generateUniqueId()}`;
|
|
361
|
-
wrapper.id = wrapperId;
|
|
362
|
-
wrapper.appendChild(node);
|
|
363
|
-
this.appendChild(wrapper);
|
|
364
|
-
setAriaIDReference(this._overlayElement, 'aria-describedby', { newId: wrapperId });
|
|
365
|
-
this._messageNodes = [...this._messageNodes, wrapper];
|
|
366
|
-
},
|
|
367
|
-
});
|
|
368
|
-
this.addController(this._messageController);
|
|
369
|
-
|
|
370
|
-
// NOTE: order in which buttons are added should match the order of slots in template
|
|
371
|
-
this._cancelController = new SlotController(this, 'cancel-button', 'vaadin-button', {
|
|
372
|
-
initializer: (button) => {
|
|
373
|
-
this.__setupSlottedButton('cancel', button);
|
|
374
|
-
},
|
|
375
|
-
});
|
|
376
|
-
this.addController(this._cancelController);
|
|
377
|
-
|
|
378
|
-
this._rejectController = new SlotController(this, 'reject-button', 'vaadin-button', {
|
|
379
|
-
initializer: (button) => {
|
|
380
|
-
this.__setupSlottedButton('reject', button);
|
|
381
|
-
},
|
|
382
|
-
});
|
|
383
|
-
this.addController(this._rejectController);
|
|
384
|
-
|
|
385
|
-
this._confirmController = new SlotController(this, 'confirm-button', 'vaadin-button', {
|
|
386
|
-
initializer: (button) => {
|
|
387
|
-
this.__setupSlottedButton('confirm', button);
|
|
388
|
-
},
|
|
389
|
-
});
|
|
390
|
-
this.addController(this._confirmController);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/** @private */
|
|
394
|
-
__accessibleDescriptionRefChanged(_overlayElement, accessibleDescriptionRef) {
|
|
395
|
-
if (!_overlayElement || (!accessibleDescriptionRef && !this.__oldAccessibleDescriptionRef)) {
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
setAriaIDReference(this._overlayElement, 'aria-describedby', {
|
|
399
|
-
newId: accessibleDescriptionRef,
|
|
400
|
-
oldId: this.__oldAccessibleDescriptionRef,
|
|
401
|
-
fromUser: true,
|
|
402
|
-
});
|
|
403
|
-
this.__oldAccessibleDescriptionRef = accessibleDescriptionRef;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/** @private */
|
|
407
|
-
__onDialogOpened() {
|
|
408
|
-
const overlay = this._overlayElement;
|
|
409
|
-
|
|
410
|
-
// Teleport slotted nodes to the overlay element.
|
|
411
|
-
this.__slottedNodes.forEach((node) => {
|
|
412
|
-
overlay.appendChild(node);
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
const confirmButton = overlay.querySelector('[slot="confirm-button"]');
|
|
416
|
-
if (confirmButton) {
|
|
417
|
-
confirmButton.focus();
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/** @private */
|
|
422
|
-
__onDialogClosed() {
|
|
423
|
-
// Move nodes from the overlay back to the host.
|
|
424
|
-
this.__slottedNodes.forEach((node) => {
|
|
425
|
-
this.appendChild(node);
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/** @private */
|
|
430
|
-
__setupSlottedButton(type, button) {
|
|
431
|
-
const property = `_${type}Button`;
|
|
432
|
-
const listener = `__${type}`;
|
|
433
|
-
|
|
434
|
-
if (this[property] && this[property] !== button) {
|
|
435
|
-
this[property].remove();
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
button.addEventListener('click', this[listener]);
|
|
439
|
-
this[property] = button;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/** @private */
|
|
443
|
-
__updateCancelButton(button, cancelText, cancelTheme, showCancel) {
|
|
444
|
-
if (button) {
|
|
445
|
-
if (button === this._cancelController.defaultNode) {
|
|
446
|
-
button.textContent = cancelText;
|
|
447
|
-
button.setAttribute('theme', cancelTheme);
|
|
448
|
-
}
|
|
449
|
-
button.toggleAttribute('hidden', !showCancel);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
/** @private */
|
|
454
|
-
__updateConfirmButton(button, confirmText, confirmTheme) {
|
|
455
|
-
if (button && button === this._confirmController.defaultNode) {
|
|
456
|
-
button.textContent = confirmText;
|
|
457
|
-
button.setAttribute('theme', confirmTheme);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/** @private */
|
|
462
|
-
__updateHeaderNode(headerNode, header) {
|
|
463
|
-
// Only update text content for the default header node.
|
|
464
|
-
if (headerNode && headerNode === this._headerController.defaultNode) {
|
|
465
|
-
headerNode.textContent = header;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
/** @private */
|
|
470
|
-
__updateMessageNodes(nodes, message) {
|
|
471
|
-
if (nodes && nodes.length > 0) {
|
|
472
|
-
const defaultWrapperNode = nodes.find(
|
|
473
|
-
(node) => this._messageController.defaultNode && node === this._messageController.defaultNode.parentElement,
|
|
474
|
-
);
|
|
475
|
-
if (defaultWrapperNode) {
|
|
476
|
-
defaultWrapperNode.firstChild.textContent = message;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
/** @private */
|
|
482
|
-
__updateRejectButton(button, rejectText, rejectTheme, showReject) {
|
|
483
|
-
if (button) {
|
|
484
|
-
if (button === this._rejectController.defaultNode) {
|
|
485
|
-
button.textContent = rejectText;
|
|
486
|
-
button.setAttribute('theme', rejectTheme);
|
|
487
|
-
}
|
|
488
|
-
button.toggleAttribute('hidden', !showReject);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
/** @private */
|
|
493
|
-
_escPressed(event) {
|
|
494
|
-
if (!event.defaultPrevented) {
|
|
495
|
-
this.__cancel();
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
/** @private */
|
|
500
|
-
__confirm() {
|
|
501
|
-
this.dispatchEvent(new CustomEvent('confirm'));
|
|
502
|
-
this.opened = false;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/** @private */
|
|
506
|
-
__cancel() {
|
|
507
|
-
this.dispatchEvent(new CustomEvent('cancel'));
|
|
508
|
-
this.opened = false;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
/** @private */
|
|
512
|
-
__reject() {
|
|
513
|
-
this.dispatchEvent(new CustomEvent('reject'));
|
|
514
|
-
this.opened = false;
|
|
515
|
-
}
|
|
516
111
|
|
|
517
|
-
|
|
518
|
-
_getAriaLabel(header) {
|
|
519
|
-
return header || 'confirmation';
|
|
112
|
+
this._initOverlay(this._overlayElement);
|
|
520
113
|
}
|
|
521
114
|
|
|
522
115
|
/**
|
|
@@ -535,6 +128,6 @@ class ConfirmDialog extends ElementMixin(ThemePropertyMixin(ControllerMixin(Poly
|
|
|
535
128
|
*/
|
|
536
129
|
}
|
|
537
130
|
|
|
538
|
-
|
|
131
|
+
defineCustomElement(ConfirmDialog);
|
|
539
132
|
|
|
540
133
|
export { ConfirmDialog };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import '@vaadin/button/theme/material/vaadin-button-styles.js';
|
|
1
2
|
import { dialogOverlay } from '@vaadin/dialog/theme/material/vaadin-dialog-styles.js';
|
|
2
3
|
import { overlay } from '@vaadin/vaadin-material-styles/mixins/overlay.js';
|
|
3
4
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|