@purpurds/slider 5.30.1 → 5.32.0
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/LICENSE.txt +1 -1
- package/dist/slider.cjs.js +1 -1
- package/dist/slider.cjs.js.map +1 -1
- package/dist/slider.es.js +49 -49
- package/dist/slider.es.js.map +1 -1
- package/package.json +2 -2
package/dist/slider.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as Pe, jsx as G } from "react/jsx-runtime";
|
|
2
|
-
import D, { useCallback as ce, createContext as q, useMemo as O, createElement as
|
|
2
|
+
import D, { useCallback as ce, createContext as q, useMemo as O, createElement as b, useContext as ae, useRef as E, useEffect as B, useState as T, useLayoutEffect as Ee, forwardRef as P, Children as k, isValidElement as F, cloneElement as se, Fragment as De, useId as Me } from "react";
|
|
3
3
|
import "react-dom";
|
|
4
4
|
function y() {
|
|
5
5
|
return y = Object.assign ? Object.assign.bind() : function(e) {
|
|
@@ -42,7 +42,7 @@ function de(e, t = []) {
|
|
|
42
42
|
() => f,
|
|
43
43
|
Object.values(f)
|
|
44
44
|
);
|
|
45
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ b($.Provider, {
|
|
46
46
|
value: p
|
|
47
47
|
}, S);
|
|
48
48
|
}
|
|
@@ -204,11 +204,11 @@ const U = /* @__PURE__ */ P((e, t) => {
|
|
|
204
204
|
const { children: n, ...r } = e, i = k.toArray(n), o = i.find(ze);
|
|
205
205
|
if (o) {
|
|
206
206
|
const a = o.props.children, c = i.map((l) => l === o ? k.count(a) > 1 ? k.only(null) : /* @__PURE__ */ F(a) ? a.props.children : null : l);
|
|
207
|
-
return /* @__PURE__ */
|
|
207
|
+
return /* @__PURE__ */ b(Z, y({}, r, {
|
|
208
208
|
ref: t
|
|
209
209
|
}), /* @__PURE__ */ F(a) ? /* @__PURE__ */ se(a, void 0, c) : null);
|
|
210
210
|
}
|
|
211
|
-
return /* @__PURE__ */
|
|
211
|
+
return /* @__PURE__ */ b(Z, y({}, r, {
|
|
212
212
|
ref: t
|
|
213
213
|
}), n);
|
|
214
214
|
});
|
|
@@ -221,7 +221,7 @@ const Z = /* @__PURE__ */ P((e, t) => {
|
|
|
221
221
|
}) : k.count(n) > 1 ? k.only(null) : null;
|
|
222
222
|
});
|
|
223
223
|
Z.displayName = "SlotClone";
|
|
224
|
-
const Be = ({ children: e }) => /* @__PURE__ */
|
|
224
|
+
const Be = ({ children: e }) => /* @__PURE__ */ b(De, null, e);
|
|
225
225
|
function ze(e) {
|
|
226
226
|
return /* @__PURE__ */ F(e) && e.type === Be;
|
|
227
227
|
}
|
|
@@ -268,7 +268,7 @@ const He = [
|
|
|
268
268
|
const { asChild: o, ...a } = r, c = o ? U : t;
|
|
269
269
|
return B(() => {
|
|
270
270
|
window[Symbol.for("radix-ui")] = !0;
|
|
271
|
-
}, []), /* @__PURE__ */
|
|
271
|
+
}, []), /* @__PURE__ */ b(c, y({}, a, {
|
|
272
272
|
ref: i
|
|
273
273
|
}));
|
|
274
274
|
});
|
|
@@ -284,22 +284,22 @@ function je(e) {
|
|
|
284
284
|
},
|
|
285
285
|
itemMap: /* @__PURE__ */ new Map()
|
|
286
286
|
}), a = (S) => {
|
|
287
|
-
const { scope: f, children: $ } = S, p = D.useRef(null),
|
|
287
|
+
const { scope: f, children: $ } = S, p = D.useRef(null), v = D.useRef(/* @__PURE__ */ new Map()).current;
|
|
288
288
|
return /* @__PURE__ */ D.createElement(i, {
|
|
289
289
|
scope: f,
|
|
290
|
-
itemMap:
|
|
290
|
+
itemMap: v,
|
|
291
291
|
collectionRef: p
|
|
292
292
|
}, $);
|
|
293
293
|
}, c = e + "CollectionSlot", l = /* @__PURE__ */ D.forwardRef((S, f) => {
|
|
294
|
-
const { scope: $, children: p } = S,
|
|
294
|
+
const { scope: $, children: p } = S, v = o(c, $), _ = M(f, v.collectionRef);
|
|
295
295
|
return /* @__PURE__ */ D.createElement(U, {
|
|
296
296
|
ref: _
|
|
297
297
|
}, p);
|
|
298
298
|
}), u = e + "CollectionItemSlot", m = "data-radix-collection-item", s = /* @__PURE__ */ D.forwardRef((S, f) => {
|
|
299
|
-
const { scope: $, children: p, ...
|
|
299
|
+
const { scope: $, children: p, ...v } = S, _ = D.useRef(null), h = M(f, _), g = o(u, $);
|
|
300
300
|
return D.useEffect(() => (g.itemMap.set(_, {
|
|
301
301
|
ref: _,
|
|
302
|
-
...
|
|
302
|
+
...v
|
|
303
303
|
}), () => void g.itemMap.delete(_))), /* @__PURE__ */ D.createElement(U, {
|
|
304
304
|
[m]: "",
|
|
305
305
|
ref: h
|
|
@@ -310,9 +310,9 @@ function je(e) {
|
|
|
310
310
|
return D.useCallback(() => {
|
|
311
311
|
const p = f.collectionRef.current;
|
|
312
312
|
if (!p) return [];
|
|
313
|
-
const
|
|
313
|
+
const v = Array.from(p.querySelectorAll(`[${m}]`));
|
|
314
314
|
return Array.from(f.itemMap.values()).sort(
|
|
315
|
-
(g, R) =>
|
|
315
|
+
(g, R) => v.indexOf(g.ref.current) - v.indexOf(R.ref.current)
|
|
316
316
|
);
|
|
317
317
|
}, [
|
|
318
318
|
f.collectionRef,
|
|
@@ -369,7 +369,7 @@ const pe = [
|
|
|
369
369
|
r
|
|
370
370
|
], value: m, onValueChange: s = () => {
|
|
371
371
|
}, onValueCommit: d = () => {
|
|
372
|
-
}, inverted: S = !1, ...f } = e, [$, p] = T(null),
|
|
372
|
+
}, inverted: S = !1, ...f } = e, [$, p] = T(null), v = M(
|
|
373
373
|
t,
|
|
374
374
|
(x) => p(x)
|
|
375
375
|
), _ = E(/* @__PURE__ */ new Set()), h = E(0), g = a === "horizontal", R = $ ? !!$.closest("form") : !0, ee = g ? Xe : Ge, [w = [], _e] = Ie({
|
|
@@ -409,7 +409,7 @@ const pe = [
|
|
|
409
409
|
} else return I;
|
|
410
410
|
});
|
|
411
411
|
}
|
|
412
|
-
return /* @__PURE__ */
|
|
412
|
+
return /* @__PURE__ */ b(Ye, {
|
|
413
413
|
scope: e.__scopeSlider,
|
|
414
414
|
disabled: c,
|
|
415
415
|
min: r,
|
|
@@ -418,15 +418,15 @@ const pe = [
|
|
|
418
418
|
thumbs: _.current,
|
|
419
419
|
values: w,
|
|
420
420
|
orientation: a
|
|
421
|
-
}, /* @__PURE__ */
|
|
421
|
+
}, /* @__PURE__ */ b(J.Provider, {
|
|
422
422
|
scope: e.__scopeSlider
|
|
423
|
-
}, /* @__PURE__ */
|
|
423
|
+
}, /* @__PURE__ */ b(J.Slot, {
|
|
424
424
|
scope: e.__scopeSlider
|
|
425
|
-
}, /* @__PURE__ */
|
|
425
|
+
}, /* @__PURE__ */ b(ee, y({
|
|
426
426
|
"aria-disabled": c,
|
|
427
427
|
"data-disabled": c ? "" : void 0
|
|
428
428
|
}, f, {
|
|
429
|
-
ref:
|
|
429
|
+
ref: v,
|
|
430
430
|
onPointerDown: N(f.onPointerDown, () => {
|
|
431
431
|
c || (te.current = w);
|
|
432
432
|
}),
|
|
@@ -451,13 +451,13 @@ const pe = [
|
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
453
|
})))), R && w.map(
|
|
454
|
-
(x, C) => /* @__PURE__ */
|
|
454
|
+
(x, C) => /* @__PURE__ */ b(tt, {
|
|
455
455
|
key: C,
|
|
456
456
|
name: n ? n + (w.length > 1 ? "[]" : "") : void 0,
|
|
457
457
|
value: x
|
|
458
458
|
})
|
|
459
459
|
));
|
|
460
|
-
}), [he,
|
|
460
|
+
}), [he, be] = Se(z, {
|
|
461
461
|
startEdge: "left",
|
|
462
462
|
endEdge: "right",
|
|
463
463
|
size: "width",
|
|
@@ -466,12 +466,12 @@ const pe = [
|
|
|
466
466
|
const { min: n, max: r, dir: i, inverted: o, onSlideStart: a, onSlideMove: c, onSlideEnd: l, onStepKeyDown: u, ...m } = e, [s, d] = T(null), S = M(
|
|
467
467
|
t,
|
|
468
468
|
(h) => d(h)
|
|
469
|
-
), f = E(), $ = Te(i), p = $ === "ltr",
|
|
469
|
+
), f = E(), $ = Te(i), p = $ === "ltr", v = p && !o || !p && o;
|
|
470
470
|
function _(h) {
|
|
471
471
|
const g = f.current || s.getBoundingClientRect(), R = [
|
|
472
472
|
0,
|
|
473
473
|
g.width
|
|
474
|
-
], w = Q(R,
|
|
474
|
+
], w = Q(R, v ? [
|
|
475
475
|
n,
|
|
476
476
|
r
|
|
477
477
|
] : [
|
|
@@ -480,13 +480,13 @@ const pe = [
|
|
|
480
480
|
]);
|
|
481
481
|
return f.current = g, w(h - g.left);
|
|
482
482
|
}
|
|
483
|
-
return /* @__PURE__ */
|
|
483
|
+
return /* @__PURE__ */ b(he, {
|
|
484
484
|
scope: e.__scopeSlider,
|
|
485
|
-
startEdge:
|
|
486
|
-
endEdge:
|
|
487
|
-
direction:
|
|
485
|
+
startEdge: v ? "left" : "right",
|
|
486
|
+
endEdge: v ? "right" : "left",
|
|
487
|
+
direction: v ? 1 : -1,
|
|
488
488
|
size: "width"
|
|
489
|
-
}, /* @__PURE__ */
|
|
489
|
+
}, /* @__PURE__ */ b(ve, y({
|
|
490
490
|
dir: $,
|
|
491
491
|
"data-orientation": "horizontal"
|
|
492
492
|
}, m, {
|
|
@@ -507,7 +507,7 @@ const pe = [
|
|
|
507
507
|
f.current = void 0, l == null || l();
|
|
508
508
|
},
|
|
509
509
|
onStepKeyDown: (h) => {
|
|
510
|
-
const R = me[
|
|
510
|
+
const R = me[v ? "from-left" : "from-right"].includes(h.key);
|
|
511
511
|
u == null || u({
|
|
512
512
|
event: h,
|
|
513
513
|
direction: R ? -1 : 1
|
|
@@ -517,10 +517,10 @@ const pe = [
|
|
|
517
517
|
}), Ge = /* @__PURE__ */ P((e, t) => {
|
|
518
518
|
const { min: n, max: r, inverted: i, onSlideStart: o, onSlideMove: a, onSlideEnd: c, onStepKeyDown: l, ...u } = e, m = E(null), s = M(t, m), d = E(), S = !i;
|
|
519
519
|
function f($) {
|
|
520
|
-
const p = d.current || m.current.getBoundingClientRect(),
|
|
520
|
+
const p = d.current || m.current.getBoundingClientRect(), v = [
|
|
521
521
|
0,
|
|
522
522
|
p.height
|
|
523
|
-
], h = Q(
|
|
523
|
+
], h = Q(v, S ? [
|
|
524
524
|
r,
|
|
525
525
|
n
|
|
526
526
|
] : [
|
|
@@ -529,13 +529,13 @@ const pe = [
|
|
|
529
529
|
]);
|
|
530
530
|
return d.current = p, h($ - p.top);
|
|
531
531
|
}
|
|
532
|
-
return /* @__PURE__ */
|
|
532
|
+
return /* @__PURE__ */ b(he, {
|
|
533
533
|
scope: e.__scopeSlider,
|
|
534
534
|
startEdge: S ? "bottom" : "top",
|
|
535
535
|
endEdge: S ? "top" : "bottom",
|
|
536
536
|
size: "height",
|
|
537
537
|
direction: S ? 1 : -1
|
|
538
|
-
}, /* @__PURE__ */
|
|
538
|
+
}, /* @__PURE__ */ b(ve, y({
|
|
539
539
|
"data-orientation": "vertical"
|
|
540
540
|
}, u, {
|
|
541
541
|
ref: s,
|
|
@@ -555,16 +555,16 @@ const pe = [
|
|
|
555
555
|
d.current = void 0, c == null || c();
|
|
556
556
|
},
|
|
557
557
|
onStepKeyDown: ($) => {
|
|
558
|
-
const
|
|
558
|
+
const v = me[S ? "from-bottom" : "from-top"].includes($.key);
|
|
559
559
|
l == null || l({
|
|
560
560
|
event: $,
|
|
561
|
-
direction:
|
|
561
|
+
direction: v ? -1 : 1
|
|
562
562
|
});
|
|
563
563
|
}
|
|
564
564
|
})));
|
|
565
|
-
}),
|
|
565
|
+
}), ve = /* @__PURE__ */ P((e, t) => {
|
|
566
566
|
const { __scopeSlider: n, onSlideStart: r, onSlideMove: i, onSlideEnd: o, onHomeKeyDown: a, onEndKeyDown: c, onStepKeyDown: l, ...u } = e, m = W(z, n);
|
|
567
|
-
return /* @__PURE__ */
|
|
567
|
+
return /* @__PURE__ */ b(Y.span, y({}, u, {
|
|
568
568
|
ref: t,
|
|
569
569
|
onKeyDown: N(e.onKeyDown, (s) => {
|
|
570
570
|
s.key === "Home" ? (a(s), s.preventDefault()) : s.key === "End" ? (c(s), s.preventDefault()) : pe.concat($e).includes(s.key) && (l(s), s.preventDefault());
|
|
@@ -583,17 +583,17 @@ const pe = [
|
|
|
583
583
|
}));
|
|
584
584
|
}), qe = "SliderTrack", Ze = /* @__PURE__ */ P((e, t) => {
|
|
585
585
|
const { __scopeSlider: n, ...r } = e, i = W(qe, n);
|
|
586
|
-
return /* @__PURE__ */
|
|
586
|
+
return /* @__PURE__ */ b(Y.span, y({
|
|
587
587
|
"data-disabled": i.disabled ? "" : void 0,
|
|
588
588
|
"data-orientation": i.orientation
|
|
589
589
|
}, r, {
|
|
590
590
|
ref: t
|
|
591
591
|
}));
|
|
592
592
|
}), re = "SliderRange", Je = /* @__PURE__ */ P((e, t) => {
|
|
593
|
-
const { __scopeSlider: n, ...r } = e, i = W(re, n), o =
|
|
593
|
+
const { __scopeSlider: n, ...r } = e, i = W(re, n), o = be(re, n), a = E(null), c = M(t, a), l = i.values.length, u = i.values.map(
|
|
594
594
|
(d) => xe(d, i.min, i.max)
|
|
595
595
|
), m = l > 1 ? Math.min(...u) : 0, s = 100 - Math.max(...u);
|
|
596
|
-
return /* @__PURE__ */
|
|
596
|
+
return /* @__PURE__ */ b(Y.span, y({
|
|
597
597
|
"data-orientation": i.orientation,
|
|
598
598
|
"data-disabled": i.disabled ? "" : void 0
|
|
599
599
|
}, r, {
|
|
@@ -617,12 +617,12 @@ const pe = [
|
|
|
617
617
|
r
|
|
618
618
|
]
|
|
619
619
|
);
|
|
620
|
-
return /* @__PURE__ */
|
|
620
|
+
return /* @__PURE__ */ b(et, y({}, e, {
|
|
621
621
|
ref: o,
|
|
622
622
|
index: a
|
|
623
623
|
}));
|
|
624
624
|
}), et = /* @__PURE__ */ P((e, t) => {
|
|
625
|
-
const { __scopeSlider: n, index: r, ...i } = e, o = W(ie, n), a =
|
|
625
|
+
const { __scopeSlider: n, index: r, ...i } = e, o = W(ie, n), a = be(ie, n), [c, l] = T(null), u = M(
|
|
626
626
|
t,
|
|
627
627
|
(p) => l(p)
|
|
628
628
|
), m = ke(c), s = o.values[r], d = s === void 0 ? 0 : xe(s, o.min, o.max), S = ot(r, o.values.length), f = m == null ? void 0 : m[a.size], $ = f ? it(f, d, a.direction) : 0;
|
|
@@ -634,15 +634,15 @@ const pe = [
|
|
|
634
634
|
}, [
|
|
635
635
|
c,
|
|
636
636
|
o.thumbs
|
|
637
|
-
]), /* @__PURE__ */
|
|
637
|
+
]), /* @__PURE__ */ b("span", {
|
|
638
638
|
style: {
|
|
639
639
|
transform: "var(--radix-slider-thumb-transform)",
|
|
640
640
|
position: "absolute",
|
|
641
641
|
[a.startEdge]: `calc(${d}% + ${$}px)`
|
|
642
642
|
}
|
|
643
|
-
}, /* @__PURE__ */
|
|
643
|
+
}, /* @__PURE__ */ b(J.ItemSlot, {
|
|
644
644
|
scope: e.__scopeSlider
|
|
645
|
-
}, /* @__PURE__ */
|
|
645
|
+
}, /* @__PURE__ */ b(Y.span, y({
|
|
646
646
|
role: "slider",
|
|
647
647
|
"aria-label": e["aria-label"] || S,
|
|
648
648
|
"aria-valuemin": o.min,
|
|
@@ -674,7 +674,7 @@ const pe = [
|
|
|
674
674
|
}, [
|
|
675
675
|
i,
|
|
676
676
|
t
|
|
677
|
-
]), /* @__PURE__ */
|
|
677
|
+
]), /* @__PURE__ */ b("input", y({
|
|
678
678
|
style: {
|
|
679
679
|
display: "none"
|
|
680
680
|
}
|
|
@@ -793,7 +793,7 @@ const St = /* @__PURE__ */ $t(mt), ht = {
|
|
|
793
793
|
"purpur-slider__track": "_purpur-slider__track_14tuk_17",
|
|
794
794
|
"purpur-slider__range": "_purpur-slider__range_14tuk_17",
|
|
795
795
|
"purpur-slider__thumb": "_purpur-slider__thumb_14tuk_43"
|
|
796
|
-
}, H = St.bind(ht), Ct = ["horizontal", "vertical"], j = "purpur-slider",
|
|
796
|
+
}, H = St.bind(ht), Ct = ["horizontal", "vertical"], j = "purpur-slider", bt = (e) => String(e), vt = ({
|
|
797
797
|
"aria-label": e,
|
|
798
798
|
"aria-valuetext": t,
|
|
799
799
|
className: n,
|
|
@@ -821,12 +821,12 @@ const St = /* @__PURE__ */ $t(mt), ht = {
|
|
|
821
821
|
"aria-label": e,
|
|
822
822
|
"aria-valuetext": t
|
|
823
823
|
},
|
|
824
|
-
|
|
824
|
+
bt(s)
|
|
825
825
|
))
|
|
826
826
|
]
|
|
827
827
|
}
|
|
828
828
|
);
|
|
829
|
-
}, xt = P(
|
|
829
|
+
}, xt = P(vt);
|
|
830
830
|
xt.displayName = "Slider";
|
|
831
831
|
export {
|
|
832
832
|
Ct as SLIDER_ORIENTATION,
|