@caseparts-org/caseblocks 0.0.101 → 0.0.102
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.
|
@@ -1,78 +1,79 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as W, Fragment as A, jsx as S } from "react/jsx-runtime";
|
|
2
2
|
import * as i from "react";
|
|
3
|
-
import { c as
|
|
4
|
-
import { r as
|
|
5
|
-
import '../../assets/Tooltip.css';const
|
|
6
|
-
tooltip:
|
|
7
|
-
content:
|
|
3
|
+
import { c as j } from "../../clsx-OuTLNxxd.js";
|
|
4
|
+
import { r as D } from "../../index-B4KbmMH3.js";
|
|
5
|
+
import '../../assets/Tooltip.css';const I = "_tooltip_17o7a_1", O = "_content_17o7a_11", H = {
|
|
6
|
+
tooltip: I,
|
|
7
|
+
content: O
|
|
8
8
|
};
|
|
9
|
-
function
|
|
10
|
-
return
|
|
9
|
+
function $(u) {
|
|
10
|
+
return u ? u.includes(" ") ? u : `${u} center` : "top center";
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
12
|
+
function q(u) {
|
|
13
|
+
const w = $(u).toLowerCase(), [s, t] = w.split(" ");
|
|
14
14
|
return { side: ["top", "right", "bottom", "left"].includes(s) ? s : "top", align: t === "left" || t === "top" ? "start" : t === "right" || t === "bottom" ? "end" : "center" };
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const n =
|
|
18
|
-
let
|
|
19
|
-
s === "top" ?
|
|
20
|
-
const E = window.innerWidth,
|
|
21
|
-
return
|
|
16
|
+
function G(u, w, s, t, d = 0) {
|
|
17
|
+
const n = u.getBoundingClientRect(), f = w.getBoundingClientRect();
|
|
18
|
+
let a = 0, c = 0;
|
|
19
|
+
s === "top" ? a = n.top - f.height - d : s === "bottom" ? a = n.bottom + d : s === "left" ? c = n.left - f.width - d : s === "right" && (c = n.right + d), s === "top" || s === "bottom" ? t === "start" ? c = n.left : t === "end" ? c = n.right - f.width : c = n.left + n.width / 2 - f.width / 2 : t === "start" ? a = n.top : t === "end" ? a = n.bottom - f.height : a = n.top + n.height / 2 - f.height / 2;
|
|
20
|
+
const E = window.innerWidth, v = window.innerHeight;
|
|
21
|
+
return a = Math.max(4, Math.min(v - f.height - 4, a)), c = Math.max(4, Math.min(E - f.width - 4, c)), { top: a, left: c };
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
tooltipClassName:
|
|
25
|
-
contentClassName:
|
|
23
|
+
const U = ({
|
|
24
|
+
tooltipClassName: u,
|
|
25
|
+
contentClassName: w,
|
|
26
26
|
children: s,
|
|
27
27
|
trigger: t,
|
|
28
28
|
position: d,
|
|
29
29
|
disabled: n,
|
|
30
|
-
openDelay:
|
|
31
|
-
closeDelay:
|
|
32
|
-
leaveGraceMs: c = 0
|
|
30
|
+
openDelay: f = 150,
|
|
31
|
+
closeDelay: a = 100,
|
|
32
|
+
leaveGraceMs: c = 0,
|
|
33
|
+
tooltipOffset: E = 4
|
|
33
34
|
}) => {
|
|
34
|
-
const { side:
|
|
35
|
+
const { side: v, align: b } = q(d), [o, R] = i.useState(!1), [m, C] = i.useState(null), T = i.useRef(null), g = i.useRef(null), x = i.useRef(null), y = i.useRef(null), L = i.useRef(null), h = i.useRef(!1), p = (e) => {
|
|
35
36
|
e.current && (window.clearTimeout(e.current), e.current = null);
|
|
36
37
|
}, B = () => {
|
|
37
|
-
|
|
38
|
+
p(x), p(y), p(L);
|
|
38
39
|
};
|
|
39
40
|
i.useEffect(() => () => B(), []);
|
|
40
41
|
const k = () => {
|
|
41
|
-
n || o || (
|
|
42
|
+
n || o || (p(x), x.current = window.setTimeout(() => R(!0), f));
|
|
42
43
|
}, _ = () => {
|
|
43
|
-
o && (
|
|
44
|
-
|
|
45
|
-
},
|
|
44
|
+
o && (p(y), y.current = window.setTimeout(() => {
|
|
45
|
+
h.current || R(!1);
|
|
46
|
+
}, a));
|
|
46
47
|
}, z = () => {
|
|
47
48
|
if (o) {
|
|
48
|
-
if (
|
|
49
|
+
if (p(L), c <= 0) {
|
|
49
50
|
_();
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
L.current = window.setTimeout(() => {
|
|
54
|
+
h.current || _();
|
|
54
55
|
}, c);
|
|
55
56
|
}
|
|
56
|
-
},
|
|
57
|
-
e == null || e(
|
|
58
|
-
},
|
|
57
|
+
}, P = (e, r) => (l) => {
|
|
58
|
+
e == null || e(l), r == null || r(l);
|
|
59
|
+
}, N = i.cloneElement(t, {
|
|
59
60
|
ref: (e) => {
|
|
60
61
|
const { ref: r } = t;
|
|
61
62
|
typeof r == "function" ? r(e) : r && (r.current = e), T.current = e;
|
|
62
63
|
},
|
|
63
|
-
onPointerEnter:
|
|
64
|
-
onPointerLeave:
|
|
65
|
-
onFocus:
|
|
66
|
-
onBlur:
|
|
64
|
+
onPointerEnter: P(t.props.onPointerEnter, k),
|
|
65
|
+
onPointerLeave: P(t.props.onPointerLeave, z),
|
|
66
|
+
onFocus: P(t.props.onFocus, k),
|
|
67
|
+
onBlur: P(t.props.onBlur, _),
|
|
67
68
|
"aria-describedby": o ? "tooltip-popup" : void 0,
|
|
68
69
|
style: { ...t.props.style || {}, outline: "none" }
|
|
69
70
|
});
|
|
70
71
|
return i.useEffect(() => {
|
|
71
|
-
n && o && (B(),
|
|
72
|
+
n && o && (B(), R(!1));
|
|
72
73
|
}, [n]), i.useEffect(() => {
|
|
73
74
|
if (!o) return;
|
|
74
75
|
const e = (r) => {
|
|
75
|
-
r.key === "Escape" &&
|
|
76
|
+
r.key === "Escape" && R(!1);
|
|
76
77
|
};
|
|
77
78
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
78
79
|
}, [o]), i.useLayoutEffect(() => {
|
|
@@ -82,36 +83,36 @@ const Q = ({
|
|
|
82
83
|
}
|
|
83
84
|
const e = T.current, r = g.current;
|
|
84
85
|
if (!e || !r) return;
|
|
85
|
-
const
|
|
86
|
-
C(
|
|
86
|
+
const l = () => {
|
|
87
|
+
C(G(e, r, v, b, E));
|
|
87
88
|
};
|
|
88
|
-
return
|
|
89
|
-
window.removeEventListener("resize",
|
|
89
|
+
return l(), window.addEventListener("resize", l), window.addEventListener("scroll", l, !0), () => {
|
|
90
|
+
window.removeEventListener("resize", l), window.removeEventListener("scroll", l, !0);
|
|
90
91
|
};
|
|
91
|
-
}, [o,
|
|
92
|
+
}, [o, v, b, s, E]), i.useEffect(() => {
|
|
92
93
|
if (!o) return;
|
|
93
94
|
const e = (r) => {
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
96
|
-
const
|
|
97
|
-
!
|
|
95
|
+
const l = T.current, F = g.current;
|
|
96
|
+
if (!l || !F) return;
|
|
97
|
+
const M = r.target;
|
|
98
|
+
!l.contains(M) && !F.contains(M) && (h.current = !1, z());
|
|
98
99
|
};
|
|
99
100
|
return document.addEventListener("pointermove", e), () => document.removeEventListener("pointermove", e);
|
|
100
101
|
}, [o]), i.useEffect(() => {
|
|
101
|
-
o || (
|
|
102
|
-
}, [o]), /* @__PURE__ */
|
|
103
|
-
|
|
104
|
-
o && typeof document < "u" &&
|
|
105
|
-
/* @__PURE__ */
|
|
102
|
+
o || (h.current = !1);
|
|
103
|
+
}, [o]), /* @__PURE__ */ W(A, { children: [
|
|
104
|
+
N,
|
|
105
|
+
o && typeof document < "u" && D.createPortal(
|
|
106
|
+
/* @__PURE__ */ S(
|
|
106
107
|
"div",
|
|
107
108
|
{
|
|
108
109
|
id: "tooltip-popup",
|
|
109
110
|
ref: g,
|
|
110
111
|
role: "tooltip",
|
|
111
112
|
"aria-hidden": !o,
|
|
112
|
-
"data-side":
|
|
113
|
-
"data-align":
|
|
114
|
-
className:
|
|
113
|
+
"data-side": v,
|
|
114
|
+
"data-align": b,
|
|
115
|
+
className: j(H.tooltip, u),
|
|
115
116
|
style: {
|
|
116
117
|
position: "absolute",
|
|
117
118
|
top: (m == null ? void 0 : m.top) ?? 0,
|
|
@@ -120,12 +121,12 @@ const Q = ({
|
|
|
120
121
|
zIndex: 10
|
|
121
122
|
},
|
|
122
123
|
onPointerEnter: () => {
|
|
123
|
-
|
|
124
|
+
h.current = !0, p(y), p(L);
|
|
124
125
|
},
|
|
125
126
|
onPointerLeave: () => {
|
|
126
|
-
|
|
127
|
+
h.current = !1, z();
|
|
127
128
|
},
|
|
128
|
-
children: /* @__PURE__ */
|
|
129
|
+
children: /* @__PURE__ */ S("div", { className: j(H.content, w), children: s })
|
|
129
130
|
}
|
|
130
131
|
),
|
|
131
132
|
document.body
|
|
@@ -133,5 +134,5 @@ const Q = ({
|
|
|
133
134
|
] });
|
|
134
135
|
};
|
|
135
136
|
export {
|
|
136
|
-
|
|
137
|
+
U as Tooltip
|
|
137
138
|
};
|
|
@@ -19,6 +19,7 @@ function z({
|
|
|
19
19
|
{
|
|
20
20
|
openDelay: 180,
|
|
21
21
|
closeDelay: 0,
|
|
22
|
+
tooltipOffset: 0,
|
|
22
23
|
trigger: /* @__PURE__ */ e("li", { className: o.category, tabIndex: 0, children: /* @__PURE__ */ t(s, { href: i.route, children: [
|
|
23
24
|
/* @__PURE__ */ e(n, { size: "sm", weight: "semibold", children: i.label }),
|
|
24
25
|
i.showChevron && /* @__PURE__ */ e(
|