@indielayer/ui 1.15.2 → 1.15.3
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/lib/components/tooltip/Tooltip.vue.js +76 -78
- package/lib/components/tooltip/index.d.ts +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/components/tooltip/Tooltip.vue +31 -25
- package/src/components/tooltip/index.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { useTheme as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as H, ref as r, useSlots as M, computed as c, openBlock as v, createBlock as w, resolveDynamicComponent as W, normalizeClass as u, unref as y, withCtx as k, renderSlot as C, Teleport as O, createVNode as X, Transition as j, createElementBlock as q, normalizeStyle as A, createTextVNode as F, toDisplayString as G, createElementVNode as T, createCommentVNode as R } from "vue";
|
|
2
|
+
import { useTheme as I } from "../../composables/useTheme.js";
|
|
3
|
+
const J = {
|
|
4
4
|
tag: {
|
|
5
5
|
type: String,
|
|
6
6
|
default: "div"
|
|
@@ -11,112 +11,110 @@ const K = {
|
|
|
11
11
|
type: String,
|
|
12
12
|
default: "bottom"
|
|
13
13
|
}
|
|
14
|
-
},
|
|
15
|
-
...
|
|
16
|
-
props:
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
14
|
+
}, K = { name: "XTooltip" }, U = /* @__PURE__ */ H({
|
|
15
|
+
...K,
|
|
16
|
+
props: J,
|
|
17
|
+
setup(S) {
|
|
18
|
+
const n = S, f = r(null), h = r(null), g = r(!1), b = r({}), p = r(n.position), _ = M(), B = c(() => n.tooltip || _.tooltip), a = c(() => n.disabled || !B.value), N = c(() => a.value ? "" : {
|
|
19
19
|
top: "-bottom-2.5 left-1/2 -translate-x-1/2 w-3.5",
|
|
20
20
|
bottom: "-top-2.5 left-1/2 -translate-x-1/2 w-3.5",
|
|
21
21
|
left: "-right-2.5 top-1/2 -translate-y-1/2 h-3.5",
|
|
22
22
|
right: "-left-2.5 top-1/2 -translate-y-1/2 h-3.5"
|
|
23
|
-
}
|
|
23
|
+
}[p.value]), V = c(() => a.value ? "" : {
|
|
24
24
|
top: "-rotate-45 origin-top-left",
|
|
25
25
|
bottom: "rotate-45 origin-bottom-left",
|
|
26
26
|
left: "rotate-45 origin-top-left",
|
|
27
27
|
right: "-rotate-45 origin-top-right"
|
|
28
|
-
}
|
|
28
|
+
}[p.value]), $ = c(() => a.value ? "" : {
|
|
29
29
|
top: "origin-bottom",
|
|
30
30
|
bottom: "origin-top",
|
|
31
31
|
left: "origin-right",
|
|
32
32
|
right: "origin-left"
|
|
33
|
-
}
|
|
34
|
-
if (!
|
|
33
|
+
}[p.value]), x = () => {
|
|
34
|
+
if (!f.value || !h.value)
|
|
35
35
|
return;
|
|
36
|
-
const t =
|
|
37
|
-
let s =
|
|
36
|
+
const t = f.value.getBoundingClientRect(), e = h.value.getBoundingClientRect(), l = 8, d = window.innerWidth, m = window.innerHeight;
|
|
37
|
+
let s = n.position, o = 0, i = 0;
|
|
38
38
|
switch (s) {
|
|
39
39
|
case "top":
|
|
40
40
|
o = t.top - e.height - l, i = t.left + t.width / 2 - e.width / 2, o < 0 && (s = "bottom", o = t.bottom + l);
|
|
41
41
|
break;
|
|
42
42
|
case "bottom":
|
|
43
|
-
o = t.bottom + l, i = t.left + t.width / 2 - e.width / 2, o + e.height >
|
|
43
|
+
o = t.bottom + l, i = t.left + t.width / 2 - e.width / 2, o + e.height > m && (s = "top", o = t.top - e.height - l);
|
|
44
44
|
break;
|
|
45
45
|
case "left":
|
|
46
46
|
o = t.top + t.height / 2 - e.height / 2, i = t.left - e.width - l, i < 0 && (s = "right", i = t.right + l);
|
|
47
47
|
break;
|
|
48
48
|
case "right":
|
|
49
|
-
o = t.top + t.height / 2 - e.height / 2, i = t.right + l, i + e.width >
|
|
49
|
+
o = t.top + t.height / 2 - e.height / 2, i = t.right + l, i + e.width > d && (s = "left", i = t.left - e.width - l);
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
|
-
(s === "top" || s === "bottom") && (i < 0 && (i = l), i + e.width >
|
|
52
|
+
(s === "top" || s === "bottom") && (i < 0 && (i = l), i + e.width > d && (i = d - e.width - l)), (s === "left" || s === "right") && (o < 0 && (o = l), o + e.height > m && (o = m - e.height - l)), p.value = s, b.value = {
|
|
53
53
|
top: `${o}px`,
|
|
54
54
|
left: `${i}px`
|
|
55
55
|
};
|
|
56
|
+
}, z = () => {
|
|
57
|
+
a.value || (g.value = !0, setTimeout(x, 0));
|
|
56
58
|
}, P = () => {
|
|
57
|
-
|
|
58
|
-
}, D = (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
ref: h,
|
|
96
|
-
style: A(b.value),
|
|
97
|
-
class: f(["fixed z-[9999] pointer-events-none", [
|
|
98
|
-
k(E).tooltip,
|
|
99
|
-
x.value
|
|
100
|
-
]])
|
|
101
|
-
}, [
|
|
102
|
-
T(t.$slots, "tooltip", {}, () => [
|
|
103
|
-
G(I(t.tooltip), 1)
|
|
104
|
-
]),
|
|
105
|
-
R("div", {
|
|
106
|
-
class: f(["absolute overflow-hidden shadow-lg z-10", V.value])
|
|
59
|
+
a.value || (g.value = !1);
|
|
60
|
+
}, { classes: D, className: E } = I("Tooltip", {}, n);
|
|
61
|
+
return (t, e) => (v(), w(W(t.tag), {
|
|
62
|
+
ref_key: "triggerRef",
|
|
63
|
+
ref: f,
|
|
64
|
+
class: u([
|
|
65
|
+
y(E),
|
|
66
|
+
{
|
|
67
|
+
"inline-block": !t.$attrs.class
|
|
68
|
+
}
|
|
69
|
+
]),
|
|
70
|
+
onMouseenter: z,
|
|
71
|
+
onMouseleave: P
|
|
72
|
+
}, {
|
|
73
|
+
default: k(() => [
|
|
74
|
+
C(t.$slots, "default"),
|
|
75
|
+
a.value ? R("", !0) : (v(), w(O, {
|
|
76
|
+
key: 0,
|
|
77
|
+
to: "body"
|
|
78
|
+
}, [
|
|
79
|
+
X(j, {
|
|
80
|
+
"enter-active-class": "transition-opacity duration-150 ease-out",
|
|
81
|
+
"leave-active-class": "transition-opacity duration-150 ease-in",
|
|
82
|
+
"enter-from-class": "opacity-0",
|
|
83
|
+
"enter-to-class": "opacity-100",
|
|
84
|
+
"leave-from-class": "opacity-100",
|
|
85
|
+
"leave-to-class": "opacity-0"
|
|
86
|
+
}, {
|
|
87
|
+
default: k(() => [
|
|
88
|
+
g.value ? (v(), q("div", {
|
|
89
|
+
key: 0,
|
|
90
|
+
ref_key: "tooltipRef",
|
|
91
|
+
ref: h,
|
|
92
|
+
style: A(b.value),
|
|
93
|
+
class: u(["fixed z-[10001] pointer-events-none", [
|
|
94
|
+
y(D).tooltip,
|
|
95
|
+
$.value
|
|
96
|
+
]])
|
|
107
97
|
}, [
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
98
|
+
C(t.$slots, "tooltip", {}, () => [
|
|
99
|
+
F(G(t.tooltip), 1)
|
|
100
|
+
]),
|
|
101
|
+
T("div", {
|
|
102
|
+
class: u(["absolute overflow-hidden shadow-lg z-10", N.value])
|
|
103
|
+
}, [
|
|
104
|
+
T("div", {
|
|
105
|
+
class: u(["h-2.5 w-2.5 bg-secondary-700 transform border border-secondary-800", V.value])
|
|
106
|
+
}, null, 2)
|
|
107
|
+
], 2)
|
|
108
|
+
], 6)) : R("", !0)
|
|
109
|
+
]),
|
|
110
|
+
_: 3
|
|
111
|
+
})
|
|
112
|
+
]))
|
|
113
|
+
]),
|
|
114
|
+
_: 3
|
|
115
|
+
}, 40, ["class"]));
|
|
118
116
|
}
|
|
119
117
|
});
|
|
120
118
|
export {
|
|
121
|
-
|
|
119
|
+
U as default
|
|
122
120
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as XTooltip } from './Tooltip.vue';
|
|
2
|
-
export type { TooltipProps, TooltipTheme } from './Tooltip.vue';
|
|
2
|
+
export type { TooltipProps, TooltipPosition, TooltipTheme } from './Tooltip.vue';
|
|
3
3
|
export { default as XToggleTip } from './ToggleTip.vue';
|
|
4
4
|
export type { ToggleTipProps } from './ToggleTip.vue';
|