@vialiq/web-components 0.14.0 → 0.15.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.
@@ -27,8 +27,8 @@ declare const ViInput_base: typeof ViElement & (new (...args: any[]) => import('
27
27
  *
28
28
  * @slot helper - Helper text shown below the input.
29
29
  *
30
- * @fires {CustomEvent<{value:string}>} vialiq-input - Every keystroke. Bubbles, composed.
31
- * @fires {CustomEvent<{value:string}>} vialiq-change - Value committed (blur). Bubbles, composed.
30
+ * @fires {CustomEvent<{value:string}>} vi-input-input - Every keystroke. Bubbles, composed.
31
+ * @fires {CustomEvent<{value:string}>} vi-input-change - Value committed (blur). Bubbles, composed.
32
32
  * @fires {Event} invalid - Cancelable; fires when checkValidity() fails.
33
33
  *
34
34
  * @csspart field - The outer `<div>` wrapper
package/input/vi-input.js CHANGED
@@ -634,7 +634,7 @@ new class extends _identity {
634
634
  e.stopPropagation();
635
635
  const input = e.target;
636
636
  this.value = input.value;
637
- this.dispatchEvent(new CustomEvent('vialiq-input', {
637
+ this.dispatchEvent(new CustomEvent('vi-input-input', {
638
638
  detail: {
639
639
  value: this.value
640
640
  },
@@ -646,7 +646,7 @@ new class extends _identity {
646
646
  e.stopPropagation();
647
647
  const input = e.target;
648
648
  this.value = input.value;
649
- this.dispatchEvent(new CustomEvent('vialiq-change', {
649
+ this.dispatchEvent(new CustomEvent('vi-input-change', {
650
650
  detail: {
651
651
  value: this.value
652
652
  },
@@ -0,0 +1,108 @@
1
+ /**
2
+ * OverlayManagerService
3
+ *
4
+ * A singleton service responsible for managing the z-index stacking context
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
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
10
+ * when a modal is active.
11
+ */ class OverlayManagerService {
12
+ _baseZIndexCache;
13
+ get baseZIndex() {
14
+ if (this._baseZIndexCache !== undefined) return this._baseZIndexCache;
15
+ if (typeof document !== 'undefined' && typeof getComputedStyle !== 'undefined') {
16
+ // Derive base stacking context from the modal z-index token (minus 10 to start slightly below it)
17
+ const cssVar = getComputedStyle(document.documentElement).getPropertyValue('--vi-modal-z-index').trim();
18
+ const parsed = parseInt(cssVar, 10);
19
+ this._baseZIndexCache = !isNaN(parsed) ? parsed - 10 : 1040;
20
+ } else {
21
+ this._baseZIndexCache = 1040;
22
+ }
23
+ return this._baseZIndexCache;
24
+ }
25
+ overlays = [];
26
+ _previousOverflow = null;
27
+ /**
28
+ * Registers an element as an active overlay.
29
+ * Calculates and returns the appropriate z-index for this overlay.
30
+ *
31
+ * @param element The DOM element being registered (e.g., the modal dialog or dropdown listbox)
32
+ * @param type The type of overlay, used to determine behaviors like scroll-locking.
33
+ * @returns The calculated z-index to be applied to the element.
34
+ */ register(element, type = 'dropdown') {
35
+ this.unregister(element); // Ensure no duplicates
36
+ let highestZIndex = this.baseZIndex;
37
+ if (this.overlays.length > 0) {
38
+ highestZIndex = Math.max(...this.overlays.map((o)=>o.zIndex));
39
+ }
40
+ // Increment by 10 to allow room for backdrops (which typically sit at z-index - 1)
41
+ const newZIndex = highestZIndex + 10;
42
+ this.overlays.push({
43
+ element,
44
+ type,
45
+ zIndex: newZIndex
46
+ });
47
+ this._updateBodyScroll();
48
+ return newZIndex;
49
+ }
50
+ /**
51
+ * Unregisters an element, removing it from the overlay stack.
52
+ * Should be called when the overlay is closed or disconnected from the DOM.
53
+ *
54
+ * @param element The DOM element to unregister.
55
+ */ unregister(element) {
56
+ this.overlays = this.overlays.filter((o)=>o.element !== element);
57
+ this._updateBodyScroll();
58
+ }
59
+ /**
60
+ * Gets the assigned z-index for an element if it is currently registered.
61
+ *
62
+ * @param element The DOM element to query.
63
+ * @returns The z-index number, or null if the element is not registered.
64
+ */ getZIndex(element) {
65
+ const item = this.overlays.find((o)=>o.element === element);
66
+ return item ? item.zIndex : null;
67
+ }
68
+ /**
69
+ * Evaluates whether the provided element is currently the top-most active overlay.
70
+ * Useful for trapping focus or handling global Escape key presses.
71
+ *
72
+ * @param element The DOM element to check.
73
+ * @returns True if the element has the highest z-index in the registry.
74
+ */ isTopOverlay(element) {
75
+ if (this.overlays.length === 0) return false;
76
+ const topOverlay = this.overlays.reduce((prev, current)=>prev.zIndex > current.zIndex ? prev : current);
77
+ return topOverlay.element === element;
78
+ }
79
+ /**
80
+ * Locks or unlocks the document.body scroll based on the presence of modals.
81
+ * Modals require the body to be unscrollable to trap scroll inside the modal.
82
+ * It applies a utility class `vi-scroll-locked` to the body.
83
+ */ _updateBodyScroll() {
84
+ const hasModal = this.overlays.some((o)=>o.type === 'modal');
85
+ if (hasModal) {
86
+ // Prevent double-setting if already locked
87
+ if (!document.body.classList.contains('vi-scroll-locked')) {
88
+ document.body.classList.add('vi-scroll-locked');
89
+ this._previousOverflow = document.body.style.getPropertyValue('overflow') || null;
90
+ document.body.style.setProperty('overflow', 'hidden', 'important');
91
+ }
92
+ } else {
93
+ if (document.body.classList.contains('vi-scroll-locked')) {
94
+ document.body.classList.remove('vi-scroll-locked');
95
+ if (this._previousOverflow !== null) {
96
+ document.body.style.setProperty('overflow', this._previousOverflow);
97
+ } else {
98
+ document.body.style.removeProperty('overflow');
99
+ }
100
+ this._previousOverflow = null;
101
+ }
102
+ }
103
+ }
104
+ }
105
+ // Export as a singleton
106
+ const OverlayManager = new OverlayManagerService();
107
+
108
+ export { OverlayManager as O };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vialiq/web-components",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -103,8 +103,8 @@
103
103
  },
104
104
  "peerDependencies": {
105
105
  "@floating-ui/dom": ">=1.0.0",
106
- "@vialiq/flux-ui": "^0.12.0",
107
- "@vialiq/icons": "^0.2.0",
106
+ "@vialiq/flux-ui": ">=0.0.4 <0.1.0",
107
+ "@vialiq/icons": ">=0.0.3 <0.1.0",
108
108
  "lit": "^3.0.0"
109
109
  },
110
110
  "keywords": [
@@ -23,7 +23,7 @@ declare const ViRadioGroup_base: typeof ViElement & (new (...args: any[]) => imp
23
23
  * @slot label - Text displayed above the group.
24
24
  * @slot helper - Helper text displayed below the group.
25
25
  *
26
- * @fires {CustomEvent<{value: string}>} vialiq-change - Dispatched when selection changes. Bubbles, composed.
26
+ * @fires {CustomEvent<{value: string}>} vi-radio-group-change - Dispatched when selection changes. Bubbles, composed.
27
27
  * @fires {Event} invalid - Fired when validation check fails.
28
28
  */
29
29
  export declare class ViRadioGroup extends ViRadioGroup_base {
@@ -649,7 +649,7 @@ new class extends _identity {
649
649
  this.value = targetRadio.value;
650
650
  this._updateRadios();
651
651
  if (this.value !== oldValue) {
652
- this.dispatchEvent(new CustomEvent('vialiq-change', {
652
+ this.dispatchEvent(new CustomEvent('vi-radio-group-change', {
653
653
  detail: {
654
654
  value: this.value
655
655
  },
@@ -696,7 +696,7 @@ new class extends _identity {
696
696
  this._updateRadios();
697
697
  targetRadio.focus();
698
698
  if (this.value !== oldValue) {
699
- this.dispatchEvent(new CustomEvent('vialiq-change', {
699
+ this.dispatchEvent(new CustomEvent('vi-radio-group-change', {
700
700
  detail: {
701
701
  value: this.value
702
702
  },
@@ -715,7 +715,7 @@ new class extends _identity {
715
715
  this.value = '';
716
716
  this._updateRadios();
717
717
  if (this.value !== oldValue) {
718
- this.dispatchEvent(new CustomEvent('vialiq-change', {
718
+ this.dispatchEvent(new CustomEvent('vi-radio-group-change', {
719
719
  detail: {
720
720
  value: this.value
721
721
  },
@@ -2,116 +2,10 @@ 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-CZSDXl6Z.js';
5
6
 
6
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}";
7
8
 
8
- /**
9
- * OverlayManagerService
10
- *
11
- * A singleton service responsible for managing the z-index stacking context
12
- * of all floating elements (Modals, Dropdowns, Tooltips, Toasts) across the application.
13
- *
14
- * It ensures that newly opened overlays always appear on top of existing ones by
15
- * maintaining a registry and dynamically calculating the next highest z-index.
16
- * It also manages global state side-effects, such as locking `document.body` scroll
17
- * when a modal is active.
18
- */ class OverlayManagerService {
19
- _baseZIndexCache;
20
- get baseZIndex() {
21
- if (this._baseZIndexCache !== undefined) return this._baseZIndexCache;
22
- if (typeof document !== 'undefined' && typeof getComputedStyle !== 'undefined') {
23
- // Derive base stacking context from the modal z-index token (minus 10 to start slightly below it)
24
- const cssVar = getComputedStyle(document.documentElement).getPropertyValue('--vi-modal-z-index').trim();
25
- const parsed = parseInt(cssVar, 10);
26
- this._baseZIndexCache = !isNaN(parsed) ? parsed - 10 : 1040;
27
- } else {
28
- this._baseZIndexCache = 1040;
29
- }
30
- return this._baseZIndexCache;
31
- }
32
- overlays = [];
33
- _previousOverflow = null;
34
- /**
35
- * Registers an element as an active overlay.
36
- * Calculates and returns the appropriate z-index for this overlay.
37
- *
38
- * @param element The DOM element being registered (e.g., the modal dialog or dropdown listbox)
39
- * @param type The type of overlay, used to determine behaviors like scroll-locking.
40
- * @returns The calculated z-index to be applied to the element.
41
- */ register(element, type = 'dropdown') {
42
- this.unregister(element); // Ensure no duplicates
43
- let highestZIndex = this.baseZIndex;
44
- if (this.overlays.length > 0) {
45
- highestZIndex = Math.max(...this.overlays.map((o)=>o.zIndex));
46
- }
47
- // Increment by 10 to allow room for backdrops (which typically sit at z-index - 1)
48
- const newZIndex = highestZIndex + 10;
49
- this.overlays.push({
50
- element,
51
- type,
52
- zIndex: newZIndex
53
- });
54
- this._updateBodyScroll();
55
- return newZIndex;
56
- }
57
- /**
58
- * Unregisters an element, removing it from the overlay stack.
59
- * Should be called when the overlay is closed or disconnected from the DOM.
60
- *
61
- * @param element The DOM element to unregister.
62
- */ unregister(element) {
63
- this.overlays = this.overlays.filter((o)=>o.element !== element);
64
- this._updateBodyScroll();
65
- }
66
- /**
67
- * Gets the assigned z-index for an element if it is currently registered.
68
- *
69
- * @param element The DOM element to query.
70
- * @returns The z-index number, or null if the element is not registered.
71
- */ getZIndex(element) {
72
- const item = this.overlays.find((o)=>o.element === element);
73
- return item ? item.zIndex : null;
74
- }
75
- /**
76
- * Evaluates whether the provided element is currently the top-most active overlay.
77
- * Useful for trapping focus or handling global Escape key presses.
78
- *
79
- * @param element The DOM element to check.
80
- * @returns True if the element has the highest z-index in the registry.
81
- */ isTopOverlay(element) {
82
- if (this.overlays.length === 0) return false;
83
- const topOverlay = this.overlays.reduce((prev, current)=>prev.zIndex > current.zIndex ? prev : current);
84
- return topOverlay.element === element;
85
- }
86
- /**
87
- * Locks or unlocks the document.body scroll based on the presence of modals.
88
- * Modals require the body to be unscrollable to trap scroll inside the modal.
89
- * It applies a utility class `vi-scroll-locked` to the body.
90
- */ _updateBodyScroll() {
91
- const hasModal = this.overlays.some((o)=>o.type === 'modal');
92
- if (hasModal) {
93
- // Prevent double-setting if already locked
94
- if (!document.body.classList.contains('vi-scroll-locked')) {
95
- document.body.classList.add('vi-scroll-locked');
96
- this._previousOverflow = document.body.style.getPropertyValue('overflow') || null;
97
- document.body.style.setProperty('overflow', 'hidden', 'important');
98
- }
99
- } else {
100
- if (document.body.classList.contains('vi-scroll-locked')) {
101
- document.body.classList.remove('vi-scroll-locked');
102
- if (this._previousOverflow !== null) {
103
- document.body.style.setProperty('overflow', this._previousOverflow);
104
- } else {
105
- document.body.style.removeProperty('overflow');
106
- }
107
- this._previousOverflow = null;
108
- }
109
- }
110
- }
111
- }
112
- // Export as a singleton
113
- const OverlayManager = new OverlayManagerService();
114
-
115
9
  function applyDecs2203RFactory() {
116
10
  function createAddInitializerMethod(initializers, decoratorFinishedRef) {
117
11
  return function addInitializer(initializer) {
@@ -790,7 +684,7 @@ new class extends _identity {
790
684
  document.addEventListener('pointerdown', this._handleDocumentClick);
791
685
  }
792
686
  }
793
- this.dispatchEvent(new CustomEvent('vialiq-show', {
687
+ this.dispatchEvent(new CustomEvent('vi-tooltip-show', {
794
688
  bubbles: true,
795
689
  composed: true
796
690
  }));
@@ -815,7 +709,7 @@ new class extends _identity {
815
709
  }
816
710
  document.removeEventListener('pointerdown', this._handleDocumentClick);
817
711
  }
818
- this.dispatchEvent(new CustomEvent('vialiq-hide', {
712
+ this.dispatchEvent(new CustomEvent('vi-tooltip-hide', {
819
713
  bubbles: true,
820
714
  composed: true
821
715
  }));