@vaadin/overlay 25.0.0-alpha9 → 25.0.0-beta2

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/overlay",
3
- "version": "25.0.0-alpha9",
3
+ "version": "25.0.0-beta2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,9 +21,6 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
- "!src/styles/*-base-styles.d.ts",
25
- "!src/styles/*-base-styles.js",
26
- "theme",
27
24
  "vaadin-*.d.ts",
28
25
  "vaadin-*.js"
29
26
  ],
@@ -36,17 +33,17 @@
36
33
  ],
37
34
  "dependencies": {
38
35
  "@open-wc/dedupe-mixin": "^1.3.0",
39
- "@vaadin/a11y-base": "25.0.0-alpha9",
40
- "@vaadin/component-base": "25.0.0-alpha9",
41
- "@vaadin/vaadin-lumo-styles": "25.0.0-alpha9",
42
- "@vaadin/vaadin-themable-mixin": "25.0.0-alpha9",
36
+ "@vaadin/a11y-base": "25.0.0-beta2",
37
+ "@vaadin/component-base": "25.0.0-beta2",
38
+ "@vaadin/vaadin-themable-mixin": "25.0.0-beta2",
43
39
  "lit": "^3.0.0"
44
40
  },
45
41
  "devDependencies": {
46
- "@vaadin/chai-plugins": "25.0.0-alpha9",
47
- "@vaadin/test-runner-commands": "25.0.0-alpha9",
42
+ "@vaadin/chai-plugins": "25.0.0-beta2",
43
+ "@vaadin/test-runner-commands": "25.0.0-beta2",
48
44
  "@vaadin/testing-helpers": "^2.0.0",
49
- "sinon": "^18.0.0"
45
+ "@vaadin/vaadin-lumo-styles": "25.0.0-beta2",
46
+ "sinon": "^21.0.0"
50
47
  },
51
- "gitHead": "bbe4720721e0955ffc87a79b412bee38b1f0eb1e"
48
+ "gitHead": "e078f8371ae266f05c7ca1ec25686cc489c83f24"
52
49
  }
@@ -3,7 +3,7 @@
3
3
  * Copyright (c) 2017 - 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 '@vaadin/component-base/src/style-props.js';
6
+ import '@vaadin/component-base/src/styles/style-props.js';
7
7
  import { css } from 'lit';
8
8
 
9
9
  export const overlayStyles = css`
@@ -16,7 +16,7 @@ export const overlayStyles = css`
16
16
 
17
17
  /* Default position constraints. Themes can
18
18
  override this to adjust the gap between the overlay and the viewport. */
19
- inset: 8px;
19
+ inset: var(--vaadin-overlay-viewport-inset, 8px);
20
20
  bottom: var(--vaadin-overlay-viewport-bottom);
21
21
 
22
22
  /* Override native [popover] user agent styles */
@@ -55,19 +55,32 @@ export const overlayStyles = css`
55
55
 
56
56
  [part='overlay'] {
57
57
  background: var(--vaadin-overlay-background, var(--vaadin-background-color));
58
- border: var(--vaadin-overlay-border-width, 1px) solid var(--vaadin-overlay-border-color, var(--vaadin-border-color));
58
+ border: var(--vaadin-overlay-border-width, 1px) solid
59
+ var(--vaadin-overlay-border-color, var(--vaadin-border-color-secondary));
59
60
  border-radius: var(--vaadin-overlay-border-radius, var(--vaadin-radius-m));
60
- box-shadow: var(--vaadin-overlay-box-shadow, 0 8px 24px -4px rgba(0, 0, 0, 0.3));
61
+ box-shadow: var(--vaadin-overlay-shadow, 0 8px 24px -4px rgba(0, 0, 0, 0.3));
61
62
  box-sizing: border-box;
62
63
  max-width: 100%;
63
64
  overflow: auto;
64
65
  overscroll-behavior: contain;
65
66
  pointer-events: auto;
66
67
  -webkit-tap-highlight-color: initial;
68
+
69
+ /* CSS reset for font styles */
70
+ color: initial;
71
+ font: initial;
72
+ letter-spacing: initial;
73
+ text-align: initial;
74
+ text-decoration: initial;
75
+ text-indent: initial;
76
+ text-transform: initial;
77
+ user-select: text;
78
+ white-space: initial;
79
+ word-spacing: initial;
67
80
  }
68
81
 
69
82
  [part='backdrop'] {
70
- background: var(--vaadin-overlay-backdrop-background, rgba(0, 0, 0, 0.5));
83
+ background: var(--vaadin-overlay-backdrop-background, rgba(0, 0, 0, 0.2));
71
84
  content: '';
72
85
  inset: 0;
73
86
  pointer-events: auto;
@@ -81,7 +94,7 @@ export const overlayStyles = css`
81
94
 
