@vaadin/confirm-dialog 25.0.0-alpha7 → 25.0.0-alpha8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/confirm-dialog",
3
- "version": "25.0.0-alpha7",
3
+ "version": "25.0.0-alpha8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,18 +37,18 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@open-wc/dedupe-mixin": "^1.3.0",
40
- "@vaadin/button": "25.0.0-alpha7",
41
- "@vaadin/component-base": "25.0.0-alpha7",
42
- "@vaadin/dialog": "25.0.0-alpha7",
43
- "@vaadin/overlay": "25.0.0-alpha7",
44
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha7",
45
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha7",
40
+ "@vaadin/button": "25.0.0-alpha8",
41
+ "@vaadin/component-base": "25.0.0-alpha8",
42
+ "@vaadin/dialog": "25.0.0-alpha8",
43
+ "@vaadin/overlay": "25.0.0-alpha8",
44
+ "@vaadin/vaadin-lumo-styles": "25.0.0-alpha8",
45
+ "@vaadin/vaadin-themable-mixin": "25.0.0-alpha8",
46
46
  "lit": "^3.0.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@vaadin/a11y-base": "25.0.0-alpha7",
50
- "@vaadin/chai-plugins": "25.0.0-alpha7",
51
- "@vaadin/test-runner-commands": "25.0.0-alpha7",
49
+ "@vaadin/a11y-base": "25.0.0-alpha8",
50
+ "@vaadin/chai-plugins": "25.0.0-alpha8",
51
+ "@vaadin/test-runner-commands": "25.0.0-alpha8",
52
52
  "@vaadin/testing-helpers": "^2.0.0",
53
53
  "sinon": "^18.0.0"
54
54
  },
@@ -56,5 +56,5 @@
56
56
  "web-types.json",
57
57
  "web-types.lit.json"
58
58
  ],
59
- "gitHead": "87f72707ce6866892f8be5782fa0da008e87dcbc"
59
+ "gitHead": "ebf53673d5f639d2b1b6f2b31f640f530643ee2f"
60
60
  }
@@ -8,38 +8,36 @@ import { dialogOverlayBase } from '@vaadin/dialog/src/styles/vaadin-dialog-overl
8
8
  import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-base-styles.js';
9
9
 
10
10
  const confirmDialogOverlay = css`
11
- @layer base {
12
- :host {
13
- --vaadin-dialog-min-width: var(--vaadin-confirm-dialog-min-width, 15em);
14
- --vaadin-dialog-max-width: var(--vaadin-confirm-dialog-max-width, 25em);
15
- }
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
+ }
16
15
 
17
- ::slotted([slot='header']) {
18
- display: contents;
19
- font: inherit !important;
20
- color: inherit !important;
21
- }
16
+ ::slotted([slot='header']) {
17
+ display: contents;
18
+ font: inherit !important;
19
+ color: inherit !important;
20
+ }
22
21
 
23
- [part='header'] {
24
- color: var(--vaadin-dialog-title-color, var(--vaadin-color));
25
- font-weight: var(--vaadin-dialog-title-font-weight, 600);
26
- font-size: var(--vaadin-dialog-title-font-size, 1em);
27
- line-height: var(--vaadin-dialog-title-line-height, inherit);
28
- }
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
+ }
29
28
 
30
- [part='overlay'] {
31
- display: flex;
32
- flex-direction: column;
33
- }
29
+ [part='overlay'] {
30
+ display: flex;
31
+ flex-direction: column;
32
+ }
34
33
 
35
- [part='content'] {
36
- flex: 1;
37
- }
34
+ [part='content'] {
35
+ flex: 1;
36
+ }
38
37
 
39
- /* TODO remove this wrapper element */
40
- #resizerContainer {
41
- display: contents;
42
- }
38
+ /* TODO remove this wrapper element */
39
+ #resizerContainer {
40
+ display: contents;
43
41
  }
44
42
  `;
45
43
 
