@cfx-dev/ui-components 5.0.23 → 5.0.24
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/dist/components/Title/Title.js +81 -77
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { clsx as
|
|
1
|
+
import { jsx as b, jsxs as O, Fragment as R } from "react/jsx-runtime";
|
|
2
|
+
import a from "react";
|
|
3
|
+
import { clsx as L } from "../../utils/clsx.js";
|
|
4
4
|
import "../../utils/hooks/useGlobalKeyboardEvent.js";
|
|
5
5
|
import "../../utils/hooks/useKeyboardClose.js";
|
|
6
|
-
import { useOutlet as
|
|
7
|
-
import { mergeRefs as
|
|
8
|
-
const
|
|
9
|
-
wrapper:
|
|
10
|
-
appearance:
|
|
11
|
-
animated:
|
|
6
|
+
import { useOutlet as S } from "../../utils/hooks/useOutlet.js";
|
|
7
|
+
import { mergeRefs as k } from "../../utils/mergeRefs.js";
|
|
8
|
+
const N = "cfxui__Title__wrapper__ec63b", $ = "cfxui__Title__appearance__9b5a4", A = "cfxui__Title__animated__151a8", F = "cfxui__Title__root__0f286", I = "cfxui__Title__shortcut__85352", x = {
|
|
9
|
+
wrapper: N,
|
|
10
|
+
appearance: $,
|
|
11
|
+
animated: A,
|
|
12
12
|
"fixed-on-top": "cfxui__Title__fixed-on-top__100f6",
|
|
13
13
|
"fixed-on-top-left": "cfxui__Title__fixed-on-top-left__ec383",
|
|
14
14
|
"fixed-on-bottom": "cfxui__Title__fixed-on-bottom__a00c2",
|
|
@@ -16,112 +16,116 @@ const $ = "cfxui__Title__wrapper__ec63b", A = "cfxui__Title__appearance__9b5a4",
|
|
|
16
16
|
"fixed-on-bottom-right": "cfxui__Title__fixed-on-bottom-right__58fb5",
|
|
17
17
|
"fixed-on-left": "cfxui__Title__fixed-on-left__01d9d",
|
|
18
18
|
"fixed-on-right": "cfxui__Title__fixed-on-right__2c799",
|
|
19
|
-
root:
|
|
20
|
-
shortcut:
|
|
19
|
+
root: F,
|
|
20
|
+
shortcut: I
|
|
21
21
|
}, _ = 10, j = "title-outlet";
|
|
22
|
-
function D(
|
|
23
|
-
|
|
22
|
+
function D(n, c) {
|
|
23
|
+
var o;
|
|
24
|
+
return typeof n.computedStyleMap == "function" ? ((o = n.computedStyleMap().get(c)) == null ? void 0 : o.toString()) || "" : window.getComputedStyle(n).getPropertyValue(c) || "";
|
|
25
|
+
}
|
|
26
|
+
function G(n, c, [o, r]) {
|
|
27
|
+
const e = n ? r : r - 20, s = n ? o : o + 16;
|
|
24
28
|
return {
|
|
25
|
-
top: `${
|
|
26
|
-
left: `${
|
|
27
|
-
maxWidth: `calc(100vw - ${
|
|
28
|
-
animationDelay: `${
|
|
29
|
+
top: `${e}px`,
|
|
30
|
+
left: `${s}px`,
|
|
31
|
+
maxWidth: `calc(100vw - ${s}px - 10px)`,
|
|
32
|
+
animationDelay: `${c}ms`
|
|
29
33
|
};
|
|
30
34
|
}
|
|
31
|
-
function
|
|
32
|
-
const {
|
|
33
|
-
x:
|
|
34
|
-
y:
|
|
35
|
-
width:
|
|
36
|
-
height:
|
|
37
|
-
} =
|
|
38
|
-
let
|
|
39
|
-
switch (
|
|
35
|
+
function X(n, c) {
|
|
36
|
+
const o = D(n, "display") === "contents" ? n.children[0] : n, {
|
|
37
|
+
x: r,
|
|
38
|
+
y: e,
|
|
39
|
+
width: s,
|
|
40
|
+
height: u
|
|
41
|
+
} = o.getBoundingClientRect();
|
|
42
|
+
let t = 0, i = 0;
|
|
43
|
+
switch (c) {
|
|
40
44
|
case "top":
|
|
41
|
-
|
|
45
|
+
t = r + s / 2, i = e - _;
|
|
42
46
|
break;
|
|
43
47
|
case "top-left":
|
|
44
|
-
|
|
48
|
+
t = r, i = e - _;
|
|
45
49
|
break;
|
|
46
50
|
case "bottom":
|
|
47
|
-
|
|
51
|
+
t = r + s / 2, i = e + u + _;
|
|
48
52
|
break;
|
|
49
53
|
case "bottom-left":
|
|
50
|
-
|
|
54
|
+
t = r, i = e + u + _;
|
|
51
55
|
break;
|
|
52
56
|
case "bottom-right":
|
|
53
|
-
|
|
57
|
+
t = r + s, i = e + u + _;
|
|
54
58
|
break;
|
|
55
59
|
case "left":
|
|
56
|
-
|
|
60
|
+
t = r - _, i = e + u / 2;
|
|
57
61
|
break;
|
|
58
62
|
case "right":
|
|
59
|
-
|
|
63
|
+
t = r + s + _, i = e + u / 2;
|
|
60
64
|
break;
|
|
61
65
|
}
|
|
62
|
-
return [
|
|
66
|
+
return [t, i];
|
|
63
67
|
}
|
|
64
|
-
function
|
|
68
|
+
function z(n) {
|
|
65
69
|
const {
|
|
66
|
-
title:
|
|
67
|
-
children:
|
|
68
|
-
animated:
|
|
69
|
-
fixedOn:
|
|
70
|
-
delay:
|
|
71
|
-
className:
|
|
70
|
+
title: c,
|
|
71
|
+
children: o,
|
|
72
|
+
animated: r = !0,
|
|
73
|
+
fixedOn: e = "bottom",
|
|
74
|
+
delay: s = 0,
|
|
75
|
+
className: u = "",
|
|
72
76
|
suppressMouseActivation: t = !1,
|
|
73
|
-
active:
|
|
77
|
+
active: i = !1,
|
|
74
78
|
rootClassName: v = ""
|
|
75
|
-
} =
|
|
76
|
-
m.current =
|
|
77
|
-
const T =
|
|
78
|
-
|
|
79
|
-
t &&
|
|
80
|
-
}, [
|
|
81
|
-
if (!
|
|
79
|
+
} = n, m = a.useRef(e), p = a.useRef([0, 0]);
|
|
80
|
+
m.current = e;
|
|
81
|
+
const T = S(j), l = a.useRef(null), [g, h] = a.useState(!1);
|
|
82
|
+
a.useEffect(() => {
|
|
83
|
+
t && h(i);
|
|
84
|
+
}, [i, t]), a.useEffect(() => {
|
|
85
|
+
if (!l.current)
|
|
82
86
|
return;
|
|
83
|
-
const
|
|
84
|
-
m.current &&
|
|
85
|
-
},
|
|
86
|
-
t ||
|
|
87
|
-
}, w = (
|
|
88
|
-
m.current || (
|
|
87
|
+
const f = l.current, E = (d) => {
|
|
88
|
+
m.current && l.current ? p.current = X(l.current, m.current) : p.current = [d.clientX, d.clientY], t || h(!0);
|
|
89
|
+
}, y = () => {
|
|
90
|
+
t || h(!1);
|
|
91
|
+
}, w = (d) => {
|
|
92
|
+
m.current || (p.current = [d.clientX, d.clientY]);
|
|
89
93
|
};
|
|
90
|
-
return
|
|
91
|
-
|
|
94
|
+
return f.addEventListener("mouseenter", E), f.addEventListener("mouseleave", y), f.addEventListener("mousemove", w), () => {
|
|
95
|
+
f && (f.removeEventListener("mouseenter", E), f.removeEventListener("mouseleave", y), f.removeEventListener("mousemove", w));
|
|
92
96
|
};
|
|
93
97
|
}, [t]);
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
98
|
+
const M = a.useMemo(() => {
|
|
99
|
+
if (!g || !c)
|
|
96
100
|
return null;
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
const f = L(
|
|
102
|
+
x.wrapper,
|
|
103
|
+
x[`fixed-on-${e}`],
|
|
100
104
|
{
|
|
101
|
-
[
|
|
105
|
+
[x.animated]: r
|
|
102
106
|
},
|
|
103
|
-
|
|
107
|
+
u
|
|
104
108
|
);
|
|
105
|
-
return /* @__PURE__ */
|
|
109
|
+
return /* @__PURE__ */ b(T, { children: /* @__PURE__ */ b(
|
|
106
110
|
"div",
|
|
107
111
|
{
|
|
108
|
-
className:
|
|
109
|
-
style:
|
|
110
|
-
children: /* @__PURE__ */
|
|
112
|
+
className: f,
|
|
113
|
+
style: G(!!e, s, p.current),
|
|
114
|
+
children: /* @__PURE__ */ b("div", { className: L(x.root, v), children: c })
|
|
111
115
|
}
|
|
112
116
|
) });
|
|
113
|
-
}, [
|
|
114
|
-
() => typeof
|
|
115
|
-
[
|
|
117
|
+
}, [g, c, e, r, T, s, u, v]), C = a.useMemo(
|
|
118
|
+
() => typeof o == "function" ? o(l) : a.cloneElement(o, { ref: k(l, o.props.ref) }),
|
|
119
|
+
[o, l]
|
|
116
120
|
);
|
|
117
|
-
return /* @__PURE__ */
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
return /* @__PURE__ */ O(R, { children: [
|
|
122
|
+
C,
|
|
123
|
+
M
|
|
120
124
|
] });
|
|
121
125
|
}
|
|
122
126
|
export {
|
|
123
127
|
j as TITLE_OUTLET_ID,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
z as Title,
|
|
129
|
+
X as titleGetCoords,
|
|
130
|
+
G as titleGetCssStyle
|
|
127
131
|
};
|