@vaadin/popover 25.0.0-alpha8 → 25.0.0-beta1

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/popover",
3
- "version": "25.0.0-alpha8",
3
+ "version": "25.0.0-beta1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -23,9 +23,6 @@
23
23
  "lit.d.ts",
24
24
  "lit.js",
25
25
  "src",
26
- "!src/styles/*-base-styles.d.ts",
27
- "!src/styles/*-base-styles.js",
28
- "theme",
29
26
  "vaadin-*.d.ts",
30
27
  "vaadin-*.js",
31
28
  "web-types.json",
@@ -39,23 +36,23 @@
39
36
  ],
40
37
  "dependencies": {
41
38
  "@open-wc/dedupe-mixin": "^1.3.0",
42
- "@vaadin/a11y-base": "25.0.0-alpha8",
43
- "@vaadin/component-base": "25.0.0-alpha8",
44
- "@vaadin/lit-renderer": "25.0.0-alpha8",
45
- "@vaadin/overlay": "25.0.0-alpha8",
46
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha8",
47
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha8",
39
+ "@vaadin/a11y-base": "25.0.0-beta1",
40
+ "@vaadin/component-base": "25.0.0-beta1",
41
+ "@vaadin/lit-renderer": "25.0.0-beta1",
42
+ "@vaadin/overlay": "25.0.0-beta1",
43
+ "@vaadin/vaadin-themable-mixin": "25.0.0-beta1",
48
44
  "lit": "^3.0.0"
49
45
  },
50
46
  "devDependencies": {
51
- "@vaadin/chai-plugins": "25.0.0-alpha8",
52
- "@vaadin/test-runner-commands": "25.0.0-alpha8",
47
+ "@vaadin/chai-plugins": "25.0.0-beta1",
48
+ "@vaadin/test-runner-commands": "25.0.0-beta1",
53
49
  "@vaadin/testing-helpers": "^2.0.0",
54
- "sinon": "^18.0.0"
50
+ "@vaadin/vaadin-lumo-styles": "25.0.0-beta1",
51
+ "sinon": "^21.0.0"
55
52
  },
56
53
  "web-types": [
57
54
  "web-types.json",
58
55
  "web-types.lit.json"
59
56
  ],
60
- "gitHead": "ebf53673d5f639d2b1b6f2b31f640f530643ee2f"
57
+ "gitHead": "1d20cf54e582d1f2e209126d4586f8b4c01c50e0"
61
58
  }
@@ -27,7 +27,7 @@ export class PopoverRendererDirective extends LitRendererDirective<Popover, Popo
27
27
  }
28
28
 
29
29
  /**
30
- * A Lit directive for populating the content of the `<vaadin-popover-overlay>` element.
30
+ * A Lit directive for populating the content of the `<vaadin-popover>` element.
31
31
  *
32
32
  * The directive accepts a renderer callback returning a Lit template and assigns it to the popover
33
33
  * via the `renderer` property. The renderer is called once to populate the content when assigned
@@ -51,6 +51,7 @@ export class PopoverRendererDirective extends LitRendererDirective<Popover, Popo
51
51
  * @param renderer the renderer callback that returns a Lit template.
52
52
  * @param dependencies a single dependency or an array of dependencies
53
53
  * which trigger a re-render when changed.
54
+ * @deprecated Add content elements as children of the popover using default slot
54
55
  */
