@cfx-dev/ui-components 3.0.3 → 3.0.5
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/Select-Ds-fm4CN.js +3245 -0
- package/dist/assets/all_css.css +2 -0
- package/dist/assets/css/DropdownSelect.css +1 -0
- package/dist/assets/css/Input.css +1 -1
- package/dist/assets/css/Slider.css +1 -0
- package/dist/components/Checkbox/Checkbox.js +190 -118
- package/dist/components/DropdownSelect/DropdownSelect.d.ts +16 -0
- package/dist/components/DropdownSelect/DropdownSelect.js +2393 -0
- package/dist/components/DropdownSelect/DropdownSelectShowcase.d.ts +5 -0
- package/dist/components/DropdownSelect/DropdownSelectShowcase.js +52 -0
- package/dist/components/DropdownSelect/index.d.ts +1 -0
- package/dist/components/DropdownSelect/index.js +4 -0
- package/dist/components/Icons/cfx-icons/UpvotesRecurring.js +9 -8
- package/dist/components/Input/Input.js +4 -4
- package/dist/components/Select/Select.d.ts +2 -0
- package/dist/components/Select/Select.js +7 -3092
- package/dist/components/Select/SelectShowcase.js +1 -1
- package/dist/components/Select/index.d.ts +1 -1
- package/dist/components/Select/index.js +3 -2
- package/dist/components/Slider/Slider.d.ts +11 -0
- package/dist/components/Slider/Slider.js +606 -0
- package/dist/components/Slider/SliderShowcase.d.ts +5 -0
- package/dist/components/Slider/SliderShowcase.js +63 -0
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/Slider/index.js +4 -0
- package/dist/components/Switch/Switch.js +131 -68
- package/dist/index-BCnz73Lm.js +72 -0
- package/dist/index-BW3WdIgK.js +14 -0
- package/dist/index-BlbvKsmN.js +82 -0
- package/dist/index-CjTSD6zB.js +161 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +69 -65
- package/package.json +3 -1
- package/dist/index-CjWRnNpt.js +0 -210
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import i from "react";
|
|
3
|
+
import { Flex as l } from "../Layout/Flex/Flex.js";
|
|
4
|
+
import { Text as r } from "../Text/Text.js";
|
|
5
|
+
import { Slider as t } from "./Slider.js";
|
|
6
|
+
function m() {
|
|
7
|
+
return /* @__PURE__ */ a(l, { gap: "large", vertical: !0, children: [
|
|
8
|
+
/* @__PURE__ */ a(l, { gap: "normal", vertical: !0, children: [
|
|
9
|
+
/* @__PURE__ */ e(r, { children: "Default Slider" }),
|
|
10
|
+
/* @__PURE__ */ e(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
style: {
|
|
14
|
+
marginTop: "40px",
|
|
15
|
+
marginLeft: "40px"
|
|
16
|
+
},
|
|
17
|
+
children: /* @__PURE__ */ e(
|
|
18
|
+
t,
|
|
19
|
+
{
|
|
20
|
+
defaultValue: [5],
|
|
21
|
+
max: 5e3,
|
|
22
|
+
step: 1,
|
|
23
|
+
ariaLabel: "Volume",
|
|
24
|
+
className: "",
|
|
25
|
+
minLabel: 0,
|
|
26
|
+
maxLabel: 5e3,
|
|
27
|
+
title: "Upvotes"
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ a(l, { gap: "normal", vertical: !0, children: [
|
|
34
|
+
/* @__PURE__ */ e(r, { children: "Custom Slider" }),
|
|
35
|
+
/* @__PURE__ */ e(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
style: {
|
|
39
|
+
marginTop: "40px",
|
|
40
|
+
marginLeft: "40px"
|
|
41
|
+
},
|
|
42
|
+
children: /* @__PURE__ */ e(
|
|
43
|
+
t,
|
|
44
|
+
{
|
|
45
|
+
defaultValue: [10],
|
|
46
|
+
max: 200,
|
|
47
|
+
step: 5,
|
|
48
|
+
ariaLabel: "Custom Slider",
|
|
49
|
+
className: "custom-slider-class",
|
|
50
|
+
minLabel: 0,
|
|
51
|
+
maxLabel: 1e4,
|
|
52
|
+
title: "Upvotes"
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
)
|
|
57
|
+
] })
|
|
58
|
+
] });
|
|
59
|
+
}
|
|
60
|
+
const p = i.memo(m);
|
|
61
|
+
export {
|
|
62
|
+
p as default
|
|
63
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Slider } from './Slider';
|
|
@@ -1,96 +1,159 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { jsx as l, jsxs as $ } from "react/jsx-runtime";
|
|
2
|
+
import * as u from "react";
|
|
3
|
+
import g from "react";
|
|
4
|
+
import { u as B, a as U, b as j } from "../../index-BCnz73Lm.js";
|
|
5
|
+
import { P } from "../../index-BlbvKsmN.js";
|
|
5
6
|
import { clsx as k } from "../../utils/clsx.js";
|
|
6
|
-
|
|
7
|
+
function I(t, o, { checkForDefaultPrevented: e = !0 } = {}) {
|
|
8
|
+
return function(c) {
|
|
9
|
+
if (t == null || t(c), e === !1 || !c.defaultPrevented)
|
|
10
|
+
return o == null ? void 0 : o(c);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function E(t, o) {
|
|
14
|
+
typeof t == "function" ? t(o) : t != null && (t.current = o);
|
|
15
|
+
}
|
|
16
|
+
function O(...t) {
|
|
17
|
+
return (o) => t.forEach((e) => E(e, o));
|
|
18
|
+
}
|
|
19
|
+
function q(...t) {
|
|
20
|
+
return u.useCallback(O(...t), t);
|
|
21
|
+
}
|
|
22
|
+
function z(t, o = []) {
|
|
23
|
+
let e = [];
|
|
24
|
+
function r(h, n) {
|
|
25
|
+
const s = u.createContext(n), i = e.length;
|
|
26
|
+
e = [...e, n];
|
|
27
|
+
function f(a) {
|
|
28
|
+
const { scope: p, children: b, ...d } = a, S = (p == null ? void 0 : p[t][i]) || s, m = u.useMemo(() => d, Object.values(d));
|
|
29
|
+
return /* @__PURE__ */ l(S.Provider, { value: m, children: b });
|
|
30
|
+
}
|
|
31
|
+
function w(a, p) {
|
|
32
|
+
const b = (p == null ? void 0 : p[t][i]) || s, d = u.useContext(b);
|
|
33
|
+
if (d) return d;
|
|
34
|
+
if (n !== void 0) return n;
|
|
35
|
+
throw new Error(`\`${a}\` must be used within \`${h}\``);
|
|
36
|
+
}
|
|
37
|
+
return f.displayName = h + "Provider", [f, w];
|
|
38
|
+
}
|
|
39
|
+
const c = () => {
|
|
40
|
+
const h = e.map((n) => u.createContext(n));
|
|
41
|
+
return function(s) {
|
|
42
|
+
const i = (s == null ? void 0 : s[t]) || h;
|
|
43
|
+
return u.useMemo(
|
|
44
|
+
() => ({ [`__scope${t}`]: { ...s, [t]: i } }),
|
|
45
|
+
[s, i]
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
return c.scopeName = t, [r, A(c, ...o)];
|
|
50
|
+
}
|
|
51
|
+
function A(...t) {
|
|
52
|
+
const o = t[0];
|
|
53
|
+
if (t.length === 1) return o;
|
|
54
|
+
const e = () => {
|
|
55
|
+
const r = t.map((c) => ({
|
|
56
|
+
useScope: c(),
|
|
57
|
+
scopeName: c.scopeName
|
|
58
|
+
}));
|
|
59
|
+
return function(h) {
|
|
60
|
+
const n = r.reduce((s, { useScope: i, scopeName: f }) => {
|
|
61
|
+
const a = i(h)[`__scope${f}`];
|
|
62
|
+
return { ...s, ...a };
|
|
63
|
+
}, {});
|
|
64
|
+
return u.useMemo(() => ({ [`__scope${o.scopeName}`]: n }), [n]);
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
return e.scopeName = o.scopeName, e;
|
|
68
|
+
}
|
|
69
|
+
var x = "Switch", [D, ot] = z(x), [F, L] = D(x), v = u.forwardRef(
|
|
7
70
|
(t, o) => {
|
|
8
71
|
const {
|
|
9
72
|
__scopeSwitch: e,
|
|
10
|
-
name:
|
|
11
|
-
checked:
|
|
12
|
-
defaultChecked:
|
|
13
|
-
required:
|
|
14
|
-
disabled:
|
|
15
|
-
value:
|
|
73
|
+
name: r,
|
|
74
|
+
checked: c,
|
|
75
|
+
defaultChecked: h,
|
|
76
|
+
required: n,
|
|
77
|
+
disabled: s,
|
|
78
|
+
value: i = "on",
|
|
16
79
|
onCheckedChange: f,
|
|
17
|
-
...
|
|
18
|
-
} = t, [
|
|
19
|
-
prop:
|
|
20
|
-
defaultProp:
|
|
80
|
+
...w
|
|
81
|
+
} = t, [a, p] = u.useState(null), b = q(o, (_) => p(_)), d = u.useRef(!1), S = a ? !!a.closest("form") : !0, [m = !1, N] = B({
|
|
82
|
+
prop: c,
|
|
83
|
+
defaultProp: h,
|
|
21
84
|
onChange: f
|
|
22
85
|
});
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
|
|
86
|
+
return /* @__PURE__ */ $(F, { scope: e, checked: m, disabled: s, children: [
|
|
87
|
+
/* @__PURE__ */ l(
|
|
88
|
+
P.button,
|
|
26
89
|
{
|
|
27
90
|
type: "button",
|
|
28
91
|
role: "switch",
|
|
29
|
-
"aria-checked":
|
|
30
|
-
"aria-required":
|
|
31
|
-
"data-state":
|
|
32
|
-
"data-disabled":
|
|
33
|
-
disabled:
|
|
34
|
-
value:
|
|
35
|
-
...
|
|
36
|
-
ref:
|
|
37
|
-
onClick:
|
|
38
|
-
|
|
92
|
+
"aria-checked": m,
|
|
93
|
+
"aria-required": n,
|
|
94
|
+
"data-state": T(m),
|
|
95
|
+
"data-disabled": s ? "" : void 0,
|
|
96
|
+
disabled: s,
|
|
97
|
+
value: i,
|
|
98
|
+
...w,
|
|
99
|
+
ref: b,
|
|
100
|
+
onClick: I(t.onClick, (_) => {
|
|
101
|
+
N((M) => !M), S && (d.current = _.isPropagationStopped(), d.current || _.stopPropagation());
|
|
39
102
|
})
|
|
40
103
|
}
|
|
41
104
|
),
|
|
42
|
-
|
|
43
|
-
|
|
105
|
+
S && /* @__PURE__ */ l(
|
|
106
|
+
W,
|
|
44
107
|
{
|
|
45
|
-
control:
|
|
46
|
-
bubbles: !
|
|
47
|
-
name:
|
|
48
|
-
value:
|
|
49
|
-
checked:
|
|
50
|
-
required:
|
|
51
|
-
disabled:
|
|
108
|
+
control: a,
|
|
109
|
+
bubbles: !d.current,
|
|
110
|
+
name: r,
|
|
111
|
+
value: i,
|
|
112
|
+
checked: m,
|
|
113
|
+
required: n,
|
|
114
|
+
disabled: s,
|
|
52
115
|
style: { transform: "translateX(-100%)" }
|
|
53
116
|
}
|
|
54
117
|
)
|
|
55
118
|
] });
|
|
56
119
|
}
|
|
57
120
|
);
|
|
58
|
-
|
|
59
|
-
var R = "SwitchThumb",
|
|
121
|
+
v.displayName = x;
|
|
122
|
+
var R = "SwitchThumb", y = u.forwardRef(
|
|
60
123
|
(t, o) => {
|
|
61
|
-
const { __scopeSwitch: e, ...
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
|
|
124
|
+
const { __scopeSwitch: e, ...r } = t, c = L(R, e);
|
|
125
|
+
return /* @__PURE__ */ l(
|
|
126
|
+
P.span,
|
|
64
127
|
{
|
|
65
|
-
"data-state":
|
|
66
|
-
"data-disabled":
|
|
67
|
-
...
|
|
128
|
+
"data-state": T(c.checked),
|
|
129
|
+
"data-disabled": c.disabled ? "" : void 0,
|
|
130
|
+
...r,
|
|
68
131
|
ref: o
|
|
69
132
|
}
|
|
70
133
|
);
|
|
71
134
|
}
|
|
72
135
|
);
|
|
73
|
-
|
|
74
|
-
var
|
|
75
|
-
const { control: o, checked: e, bubbles:
|
|
76
|
-
return
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
80
|
-
|
|
136
|
+
y.displayName = R;
|
|
137
|
+
var W = (t) => {
|
|
138
|
+
const { control: o, checked: e, bubbles: r = !0, ...c } = t, h = u.useRef(null), n = U(e), s = j(o);
|
|
139
|
+
return u.useEffect(() => {
|
|
140
|
+
const i = h.current, f = window.HTMLInputElement.prototype, a = Object.getOwnPropertyDescriptor(f, "checked").set;
|
|
141
|
+
if (n !== e && a) {
|
|
142
|
+
const p = new Event("click", { bubbles: r });
|
|
143
|
+
a.call(i, e), i.dispatchEvent(p);
|
|
81
144
|
}
|
|
82
|
-
}, [
|
|
145
|
+
}, [n, e, r]), /* @__PURE__ */ l(
|
|
83
146
|
"input",
|
|
84
147
|
{
|
|
85
148
|
type: "checkbox",
|
|
86
149
|
"aria-hidden": !0,
|
|
87
150
|
defaultChecked: e,
|
|
88
|
-
...
|
|
151
|
+
...c,
|
|
89
152
|
tabIndex: -1,
|
|
90
|
-
ref:
|
|
153
|
+
ref: h,
|
|
91
154
|
style: {
|
|
92
155
|
...t.style,
|
|
93
|
-
...
|
|
156
|
+
...s,
|
|
94
157
|
position: "absolute",
|
|
95
158
|
pointerEvents: "none",
|
|
96
159
|
opacity: 0,
|
|
@@ -99,24 +162,24 @@ var $ = (t) => {
|
|
|
99
162
|
}
|
|
100
163
|
);
|
|
101
164
|
};
|
|
102
|
-
function
|
|
165
|
+
function T(t) {
|
|
103
166
|
return t ? "checked" : "unchecked";
|
|
104
167
|
}
|
|
105
|
-
var
|
|
106
|
-
const
|
|
107
|
-
switchUnset:
|
|
108
|
-
switchRoot:
|
|
109
|
-
switchThumb:
|
|
168
|
+
var X = v, G = y;
|
|
169
|
+
const J = "cfxui__Switch__switchUnset__c8b03", K = "cfxui__Switch__switchRoot__f2911", Q = "cfxui__Switch__switchThumb__9cbf5", C = {
|
|
170
|
+
switchUnset: J,
|
|
171
|
+
switchRoot: K,
|
|
172
|
+
switchThumb: Q
|
|
110
173
|
};
|
|
111
|
-
function
|
|
174
|
+
function V(t) {
|
|
112
175
|
const {
|
|
113
176
|
classNameRoot: o,
|
|
114
177
|
classNameThumb: e,
|
|
115
|
-
...
|
|
178
|
+
...r
|
|
116
179
|
} = t;
|
|
117
|
-
return /* @__PURE__ */
|
|
180
|
+
return /* @__PURE__ */ l(X, { ...r, className: k(C.switchRoot, C.switchUnset, o), children: /* @__PURE__ */ l(G, { className: k(C.switchThumb, e) }) });
|
|
118
181
|
}
|
|
119
|
-
const
|
|
182
|
+
const ct = g.memo(V);
|
|
120
183
|
export {
|
|
121
|
-
|
|
184
|
+
ct as default
|
|
122
185
|
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as s from "react";
|
|
2
|
+
function l(e) {
|
|
3
|
+
const t = s.useRef(e);
|
|
4
|
+
return s.useEffect(() => {
|
|
5
|
+
t.current = e;
|
|
6
|
+
}), s.useMemo(() => (...o) => {
|
|
7
|
+
var r;
|
|
8
|
+
return (r = t.current) == null ? void 0 : r.call(t, ...o);
|
|
9
|
+
}, []);
|
|
10
|
+
}
|
|
11
|
+
function S({
|
|
12
|
+
prop: e,
|
|
13
|
+
defaultProp: t,
|
|
14
|
+
onChange: o = () => {
|
|
15
|
+
}
|
|
16
|
+
}) {
|
|
17
|
+
const [r, n] = b({ defaultProp: t, onChange: o }), u = e !== void 0, f = u ? e : r, c = l(o), a = s.useCallback(
|
|
18
|
+
(i) => {
|
|
19
|
+
if (u) {
|
|
20
|
+
const d = typeof i == "function" ? i(e) : i;
|
|
21
|
+
d !== e && c(d);
|
|
22
|
+
} else
|
|
23
|
+
n(i);
|
|
24
|
+
},
|
|
25
|
+
[u, e, n, c]
|
|
26
|
+
);
|
|
27
|
+
return [f, a];
|
|
28
|
+
}
|
|
29
|
+
function b({
|
|
30
|
+
defaultProp: e,
|
|
31
|
+
onChange: t
|
|
32
|
+
}) {
|
|
33
|
+
const o = s.useState(e), [r] = o, n = s.useRef(r), u = l(t);
|
|
34
|
+
return s.useEffect(() => {
|
|
35
|
+
n.current !== r && (u(r), n.current = r);
|
|
36
|
+
}, [r, n, u]), o;
|
|
37
|
+
}
|
|
38
|
+
function z(e) {
|
|
39
|
+
const t = s.useRef({ value: e, previous: e });
|
|
40
|
+
return s.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]);
|
|
41
|
+
}
|
|
42
|
+
var h = globalThis != null && globalThis.document ? s.useLayoutEffect : () => {
|
|
43
|
+
};
|
|
44
|
+
function y(e) {
|
|
45
|
+
const [t, o] = s.useState(void 0);
|
|
46
|
+
return h(() => {
|
|
47
|
+
if (e) {
|
|
48
|
+
o({ width: e.offsetWidth, height: e.offsetHeight });
|
|
49
|
+
const r = new ResizeObserver((n) => {
|
|
50
|
+
if (!Array.isArray(n) || !n.length)
|
|
51
|
+
return;
|
|
52
|
+
const u = n[0];
|
|
53
|
+
let f, c;
|
|
54
|
+
if ("borderBoxSize" in u) {
|
|
55
|
+
const a = u.borderBoxSize, i = Array.isArray(a) ? a[0] : a;
|
|
56
|
+
f = i.inlineSize, c = i.blockSize;
|
|
57
|
+
} else
|
|
58
|
+
f = e.offsetWidth, c = e.offsetHeight;
|
|
59
|
+
o({ width: f, height: c });
|
|
60
|
+
});
|
|
61
|
+
return r.observe(e, { box: "border-box" }), () => r.unobserve(e);
|
|
62
|
+
} else
|
|
63
|
+
o(void 0);
|
|
64
|
+
}, [e]), t;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
z as a,
|
|
68
|
+
y as b,
|
|
69
|
+
h as c,
|
|
70
|
+
l as d,
|
|
71
|
+
S as u
|
|
72
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as r from "react";
|
|
2
|
+
import "react/jsx-runtime";
|
|
3
|
+
function i(t, [o, e]) {
|
|
4
|
+
return Math.min(e, Math.max(o, t));
|
|
5
|
+
}
|
|
6
|
+
var n = r.createContext(void 0);
|
|
7
|
+
function c(t) {
|
|
8
|
+
const o = r.useContext(n);
|
|
9
|
+
return t || o || "ltr";
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
i as c,
|
|
13
|
+
c as u
|
|
14
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { r as d } from "./index-2hJuj4UN.js";
|
|
3
|
+
import { jsx as c, Fragment as m } from "react/jsx-runtime";
|
|
4
|
+
function h(r, e) {
|
|
5
|
+
typeof r == "function" ? r(e) : r != null && (r.current = e);
|
|
6
|
+
}
|
|
7
|
+
function y(...r) {
|
|
8
|
+
return (e) => r.forEach((n) => h(n, e));
|
|
9
|
+
}
|
|
10
|
+
var u = o.forwardRef((r, e) => {
|
|
11
|
+
const { children: n, ...t } = r, i = o.Children.toArray(n), l = i.find(E);
|
|
12
|
+
if (l) {
|
|
13
|
+
const s = l.props.children, a = i.map((p) => p === l ? o.Children.count(s) > 1 ? o.Children.only(null) : o.isValidElement(s) ? s.props.children : null : p);
|
|
14
|
+
return /* @__PURE__ */ c(f, { ...t, ref: e, children: o.isValidElement(s) ? o.cloneElement(s, void 0, a) : null });
|
|
15
|
+
}
|
|
16
|
+
return /* @__PURE__ */ c(f, { ...t, ref: e, children: n });
|
|
17
|
+
});
|
|
18
|
+
u.displayName = "Slot";
|
|
19
|
+
var f = o.forwardRef((r, e) => {
|
|
20
|
+
const { children: n, ...t } = r;
|
|
21
|
+
if (o.isValidElement(n)) {
|
|
22
|
+
const i = C(n);
|
|
23
|
+
return o.cloneElement(n, {
|
|
24
|
+
...g(t, n.props),
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
ref: e ? y(e, i) : i
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return o.Children.count(n) > 1 ? o.Children.only(null) : null;
|
|
30
|
+
});
|
|
31
|
+
f.displayName = "SlotClone";
|
|
32
|
+
var v = ({ children: r }) => /* @__PURE__ */ c(m, { children: r });
|
|
33
|
+
function E(r) {
|
|
34
|
+
return o.isValidElement(r) && r.type === v;
|
|
35
|
+
}
|
|
36
|
+
function g(r, e) {
|
|
37
|
+
const n = { ...e };
|
|
38
|
+
for (const t in e) {
|
|
39
|
+
const i = r[t], l = e[t];
|
|
40
|
+
/^on[A-Z]/.test(t) ? i && l ? n[t] = (...a) => {
|
|
41
|
+
l(...a), i(...a);
|
|
42
|
+
} : i && (n[t] = i) : t === "style" ? n[t] = { ...i, ...l } : t === "className" && (n[t] = [i, l].filter(Boolean).join(" "));
|
|
43
|
+
}
|
|
44
|
+
return { ...r, ...n };
|
|
45
|
+
}
|
|
46
|
+
function C(r) {
|
|
47
|
+
var t, i;
|
|
48
|
+
let e = (t = Object.getOwnPropertyDescriptor(r.props, "ref")) == null ? void 0 : t.get, n = e && "isReactWarning" in e && e.isReactWarning;
|
|
49
|
+
return n ? r.ref : (e = (i = Object.getOwnPropertyDescriptor(r, "ref")) == null ? void 0 : i.get, n = e && "isReactWarning" in e && e.isReactWarning, n ? r.props.ref : r.props.ref || r.ref);
|
|
50
|
+
}
|
|
51
|
+
var R = [
|
|
52
|
+
"a",
|
|
53
|
+
"button",
|
|
54
|
+
"div",
|
|
55
|
+
"form",
|
|
56
|
+
"h2",
|
|
57
|
+
"h3",
|
|
58
|
+
"img",
|
|
59
|
+
"input",
|
|
60
|
+
"label",
|
|
61
|
+
"li",
|
|
62
|
+
"nav",
|
|
63
|
+
"ol",
|
|
64
|
+
"p",
|
|
65
|
+
"span",
|
|
66
|
+
"svg",
|
|
67
|
+
"ul"
|
|
68
|
+
], P = R.reduce((r, e) => {
|
|
69
|
+
const n = o.forwardRef((t, i) => {
|
|
70
|
+
const { asChild: l, ...s } = t, a = l ? u : e;
|
|
71
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ c(a, { ...s, ref: i });
|
|
72
|
+
});
|
|
73
|
+
return n.displayName = `Primitive.${e}`, { ...r, [e]: n };
|
|
74
|
+
}, {});
|
|
75
|
+
function b(r, e) {
|
|
76
|
+
r && d.flushSync(() => r.dispatchEvent(e));
|
|
77
|
+
}
|
|
78
|
+
export {
|
|
79
|
+
P,
|
|
80
|
+
u as S,
|
|
81
|
+
b as d
|
|
82
|
+
};
|
|
@@ -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
|
+
};
|
package/dist/main.d.ts
CHANGED
|
@@ -54,8 +54,10 @@ export { PremiumBadge } from './components/PremiumBadge/PremiumBadge';
|
|
|
54
54
|
export { Prose } from './components/Prose/Prose';
|
|
55
55
|
export { Radio } from './components/Radio/Radio';
|
|
56
56
|
export { Select } from './components/Select';
|
|
57
|
+
export { DropdownSelect } from './components/DropdownSelect';
|
|
57
58
|
export { Separator } from './components/Separator/Separator';
|
|
58
59
|
export { Shroud } from './components/Shroud/Shroud';
|
|
60
|
+
export { Slider } from './components/Slider/Slider';
|
|
59
61
|
export { Spacer } from './components/Spacer/Spacer';
|
|
60
62
|
export { Style, useContextualStyle } from './components/Style/Style';
|
|
61
63
|
export { Switch } from './components/Switch';
|