@cfx-dev/ui-components 4.2.12 → 4.2.13
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/assets/css/Accordion.css +1 -1
- package/dist/assets/css/Text.css +1 -1
- package/dist/assets/general/global.css +1 -1
- package/dist/components/Accordion/Accordion.d.ts +5 -11
- package/dist/components/Accordion/Accordion.js +113 -86
- package/dist/components/Accordion/AccordionShowcase.js +56 -26
- package/dist/components/DropdownSelect/DropdownSelect.js +1040 -802
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Slider/Slider.js +374 -294
- package/dist/components/Text/Text.js +63 -59
- package/dist/components/Text/Text.types.d.ts +2 -0
- package/dist/index-CjTSD6zB.js +161 -0
- package/dist/{index-Bz27DCHt.js → index-DBus3GoO.js} +2 -2
- package/dist/styles-scss/tokens.scss +3 -1
- package/dist/utils/math.d.ts +1 -0
- package/dist/utils/math.js +10 -6
- package/package.json +2 -2
- package/dist/index-AweK2ufS.js +0 -171
|
@@ -1,82 +1,86 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { ui as t, TextSizeEnum as
|
|
4
|
-
import { clsx as
|
|
5
|
-
import { getColor as
|
|
6
|
-
const
|
|
7
|
-
root:
|
|
8
|
-
centered:
|
|
9
|
-
underlined:
|
|
10
|
-
truncated:
|
|
11
|
-
typographic:
|
|
12
|
-
block:
|
|
13
|
-
},
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import f from "react";
|
|
3
|
+
import { ui as t, TextSizeEnum as u } from "../ui.js";
|
|
4
|
+
import { clsx as w } from "../../utils/clsx.js";
|
|
5
|
+
import { getColor as A } from "../../utils/color.js";
|
|
6
|
+
const E = "cfxui__Text__root__2fe11", O = "cfxui__Text__centered__4d7bd", F = "cfxui__Text__underlined__5860e", H = "cfxui__Text__truncated__417f4", N = "cfxui__Text__typographic__d8155", $ = "cfxui__Text__block__cb1b6", r = {
|
|
7
|
+
root: E,
|
|
8
|
+
centered: O,
|
|
9
|
+
underlined: F,
|
|
10
|
+
truncated: H,
|
|
11
|
+
typographic: N,
|
|
12
|
+
block: $
|
|
13
|
+
}, B = (e) => e in u ? t.fontSize(e) : typeof e == "number" ? t.q(e) : e, P = (e) => e in u ? t.lineHeight(e) : typeof e == "number" ? t.q(e) : e, q = {
|
|
14
14
|
0: 0,
|
|
15
15
|
25: "var(--text-opacity-25)",
|
|
16
16
|
50: "var(--text-opacity-50)",
|
|
17
17
|
75: "var(--text-opacity-75)",
|
|
18
18
|
100: 1
|
|
19
|
-
},
|
|
19
|
+
}, D = {
|
|
20
20
|
h1: "h1",
|
|
21
21
|
h2: "h2",
|
|
22
22
|
h3: "h3",
|
|
23
23
|
h4: "h4",
|
|
24
24
|
h5: "h5",
|
|
25
25
|
h6: "h6"
|
|
26
|
-
},
|
|
27
|
-
const
|
|
28
|
-
return typeof
|
|
29
|
-
},
|
|
26
|
+
}, I = (e, o = 1) => {
|
|
27
|
+
const n = typeof e == "string" && q[e];
|
|
28
|
+
return typeof n == "string" || typeof n == "number" ? n : o;
|
|
29
|
+
}, L = "primary", M = f.forwardRef(function(o, n) {
|
|
30
30
|
const {
|
|
31
|
-
family:
|
|
31
|
+
family: c,
|
|
32
32
|
size: i = "normal",
|
|
33
|
-
weight:
|
|
34
|
-
letterSpacing:
|
|
35
|
-
as:
|
|
36
|
-
centered:
|
|
37
|
-
truncated:
|
|
38
|
-
typographic:
|
|
39
|
-
uppercase:
|
|
40
|
-
userSelectable:
|
|
41
|
-
underlined:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
weight: _ = "normal",
|
|
34
|
+
letterSpacing: p = "normal",
|
|
35
|
+
as: s = "span",
|
|
36
|
+
centered: h = !1,
|
|
37
|
+
truncated: m = !1,
|
|
38
|
+
typographic: d = !1,
|
|
39
|
+
uppercase: y = !1,
|
|
40
|
+
userSelectable: g = !1,
|
|
41
|
+
underlined: x = !1,
|
|
42
|
+
strikethrough: T = !1,
|
|
43
|
+
children: b,
|
|
44
|
+
className: R,
|
|
45
|
+
style: S
|
|
46
|
+
} = o, k = s === "div", C = w(
|
|
45
47
|
r.root,
|
|
46
|
-
|
|
48
|
+
R,
|
|
47
49
|
t.getResponsiveClassnames("font-size", i),
|
|
48
50
|
t.getResponsiveClassnames("line-height", i),
|
|
49
51
|
{
|
|
50
|
-
[r.block]:
|
|
51
|
-
[r.centered]:
|
|
52
|
-
[r.truncated]:
|
|
53
|
-
[r.underlined]:
|
|
54
|
-
[r.
|
|
55
|
-
[
|
|
52
|
+
[r.block]: k,
|
|
53
|
+
[r.centered]: h,
|
|
54
|
+
[r.truncated]: m,
|
|
55
|
+
[r.underlined]: x,
|
|
56
|
+
[r.strikethrough]: T,
|
|
57
|
+
[r.typographic]: d,
|
|
58
|
+
[t.cls.userSelectableText]: g
|
|
56
59
|
}
|
|
57
|
-
),
|
|
58
|
-
...
|
|
59
|
-
color:
|
|
60
|
-
opacity:
|
|
61
|
-
}),
|
|
62
|
-
color:
|
|
63
|
-
fontFamily: `var(--font-family-${
|
|
60
|
+
), v = A({
|
|
61
|
+
...o,
|
|
62
|
+
color: o.color || L,
|
|
63
|
+
opacity: I(o.opacity)
|
|
64
|
+
}), z = typeof c == "string" ? c : D[s] || "primary", a = {
|
|
65
|
+
color: v,
|
|
66
|
+
fontFamily: `var(--font-family-${z})`,
|
|
64
67
|
lineHeight: `var(--line-height-${i})`,
|
|
65
|
-
letterSpacing: `var(--letter-spacing-${
|
|
66
|
-
fontWeight: `var(--font-weight-${
|
|
67
|
-
...t.getResponsiveStyles("font-size", i,
|
|
68
|
-
...t.getResponsiveStyles("line-height", i,
|
|
68
|
+
letterSpacing: `var(--letter-spacing-${p})`,
|
|
69
|
+
fontWeight: `var(--font-weight-${_})`,
|
|
70
|
+
...t.getResponsiveStyles("font-size", i, B),
|
|
71
|
+
...t.getResponsiveStyles("line-height", i, P),
|
|
72
|
+
...S
|
|
69
73
|
};
|
|
70
|
-
return
|
|
71
|
-
}),
|
|
72
|
-
return /* @__PURE__ */
|
|
74
|
+
return y && (a.textTransform = "uppercase"), /* @__PURE__ */ l(s, { ref: n, dir: "auto", className: C, style: a, children: b });
|
|
75
|
+
}), Y = f.forwardRef(function(o, n) {
|
|
76
|
+
return /* @__PURE__ */ l(M, { ref: n, ...o, as: "div" });
|
|
73
77
|
});
|
|
74
78
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
L as DEFAULT_TEXT_COLOR,
|
|
80
|
+
q as TEXT_OPACITY_MAP,
|
|
81
|
+
M as Text,
|
|
82
|
+
Y as TextBlock,
|
|
83
|
+
I as getTextOpacity,
|
|
84
|
+
P as lineHeightResponsiveValueFormatter,
|
|
85
|
+
B as textSizeResponsiveValueFormatter
|
|
82
86
|
};
|
|
@@ -21,12 +21,14 @@ interface TextPropsBase {
|
|
|
21
21
|
userSelectable?: boolean;
|
|
22
22
|
uppercase?: boolean;
|
|
23
23
|
underlined?: boolean;
|
|
24
|
+
strikethrough?: boolean;
|
|
24
25
|
size?: ResponsiveValueType<ResponsiveTextSize>;
|
|
25
26
|
weight?: TextWeight;
|
|
26
27
|
letterSpacing?: TextLetterSpacing;
|
|
27
28
|
family?: 'primary' | 'secondary';
|
|
28
29
|
children?: React.ReactNode;
|
|
29
30
|
className?: string;
|
|
31
|
+
style?: React.CSSProperties;
|
|
30
32
|
}
|
|
31
33
|
export interface TextColorProps extends GetColorProps {
|
|
32
34
|
opacity?: TextOpacity;
|
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
};
|
|
@@ -135,7 +135,9 @@
|
|
|
135
135
|
|
|
136
136
|
@mixin accordion-tokens() {
|
|
137
137
|
@include ui.define-color-token('accordion-border-color', ui.color('secondary', $alpha: .1));
|
|
138
|
-
@include ui.define-color-token('accordion-
|
|
138
|
+
@include ui.define-color-token('accordion-border-hover-color', ui.color('primary'));
|
|
139
|
+
@include ui.def('accordion-border-size', 1px);
|
|
140
|
+
@include ui.def('accordion-border-hover-size', ui.q(.25));
|
|
139
141
|
}
|
|
140
142
|
|
|
141
143
|
@mixin select-tokens() {
|
package/dist/utils/math.d.ts
CHANGED
package/dist/utils/math.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
1
|
+
function a(t) {
|
|
2
|
+
return t < 0 ? 0 : t > 1 ? 1 : t;
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return Math.min(
|
|
4
|
+
function i(t, n, r) {
|
|
5
|
+
return Math.min(r, Math.max(n, t));
|
|
6
|
+
}
|
|
7
|
+
function m(t, n, r) {
|
|
8
|
+
return Math.min(r, Math.max(n, t));
|
|
6
9
|
}
|
|
7
10
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
i as clamp,
|
|
12
|
+
a as clamp01,
|
|
13
|
+
m as minmax
|
|
10
14
|
};
|
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.
|
|
4
|
+
"version": "4.2.13",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/main.js",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@storybook/test": "^8.1.5",
|
|
53
53
|
"@types/node": "^20.12.13",
|
|
54
54
|
"@types/react": "^18.3.12",
|
|
55
|
-
"@types/react-dom": "^18.3.
|
|
55
|
+
"@types/react-dom": "^18.3.1",
|
|
56
56
|
"@types/react-window": "^1.8.8",
|
|
57
57
|
"@vitejs/plugin-react": "^4.2.1",
|
|
58
58
|
"eslint": "^8.57.0",
|
package/dist/index-AweK2ufS.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
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
|
-
};
|