@zealsolutions/zeal-ui 1.0.0-alpha.361 → 1.0.0-alpha.362

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.
@@ -0,0 +1,115 @@
1
+ import { ref as r, onUnmounted as M, openBlock as y, createElementBlock as L, Fragment as z, createElementVNode as m, renderSlot as B, createBlock as X, Teleport as D, withDirectives as N, normalizeStyle as $, createTextVNode as C, toDisplayString as F, normalizeClass as P, vShow as V, nextTick as Y } from "vue";
2
+ const s = r(null);
3
+ function q() {
4
+ function e(t) {
5
+ s.value && s.value !== t && s.value.hideImmediate(), s.value = t;
6
+ }
7
+ function n(t) {
8
+ s.value === t && (s.value = null);
9
+ }
10
+ return {
11
+ register: e,
12
+ unregister: n
13
+ };
14
+ }
15
+ function H({ rect: e, scrollX: n = 0, scrollY: t = 0, position: v = "top", offset: u = 20 }) {
16
+ const l = v === "bottom", c = e.left + n + e.width / 2, p = l ? e.bottom + t + u : e.top + t - u;
17
+ return {
18
+ top: `${Math.round(p)}px`,
19
+ left: `${Math.round(c)}px`,
20
+ transform: l ? "translateX(-50%)" : "translateX(-50%) translateY(-100%)",
21
+ position: "absolute",
22
+ pointerEvents: "none"
23
+ };
24
+ }
25
+ const I = { class: "px-4 py-2 text-center pointer-events-none" }, U = {
26
+ __name: "Tooltip",
27
+ props: {
28
+ text: {
29
+ type: String,
30
+ required: !0
31
+ },
32
+ position: {
33
+ type: String,
34
+ default: "top"
35
+ // 'top', 'bottom', 'left', 'right'
36
+ },
37
+ offset: {
38
+ type: Number,
39
+ default: 20
40
+ // Offset from the trigger element
41
+ }
42
+ },
43
+ setup(e) {
44
+ const n = e, { register: t, unregister: v } = q(), u = {
45
+ hideImmediate: w
46
+ }, l = r(!1);
47
+ let c = null, p = null;
48
+ const d = r(!1), b = r(null), T = r(null), g = r({ top: "0px", left: "0px" });
49
+ function h() {
50
+ const o = b.value, i = T.value;
51
+ if (!o || !i)
52
+ return;
53
+ const a = o.getBoundingClientRect(), k = window.scrollY || document.documentElement.scrollTop, S = window.scrollX || document.documentElement.scrollLeft;
54
+ g.value = H({ rect: a, scrollX: S, scrollY: k, position: n.position, offset: n.offset });
55
+ }
56
+ function f() {
57
+ clearTimeout(p), p = setTimeout(() => {
58
+ h();
59
+ }, 50);
60
+ }
61
+ function E() {
62
+ d.value || (clearTimeout(c), t(u), l.value = !0, d.value = !0, Y(() => {
63
+ setTimeout(() => {
64
+ h();
65
+ }, 0);
66
+ }), window.addEventListener("scroll", f), window.addEventListener("resize", f));
67
+ }
68
+ function x() {
69
+ l.value = !1, c = setTimeout(() => {
70
+ l.value || w();
71
+ }, 100);
72
+ }
73
+ function w() {
74
+ d.value = !1, v(u), window.removeEventListener("scroll", f), window.removeEventListener("resize", f);
75
+ }
76
+ return M(() => {
77
+ w();
78
+ }), (o, i) => (y(), L(z, null, [
79
+ m("span", {
80
+ ref_key: "triggerEl",
81
+ ref: b,
82
+ onMouseenter: E,
83
+ onMouseleave: x,
84
+ onFocus: i[0] || (i[0] = (...a) => o.showTooltip && o.showTooltip(...a)),
85
+ onBlur: i[1] || (i[1] = (...a) => o.hideTooltip && o.hideTooltip(...a)),
86
+ tabindex: "0",
87
+ class: "inline-block will-change"
88
+ }, [
89
+ B(o.$slots, "default")
90
+ ], 544),
91
+ (y(), X(D, { to: "body" }, [
92
+ N(m("div", {
93
+ class: "absolute z-50 bg-black-950 text-white font-semibold text-xs text-center rounded whitespace-nowrap pointer-events-none transition-none",
94
+ style: $(g.value),
95
+ ref_key: "tooltipEl",
96
+ ref: T,
97
+ onMouseenter: E,
98
+ onMouseleave: x
99
+ }, [
100
+ m("div", I, [
101
+ C(F(e.text) + " ", 1),
102
+ m("span", {
103
+ class: P(["absolute left-1/2 w-2 h-2 bg-black-950 rotate-45 -translate-x-1/2 pointer-events-none", e.position === "bottom" ? "-top-1" : "-bottom-1"])
104
+ }, null, 2)
105
+ ])
106
+ ], 36), [
107
+ [V, d.value]
108
+ ])
109
+ ]))
110
+ ], 64));
111
+ }
112
+ };
113
+ export {
114
+ U as _
115
+ };
@@ -1,7 +1,7 @@
1
1
  import { openBlock as a, createElementBlock as u, createVNode as T, createElementVNode as r, createTextVNode as j, mergeModels as ne, useModel as ke, getCurrentInstance as ce, ref as k, computed as $, watch as K, nextTick as oe, onMounted as ge, onBeforeUnmount as we, createBlock as I, Teleport as Ce, withModifiers as N, withDirectives as G, vModelText as $e, createCommentVNode as v, normalizeClass as M, toDisplayString as b, Fragment as H, renderList as P, normalizeStyle as q, pushScopeId as Se, popScopeId as _e, Transition as ue, withCtx as F, resolveDynamicComponent as de, unref as Q, vShow as pe, renderSlot as R } from "vue";
