adverich-kun-ui 0.1.472 → 0.1.474
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.
|
@@ -21,6 +21,7 @@ const O = {
|
|
|
21
21
|
validator: (e) => ["left", "center", "right"].includes(e)
|
|
22
22
|
},
|
|
23
23
|
density: { type: String, default: "default" },
|
|
24
|
+
height: String,
|
|
24
25
|
elevation: { type: String, default: "md" },
|
|
25
26
|
bordered: { type: Boolean, default: !1 },
|
|
26
27
|
borderColor: { type: String, default: "border-b border-slate-200 dark:border-slate-800" },
|
|
@@ -71,6 +72,7 @@ const O = {
|
|
|
71
72
|
updateHeight: u
|
|
72
73
|
});
|
|
73
74
|
const w = f(() => {
|
|
75
|
+
if (t.height) return t.height;
|
|
74
76
|
switch (t.density) {
|
|
75
77
|
case "comfortable":
|
|
76
78
|
return "h-[56px]";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref as g, computed as h, onMounted as
|
|
2
|
-
const
|
|
1
|
+
import { ref as g, computed as h, onMounted as V, onBeforeUnmount as D, createElementBlock as P, openBlock as $, Fragment as j, createElementVNode as E, createBlock as F, createCommentVNode as A, mergeProps as I, renderSlot as O, Teleport as K, createVNode as U, Transition as X, withCtx as Y, withDirectives as _, normalizeStyle as q, normalizeClass as G, createTextVNode as H, toDisplayString as J, vShow as Q, nextTick as W } from "vue";
|
|
2
|
+
const Z = "absolute px-3 py-2 shadow", te = {
|
|
3
3
|
__name: "KunTooltip",
|
|
4
4
|
props: {
|
|
5
5
|
class: [String, Array, Object],
|
|
@@ -16,81 +16,83 @@ const W = "absolute px-3 py-2 shadow", ee = {
|
|
|
16
16
|
textSize: { type: String, default: "text-sm" },
|
|
17
17
|
dist: { type: [Number, Object], default: () => ({ x: 0, y: 8 }) }
|
|
18
18
|
},
|
|
19
|
-
setup(
|
|
20
|
-
const t =
|
|
21
|
-
let
|
|
19
|
+
setup(s) {
|
|
20
|
+
const t = s, z = "tooltip-" + Math.random().toString(36).slice(2, 11), o = g(!1), v = g(null), x = g(null), T = g({});
|
|
21
|
+
let u = null, n = null, i = null, r = !1;
|
|
22
22
|
function y() {
|
|
23
|
-
t.disabled || (clearTimeout(u), clearTimeout(
|
|
24
|
-
v.value && (
|
|
23
|
+
t.disabled || o.value || r || (clearTimeout(u), clearTimeout(n), clearTimeout(i), r = !0, u = setTimeout(async () => {
|
|
24
|
+
r = !1, v.value && (o.value = !0, await W(), b(), i = setTimeout(() => {
|
|
25
|
+
a();
|
|
26
|
+
}, 5e3));
|
|
25
27
|
}, +t.delay));
|
|
26
28
|
}
|
|
27
|
-
function
|
|
28
|
-
clearTimeout(u), clearTimeout(
|
|
29
|
-
|
|
30
|
-
}, +t.closeDelay);
|
|
31
|
-
}
|
|
32
|
-
function z() {
|
|
33
|
-
l.value ? r() : y();
|
|
29
|
+
function a() {
|
|
30
|
+
clearTimeout(u), clearTimeout(n), clearTimeout(i), !(!o.value && !r) && (n = setTimeout(() => {
|
|
31
|
+
o.value = !1, r = !1;
|
|
32
|
+
}, +t.closeDelay));
|
|
34
33
|
}
|
|
35
34
|
function B() {
|
|
36
|
-
|
|
35
|
+
o.value ? a() : y();
|
|
37
36
|
}
|
|
38
37
|
function L() {
|
|
39
|
-
|
|
38
|
+
clearTimeout(n), clearTimeout(i);
|
|
39
|
+
}
|
|
40
|
+
function N() {
|
|
41
|
+
a();
|
|
40
42
|
}
|
|
41
|
-
const
|
|
43
|
+
const w = h(() => {
|
|
42
44
|
if (t.disabled) return {};
|
|
43
45
|
const e = {};
|
|
44
|
-
return t.openOn === "hover" && (e.onMouseenter = y, e.onMouseleave =
|
|
45
|
-
}),
|
|
46
|
-
function
|
|
46
|
+
return t.openOn === "hover" && (e.onMouseenter = y, e.onMouseleave = a), t.openOn === "click" && (e.onClick = B), t.openOn === "focus" && (e.onFocus = y, e.onBlur = a), e;
|
|
47
|
+
}), R = h(() => [Z, t.textColor, t.bgColor, t.textSize, t.rounded, t.class]), M = h(() => typeof t.dist == "number" ? { x: 0, y: t.dist } : { x: t.dist.x ?? 0, y: t.dist.y ?? 0 });
|
|
48
|
+
function b() {
|
|
47
49
|
var k, C;
|
|
48
|
-
const e = (k = v.value) == null ? void 0 : k.getBoundingClientRect(),
|
|
49
|
-
if (!e || !
|
|
50
|
-
const d = window.pageYOffset || document.documentElement.scrollTop, f = window.pageXOffset || document.documentElement.scrollLeft, { x: p, y: m } =
|
|
51
|
-
top: { top: `${e.top + d -
|
|
52
|
-
bottom: { top: `${e.bottom + d + m}px`, left: `${e.left + f + e.width / 2 -
|
|
53
|
-
left: { top: `${e.top + d + e.height / 2 -
|
|
54
|
-
right: { top: `${e.top + d + e.height / 2 -
|
|
50
|
+
const e = (k = v.value) == null ? void 0 : k.getBoundingClientRect(), l = (C = x.value) == null ? void 0 : C.getBoundingClientRect();
|
|
51
|
+
if (!e || !l) return;
|
|
52
|
+
const d = window.pageYOffset || document.documentElement.scrollTop, f = window.pageXOffset || document.documentElement.scrollLeft, { x: p, y: m } = M.value, S = {
|
|
53
|
+
top: { top: `${e.top + d - l.height - m}px`, left: `${e.left + f + e.width / 2 - l.width / 2 + p}px` },
|
|
54
|
+
bottom: { top: `${e.bottom + d + m}px`, left: `${e.left + f + e.width / 2 - l.width / 2 + p}px` },
|
|
55
|
+
left: { top: `${e.top + d + e.height / 2 - l.height / 2 + m}px`, left: `${e.left + f - l.width - p}px` },
|
|
56
|
+
right: { top: `${e.top + d + e.height / 2 - l.height / 2 + m}px`, left: `${e.right + f + p}px` }
|
|
55
57
|
};
|
|
56
|
-
|
|
58
|
+
T.value = S[t.location] || S.top;
|
|
57
59
|
}
|
|
58
60
|
const c = () => {
|
|
59
|
-
|
|
61
|
+
o.value && b();
|
|
60
62
|
};
|
|
61
|
-
return
|
|
63
|
+
return V(() => {
|
|
62
64
|
window.addEventListener("scroll", c), window.addEventListener("resize", c);
|
|
63
|
-
}),
|
|
64
|
-
clearTimeout(u), clearTimeout(i),
|
|
65
|
-
}), (e,
|
|
66
|
-
E("span",
|
|
65
|
+
}), D(() => {
|
|
66
|
+
clearTimeout(u), clearTimeout(n), clearTimeout(i), o.value = !1, window.removeEventListener("scroll", c), window.removeEventListener("resize", c);
|
|
67
|
+
}), (e, l) => ($(), P(j, null, [
|
|
68
|
+
E("span", I({
|
|
67
69
|
ref_key: "activatorRef",
|
|
68
70
|
ref: v
|
|
69
|
-
},
|
|
70
|
-
O(e.$slots, "activator", { props:
|
|
71
|
+
}, w.value), [
|
|
72
|
+
O(e.$slots, "activator", { props: w.value })
|
|
71
73
|
], 16),
|
|
72
|
-
|
|
74
|
+
s.disabled ? A("", !0) : ($(), F(K, {
|
|
73
75
|
key: 0,
|
|
74
76
|
to: "body"
|
|
75
77
|
}, [
|
|
76
|
-
|
|
77
|
-
default:
|
|
78
|
-
|
|
79
|
-
id:
|
|
78
|
+
U(X, { name: s.transition }, {
|
|
79
|
+
default: Y(() => [
|
|
80
|
+
_(E("div", {
|
|
81
|
+
id: z,
|
|
80
82
|
ref_key: "tooltipRef",
|
|
81
83
|
ref: x,
|
|
82
|
-
class:
|
|
83
|
-
style:
|
|
84
|
+
class: G(R.value),
|
|
85
|
+
style: q([T.value, { "z-index": "9999" }]),
|
|
84
86
|
role: "tooltip",
|
|
85
87
|
"aria-hidden": "!isVisible",
|
|
86
|
-
onMouseenter:
|
|
87
|
-
onMouseleave:
|
|
88
|
+
onMouseenter: L,
|
|
89
|
+
onMouseleave: N
|
|
88
90
|
}, [
|
|
89
91
|
O(e.$slots, "default", {}, () => [
|
|
90
|
-
|
|
92
|
+
H(J(s.text), 1)
|
|
91
93
|
])
|
|
92
94
|
], 38), [
|
|
93
|
-
[
|
|
95
|
+
[Q, o.value]
|
|
94
96
|
])
|
|
95
97
|
]),
|
|
96
98
|
_: 3
|
|
@@ -100,5 +102,5 @@ const W = "absolute px-3 py-2 shadow", ee = {
|
|
|
100
102
|
}
|
|
101
103
|
};
|
|
102
104
|
export {
|
|
103
|
-
|
|
105
|
+
te as default
|
|
104
106
|
};
|