@cfx-dev/ui-components 4.2.9 → 4.2.11

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,161 +0,0 @@
1
- import * as s from "react";
2
- import y from "react";
3
- import { jsx as h, Fragment as O } from "react/jsx-runtime";
4
- function w(e, t = []) {
5
- let n = [];
6
- function r(c, l) {
7
- const i = s.createContext(l), a = n.length;
8
- n = [...n, l];
9
- const S = (R) => {
10
- var d;
11
- const { scope: C, children: f, ...u } = R, p = ((d = C == null ? void 0 : C[e]) == null ? void 0 : d[a]) || i, m = s.useMemo(() => u, Object.values(u));
12
- return /* @__PURE__ */ h(p.Provider, { value: m, children: f });
13
- };
14
- S.displayName = c + "Provider";
15
- function v(R, C) {
16
- var p;
17
- const f = ((p = C == null ? void 0 : C[e]) == null ? void 0 : p[a]) || i, u = s.useContext(f);
18
- if (u) return u;
19
- if (l !== void 0) return l;
20
- throw new Error(`\`${R}\` must be used within \`${c}\``);
21
- }
22
- return [S, v];
23
- }
24
- const o = () => {
25
- const c = n.map((l) => s.createContext(l));
26
- return function(i) {
27
- const a = (i == null ? void 0 : i[e]) || c;
28
- return s.useMemo(
29
- () => ({ [`__scope${e}`]: { ...i, [e]: a } }),
30
- [i, a]
31
- );
32
- };
33
- };
34
- return o.scopeName = e, [r, b(o, ...t)];
35
- }
36
- function b(...e) {
37
- const t = e[0];
38
- if (e.length === 1) return t;
39
- const n = () => {
40
- const r = e.map((o) => ({
41
- useScope: o(),
42
- scopeName: o.scopeName
43
- }));
44
- return function(c) {
45
- const l = r.reduce((i, { useScope: a, scopeName: S }) => {
46
- const R = a(c)[`__scope${S}`];
47
- return { ...i, ...R };
48
- }, {});
49
- return s.useMemo(() => ({ [`__scope${t.scopeName}`]: l }), [l]);
50
- };
51
- };
52
- return n.scopeName = t.scopeName, n;
53
- }
54
- function _(e, t) {
55
- if (typeof e == "function")
56
- return e(t);
57
- e != null && (e.current = t);
58
- }
59
- function A(...e) {
60
- return (t) => {
61
- let n = !1;
62
- const r = e.map((o) => {
63
- const c = _(o, t);
64
- return !n && typeof c == "function" && (n = !0), c;
65
- });
66
- if (n)
67
- return () => {
68
- for (let o = 0; o < r.length; o++) {
69
- const c = r[o];
70
- typeof c == "function" ? c() : _(e[o], null);
71
- }
72
- };
73
- };
74
- }
75
- function N(...e) {
76
- return s.useCallback(A(...e), e);
77
- }
78
- var g = s.forwardRef((e, t) => {
79
- const { children: n, ...r } = e, o = s.Children.toArray(n), c = o.find(V);
80
- if (c) {
81
- const l = c.props.children, i = o.map((a) => a === c ? s.Children.count(l) > 1 ? s.Children.only(null) : s.isValidElement(l) ? l.props.children : null : a);
82
- return /* @__PURE__ */ h(M, { ...r, ref: t, children: s.isValidElement(l) ? s.cloneElement(l, void 0, i) : null });
83
- }
84
- return /* @__PURE__ */ h(M, { ...r, ref: t, children: n });
85
- });
86
- g.displayName = "Slot";
87
- var M = s.forwardRef((e, t) => {
88
- const { children: n, ...r } = e;
89
- if (s.isValidElement(n)) {
90
- const o = j(n);
91
- return s.cloneElement(n, {
92
- ...$(r, n.props),
93
- // @ts-ignore
94
- ref: t ? A(t, o) : o
95
- });
96
- }
97
- return s.Children.count(n) > 1 ? s.Children.only(null) : null;
98
- });
99
- M.displayName = "SlotClone";
100
- var T = ({ children: e }) => /* @__PURE__ */ h(O, { children: e });
101
- function V(e) {
102
- return s.isValidElement(e) && e.type === T;
103
- }
104
- function $(e, t) {
105
- const n = { ...t };
106
- for (const r in t) {
107
- const o = e[r], c = t[r];
108
- /^on[A-Z]/.test(r) ? o && c ? n[r] = (...i) => {
109
- c(...i), o(...i);
110
- } : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...c } : r === "className" && (n[r] = [o, c].filter(Boolean).join(" "));
111
- }
112
- return { ...e, ...n };
113
- }
114
- function j(e) {
115
- var r, o;
116
- let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
117
- return n ? e.ref : (t = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
118
- }
119
- function L(e) {
120
- const t = e + "CollectionProvider", [n, r] = w(t), [o, c] = n(
121
- t,
122
- { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
123
- ), l = (f) => {
124
- const { scope: u, children: p } = f, m = y.useRef(null), d = y.useRef(/* @__PURE__ */ new Map()).current;
125
- return /* @__PURE__ */ h(o, { scope: u, itemMap: d, collectionRef: m, children: p });
126
- };
127
- l.displayName = t;
128
- const i = e + "CollectionSlot", a = y.forwardRef(
129
- (f, u) => {
130
- const { scope: p, children: m } = f, d = c(i, p), x = N(u, d.collectionRef);
131
- return /* @__PURE__ */ h(g, { ref: x, children: m });
132
- }
133
- );
134
- a.displayName = i;
135
- const S = e + "CollectionItemSlot", v = "data-radix-collection-item", R = y.forwardRef(
136
- (f, u) => {
137
- const { scope: p, children: m, ...d } = f, x = y.useRef(null), P = N(u, x), E = c(S, p);
138
- return y.useEffect(() => (E.itemMap.set(x, { ref: x, ...d }), () => void E.itemMap.delete(x))), /* @__PURE__ */ h(g, { [v]: "", ref: P, children: m });
139
- }
140
- );
141
- R.displayName = S;
142
- function C(f) {
143
- const u = c(e + "CollectionConsumer", f);
144
- return y.useCallback(() => {
145
- const m = u.collectionRef.current;
146
- if (!m) return [];
147
- const d = Array.from(m.querySelectorAll(`[${v}]`));
148
- return Array.from(u.itemMap.values()).sort(
149
- (E, I) => d.indexOf(E.ref.current) - d.indexOf(I.ref.current)
150
- );
151
- }, [u.collectionRef, u.itemMap]);
152
- }
153
- return [
154
- { Provider: l, Slot: a, ItemSlot: R },
155
- C,
156
- r
157
- ];
158
- }
159
- export {
160
- L as c
161
- };