@memobit/libs 3.28.0 → 3.28.2
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,111 +1,121 @@
|
|
|
1
1
|
import './Popover.css';
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { useCallback as
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
var
|
|
7
|
-
const
|
|
3
|
+
import { useCallback as z, useEffect as y, useRef as A, useState as G } from "react";
|
|
4
|
+
import { jsx as F, jsxs as S } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as T } from "react-dom";
|
|
6
|
+
var l = 20, M = 16, j = 8, q = ({ children: b, visible: d, onClose: v, anchorEl: h, offset: m = j, placement: r = "auto" }) => {
|
|
7
|
+
const f = A(null), R = A(null), [u, k] = G({
|
|
8
8
|
top: 0,
|
|
9
9
|
left: 0,
|
|
10
10
|
placement: "bottom",
|
|
11
11
|
arrowOffset: null
|
|
12
|
-
}),
|
|
13
|
-
if (!
|
|
14
|
-
const t =
|
|
12
|
+
}), p = z(() => {
|
|
13
|
+
if (!h || !f.current || !d) return;
|
|
14
|
+
const t = h.getBoundingClientRect(), e = {
|
|
15
|
+
width: f.current.offsetWidth,
|
|
16
|
+
height: f.current.offsetHeight
|
|
17
|
+
}, o = {
|
|
15
18
|
width: window.innerWidth,
|
|
16
19
|
height: window.innerHeight
|
|
17
|
-
},
|
|
20
|
+
}, E = (i, n) => i >= l && n >= l && i + e.height <= o.height - l && n + e.width <= o.width - l, w = {
|
|
18
21
|
bottom: {
|
|
19
|
-
top: t.bottom +
|
|
22
|
+
top: t.bottom + m,
|
|
20
23
|
left: t.left + (t.width - e.width) / 2
|
|
21
24
|
},
|
|
22
25
|
top: {
|
|
23
|
-
top: t.top - e.height -
|
|
26
|
+
top: t.top - e.height - m,
|
|
24
27
|
left: t.left + (t.width - e.width) / 2
|
|
25
28
|
},
|
|
26
29
|
left: {
|
|
27
30
|
top: t.top + (t.height - e.height) / 2,
|
|
28
|
-
left: t.left - e.width -
|
|
31
|
+
left: t.left - e.width - m
|
|
29
32
|
},
|
|
30
33
|
right: {
|
|
31
34
|
top: t.top + (t.height - e.height) / 2,
|
|
32
|
-
left: t.right +
|
|
35
|
+
left: t.right + m
|
|
33
36
|
}
|
|
34
|
-
};
|
|
35
|
-
let
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
"bottom",
|
|
39
|
-
"top",
|
|
40
|
-
"right",
|
|
41
|
-
"left"
|
|
42
|
-
].find((p) => {
|
|
43
|
-
const d = l[p];
|
|
44
|
-
return R(d.top, d.left);
|
|
45
|
-
}) || "bottom", { top: r, left: s } = l[o];
|
|
46
|
-
else {
|
|
47
|
-
const p = l[a];
|
|
48
|
-
R(p.top, p.left) ? (o = a, { top: r, left: s } = p) : (o = [
|
|
37
|
+
}, _ = t.top > o.height - t.bottom ? "top" : "bottom";
|
|
38
|
+
let c, L = !0;
|
|
39
|
+
if (r === "auto") {
|
|
40
|
+
const i = [
|
|
49
41
|
"bottom",
|
|
50
42
|
"top",
|
|
51
43
|
"right",
|
|
52
44
|
"left"
|
|
53
|
-
].
|
|
54
|
-
const
|
|
55
|
-
return
|
|
56
|
-
})
|
|
45
|
+
].find((n) => {
|
|
46
|
+
const s = w[n];
|
|
47
|
+
return E(s.top, s.left);
|
|
48
|
+
});
|
|
49
|
+
L = i !== void 0, c = i ?? _;
|
|
50
|
+
} else {
|
|
51
|
+
const i = w[r];
|
|
52
|
+
if (E(i.top, i.left)) c = r;
|
|
53
|
+
else {
|
|
54
|
+
const n = [
|
|
55
|
+
"bottom",
|
|
56
|
+
"top",
|
|
57
|
+
"right",
|
|
58
|
+
"left"
|
|
59
|
+
].filter((s) => s !== r).find((s) => {
|
|
60
|
+
const P = w[s];
|
|
61
|
+
return E(P.top, P.left);
|
|
62
|
+
});
|
|
63
|
+
L = n !== void 0, c = n ?? (r === "top" || r === "bottom" ? _ : r);
|
|
64
|
+
}
|
|
57
65
|
}
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
let { top: a, left: g } = w[c];
|
|
67
|
+
const x = (i, n, s) => Math.max(l, Math.min(i, s - n - l)), O = c === "top" || c === "bottom";
|
|
68
|
+
O ? (g = x(g, e.width, o.width), L || (a = x(a, e.height, o.height))) : a = x(a, e.height, o.height);
|
|
69
|
+
const N = O ? t.left + t.width / 2 - g : t.top + t.height / 2 - a, V = O ? e.width : e.height, W = Math.min(Math.max(N, M), V - M);
|
|
70
|
+
k({
|
|
71
|
+
top: a,
|
|
72
|
+
left: g,
|
|
73
|
+
placement: c,
|
|
74
|
+
arrowOffset: W
|
|
65
75
|
});
|
|
66
76
|
}, [
|
|
67
|
-
c,
|
|
68
77
|
h,
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
d,
|
|
79
|
+
m,
|
|
80
|
+
r
|
|
71
81
|
]);
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
}), [
|
|
75
|
-
if (!
|
|
76
|
-
const t = (
|
|
77
|
-
|
|
78
|
-
}, e = (
|
|
79
|
-
|
|
82
|
+
if (y(() => (d && (R.current = requestAnimationFrame(p)), () => {
|
|
83
|
+
R.current !== null && cancelAnimationFrame(R.current);
|
|
84
|
+
}), [d, p]), y(() => {
|
|
85
|
+
if (!d) return;
|
|
86
|
+
const t = (o) => {
|
|
87
|
+
f.current && h && !f.current.contains(o.target) && !h.contains(o.target) && v();
|
|
88
|
+
}, e = (o) => {
|
|
89
|
+
o.key === "Escape" && v();
|
|
80
90
|
};
|
|
81
|
-
return document.addEventListener("mousedown", t), document.addEventListener("keydown", e), window.addEventListener("resize",
|
|
82
|
-
document.removeEventListener("mousedown", t), document.removeEventListener("keydown", e), window.removeEventListener("resize",
|
|
91
|
+
return document.addEventListener("mousedown", t), document.addEventListener("keydown", e), window.addEventListener("resize", p), window.addEventListener("scroll", p, !0), () => {
|
|
92
|
+
document.removeEventListener("mousedown", t), document.removeEventListener("keydown", e), window.removeEventListener("resize", p), window.removeEventListener("scroll", p, !0);
|
|
83
93
|
};
|
|
84
94
|
}, [
|
|
95
|
+
d,
|
|
96
|
+
v,
|
|
85
97
|
h,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
ref: m,
|
|
92
|
-
className: `simple-popover simple-popover--${w.placement}`,
|
|
98
|
+
p
|
|
99
|
+
]), !d || !h) return null;
|
|
100
|
+
const I = /* @__PURE__ */ S("div", {
|
|
101
|
+
ref: f,
|
|
102
|
+
className: `simple-popover simple-popover--${u.placement}`,
|
|
93
103
|
style: {
|
|
94
104
|
position: "fixed",
|
|
95
|
-
top:
|
|
96
|
-
left:
|
|
105
|
+
top: u.top,
|
|
106
|
+
left: u.left,
|
|
97
107
|
zIndex: 9999
|
|
98
108
|
},
|
|
99
|
-
children: [/* @__PURE__ */
|
|
109
|
+
children: [/* @__PURE__ */ F("div", {
|
|
100
110
|
className: "simple-popover__arrow",
|
|
101
|
-
style:
|
|
102
|
-
}), /* @__PURE__ */
|
|
111
|
+
style: u.arrowOffset === null ? void 0 : { "--popover-arrow-position": `${u.arrowOffset}px` }
|
|
112
|
+
}), /* @__PURE__ */ F("div", {
|
|
103
113
|
className: "simple-popover__content",
|
|
104
|
-
children:
|
|
114
|
+
children: b
|
|
105
115
|
})]
|
|
106
116
|
});
|
|
107
|
-
return
|
|
117
|
+
return T(I, document.body);
|
|
108
118
|
};
|
|
109
119
|
export {
|
|
110
|
-
|
|
120
|
+
q as Popover
|
|
111
121
|
};
|
|
@@ -1,108 +1,114 @@
|
|
|
1
1
|
import './Tooltip.css';
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
var j =
|
|
7
|
-
const [g, u] =
|
|
3
|
+
import { createContext as H, useCallback as F, useContext as tt, useEffect as C, useRef as w, useState as P } from "react";
|
|
4
|
+
import { Fragment as et, jsx as x, jsxs as V } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as rt } from "react-dom";
|
|
6
|
+
var j = H(null), lt = ({ title: y, position: c = "top", delay: z = 200, children: q, disabled: E = !1, className: A = "", maxWidth: p, maxHeight: f }) => {
|
|
7
|
+
const [g, u] = P(!1), [D, G] = P(0), m = tt(j), [d, J] = P({
|
|
8
8
|
top: 0,
|
|
9
9
|
left: 0
|
|
10
|
-
}),
|
|
11
|
-
|
|
10
|
+
}), s = w(null), n = w(null), a = w(null), h = w(null), v = w(!1), T = f !== void 0, M = T ? 150 : 0, B = !!y && !E, $ = g && B && D === 0, N = g && B || D > 0, K = F((e) => {
|
|
11
|
+
G((t) => Math.max(0, t + (e ? 1 : -1)));
|
|
12
12
|
}, []);
|
|
13
13
|
C(() => {
|
|
14
|
-
if (!(!
|
|
15
|
-
return
|
|
16
|
-
}, [N,
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
19
|
-
const
|
|
20
|
-
let
|
|
21
|
-
if (
|
|
14
|
+
if (!(!m || !N))
|
|
15
|
+
return m(!0), () => m(!1);
|
|
16
|
+
}, [N, m]);
|
|
17
|
+
const R = F(() => {
|
|
18
|
+
if (!a.current || !h.current) return;
|
|
19
|
+
const e = a.current.firstElementChild?.getBoundingClientRect();
|
|
20
|
+
let t = e && e.width > 0 ? e : a.current.getBoundingClientRect();
|
|
21
|
+
if (t.width === 0 && t.height === 0) {
|
|
22
22
|
const _ = document.createRange();
|
|
23
|
-
_.selectNodeContents(
|
|
24
|
-
const
|
|
25
|
-
(
|
|
23
|
+
_.selectNodeContents(a.current);
|
|
24
|
+
const L = _.getBoundingClientRect();
|
|
25
|
+
(L.width > 0 || L.height > 0) && (t = L);
|
|
26
26
|
}
|
|
27
|
-
const r =
|
|
27
|
+
const r = h.current.getBoundingClientRect(), b = 8;
|
|
28
28
|
let o = 0, i = 0;
|
|
29
|
-
switch (
|
|
29
|
+
switch (c) {
|
|
30
30
|
case "top":
|
|
31
|
-
o =
|
|
31
|
+
o = t.top - r.height - b, i = t.left + t.width / 2 - r.width / 2;
|
|
32
32
|
break;
|
|
33
33
|
case "bottom":
|
|
34
|
-
o =
|
|
34
|
+
o = t.bottom + b, i = t.left + t.width / 2 - r.width / 2;
|
|
35
35
|
break;
|
|
36
36
|
case "left":
|
|
37
|
-
o =
|
|
37
|
+
o = t.top + t.height / 2 - r.height / 2, i = t.left - r.width - b;
|
|
38
38
|
break;
|
|
39
39
|
case "right":
|
|
40
|
-
o =
|
|
40
|
+
o = t.top + t.height / 2 - r.height / 2, i = t.right + b;
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
i <
|
|
42
|
+
const l = 8;
|
|
43
|
+
i < l && (i = l), i + r.width > window.innerWidth - l && (i = window.innerWidth - r.width - l), o < l && (o = l), o + r.height > window.innerHeight - l && (o = window.innerHeight - r.height - l);
|
|
44
|
+
const k = 12, I = c === "top" || c === "bottom", X = I ? t.left + t.width / 2 - i : t.top + t.height / 2 - o, Y = I ? r.width : r.height, Z = Math.min(Math.max(X, k), Y - k);
|
|
45
|
+
J({
|
|
44
46
|
top: o,
|
|
45
|
-
left: i
|
|
47
|
+
left: i,
|
|
48
|
+
arrowOffset: Z
|
|
46
49
|
});
|
|
47
|
-
}, [
|
|
48
|
-
E ||
|
|
50
|
+
}, [c]), S = () => {
|
|
51
|
+
E || v.current || (n.current && (clearTimeout(n.current), n.current = null), s.current = setTimeout(() => {
|
|
49
52
|
u(!0);
|
|
50
53
|
}, z));
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
},
|
|
54
|
-
|
|
54
|
+
}, O = () => {
|
|
55
|
+
v.current || (s.current && clearTimeout(s.current), M > 0 ? n.current = setTimeout(() => u(!1), M) : u(!1));
|
|
56
|
+
}, Q = (e) => {
|
|
57
|
+
e.pointerType !== "touch" && e.pointerType !== "pen" || E || (v.current = !0, s.current && (clearTimeout(s.current), s.current = null), e.stopPropagation(), u((t) => !t));
|
|
55
58
|
};
|
|
56
59
|
C(() => {
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
+
if (!$) return;
|
|
61
|
+
const e = (t) => {
|
|
62
|
+
t.target instanceof Node && h.current?.contains(t.target) || u(!1);
|
|
60
63
|
};
|
|
61
|
-
return
|
|
62
|
-
window.removeEventListener("scroll",
|
|
64
|
+
return R(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", R), () => {
|
|
65
|
+
window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", R);
|
|
63
66
|
};
|
|
64
|
-
}, [
|
|
67
|
+
}, [$, R]), C(() => {
|
|
65
68
|
if (!g) return;
|
|
66
|
-
const
|
|
67
|
-
|
|
69
|
+
const e = (t) => {
|
|
70
|
+
a.current?.contains(t.target) || h.current?.contains(t.target) || u(!1);
|
|
68
71
|
};
|
|
69
|
-
return document.addEventListener("pointerdown",
|
|
70
|
-
document.removeEventListener("pointerdown",
|
|
72
|
+
return document.addEventListener("pointerdown", e), () => {
|
|
73
|
+
document.removeEventListener("pointerdown", e), v.current = !1;
|
|
71
74
|
};
|
|
72
75
|
}, [g]), C(() => () => {
|
|
73
|
-
|
|
76
|
+
s.current && clearTimeout(s.current), n.current && clearTimeout(n.current);
|
|
74
77
|
}, []);
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
|
|
78
|
+
const U = () => {
|
|
79
|
+
T && n.current && (clearTimeout(n.current), n.current = null);
|
|
80
|
+
}, W = () => {
|
|
81
|
+
T && (n.current = setTimeout(() => u(!1), M));
|
|
79
82
|
};
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
ref:
|
|
83
|
+
return /* @__PURE__ */ V(et, { children: [/* @__PURE__ */ x("span", {
|
|
84
|
+
ref: a,
|
|
82
85
|
className: "tooltip-trigger",
|
|
83
86
|
onMouseEnter: S,
|
|
84
|
-
onMouseLeave:
|
|
87
|
+
onMouseLeave: O,
|
|
85
88
|
onFocus: S,
|
|
86
|
-
onBlur:
|
|
87
|
-
onPointerDown:
|
|
88
|
-
children: /* @__PURE__ */
|
|
89
|
-
value:
|
|
90
|
-
children:
|
|
89
|
+
onBlur: O,
|
|
90
|
+
onPointerDown: Q,
|
|
91
|
+
children: /* @__PURE__ */ x(j.Provider, {
|
|
92
|
+
value: K,
|
|
93
|
+
children: q
|
|
91
94
|
})
|
|
92
|
-
}),
|
|
93
|
-
ref:
|
|
94
|
-
className: `tooltip tooltip--${
|
|
95
|
+
}), $ && rt(/* @__PURE__ */ V("div", {
|
|
96
|
+
ref: h,
|
|
97
|
+
className: `tooltip tooltip--${c} ${T ? "tooltip--scrollable" : ""} ${A}`,
|
|
95
98
|
style: {
|
|
96
|
-
top: `${
|
|
97
|
-
left: `${
|
|
99
|
+
top: `${d.top}px`,
|
|
100
|
+
left: `${d.left}px`,
|
|
98
101
|
...p !== void 0 && { maxWidth: typeof p == "number" ? `${p}px` : p },
|
|
99
|
-
...
|
|
102
|
+
...f !== void 0 && { maxHeight: typeof f == "number" ? `${f}px` : f }
|
|
100
103
|
},
|
|
101
|
-
onMouseEnter:
|
|
102
|
-
onMouseLeave:
|
|
103
|
-
children: [y, /* @__PURE__ */
|
|
104
|
+
onMouseEnter: U,
|
|
105
|
+
onMouseLeave: W,
|
|
106
|
+
children: [y, /* @__PURE__ */ x("div", {
|
|
107
|
+
className: `tooltip__arrow tooltip__arrow--${c}`,
|
|
108
|
+
style: d.arrowOffset === void 0 ? void 0 : c === "top" || c === "bottom" ? { left: `${d.arrowOffset}px` } : { top: `${d.arrowOffset}px` }
|
|
109
|
+
})]
|
|
104
110
|
}), document.body)] });
|
|
105
111
|
};
|
|
106
112
|
export {
|
|
107
|
-
|
|
113
|
+
lt as Tooltip
|
|
108
114
|
};
|
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.28.
|
|
3
|
+
"version": "3.28.2",
|
|
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",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"brace-expansion@1": "1.1.21",
|
|
133
133
|
"brace-expansion@5": "5.0.12",
|
|
134
134
|
"esbuild": "0.28.2",
|
|
135
|
-
"fast-uri@3": "3.1.
|
|
135
|
+
"fast-uri@3": "3.1.9",
|
|
136
136
|
"immutable": "5.1.9",
|
|
137
137
|
"js-yaml": "4.3.2",
|
|
138
138
|
"minimatch@10": "10.2.6",
|