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