@cfx-dev/ui-components 4.2.17 → 4.2.18

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