82
95
  @media (forced-colors: active) {
83
96
  [part='overlay'] {
84
- border: 3px solid;
97
+ border: 3px solid !important;
85
98
  }
86
99
  }
87
100
  `;
@@ -3,7 +3,6 @@
3
3
  * Copyright (c) 2017 - 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 { AriaModalController } from '@vaadin/a11y-base/src/aria-modal-controller.js';
7
6
  import { FocusRestorationController } from '@vaadin/a11y-base/src/focus-restoration-controller.js';
8
7
  import { FocusTrapController } from '@vaadin/a11y-base/src/focus-trap-controller.js';
9
8
  import { getDeepActiveElement, isKeyboardActive } from '@vaadin/a11y-base/src/focus-utils.js';
@@ -48,7 +47,6 @@ export const OverlayFocusMixin = (superClass) =>
48
47
  constructor() {
49
48
  super();
50
49
 
51
- this.__ariaModalController = new AriaModalController(this, () => this._modalRoot);
52
50
  this.__focusTrapController = new FocusTrapController(this);
53
51
  this.__focusRestorationController = new FocusRestorationController();
54
52
  }
@@ -66,18 +64,17 @@ export const OverlayFocusMixin = (superClass) =>
66
64
  ready() {
67
65
  super.ready();
68
66
 
69
- this.addController(this.__ariaModalController);
70
67
  this.addController(this.__focusTrapController);
71
68
  this.addController(this.__focusRestorationController);
72
69
  }
73
70
 
74
71
  /**
75
- * Override to specify another element used as a modality root,
76
- * e.g. the overlay's owner element, rather than overlay itself.
72
+ * Override to specify another element used as a focus trap root,
73
+ * e.g. the overlay's owner element, rather than overlay part.
77
74
  * @protected
78
75
  */
79
- get _modalRoot() {
80
- return this;
76
+ get _focusTrapRoot() {
77
+ return this.$.overlay;
81
78
  }
82
79
 
83
80
  /**
@@ -87,13 +84,13 @@ export const OverlayFocusMixin = (superClass) =>
87
84
  */
88
85
  _resetFocus() {
89
86
  if (this.focusTrap) {
90
- this.__ariaModalController.close();
91
87
  this.__focusTrapController.releaseFocus();
92
88
  }
93
89
 
94
90
  if (this.restoreFocusOnClose && this._shouldRestoreFocus()) {
95
- const preventScroll = !isKeyboardActive();
96
- this.__focusRestorationController.restoreFocus({ preventScroll });
91
+ const focusVisible = isKeyboardActive();
92
+ const preventScroll = !focusVisible;
93
+ this.__focusRestorationController.restoreFocus({ preventScroll, focusVisible });
97
94
  }
98
95
  }
99
96
 
@@ -115,8 +112,7 @@ export const OverlayFocusMixin = (superClass) =>
115
112
  */
116
113
  _trapFocus() {
117
114
  if (this.focusTrap) {
118
- this.__ariaModalController.showModal();
119
- this.__focusTrapController.trapFocus(this.$.overlay);
115
+ this.__focusTrapController.trapFocus(this._focusTrapRoot);
120
116
  }
121
117
  }
122
118
 
@@ -102,6 +102,15 @@ export const OverlayMixin = (superClass) =>
102
102
  return ['_rendererOrDataChanged(renderer, owner, model, opened)'];
103
103
  }
104
104
 
105
+ /**
106
+ * Override to specify another element used as a renderer root,
107
+ * e.g. slotted into the overlay, rather than overlay itself.
108
+ * @protected
109
+ */
110
+ get _rendererRoot() {
111
+ return this;
112
+ }
113
+
105
114
  constructor() {
106
115
  super();
107
116
 
@@ -156,6 +165,11 @@ export const OverlayMixin = (superClass) =>
156
165
  disconnectedCallback() {
157
166
  super.disconnectedCallback();
158
167
 
168
+ if (this.__scheduledOpen) {
169
+ cancelAnimationFrame(this.__scheduledOpen);
170
+ this.__scheduledOpen = null;
171
+ }
172
+
159
173
  /* c8 ignore next 3 */
160
174
  if (this._boundIosResizeListener) {
161
175
  window.removeEventListener('resize', this._boundIosResizeListener);
@@ -170,7 +184,7 @@ export const OverlayMixin = (superClass) =>
170
184
  */
171
185
  requestContentUpdate() {
172
186
  if (this.renderer) {
173
- this.renderer.call(this.owner, this._contentRoot, this.owner, this.model);
187
+ this.renderer.call(this.owner, this._rendererRoot, this.owner, this.model);
174
188
  }
175
189
  }
176
190
 
@@ -183,7 +197,7 @@ export const OverlayMixin = (superClass) =>
183
197
  const event = new CustomEvent('vaadin-overlay-close', {
184
198
  bubbles: true,
185
199
  cancelable: true,
186
- detail: { sourceEvent },
200
+ detail: { overlay: this, sourceEvent },
187
201
  });
188
202
  this.dispatchEvent(event);
189
203
  // To allow listening for the event globally, also dispatch it on the document body
@@ -237,8 +251,25 @@ export const OverlayMixin = (superClass) =>
237
251
  }
238
252
  }
239
253
 
254
+ /**
255
+ * Whether to add global listeners for closing on outside click.
256
+ * By default, listeners are not added for a modeless overlay.
257
+ *
258
+ * @return {boolean}
259
+ * @protected
260
+ */
261
+ _shouldAddGlobalListeners() {
262
+ return !this.modeless;
263
+ }
264
+
240
265
  /** @private */
241
266
  _addGlobalListeners() {
267
+ if (this.__hasGlobalListeners) {
268
+ return;
269
+ }
270
+
271
+ this.__hasGlobalListeners = true;
272
+
242
273
  document.addEventListener('mousedown', this._boundMouseDownListener);
243
274
  document.addEventListener('mouseup', this._boundMouseUpListener);
244
275
  // Firefox leaks click to document on contextmenu even if prevented
@@ -248,6 +279,12 @@ export const OverlayMixin = (superClass) =>
248
279
 
249
280
  /** @private */
250
281
  _removeGlobalListeners() {
282
+ if (!this.__hasGlobalListeners) {
283
+ return;
284
+ }
285
+
286
+ this.__hasGlobalListeners = false;
287
+
251
288
  document.removeEventListener('mousedown', this._boundMouseDownListener);
252
289
  document.removeEventListener('mouseup', this._boundMouseUpListener);
253
290
  document.documentElement.removeEventListener('click', this._boundOutsideClickListener, true);
@@ -267,11 +304,11 @@ export const OverlayMixin = (superClass) =>
267
304
  this._oldOpened = opened;
268
305
 
269
306
  if (rendererChanged && hasOldRenderer) {
270
- this._contentRoot.innerHTML = '';
307
+ this._rendererRoot.innerHTML = '';
271
308
  // Whenever a Lit-based renderer is used, it assigns a Lit part to the node it was rendered into.
272
309
  // When clearing the rendered content, this part needs to be manually disposed of.
273
310
  // Otherwise, using a Lit-based renderer on the same node will throw an exception or render nothing afterward.
274
- delete this._contentRoot._$litPart$;
311
+ delete this._rendererRoot._$litPart$;
275
312
  }
276
313
 
277
314
  if (opened && renderer && (rendererChanged || openedChanged || ownerOrModelChanged)) {
@@ -281,13 +318,20 @@ export const OverlayMixin = (superClass) =>
281
318
 
282
319
  /** @private */
283
320
  _modelessChanged(modeless) {
321
+ if (this.opened) {
322
+ // Add / remove listeners if modeless is changed while opened
323
+ if (this._shouldAddGlobalListeners()) {
324
+ this._addGlobalListeners();
325
+ } else {
326
+ this._removeGlobalListeners();
327
+ }
328
+ }
329
+
284
330
  if (!modeless) {
285
331
  if (this.opened) {
286
- this._addGlobalListeners();
287
332
  this._enterModalState();
288
333
  }
289
334
  } else {
290
- this._removeGlobalListeners();
291
335
  this._exitModalState();
292
336
  }
293
337
  setOverlayStateAttribute(this, 'modeless', modeless);
@@ -317,7 +361,7 @@ export const OverlayMixin = (superClass) =>
317
361
 
318
362
  // Dispatch the event on the overlay. Not using composed, as propagating the event through shadow roots
319
363
  // could have side effects when nesting overlays
320
- const event = new CustomEvent('vaadin-overlay-open', { bubbles: true });
364
+ const event = new CustomEvent('vaadin-overlay-open', { detail: { overlay: this }, bubbles: true });
321
365
  this.dispatchEvent(event);
322
366
  // To allow listening for the event globally, also dispatch it on the document body
323
367
  document.body.dispatchEvent(event);
@@ -326,7 +370,7 @@ export const OverlayMixin = (superClass) =>
326
370
 
327
371
  document.addEventListener('keydown', this._boundKeydownListener);
328
372
 
329
- if (!this.modeless) {
373
+ if (this._shouldAddGlobalListeners()) {
330
374
  this._addGlobalListeners();
331
375
  }
332
376
  } else if (wasOpened) {
@@ -341,7 +385,7 @@ export const OverlayMixin = (superClass) =>
341
385
 
342
386
  document.removeEventListener('keydown', this._boundKeydownListener);
343
387
 
344
- if (!this.modeless) {
388
+ if (this._shouldAddGlobalListeners()) {
345
389
  this._removeGlobalListeners();
346
390
  }
347
391
  }
@@ -517,12 +561,12 @@ export const OverlayMixin = (superClass) =>
517
561
  * @private
518
562
  */
519
563
  _keydownListener(event) {
520
- if (!this._last) {
564
+ if (!this._last || event.defaultPrevented) {
521
565
  return;
522
566
  }
523
567
 
524
568
  // Only close modeless overlay on Esc press when it contains focus
525
- if (this.modeless && !event.composedPath().includes(this.$.overlay)) {
569
+ if (!this._shouldAddGlobalListeners() && !event.composedPath().includes(this._focusTrapRoot)) {
526
570
  return;
527
571
  }
528
572
 
@@ -116,13 +116,6 @@ export const PositionMixin = (superClass) =>
116
116
  };
117
117
  }
118
118
 
119
- static get observers() {
120
- return [
121
- '__positionSettingsChanged(horizontalAlign, verticalAlign, noHorizontalOverlap, noVerticalOverlap, requiredVerticalSpace)',
122
- '__overlayOpenedChanged(opened, positionTarget)',
123
- ];
124
- }
125
-
126
119
  constructor() {
127
120
  super();
128
121
 
@@ -145,6 +138,36 @@ export const PositionMixin = (superClass) =>
145
138
  this.__removeUpdatePositionEventListeners();
146
139
  }
147
140
 
141
+ /** @protected */
142
+ updated(props) {
143
+ super.updated(props);
144
+
145
+ if (props.has('positionTarget')) {
146
+ const oldTarget = props.get('positionTarget');
147
+
148
+ // 1. When position target is removed, always reset position settings
149
+ // 2. When position target is set, reset if overlay was opened before
150
+ if ((!this.positionTarget && oldTarget) || (this.positionTarget && !oldTarget && !!this.__margins)) {
151
+ this.__resetPosition();
152
+ }
153
+ }
154
+
155
+ if (props.has('opened') || props.has('positionTarget')) {
156
+ this.__updatePositionSettings(this.opened, this.positionTarget);
157
+ }
158
+
159
+ const positionProps = [
160
+ 'horizontalAlign',
161
+ 'verticalAlign',
162
+ 'noHorizontalOverlap',
163
+ 'noVerticalOverlap',
164
+ 'requiredVerticalSpace',
165
+ ];
166
+ if (positionProps.some((prop) => props.has(prop))) {
167
+ this._updatePosition();
168
+ }
169
+ }
170
+
148
171
  /** @private */
149
172
  __addUpdatePositionEventListeners() {
150
173
  window.visualViewport.addEventListener('resize', this._updatePosition);
@@ -181,7 +204,7 @@ export const PositionMixin = (superClass) =>
181
204
  }
182
205
 
183
206
  /** @private */
184
- __overlayOpenedChanged(opened, positionTarget) {
207
+ __updatePositionSettings(opened, positionTarget) {
185
208
  this.__removeUpdatePositionEventListeners();
186
209
 
187
210
  if (positionTarget) {
@@ -210,20 +233,35 @@ export const PositionMixin = (superClass) =>
210
233
  }
211
234
  }
212
235
 
213
- __positionSettingsChanged() {
214
- this._updatePosition();
215
- }
216
-
217
236
  /** @private */
218
237
  __onScroll(e) {
219
238
  // If the scroll event occurred inside the overlay, ignore it.
220
- if (e.target instanceof Node && this.contains(e.target)) {
239
+ if (e.target instanceof Node && this._deepContains(e.target)) {
221
240
  return;
222
241
  }
223
242
 
224
243
  this._updatePosition();
225
244
  }
226
245
 
246
+ /** @private */
247
+ __resetPosition() {
248
+ this.__margins = null;
249
+
250
+ Object.assign(this.style, {
251
+ justifyContent: '',
252
+ alignItems: '',
253
+ top: '',
254
+ bottom: '',
255
+ left: '',
256
+ right: '',
257
+ });
258
+
259
+ setOverlayStateAttribute(this, 'bottom-aligned', false);
260
+ setOverlayStateAttribute(this, 'top-aligned', false);
261
+ setOverlayStateAttribute(this, 'end-aligned', false);
262
+ setOverlayStateAttribute(this, 'start-aligned', false);
263
+ }
264
+
227
265
  _updatePosition() {
228
266
  if (!this.positionTarget || !this.opened || !this.__margins) {
229
267
  return;
@@ -17,7 +17,7 @@ const getAttachedInstances = () => [...attachedInstances].filter((el) => !el.has
17
17
  * Returns true if all the instances on top of the overlay are nested overlays.
18
18
  * @private
19
19
  */
20
- const hasOnlyNestedOverlays = (overlay) => {
20
+ export const hasOnlyNestedOverlays = (overlay) => {
21
21
  const instances = getAttachedInstances();
22
22
  const next = instances[instances.indexOf(overlay) + 1];
23
23
  if (!next) {
@@ -16,10 +16,12 @@
16
16
  */
17
17
  export function observeMove(element, callback) {
18
18
  let io = null;
19
+ let timeout;
19
20
 
20
21
  const root = document.documentElement;
21
22
 
22
23
  function cleanup() {
24
+ timeout && clearTimeout(timeout);
23
25
  io && io.disconnect();
24
26
  io = null;
25
27
  }
@@ -52,27 +54,22 @@ export function observeMove(element, callback) {
52
54
  let isFirstUpdate = true;
53
55
 
54
56
  function handleObserve(entries) {
55
- let ratio = entries[0].intersectionRatio;
57
+ const ratio = entries[0].intersectionRatio;
56
58
 
57
59
  if (ratio !== threshold) {
58
60
  if (!isFirstUpdate) {
59
61
  return refresh();
60
62
  }
61
63
 
62
- // It's possible for the watched element to not be at perfect 1.0 visibility when we create
63
- // the IntersectionObserver. This has a couple of causes:
64
- // - elements being on partial pixels
65
- // - elements being hidden offscreen (e.g., <html> has `overflow: hidden`)
66
- // - delays: if your DOM change occurs due to e.g., page resize, you can see elements
67
- // behind their actual position
68
- //
69
- // In all of these cases, refresh but with this lower ratio of threshold. When the element
70
- // moves beneath _that_ new value, the user will get notified.
71
- if (ratio === 0.0) {
72
- ratio = 0.0000001; // Just needs to be non-zero
64
+ if (!ratio) {
65
+ // If the reference is clipped, the ratio is 0. Throttle the refresh
66
+ // to prevent an infinite loop of updates.
67
+ timeout = setTimeout(() => {
68
+ refresh(false, 1e-7);
69
+ }, 1000);
70
+ } else {
71
+ refresh(false, ratio);
73
72
  }
74
-
75
- refresh(false, ratio);
76
73
  }
77
74
 
78
75
  isFirstUpdate = false;
@@ -17,13 +17,13 @@ export type OverlayOpenedChangedEvent = CustomEvent<{ value: boolean }>;
17
17
  /**
18
18
  * Fired after the overlay is opened.
19
19
  */
20
- export type OverlayOpenEvent = CustomEvent;
20
+ export type OverlayOpenEvent = CustomEvent<{ overlay: HTMLElement }>;
21
21
 
22
22
  /**
23
23
  * Fired when the opened overlay is about to be closed.
24
24
  * Calling `preventDefault()` on the event cancels the closing.
25
25
  */
26
- export type OverlayCloseEvent = CustomEvent;
26
+ export type OverlayCloseEvent = CustomEvent<{ overlay: HTMLElement; sourceEvent?: Event }>;
27
27
 
28
28
  /**
29
29
  * Fired after the overlay is closed.
@@ -98,10 +98,10 @@ export type OverlayEventMap = HTMLElementEventMap & OverlayCustomEventMap;
98
98
  *
99
99
  * The following state attributes are available for styling:
100
100
  *
101
- * Attribute | Description | Part
102
- * ---|---|---
103
- * `opening` | Applied just after the overlay is attached to the DOM. You can apply a CSS @keyframe animation for this state. | `:host`
104
- * `closing` | Applied just before the overlay is detached from the DOM. You can apply a CSS @keyframe animation for this state. | `:host`
101
+ * Attribute | Description
102
+ * ----------|------------
103
+ * `opening` | Applied just after the overlay is opened. You can apply a CSS animation for this state.
104
+ * `closing` | Applied just before the overlay is closed. You can apply a CSS animation for this state.
105
105
  *
106
106
  * The following custom CSS properties are available for styling:
107
107
  *
@@ -9,7 +9,7 @@ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
9
  import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
10
  import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
11
11
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
- import { overlayStyles } from './styles/vaadin-overlay-core-styles.js';
12
+ import { overlayStyles } from './styles/vaadin-overlay-base-styles.js';
13
13
  import { OverlayMixin } from './vaadin-overlay-mixin.js';
14
14
 
15
15
  /**
@@ -50,10 +50,10 @@ import { OverlayMixin } from './vaadin-overlay-mixin.js';
50
50
  *
51
51
  * The following state attributes are available for styling:
52
52
  *
53
- * Attribute | Description | Part
54
- * ---|---|---
55
- * `opening` | Applied just after the overlay is attached to the DOM. You can apply a CSS @keyframe animation for this state. | `:host`
56
- * `closing` | Applied just before the overlay is detached from the DOM. You can apply a CSS @keyframe animation for this state. | `:host`
53
+ * Attribute | Description
54
+ * ----------|------------
55
+ * `opening` | Applied just after the overlay is opened. You can apply a CSS animation for this state.
56
+ * `closing` | Applied just before the overlay is closed. You can apply a CSS animation for this state.
57
57
  *
58
58
  * The following custom CSS properties are available for styling:
59
59
  *
package/vaadin-overlay.js CHANGED
@@ -1,2 +1,2 @@
1
- import './theme/lumo/vaadin-overlay.js';
1
+ import './src/vaadin-overlay.js';
2
2
  export * from './src/vaadin-overlay.js';
@@ -1,74 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { css } from 'lit';
7
-
8
- export const overlayStyles = css`
9
- :host {
10
- z-index: 200;
11
- position: fixed;
12
-
13
- /* Despite of what the names say, <vaadin-overlay> is just a container
14
- for position/sizing/alignment. The actual overlay is the overlay part. */
15
-
16
- /* Default position constraints: the entire viewport. Note: themes can
17
- override this to introduce gaps between the overlay and the viewport. */
18
- inset: 0;
19
- bottom: var(--vaadin-overlay-viewport-bottom);
20
-
21
- /* Override native [popover] user agent styles */
22
- width: auto;
23
- height: auto;
24
- border: none;
25
- padding: 0;
26
- background-color: transparent;
27
- overflow: visible;
28
-
29
- /* Use flexbox alignment for the overlay part. */
30
- display: flex;
31
- flex-direction: column; /* makes dropdowns sizing easier */
32
- /* Align to center by default. */
33
- align-items: center;
34
- justify-content: center;
35
-
36
- /* Allow centering when max-width/max-height applies. */
37
- margin: auto;
38
-
39
- /* The host is not clickable, only the overlay part is. */
40
- pointer-events: none;
41
-
42
- /* Remove tap highlight on touch devices. */
43
- -webkit-tap-highlight-color: transparent;
44
-
45
- /* CSS API for host */
46
- --vaadin-overlay-viewport-bottom: 0;
47
- }
48
-
49
- :host([hidden]),
50
- :host(:not([opened]):not([closing])),
51
- :host(:not([opened]):not([closing])) [part='overlay'] {
52
- display: none !important;
53
- }
54
-
55
- [part='overlay'] {
56
- overflow: auto;
57
- pointer-events: auto;
58
-
59
- /* Prevent overflowing the host */
60
- max-width: 100%;
61
- box-sizing: border-box;
62
-
63
- -webkit-tap-highlight-color: initial; /* reenable tap highlight inside */
64
- }
65
-
66
- [part='backdrop'] {
67
- z-index: -1;
68
- content: '';
69
- background: rgba(0, 0, 0, 0.5);
70
- position: fixed;
71
- inset: 0;
72
- pointer-events: auto;
73
- }
74
- `;
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { overlay } from '@vaadin/vaadin-lumo-styles/mixins/overlay.js';
2
- import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
-
4
- registerStyles('vaadin-overlay', overlay, { moduleId: 'lumo-vaadin-overlay' });
@@ -1,2 +0,0 @@
1
- import './vaadin-overlay-styles.js';
2
- import '../../src/vaadin-overlay.js';
@@ -1,2 +0,0 @@
1
- import './vaadin-overlay-styles.js';
2
- import '../../src/vaadin-overlay.js';