@@ -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 are linked
41
- * through the `aria-describedby` attribute. However, there are
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,24 +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
-
133
- /**
134
- * Set the width of the overlay.
135
- * If a unitless number is provided, pixels are assumed.
136
- */
137
- width: string | null;
138
-
139
- /**
140
- * Set the height of the overlay.
141
- * If a unitless number is provided, pixels are assumed.
142
- */
143
- height: string | null;
144
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 { generateUniqueId } from '@vaadin/component-base/src/unique-id-utils.js';
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 are linked
21
- * through the `aria-describedby` attribute. However, there are
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,32 +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
- /**
168
- * Set the height of the overlay.
169
- * If a unitless number is provided, pixels are assumed.
170
- */
171
- height: {
172
- type: String,
173
- },
174
-
175
- /**
176
- * Set the width of the overlay.
177
- * If a unitless number is provided, pixels are assumed.
178
- */
179
- width: {
180
- type: String,
181
- },
182
-
183
161
  /**
184
162
  * A reference to the "Cancel" button which will be teleported to the overlay.
185
163
  * @private
@@ -213,15 +191,6 @@ export const ConfirmDialogMixin = (superClass) =>
213
191
  value: () => [],
214
192
  },
215
193
 
216
- /**
217
- * A reference to the overlay element.
218
- * @private
219
- */
220
- _overlayElement: {
221
- type: Object,
222
- sync: true,
223
- },
224
-
225
194
  /**
226
195
  * A reference to the "Reject" button which will be teleported to the overlay.
227
196
  * @private
@@ -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(_overlayElement, _messageNodes, accessibleDescriptionRef)',
211
+ '__accessibleDescriptionRefChanged(_messageNodes, accessibleDescriptionRef)',
243
212
  ];
244
213
  }
245
214
 
@@ -255,10 +224,35 @@ export const ConfirmDialogMixin = (superClass) =>
255
224
  return [this._headerNode, ...this._messageNodes, this._cancelButton, this._confirmButton, this._rejectButton];
256
225
  }
257
226
 
227
+ /** @protected */
228
+ connectedCallback() {
229
+ super.connectedCallback();
230
+ // Restore opened state if overlay was opened when disconnecting
231
+ if (this.__restoreOpened) {
232
+ this.opened = true;
233
+ }
234
+ }
235
+
236
+ /** @protected */
237
+ disconnectedCallback() {
238
+ super.disconnectedCallback();
239
+ // Automatically close the overlay when dialog is removed from DOM
240
+ // Using a timeout to avoid toggling opened state, and dispatching change
241
+ // events, when just moving the dialog in the DOM
242
+ setTimeout(() => {
243
+ if (!this.isConnected) {
244
+ this.__restoreOpened = this.opened;
245
+ this.opened = false;
246
+ }
247
+ });
248
+ }
249
+
258
250
  /** @protected */
259
251
  ready() {
260
252
  super.ready();
261
253
 
254
+ this.role = 'alertdialog';
255
+
262
256
  this._headerController = new SlotController(this, 'header', 'h3', {
263
257
  initializer: (node) => {
264
258
  this._headerNode = node;
@@ -271,13 +265,7 @@ export const ConfirmDialogMixin = (superClass) =>
271
265
  multiple: true,
272
266
  observe: false,
273
267
  initializer: (node) => {
274
- const wrapper = document.createElement('div');
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];
268
+ this._messageNodes = [...this._messageNodes, node];
281
269
  },
282
270
  });
283
271
  this.addController(this._messageController);
@@ -304,59 +292,47 @@ export const ConfirmDialogMixin = (superClass) =>
304
292
  });
305
293
  this.addController(this._confirmController);
306
294
 
307
- this._overlayElement = this.$.dialog.$.overlay;
308
-
309
- this._initOverlay(this._overlayElement);
295
+ this._overlayElement = this.$.overlay;
310
296
  }
311
297
 
312
298
  /** @protected */
