@memobit/libs 3.11.0 → 3.11.1
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,70 +1,76 @@
|
|
|
1
1
|
import './Tooltip.css';
|
|
2
2
|
/* empty css */
|
|
3
3
|
import { useEffect as b, useRef as h, useState as B } from "react";
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { createPortal as
|
|
4
|
+
import { Fragment as S, jsx as N, jsxs as D } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as V } from "react-dom";
|
|
6
6
|
var K = ({ title: L, position: T = "top", delay: _ = 200, children: k, disabled: $ = !1, className: F = "", maxWidth: p, maxHeight: a }) => {
|
|
7
|
-
const [f,
|
|
7
|
+
const [f, u] = B(!1), [M, I] = B({
|
|
8
8
|
top: 0,
|
|
9
9
|
left: 0
|
|
10
|
-
}), c = h(null),
|
|
11
|
-
if (!l.current || !
|
|
12
|
-
const
|
|
13
|
-
let e =
|
|
10
|
+
}), c = h(null), r = h(null), l = h(null), d = h(null), g = h(!1), w = a !== void 0, v = w ? 150 : 0, R = () => {
|
|
11
|
+
if (!l.current || !d.current) return;
|
|
12
|
+
const t = l.current.firstElementChild?.getBoundingClientRect();
|
|
13
|
+
let e = t && t.width > 0 ? t : l.current.getBoundingClientRect();
|
|
14
14
|
if (e.width === 0 && e.height === 0) {
|
|
15
15
|
const C = document.createRange();
|
|
16
16
|
C.selectNodeContents(l.current);
|
|
17
17
|
const E = C.getBoundingClientRect();
|
|
18
18
|
(E.width > 0 || E.height > 0) && (e = E);
|
|
19
19
|
}
|
|
20
|
-
const n =
|
|
20
|
+
const n = d.current.getBoundingClientRect(), m = 8;
|
|
21
21
|
let o = 0, i = 0;
|
|
22
22
|
switch (T) {
|
|
23
23
|
case "top":
|
|
24
|
-
o = e.top - n.height -
|
|
24
|
+
o = e.top - n.height - m, i = e.left + e.width / 2 - n.width / 2;
|
|
25
25
|
break;
|
|
26
26
|
case "bottom":
|
|
27
|
-
o = e.bottom +
|
|
27
|
+
o = e.bottom + m, i = e.left + e.width / 2 - n.width / 2;
|
|
28
28
|
break;
|
|
29
29
|
case "left":
|
|
30
|
-
o = e.top + e.height / 2 - n.height / 2, i = e.left - n.width -
|
|
30
|
+
o = e.top + e.height / 2 - n.height / 2, i = e.left - n.width - m;
|
|
31
31
|
break;
|
|
32
32
|
case "right":
|
|
33
|
-
o = e.top + e.height / 2 - n.height / 2, i = e.right +
|
|
33
|
+
o = e.top + e.height / 2 - n.height / 2, i = e.right + m;
|
|
34
34
|
}
|
|
35
|
-
const
|
|
36
|
-
i <
|
|
35
|
+
const s = 8;
|
|
36
|
+
i < s && (i = s), i + n.width > window.innerWidth - s && (i = window.innerWidth - n.width - s), o < s && (o = s), o + n.height > window.innerHeight - s && (o = window.innerHeight - n.height - s), I({
|
|
37
37
|
top: o,
|
|
38
38
|
left: i
|
|
39
39
|
});
|
|
40
40
|
}, P = () => {
|
|
41
|
-
$ ||
|
|
42
|
-
|
|
41
|
+
$ || g.current || (r.current && (clearTimeout(r.current), r.current = null), c.current = setTimeout(() => {
|
|
42
|
+
u(!0);
|
|
43
43
|
}, _));
|
|
44
44
|
}, y = () => {
|
|
45
|
-
|
|
46
|
-
}, j = (
|
|
47
|
-
|
|
45
|
+
g.current || (c.current && clearTimeout(c.current), v > 0 ? r.current = setTimeout(() => u(!1), v) : u(!1));
|
|
46
|
+
}, j = (t) => {
|
|
47
|
+
t.pointerType !== "touch" && t.pointerType !== "pen" || $ || (g.current = !0, c.current && (clearTimeout(c.current), c.current = null), t.stopPropagation(), u((e) => !e));
|
|
48
48
|
};
|
|
49
|
-
b(() =>
|
|
50
|
-
window.removeEventListener("scroll", d, !0), window.removeEventListener("resize", d);
|
|
51
|
-
}), [f]), b(() => {
|
|
49
|
+
b(() => {
|
|
52
50
|
if (!f) return;
|
|
53
|
-
const
|
|
54
|
-
|
|
51
|
+
const t = (e) => {
|
|
52
|
+
e.target instanceof Node && d.current?.contains(e.target) || u(!1);
|
|
55
53
|
};
|
|
56
|
-
return
|
|
57
|
-
|
|
54
|
+
return R(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", R), () => {
|
|
55
|
+
window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", R);
|
|
56
|
+
};
|
|
57
|
+
}, [f]), b(() => {
|
|
58
|
+
if (!f) return;
|
|
59
|
+
const t = (e) => {
|
|
60
|
+
l.current?.contains(e.target) || d.current?.contains(e.target) || u(!1);
|
|
61
|
+
};
|
|
62
|
+
return document.addEventListener("pointerdown", t), () => {
|
|
63
|
+
document.removeEventListener("pointerdown", t), g.current = !1;
|
|
58
64
|
};
|
|
59
65
|
}, [f]), b(() => () => {
|
|
60
|
-
c.current && clearTimeout(c.current),
|
|
66
|
+
c.current && clearTimeout(c.current), r.current && clearTimeout(r.current);
|
|
61
67
|
}, []);
|
|
62
68
|
const x = () => {
|
|
63
|
-
|
|
69
|
+
w && r.current && (clearTimeout(r.current), r.current = null);
|
|
64
70
|
}, z = () => {
|
|
65
|
-
|
|
71
|
+
w && (r.current = setTimeout(() => u(!1), v));
|
|
66
72
|
};
|
|
67
|
-
return /* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ D(S, { children: [/* @__PURE__ */ N("span", {
|
|
68
74
|
ref: l,
|
|
69
75
|
className: "tooltip-trigger",
|
|
70
76
|
onMouseEnter: P,
|
|
@@ -73,9 +79,9 @@ var K = ({ title: L, position: T = "top", delay: _ = 200, children: k, disabled:
|
|
|
73
79
|
onBlur: y,
|
|
74
80
|
onPointerDown: j,
|
|
75
81
|
children: k
|
|
76
|
-
}), f && L &&
|
|
77
|
-
ref:
|
|
78
|
-
className: `tooltip tooltip--${T} ${
|
|
82
|
+
}), f && L && V(/* @__PURE__ */ D("div", {
|
|
83
|
+
ref: d,
|
|
84
|
+
className: `tooltip tooltip--${T} ${w ? "tooltip--scrollable" : ""} ${F}`,
|
|
79
85
|
style: {
|
|
80
86
|
top: `${M.top}px`,
|
|
81
87
|
left: `${M.left}px`,
|
|
@@ -84,7 +90,7 @@ var K = ({ title: L, position: T = "top", delay: _ = 200, children: k, disabled:
|
|
|
84
90
|
},
|
|
85
91
|
onMouseEnter: x,
|
|
86
92
|
onMouseLeave: z,
|
|
87
|
-
children: [L, /* @__PURE__ */
|
|
93
|
+
children: [L, /* @__PURE__ */ N("div", { className: `tooltip__arrow tooltip__arrow--${T}` })]
|
|
88
94
|
}), document.body)] });
|
|
89
95
|
};
|
|
90
96
|
export {
|
package/dist/version.js
CHANGED
package/dist/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memobit/libs",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "React component library powering the Memobit apps — 100+ components, helpers and hooks. Icons ship as @memobit/icons and themes as @memobit/themes. TypeScript-first, ESM-only, React 19.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|