@vaadin/confirm-dialog 24.0.0-alpha1 → 24.0.0-alpha11
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 +9 -9
- package/src/vaadin-confirm-dialog-overlay.js +65 -2
- package/src/vaadin-confirm-dialog.d.ts +17 -7
- package/src/vaadin-confirm-dialog.js +119 -161
- package/web-types.json +30 -8
- package/web-types.lit.json +12 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/confirm-dialog",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/button": "24.0.0-
|
|
40
|
-
"@vaadin/component-base": "24.0.0-
|
|
41
|
-
"@vaadin/dialog": "24.0.0-
|
|
42
|
-
"@vaadin/overlay": "24.0.0-
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
44
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
39
|
+
"@vaadin/button": "24.0.0-alpha11",
|
|
40
|
+
"@vaadin/component-base": "24.0.0-alpha11",
|
|
41
|
+
"@vaadin/dialog": "24.0.0-alpha11",
|
|
42
|
+
"@vaadin/overlay": "24.0.0-alpha11",
|
|
43
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha11",
|
|
44
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha11",
|
|
45
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha11"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"web-types.json",
|
|
54
54
|
"web-types.lit.json"
|
|
55
55
|
],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "641b3d96ceeb3e503a093682ebe686afdd8c3a68"
|
|
57
57
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2018 -
|
|
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
6
|
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
7
|
-
import { Dialog
|
|
7
|
+
import { Dialog } from '@vaadin/dialog/src/vaadin-dialog.js';
|
|
8
|
+
import { DialogOverlay } from '@vaadin/dialog/src/vaadin-dialog-overlay.js';
|
|
8
9
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
10
|
|
|
10
11
|
registerStyles(
|
|
@@ -142,6 +143,68 @@ class ConfirmDialogDialog extends Dialog {
|
|
|
142
143
|
></vaadin-confirm-dialog-overlay>
|
|
143
144
|
`;
|
|
144
145
|
}
|
|
146
|
+
|
|
147
|
+
static get properties() {
|
|
148
|
+
return {
|
|
149
|
+
/**
|
|
150
|
+
* Height to be set on the overlay content.
|
|
151
|
+
*/
|
|
152
|
+
contentHeight: {
|
|
153
|
+
type: String,
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Width to be set on the overlay content.
|
|
158
|
+
*/
|
|
159
|
+
contentWidth: {
|
|
160
|
+
type: String,
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
/** @private */
|
|
164
|
+
_overlayElement: {
|
|
165
|
+
type: Object,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
static get observers() {
|
|
171
|
+
return [
|
|
172
|
+
'__updateContentHeight(contentHeight, _overlayElement)',
|
|
173
|
+
'__updateContentWidth(contentWidth, _overlayElement)',
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** @protected */
|
|
178
|
+
ready() {
|
|
179
|
+
super.ready();
|
|
180
|
+
|
|
181
|
+
this._overlayElement = this.$.overlay;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** @private */
|
|
185
|
+
__updateDimension(overlay, dimension, value) {
|
|
186
|
+
const prop = `--_vaadin-confirm-dialog-content-${dimension}`;
|
|
187
|
+
|
|
188
|
+
if (value) {
|
|
189
|
+
overlay.style.setProperty(prop, value);
|
|
190
|
+
} else {
|
|
191
|
+
overlay.style.removeProperty(prop);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** @private */
|
|
196
|
+
__updateContentHeight(height, overlay) {
|
|
197
|
+
if (overlay) {
|
|
198
|
+
this.__updateDimension(overlay, 'height', height);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** @private */
|
|
203
|
+
__updateContentWidth(width, overlay) {
|
|
204
|
+
if (overlay) {
|
|
205
|
+
this.__updateDimension(overlay, 'width', width);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
145
208
|
}
|
|
146
209
|
|
|
147
210
|
customElements.define(ConfirmDialogDialog.is, ConfirmDialogDialog);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2018 -
|
|
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 { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
6
7
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
|
-
import { SlotMixin } from '@vaadin/component-base/src/slot-mixin.js';
|
|
8
8
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -28,7 +28,7 @@ export type ConfirmDialogEventMap = ConfirmDialogCustomEventMap & HTMLElementEve
|
|
|
28
28
|
* `<vaadin-confirm-dialog>` is a Web Component for showing alerts and asking for user confirmation.
|
|
29
29
|
*
|
|
30
30
|
* ```
|
|
31
|
-
* <vaadin-confirm-dialog cancel>
|
|
31
|
+
* <vaadin-confirm-dialog cancel-button-visible>
|
|
32
32
|
* There are unsaved changes. Do you really want to leave?
|
|
33
33
|
* </vaadin-confirm-dialog>
|
|
34
34
|
* ```
|
|
@@ -72,7 +72,7 @@ export type ConfirmDialogEventMap = ConfirmDialogCustomEventMap & HTMLElementEve
|
|
|
72
72
|
* @fires {Event} reject - Fired when Reject button was pressed.
|
|
73
73
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
74
74
|
*/
|
|
75
|
-
declare class ConfirmDialog extends
|
|
75
|
+
declare class ConfirmDialog extends ElementMixin(ThemePropertyMixin(ControllerMixin(HTMLElement))) {
|
|
76
76
|
/**
|
|
77
77
|
* True if the overlay is currently displayed.
|
|
78
78
|
*/
|
|
@@ -109,9 +109,10 @@ declare class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(HT
|
|
|
109
109
|
noCloseOnEsc: boolean;
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
|
-
* Whether to show
|
|
112
|
+
* Whether to show reject button or not.
|
|
113
|
+
* @attr {boolean} reject-button-visible
|
|
113
114
|
*/
|
|
114
|
-
|
|
115
|
+
rejectButtonVisible: boolean;
|
|
115
116
|
|
|
116
117
|
/**
|
|
117
118
|
* Text displayed on reject-button.
|
|
@@ -129,8 +130,9 @@ declare class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(HT
|
|
|
129
130
|
|
|
130
131
|
/**
|
|
131
132
|
* Whether to show cancel button or not.
|
|
133
|
+
* @attr {boolean} cancel-button-visible
|
|
132
134
|
*/
|
|
133
|
-
|
|
135
|
+
cancelButtonVisible: boolean;
|
|
134
136
|
|
|
135
137
|
/**
|
|
136
138
|
* Text displayed on cancel-button.
|
|
@@ -146,6 +148,14 @@ declare class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(HT
|
|
|
146
148
|
*/
|
|
147
149
|
cancelTheme: string;
|
|
148
150
|
|
|
151
|
+
/**
|
|
152
|
+
* A space-delimited list of CSS class names
|
|
153
|
+
* to set on the underlying overlay element.
|
|
154
|
+
*
|
|
155
|
+
* @attr {string} overlay-class
|
|
156
|
+
*/
|
|
157
|
+
overlayClass: string;
|
|
158
|
+
|
|
149
159
|
addEventListener<K extends keyof ConfirmDialogEventMap>(
|
|
150
160
|
type: K,
|
|
151
161
|
listener: (this: ConfirmDialog, ev: ConfirmDialogEventMap[K]) => void,
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2018 -
|
|
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
6
|
import './vaadin-confirm-dialog-overlay.js';
|
|
7
|
-
import { FlattenedNodesObserver } from '@polymer/polymer/lib/utils/flattened-nodes-observer.js';
|
|
8
7
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
8
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
9
9
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
10
|
-
import {
|
|
10
|
+
import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
|
|
11
11
|
import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* `<vaadin-confirm-dialog>` is a Web Component for showing alerts and asking for user confirmation.
|
|
15
15
|
*
|
|
16
16
|
* ```
|
|
17
|
-
* <vaadin-confirm-dialog cancel>
|
|
17
|
+
* <vaadin-confirm-dialog cancel-button-visible>
|
|
18
18
|
* There are unsaved changes. Do you really want to leave?
|
|
19
19
|
* </vaadin-confirm-dialog>
|
|
20
20
|
* ```
|
|
@@ -59,11 +59,11 @@ import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-p
|
|
|
59
59
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
60
60
|
*
|
|
61
61
|
* @extends HTMLElement
|
|
62
|
-
* @mixes
|
|
62
|
+
* @mixes ControllerMixin
|
|
63
63
|
* @mixes ElementMixin
|
|
64
64
|
* @mixes ThemePropertyMixin
|
|
65
65
|
*/
|
|
66
|
-
class ConfirmDialog extends
|
|
66
|
+
class ConfirmDialog extends ElementMixin(ThemePropertyMixin(ControllerMixin(PolymerElement))) {
|
|
67
67
|
static get template() {
|
|
68
68
|
return html`
|
|
69
69
|
<style>
|
|
@@ -76,10 +76,13 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
76
76
|
<vaadin-confirm-dialog-dialog
|
|
77
77
|
id="dialog"
|
|
78
78
|
opened="{{opened}}"
|
|
79
|
+
overlay-class="[[overlayClass]]"
|
|
79
80
|
aria-label="[[_getAriaLabel(header)]]"
|
|
80
81
|
theme$="[[_theme]]"
|
|
81
82
|
no-close-on-outside-click
|
|
82
83
|
no-close-on-esc="[[noCloseOnEsc]]"
|
|
84
|
+
content-height="[[_contentHeight]]"
|
|
85
|
+
content-width="[[_contentWidth]]"
|
|
83
86
|
></vaadin-confirm-dialog-dialog>
|
|
84
87
|
|
|
85
88
|
<div hidden>
|
|
@@ -158,10 +161,11 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
158
161
|
},
|
|
159
162
|
|
|
160
163
|
/**
|
|
161
|
-
* Whether to show
|
|
164
|
+
* Whether to show reject button or not.
|
|
165
|
+
* @attr {boolean} reject-button-visible
|
|
162
166
|
* @type {boolean}
|
|
163
167
|
*/
|
|
164
|
-
|
|
168
|
+
rejectButtonVisible: {
|
|
165
169
|
type: Boolean,
|
|
166
170
|
reflectToAttribute: true,
|
|
167
171
|
value: false,
|
|
@@ -191,9 +195,10 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
191
195
|
|
|
192
196
|
/**
|
|
193
197
|
* Whether to show cancel button or not.
|
|
198
|
+
* @attr {boolean} cancel-button-visible
|
|
194
199
|
* @type {boolean}
|
|
195
200
|
*/
|
|
196
|
-
|
|
201
|
+
cancelButtonVisible: {
|
|
197
202
|
type: Boolean,
|
|
198
203
|
reflectToAttribute: true,
|
|
199
204
|
value: false,
|
|
@@ -221,13 +226,22 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
221
226
|
value: 'tertiary',
|
|
222
227
|
},
|
|
223
228
|
|
|
229
|
+
/**
|
|
230
|
+
* A space-delimited list of CSS class names
|
|
231
|
+
* to set on the underlying overlay element.
|
|
232
|
+
*
|
|
233
|
+
* @attr {string} overlay-class
|
|
234
|
+
*/
|
|
235
|
+
overlayClass: {
|
|
236
|
+
type: String,
|
|
237
|
+
},
|
|
238
|
+
|
|
224
239
|
/**
|
|
225
240
|
* A reference to the "Cancel" button which will be teleported to the overlay.
|
|
226
241
|
* @private
|
|
227
242
|
*/
|
|
228
243
|
_cancelButton: {
|
|
229
|
-
type:
|
|
230
|
-
observer: '_cancelButtonChanged',
|
|
244
|
+
type: Object,
|
|
231
245
|
},
|
|
232
246
|
|
|
233
247
|
/**
|
|
@@ -235,8 +249,7 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
235
249
|
* @private
|
|
236
250
|
*/
|
|
237
251
|
_confirmButton: {
|
|
238
|
-
type:
|
|
239
|
-
observer: '_confirmButtonChanged',
|
|
252
|
+
type: Object,
|
|
240
253
|
},
|
|
241
254
|
|
|
242
255
|
/**
|
|
@@ -244,15 +257,16 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
244
257
|
* @private
|
|
245
258
|
*/
|
|
246
259
|
_headerNode: {
|
|
247
|
-
type:
|
|
260
|
+
type: Object,
|
|
248
261
|
},
|
|
249
262
|
|
|
250
263
|
/**
|
|
251
|
-
* A
|
|
264
|
+
* A list of message nodes which will be placed in the overlay default slot.
|
|
252
265
|
* @private
|
|
253
266
|
*/
|
|
254
|
-
|
|
255
|
-
type:
|
|
267
|
+
_messageNodes: {
|
|
268
|
+
type: Array,
|
|
269
|
+
value: () => [],
|
|
256
270
|
},
|
|
257
271
|
|
|
258
272
|
/**
|
|
@@ -260,8 +274,23 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
260
274
|
* @private
|
|
261
275
|
*/
|
|
262
276
|
_rejectButton: {
|
|
263
|
-
type:
|
|
264
|
-
|
|
277
|
+
type: Object,
|
|
278
|
+
},
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Height to be set on the overlay content.
|
|
282
|
+
* @protected
|
|
283
|
+
*/
|
|
284
|
+
_contentHeight: {
|
|
285
|
+
type: String,
|
|
286
|
+
},
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Width to be set on the overlay content.
|
|
290
|
+
* @protected
|
|
291
|
+
*/
|
|
292
|
+
_contentWidth: {
|
|
293
|
+
type: String,
|
|
265
294
|
},
|
|
266
295
|
};
|
|
267
296
|
}
|
|
@@ -269,76 +298,72 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
269
298
|
static get observers() {
|
|
270
299
|
return [
|
|
271
300
|
'__updateConfirmButton(_confirmButton, confirmText, confirmTheme)',
|
|
272
|
-
'__updateCancelButton(_cancelButton, cancelText, cancelTheme,
|
|
301
|
+
'__updateCancelButton(_cancelButton, cancelText, cancelTheme, cancelButtonVisible)',
|
|
273
302
|
'__updateHeaderNode(_headerNode, header)',
|
|
274
|
-
'
|
|
275
|
-
'__updateRejectButton(_rejectButton, rejectText, rejectTheme,
|
|
303
|
+
'__updateMessageNodes(_messageNodes, message)',
|
|
304
|
+
'__updateRejectButton(_rejectButton, rejectText, rejectTheme, rejectButtonVisible)',
|
|
276
305
|
];
|
|
277
306
|
}
|
|
278
307
|
|
|
279
|
-
/** @protected */
|
|
280
|
-
get slots() {
|
|
281
|
-
// NOTE: order in which slots are listed matches the template.
|
|
282
|
-
return {
|
|
283
|
-
...super.slots,
|
|
284
|
-
header: () => {
|
|
285
|
-
const h3 = document.createElement('h3');
|
|
286
|
-
this.__defaultHeader = h3;
|
|
287
|
-
return h3;
|
|
288
|
-
},
|
|
289
|
-
'': () => {
|
|
290
|
-
const div = document.createElement('div');
|
|
291
|
-
this.__defaultMessage = div;
|
|
292
|
-
return div;
|
|
293
|
-
},
|
|
294
|
-
'cancel-button': () => {
|
|
295
|
-
const button = document.createElement('vaadin-button');
|
|
296
|
-
button.setAttribute('theme', this.cancelTheme);
|
|
297
|
-
button.textContent = this.cancelText;
|
|
298
|
-
button._isDefaultButton = true;
|
|
299
|
-
return button;
|
|
300
|
-
},
|
|
301
|
-
'reject-button': () => {
|
|
302
|
-
const button = document.createElement('vaadin-button');
|
|
303
|
-
button.setAttribute('theme', this.rejectTheme);
|
|
304
|
-
button.textContent = this.rejectText;
|
|
305
|
-
button._isDefaultButton = true;
|
|
306
|
-
return button;
|
|
307
|
-
},
|
|
308
|
-
'confirm-button': () => {
|
|
309
|
-
const button = document.createElement('vaadin-button');
|
|
310
|
-
button._isDefaultButton = true;
|
|
311
|
-
return button;
|
|
312
|
-
},
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
|
|
316
308
|
constructor() {
|
|
317
309
|
super();
|
|
318
|
-
|
|
319
|
-
this.
|
|
320
|
-
|
|
321
|
-
|
|
310
|
+
|
|
311
|
+
this.__cancel = this.__cancel.bind(this);
|
|
312
|
+
this.__confirm = this.__confirm.bind(this);
|
|
313
|
+
this.__reject = this.__reject.bind(this);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
get __slottedNodes() {
|
|
317
|
+
return [this._headerNode, ...this._messageNodes, this._cancelButton, this._confirmButton, this._rejectButton];
|
|
322
318
|
}
|
|
323
319
|
|
|
324
320
|
/** @protected */
|
|
325
321
|
ready() {
|
|
326
322
|
super.ready();
|
|
327
323
|
|
|
328
|
-
this.__boundCancel = this._cancel.bind(this);
|
|
329
|
-
this.__boundConfirm = this._confirm.bind(this);
|
|
330
|
-
this.__boundReject = this._reject.bind(this);
|
|
331
|
-
|
|
332
324
|
this._overlayElement = this.$.dialog.$.overlay;
|
|
333
325
|
this._overlayElement.addEventListener('vaadin-overlay-escape-press', this._escPressed.bind(this));
|
|
334
326
|
this._overlayElement.addEventListener('vaadin-overlay-open', () => this.__onDialogOpened());
|
|
335
327
|
this._overlayElement.addEventListener('vaadin-confirm-dialog-close', () => this.__onDialogClosed());
|
|
336
328
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
this.
|
|
340
|
-
}
|
|
341
|
-
}
|
|
329
|
+
this._headerController = new SlotController(this, 'header', 'h3', {
|
|
330
|
+
initializer: (node) => {
|
|
331
|
+
this._headerNode = node;
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
this.addController(this._headerController);
|
|
335
|
+
|
|
336
|
+
this._messageController = new SlotController(this, '', 'div', {
|
|
337
|
+
// Allow providing multiple custom nodes in the default slot
|
|
338
|
+
multiple: true,
|
|
339
|
+
observe: false,
|
|
340
|
+
initializer: (node) => {
|
|
341
|
+
this._messageNodes = [...this._messageNodes, node];
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
this.addController(this._messageController);
|
|
345
|
+
|
|
346
|
+
// NOTE: order in which buttons are added should match the order of slots in template
|
|
347
|
+
this._cancelController = new SlotController(this, 'cancel-button', 'vaadin-button', {
|
|
348
|
+
initializer: (button) => {
|
|
349
|
+
this.__setupSlottedButton('cancel', button);
|
|
350
|
+
},
|
|
351
|
+
});
|
|
352
|
+
this.addController(this._cancelController);
|
|
353
|
+
|
|
354
|
+
this._rejectController = new SlotController(this, 'reject-button', 'vaadin-button', {
|
|
355
|
+
initializer: (button) => {
|
|
356
|
+
this.__setupSlottedButton('reject', button);
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
this.addController(this._rejectController);
|
|
360
|
+
|
|
361
|
+
this._confirmController = new SlotController(this, 'confirm-button', 'vaadin-button', {
|
|
362
|
+
initializer: (button) => {
|
|
363
|
+
this.__setupSlottedButton('confirm', button);
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
this.addController(this._confirmController);
|
|
342
367
|
}
|
|
343
368
|
|
|
344
369
|
/** @private */
|
|
@@ -358,73 +383,29 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
358
383
|
|
|
359
384
|
/** @private */
|
|
360
385
|
__onDialogClosed() {
|
|
361
|
-
const nodes = this.__slottedNodes;
|
|
362
|
-
|
|
363
|
-
// Reset the list of nodes, it will be re-created.
|
|
364
|
-
this.__slottedNodes = [];
|
|
365
|
-
|
|
366
386
|
// Move nodes from the overlay back to the host.
|
|
367
|
-
|
|
387
|
+
this.__slottedNodes.forEach((node) => {
|
|
368
388
|
this.appendChild(node);
|
|
369
389
|
});
|
|
370
390
|
}
|
|
371
391
|
|
|
372
392
|
/** @private */
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
addedNodes.forEach((node) => {
|
|
377
|
-
this.__slottedNodes.push(node);
|
|
378
|
-
|
|
379
|
-
const isElementNode = node.nodeType === Node.ELEMENT_NODE;
|
|
380
|
-
const slotName = isElementNode ? node.getAttribute('slot') : '';
|
|
381
|
-
|
|
382
|
-
// Handle named slots (header and buttons).
|
|
383
|
-
if (slotName) {
|
|
384
|
-
if (slotName.indexOf('button') >= 0) {
|
|
385
|
-
const [button] = slotName.split('-');
|
|
386
|
-
this[`_${button}Button`] = node;
|
|
387
|
-
} else if (slotName === 'header') {
|
|
388
|
-
this._headerNode = node;
|
|
389
|
-
}
|
|
390
|
-
} else {
|
|
391
|
-
const isNotEmptyText = node.nodeType === Node.TEXT_NODE && node.textContent.trim() !== '';
|
|
392
|
-
// Handle default slot (message element).
|
|
393
|
-
if (isNotEmptyText || (isElementNode && node.slot === '')) {
|
|
394
|
-
this._messageNode = node;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
/** @private */
|
|
401
|
-
_cancelButtonChanged(button, oldButton) {
|
|
402
|
-
this.__setupSlottedButton(button, oldButton, this.__boundCancel);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/** @private */
|
|
406
|
-
_confirmButtonChanged(button, oldButton) {
|
|
407
|
-
this.__setupSlottedButton(button, oldButton, this.__boundConfirm);
|
|
408
|
-
}
|
|
393
|
+
__setupSlottedButton(type, button) {
|
|
394
|
+
const property = `_${type}Button`;
|
|
395
|
+
const listener = `__${type}`;
|
|
409
396
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
this.__setupSlottedButton(button, oldButton, this.__boundReject);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/** @private */
|
|
416
|
-
__setupSlottedButton(slottedButton, currentButton, clickListener) {
|
|
417
|
-
if (currentButton && currentButton.parentElement) {
|
|
418
|
-
currentButton.remove();
|
|
397
|
+
if (this[property] && this[property] !== button) {
|
|
398
|
+
this[property].remove();
|
|
419
399
|
}
|
|
420
400
|
|
|
421
|
-
|
|
401
|
+
button.addEventListener('click', this[listener]);
|
|
402
|
+
this[property] = button;
|
|
422
403
|
}
|
|
423
404
|
|
|
424
405
|
/** @private */
|
|
425
406
|
__updateCancelButton(button, cancelText, cancelTheme, showCancel) {
|
|
426
407
|
if (button) {
|
|
427
|
-
if (button.
|
|
408
|
+
if (button === this._cancelController.defaultNode) {
|
|
428
409
|
button.textContent = cancelText;
|
|
429
410
|
button.setAttribute('theme', cancelTheme);
|
|
430
411
|
}
|
|
@@ -434,7 +415,7 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
434
415
|
|
|
435
416
|
/** @private */
|
|
436
417
|
__updateConfirmButton(button, confirmText, confirmTheme) {
|
|
437
|
-
if (button && button.
|
|
418
|
+
if (button && button === this._confirmController.defaultNode) {
|
|
438
419
|
button.textContent = confirmText;
|
|
439
420
|
button.setAttribute('theme', confirmTheme);
|
|
440
421
|
}
|
|
@@ -443,23 +424,25 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
443
424
|
/** @private */
|
|
444
425
|
__updateHeaderNode(headerNode, header) {
|
|
445
426
|
// Only update text content for the default header node.
|
|
446
|
-
if (headerNode && headerNode === this.
|
|
427
|
+
if (headerNode && headerNode === this._headerController.defaultNode) {
|
|
447
428
|
headerNode.textContent = header;
|
|
448
429
|
}
|
|
449
430
|
}
|
|
450
431
|
|
|
451
432
|
/** @private */
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
433
|
+
__updateMessageNodes(nodes, message) {
|
|
434
|
+
if (nodes && nodes.length > 0) {
|
|
435
|
+
const defaultNode = nodes.find((node) => node === this._messageController.defaultNode);
|
|
436
|
+
if (defaultNode) {
|
|
437
|
+
defaultNode.textContent = message;
|
|
438
|
+
}
|
|
456
439
|
}
|
|
457
440
|
}
|
|
458
441
|
|
|
459
442
|
/** @private */
|
|
460
443
|
__updateRejectButton(button, rejectText, rejectTheme, showReject) {
|
|
461
444
|
if (button) {
|
|
462
|
-
if (button.
|
|
445
|
+
if (button === this._rejectController.defaultNode) {
|
|
463
446
|
button.textContent = rejectText;
|
|
464
447
|
button.setAttribute('theme', rejectTheme);
|
|
465
448
|
}
|
|
@@ -470,24 +453,24 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
470
453
|
/** @private */
|
|
471
454
|
_escPressed(event) {
|
|
472
455
|
if (!event.defaultPrevented) {
|
|
473
|
-
this.
|
|
456
|
+
this.__cancel();
|
|
474
457
|
}
|
|
475
458
|
}
|
|
476
459
|
|
|
477
460
|
/** @private */
|
|
478
|
-
|
|
461
|
+
__confirm() {
|
|
479
462
|
this.dispatchEvent(new CustomEvent('confirm'));
|
|
480
463
|
this.opened = false;
|
|
481
464
|
}
|
|
482
465
|
|
|
483
466
|
/** @private */
|
|
484
|
-
|
|
467
|
+
__cancel() {
|
|
485
468
|
this.dispatchEvent(new CustomEvent('cancel'));
|
|
486
469
|
this.opened = false;
|
|
487
470
|
}
|
|
488
471
|
|
|
489
472
|
/** @private */
|
|
490
|
-
|
|
473
|
+
__reject() {
|
|
491
474
|
this.dispatchEvent(new CustomEvent('reject'));
|
|
492
475
|
this.opened = false;
|
|
493
476
|
}
|
|
@@ -497,31 +480,6 @@ class ConfirmDialog extends SlotMixin(ElementMixin(ThemePropertyMixin(PolymerEle
|
|
|
497
480
|
return header || 'confirmation';
|
|
498
481
|
}
|
|
499
482
|
|
|
500
|
-
/** @private */
|
|
501
|
-
_setWidth(width) {
|
|
502
|
-
this._setDimensionIfAttached('width', width);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
/** @private */
|
|
506
|
-
_setHeight(height) {
|
|
507
|
-
this._setDimensionIfAttached('height', height);
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
/** @private */
|
|
511
|
-
_setDimensionIfAttached(name, value) {
|
|
512
|
-
if (this._overlayElement) {
|
|
513
|
-
this._setDimension(name, value);
|
|
514
|
-
} else {
|
|
515
|
-
this._dimensions = this._dimensions || {};
|
|
516
|
-
this._dimensions[name] = value;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/** @private */
|
|
521
|
-
_setDimension(name, value) {
|
|
522
|
-
this._overlayElement.style.setProperty(`--_vaadin-confirm-dialog-content-${name}`, value);
|
|
523
|
-
}
|
|
524
|
-
|
|
525
483
|
/**
|
|
526
484
|
* @event confirm
|
|
527
485
|
* fired when Confirm button was pressed.
|
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.0.0-
|
|
4
|
+
"version": "24.0.0-alpha11",
|
|
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>\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.0.0-
|
|
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.0.0-alpha11/#/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/custom-theme/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": "opened",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
|
-
"name": "reject",
|
|
71
|
-
"description": "Whether to show
|
|
70
|
+
"name": "reject-button-visible",
|
|
71
|
+
"description": "Whether to show reject button or not.",
|
|
72
72
|
"value": {
|
|
73
73
|
"type": [
|
|
74
74
|
"boolean"
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
|
-
"name": "cancel",
|
|
97
|
+
"name": "cancel-button-visible",
|
|
98
98
|
"description": "Whether to show cancel button or not.",
|
|
99
99
|
"value": {
|
|
100
100
|
"type": [
|
|
@@ -120,6 +120,17 @@
|
|
|
120
120
|
]
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
+
{
|
|
124
|
+
"name": "overlay-class",
|
|
125
|
+
"description": "A space-delimited list of CSS class names\nto set on the underlying overlay element.",
|
|
126
|
+
"value": {
|
|
127
|
+
"type": [
|
|
128
|
+
"string",
|
|
129
|
+
"null",
|
|
130
|
+
"undefined"
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
},
|
|
123
134
|
{
|
|
124
135
|
"name": "theme",
|
|
125
136
|
"description": "The theme variants to apply to the component.",
|
|
@@ -191,8 +202,8 @@
|
|
|
191
202
|
}
|
|
192
203
|
},
|
|
193
204
|
{
|
|
194
|
-
"name": "
|
|
195
|
-
"description": "Whether to show
|
|
205
|
+
"name": "rejectButtonVisible",
|
|
206
|
+
"description": "Whether to show reject button or not.",
|
|
196
207
|
"value": {
|
|
197
208
|
"type": [
|
|
198
209
|
"boolean"
|
|
@@ -218,7 +229,7 @@
|
|
|
218
229
|
}
|
|
219
230
|
},
|
|
220
231
|
{
|
|
221
|
-
"name": "
|
|
232
|
+
"name": "cancelButtonVisible",
|
|
222
233
|
"description": "Whether to show cancel button or not.",
|
|
223
234
|
"value": {
|
|
224
235
|
"type": [
|
|
@@ -243,6 +254,17 @@
|
|
|
243
254
|
"string"
|
|
244
255
|
]
|
|
245
256
|
}
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"name": "overlayClass",
|
|
260
|
+
"description": "A space-delimited list of CSS class names\nto set on the underlying overlay element.",
|
|
261
|
+
"value": {
|
|
262
|
+
"type": [
|
|
263
|
+
"string",
|
|
264
|
+
"null",
|
|
265
|
+
"undefined"
|
|
266
|
+
]
|
|
267
|
+
}
|
|
246
268
|
}
|
|
247
269
|
],
|
|
248
270
|
"events": [
|
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.0.0-
|
|
4
|
+
"version": "24.0.0-alpha11",
|
|
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>\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.0.0-
|
|
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.0.0-alpha11/#/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/custom-theme/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
|
{
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
|
-
"name": "?
|
|
38
|
-
"description": "Whether to show
|
|
37
|
+
"name": "?rejectButtonVisible",
|
|
38
|
+
"description": "Whether to show reject button or not.",
|
|
39
39
|
"value": {
|
|
40
40
|
"kind": "expression"
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
|
-
"name": "?
|
|
44
|
+
"name": "?cancelButtonVisible",
|
|
45
45
|
"description": "Whether to show cancel button or not.",
|
|
46
46
|
"value": {
|
|
47
47
|
"kind": "expression"
|
|
@@ -103,6 +103,13 @@
|
|
|
103
103
|
"kind": "expression"
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
|
+
{
|
|
107
|
+
"name": ".overlayClass",
|
|
108
|
+
"description": "A space-delimited list of CSS class names\nto set on the underlying overlay element.",
|
|
109
|
+
"value": {
|
|
110
|
+
"kind": "expression"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
106
113
|
{
|
|
107
114
|
"name": "@cancel",
|
|
108
115
|
"description": "cancel\nfired when Cancel button or Escape key was pressed.",
|