@vialiq/web-components 0.17.0 → 0.18.0
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/base/draggable-mixin.d.ts +2 -0
- package/base/draggable-mixin.d.ts.map +1 -1
- package/base/overlay-manager.d.ts +7 -6
- package/base/overlay-manager.d.ts.map +1 -1
- package/base/resizable-mixin.d.ts +28 -0
- package/base/resizable-mixin.d.ts.map +1 -0
- package/index.js +4 -1299
- package/{overlay-manager-CZSDXl6Z.js → overlay-manager-xco6S92C.js} +27 -26
- package/package.json +2 -2
- package/tooltip/vi-tooltip.js +1 -1
|
@@ -1,48 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OverlayManagerService
|
|
3
|
-
*
|
|
4
|
-
* A singleton service responsible for managing the z-index stacking context
|
|
3
|
+
*
|
|
4
|
+
* A singleton service responsible for managing the z-index stacking context
|
|
5
5
|
* of all floating elements (Modals, Dropdowns, Tooltips, Toasts) across the application.
|
|
6
|
-
*
|
|
7
|
-
* It ensures that newly opened overlays always appear on top of existing ones by
|
|
6
|
+
*
|
|
7
|
+
* It ensures that newly opened overlays always appear on top of existing ones by
|
|
8
8
|
* maintaining a registry and dynamically calculating the next highest z-index.
|
|
9
|
-
* It also manages global state side-effects, such as locking `document.body` scroll
|
|
9
|
+
* It also manages global state side-effects, such as locking `document.body` scroll
|
|
10
10
|
* when a modal is active.
|
|
11
11
|
*/ class OverlayManagerService {
|
|
12
|
-
|
|
13
|
-
get baseZIndex() {
|
|
14
|
-
if (this._baseZIndexCache !== undefined) return this._baseZIndexCache;
|
|
12
|
+
getBaseZIndex(element) {
|
|
15
13
|
if (typeof document !== 'undefined' && typeof getComputedStyle !== 'undefined') {
|
|
16
14
|
// Derive base stacking context from the modal z-index token (minus 10 to start slightly below it)
|
|
17
|
-
|
|
15
|
+
// Read directly from the element if provided to support CSS variable scoping/theming.
|
|
16
|
+
const target = element || document.documentElement;
|
|
17
|
+
const cssVar = getComputedStyle(target).getPropertyValue('--vi-modal-z-index').trim();
|
|
18
18
|
const parsed = parseInt(cssVar, 10);
|
|
19
|
-
|
|
20
|
-
} else {
|
|
21
|
-
this._baseZIndexCache = 1040;
|
|
19
|
+
return !isNaN(parsed) ? parsed - 10 : 1040;
|
|
22
20
|
}
|
|
23
|
-
return
|
|
21
|
+
return 1040;
|
|
24
22
|
}
|
|
25
23
|
overlays = [];
|
|
26
24
|
_previousOverflow = null;
|
|
27
25
|
/**
|
|
28
26
|
* Registers an element as an active overlay.
|
|
29
27
|
* Calculates and returns the appropriate z-index for this overlay.
|
|
30
|
-
*
|
|
28
|
+
*
|
|
31
29
|
* @param element The DOM element being registered (e.g., the modal dialog or dropdown listbox)
|
|
32
30
|
* @param type The type of overlay, used to determine behaviors like scroll-locking.
|
|
31
|
+
* @param scrollStrategy How this overlay interacts with background scrolling.
|
|
33
32
|
* @returns The calculated z-index to be applied to the element.
|
|
34
|
-
*/ register(element, type = 'dropdown') {
|
|
33
|
+
*/ register(element, type = 'dropdown', scrollStrategy) {
|
|
35
34
|
this.unregister(element); // Ensure no duplicates
|
|
36
|
-
let highestZIndex = this.
|
|
35
|
+
let highestZIndex = this.getBaseZIndex(element);
|
|
37
36
|
if (this.overlays.length > 0) {
|
|
38
|
-
highestZIndex = Math.max(...this.overlays.map((o)=>o.zIndex));
|
|
37
|
+
highestZIndex = Math.max(...this.overlays.map((o)=>o.zIndex), highestZIndex);
|
|
39
38
|
}
|
|
40
39
|
// Increment by 10 to allow room for backdrops (which typically sit at z-index - 1)
|
|
41
40
|
const newZIndex = highestZIndex + 10;
|
|
41
|
+
const finalStrategy = scrollStrategy ?? (type === 'modal' ? 'block' : 'noop');
|
|
42
42
|
this.overlays.push({
|
|
43
43
|
element,
|
|
44
44
|
type,
|
|
45
|
-
zIndex: newZIndex
|
|
45
|
+
zIndex: newZIndex,
|
|
46
|
+
scrollStrategy: finalStrategy
|
|
46
47
|
});
|
|
47
48
|
this._updateBodyScroll();
|
|
48
49
|
return newZIndex;
|
|
@@ -50,7 +51,7 @@
|
|
|
50
51
|
/**
|
|
51
52
|
* Unregisters an element, removing it from the overlay stack.
|
|
52
53
|
* Should be called when the overlay is closed or disconnected from the DOM.
|
|
53
|
-
*
|
|
54
|
+
*
|
|
54
55
|
* @param element The DOM element to unregister.
|
|
55
56
|
*/ unregister(element) {
|
|
56
57
|
this.overlays = this.overlays.filter((o)=>o.element !== element);
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* Gets the assigned z-index for an element if it is currently registered.
|
|
61
|
-
*
|
|
62
|
+
*
|
|
62
63
|
* @param element The DOM element to query.
|
|
63
64
|
* @returns The z-index number, or null if the element is not registered.
|
|
64
65
|
*/ getZIndex(element) {
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
/**
|
|
69
70
|
* Evaluates whether the provided element is currently the top-most active overlay.
|
|
70
71
|
* Useful for trapping focus or handling global Escape key presses.
|
|
71
|
-
*
|
|
72
|
+
*
|
|
72
73
|
* @param element The DOM element to check.
|
|
73
74
|
* @returns True if the element has the highest z-index in the registry.
|
|
74
75
|
*/ isTopOverlay(element) {
|
|
@@ -77,12 +78,12 @@
|
|
|
77
78
|
return topOverlay.element === element;
|
|
78
79
|
}
|
|
79
80
|
/**
|
|
80
|
-
* Locks or unlocks the document.body scroll based on the
|
|
81
|
-
* Modals
|
|
82
|
-
* It applies a utility class `vi-scroll-locked` to the body.
|
|
81
|
+
* Locks or unlocks the document.body scroll based on the active overlays.
|
|
82
|
+
* Modals (and other overlays with scrollStrategy='block') require the body
|
|
83
|
+
* to be unscrollable. It applies a utility class `vi-scroll-locked` to the body.
|
|
83
84
|
*/ _updateBodyScroll() {
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
85
|
+
const hasBlock = this.overlays.some((o)=>o.scrollStrategy === 'block');
|
|
86
|
+
if (hasBlock) {
|
|
86
87
|
// Prevent double-setting if already locked
|
|
87
88
|
if (!document.body.classList.contains('vi-scroll-locked')) {
|
|
88
89
|
document.body.classList.add('vi-scroll-locked');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vialiq/web-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
},
|
|
104
104
|
"peerDependencies": {
|
|
105
105
|
"@floating-ui/dom": ">=1.0.0",
|
|
106
|
-
"@vialiq/flux-ui": "
|
|
106
|
+
"@vialiq/flux-ui": ">=0.0.4 <0.1.0",
|
|
107
107
|
"@vialiq/icons": ">=0.0.3 <0.1.0",
|
|
108
108
|
"lit": "^3.0.0"
|
|
109
109
|
},
|
package/tooltip/vi-tooltip.js
CHANGED
|
@@ -2,7 +2,7 @@ import { unsafeCSS, css, nothing, html } from 'lit';
|
|
|
2
2
|
import { customElement, property, state, query } from 'lit/decorators.js';
|
|
3
3
|
import { V as ViElement } from '../vi-element-C6GfDPs3.js';
|
|
4
4
|
import { autoUpdate, offset, flip, shift, arrow, computePosition } from '@floating-ui/dom';
|
|
5
|
-
import { O as OverlayManager } from '../overlay-manager-
|
|
5
|
+
import { O as OverlayManager } from '../overlay-manager-xco6S92C.js';
|
|
6
6
|
|
|
7
7
|
const tooltipStyles = "@charset \"UTF-8\";@layer reset,components,utilities;.tooltip-panel{position:fixed;z-index:var(--vi-tooltip-z-index, var(--vi-tooltip-z-index, 1070));pointer-events:none;opacity:0;transform:scale(.95);transition:opacity .15s ease-out,transform .15s ease-out;margin:0;border:none;background:transparent;padding:0;overflow:visible;font-family:var(--vi-font-family-base, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif)}.tooltip-panel[popover]:popover-open{display:block;pointer-events:auto;opacity:1;transform:scale(1)}.tooltip-panel{transition-property:opacity,transform,display,overlay;transition-behavior:allow-discrete}@media(prefers-reduced-motion:reduce){.tooltip-panel{transition:none;transform:none}}.tooltip-content{background-color:var(--vi-tooltip-background, var(--vi-layer-inverse, #111827));color:var(--vi-tooltip-color, var(--vi-text-primary-inverse, #ffffff));font-size:var(--vi-tooltip-font-size, 12px);line-height:1.4;padding:var(--vi-tooltip-padding, 6px 10px);border-radius:var(--vi-tooltip-border-radius, 4px);box-shadow:var(--vi-tooltip-shadow, var(--vi-shadow-md, 0 4px 6px -1px rgba(0, 0, 0, .1)));max-width:var(--vi-tooltip-max-width, 240px);word-wrap:break-word;white-space:normal;position:relative}.tooltip-arrow{position:absolute;width:0;height:0;border-style:solid;border-color:transparent;pointer-events:none}.tooltip-panel[placement^=top] .tooltip-arrow,.tooltip-panel[data-placement^=top] .tooltip-arrow{bottom:calc(-1 * var(--vi-tooltip-arrow-size, 6px));left:50%;transform:translate(-50%);border-width:var(--vi-tooltip-arrow-size, 6px) var(--vi-tooltip-arrow-size, 6px) 0;border-top-color:var(--vi-tooltip-background, var(--vi-layer-inverse, #111827))}.tooltip-panel[placement^=bottom] .tooltip-arrow,.tooltip-panel[data-placement^=bottom] .tooltip-arrow{top:calc(-1 * var(--vi-tooltip-arrow-size, 6px));left:50%;transform:translate(-50%);border-width:0 var(--vi-tooltip-arrow-size, 6px) var(--vi-tooltip-arrow-size, 6px);border-bottom-color:var(--vi-tooltip-background, var(--vi-layer-inverse, #111827))}.tooltip-panel[placement=left] .tooltip-arrow,.tooltip-panel[data-placement=left] .tooltip-arrow{right:calc(-1 * var(--vi-tooltip-arrow-size, 6px));top:50%;transform:translateY(-50%);border-width:var(--vi-tooltip-arrow-size, 6px) 0 var(--vi-tooltip-arrow-size, 6px) var(--vi-tooltip-arrow-size, 6px);border-left-color:var(--vi-tooltip-background, var(--vi-layer-inverse, #111827))}.tooltip-panel[placement=right] .tooltip-arrow,.tooltip-panel[data-placement=right] .tooltip-arrow{left:calc(-1 * var(--vi-tooltip-arrow-size, 6px));top:50%;transform:translateY(-50%);border-width:var(--vi-tooltip-arrow-size, 6px) var(--vi-tooltip-arrow-size, 6px) var(--vi-tooltip-arrow-size, 6px) 0;border-right-color:var(--vi-tooltip-background, var(--vi-layer-inverse, #111827))}.tooltip-panel[placement$=-start] .tooltip-arrow,.tooltip-panel[data-placement$=-start] .tooltip-arrow{left:12px;transform:none}.tooltip-panel[placement$=-end] .tooltip-arrow,.tooltip-panel[data-placement$=-end] .tooltip-arrow{left:auto;right:12px;transform:none}:host{display:inline-block}";
|
|
8
8
|
|