55
56
  export declare function popoverRenderer(
56
57
  renderer: PopoverLitRenderer,
@@ -32,7 +32,7 @@ export class PopoverRendererDirective extends LitRendererDirective {
32
32
  }
33
33
 
34
34
  /**
35
- * A Lit directive for populating the content of the `<vaadin-popover-overlay>` element.
35
+ * A Lit directive for populating the content of the `<vaadin-popover>` element.
36
36
  *
37
37
  * The directive accepts a renderer callback returning a Lit template and assigns it to the popover
38
38
  * via the `renderer` property. The renderer is called once to populate the content when assigned
@@ -56,5 +56,6 @@ export class PopoverRendererDirective extends LitRendererDirective {
56
56
  * @param renderer the renderer callback that returns a Lit template.
57
57
  * @param dependencies a single dependency or an array of dependencies
58
58
  * which trigger a re-render when changed.
59
+ * @deprecated Add content elements as children of the popover using default slot
59
60
  */
60
61
  export const popoverRenderer = directive(PopoverRendererDirective);
@@ -36,9 +36,10 @@ const popoverOverlay = css`
36
36
  overflow: visible;
37
37
  max-height: 100%;
38
38
  border: var(--_border-width) solid
39
- var(--vaadin-popover-border-color, var(--vaadin-overlay-border-color, var(--vaadin-border-color)));
39
+ var(--vaadin-popover-border-color, var(--vaadin-overlay-border-color, var(--vaadin-border-color-secondary)));
40
40
  background: var(--vaadin-popover-background, var(--vaadin-overlay-background, var(--vaadin-background-color)));
41
- box-shadow: var(--vaadin-popover-box-shadow, var(--vaadin-overlay-box-shadow, 0 8px 24px -4px rgba(0, 0, 0, 0.3)));
41
+ box-shadow: var(--vaadin-popover-shadow, var(--vaadin-overlay-shadow, 0 8px 24px -4px rgba(0, 0, 0, 0.3)));
42
+ border-radius: var(--vaadin-popover-border-radius, var(--vaadin-overlay-border-radius, var(--vaadin-radius-m)));
42
43
  }
43
44
 
44
45
  [part='content'] {
@@ -46,11 +47,11 @@ const popoverOverlay = css`
46
47
  overscroll-behavior: contain;
47
48
  box-sizing: border-box;
48
49
  max-height: 100%;
49
- padding: var(--vaadin-popover-padding, var(--vaadin-padding));
50
+ padding: var(--vaadin-popover-padding, var(--vaadin-padding-s));
50
51
  }
51
52
 
52
53
  :host([theme~='no-padding']) [part='content'] {
53
- padding: 0;
54
+ padding: 0 !important;
54
55
  }
55
56
 
56
57
  /* Increase the area of the popover so the pointer can go from the target directly to it. */
@@ -85,7 +86,7 @@ const popoverOverlay = css`
85
86
  }
86
87
 
87
88
  :host([theme~='arrow']) {
88
- --_default-offset: calc(4px + var(--_arrow-size) / 2);
89
+ --_default-offset: var(--_arrow-size);
89
90
  }
90
91
 
91
92
  :host([theme~='arrow']) [part='arrow'] {
@@ -4,12 +4,13 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { html, LitElement } from 'lit';
7
+ import { isElementFocused } from '@vaadin/a11y-base/src/focus-utils.js';
7
8
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
9
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
10
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
11
  import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
11
12
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
- import { popoverOverlayStyles } from './styles/vaadin-popover-overlay-core-styles.js';
13
+ import { popoverOverlayStyles } from './styles/vaadin-popover-overlay-base-styles.js';
13
14
  import { PopoverOverlayMixin } from './vaadin-popover-overlay-mixin.js';
14
15
 
15
16
  /**
@@ -33,17 +34,38 @@ class PopoverOverlay extends PopoverOverlayMixin(
33
34
  return popoverOverlayStyles;
34
35
  }
35
36
 
37
+ static get lumoInjector() {
38
+ return {
39
+ includeBaseStyles: true,
40
+ };
41
+ }
42
+
36
43
  /** @protected */
37
44
  render() {
38
45
  return html`
39
46
  <div id="backdrop" part="backdrop" hidden ?hidden="${!this.withBackdrop}"></div>
40
- <div part="overlay" id="overlay" tabindex="0">
47
+ <div part="overlay" id="overlay">
41
48
  <div part="arrow"></div>
42
49
  <div part="content" id="content"><slot></slot></div>
43
50
  </div>