2
2
  import Me from "../../HouseIcon-BxmNyxvv.js";
3
3
  import Te from "../../ArrowLeftIcon-Cgsy08pY.js";
4
- import { _ as Ae } from "../../Tooltip-9q1tA0wI.js";
4
+ import { _ as Ae } from "../../Tooltip-CQjz2EXM.js";
5
5
  import fe from "../../MagnifyingGlassIcon-ChYNIA-H.js";
6
6
  import { _ as Ie } from "../../_plugin-vue_export-helper-CHgC5LLL.js";
7
7
  import { o as xe } from "../../index-D9ihCfA2.js";
@@ -1,5 +1,5 @@
1
1
  import { _ as r } from "../../BaseTooltip-CcnCHpL4.js";
2
- import { _ as a } from "../../Tooltip-9q1tA0wI.js";
2
+ import { _ as a } from "../../Tooltip-CQjz2EXM.js";
3
3
  export {
4
4
  r as BaseTooltip,
5
5
  a as Tooltip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zealsolutions/zeal-ui",
3
- "version": "1.0.0-alpha.361",
3
+ "version": "1.0.0-alpha.362",
4
4
  "description": "UI library for Zeal Solutions",
5
5
  "author": "Zeal Solutions",
6
6
  "license": "ISC",
@@ -1,110 +0,0 @@
1
- import { ref as i, onUnmounted as z, openBlock as y, createElementBlock as D, Fragment as N, createElementVNode as a, renderSlot as Y, createBlock as $, Teleport as F, withDirectives as P, normalizeStyle as V, createTextVNode as W, toDisplayString as _, vShow as q, nextTick as C } from "vue";
2
- const l = i(null);
3
- function H() {
4
- function s(n) {
5
- l.value && l.value !== n && l.value.hideImmediate(), l.value = n;
6
- }
7
- function c(n) {
8
- l.value === n && (l.value = null);
9
- }
10
- return {
11
- register: s,
12
- unregister: c
13
- };
14
- }
15
- const I = { class: "px-4 py-2 text-center pointer-events-none" }, R = /* @__PURE__ */ a("span", { class: "fixed left-1/2 -bottom-1 w-2 h-2 bg-black-950 rotate-45 -translate-x-1/2 pointer-events-none" }, null, -1), j = {
16
- __name: "Tooltip",
17
- props: {
18
- text: {
19
- type: String,
20
- required: !0
21
- },
22
- position: {
23
- type: String,
24
- default: "top"
25
- // 'top', 'bottom', 'left', 'right'
26
- },
27
- offset: {
28
- type: Number,
29
- default: 20
30
- // Offset from the trigger element
31
- }
32
- },
33
- setup(s) {
34
- const c = s, { register: n, unregister: k } = H(), f = {
35
- hideImmediate: p
36
- }, d = i(!1);
37
- let v = null, m = null;
38
- const r = i(!1), w = i(null), g = i(null), T = i({ top: "0px", left: "0px" });
39
- function h() {
40
- const e = w.value, t = g.value;
41
- if (!e || !t)
42
- return;
43
- const o = e.getBoundingClientRect(), E = t.offsetWidth, M = window.scrollY || document.documentElement.scrollTop, S = window.scrollX || document.documentElement.scrollLeft, L = o.left + S + o.width / 2, B = o.top + M - c.offset, X = L - E / 2;
44
- T.value = {
45
- top: `${Math.round(B)}px`,
46
- left: `${Math.round(X)}px`,
47
- transform: "translateY(-100%) translateX(-50%) translateX(" + (E - 16) / 2 + "px)",
48
- // Adjust for tooltip width and padding
49
- position: "absolute",
50
- pointerEvents: "none"
51
- };
52
- }
53
- function u() {
54
- clearTimeout(m), m = setTimeout(() => {
55
- h();
56
- }, 50);
57
- }
58
- function x() {
59
- r.value || (clearTimeout(v), n(f), d.value = !0, r.value = !0, C(() => {
60
- setTimeout(() => {
61
- h();
62
- }, 0);
63
- }), window.addEventListener("scroll", u), window.addEventListener("resize", u));
64
- }
65
- function b() {
66
- d.value = !1, v = setTimeout(() => {
67
- d.value || p();
68
- }, 100);
69
- }
70
- function p() {
71
- r.value = !1, k(f), window.removeEventListener("scroll", u), window.removeEventListener("resize", u);
72
- }
73
- return z(() => {
74
- p();
75
- }), (e, t) => (y(), D(N, null, [
76
- a("span", {
77
- ref_key: "triggerEl",
78
- ref: w,
79
- onMouseenter: x,
80
- onMouseleave: b,
81
- onFocus: t[0] || (t[0] = (...o) => e.showTooltip && e.showTooltip(...o)),
82
- onBlur: t[1] || (t[1] = (...o) => e.hideTooltip && e.hideTooltip(...o)),
83
- tabindex: "0",
84
- class: "inline-block will-change"
85
- }, [
86
- Y(e.$slots, "default")
87
- ], 544),
88
- (y(), $(F, { to: "body" }, [
89
- P(a("div", {
90
- class: "absolute z-50 bg-black-950 text-white font-semibold text-xs text-center rounded whitespace-nowrap pointer-events-none transition-none",
91
- style: V(T.value),
92
- ref_key: "tooltipEl",
93
- ref: g,
94
- onMouseenter: x,
95
- onMouseleave: b
96
- }, [
97
- a("div", I, [
98
- W(_(s.text) + " ", 1),
99
- R
100
- ])
101
- ], 36), [
102
- [q, r.value]
103
- ])
104
- ]))
105
- ], 64));
106
- }
107
- };
108
- export {
109
- j as _
110
- };