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