@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
|
@@ -2,7 +2,7 @@ import { jsxs as l, jsx as e } from "react/jsx-runtime";
|
|
|
2
2
|
import o from "react";
|
|
3
3
|
import { Flex as a } from "../Layout/Flex/Flex.js";
|
|
4
4
|
import { Text as i } from "../Text/Text.js";
|
|
5
|
-
import {
|
|
5
|
+
import { S as n } from "../../Select-Ds-fm4CN.js";
|
|
6
6
|
const t = [
|
|
7
7
|
{
|
|
8
8
|
value: "value",
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Select } from './Select';
|
|
1
|
+
export { Select, ICON_SIZE_MAP } from './Select';
|
|
2
2
|
export type { SelectProps, SelectOption } from './Select';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import * as RadixSlider from '@radix-ui/react-slider';
|
|
3
|
+
interface SliderProps extends RadixSlider.SliderProps {
|
|
4
|
+
ariaLabel?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
title: string;
|
|
7
|
+
minLabel?: string | number;
|
|
8
|
+
maxLabel?: string | number;
|
|
9
|
+
}
|
|
10
|
+
export declare const Slider: React.FC<SliderProps>;
|
|
11
|
+
export default Slider;
|
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import { jsx as f, Fragment as pe, jsxs as B } from "react/jsx-runtime";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import z from "react";
|
|
4
|
+
import { u as he, c as Z } from "../../index-BW3WdIgK.js";
|
|
5
|
+
import { u as Se, b as ge, a as be } from "../../index-BCnz73Lm.js";
|
|
6
|
+
import "../../index-2hJuj4UN.js";
|
|
7
|
+
import { c as _e } from "../../index-CjTSD6zB.js";
|
|
8
|
+
import { clsx as ve } from "../../utils/clsx.js";
|
|
9
|
+
function V(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
|
|
10
|
+
return function(o) {
|
|
11
|
+
if (e == null || e(o), n === !1 || !o.defaultPrevented)
|
|
12
|
+
return t == null ? void 0 : t(o);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function G(e, t) {
|
|
16
|
+
if (typeof e == "function")
|
|
17
|
+
return e(t);
|
|
18
|
+
e != null && (e.current = t);
|
|
19
|
+
}
|
|
20
|
+
function q(...e) {
|
|
21
|
+
return (t) => {
|
|
22
|
+
let n = !1;
|
|
23
|
+
const r = e.map((o) => {
|
|
24
|
+
const s = G(o, t);
|
|
25
|
+
return !n && typeof s == "function" && (n = !0), s;
|
|
26
|
+
});
|
|
27
|
+
if (n)
|
|
28
|
+
return () => {
|
|
29
|
+
for (let o = 0; o < r.length; o++) {
|
|
30
|
+
const s = r[o];
|
|
31
|
+
typeof s == "function" ? s() : G(e[o], null);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function k(...e) {
|
|
37
|
+
return c.useCallback(q(...e), e);
|
|
38
|
+
}
|
|
39
|
+
function we(e, t = []) {
|
|
40
|
+
let n = [];
|
|
41
|
+
function r(s, i) {
|
|
42
|
+
const a = c.createContext(i), u = n.length;
|
|
43
|
+
n = [...n, i];
|
|
44
|
+
const m = (l) => {
|
|
45
|
+
var h;
|
|
46
|
+
const { scope: d, children: p, ..._ } = l, S = ((h = d == null ? void 0 : d[e]) == null ? void 0 : h[u]) || a, g = c.useMemo(() => _, Object.values(_));
|
|
47
|
+
return /* @__PURE__ */ f(S.Provider, { value: g, children: p });
|
|
48
|
+
};
|
|
49
|
+
m.displayName = s + "Provider";
|
|
50
|
+
function b(l, d) {
|
|
51
|
+
var S;
|
|
52
|
+
const p = ((S = d == null ? void 0 : d[e]) == null ? void 0 : S[u]) || a, _ = c.useContext(p);
|
|
53
|
+
if (_) return _;
|
|
54
|
+
if (i !== void 0) return i;
|
|
55
|
+
throw new Error(`\`${l}\` must be used within \`${s}\``);
|
|
56
|
+
}
|
|
57
|
+
return [m, b];
|
|
58
|
+
}
|
|
59
|
+
const o = () => {
|
|
60
|
+
const s = n.map((i) => c.createContext(i));
|
|
61
|
+
return function(a) {
|
|
62
|
+
const u = (a == null ? void 0 : a[e]) || s;
|
|
63
|
+
return c.useMemo(
|
|
64
|
+
() => ({ [`__scope${e}`]: { ...a, [e]: u } }),
|
|
65
|
+
[a, u]
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
return o.scopeName = e, [r, xe(o, ...t)];
|
|
70
|
+
}
|
|
71
|
+
function xe(...e) {
|
|
72
|
+
const t = e[0];
|
|
73
|
+
if (e.length === 1) return t;
|
|
74
|
+
const n = () => {
|
|
75
|
+
const r = e.map((o) => ({
|
|
76
|
+
useScope: o(),
|
|
77
|
+
scopeName: o.scopeName
|
|
78
|
+
}));
|
|
79
|
+
return function(s) {
|
|
80
|
+
const i = r.reduce((a, { useScope: u, scopeName: m }) => {
|
|
81
|
+
const l = u(s)[`__scope${m}`];
|
|
82
|
+
return { ...a, ...l };
|
|
83
|
+
}, {});
|
|
84
|
+
return c.useMemo(() => ({ [`__scope${t.scopeName}`]: i }), [i]);
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
return n.scopeName = t.scopeName, n;
|
|
88
|
+
}
|
|
89
|
+
var J = c.forwardRef((e, t) => {
|
|
90
|
+
const { children: n, ...r } = e, o = c.Children.toArray(n), s = o.find(ye);
|
|
91
|
+
if (s) {
|
|
92
|
+
const i = s.props.children, a = o.map((u) => u === s ? c.Children.count(i) > 1 ? c.Children.only(null) : c.isValidElement(i) ? i.props.children : null : u);
|
|
93
|
+
return /* @__PURE__ */ f(F, { ...r, ref: t, children: c.isValidElement(i) ? c.cloneElement(i, void 0, a) : null });
|
|
94
|
+
}
|
|
95
|
+
return /* @__PURE__ */ f(F, { ...r, ref: t, children: n });
|
|
96
|
+
});
|
|
97
|
+
J.displayName = "Slot";
|
|
98
|
+
var F = c.forwardRef((e, t) => {
|
|
99
|
+
const { children: n, ...r } = e;
|
|
100
|
+
if (c.isValidElement(n)) {
|
|
101
|
+
const o = Ce(n);
|
|
102
|
+
return c.cloneElement(n, {
|
|
103
|
+
...Pe(r, n.props),
|
|
104
|
+
// @ts-ignore
|
|
105
|
+
ref: t ? q(t, o) : o
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return c.Children.count(n) > 1 ? c.Children.only(null) : null;
|
|
109
|
+
});
|
|
110
|
+
F.displayName = "SlotClone";
|
|
111
|
+
var Re = ({ children: e }) => /* @__PURE__ */ f(pe, { children: e });
|
|
112
|
+
function ye(e) {
|
|
113
|
+
return c.isValidElement(e) && e.type === Re;
|
|
114
|
+
}
|
|
115
|
+
function Pe(e, t) {
|
|
116
|
+
const n = { ...t };
|
|
117
|
+
for (const r in t) {
|
|
118
|
+
const o = e[r], s = t[r];
|
|
119
|
+
/^on[A-Z]/.test(r) ? o && s ? n[r] = (...a) => {
|
|
120
|
+
s(...a), o(...a);
|
|
121
|
+
} : o && (n[r] = o) : r === "style" ? n[r] = { ...o, ...s } : r === "className" && (n[r] = [o, s].filter(Boolean).join(" "));
|
|
122
|
+
}
|
|
123
|
+
return { ...e, ...n };
|
|
124
|
+
}
|
|
125
|
+
function Ce(e) {
|
|
126
|
+
var r, o;
|
|
127
|
+
let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
|
|
128
|
+
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);
|
|
129
|
+
}
|
|
130
|
+
var De = [
|
|
131
|
+
"a",
|
|
132
|
+
"button",
|
|
133
|
+
"div",
|
|
134
|
+
"form",
|
|
135
|
+
"h2",
|
|
136
|
+
"h3",
|
|
137
|
+
"img",
|
|
138
|
+
"input",
|
|
139
|
+
"label",
|
|
140
|
+
"li",
|
|
141
|
+
"nav",
|
|
142
|
+
"ol",
|
|
143
|
+
"p",
|
|
144
|
+
"span",
|
|
145
|
+
"svg",
|
|
146
|
+
"ul"
|
|
147
|
+
], I = De.reduce((e, t) => {
|
|
148
|
+
const n = c.forwardRef((r, o) => {
|
|
149
|
+
const { asChild: s, ...i } = r, a = s ? J : t;
|
|
150
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(a, { ...i, ref: o });
|
|
151
|
+
});
|
|
152
|
+
return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
|
|
153
|
+
}, {}), Q = ["PageUp", "PageDown"], ee = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], te = {
|
|
154
|
+
"from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
|
|
155
|
+
"from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
|
|
156
|
+
"from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
|
|
157
|
+
"from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
|
|
158
|
+
}, M = "Slider", [H, Ee, Ve] = _e(M), [ne, at] = we(M, [
|
|
159
|
+
Ve
|
|
160
|
+
]), [Me, K] = ne(M), re = c.forwardRef(
|
|
161
|
+
(e, t) => {
|
|
162
|
+
const {
|
|
163
|
+
name: n,
|
|
164
|
+
min: r = 0,
|
|
165
|
+
max: o = 100,
|
|
166
|
+
step: s = 1,
|
|
167
|
+
orientation: i = "horizontal",
|
|
168
|
+
disabled: a = !1,
|
|
169
|
+
minStepsBetweenThumbs: u = 0,
|
|
170
|
+
defaultValue: m = [r],
|
|
171
|
+
value: b,
|
|
172
|
+
onValueChange: l = () => {
|
|
173
|
+
},
|
|
174
|
+
onValueCommit: d = () => {
|
|
175
|
+
},
|
|
176
|
+
inverted: p = !1,
|
|
177
|
+
form: _,
|
|
178
|
+
...S
|
|
179
|
+
} = e, g = c.useRef(/* @__PURE__ */ new Set()), h = c.useRef(0), w = i === "horizontal" ? Te : Ne, [v = [], T] = Se({
|
|
180
|
+
prop: b,
|
|
181
|
+
defaultProp: m,
|
|
182
|
+
onChange: (x) => {
|
|
183
|
+
var D;
|
|
184
|
+
(D = [...g.current][h.current]) == null || D.focus(), l(x);
|
|
185
|
+
}
|
|
186
|
+
}), O = c.useRef(v);
|
|
187
|
+
function L(x) {
|
|
188
|
+
const R = Ke(v, x);
|
|
189
|
+
N(x, R);
|
|
190
|
+
}
|
|
191
|
+
function fe(x) {
|
|
192
|
+
N(x, h.current);
|
|
193
|
+
}
|
|
194
|
+
function me() {
|
|
195
|
+
const x = O.current[h.current];
|
|
196
|
+
v[h.current] !== x && d(v);
|
|
197
|
+
}
|
|
198
|
+
function N(x, R, { commit: D } = { commit: !1 }) {
|
|
199
|
+
const Y = ze(s), $ = Fe(Math.round((x - r) / s) * s + r, Y), A = Z($, [r, o]);
|
|
200
|
+
T((E = []) => {
|
|
201
|
+
const y = Be(E, A, R);
|
|
202
|
+
if ($e(y, u * s)) {
|
|
203
|
+
h.current = y.indexOf(A);
|
|
204
|
+
const X = String(y) !== String(E);
|
|
205
|
+
return X && D && d(y), X ? y : E;
|
|
206
|
+
} else
|
|
207
|
+
return E;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return /* @__PURE__ */ f(
|
|
211
|
+
Me,
|
|
212
|
+
{
|
|
213
|
+
scope: e.__scopeSlider,
|
|
214
|
+
name: n,
|
|
215
|
+
disabled: a,
|
|
216
|
+
min: r,
|
|
217
|
+
max: o,
|
|
218
|
+
valueIndexToChangeRef: h,
|
|
219
|
+
thumbs: g.current,
|
|
220
|
+
values: v,
|
|
221
|
+
orientation: i,
|
|
222
|
+
form: _,
|
|
223
|
+
children: /* @__PURE__ */ f(H.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ f(H.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ f(
|
|
224
|
+
w,
|
|
225
|
+
{
|
|
226
|
+
"aria-disabled": a,
|
|
227
|
+
"data-disabled": a ? "" : void 0,
|
|
228
|
+
...S,
|
|
229
|
+
ref: t,
|
|
230
|
+
onPointerDown: V(S.onPointerDown, () => {
|
|
231
|
+
a || (O.current = v);
|
|
232
|
+
}),
|
|
233
|
+
min: r,
|
|
234
|
+
max: o,
|
|
235
|
+
inverted: p,
|
|
236
|
+
onSlideStart: a ? void 0 : L,
|
|
237
|
+
onSlideMove: a ? void 0 : fe,
|
|
238
|
+
onSlideEnd: a ? void 0 : me,
|
|
239
|
+
onHomeKeyDown: () => !a && N(r, 0, { commit: !0 }),
|
|
240
|
+
onEndKeyDown: () => !a && N(o, v.length - 1, { commit: !0 }),
|
|
241
|
+
onStepKeyDown: ({ event: x, direction: R }) => {
|
|
242
|
+
if (!a) {
|
|
243
|
+
const $ = Q.includes(x.key) || x.shiftKey && ee.includes(x.key) ? 10 : 1, A = h.current, E = v[A], y = s * $ * R;
|
|
244
|
+
N(E + y, A, { commit: !0 });
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
) }) })
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
re.displayName = M;
|
|
254
|
+
var [oe, ie] = ne(M, {
|
|
255
|
+
startEdge: "left",
|
|
256
|
+
endEdge: "right",
|
|
257
|
+
size: "width",
|
|
258
|
+
direction: 1
|
|
259
|
+
}), Te = c.forwardRef(
|
|
260
|
+
(e, t) => {
|
|
261
|
+
const {
|
|
262
|
+
min: n,
|
|
263
|
+
max: r,
|
|
264
|
+
dir: o,
|
|
265
|
+
inverted: s,
|
|
266
|
+
onSlideStart: i,
|
|
267
|
+
onSlideMove: a,
|
|
268
|
+
onSlideEnd: u,
|
|
269
|
+
onStepKeyDown: m,
|
|
270
|
+
...b
|
|
271
|
+
} = e, [l, d] = c.useState(null), p = k(t, (w) => d(w)), _ = c.useRef(void 0), S = he(o), g = S === "ltr", h = g && !s || !g && s;
|
|
272
|
+
function C(w) {
|
|
273
|
+
const v = _.current || l.getBoundingClientRect(), T = [0, v.width], L = U(T, h ? [n, r] : [r, n]);
|
|
274
|
+
return _.current = v, L(w - v.left);
|
|
275
|
+
}
|
|
276
|
+
return /* @__PURE__ */ f(
|
|
277
|
+
oe,
|
|
278
|
+
{
|
|
279
|
+
scope: e.__scopeSlider,
|
|
280
|
+
startEdge: h ? "left" : "right",
|
|
281
|
+
endEdge: h ? "right" : "left",
|
|
282
|
+
direction: h ? 1 : -1,
|
|
283
|
+
size: "width",
|
|
284
|
+
children: /* @__PURE__ */ f(
|
|
285
|
+
se,
|
|
286
|
+
{
|
|
287
|
+
dir: S,
|
|
288
|
+
"data-orientation": "horizontal",
|
|
289
|
+
...b,
|
|
290
|
+
ref: p,
|
|
291
|
+
style: {
|
|
292
|
+
...b.style,
|
|
293
|
+
"--radix-slider-thumb-transform": "translateX(-50%)"
|
|
294
|
+
},
|
|
295
|
+
onSlideStart: (w) => {
|
|
296
|
+
const v = C(w.clientX);
|
|
297
|
+
i == null || i(v);
|
|
298
|
+
},
|
|
299
|
+
onSlideMove: (w) => {
|
|
300
|
+
const v = C(w.clientX);
|
|
301
|
+
a == null || a(v);
|
|
302
|
+
},
|
|
303
|
+
onSlideEnd: () => {
|
|
304
|
+
_.current = void 0, u == null || u();
|
|
305
|
+
},
|
|
306
|
+
onStepKeyDown: (w) => {
|
|
307
|
+
const T = te[h ? "from-left" : "from-right"].includes(w.key);
|
|
308
|
+
m == null || m({ event: w, direction: T ? -1 : 1 });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
)
|
|
312
|
+
}
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
), Ne = c.forwardRef(
|
|
316
|
+
(e, t) => {
|
|
317
|
+
const {
|
|
318
|
+
min: n,
|
|
319
|
+
max: r,
|
|
320
|
+
inverted: o,
|
|
321
|
+
onSlideStart: s,
|
|
322
|
+
onSlideMove: i,
|
|
323
|
+
onSlideEnd: a,
|
|
324
|
+
onStepKeyDown: u,
|
|
325
|
+
...m
|
|
326
|
+
} = e, b = c.useRef(null), l = k(t, b), d = c.useRef(void 0), p = !o;
|
|
327
|
+
function _(S) {
|
|
328
|
+
const g = d.current || b.current.getBoundingClientRect(), h = [0, g.height], w = U(h, p ? [r, n] : [n, r]);
|
|
329
|
+
return d.current = g, w(S - g.top);
|
|
330
|
+
}
|
|
331
|
+
return /* @__PURE__ */ f(
|
|
332
|
+
oe,
|
|
333
|
+
{
|
|
334
|
+
scope: e.__scopeSlider,
|
|
335
|
+
startEdge: p ? "bottom" : "top",
|
|
336
|
+
endEdge: p ? "top" : "bottom",
|
|
337
|
+
size: "height",
|
|
338
|
+
direction: p ? 1 : -1,
|
|
339
|
+
children: /* @__PURE__ */ f(
|
|
340
|
+
se,
|
|
341
|
+
{
|
|
342
|
+
"data-orientation": "vertical",
|
|
343
|
+
...m,
|
|
344
|
+
ref: l,
|
|
345
|
+
style: {
|
|
346
|
+
...m.style,
|
|
347
|
+
"--radix-slider-thumb-transform": "translateY(50%)"
|
|
348
|
+
},
|
|
349
|
+
onSlideStart: (S) => {
|
|
350
|
+
const g = _(S.clientY);
|
|
351
|
+
s == null || s(g);
|
|
352
|
+
},
|
|
353
|
+
onSlideMove: (S) => {
|
|
354
|
+
const g = _(S.clientY);
|
|
355
|
+
i == null || i(g);
|
|
356
|
+
},
|
|
357
|
+
onSlideEnd: () => {
|
|
358
|
+
d.current = void 0, a == null || a();
|
|
359
|
+
},
|
|
360
|
+
onStepKeyDown: (S) => {
|
|
361
|
+
const h = te[p ? "from-bottom" : "from-top"].includes(S.key);
|
|
362
|
+
u == null || u({ event: S, direction: h ? -1 : 1 });
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
)
|
|
366
|
+
}
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
), se = c.forwardRef(
|
|
370
|
+
(e, t) => {
|
|
371
|
+
const {
|
|
372
|
+
__scopeSlider: n,
|
|
373
|
+
onSlideStart: r,
|
|
374
|
+
onSlideMove: o,
|
|
375
|
+
onSlideEnd: s,
|
|
376
|
+
onHomeKeyDown: i,
|
|
377
|
+
onEndKeyDown: a,
|
|
378
|
+
onStepKeyDown: u,
|
|
379
|
+
...m
|
|
380
|
+
} = e, b = K(M, n);
|
|
381
|
+
return /* @__PURE__ */ f(
|
|
382
|
+
I.span,
|
|
383
|
+
{
|
|
384
|
+
...m,
|
|
385
|
+
ref: t,
|
|
386
|
+
onKeyDown: V(e.onKeyDown, (l) => {
|
|
387
|
+
l.key === "Home" ? (i(l), l.preventDefault()) : l.key === "End" ? (a(l), l.preventDefault()) : Q.concat(ee).includes(l.key) && (u(l), l.preventDefault());
|
|
388
|
+
}),
|
|
389
|
+
onPointerDown: V(e.onPointerDown, (l) => {
|
|
390
|
+
const d = l.target;
|
|
391
|
+
d.setPointerCapture(l.pointerId), l.preventDefault(), b.thumbs.has(d) ? d.focus() : r(l);
|
|
392
|
+
}),
|
|
393
|
+
onPointerMove: V(e.onPointerMove, (l) => {
|
|
394
|
+
l.target.hasPointerCapture(l.pointerId) && o(l);
|
|
395
|
+
}),
|
|
396
|
+
onPointerUp: V(e.onPointerUp, (l) => {
|
|
397
|
+
const d = l.target;
|
|
398
|
+
d.hasPointerCapture(l.pointerId) && (d.releasePointerCapture(l.pointerId), s(l));
|
|
399
|
+
})
|
|
400
|
+
}
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
), ae = "SliderTrack", ce = c.forwardRef(
|
|
404
|
+
(e, t) => {
|
|
405
|
+
const { __scopeSlider: n, ...r } = e, o = K(ae, n);
|
|
406
|
+
return /* @__PURE__ */ f(
|
|
407
|
+
I.span,
|
|
408
|
+
{
|
|
409
|
+
"data-disabled": o.disabled ? "" : void 0,
|
|
410
|
+
"data-orientation": o.orientation,
|
|
411
|
+
...r,
|
|
412
|
+
ref: t
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
);
|
|
417
|
+
ce.displayName = ae;
|
|
418
|
+
var j = "SliderRange", le = c.forwardRef(
|
|
419
|
+
(e, t) => {
|
|
420
|
+
const { __scopeSlider: n, ...r } = e, o = K(j, n), s = ie(j, n), i = c.useRef(null), a = k(t, i), u = o.values.length, m = o.values.map(
|
|
421
|
+
(d) => de(d, o.min, o.max)
|
|
422
|
+
), b = u > 1 ? Math.min(...m) : 0, l = 100 - Math.max(...m);
|
|
423
|
+
return /* @__PURE__ */ f(
|
|
424
|
+
I.span,
|
|
425
|
+
{
|
|
426
|
+
"data-orientation": o.orientation,
|
|
427
|
+
"data-disabled": o.disabled ? "" : void 0,
|
|
428
|
+
...r,
|
|
429
|
+
ref: a,
|
|
430
|
+
style: {
|
|
431
|
+
...e.style,
|
|
432
|
+
[s.startEdge]: b + "%",
|
|
433
|
+
[s.endEdge]: l + "%"
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
);
|
|
439
|
+
le.displayName = j;
|
|
440
|
+
var W = "SliderThumb", ue = c.forwardRef(
|
|
441
|
+
(e, t) => {
|
|
442
|
+
const n = Ee(e.__scopeSlider), [r, o] = c.useState(null), s = k(t, (a) => o(a)), i = c.useMemo(
|
|
443
|
+
() => r ? n().findIndex((a) => a.ref.current === r) : -1,
|
|
444
|
+
[n, r]
|
|
445
|
+
);
|
|
446
|
+
return /* @__PURE__ */ f(Ae, { ...e, ref: s, index: i });
|
|
447
|
+
}
|
|
448
|
+
), Ae = c.forwardRef(
|
|
449
|
+
(e, t) => {
|
|
450
|
+
const { __scopeSlider: n, index: r, name: o, ...s } = e, i = K(W, n), a = ie(W, n), [u, m] = c.useState(null), b = k(t, (C) => m(C)), l = u ? i.form || !!u.closest("form") : !0, d = ge(u), p = i.values[r], _ = p === void 0 ? 0 : de(p, i.min, i.max), S = Ie(r, i.values.length), g = d == null ? void 0 : d[a.size], h = g ? Oe(g, _, a.direction) : 0;
|
|
451
|
+
return c.useEffect(() => {
|
|
452
|
+
if (u)
|
|
453
|
+
return i.thumbs.add(u), () => {
|
|
454
|
+
i.thumbs.delete(u);
|
|
455
|
+
};
|
|
456
|
+
}, [u, i.thumbs]), /* @__PURE__ */ B(
|
|
457
|
+
"span",
|
|
458
|
+
{
|
|
459
|
+
style: {
|
|
460
|
+
transform: "var(--radix-slider-thumb-transform)",
|
|
461
|
+
position: "absolute",
|
|
462
|
+
[a.startEdge]: `calc(${_}% + ${h}px)`
|
|
463
|
+
},
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ f(H.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ f(
|
|
466
|
+
I.span,
|
|
467
|
+
{
|
|
468
|
+
role: "slider",
|
|
469
|
+
"aria-label": e["aria-label"] || S,
|
|
470
|
+
"aria-valuemin": i.min,
|
|
471
|
+
"aria-valuenow": p,
|
|
472
|
+
"aria-valuemax": i.max,
|
|
473
|
+
"aria-orientation": i.orientation,
|
|
474
|
+
"data-orientation": i.orientation,
|
|
475
|
+
"data-disabled": i.disabled ? "" : void 0,
|
|
476
|
+
tabIndex: i.disabled ? void 0 : 0,
|
|
477
|
+
...s,
|
|
478
|
+
ref: b,
|
|
479
|
+
style: p === void 0 ? { display: "none" } : e.style,
|
|
480
|
+
onFocus: V(e.onFocus, () => {
|
|
481
|
+
i.valueIndexToChangeRef.current = r;
|
|
482
|
+
})
|
|
483
|
+
}
|
|
484
|
+
) }),
|
|
485
|
+
l && /* @__PURE__ */ f(
|
|
486
|
+
ke,
|
|
487
|
+
{
|
|
488
|
+
name: o ?? (i.name ? i.name + (i.values.length > 1 ? "[]" : "") : void 0),
|
|
489
|
+
form: i.form,
|
|
490
|
+
value: p
|
|
491
|
+
},
|
|
492
|
+
r
|
|
493
|
+
)
|
|
494
|
+
]
|
|
495
|
+
}
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
);
|
|
499
|
+
ue.displayName = W;
|
|
500
|
+
var ke = (e) => {
|
|
501
|
+
const { value: t, ...n } = e, r = c.useRef(null), o = be(t);
|
|
502
|
+
return c.useEffect(() => {
|
|
503
|
+
const s = r.current, i = window.HTMLInputElement.prototype, u = Object.getOwnPropertyDescriptor(i, "value").set;
|
|
504
|
+
if (o !== t && u) {
|
|
505
|
+
const m = new Event("input", { bubbles: !0 });
|
|
506
|
+
u.call(s, t), s.dispatchEvent(m);
|
|
507
|
+
}
|
|
508
|
+
}, [o, t]), /* @__PURE__ */ f("input", { style: { display: "none" }, ...n, ref: r, defaultValue: t });
|
|
509
|
+
};
|
|
510
|
+
function Be(e = [], t, n) {
|
|
511
|
+
const r = [...e];
|
|
512
|
+
return r[n] = t, r.sort((o, s) => o - s);
|
|
513
|
+
}
|
|
514
|
+
function de(e, t, n) {
|
|
515
|
+
const s = 100 / (n - t) * (e - t);
|
|
516
|
+
return Z(s, [0, 100]);
|
|
517
|
+
}
|
|
518
|
+
function Ie(e, t) {
|
|
519
|
+
return t > 2 ? `Value ${e + 1} of ${t}` : t === 2 ? ["Minimum", "Maximum"][e] : void 0;
|
|
520
|
+
}
|
|
521
|
+
function Ke(e, t) {
|
|
522
|
+
if (e.length === 1) return 0;
|
|
523
|
+
const n = e.map((o) => Math.abs(o - t)), r = Math.min(...n);
|
|
524
|
+
return n.indexOf(r);
|
|
525
|
+
}
|
|
526
|
+
function Oe(e, t, n) {
|
|
527
|
+
const r = e / 2, s = U([0, 50], [0, r]);
|
|
528
|
+
return (r - s(t) * n) * n;
|
|
529
|
+
}
|
|
530
|
+
function Le(e) {
|
|
531
|
+
return e.slice(0, -1).map((t, n) => e[n + 1] - t);
|
|
532
|
+
}
|
|
533
|
+
function $e(e, t) {
|
|
534
|
+
if (t > 0) {
|
|
535
|
+
const n = Le(e);
|
|
536
|
+
return Math.min(...n) >= t;
|
|
537
|
+
}
|
|
538
|
+
return !0;
|
|
539
|
+
}
|
|
540
|
+
function U(e, t) {
|
|
541
|
+
return (n) => {
|
|
542
|
+
if (e[0] === e[1] || t[0] === t[1]) return t[0];
|
|
543
|
+
const r = (t[1] - t[0]) / (e[1] - e[0]);
|
|
544
|
+
return t[0] + r * (n - e[0]);
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function ze(e) {
|
|
548
|
+
return (String(e).split(".")[1] || "").length;
|
|
549
|
+
}
|
|
550
|
+
function Fe(e, t) {
|
|
551
|
+
const n = Math.pow(10, t);
|
|
552
|
+
return Math.round(e * n) / n;
|
|
553
|
+
}
|
|
554
|
+
var He = re, je = ce, We = le, Ue = ue;
|
|
555
|
+
const Ye = "cfxui__Slider__sliderContainer__fac82", Xe = "cfxui__Slider__sliderLabels__f63f4", Ge = "cfxui__Slider__sliderRoot__032df", Ze = "cfxui__Slider__sliderTrack__b32a8", qe = "cfxui__Slider__sliderRange__a13a7", Je = "cfxui__Slider__sliderThumb__e8450", Qe = "cfxui__Slider__sliderValueBubble__086d6", P = {
|
|
556
|
+
sliderContainer: Ye,
|
|
557
|
+
sliderLabels: Xe,
|
|
558
|
+
sliderRoot: Ge,
|
|
559
|
+
sliderTrack: Ze,
|
|
560
|
+
sliderRange: qe,
|
|
561
|
+
sliderThumb: Je,
|
|
562
|
+
sliderValueBubble: Qe
|
|
563
|
+
}, ct = function({
|
|
564
|
+
value: t,
|
|
565
|
+
defaultValue: n,
|
|
566
|
+
title: r,
|
|
567
|
+
ariaLabel: o,
|
|
568
|
+
className: s,
|
|
569
|
+
minLabel: i = 0,
|
|
570
|
+
maxLabel: a = 5e3,
|
|
571
|
+
onValueChange: u,
|
|
572
|
+
...m
|
|
573
|
+
}) {
|
|
574
|
+
const [b, l] = z.useState(() => {
|
|
575
|
+
if (t)
|
|
576
|
+
return t;
|
|
577
|
+
if (n)
|
|
578
|
+
return n;
|
|
579
|
+
}), d = z.useCallback((p) => {
|
|
580
|
+
u && u(p), l(p);
|
|
581
|
+
}, [u]);
|
|
582
|
+
return z.useEffect(() => {
|
|
583
|
+
t && l(t);
|
|
584
|
+
}, [t]), /* @__PURE__ */ B("div", { className: P.sliderContainer, children: [
|
|
585
|
+
/* @__PURE__ */ B(
|
|
586
|
+
He,
|
|
587
|
+
{
|
|
588
|
+
...m,
|
|
589
|
+
className: ve(P.sliderRoot, s),
|
|
590
|
+
onValueChange: d,
|
|
591
|
+
children: [
|
|
592
|
+
/* @__PURE__ */ f(je, { className: P.sliderTrack, children: /* @__PURE__ */ f(We, { className: P.sliderRange }) }),
|
|
593
|
+
/* @__PURE__ */ f(Ue, { className: P.sliderThumb, "aria-label": o, children: /* @__PURE__ */ f("div", { className: P.sliderValueBubble, children: `${b} ${r}` }) })
|
|
594
|
+
]
|
|
595
|
+
}
|
|
596
|
+
),
|
|
597
|
+
/* @__PURE__ */ B("div", { className: P.sliderLabels, children: [
|
|
598
|
+
/* @__PURE__ */ f("span", { children: i }),
|
|
599
|
+
/* @__PURE__ */ f("span", { children: a })
|
|
600
|
+
] })
|
|
601
|
+
] });
|
|
602
|
+
};
|
|
603
|
+
export {
|
|
604
|
+
ct as Slider,
|
|
605
|
+
ct as default
|
|
606
|
+
};
|