313
- _initOverlay(overlay) {
314
- overlay.addEventListener('vaadin-overlay-escape-press', this._escPressed.bind(this));
315
- overlay.addEventListener('vaadin-overlay-open', () => this.__onDialogOpened());
316
- overlay.addEventListener('vaadin-overlay-closed', () => this.__onDialogClosed());
317
- overlay.setAttribute('role', 'alertdialog');
299
+ updated(props) {
300
+ super.updated(props);
301
+
302
+ if (props.has('header')) {
303
+ this.ariaLabel = this.header || 'confirmation';
304
+ }
318
305
  }
319
306
 
320
- /** @private */
307
+ /** @protected */
321
308
  __onDialogOpened() {
322
- const overlay = this._overlayElement;
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();
309
+ if (this._confirmButton) {
310
+ this._confirmButton.focus();
332
311
  }
333
312
  }
334
313
 
335
- /** @private */
314
+ /** @protected */
336
315
  __onDialogClosed() {
337
- // Move nodes from the overlay back to the host.
338
- this.__slottedNodes.forEach((node) => {
339
- this.appendChild(node);
340
- });
341
316
  this.dispatchEvent(new CustomEvent('closed'));
342
317
  }
343
318
 
344
319
  /** @private */
345
- __accessibleDescriptionRefChanged(overlay, messageNodes, accessibleDescriptionRef) {
346
- if (!overlay || !messageNodes) {
320
+ __accessibleDescriptionRefChanged(messageNodes, accessibleDescriptionRef) {
321
+ if (!messageNodes) {
347
322
  return;
348
323
  }
349
324
 
350
- if (accessibleDescriptionRef !== undefined) {
351
- setAriaIDReference(overlay, 'aria-describedby', {
325
+ if (accessibleDescriptionRef) {
326
+ this.removeAttribute('aria-description');
327
+ setAriaIDReference(this, 'aria-describedby', {
352
328
  newId: accessibleDescriptionRef,
353
329
  oldId: this.__oldAccessibleDescriptionRef,
354
330
  fromUser: true,
355
331
  });
356
332
  } else {
357
- messageNodes.forEach((node) => {
358
- setAriaIDReference(overlay, 'aria-describedby', { newId: node.id });
359
- });
333
+ this.removeAttribute('aria-describedby');
334
+ const ariaDescription = messageNodes.map((node) => node.textContent.trim()).join(' ');
335
+ this.setAttribute('aria-description', ariaDescription);
360
336
  }
361
337
 
362
338
  this.__oldAccessibleDescriptionRef = accessibleDescriptionRef;
@@ -405,11 +381,9 @@ export const ConfirmDialogMixin = (superClass) =>
405
381
  /** @private */
406
382
  __updateMessageNodes(nodes, message) {
407
383
  if (nodes && nodes.length > 0) {
408
- const defaultWrapperNode = nodes.find(
409
- (node) => this._messageController.defaultNode && node === this._messageController.defaultNode.parentElement,
410
- );
411
- if (defaultWrapperNode) {
412
- defaultWrapperNode.firstChild.textContent = message;
384
+ const defaultNode = nodes.find((node) => node === this._messageController.defaultNode);
385
+ if (defaultNode) {
386
+ defaultNode.textContent = message;
413
387
  }
414
388
  }
415
389
  }
@@ -425,13 +399,20 @@ export const ConfirmDialogMixin = (superClass) =>
425
399
  }
426
400
  }
427
401
 
428
- /** @private */
429
- _escPressed(event) {
430
- if (!event.defaultPrevented) {
402
+ /** @protected */
403
+ _onOverlayEscapePress(event) {
404
+ if (this.noCloseOnEsc) {
405
+ event.preventDefault();
406
+ } else {
431
407
  this.__cancel();
432
408
  }
433
409
  }
434
410
 
411
+ /** @protected */
412
+ _onOverlayOutsideClick(event) {
413
+ event.preventDefault();
414
+ }
415
+
435
416
  /** @private */
436
417
  __confirm() {
437
418
  this.dispatchEvent(new CustomEvent('confirm'));
@@ -450,11 +431,6 @@ export const ConfirmDialogMixin = (superClass) =>
450
431
  this.opened = false;
451
432
  }
452
433
 
453
- /** @private */
454
- _getAriaLabel(header) {
455
- return header || 'confirmation';
456
- }
457
-
458
434
  /**
459
435
  * Fired when the confirm dialog is closed.
460
436
  *
@@ -3,17 +3,13 @@
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 { css, html, LitElement } from 'lit';
7
- import { ifDefined } from 'lit/directives/if-defined.js';
6
+ import { html, LitElement } from 'lit';
8
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
9
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
10
- import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
11
9
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
12
- import { DialogBaseMixin } from '@vaadin/dialog/src/vaadin-dialog-base-mixin.js';
13
10
  import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
14
11
  import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
15
12
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
16
- import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
17
13
  import { confirmDialogOverlayStyles } from './styles/vaadin-confirm-dialog-overlay-core-styles.js';
18
14
 
19
15
  /**
@@ -26,7 +22,7 @@ import { confirmDialogOverlayStyles } from './styles/vaadin-confirm-dialog-overl
26
22
  * @mixes ThemableMixin
27
23
  * @private
28
24
  */
29
- class ConfirmDialogOverlay extends OverlayMixin(DirMixin(ThemableMixin(LumoInjectionMixin(PolylitMixin(LitElement))))) {
25
+ class ConfirmDialogOverlay extends OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))) {
30
26
  static get is() {
31
27
  return 'vaadin-confirm-dialog-overlay';
32
28
  }
@@ -86,71 +82,40 @@ class ConfirmDialogOverlay extends OverlayMixin(DirMixin(ThemableMixin(LumoInjec
86
82
  this.setAttribute('has-header', '');
87
83
  this.setAttribute('has-footer', '');
88
84
  }
89
- }
90
-
91
- defineCustomElement(ConfirmDialogOverlay);
92
85
 
93
- /**
94
- * An element used internally by `<vaadin-confirm-dialog>`. Not intended to be used separately.
95
- * @private
96
- */
97
- class ConfirmDialogDialog extends DialogBaseMixin(OverlayClassMixin(ThemePropertyMixin(PolylitMixin(LitElement)))) {
98
- static get is() {
99
- return 'vaadin-confirm-dialog-dialog';
86
+ /**
87
+ * @protected
88
+ * @override
89
+ */
90
+ _attachOverlay() {
91
+ this.showPopover();
100
92
  }
101
93
 
102
- static get styles() {
103
- return css`
104
- :host {
105
- display: none;
106
- }
107
- `;
94
+ /**
95
+ * @protected
96
+ * @override
97
+ */
98
+ _detachOverlay() {
99
+ this.hidePopover();
108
100
  }
109
101
 
110
- static get properties() {
111
- return {
112
- /**
113
- * Set the `aria-label` attribute for assistive technologies like
114
- * screen readers. An empty string value for this property (the
115
- * default) means that the `aria-label` attribute is not present.
116
- */
117
- ariaLabel: {
118
- type: String,
119
- value: '',
120
- },
121
-
122
- cancelButtonVisible: {
123
- type: Boolean,
124
- },
125
-
126
- rejectButtonVisible: {
127
- type: Boolean,
128
- },
129
- };
102
+ /**
103
+ * Override method from OverlayFocusMixin to use owner as content root
104
+ * @protected
105
+ * @override
106
+ */
107
+ get _contentRoot() {
108
+ return this.owner;
130
109
  }
131
110
 
132
- /** @protected */
133
- render() {
134
- return html`
135
- <vaadin-confirm-dialog-overlay
136
- id="overlay"
137
- .owner="${this}"
138
- .opened="${this.opened}"
139
- @opened-changed="${this._onOverlayOpened}"
140
- @mousedown="${this._bringOverlayToFront}"
141
- @touchstart="${this._bringOverlayToFront}"
142
- theme="${ifDefined(this._theme)}"
143
- .modeless="${this.modeless}"
144
- .withBackdrop="${!this.modeless}"
145
- ?resizable="${this.resizable}"
146
- aria-label="${this.ariaLabel}"
147
- .cancelButtonVisible="${this.cancelButtonVisible}"
148
- .rejectButtonVisible="${this.rejectButtonVisible}"
149
- restore-focus-on-close
150
- focus-trap
151
- ></vaadin-confirm-dialog-overlay>
152
- `;
111
+ /**
112
+ * Override method from OverlayFocusMixin to use owner as modal root
113
+ * @protected
114
+ * @override
115
+ */
116
+ get _modalRoot() {
117
+ return this.owner;
153
118
  }
154
119
  }
155
120
 
156
- defineCustomElement(ConfirmDialogDialog);
121
+ defineCustomElement(ConfirmDialogOverlay);
@@ -12,7 +12,7 @@ export * from './vaadin-confirm-dialog-mixin.js';
12
12
  /**
13
13
  * `<vaadin-confirm-dialog>` is a Web Component for showing alerts and asking for user confirmation.
14
14
  *
15
- * ```
15
+ * ```html
16
16
  * <vaadin-confirm-dialog cancel-button-visible>
17
17
  * There are unsaved changes. Do you really want to leave?
18
18
  * </vaadin-confirm-dialog>
@@ -20,14 +20,13 @@ export * from './vaadin-confirm-dialog-mixin.js';
20
20
  *
21
21
  * ### Styling
22
22
  *
23
- * The `<vaadin-confirm-dialog>` is not themable. Apply styles to `<vaadin-confirm-dialog-overlay>`
24
- * component and use its shadow parts for styling.
25
- * See [`<vaadin-overlay>`](#/elements/vaadin-overlay) for the overlay styling documentation.
26
- *
27
- * In addition to `<vaadin-overlay>` parts, the following parts are available for theming:
23
+ * The following shadow DOM parts are available for styling:
28
24
  *
29
25
  * Part name | Description
30
26
  * -----------------|-------------------------------------------
27
+ * `backdrop` | Backdrop of the overlay
28
+ * `overlay` | The overlay container
29
+ * `content` | The overlay content
31
30
  * `header` | The header element wrapper
32
31
  * `message` | The message element wrapper
33
32
  * `footer` | The footer element that wraps the buttons
@@ -36,8 +35,6 @@ export * from './vaadin-confirm-dialog-mixin.js';
36
35
  * `reject-button` | The "Reject" button wrapper
37
36
  *
38
37
  * Use `confirmTheme`, `cancelTheme` and `rejectTheme` properties to customize buttons theme.
39
- * Also, the `theme` attribute value set on `<vaadin-confirm-dialog>` is propagated to the
40
- * `<vaadin-confirm-dialog-overlay>` component.
41
38
  *
42
39
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
43
40
  *
@@ -16,7 +16,7 @@ import { ConfirmDialogMixin } from './vaadin-confirm-dialog-mixin.js';
16
16
  /**
17
17
  * `<vaadin-confirm-dialog>` is a Web Component for showing alerts and asking for user confirmation.
18
18
  *
19
- * ```
19
+ * ```html
20
20
  * <vaadin-confirm-dialog cancel-button-visible>
21
21
  * There are unsaved changes. Do you really want to leave?
22
22
  * </vaadin-confirm-dialog>
@@ -24,14 +24,13 @@ import { ConfirmDialogMixin } from './vaadin-confirm-dialog-mixin.js';
24
24
  *
25
25
  * ### Styling
26
26
  *
27
- * The `<vaadin-confirm-dialog>` is not themable. Apply styles to `<vaadin-confirm-dialog-overlay>`
28
- * component and use its shadow parts for styling.
29
- * See [`<vaadin-overlay>`](#/elements/vaadin-overlay) for the overlay styling documentation.
30
- *
31
- * In addition to `<vaadin-overlay>` parts, the following parts are available for theming:
27
+ * The following shadow DOM parts are available for styling:
32
28
  *
33
29
  * Part name | Description
34
30
  * -----------------|-------------------------------------------
31
+ * `backdrop` | Backdrop of the overlay
32
+ * `overlay` | The overlay container
33
+ * `content` | The overlay content
35
34
  * `header` | The header element wrapper
36
35
  * `message` | The message element wrapper
37
36
  * `footer` | The footer element that wraps the buttons
@@ -40,8 +39,6 @@ import { ConfirmDialogMixin } from './vaadin-confirm-dialog-mixin.js';
40
39
  * `reject-button` | The "Reject" button wrapper
41
40
  *
42
41
  * Use `confirmTheme`, `cancelTheme` and `rejectTheme` properties to customize buttons theme.
43
- * Also, the `theme` attribute value set on `<vaadin-confirm-dialog>` is propagated to the
44
- * `<vaadin-confirm-dialog-overlay>` component.
45
42
  *
46
43
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
47
44
  *
@@ -79,34 +76,42 @@ class ConfirmDialog extends ConfirmDialogMixin(ElementMixin(ThemePropertyMixin(P
79
76
  [hidden] {
80
77
  display: none !important;
81
78
  }
79
+
80
+ :host([opened]),
81
+ :host([opening]),
82
+ :host([closing]) {
83
+ display: contents !important;
84
+ }
82
85
  `;
83
86
  }
84
87
 
85
88
  /** @protected */
86
89
  render() {
87
90
  return html`
88
- <vaadin-confirm-dialog-dialog
89
- id="dialog"
91
+ <vaadin-confirm-dialog-overlay
92
+ id="overlay"
93
+ popover="manual"
94
+ .owner="${this}"
90
95
  .opened="${this.opened}"
91
- .overlayClass="${this.overlayClass}"
96
+ theme="${ifDefined(this._theme)}"
92
97
  .cancelButtonVisible="${this.cancelButtonVisible}"
93
98
  .rejectButtonVisible="${this.rejectButtonVisible}"
94
- aria-label="${this.header || 'confirmation'}"
95
- theme="${ifDefined(this._theme)}"
96
- no-close-on-outside-click
97
- .noCloseOnEsc="${this.noCloseOnEsc}"
98
- .height="${this.height}"
99
- .width="${this.width}"
99
+ with-backdrop
100
+ restore-focus-on-close
101
+ focus-trap
102
+ exportparts="backdrop, overlay, header, content, message, footer, cancel-button, confirm-button, reject-button"
100
103
  @opened-changed="${this._onOpenedChanged}"
101
- ></vaadin-confirm-dialog-dialog>
102
-
103
- <div hidden>
104
- <slot name="header"></slot>
104
+ @vaadin-overlay-open="${this.__onDialogOpened}"
105
+ @vaadin-overlay-closed="${this.__onDialogClosed}"
106
+ @vaadin-overlay-outside-click="${this._onOverlayOutsideClick}"
107
+ @vaadin-overlay-escape-press="${this._onOverlayEscapePress}"
108
+ >
109
+ <slot name="header" slot="header"></slot>
105
110
  <slot></slot>
106
- <slot name="cancel-button"></slot>
107
- <slot name="reject-button"></slot>
108
- <slot name="confirm-button"></slot>
109
- </div>
111
+ <slot name="cancel-button" slot="cancel-button"></slot>
112
+ <slot name="reject-button" slot="reject-button"></slot>
113
+ <slot name="confirm-button" slot="confirm-button"></slot>
114
+ </vaadin-confirm-dialog-overlay>
110
115
  `;
111
116
  }
112
117
 
package/web-types.json CHANGED
@@ -1,18 +1,51 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/confirm-dialog",
4
- "version": "25.0.0-alpha7",
4
+ "version": "25.0.0-alpha8",
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/25.0.0-alpha7/#/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",
11
+ "description": "`<vaadin-confirm-dialog>` is a Web Component for showing alerts and asking for user confirmation.\n\n```html\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 following shadow DOM parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\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.\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
+ {
14
+ "name": "width",
15
+ "description": "Set the width of the overlay.\nIf a unitless number is provided, pixels are assumed.",
16
+ "value": {
17
+ "type": [
18
+ "string",
19
+ "null",
20
+ "undefined"
21
+ ]
22
+ }
23
+ },
24
+ {
25
+ "name": "height",
26
+ "description": "Set the height of the overlay.\nIf a unitless number is provided, pixels are assumed.",
27
+ "value": {
28
+ "type": [
29
+ "string",
30
+ "null",
31
+ "undefined"
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ "name": "overlay-class",
37
+ "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
38
+ "value": {
39
+ "type": [
40
+ "string",
41
+ "null",
42
+ "undefined"
43
+ ]
44
+ }
45
+ },
13
46
  {
14
47
  "name": "accessible-description-ref",
15
- "description": "Sets the `aria-describedby` attribute of the overlay element.\n\nBy default, all elements inside the message area are linked\nthrough the `aria-describedby` attribute. However, there are\ncases where this can confuse screen reader users (e.g. the dialog\nmay present a password confirmation form). For these cases,\nit's better to associate only the elements that will help describe\nthe confirmation dialog through this API.",
48
+ "description": "Sets the `aria-describedby` attribute of the overlay element.\n\nBy default, the text contents of all elements inside the message area\nare combined into the `aria-description` attribute. However, there are\ncases where this can confuse screen reader users (e.g. the dialog\nmay present a password confirmation form). For these cases,\nit's better to associate only the elements that will help describe\nthe confirmation dialog through this API.",
16
49
  "value": {
17
50
  "type": [
18
51
  "string",
@@ -131,39 +164,6 @@
131
164
  ]
132
165
  }
133
166
  },
134
- {
135
- "name": "overlay-class",
136
- "description": "A space-delimited list of CSS class names\nto set on the underlying overlay element.",
137
- "value": {
138
- "type": [
139
- "string",
140
- "null",
141
- "undefined"
142
- ]
143
- }
144
- },
145
- {
146
- "name": "height",
147
- "description": "Set the height of the overlay.\nIf a unitless number is provided, pixels are assumed.",
148
- "value": {
149
- "type": [
150
- "string",
151
- "null",
152
- "undefined"
153
- ]
154
- }
155
- },
156
- {
157
- "name": "width",
158
- "description": "Set the width of the overlay.\nIf a unitless number is provided, pixels are assumed.",
159
- "value": {
160
- "type": [
161
- "string",
162
- "null",
163
- "undefined"
164
- ]
165
- }
166
- },
167
167
  {
168
168
  "name": "theme",
169
169
  "description": "The theme variants to apply to the component.",
@@ -178,9 +178,42 @@
178
178
  ],
179
179
  "js": {
180
180
  "properties": [
181
+ {
182
+ "name": "width",
183
+ "description": "Set the width of the overlay.\nIf a unitless number is provided, pixels are assumed.",
184
+ "value": {
185
+ "type": [
186
+ "string",
187
+ "null",
188
+ "undefined"
189
+ ]
190
+ }
191
+ },
192
+ {
193
+ "name": "height",
194
+ "description": "Set the height of the overlay.\nIf a unitless number is provided, pixels are assumed.",
195
+ "value": {
196
+ "type": [
197
+ "string",
198
+ "null",
199
+ "undefined"
200
+ ]
201
+ }
202
+ },
203
+ {
204
+ "name": "overlayClass",
205
+ "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
206
+ "value": {
207
+ "type": [
208
+ "string",
209
+ "null",
210
+ "undefined"
211
+ ]
212
+ }
213
+ },
181
214
  {
182
215
  "name": "accessibleDescriptionRef",
183
- "description": "Sets the `aria-describedby` attribute of the overlay element.\n\nBy default, all elements inside the message area are linked\nthrough the `aria-describedby` attribute. However, there are\ncases where this can confuse screen reader users (e.g. the dialog\nmay present a password confirmation form). For these cases,\nit's better to associate only the elements that will help describe\nthe confirmation dialog through this API.",
216
+ "description": "Sets the `aria-describedby` attribute of the overlay element.\n\nBy default, the text contents of all elements inside the message area\nare combined into the `aria-description` attribute. However, there are\ncases where this can confuse screen reader users (e.g. the dialog\nmay present a password confirmation form). For these cases,\nit's better to associate only the elements that will help describe\nthe confirmation dialog through this API.",
184
217
  "value": {
185
218
  "type": [
186
219
  "string",
@@ -298,39 +331,6 @@
298
331
  "string"
299
332
  ]
300
333
  }
301
- },
302
- {
303
- "name": "overlayClass",
304
- "description": "A space-delimited list of CSS class names\nto set on the underlying overlay element.",
305
- "value": {
306
- "type": [
307
- "string",
308
- "null",
309
- "undefined"
310
- ]
311
- }
312
- },
313
- {
314
- "name": "height",
315
- "description": "Set the height of the overlay.\nIf a unitless number is provided, pixels are assumed.",
316
- "value": {
317
- "type": [
318
- "string",
319
- "null",
320
- "undefined"
321
- ]
322
- }
323
- },
324
- {
325
- "name": "width",
326
- "description": "Set the width of the overlay.\nIf a unitless number is provided, pixels are assumed.",
327
- "value": {
328
- "type": [
329
- "string",
330
- "null",
331
- "undefined"
332
- ]
333
- }
334
334
  }
335
335
  ],
336
336
  "events": [
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/confirm-dialog",
4
- "version": "25.0.0-alpha7",
4
+ "version": "25.0.0-alpha8",
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/25.0.0-alpha7/#/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",
19
+ "description": "`<vaadin-confirm-dialog>` is a Web Component for showing alerts and asking for user confirmation.\n\n```html\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 following shadow DOM parts are available for styling:\n\nPart name | Description\n-----------------|-------------------------------------------\n`backdrop` | Backdrop of the overlay\n`overlay` | The overlay container\n`content` | The overlay content\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.\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
  {
@@ -47,9 +47,30 @@
47
47
  "kind": "expression"
48
48
  }
49
49
  },
50
+ {
51
+ "name": ".width",
52
+ "description": "Set the width of the overlay.\nIf a unitless number is provided, pixels are assumed.",
53
+ "value": {
54
+ "kind": "expression"
55
+ }
56
+ },
57
+ {
58
+ "name": ".height",
59
+ "description": "Set the height of the overlay.\nIf a unitless number is provided, pixels are assumed.",
60
+ "value": {
61
+ "kind": "expression"
62
+ }
63
+ },
64
+ {
65
+ "name": ".overlayClass",
66
+ "description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
67
+ "value": {
68
+ "kind": "expression"
69
+ }
70
+ },
50
71
  {
51
72
  "name": ".accessibleDescriptionRef",
52
- "description": "Sets the `aria-describedby` attribute of the overlay element.\n\nBy default, all elements inside the message area are linked\nthrough the `aria-describedby` attribute. However, there are\ncases where this can confuse screen reader users (e.g. the dialog\nmay present a password confirmation form). For these cases,\nit's better to associate only the elements that will help describe\nthe confirmation dialog through this API.",
73
+ "description": "Sets the `aria-describedby` attribute of the overlay element.\n\nBy default, the text contents of all elements inside the message area\nare combined into the `aria-description` attribute. However, there are\ncases where this can confuse screen reader users (e.g. the dialog\nmay present a password confirmation form). For these cases,\nit's better to associate only the elements that will help describe\nthe confirmation dialog through this API.",
53
74
  "value": {
54
75
  "kind": "expression"
55
76
  }
@@ -110,27 +131,6 @@
110
131
  "kind": "expression"
111
132
  }
112
133
  },
113
- {
114
- "name": ".overlayClass",
115
- "description": "A space-delimited list of CSS class names\nto set on the underlying overlay element.",
116
- "value": {
117
- "kind": "expression"
118
- }
119
- },
120
- {
121
- "name": ".height",
122
- "description": "Set the height of the overlay.\nIf a unitless number is provided, pixels are assumed.",
123
- "value": {
124
- "kind": "expression"
125
- }
126
- },
127
- {
128
- "name": ".width",
129
- "description": "Set the width of the overlay.\nIf a unitless number is provided, pixels are assumed.",
130
- "value": {
131
- "kind": "expression"
132
- }
133
- },
134
134
  {
135
135
  "name": "@closed",
136
136
  "description": "Fired when the confirm dialog is closed.",