@cfx-dev/ui-components 4.5.16 → 4.5.17

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.
Files changed (38) hide show
  1. package/dist/{Combination-2dfXEDc9.js → Combination-CcTTSYNP.js} +1 -1
  2. package/dist/{DropdownContent-CLtPVRZg.js → DropdownContent-MvHlrWi6.js} +4 -4
  3. package/dist/assets/all_css.css +2 -0
  4. package/dist/assets/css/DropdownSelect.css +1 -1
  5. package/dist/assets/css/Range.css +1 -0
  6. package/dist/assets/css/RangeInput.css +1 -0
  7. package/dist/assets/css/RichInput.css +1 -1
  8. package/dist/assets/css/Select.css +1 -1
  9. package/dist/assets/css/StyledInput.css +1 -1
  10. package/dist/components/Checkbox/Checkbox.js +23 -23
  11. package/dist/components/DropdownContent/DropdownContent.js +1 -1
  12. package/dist/components/DropdownContent/index.js +1 -1
  13. package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
  14. package/dist/components/DropdownSelect/DropdownSelect.js +1 -1
  15. package/dist/components/Range/Range.d.ts +4 -0
  16. package/dist/components/Range/Range.js +90 -0
  17. package/dist/components/Range/Range.types.d.ts +9 -0
  18. package/dist/components/Range/Range.types.js +1 -0
  19. package/dist/components/Range/RangeInput.d.ts +13 -0
  20. package/dist/components/Range/RangeInput.js +78 -0
  21. package/dist/components/Range/RangeShowcase.d.ts +2 -0
  22. package/dist/components/Range/RangeShowcase.js +41 -0
  23. package/dist/components/Range/RangeWithInputs.d.ts +8 -0
  24. package/dist/components/Range/RangeWithInputs.js +81 -0
  25. package/dist/components/Range/index.d.ts +6 -0
  26. package/dist/components/Range/index.js +8 -0
  27. package/dist/components/Select/Select.js +3 -3
  28. package/dist/components/Slider/Slider.js +64 -472
  29. package/dist/components/Slider/SliderShowcase.js +6 -4
  30. package/dist/components/Switch/Switch.js +1 -1
  31. package/dist/{index-DWzyrn_L.js → index-3ctv5u9o.js} +1 -1
  32. package/dist/{index-BMU9X4M-.js → index-9LBuZ7x4.js} +7 -7
  33. package/dist/{index-DCuJlMqr.js → index-CfQtbUfi.js} +6 -6
  34. package/dist/index-D5SMGei3.js +427 -0
  35. package/dist/main.d.ts +2 -0
  36. package/dist/main.js +105 -99
  37. package/dist/styles-scss/_ui.scss +19 -17
  38. package/package.json +1 -1
