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

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,110 @@
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
+ };