44
51
  `;
45
52
  }
46
53
 
54
+ /** @protected */
55
+ updated(props) {
56
+ super.updated(props);
57
+
58
+ if (props.has('restoreFocusNode') && this.opened) {
59
+ // Save focus to be restored when target is set while opened
60
+ if (this.restoreFocusNode && isElementFocused(this.restoreFocusNode.focusElement || this.restoreFocusNode)) {
61
+ this.__focusRestorationController.saveFocus();
62
+ } else if (!this.restoreFocusNode) {
63
+ // Do not restore focus when target is cleared while opened
64
+ this.__focusRestorationController.focusNode = null;
65
+ }
66
+ }
67
+ }
68
+
47
69
  /**
48
70
  * @override
49
71
  * @protected
@@ -53,27 +75,37 @@ class PopoverOverlay extends PopoverOverlayMixin(
53
75
  }
54
76
 
55
77
  /**
56
- * @override
78
+ * Override method from OverlayFocusMixin to use owner as focus trap root
57
79
  * @protected
80
+ * @override
58
81
  */
59
- get _modalRoot() {
82
+ get _focusTrapRoot() {
60
83
  return this.owner;
61
84
  }
62
85
 
63
86
  /**
87
+ * Override method from `OverlayMixin` to always add outside
88
+ * click listener so that it can be used by modeless popover.
89
+ * @return {boolean}
64
90
  * @protected
65
91
  * @override
66
92
  */
67
- _attachOverlay() {
68
- this.showPopover();
93
+ _shouldAddGlobalListeners() {
94
+ return true;
69
95
  }
70
96
 
71
97
  /**
72
- * @protected
98
+ * Override method from `OverlayMixin` to prevent closing when clicking on target.
99
+ * Clicking the target will already close the popover when using the click trigger.
100
+ *
73
101
  * @override
102
+ * @protected
74
103
  */
75
- _detachOverlay() {
76
- this.hidePopover();
104
+ _shouldCloseOnOutsideClick(event) {
105
+ if (event.composedPath().includes(this.positionTarget)) {
106
+ return false;
107
+ }
108
+ return super._shouldCloseOnOutsideClick(event);
77
109
  }
78
110
  }
79
111
 
@@ -4,7 +4,6 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
7
- import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
8
7
  import { ThemePropertyMixin } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
9
8
  import { PopoverPositionMixin } from './vaadin-popover-position-mixin.js';
10
9
  import { PopoverTargetMixin } from './vaadin-popover-target-mixin.js';
@@ -68,9 +67,7 @@ export type PopoverEventMap = HTMLElementEventMap & PopoverCustomEventMap;
68
67
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
69
68
  * @fires {CustomEvent} closed - Fired when the popover is closed.
70
69
  */
71
- declare class Popover extends PopoverPositionMixin(
72
- PopoverTargetMixin(OverlayClassMixin(ThemePropertyMixin(ElementMixin(HTMLElement)))),
73
- ) {
70
+ declare class Popover extends PopoverPositionMixin(PopoverTargetMixin(ThemePropertyMixin(ElementMixin(HTMLElement)))) {
74
71
  /**
75
72
  * Sets the default focus delay to be used by all popover instances,
76
73
  * except for those that have focus delay configured using property.
@@ -93,6 +90,7 @@ declare class Popover extends PopoverPositionMixin(
93
90
  * String used to label the popover to screen reader users.
94
91
  *
95
92
  * @attr {string} accessible-name
93
+ * @deprecated Use `aria-label` attribute on the popover instead
96
94
  */
97
95
  accessibleName: string | null | undefined;
98
96
 
@@ -100,6 +98,7 @@ declare class Popover extends PopoverPositionMixin(
100
98
  * Id of the element used as label of the popover to screen reader users.
101
99
  *
102
100
  * @attr {string} accessible-name-ref
101
+ * @deprecated Use `aria-labelledby` attribute on the popover instead
103
102
  */
104
103
  accessibleNameRef: string | null | undefined;
105
104
 
@@ -110,13 +109,13 @@ declare class Popover extends PopoverPositionMixin(
110
109
  autofocus: boolean;
111
110
 
112
111
  /**
113
- * Set the height of the overlay.
112
+ * Set the height of the popover.
114
113
  * If a unitless number is provided, pixels are assumed.
115
114
  */
116
115
  height: string | null;
117
116
 
118
117
  /**
119
- * Set the width of the overlay.
118
+ * Set the width of the popover.
120
119
  * If a unitless number is provided, pixels are assumed.
121
120
  */
122
121
  width: string | null;
@@ -153,60 +152,60 @@ declare class Popover extends PopoverPositionMixin(
153
152
  hoverDelay: number;
154
153
 
155
154
  /**
156
- * True if the popover overlay is opened, false otherwise.
155
+ * True if the popover is visible and available for interaction.
157
156
  */
158
157
  opened: boolean;
159
158
 
160
159
  /**
161
- * The `role` attribute value to be set on the overlay.
160
+ * The `role` attribute value to be set on the popover.
162
161
  *
163
162
  * @attr {string} overlay-role
163
+ * @deprecated Use standard `role` attribute on the popover instead
164
164
  */
165
165
  overlayRole: string;
166
166
 
167
167
  /**
168
- * Custom function for rendering the content of the overlay.
168
+ * Custom function for rendering the content of the popover.
169
169
  * Receives two arguments:
170
170
  *
171
171
  * - `root` The root container DOM element. Append your content to it.
172
- * - `popover` The reference to the `vaadin-popover` element (overlay host).
172
+ * - `popover` The reference to the `vaadin-popover` element.
173
+ *
174
+ * @deprecated Add content elements as children of the popover using default slot
173
175
  */
174
176
  renderer: PopoverRenderer | null | undefined;
175
177
 
176
178
  /**
177
179
  * When true, the popover prevents interacting with background elements
178
180
  * by setting `pointer-events` style on the document body to `none`.
179
- * This also enables trapping focus inside the overlay.
181
+ * This also enables trapping focus inside the popover.
180
182
  */
181
183
  modal: boolean;
182
184
 
183
185
  /**
184
- * Set to true to disable closing popover overlay on outside click.
186
+ * Set to true to disable closing popover on outside click.
185
187
  *
186
188
  * @attr {boolean} no-close-on-outside-click
187
189
  */
188
190
  noCloseOnOutsideClick: boolean;
189
191
 
190
192
  /**
191
- * Set to true to disable closing popover overlay on Escape press.
192
- * When the popover is modal, pressing Escape anywhere in the
193
- * document closes the overlay. Otherwise, only Escape press
194
- * from the popover itself or its target closes the overlay.
193
+ * Set to true to disable closing popover on Escape press.
195
194
  *
196
195
  * @attr {boolean} no-close-on-esc
197
196
  */
198
197
  noCloseOnEsc: boolean;
199
198
 
200
199
  /**
201
- * Popover trigger mode, used to configure how the overlay is opened or closed.
200
+ * Popover trigger mode, used to configure how the popover is opened or closed.
202
201
  * Could be set to multiple by providing an array, e.g. `trigger = ['hover', 'focus']`.
203
202
  *
204
203
  * Supported values:
205
204
  * - `click` (default) - opens and closes on target click.
206
205
  * - `hover` - opens on target mouseenter, closes on target mouseleave. Moving mouse
207
- * to the popover overlay content keeps the overlay opened.
206
+ * to the popover content keeps the popover opened.
208
207
  * - `focus` - opens on target focus, closes on target blur. Moving focus to the
209
- * popover overlay content keeps the overlay opened.
208
+ * popover content keeps the popover opened.
210
209
  *
211
210
  * In addition to the behavior specified by `trigger`, the popover can be closed by:
212
211
  * - pressing Escape key (unless `noCloseOnEsc` property is true)
@@ -219,7 +218,7 @@ declare class Popover extends PopoverPositionMixin(
219
218
  trigger: PopoverTrigger[] | null | undefined;
220
219
 
221
220
  /**
222
- * When true, the overlay has a backdrop (modality curtain) on top of the
221
+ * When true, the popover has a backdrop (modality curtain) on top of the
223
222
  * underlying page content, covering the whole viewport.
224
223
  *
225
224
  * @attr {boolean} with-backdrop
@@ -231,6 +230,8 @@ declare class Popover extends PopoverPositionMixin(
231
230
  * While performing the update, it invokes the renderer passed in the `renderer` property.
232
231
  *
233
232
  * It is not guaranteed that the update happens immediately (synchronously) after it is requested.
233
+ *
234
+ * @deprecated Add content elements as children of the popover using default slot
234
235
  */
235
236
  requestContentUpdate(): void;
236
237