@@ -0,0 +1,427 @@
1
+ import * as d from "react";
2
+ import { c as $ } from "./index-rKs9bXHr.js";
3
+ import { u as ce, c as le, a as C, P as B, b as M, d as de } from "./index-CfQtbUfi.js";
4
+ import { c as ue, u as fe } from "./index-9LBuZ7x4.js";
5
+ import { u as me } from "./index-BZPx6jYI.js";
6
+ import { jsx as v, jsxs as pe } from "react/jsx-runtime";
7
+ var j = ["PageUp", "PageDown"], X = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], G = {
8
+ "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
9
+ "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
10
+ "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
11
+ "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
12
+ }, I = "Slider", [z, he, Se] = ue(I), [W, Ke] = le(I, [
13
+ Se
14
+ ]), [ge, K] = W(I), q = d.forwardRef(
15
+ (e, t) => {
16
+ const {
17
+ name: o,
18
+ min: n = 0,
19
+ max: a = 100,
20
+ step: c = 1,
21
+ orientation: r = "horizontal",
22
+ disabled: s = !1,
23
+ minStepsBetweenThumbs: l = 0,
24
+ defaultValue: h = [n],
25
+ value: S,
26
+ onValueChange: i = () => {
27
+ },
28
+ onValueCommit: u = () => {
29
+ },
30
+ inverted: w = !1,
31
+ form: P,
32
+ ...g
33
+ } = e, m = d.useRef(/* @__PURE__ */ new Set()), f = d.useRef(0), b = r === "horizontal" ? ve : we, [p = [], A] = ce({
34
+ prop: S,
35
+ defaultProp: h,
36
+ onChange: (R) => {
37
+ var E;
38
+ (E = [...m.current][f.current]) == null || E.focus(), i(R);
39
+ }
40
+ }), k = d.useRef(p);
41
+ function H(R) {
42
+ const x = ye(p, R);
43
+ T(R, x);
44
+ }
45
+ function se(R) {
46
+ T(R, f.current);
47
+ }
48
+ function ae() {
49
+ const R = k.current[f.current];
50
+ p[f.current] !== R && u(p);
51
+ }
52
+ function T(R, x, { commit: E } = { commit: !1 }) {
53
+ const F = Ce(c), N = Me(Math.round((R - n) / c) * c + n, F), V = $(N, [n, a]);
54
+ A((_ = []) => {
55
+ const y = Pe(_, V, x);
56
+ if (_e(y, l * c)) {
57
+ f.current = y.indexOf(V);
58
+ const Y = String(y) !== String(_);
59
+ return Y && E && u(y), Y ? y : _;
60
+ } else
61
+ return _;
62
+ });
63
+ }
64
+ return /* @__PURE__ */ v(
65
+ ge,
66
+ {
67
+ scope: e.__scopeSlider,
68
+ name: o,
69
+ disabled: s,
70
+ min: n,
71
+ max: a,
72
+ valueIndexToChangeRef: f,
73
+ thumbs: m.current,
74
+ values: p,
75
+ orientation: r,
76
+ form: P,
77
+ children: /* @__PURE__ */ v(z.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ v(z.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ v(
78
+ b,
79
+ {
80
+ "aria-disabled": s,
81
+ "data-disabled": s ? "" : void 0,
82
+ ...g,
83
+ ref: t,
84
+ onPointerDown: C(g.onPointerDown, () => {
85
+ s || (k.current = p);
86
+ }),
87
+ min: n,
88
+ max: a,
89
+ inverted: w,
90
+ onSlideStart: s ? void 0 : H,
91
+ onSlideMove: s ? void 0 : se,
92
+ onSlideEnd: s ? void 0 : ae,
93
+ onHomeKeyDown: () => !s && T(n, 0, { commit: !0 }),
94
+ onEndKeyDown: () => !s && T(a, p.length - 1, { commit: !0 }),
95
+ onStepKeyDown: ({ event: R, direction: x }) => {
96
+ if (!s) {
97
+ const N = j.includes(R.key) || R.shiftKey && X.includes(R.key) ? 10 : 1, V = f.current, _ = p[V], y = c * N * x;
98
+ T(_ + y, V, { commit: !0 });
99
+ }
100
+ }
101
+ }
102
+ ) }) })
103
+ }
104
+ );
105
+ }
106
+ );
107
+ q.displayName = I;
108
+ var [J, Q] = W(I, {
109
+ startEdge: "left",
110
+ endEdge: "right",
111
+ size: "width",
112
+ direction: 1
113
+ }), ve = d.forwardRef(
114
+ (e, t) => {
115
+ const {
116
+ min: o,
117
+ max: n,
118
+ dir: a,
119
+ inverted: c,
120
+ onSlideStart: r,
121
+ onSlideMove: s,
122
+ onSlideEnd: l,
123
+ onStepKeyDown: h,
124
+ ...S
125
+ } = e, [i, u] = d.useState(null), w = M(t, (b) => u(b)), P = d.useRef(void 0), g = fe(a), m = g === "ltr", f = m && !c || !m && c;
126
+ function D(b) {
127
+ const p = P.current || i.getBoundingClientRect(), A = [0, p.width], H = U(A, f ? [o, n] : [n, o]);
128
+ return P.current = p, H(b - p.left);
129
+ }
130
+ return /* @__PURE__ */ v(
131
+ J,
132
+ {
133
+ scope: e.__scopeSlider,
134
+ startEdge: f ? "left" : "right",
135
+ endEdge: f ? "right" : "left",
136
+ direction: f ? 1 : -1,
137
+ size: "width",
138
+ children: /* @__PURE__ */ v(
139
+ Z,
140
+ {
141
+ dir: g,
142
+ "data-orientation": "horizontal",
143
+ ...S,
144
+ ref: w,
145
+ style: {
146
+ ...S.style,
147
+ "--radix-slider-thumb-transform": "translateX(-50%)"
148
+ },
149
+ onSlideStart: (b) => {
150
+ const p = D(b.clientX);
151
+ r == null || r(p);
152
+ },
153
+ onSlideMove: (b) => {
154
+ const p = D(b.clientX);
155
+ s == null || s(p);
156
+ },
157
+ onSlideEnd: () => {
158
+ P.current = void 0, l == null || l();
159
+ },
160
+ onStepKeyDown: (b) => {
161
+ const A = G[f ? "from-left" : "from-right"].includes(b.key);
162
+ h == null || h({ event: b, direction: A ? -1 : 1 });
163
+ }
164
+ }
165
+ )
166
+ }
167
+ );
168
+ }
169
+ ), we = d.forwardRef(
170
+ (e, t) => {
171
+ const {
172
+ min: o,
173
+ max: n,
174
+ inverted: a,
175
+ onSlideStart: c,
176
+ onSlideMove: r,
177
+ onSlideEnd: s,
178
+ onStepKeyDown: l,
179
+ ...h
180
+ } = e, S = d.useRef(null), i = M(t, S), u = d.useRef(void 0), w = !a;
181
+ function P(g) {
182
+ const m = u.current || S.current.getBoundingClientRect(), f = [0, m.height], b = U(f, w ? [n, o] : [o, n]);
183
+ return u.current = m, b(g - m.top);
184
+ }
185
+ return /* @__PURE__ */ v(
186
+ J,
187
+ {
188
+ scope: e.__scopeSlider,
189
+ startEdge: w ? "bottom" : "top",
190
+ endEdge: w ? "top" : "bottom",
191
+ size: "height",
192
+ direction: w ? 1 : -1,
193
+ children: /* @__PURE__ */ v(
194
+ Z,
195
+ {
196
+ "data-orientation": "vertical",
197
+ ...h,
198
+ ref: i,
199
+ style: {
200
+ ...h.style,
201
+ "--radix-slider-thumb-transform": "translateY(50%)"
202
+ },
203
+ onSlideStart: (g) => {
204
+ const m = P(g.clientY);
205
+ c == null || c(m);
206
+ },
207
+ onSlideMove: (g) => {
208
+ const m = P(g.clientY);
209
+ r == null || r(m);
210
+ },
211
+ onSlideEnd: () => {
212
+ u.current = void 0, s == null || s();
213
+ },
214
+ onStepKeyDown: (g) => {
215
+ const f = G[w ? "from-bottom" : "from-top"].includes(g.key);
216
+ l == null || l({ event: g, direction: f ? -1 : 1 });
217
+ }
218
+ }
219
+ )
220
+ }
221
+ );
222
+ }
223
+ ), Z = d.forwardRef(
224
+ (e, t) => {
225
+ const {
226
+ __scopeSlider: o,
227
+ onSlideStart: n,
228
+ onSlideMove: a,
229
+ onSlideEnd: c,
230
+ onHomeKeyDown: r,
231
+ onEndKeyDown: s,
232
+ onStepKeyDown: l,
233
+ ...h
234
+ } = e, S = K(I, o);
235
+ return /* @__PURE__ */ v(
236
+ B.span,
237
+ {
238
+ ...h,
239
+ ref: t,
240
+ onKeyDown: C(e.onKeyDown, (i) => {
241
+ i.key === "Home" ? (r(i), i.preventDefault()) : i.key === "End" ? (s(i), i.preventDefault()) : j.concat(X).includes(i.key) && (l(i), i.preventDefault());
242
+ }),
243
+ onPointerDown: C(e.onPointerDown, (i) => {
244
+ const u = i.target;
245
+ u.setPointerCapture(i.pointerId), i.preventDefault(), S.thumbs.has(u) ? u.focus() : n(i);
246
+ }),
247
+ onPointerMove: C(e.onPointerMove, (i) => {
248
+ i.target.hasPointerCapture(i.pointerId) && a(i);
249
+ }),
250
+ onPointerUp: C(e.onPointerUp, (i) => {
251
+ const u = i.target;
252
+ u.hasPointerCapture(i.pointerId) && (u.releasePointerCapture(i.pointerId), c(i));
253
+ })
254
+ }
255
+ );
256
+ }
257
+ ), ee = "SliderTrack", te = d.forwardRef(
258
+ (e, t) => {
259
+ const { __scopeSlider: o, ...n } = e, a = K(ee, o);
260
+ return /* @__PURE__ */ v(
261
+ B.span,
262
+ {
263
+ "data-disabled": a.disabled ? "" : void 0,
264
+ "data-orientation": a.orientation,
265
+ ...n,
266
+ ref: t
267
+ }
268
+ );
269
+ }
270
+ );
271
+ te.displayName = ee;
272
+ var L = "SliderRange", ne = d.forwardRef(
273
+ (e, t) => {
274
+ const { __scopeSlider: o, ...n } = e, a = K(L, o), c = Q(L, o), r = d.useRef(null), s = M(t, r), l = a.values.length, h = a.values.map(
275
+ (u) => ie(u, a.min, a.max)
276
+ ), S = l > 1 ? Math.min(...h) : 0, i = 100 - Math.max(...h);
277
+ return /* @__PURE__ */ v(
278
+ B.span,
279
+ {
280
+ "data-orientation": a.orientation,
281
+ "data-disabled": a.disabled ? "" : void 0,
282
+ ...n,
283
+ ref: s,
284
+ style: {
285
+ ...e.style,
286
+ [c.startEdge]: S + "%",
287
+ [c.endEdge]: i + "%"
288
+ }
289
+ }
290
+ );
291
+ }
292
+ );
293
+ ne.displayName = L;
294
+ var O = "SliderThumb", oe = d.forwardRef(
295
+ (e, t) => {
296
+ const o = he(e.__scopeSlider), [n, a] = d.useState(null), c = M(t, (s) => a(s)), r = d.useMemo(
297
+ () => n ? o().findIndex((s) => s.ref.current === n) : -1,
298
+ [o, n]
299
+ );
300
+ return /* @__PURE__ */ v(be, { ...e, ref: c, index: r });
301
+ }
302
+ ), be = d.forwardRef(
303
+ (e, t) => {
304
+ const { __scopeSlider: o, index: n, name: a, ...c } = e, r = K(O, o), s = Q(O, o), [l, h] = d.useState(null), S = M(t, (D) => h(D)), i = l ? r.form || !!l.closest("form") : !0, u = de(l), w = r.values[n], P = w === void 0 ? 0 : ie(w, r.min, r.max), g = xe(n, r.values.length), m = u == null ? void 0 : u[s.size], f = m ? De(m, P, s.direction) : 0;
305
+ return d.useEffect(() => {
306
+ if (l)
307
+ return r.thumbs.add(l), () => {
308
+ r.thumbs.delete(l);
309
+ };
310
+ }, [l, r.thumbs]), /* @__PURE__ */ pe(
311
+ "span",
312
+ {
313
+ style: {
314
+ transform: "var(--radix-slider-thumb-transform)",
315
+ position: "absolute",
316
+ [s.startEdge]: `calc(${P}% + ${f}px)`
317
+ },
318
+ children: [
319
+ /* @__PURE__ */ v(z.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ v(
320
+ B.span,
321
+ {
322
+ role: "slider",
323
+ "aria-label": e["aria-label"] || g,
324
+ "aria-valuemin": r.min,
325
+ "aria-valuenow": w,
326
+ "aria-valuemax": r.max,
327
+ "aria-orientation": r.orientation,
328
+ "data-orientation": r.orientation,
329
+ "data-disabled": r.disabled ? "" : void 0,
330
+ tabIndex: r.disabled ? void 0 : 0,
331
+ ...c,
332
+ ref: S,
333
+ style: w === void 0 ? { display: "none" } : e.style,
334
+ onFocus: C(e.onFocus, () => {
335
+ r.valueIndexToChangeRef.current = n;
336
+ })
337
+ }
338
+ ) }),
339
+ i && /* @__PURE__ */ v(
340
+ re,
341
+ {
342
+ name: a ?? (r.name ? r.name + (r.values.length > 1 ? "[]" : "") : void 0),
343
+ form: r.form,
344
+ value: w
345
+ },
346
+ n
347
+ )
348
+ ]
349
+ }
350
+ );
351
+ }
352
+ );
353
+ oe.displayName = O;
354
+ var Re = "RadioBubbleInput", re = d.forwardRef(
355
+ ({ __scopeSlider: e, value: t, ...o }, n) => {
356
+ const a = d.useRef(null), c = M(a, n), r = me(t);
357
+ return d.useEffect(() => {
358
+ const s = a.current;
359
+ if (!s) return;
360
+ const l = window.HTMLInputElement.prototype, S = Object.getOwnPropertyDescriptor(l, "value").set;
361
+ if (r !== t && S) {
362
+ const i = new Event("input", { bubbles: !0 });
363
+ S.call(s, t), s.dispatchEvent(i);
364
+ }
365
+ }, [r, t]), /* @__PURE__ */ v(
366
+ B.input,
367
+ {
368
+ style: { display: "none" },
369
+ ...o,
370
+ ref: c,
371
+ defaultValue: t
372
+ }
373
+ );
374
+ }
375
+ );
376
+ re.displayName = Re;
377
+ function Pe(e = [], t, o) {
378
+ const n = [...e];
379
+ return n[o] = t, n.sort((a, c) => a - c);
380
+ }
381
+ function ie(e, t, o) {
382
+ const c = 100 / (o - t) * (e - t);
383
+ return $(c, [0, 100]);
384
+ }
385
+ function xe(e, t) {
386
+ return t > 2 ? `Value ${e + 1} of ${t}` : t === 2 ? ["Minimum", "Maximum"][e] : void 0;
387
+ }
388
+ function ye(e, t) {
389
+ if (e.length === 1) return 0;
390
+ const o = e.map((a) => Math.abs(a - t)), n = Math.min(...o);
391
+ return o.indexOf(n);
392
+ }
393
+ function De(e, t, o) {
394
+ const n = e / 2, c = U([0, 50], [0, n]);
395
+ return (n - c(t) * o) * o;
396
+ }
397
+ function Ee(e) {
398
+ return e.slice(0, -1).map((t, o) => e[o + 1] - t);
399
+ }
400
+ function _e(e, t) {
401
+ if (t > 0) {
402
+ const o = Ee(e);
403
+ return Math.min(...o) >= t;
404
+ }
405
+ return !0;
406
+ }
407
+ function U(e, t) {
408
+ return (o) => {
409
+ if (e[0] === e[1] || t[0] === t[1]) return t[0];
410
+ const n = (t[1] - t[0]) / (e[1] - e[0]);
411
+ return t[0] + n * (o - e[0]);
412
+ };
413
+ }
414
+ function Ce(e) {
415
+ return (String(e).split(".")[1] || "").length;
416
+ }
417
+ function Me(e, t) {
418
+ const o = Math.pow(10, t);
419
+ return Math.round(e * o) / o;
420
+ }
421
+ var ke = q, He = te, Ne = ne, ze = oe;
422
+ export {
423
+ ke as R,
424
+ He as T,
425
+ Ne as a,
426
+ ze as b
427
+ };
package/dist/main.d.ts CHANGED
@@ -111,6 +111,8 @@ export { Shroud } from './components/Shroud';
111
111
  export type { ShroudProps } from './components/Shroud';
112
112
  export { Slider } from './components/Slider';
113
113
  export type { SliderProps } from './components/Slider';
114
+ export { Range, RangeInput, RangeWithInputs, } from './components/Range';
115
+ export type { RangeProps, RangeInputProps, RangeWithInputsProps, } from './components/Range';
114
116
  export { Spacer } from './components/Spacer';
115
117
  export type { SpacerProps } from './components/Spacer';
116
118
  export { Style, useContextualStyle } from './components/Style';