zero-tooltip 1.1.1 → 1.2.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/README.md +1 -1
- package/dist/types/tooltipConfig.d.ts +1 -1
- package/dist/zero-tooltip.js +149 -154
- package/dist/zero-tooltip.umd.cjs +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/tooltip.ts +41 -60
- package/src/types/tooltipConfig.ts +1 -1
package/README.md
CHANGED
|
@@ -129,7 +129,7 @@ const tooltipConfig: ZeroTooltipLocalConfig = reactive({
|
|
|
129
129
|
| arrowSize | *5* | number | Length of arrow hypotenuse in `px` (arrow is generated using border width property, creating square which gets divided in four triangles, thus `arrowSize` is length of square side) |
|
|
130
130
|
| arrowClasses | *undefined* | string | List of classes that will be added to arrow element |
|
|
131
131
|
| arrowMinOffsetFromTooltipCorner | *6* | number | Minimal allowed arrow offset in `px` from tooltip corner. Used in situations when tooltip does not have enough space to be centered relative to element that is being hover, thus arrow is rendered closer to one of the tooltip corners |
|
|
132
|
-
| zIndex | *1* | number | `z-index` css property value of tooltip |
|
|
132
|
+
| zIndex | *1* | number | string | `z-index` css property value of tooltip |
|
|
133
133
|
|
|
134
134
|
## ZeroTooltipLocalConfig
|
|
135
135
|
Same as [ZeroTooltipConfig](#ZeroTooltipConfig) with following additions:
|
package/dist/zero-tooltip.js
CHANGED
|
@@ -1,239 +1,234 @@
|
|
|
1
|
-
import { isReactive as
|
|
2
|
-
let
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
if (!
|
|
1
|
+
import { isReactive as N, watch as Z } from "vue";
|
|
2
|
+
let O;
|
|
3
|
+
const G = new Uint8Array(16);
|
|
4
|
+
function J() {
|
|
5
|
+
if (!O && (O = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !O))
|
|
6
6
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
7
|
-
return
|
|
7
|
+
return O(G);
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const w = [];
|
|
10
10
|
for (let e = 0; e < 256; ++e)
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
return
|
|
11
|
+
w.push((e + 256).toString(16).slice(1));
|
|
12
|
+
function K(e, t = 0) {
|
|
13
|
+
return w[e[t + 0]] + w[e[t + 1]] + w[e[t + 2]] + w[e[t + 3]] + "-" + w[e[t + 4]] + w[e[t + 5]] + "-" + w[e[t + 6]] + w[e[t + 7]] + "-" + w[e[t + 8]] + w[e[t + 9]] + "-" + w[e[t + 10]] + w[e[t + 11]] + w[e[t + 12]] + w[e[t + 13]] + w[e[t + 14]] + w[e[t + 15]];
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
randomUUID:
|
|
15
|
+
const Q = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), U = {
|
|
16
|
+
randomUUID: Q
|
|
17
17
|
};
|
|
18
|
-
function
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
18
|
+
function X(e, t, r) {
|
|
19
|
+
if (U.randomUUID && !t && !e)
|
|
20
|
+
return U.randomUUID();
|
|
21
21
|
e = e || {};
|
|
22
|
-
const s = e.random || (e.rng ||
|
|
22
|
+
const s = e.random || (e.rng || J)();
|
|
23
23
|
if (s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, t) {
|
|
24
24
|
r = r || 0;
|
|
25
|
-
for (let
|
|
26
|
-
t[r +
|
|
25
|
+
for (let o = 0; o < 16; ++o)
|
|
26
|
+
t[r + o] = s[o];
|
|
27
27
|
return t;
|
|
28
28
|
}
|
|
29
|
-
return
|
|
29
|
+
return K(s);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function Y() {
|
|
32
32
|
let e = [];
|
|
33
|
-
const t = (
|
|
34
|
-
if (r(
|
|
35
|
-
for (const
|
|
36
|
-
|
|
33
|
+
const t = (o, d) => {
|
|
34
|
+
if (r(o), e.length > 0)
|
|
35
|
+
for (const i of e)
|
|
36
|
+
i.addEventListener("scroll", d);
|
|
37
37
|
window.addEventListener("scroll", () => {
|
|
38
|
-
|
|
38
|
+
d(), s(d);
|
|
39
39
|
});
|
|
40
|
-
}, r = (
|
|
41
|
-
let
|
|
42
|
-
for (;
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
(
|
|
40
|
+
}, r = (o) => {
|
|
41
|
+
let d = o;
|
|
42
|
+
for (; d !== null && d.tagName !== "HTML"; ) {
|
|
43
|
+
if (d.scrollHeight !== d.clientHeight) {
|
|
44
|
+
const i = window.getComputedStyle(d);
|
|
45
|
+
(i.overflow === "auto" || i.overflow === "scroll") && e.push(d);
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
d = d.parentElement;
|
|
48
48
|
}
|
|
49
|
-
}, s = (
|
|
49
|
+
}, s = (o) => {
|
|
50
50
|
if (e.length > 0) {
|
|
51
|
-
for (const
|
|
52
|
-
|
|
51
|
+
for (const d of e)
|
|
52
|
+
d.removeEventListener("scroll", o);
|
|
53
53
|
e = [];
|
|
54
54
|
}
|
|
55
|
-
window.removeEventListener("scroll",
|
|
55
|
+
window.removeEventListener("scroll", o);
|
|
56
56
|
};
|
|
57
57
|
return { handleHideOnScroll: t };
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function E() {
|
|
60
60
|
let e = null, t = null;
|
|
61
|
-
return { handleHideOnResize: (
|
|
62
|
-
e = new ResizeObserver((
|
|
63
|
-
const
|
|
61
|
+
return { handleHideOnResize: (o, d) => {
|
|
62
|
+
e = new ResizeObserver((i) => {
|
|
63
|
+
const p = i[0].target;
|
|
64
64
|
if (t === null)
|
|
65
|
-
t =
|
|
65
|
+
t = o.getBoundingClientRect();
|
|
66
66
|
else {
|
|
67
|
-
const
|
|
68
|
-
(
|
|
67
|
+
const n = p.getBoundingClientRect();
|
|
68
|
+
(n.left !== t.left || n.top !== t.top || n.width !== t.width || n.height !== t.height) && d();
|
|
69
69
|
}
|
|
70
|
-
}), e.observe(
|
|
70
|
+
}), e.observe(o);
|
|
71
71
|
}, resetResizeReferences: () => {
|
|
72
72
|
e !== null && e.disconnect(), e = null, t = null;
|
|
73
73
|
} };
|
|
74
74
|
}
|
|
75
|
-
const { handleHideOnScroll:
|
|
75
|
+
const { handleHideOnScroll: b } = Y(), { handleHideOnResize: C, resetResizeReferences: g } = E(), F = "zero-tooltip__container", k = "zero-tooltip__text", R = "zero-tooltip__arrow", x = {
|
|
76
76
|
left: ["left", "right", "top", "bottom"],
|
|
77
77
|
top: ["top", "bottom", "right", "left"],
|
|
78
78
|
right: ["right", "left", "top", "bottom"],
|
|
79
79
|
bottom: ["bottom", "top", "right", "left"]
|
|
80
|
-
},
|
|
80
|
+
}, tt = "body", et = "top", rt = 10, st = 20, ot = 100, it = 250, dt = 0, D = "zt-fixed zt-opacity-0 zt-inline-block zt-w-fit zt-py-1.5 zt-px-2.5 zt-rounded-md zt-bg-[#495057] zt-shadow-[0_2px_12px_0_rgba(0,0,0,0.1)] zt-box-border", P = "zt-text-sm zt-text-white zt-whitespace-pre-wrap zt-break-words", pt = 5, nt = "zt-absolute zt-border-solid zt-border-[#495057]", wt = 6, ht = 1, ut = !0, u = {}, mt = (e) => ({
|
|
81
81
|
created: (t, r, s) => {
|
|
82
|
-
const
|
|
83
|
-
s.el.$_tooltip = { uuid:
|
|
84
|
-
|
|
82
|
+
const o = X();
|
|
83
|
+
s.el.$_tooltip = { uuid: o }, T(r.value, e, r.arg, t, o), typeof r.value != "string" && N(r.value) && Z(r.value, (d) => {
|
|
84
|
+
u[o] && v(u[o]), T(d, e, r.arg, t, o);
|
|
85
85
|
});
|
|
86
86
|
},
|
|
87
87
|
updated: (t, r, s) => {
|
|
88
|
-
const
|
|
89
|
-
|
|
88
|
+
const o = s.el.$_tooltip.uuid;
|
|
89
|
+
u[o] && v(u[o]), T(r.value, e, r.arg, t, o);
|
|
90
90
|
},
|
|
91
91
|
beforeUnmount: (t, r, s) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const o = s.el.$_tooltip.uuid;
|
|
93
|
+
u[o] && v(u[o]);
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
|
-
function
|
|
97
|
-
let
|
|
98
|
-
const
|
|
99
|
-
|
|
96
|
+
function T(e, t, r, s, o) {
|
|
97
|
+
let d = ct(e, t, r);
|
|
98
|
+
const i = Ot(s, d, o);
|
|
99
|
+
u[o] = i, s.matches(":hover") && s.dispatchEvent(new Event("mouseenter"));
|
|
100
100
|
}
|
|
101
|
-
function
|
|
102
|
-
var
|
|
103
|
-
let s
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
left: ((D = t == null ? void 0 : t.positions) == null ? void 0 : D.left) ?? c.left,
|
|
111
|
-
top: ((P = t == null ? void 0 : t.positions) == null ? void 0 : P.top) ?? c.top,
|
|
112
|
-
right: ((q = t == null ? void 0 : t.positions) == null ? void 0 : q.right) ?? c.right,
|
|
113
|
-
bottom: ((j = t == null ? void 0 : t.positions) == null ? void 0 : j.bottom) ?? c.bottom
|
|
114
|
-
}), o === void 0 && (o = (t == null ? void 0 : t.offsetFromSource) ?? G), h === void 0 && (h = (t == null ? void 0 : t.offsetFromViewport) ?? J), w === void 0 && (w = (t == null ? void 0 : t.minWidth) ?? K), m === void 0 && (m = (t == null ? void 0 : t.maxWidth) ?? Q), x === void 0 && (x = (t == null ? void 0 : t.tooltipBorderWidth) ?? X), O === void 0 && (O = S + " " + Y + " " + ((t == null ? void 0 : t.tooltipClasses) ?? "")), F === void 0 && (F = N + " " + E + " " + ((t == null ? void 0 : t.textClasses) ?? "")), T === void 0 && (T = (t == null ? void 0 : t.arrowSize) ?? l), W === void 0 && (W = (t == null ? void 0 : t.arrowClasses) ?? ""), v === void 0 && (v = (t == null ? void 0 : t.arrowMinOffsetFromTooltipCorner) ?? b), z === void 0 && (z = (t == null ? void 0 : t.zIndex) ?? C), y === void 0 && (y = g), {
|
|
101
|
+
function ct(e, t, r) {
|
|
102
|
+
var V, B, L, H, $, A, _, I;
|
|
103
|
+
let s = (t == null ? void 0 : t.appendTo) ?? tt, o = at(e), d = r ?? (t == null ? void 0 : t.defaultPosition) ?? et, i = {
|
|
104
|
+
left: ((V = t == null ? void 0 : t.positions) == null ? void 0 : V.left) ?? x.left,
|
|
105
|
+
top: ((B = t == null ? void 0 : t.positions) == null ? void 0 : B.top) ?? x.top,
|
|
106
|
+
right: ((L = t == null ? void 0 : t.positions) == null ? void 0 : L.right) ?? x.right,
|
|
107
|
+
bottom: ((H = t == null ? void 0 : t.positions) == null ? void 0 : H.bottom) ?? x.bottom
|
|
108
|
+
}, p = (t == null ? void 0 : t.offsetFromSource) ?? rt, n = (t == null ? void 0 : t.offsetFromViewport) ?? st, h = (t == null ? void 0 : t.minWidth) ?? ot, m = (t == null ? void 0 : t.maxWidth) ?? it, a = (t == null ? void 0 : t.tooltipBorderWidth) ?? dt, c = F + " " + D + " " + ((t == null ? void 0 : t.tooltipClasses) ?? ""), z = k + " " + P + " " + ((t == null ? void 0 : t.textClasses) ?? ""), W = (t == null ? void 0 : t.arrowSize) ?? pt, y = (t == null ? void 0 : t.arrowClasses) ?? "", M = (t == null ? void 0 : t.arrowMinOffsetFromTooltipCorner) ?? wt, l = (t == null ? void 0 : t.zIndex) ?? ht, S = ut;
|
|
109
|
+
return typeof e != "string" && (e.appendTo !== void 0 && (s = e.appendTo), r === void 0 && e.defaultPosition !== void 0 && (d = e.defaultPosition), (($ = e.positions) == null ? void 0 : $.left) !== void 0 && (i.left = e.positions.left), ((A = e.positions) == null ? void 0 : A.top) !== void 0 && (i.top = e.positions.top), ((_ = e.positions) == null ? void 0 : _.right) !== void 0 && (i.right = e.positions.right), ((I = e.positions) == null ? void 0 : I.bottom) !== void 0 && (i.bottom = e.positions.bottom), e.offsetFromSource !== void 0 && (p = e.offsetFromSource), e.offsetFromViewport !== void 0 && (n = e.offsetFromViewport), e.minWidth !== void 0 && (h = e.minWidth), e.maxWidth !== void 0 && (m = e.maxWidth), e.tooltipBorderWidth !== void 0 && (a = e.tooltipBorderWidth), e.tooltipClasses !== void 0 && (c = F + " " + D + " " + e.tooltipClasses), e.textClasses !== void 0 && (z = k + " " + P + " " + e.textClasses), e.arrowSize !== void 0 && (W = e.arrowSize), e.arrowClasses !== void 0 && (y = e.arrowClasses), e.arrowMinOffsetFromTooltipCorner !== void 0 && (M = e.arrowMinOffsetFromTooltipCorner), e.zIndex !== void 0 && (l = e.zIndex), e.show !== void 0 && (S = e.show)), {
|
|
115
110
|
appendTo: s,
|
|
116
|
-
tooltipText:
|
|
117
|
-
tooltipPosition:
|
|
118
|
-
tooltipPositions:
|
|
119
|
-
tooltipOffsetFromSource:
|
|
120
|
-
tooltipOffsetFromViewport:
|
|
121
|
-
tooltipMinWidth:
|
|
111
|
+
tooltipText: o,
|
|
112
|
+
tooltipPosition: d,
|
|
113
|
+
tooltipPositions: i,
|
|
114
|
+
tooltipOffsetFromSource: p,
|
|
115
|
+
tooltipOffsetFromViewport: n,
|
|
116
|
+
tooltipMinWidth: h,
|
|
122
117
|
tooltipMaxWidth: m,
|
|
123
|
-
tooltipBorderWidth:
|
|
124
|
-
tooltipClasses:
|
|
125
|
-
textClasses:
|
|
126
|
-
arrowSize:
|
|
127
|
-
arrowClasses:
|
|
128
|
-
arrowMinOffsetFromTooltipCorner:
|
|
129
|
-
zIndex:
|
|
130
|
-
shouldShow:
|
|
118
|
+
tooltipBorderWidth: a,
|
|
119
|
+
tooltipClasses: c,
|
|
120
|
+
textClasses: z,
|
|
121
|
+
arrowSize: W,
|
|
122
|
+
arrowClasses: y,
|
|
123
|
+
arrowMinOffsetFromTooltipCorner: M,
|
|
124
|
+
zIndex: l,
|
|
125
|
+
shouldShow: S
|
|
131
126
|
};
|
|
132
127
|
}
|
|
133
|
-
function
|
|
128
|
+
function at(e) {
|
|
134
129
|
const t = typeof e == "string" ? e : e.content;
|
|
135
130
|
if (!t)
|
|
136
131
|
throw new Error("Please enter valid tooltip value");
|
|
137
132
|
return t;
|
|
138
133
|
}
|
|
139
|
-
function
|
|
140
|
-
let s = e,
|
|
141
|
-
|
|
142
|
-
const
|
|
143
|
-
return s.addEventListener("mouseenter", () =>
|
|
134
|
+
function Ot(e, t, r) {
|
|
135
|
+
let s = e, o = xt(t.textClasses, t.tooltipText), d = Ft(t.tooltipClasses, t.tooltipBorderWidth);
|
|
136
|
+
d.append(o), d.dataset.uuid = r;
|
|
137
|
+
const i = new AbortController(), p = new AbortController();
|
|
138
|
+
return s.addEventListener("mouseenter", () => ft(s, t, d, r), { signal: i.signal }), s.addEventListener("mouseleave", () => Tt(r), { signal: p.signal }), {
|
|
144
139
|
anchorElement: s,
|
|
145
140
|
tooltipConfig: t,
|
|
146
|
-
tooltipElement:
|
|
147
|
-
mouseEnterEventController:
|
|
148
|
-
mouseLeaveEventController:
|
|
141
|
+
tooltipElement: d,
|
|
142
|
+
mouseEnterEventController: i,
|
|
143
|
+
mouseLeaveEventController: p
|
|
149
144
|
};
|
|
150
145
|
}
|
|
151
|
-
function
|
|
146
|
+
function xt(e, t) {
|
|
152
147
|
let r = document.createElement("p");
|
|
153
148
|
return r.classList.add(...e.trim().split(" ")), r.innerHTML = t, r;
|
|
154
149
|
}
|
|
155
|
-
function
|
|
150
|
+
function Ft(e, t) {
|
|
156
151
|
let r = document.createElement("div");
|
|
157
152
|
return r.classList.add(...e.trim().split(" ")), r.style.borderWidth = `${t}px`, r;
|
|
158
153
|
}
|
|
159
|
-
function
|
|
154
|
+
function ft(e, t, r, s) {
|
|
160
155
|
if (!t.shouldShow)
|
|
161
156
|
return;
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
let
|
|
165
|
-
for (let
|
|
157
|
+
const o = e.getBoundingClientRect(), d = document.querySelector(t.appendTo);
|
|
158
|
+
d == null || d.appendChild(r);
|
|
159
|
+
let i = !1, p = t.tooltipPosition;
|
|
160
|
+
for (let n = 0; n < 4 && (p = t.tooltipPositions[t.tooltipPosition][n], p === "left" ? i = vt(o, t, r) : p === "top" ? i = Wt(o, t, r) : p === "right" ? i = zt(o, t, r) : p === "bottom" && (i = yt(o, t, r)), !i); n++)
|
|
166
161
|
;
|
|
167
|
-
|
|
162
|
+
i && (Mt(o, p, t, r), r.style.opacity = "1", r.style.zIndex = typeof t.zIndex == "string" ? t.zIndex : t.zIndex.toString(), b(e, () => f(s)), C(e, () => f(s)));
|
|
168
163
|
}
|
|
169
|
-
function
|
|
170
|
-
|
|
164
|
+
function Tt(e) {
|
|
165
|
+
f(e);
|
|
171
166
|
}
|
|
172
|
-
function
|
|
173
|
-
const s = Math.min(e.left - t.tooltipOffsetFromSource - t.tooltipOffsetFromViewport, t.tooltipMaxWidth),
|
|
174
|
-
if (s < t.tooltipMinWidth || !
|
|
167
|
+
function vt(e, t, r) {
|
|
168
|
+
const s = Math.min(e.left - t.tooltipOffsetFromSource - t.tooltipOffsetFromViewport, t.tooltipMaxWidth), o = e.top >= t.tooltipOffsetFromViewport, d = window.innerHeight - e.bottom >= t.tooltipOffsetFromViewport;
|
|
169
|
+
if (s < t.tooltipMinWidth || !o || !d)
|
|
175
170
|
return !1;
|
|
176
171
|
r.style.maxWidth = `${s}px`;
|
|
177
|
-
const
|
|
178
|
-
let
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
return e.bottom <
|
|
172
|
+
const i = r.getBoundingClientRect();
|
|
173
|
+
let p = e.top + e.height / 2 - i.height / 2;
|
|
174
|
+
p < t.tooltipOffsetFromViewport ? p = t.tooltipOffsetFromViewport : p + i.height > window.innerHeight - t.tooltipOffsetFromViewport && (p = window.innerHeight - t.tooltipOffsetFromViewport - i.height);
|
|
175
|
+
const n = e.left - t.tooltipOffsetFromSource - i.width;
|
|
176
|
+
return e.bottom < p + t.arrowMinOffsetFromTooltipCorner * 2 || e.top > p + i.height - t.arrowMinOffsetFromTooltipCorner * 2 ? !1 : (r.style.top = `${p}px`, r.style.left = `${n}px`, !0);
|
|
182
177
|
}
|
|
183
|
-
function
|
|
184
|
-
const s = Math.min(window.innerWidth - (e.right + t.tooltipOffsetFromSource) - t.tooltipOffsetFromViewport, t.tooltipMaxWidth),
|
|
185
|
-
if (s < t.tooltipMinWidth || !
|
|
178
|
+
function zt(e, t, r) {
|
|
179
|
+
const s = Math.min(window.innerWidth - (e.right + t.tooltipOffsetFromSource) - t.tooltipOffsetFromViewport, t.tooltipMaxWidth), o = e.top >= t.tooltipOffsetFromViewport, d = window.innerHeight - e.bottom >= t.tooltipOffsetFromViewport;
|
|
180
|
+
if (s < t.tooltipMinWidth || !o || !d)
|
|
186
181
|
return !1;
|
|
187
182
|
r.style.maxWidth = `${s}px`;
|
|
188
|
-
const
|
|
189
|
-
let
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
return e.bottom <
|
|
183
|
+
const i = r.getBoundingClientRect();
|
|
184
|
+
let p = e.top + e.height / 2 - i.height / 2;
|
|
185
|
+
p < t.tooltipOffsetFromViewport ? p = t.tooltipOffsetFromViewport : p + i.height > window.innerHeight - t.tooltipOffsetFromViewport && (p = window.innerHeight - t.tooltipOffsetFromViewport - i.height);
|
|
186
|
+
const n = e.right + t.tooltipOffsetFromSource;
|
|
187
|
+
return e.bottom < p + t.arrowMinOffsetFromTooltipCorner * 2 || e.top > p + i.height - t.arrowMinOffsetFromTooltipCorner * 2 ? !1 : (r.style.top = `${p}px`, r.style.left = `${n}px`, !0);
|
|
193
188
|
}
|
|
194
|
-
function
|
|
189
|
+
function Wt(e, t, r) {
|
|
195
190
|
const s = Math.min(window.innerWidth - t.tooltipOffsetFromViewport * 2, t.tooltipMaxWidth);
|
|
196
191
|
r.style.maxWidth = `${s}px`;
|
|
197
|
-
const
|
|
198
|
-
let
|
|
199
|
-
if (
|
|
192
|
+
const o = r.getBoundingClientRect();
|
|
193
|
+
let d = e.top - t.tooltipOffsetFromSource - o.height;
|
|
194
|
+
if (d < t.tooltipOffsetFromViewport)
|
|
200
195
|
return !1;
|
|
201
|
-
let
|
|
202
|
-
return
|
|
196
|
+
let i = e.left + e.width / 2 - o.width / 2;
|
|
197
|
+
return i < t.tooltipOffsetFromViewport ? i = t.tooltipOffsetFromViewport : i + o.width > window.innerWidth - t.tooltipOffsetFromViewport && (i = window.innerWidth - t.tooltipOffsetFromViewport - o.width), e.left > i + o.width - t.arrowMinOffsetFromTooltipCorner * 2 || e.right < i + t.arrowMinOffsetFromTooltipCorner * 2 ? !1 : (r.style.top = `${d}px`, r.style.left = `${i}px`, !0);
|
|
203
198
|
}
|
|
204
|
-
function
|
|
199
|
+
function yt(e, t, r) {
|
|
205
200
|
const s = Math.min(window.innerWidth - t.tooltipOffsetFromViewport * 2, t.tooltipMaxWidth);
|
|
206
201
|
r.style.maxWidth = `${s}px`;
|
|
207
|
-
const
|
|
208
|
-
let
|
|
209
|
-
if (
|
|
202
|
+
const o = r.getBoundingClientRect();
|
|
203
|
+
let d = e.bottom + t.tooltipOffsetFromSource;
|
|
204
|
+
if (d + o.height > window.innerHeight - t.tooltipOffsetFromViewport)
|
|
210
205
|
return !1;
|
|
211
|
-
let
|
|
212
|
-
return
|
|
206
|
+
let i = e.left + e.width / 2 - o.width / 2;
|
|
207
|
+
return i < t.tooltipOffsetFromViewport ? i = t.tooltipOffsetFromViewport : i + o.width > window.innerWidth - t.tooltipOffsetFromViewport && (i = window.innerWidth - t.tooltipOffsetFromViewport - o.width), e.left > i + o.width - t.arrowMinOffsetFromTooltipCorner * 2 || e.right < i + t.arrowMinOffsetFromTooltipCorner * 2 ? !1 : (r.style.top = `${d}px`, r.style.left = `${i}px`, !0);
|
|
213
208
|
}
|
|
214
|
-
function
|
|
215
|
-
var
|
|
216
|
-
const
|
|
217
|
-
let
|
|
209
|
+
function Mt(e, t, r, s) {
|
|
210
|
+
var c;
|
|
211
|
+
const o = document.createElement("div"), d = s.getBoundingClientRect(), i = Math.sin(45 * (180 / Math.PI)) * r.arrowSize, p = 1;
|
|
212
|
+
let n = 0, h = 0, m = "";
|
|
218
213
|
switch (t) {
|
|
219
214
|
case "left":
|
|
220
|
-
m = "!zt-border-y-transparent !zt-border-r-transparent",
|
|
215
|
+
m = "!zt-border-y-transparent !zt-border-r-transparent", n = e.top - d.top + e.height / 2 - i - r.tooltipBorderWidth, h = d.width - r.tooltipBorderWidth - p;
|
|
221
216
|
break;
|
|
222
217
|
case "top":
|
|
223
|
-
m = "!zt-border-x-transparent !zt-border-b-transparent",
|
|
218
|
+
m = "!zt-border-x-transparent !zt-border-b-transparent", n = d.height - r.tooltipBorderWidth - p, h = e.left - d.left + e.width / 2 - i - r.tooltipBorderWidth;
|
|
224
219
|
break;
|
|
225
220
|
case "right":
|
|
226
|
-
m = "!zt-border-y-transparent !zt-border-l-transparent",
|
|
221
|
+
m = "!zt-border-y-transparent !zt-border-l-transparent", n = e.top - d.top + e.height / 2 - i - r.tooltipBorderWidth, h = -r.arrowSize * 2 - r.tooltipBorderWidth + p;
|
|
227
222
|
break;
|
|
228
223
|
case "bottom":
|
|
229
|
-
m = "!zt-border-x-transparent !zt-border-t-transparent",
|
|
224
|
+
m = "!zt-border-x-transparent !zt-border-t-transparent", n = -r.arrowSize * 2 - r.tooltipBorderWidth + p, h = e.left - d.left + e.width / 2 - i - r.tooltipBorderWidth;
|
|
230
225
|
break;
|
|
231
226
|
}
|
|
232
|
-
t === "left" || t === "right" ?
|
|
233
|
-
const
|
|
234
|
-
|
|
227
|
+
t === "left" || t === "right" ? q(t, d, n, r) || (n = j(t, d, n, r)) : q(t, d, h, r) || (h = j(t, d, h, r));
|
|
228
|
+
const a = R + " " + nt + " " + m + " " + r.arrowClasses;
|
|
229
|
+
o.classList.add(...a.trim().split(" ")), o.style.top = `${n}px`, o.style.left = `${h}px`, o.style.borderWidth = `${r.arrowSize}px`, (c = document.querySelector(`.${F}`)) == null || c.appendChild(o);
|
|
235
230
|
}
|
|
236
|
-
function
|
|
231
|
+
function q(e, t, r, s) {
|
|
237
232
|
switch (e) {
|
|
238
233
|
case "left":
|
|
239
234
|
case "right":
|
|
@@ -243,7 +238,7 @@ function tt(e, t, r, s) {
|
|
|
243
238
|
return r > s.arrowMinOffsetFromTooltipCorner - s.tooltipBorderWidth && r < t.width + s.tooltipBorderWidth - s.arrowMinOffsetFromTooltipCorner - s.arrowSize * 2;
|
|
244
239
|
}
|
|
245
240
|
}
|
|
246
|
-
function
|
|
241
|
+
function j(e, t, r, s) {
|
|
247
242
|
switch (e) {
|
|
248
243
|
case "left":
|
|
249
244
|
case "right":
|
|
@@ -253,20 +248,20 @@ function et(e, t, r, s) {
|
|
|
253
248
|
return r < s.arrowMinOffsetFromTooltipCorner - s.tooltipBorderWidth ? s.arrowMinOffsetFromTooltipCorner - s.tooltipBorderWidth : t.width - s.tooltipBorderWidth - s.arrowMinOffsetFromTooltipCorner - s.arrowSize * 2;
|
|
254
249
|
}
|
|
255
250
|
}
|
|
256
|
-
function
|
|
257
|
-
var s,
|
|
258
|
-
const t = document.querySelector(`.${
|
|
259
|
-
r && t && t instanceof HTMLElement && t === r && (
|
|
251
|
+
function f(e) {
|
|
252
|
+
var s, o;
|
|
253
|
+
const t = document.querySelector(`.${F}`), r = (s = u[e]) == null ? void 0 : s.tooltipElement;
|
|
254
|
+
r && t && t instanceof HTMLElement && t === r && (g(), (o = t.querySelector(`.${R}`)) == null || o.remove(), t.style.left = "0", t.style.top = "0", t.remove());
|
|
260
255
|
}
|
|
261
|
-
function
|
|
256
|
+
function v(e) {
|
|
262
257
|
const t = e.tooltipElement.dataset.uuid;
|
|
263
|
-
t && (
|
|
258
|
+
t && (f(t), delete u[t]), e.mouseEnterEventController.abort(), e.mouseLeaveEventController.abort();
|
|
264
259
|
}
|
|
265
|
-
const
|
|
260
|
+
const St = {
|
|
266
261
|
install: (e, t = {}) => {
|
|
267
|
-
e.directive("tooltip",
|
|
262
|
+
e.directive("tooltip", mt(t));
|
|
268
263
|
}
|
|
269
264
|
};
|
|
270
265
|
export {
|
|
271
|
-
|
|
266
|
+
St as default
|
|
272
267
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(O,F){typeof exports=="object"&&typeof module<"u"?module.exports=F(require("vue")):typeof define=="function"&&define.amd?define(["vue"],F):(O=typeof globalThis<"u"?globalThis:O||self,O.ZeroTooltip=F(O.Vue))})(this,function(O){"use strict";const F="";let v;const it=new Uint8Array(16);function pt(){if(!v&&(v=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!v))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return v(it)}const h=[];for(let e=0;e<256;++e)h.push((e+256).toString(16).slice(1));function ot(e,t=0){return h[e[t+0]]+h[e[t+1]]+h[e[t+2]]+h[e[t+3]]+"-"+h[e[t+4]]+h[e[t+5]]+"-"+h[e[t+6]]+h[e[t+7]]+"-"+h[e[t+8]]+h[e[t+9]]+"-"+h[e[t+10]]+h[e[t+11]]+h[e[t+12]]+h[e[t+13]]+h[e[t+14]]+h[e[t+15]]}const $={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ut(e,t,r){if($.randomUUID&&!t&&!e)return $.randomUUID();e=e||{};const s=e.random||(e.rng||pt)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,t){r=r||0;for(let d=0;d<16;++d)t[r+d]=s[d];return t}return ot(s)}function ht(){let e=[];const t=(d,i)=>{if(r(d),e.length>0)for(const p of e)p.addEventListener("scroll",i);window.addEventListener("scroll",()=>{i(),s(i)})},r=d=>{let i=d;for(;i!==null&&i.tagName!=="HTML";){if(i.scrollHeight!==i.clientHeight){const p=window.getComputedStyle(i);(p.overflow==="auto"||p.overflow==="scroll")&&e.push(i)}i=i.parentElement}},s=d=>{if(e.length>0){for(const i of e)i.removeEventListener("scroll",d);e=[]}window.removeEventListener("scroll",d)};return{handleHideOnScroll:t}}function wt(){let e=null,t=null;return{handleHideOnResize:(d,i)=>{e=new ResizeObserver(p=>{const o=p[0].target;if(t===null)t=d.getBoundingClientRect();else{const u=o.getBoundingClientRect();(u.left!==t.left||u.top!==t.top||u.width!==t.width||u.height!==t.height)&&i()}}),e.observe(d)},resetResizeReferences:()=>{e!==null&&e.disconnect(),e=null,t=null}}}const{handleHideOnScroll:nt}=ht(),{handleHideOnResize:mt,resetResizeReferences:ct}=wt(),W="zero-tooltip__container",A="zero-tooltip__text",_="zero-tooltip__arrow",c={left:["left","right","top","bottom"],top:["top","bottom","right","left"],right:["right","left","top","bottom"],bottom:["bottom","top","right","left"]},I="body",U="top",f=10,k=20,D=100,P=250,q=0,j="zt-fixed zt-opacity-0 zt-inline-block zt-w-fit zt-py-1.5 zt-px-2.5 zt-rounded-md zt-bg-[#495057] zt-shadow-[0_2px_12px_0_rgba(0,0,0,0.1)] zt-box-border",R="zt-text-sm zt-text-white zt-whitespace-pre-wrap zt-break-words",Z=5,Ot="zt-absolute zt-border-solid zt-border-[#495057]",N=6,G=1,J=!0,m={},xt=e=>({created:(t,r,s)=>{const d=ut();s.el.$_tooltip={uuid:d},H(r.value,e,r.arg,t,d),typeof r.value!="string"&&O.isReactive(r.value)&&O.watch(r.value,i=>{m[d]&&a(m[d]),H(i,e,r.arg,t,d)})},updated:(t,r,s)=>{const d=s.el.$_tooltip.uuid;m[d]&&a(m[d]),H(r.value,e,r.arg,t,d)},beforeUnmount:(t,r,s)=>{const d=s.el.$_tooltip.uuid;m[d]&&a(m[d])}});function H(e,t,r,s,d){let i=Tt(e,t,r);const p=vt(s,i,d);m[d]=p,s.matches(":hover")&&s.dispatchEvent(new Event("mouseenter"))}function Tt(e,t,r){var X,Y,E,l,b,C,g,tt,et,rt,st,dt;let s,d,i,p,o,u,w,n,T,x,y,M,S,V,B,L;return d=Ft(e),typeof e!="string"&&(s=e.appendTo??(t==null?void 0:t.appendTo)??I,i=r??e.defaultPosition??(t==null?void 0:t.defaultPosition)??U,p={left:((X=e.positions)==null?void 0:X.left)??((Y=t==null?void 0:t.positions)==null?void 0:Y.left)??c.left,top:((E=e.positions)==null?void 0:E.top)??((l=t==null?void 0:t.positions)==null?void 0:l.top)??c.top,right:((b=e.positions)==null?void 0:b.right)??((C=t==null?void 0:t.positions)==null?void 0:C.right)??c.right,bottom:((g=e.positions)==null?void 0:g.bottom)??((tt=t==null?void 0:t.positions)==null?void 0:tt.bottom)??c.bottom},o=e.offsetFromSource??(t==null?void 0:t.offsetFromSource)??f,u=e.offsetFromViewport??(t==null?void 0:t.offsetFromViewport)??k,w=e.minWidth??(t==null?void 0:t.minWidth)??D,n=e.maxWidth??(t==null?void 0:t.maxWidth)??P,T=e.tooltipBorderWidth??(t==null?void 0:t.tooltipBorderWidth)??q,x=W+" "+j+" "+(e.tooltipClasses??(t==null?void 0:t.tooltipClasses)??""),y=A+" "+R+" "+(e.textClasses??(t==null?void 0:t.textClasses)??""),M=e.arrowSize??(t==null?void 0:t.arrowSize)??Z,S=e.arrowClasses??(t==null?void 0:t.arrowClasses)??"",V=e.arrowMinOffsetFromTooltipCorner??(t==null?void 0:t.arrowMinOffsetFromTooltipCorner)??N,B=e.zIndex??(t==null?void 0:t.zIndex)??G,L=e.show??J),s===void 0&&(s=(t==null?void 0:t.appendTo)??I),i===void 0&&(i=r??(t==null?void 0:t.defaultPosition)??U),p===void 0&&(p={left:((et=t==null?void 0:t.positions)==null?void 0:et.left)??c.left,top:((rt=t==null?void 0:t.positions)==null?void 0:rt.top)??c.top,right:((st=t==null?void 0:t.positions)==null?void 0:st.right)??c.right,bottom:((dt=t==null?void 0:t.positions)==null?void 0:dt.bottom)??c.bottom}),o===void 0&&(o=(t==null?void 0:t.offsetFromSource)??f),u===void 0&&(u=(t==null?void 0:t.offsetFromViewport)??k),w===void 0&&(w=(t==null?void 0:t.minWidth)??D),n===void 0&&(n=(t==null?void 0:t.maxWidth)??P),T===void 0&&(T=(t==null?void 0:t.tooltipBorderWidth)??q),x===void 0&&(x=W+" "+j+" "+((t==null?void 0:t.tooltipClasses)??"")),y===void 0&&(y=A+" "+R+" "+((t==null?void 0:t.textClasses)??"")),M===void 0&&(M=(t==null?void 0:t.arrowSize)??Z),S===void 0&&(S=(t==null?void 0:t.arrowClasses)??""),V===void 0&&(V=(t==null?void 0:t.arrowMinOffsetFromTooltipCorner)??N),B===void 0&&(B=(t==null?void 0:t.zIndex)??G),L===void 0&&(L=J),{appendTo:s,tooltipText:d,tooltipPosition:i,tooltipPositions:p,tooltipOffsetFromSource:o,tooltipOffsetFromViewport:u,tooltipMinWidth:w,tooltipMaxWidth:n,tooltipBorderWidth:T,tooltipClasses:x,textClasses:y,arrowSize:M,arrowClasses:S,arrowMinOffsetFromTooltipCorner:V,zIndex:B,shouldShow:L}}function Ft(e){const t=typeof e=="string"?e:e.content;if(!t)throw new Error("Please enter valid tooltip value");return t}function vt(e,t,r){let s=e,d=Wt(t.textClasses,t.tooltipText),i=zt(t.tooltipClasses,t.tooltipBorderWidth);i.append(d),i.dataset.uuid=r;const p=new AbortController,o=new AbortController;return s.addEventListener("mouseenter",()=>yt(s,t,i,r),{signal:p.signal}),s.addEventListener("mouseleave",()=>Mt(r),{signal:o.signal}),{anchorElement:s,tooltipConfig:t,tooltipElement:i,mouseEnterEventController:p,mouseLeaveEventController:o}}function Wt(e,t){let r=document.createElement("p");return r.classList.add(...e.trim().split(" ")),r.innerHTML=t,r}function zt(e,t){let r=document.createElement("div");return r.classList.add(...e.trim().split(" ")),r.style.borderWidth=`${t}px`,r}function yt(e,t,r,s){if(!t.shouldShow)return;const d=e.getBoundingClientRect(),i=document.querySelector(t.appendTo);i==null||i.appendChild(r);let p=!1,o=t.tooltipPosition;for(let u=0;u<4&&(o=t.tooltipPositions[t.tooltipPosition][u],o==="left"?p=St(d,t,r):o==="top"?p=Bt(d,t,r):o==="right"?p=Vt(d,t,r):o==="bottom"&&(p=Lt(d,t,r)),!p);u++);p&&(Ht(d,o,t,r),r.style.opacity="1",r.style.zIndex=t.zIndex.toString(),nt(e,()=>z(s)),mt(e,()=>z(s)))}function Mt(e){z(e)}function St(e,t,r){const s=Math.min(e.left-t.tooltipOffsetFromSource-t.tooltipOffsetFromViewport,t.tooltipMaxWidth),d=e.top>=t.tooltipOffsetFromViewport,i=window.innerHeight-e.bottom>=t.tooltipOffsetFromViewport;if(s<t.tooltipMinWidth||!d||!i)return!1;r.style.maxWidth=`${s}px`;const p=r.getBoundingClientRect();let o=e.top+e.height/2-p.height/2;o<t.tooltipOffsetFromViewport?o=t.tooltipOffsetFromViewport:o+p.height>window.innerHeight-t.tooltipOffsetFromViewport&&(o=window.innerHeight-t.tooltipOffsetFromViewport-p.height);const u=e.left-t.tooltipOffsetFromSource-p.width;return e.bottom<o+t.arrowMinOffsetFromTooltipCorner*2||e.top>o+p.height-t.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${o}px`,r.style.left=`${u}px`,!0)}function Vt(e,t,r){const s=Math.min(window.innerWidth-(e.right+t.tooltipOffsetFromSource)-t.tooltipOffsetFromViewport,t.tooltipMaxWidth),d=e.top>=t.tooltipOffsetFromViewport,i=window.innerHeight-e.bottom>=t.tooltipOffsetFromViewport;if(s<t.tooltipMinWidth||!d||!i)return!1;r.style.maxWidth=`${s}px`;const p=r.getBoundingClientRect();let o=e.top+e.height/2-p.height/2;o<t.tooltipOffsetFromViewport?o=t.tooltipOffsetFromViewport:o+p.height>window.innerHeight-t.tooltipOffsetFromViewport&&(o=window.innerHeight-t.tooltipOffsetFromViewport-p.height);const u=e.right+t.tooltipOffsetFromSource;return e.bottom<o+t.arrowMinOffsetFromTooltipCorner*2||e.top>o+p.height-t.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${o}px`,r.style.left=`${u}px`,!0)}function Bt(e,t,r){const s=Math.min(window.innerWidth-t.tooltipOffsetFromViewport*2,t.tooltipMaxWidth);r.style.maxWidth=`${s}px`;const d=r.getBoundingClientRect();let i=e.top-t.tooltipOffsetFromSource-d.height;if(i<t.tooltipOffsetFromViewport)return!1;let p=e.left+e.width/2-d.width/2;return p<t.tooltipOffsetFromViewport?p=t.tooltipOffsetFromViewport:p+d.width>window.innerWidth-t.tooltipOffsetFromViewport&&(p=window.innerWidth-t.tooltipOffsetFromViewport-d.width),e.left>p+d.width-t.arrowMinOffsetFromTooltipCorner*2||e.right<p+t.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${i}px`,r.style.left=`${p}px`,!0)}function Lt(e,t,r){const s=Math.min(window.innerWidth-t.tooltipOffsetFromViewport*2,t.tooltipMaxWidth);r.style.maxWidth=`${s}px`;const d=r.getBoundingClientRect();let i=e.bottom+t.tooltipOffsetFromSource;if(i+d.height>window.innerHeight-t.tooltipOffsetFromViewport)return!1;let p=e.left+e.width/2-d.width/2;return p<t.tooltipOffsetFromViewport?p=t.tooltipOffsetFromViewport:p+d.width>window.innerWidth-t.tooltipOffsetFromViewport&&(p=window.innerWidth-t.tooltipOffsetFromViewport-d.width),e.left>p+d.width-t.arrowMinOffsetFromTooltipCorner*2||e.right<p+t.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${i}px`,r.style.left=`${p}px`,!0)}function Ht(e,t,r,s){var x;const d=document.createElement("div"),i=s.getBoundingClientRect(),p=Math.sin(45*(180/Math.PI))*r.arrowSize,o=1;let u=0,w=0,n="";switch(t){case"left":n="!zt-border-y-transparent !zt-border-r-transparent",u=e.top-i.top+e.height/2-p-r.tooltipBorderWidth,w=i.width-r.tooltipBorderWidth-o;break;case"top":n="!zt-border-x-transparent !zt-border-b-transparent",u=i.height-r.tooltipBorderWidth-o,w=e.left-i.left+e.width/2-p-r.tooltipBorderWidth;break;case"right":n="!zt-border-y-transparent !zt-border-l-transparent",u=e.top-i.top+e.height/2-p-r.tooltipBorderWidth,w=-r.arrowSize*2-r.tooltipBorderWidth+o;break;case"bottom":n="!zt-border-x-transparent !zt-border-t-transparent",u=-r.arrowSize*2-r.tooltipBorderWidth+o,w=e.left-i.left+e.width/2-p-r.tooltipBorderWidth;break}t==="left"||t==="right"?K(t,i,u,r)||(u=Q(t,i,u,r)):K(t,i,w,r)||(w=Q(t,i,w,r));const T=_+" "+Ot+" "+n+" "+r.arrowClasses;d.classList.add(...T.trim().split(" ")),d.style.top=`${u}px`,d.style.left=`${w}px`,d.style.borderWidth=`${r.arrowSize}px`,(x=document.querySelector(`.${W}`))==null||x.appendChild(d)}function K(e,t,r,s){switch(e){case"left":case"right":return r>s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth&&r<t.height+s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2;case"top":case"bottom":return r>s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth&&r<t.width+s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2}}function Q(e,t,r,s){switch(e){case"left":case"right":return r<s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth?s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth:t.height-s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2;case"top":case"bottom":return r<s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth?s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth:t.width-s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2}}function z(e){var s,d;const t=document.querySelector(`.${W}`),r=(s=m[e])==null?void 0:s.tooltipElement;r&&t&&t instanceof HTMLElement&&t===r&&(ct(),(d=t.querySelector(`.${_}`))==null||d.remove(),t.style.left="0",t.style.top="0",t.remove())}function a(e){const t=e.tooltipElement.dataset.uuid;t&&(z(t),delete m[t]),e.mouseEnterEventController.abort(),e.mouseLeaveEventController.abort()}return{install:(e,t={})=>{e.directive("tooltip",xt(t))}}});
|
|
1
|
+
(function(c,f){typeof exports=="object"&&typeof module<"u"?module.exports=f(require("vue")):typeof define=="function"&&define.amd?define(["vue"],f):(c=typeof globalThis<"u"?globalThis:c||self,c.ZeroTooltip=f(c.Vue))})(this,function(c){"use strict";const f="";let x;const G=new Uint8Array(16);function J(){if(!x&&(x=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!x))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return x(G)}const u=[];for(let e=0;e<256;++e)u.push((e+256).toString(16).slice(1));function K(e,t=0){return u[e[t+0]]+u[e[t+1]]+u[e[t+2]]+u[e[t+3]]+"-"+u[e[t+4]]+u[e[t+5]]+"-"+u[e[t+6]]+u[e[t+7]]+"-"+u[e[t+8]]+u[e[t+9]]+"-"+u[e[t+10]]+u[e[t+11]]+u[e[t+12]]+u[e[t+13]]+u[e[t+14]]+u[e[t+15]]}const y={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Q(e,t,r){if(y.randomUUID&&!t&&!e)return y.randomUUID();e=e||{};const s=e.random||(e.rng||J)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,t){r=r||0;for(let o=0;o<16;++o)t[r+o]=s[o];return t}return K(s)}function X(){let e=[];const t=(o,d)=>{if(r(o),e.length>0)for(const i of e)i.addEventListener("scroll",d);window.addEventListener("scroll",()=>{d(),s(d)})},r=o=>{let d=o;for(;d!==null&&d.tagName!=="HTML";){if(d.scrollHeight!==d.clientHeight){const i=window.getComputedStyle(d);(i.overflow==="auto"||i.overflow==="scroll")&&e.push(d)}d=d.parentElement}},s=o=>{if(e.length>0){for(const d of e)d.removeEventListener("scroll",o);e=[]}window.removeEventListener("scroll",o)};return{handleHideOnScroll:t}}function Y(){let e=null,t=null;return{handleHideOnResize:(o,d)=>{e=new ResizeObserver(i=>{const n=i[0].target;if(t===null)t=o.getBoundingClientRect();else{const p=n.getBoundingClientRect();(p.left!==t.left||p.top!==t.top||p.width!==t.width||p.height!==t.height)&&d()}}),e.observe(o)},resetResizeReferences:()=>{e!==null&&e.disconnect(),e=null,t=null}}}const{handleHideOnScroll:E}=X(),{handleHideOnResize:b,resetResizeReferences:C}=Y(),O="zero-tooltip__container",M="zero-tooltip__text",l="zero-tooltip__arrow",T={left:["left","right","top","bottom"],top:["top","bottom","right","left"],right:["right","left","top","bottom"],bottom:["bottom","top","right","left"]},g="body",tt="top",et=10,rt=20,st=100,ot=250,it=0,S="zt-fixed zt-opacity-0 zt-inline-block zt-w-fit zt-py-1.5 zt-px-2.5 zt-rounded-md zt-bg-[#495057] zt-shadow-[0_2px_12px_0_rgba(0,0,0,0.1)] zt-box-border",V="zt-text-sm zt-text-white zt-whitespace-pre-wrap zt-break-words",dt=5,nt="zt-absolute zt-border-solid zt-border-[#495057]",pt=6,ut=1,ht=!0,w={},wt=e=>({created:(t,r,s)=>{const o=Q();s.el.$_tooltip={uuid:o},z(r.value,e,r.arg,t,o),typeof r.value!="string"&&c.isReactive(r.value)&&c.watch(r.value,d=>{w[o]&&W(w[o]),z(d,e,r.arg,t,o)})},updated:(t,r,s)=>{const o=s.el.$_tooltip.uuid;w[o]&&W(w[o]),z(r.value,e,r.arg,t,o)},beforeUnmount:(t,r,s)=>{const o=s.el.$_tooltip.uuid;w[o]&&W(w[o])}});function z(e,t,r,s,o){let d=mt(e,t,r);const i=at(s,d,o);w[o]=i,s.matches(":hover")&&s.dispatchEvent(new Event("mouseenter"))}function mt(e,t,r){var k,D,P,q,j,R,Z,N;let s=(t==null?void 0:t.appendTo)??g,o=ct(e),d=r??(t==null?void 0:t.defaultPosition)??tt,i={left:((k=t==null?void 0:t.positions)==null?void 0:k.left)??T.left,top:((D=t==null?void 0:t.positions)==null?void 0:D.top)??T.top,right:((P=t==null?void 0:t.positions)==null?void 0:P.right)??T.right,bottom:((q=t==null?void 0:t.positions)==null?void 0:q.bottom)??T.bottom},n=(t==null?void 0:t.offsetFromSource)??et,p=(t==null?void 0:t.offsetFromViewport)??rt,h=(t==null?void 0:t.minWidth)??st,m=(t==null?void 0:t.maxWidth)??ot,v=(t==null?void 0:t.tooltipBorderWidth)??it,a=O+" "+S+" "+((t==null?void 0:t.tooltipClasses)??""),H=M+" "+V+" "+((t==null?void 0:t.textClasses)??""),$=(t==null?void 0:t.arrowSize)??dt,A=(t==null?void 0:t.arrowClasses)??"",I=(t==null?void 0:t.arrowMinOffsetFromTooltipCorner)??pt,_=(t==null?void 0:t.zIndex)??ut,U=ht;return typeof e!="string"&&(e.appendTo!==void 0&&(s=e.appendTo),r===void 0&&e.defaultPosition!==void 0&&(d=e.defaultPosition),((j=e.positions)==null?void 0:j.left)!==void 0&&(i.left=e.positions.left),((R=e.positions)==null?void 0:R.top)!==void 0&&(i.top=e.positions.top),((Z=e.positions)==null?void 0:Z.right)!==void 0&&(i.right=e.positions.right),((N=e.positions)==null?void 0:N.bottom)!==void 0&&(i.bottom=e.positions.bottom),e.offsetFromSource!==void 0&&(n=e.offsetFromSource),e.offsetFromViewport!==void 0&&(p=e.offsetFromViewport),e.minWidth!==void 0&&(h=e.minWidth),e.maxWidth!==void 0&&(m=e.maxWidth),e.tooltipBorderWidth!==void 0&&(v=e.tooltipBorderWidth),e.tooltipClasses!==void 0&&(a=O+" "+S+" "+e.tooltipClasses),e.textClasses!==void 0&&(H=M+" "+V+" "+e.textClasses),e.arrowSize!==void 0&&($=e.arrowSize),e.arrowClasses!==void 0&&(A=e.arrowClasses),e.arrowMinOffsetFromTooltipCorner!==void 0&&(I=e.arrowMinOffsetFromTooltipCorner),e.zIndex!==void 0&&(_=e.zIndex),e.show!==void 0&&(U=e.show)),{appendTo:s,tooltipText:o,tooltipPosition:d,tooltipPositions:i,tooltipOffsetFromSource:n,tooltipOffsetFromViewport:p,tooltipMinWidth:h,tooltipMaxWidth:m,tooltipBorderWidth:v,tooltipClasses:a,textClasses:H,arrowSize:$,arrowClasses:A,arrowMinOffsetFromTooltipCorner:I,zIndex:_,shouldShow:U}}function ct(e){const t=typeof e=="string"?e:e.content;if(!t)throw new Error("Please enter valid tooltip value");return t}function at(e,t,r){let s=e,o=ft(t.textClasses,t.tooltipText),d=xt(t.tooltipClasses,t.tooltipBorderWidth);d.append(o),d.dataset.uuid=r;const i=new AbortController,n=new AbortController;return s.addEventListener("mouseenter",()=>Ot(s,t,d,r),{signal:i.signal}),s.addEventListener("mouseleave",()=>Tt(r),{signal:n.signal}),{anchorElement:s,tooltipConfig:t,tooltipElement:d,mouseEnterEventController:i,mouseLeaveEventController:n}}function ft(e,t){let r=document.createElement("p");return r.classList.add(...e.trim().split(" ")),r.innerHTML=t,r}function xt(e,t){let r=document.createElement("div");return r.classList.add(...e.trim().split(" ")),r.style.borderWidth=`${t}px`,r}function Ot(e,t,r,s){if(!t.shouldShow)return;const o=e.getBoundingClientRect(),d=document.querySelector(t.appendTo);d==null||d.appendChild(r);let i=!1,n=t.tooltipPosition;for(let p=0;p<4&&(n=t.tooltipPositions[t.tooltipPosition][p],n==="left"?i=Ft(o,t,r):n==="top"?i=zt(o,t,r):n==="right"?i=vt(o,t,r):n==="bottom"&&(i=Wt(o,t,r)),!i);p++);i&&(yt(o,n,t,r),r.style.opacity="1",r.style.zIndex=typeof t.zIndex=="string"?t.zIndex:t.zIndex.toString(),E(e,()=>F(s)),b(e,()=>F(s)))}function Tt(e){F(e)}function Ft(e,t,r){const s=Math.min(e.left-t.tooltipOffsetFromSource-t.tooltipOffsetFromViewport,t.tooltipMaxWidth),o=e.top>=t.tooltipOffsetFromViewport,d=window.innerHeight-e.bottom>=t.tooltipOffsetFromViewport;if(s<t.tooltipMinWidth||!o||!d)return!1;r.style.maxWidth=`${s}px`;const i=r.getBoundingClientRect();let n=e.top+e.height/2-i.height/2;n<t.tooltipOffsetFromViewport?n=t.tooltipOffsetFromViewport:n+i.height>window.innerHeight-t.tooltipOffsetFromViewport&&(n=window.innerHeight-t.tooltipOffsetFromViewport-i.height);const p=e.left-t.tooltipOffsetFromSource-i.width;return e.bottom<n+t.arrowMinOffsetFromTooltipCorner*2||e.top>n+i.height-t.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${n}px`,r.style.left=`${p}px`,!0)}function vt(e,t,r){const s=Math.min(window.innerWidth-(e.right+t.tooltipOffsetFromSource)-t.tooltipOffsetFromViewport,t.tooltipMaxWidth),o=e.top>=t.tooltipOffsetFromViewport,d=window.innerHeight-e.bottom>=t.tooltipOffsetFromViewport;if(s<t.tooltipMinWidth||!o||!d)return!1;r.style.maxWidth=`${s}px`;const i=r.getBoundingClientRect();let n=e.top+e.height/2-i.height/2;n<t.tooltipOffsetFromViewport?n=t.tooltipOffsetFromViewport:n+i.height>window.innerHeight-t.tooltipOffsetFromViewport&&(n=window.innerHeight-t.tooltipOffsetFromViewport-i.height);const p=e.right+t.tooltipOffsetFromSource;return e.bottom<n+t.arrowMinOffsetFromTooltipCorner*2||e.top>n+i.height-t.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${n}px`,r.style.left=`${p}px`,!0)}function zt(e,t,r){const s=Math.min(window.innerWidth-t.tooltipOffsetFromViewport*2,t.tooltipMaxWidth);r.style.maxWidth=`${s}px`;const o=r.getBoundingClientRect();let d=e.top-t.tooltipOffsetFromSource-o.height;if(d<t.tooltipOffsetFromViewport)return!1;let i=e.left+e.width/2-o.width/2;return i<t.tooltipOffsetFromViewport?i=t.tooltipOffsetFromViewport:i+o.width>window.innerWidth-t.tooltipOffsetFromViewport&&(i=window.innerWidth-t.tooltipOffsetFromViewport-o.width),e.left>i+o.width-t.arrowMinOffsetFromTooltipCorner*2||e.right<i+t.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${d}px`,r.style.left=`${i}px`,!0)}function Wt(e,t,r){const s=Math.min(window.innerWidth-t.tooltipOffsetFromViewport*2,t.tooltipMaxWidth);r.style.maxWidth=`${s}px`;const o=r.getBoundingClientRect();let d=e.bottom+t.tooltipOffsetFromSource;if(d+o.height>window.innerHeight-t.tooltipOffsetFromViewport)return!1;let i=e.left+e.width/2-o.width/2;return i<t.tooltipOffsetFromViewport?i=t.tooltipOffsetFromViewport:i+o.width>window.innerWidth-t.tooltipOffsetFromViewport&&(i=window.innerWidth-t.tooltipOffsetFromViewport-o.width),e.left>i+o.width-t.arrowMinOffsetFromTooltipCorner*2||e.right<i+t.arrowMinOffsetFromTooltipCorner*2?!1:(r.style.top=`${d}px`,r.style.left=`${i}px`,!0)}function yt(e,t,r,s){var a;const o=document.createElement("div"),d=s.getBoundingClientRect(),i=Math.sin(45*(180/Math.PI))*r.arrowSize,n=1;let p=0,h=0,m="";switch(t){case"left":m="!zt-border-y-transparent !zt-border-r-transparent",p=e.top-d.top+e.height/2-i-r.tooltipBorderWidth,h=d.width-r.tooltipBorderWidth-n;break;case"top":m="!zt-border-x-transparent !zt-border-b-transparent",p=d.height-r.tooltipBorderWidth-n,h=e.left-d.left+e.width/2-i-r.tooltipBorderWidth;break;case"right":m="!zt-border-y-transparent !zt-border-l-transparent",p=e.top-d.top+e.height/2-i-r.tooltipBorderWidth,h=-r.arrowSize*2-r.tooltipBorderWidth+n;break;case"bottom":m="!zt-border-x-transparent !zt-border-t-transparent",p=-r.arrowSize*2-r.tooltipBorderWidth+n,h=e.left-d.left+e.width/2-i-r.tooltipBorderWidth;break}t==="left"||t==="right"?B(t,d,p,r)||(p=L(t,d,p,r)):B(t,d,h,r)||(h=L(t,d,h,r));const v=l+" "+nt+" "+m+" "+r.arrowClasses;o.classList.add(...v.trim().split(" ")),o.style.top=`${p}px`,o.style.left=`${h}px`,o.style.borderWidth=`${r.arrowSize}px`,(a=document.querySelector(`.${O}`))==null||a.appendChild(o)}function B(e,t,r,s){switch(e){case"left":case"right":return r>s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth&&r<t.height+s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2;case"top":case"bottom":return r>s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth&&r<t.width+s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2}}function L(e,t,r,s){switch(e){case"left":case"right":return r<s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth?s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth:t.height-s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2;case"top":case"bottom":return r<s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth?s.arrowMinOffsetFromTooltipCorner-s.tooltipBorderWidth:t.width-s.tooltipBorderWidth-s.arrowMinOffsetFromTooltipCorner-s.arrowSize*2}}function F(e){var s,o;const t=document.querySelector(`.${O}`),r=(s=w[e])==null?void 0:s.tooltipElement;r&&t&&t instanceof HTMLElement&&t===r&&(C(),(o=t.querySelector(`.${l}`))==null||o.remove(),t.style.left="0",t.style.top="0",t.remove())}function W(e){const t=e.tooltipElement.dataset.uuid;t&&(F(t),delete w[t]),e.mouseEnterEventController.abort(),e.mouseLeaveEventController.abort()}return{install:(e,t={})=>{e.directive("tooltip",wt(t))}}});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/tooltip.ts
CHANGED
|
@@ -92,70 +92,51 @@ function buildTooltip(bindingValue: any, globalConfig: TooltipConfig | undefined
|
|
|
92
92
|
|
|
93
93
|
function getTooltipConfig(localConfig: string | TooltipLocalConfig, globalConfig?: TooltipConfig, position?: TooltipPosition) {
|
|
94
94
|
// Tooltip config
|
|
95
|
-
let appendTo
|
|
96
|
-
let tooltipText
|
|
97
|
-
let tooltipPosition
|
|
98
|
-
let tooltipPositions: TooltipPositions
|
|
99
|
-
let tooltipOffsetFromSource: number | undefined
|
|
100
|
-
let tooltipOffsetFromViewport: number | undefined
|
|
101
|
-
let tooltipMinWidth: number | undefined
|
|
102
|
-
let tooltipMaxWidth: number | undefined
|
|
103
|
-
let tooltipBorderWidth: number | undefined
|
|
104
|
-
let tooltipClasses: string | undefined
|
|
105
|
-
let textClasses: string | undefined
|
|
106
|
-
let arrowSize: number | undefined
|
|
107
|
-
let arrowClasses: string | undefined
|
|
108
|
-
let arrowMinOffsetFromTooltipCorner: number | undefined
|
|
109
|
-
let zIndex: number | undefined
|
|
110
|
-
let shouldShow: boolean | undefined
|
|
111
|
-
|
|
112
|
-
tooltipText = getTooltipText(localConfig)
|
|
113
|
-
|
|
114
|
-
// Check if local config is defined
|
|
115
|
-
if (typeof(localConfig) !== 'string') {
|
|
116
|
-
appendTo = localConfig.appendTo ?? globalConfig?.appendTo ?? defaultAppendTo;
|
|
117
|
-
tooltipPosition = position ?? localConfig.defaultPosition ?? globalConfig?.defaultPosition ?? defaultTooltipPosition;
|
|
118
|
-
tooltipPositions = {
|
|
119
|
-
left: localConfig.positions?.left ?? globalConfig?.positions?.left ?? defaultTooltipPositions.left,
|
|
120
|
-
top: localConfig.positions?.top ?? globalConfig?.positions?.top ?? defaultTooltipPositions.top,
|
|
121
|
-
right: localConfig.positions?.right ?? globalConfig?.positions?.right ?? defaultTooltipPositions.right,
|
|
122
|
-
bottom: localConfig.positions?.bottom ?? globalConfig?.positions?.bottom ?? defaultTooltipPositions.bottom,
|
|
123
|
-
}
|
|
124
|
-
tooltipOffsetFromSource = localConfig.offsetFromSource ?? globalConfig?.offsetFromSource ?? defaultTooltipOffsetFromSource
|
|
125
|
-
tooltipOffsetFromViewport = localConfig.offsetFromViewport ?? globalConfig?.offsetFromViewport ?? defaultTooltipOffsetFromViewport
|
|
126
|
-
tooltipMinWidth = localConfig.minWidth ?? globalConfig?.minWidth ?? defaultTooltipMinWidth
|
|
127
|
-
tooltipMaxWidth = localConfig.maxWidth ?? globalConfig?.maxWidth ?? defaultTooltipMaxWidth
|
|
128
|
-
tooltipBorderWidth = localConfig.tooltipBorderWidth ?? globalConfig?.tooltipBorderWidth ?? defaultTooltipBorderWidth
|
|
129
|
-
tooltipClasses = tooltipElementClass + ' ' + defaultTooltipClasses + ' ' + (localConfig.tooltipClasses ?? globalConfig?.tooltipClasses ?? '')
|
|
130
|
-
textClasses = textElementClass + ' ' + defaultTextClasses + ' ' + (localConfig.textClasses ?? globalConfig?.textClasses ?? '')
|
|
131
|
-
arrowSize = localConfig.arrowSize ?? globalConfig?.arrowSize ?? defaultArrowSize
|
|
132
|
-
arrowClasses = localConfig.arrowClasses ?? globalConfig?.arrowClasses ?? ''
|
|
133
|
-
arrowMinOffsetFromTooltipCorner = localConfig.arrowMinOffsetFromTooltipCorner ?? globalConfig?.arrowMinOffsetFromTooltipCorner ?? defaultMinArrowOffsetFromTooltipCorner
|
|
134
|
-
zIndex = localConfig.zIndex ?? globalConfig?.zIndex ?? defaultZIndex
|
|
135
|
-
shouldShow = localConfig.show ?? defaultShouldShow
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// If values were not not defined by localConfig, assign either globalConfig or default value
|
|
139
|
-
if (appendTo === undefined) appendTo = globalConfig?.appendTo ?? defaultAppendTo;
|
|
140
|
-
if (tooltipPosition === undefined) tooltipPosition = position ?? globalConfig?.defaultPosition ?? defaultTooltipPosition;
|
|
141
|
-
if (tooltipPositions === undefined) tooltipPositions = {
|
|
95
|
+
let appendTo = globalConfig?.appendTo ?? defaultAppendTo
|
|
96
|
+
let tooltipText = getTooltipText(localConfig)
|
|
97
|
+
let tooltipPosition = position ?? globalConfig?.defaultPosition ?? defaultTooltipPosition
|
|
98
|
+
let tooltipPositions: TooltipPositions = {
|
|
142
99
|
left: globalConfig?.positions?.left ?? defaultTooltipPositions.left,
|
|
143
100
|
top: globalConfig?.positions?.top ?? defaultTooltipPositions.top,
|
|
144
101
|
right: globalConfig?.positions?.right ?? defaultTooltipPositions.right,
|
|
145
102
|
bottom: globalConfig?.positions?.bottom ?? defaultTooltipPositions.bottom,
|
|
146
103
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
104
|
+
let tooltipOffsetFromSource = globalConfig?.offsetFromSource ?? defaultTooltipOffsetFromSource
|
|
105
|
+
let tooltipOffsetFromViewport = globalConfig?.offsetFromViewport ?? defaultTooltipOffsetFromViewport
|
|
106
|
+
let tooltipMinWidth = globalConfig?.minWidth ?? defaultTooltipMinWidth
|
|
107
|
+
let tooltipMaxWidth = globalConfig?.maxWidth ?? defaultTooltipMaxWidth
|
|
108
|
+
let tooltipBorderWidth = globalConfig?.tooltipBorderWidth ?? defaultTooltipBorderWidth
|
|
109
|
+
let tooltipClasses = tooltipElementClass + ' ' + defaultTooltipClasses + ' ' + (globalConfig?.tooltipClasses ?? '')
|
|
110
|
+
let textClasses = textElementClass + ' ' + defaultTextClasses + ' ' + (globalConfig?.textClasses ?? '')
|
|
111
|
+
let arrowSize = globalConfig?.arrowSize ?? defaultArrowSize
|
|
112
|
+
let arrowClasses = globalConfig?.arrowClasses ?? ''
|
|
113
|
+
let arrowMinOffsetFromTooltipCorner = globalConfig?.arrowMinOffsetFromTooltipCorner ?? defaultMinArrowOffsetFromTooltipCorner
|
|
114
|
+
let zIndex = globalConfig?.zIndex ?? defaultZIndex
|
|
115
|
+
let shouldShow = defaultShouldShow
|
|
116
|
+
|
|
117
|
+
// Check if local config is defined (it's defined when local config is Object and not a string, because string means that just Tooltip text is given)
|
|
118
|
+
if (typeof(localConfig) !== 'string') {
|
|
119
|
+
if (localConfig.appendTo !== undefined) appendTo = localConfig.appendTo
|
|
120
|
+
if (position === undefined && localConfig.defaultPosition !== undefined) tooltipPosition = localConfig.defaultPosition
|
|
121
|
+
|
|
122
|
+
if (localConfig.positions?.left !== undefined) tooltipPositions.left = localConfig.positions.left
|
|
123
|
+
if (localConfig.positions?.top !== undefined) tooltipPositions.top = localConfig.positions.top
|
|
124
|
+
if (localConfig.positions?.right !== undefined) tooltipPositions.right = localConfig.positions.right
|
|
125
|
+
if (localConfig.positions?.bottom !== undefined) tooltipPositions.bottom = localConfig.positions.bottom
|
|
126
|
+
|
|
127
|
+
if (localConfig.offsetFromSource !== undefined) tooltipOffsetFromSource = localConfig.offsetFromSource
|
|
128
|
+
if (localConfig.offsetFromViewport !== undefined) tooltipOffsetFromViewport = localConfig.offsetFromViewport
|
|
129
|
+
if (localConfig.minWidth !== undefined) tooltipMinWidth = localConfig.minWidth
|
|
130
|
+
if (localConfig.maxWidth !== undefined) tooltipMaxWidth = localConfig.maxWidth
|
|
131
|
+
if (localConfig.tooltipBorderWidth !== undefined) tooltipBorderWidth = localConfig.tooltipBorderWidth
|
|
132
|
+
if (localConfig.tooltipClasses !== undefined) tooltipClasses = tooltipElementClass + ' ' + defaultTooltipClasses + ' ' + localConfig.tooltipClasses
|
|
133
|
+
if (localConfig.textClasses !== undefined) textClasses = textElementClass + ' ' + defaultTextClasses + ' ' + localConfig.textClasses
|
|
134
|
+
if (localConfig.arrowSize !== undefined) arrowSize = localConfig.arrowSize
|
|
135
|
+
if (localConfig.arrowClasses !== undefined) arrowClasses = localConfig.arrowClasses
|
|
136
|
+
if (localConfig.arrowMinOffsetFromTooltipCorner !== undefined) arrowMinOffsetFromTooltipCorner = localConfig.arrowMinOffsetFromTooltipCorner
|
|
137
|
+
if (localConfig.zIndex !== undefined) zIndex = localConfig.zIndex
|
|
138
|
+
if (localConfig.show !== undefined) shouldShow = localConfig.show
|
|
139
|
+
}
|
|
159
140
|
|
|
160
141
|
return {
|
|
161
142
|
appendTo,
|
|
@@ -263,7 +244,7 @@ function onMouseEnter(
|
|
|
263
244
|
drawArrow(anchorElementRect, currentTooltipPosition, tooltipConfig, tooltipElement)
|
|
264
245
|
|
|
265
246
|
tooltipElement.style.opacity = '1'
|
|
266
|
-
tooltipElement.style.zIndex = tooltipConfig.zIndex.toString()
|
|
247
|
+
tooltipElement.style.zIndex = typeof(tooltipConfig.zIndex) === 'string' ? tooltipConfig.zIndex : tooltipConfig.zIndex.toString();
|
|
267
248
|
|
|
268
249
|
handleHideOnScroll(anchorElement, () => hideTooltip(uuid))
|
|
269
250
|
handleHideOnResize(anchorElement, () => hideTooltip(uuid))
|