@purpurds/slider 5.14.0 → 5.15.1
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 +32 -33
- package/dist/slider.es.js.map +1 -1
- package/package.json +2 -2
package/dist/slider.es.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { jsxs as Pe, jsx as G } from "react/jsx-runtime";
|
|
2
|
-
import D, { useCallback as ce, createContext as q, useMemo as
|
|
2
|
+
import D, { useCallback as ce, createContext as q, useMemo as O, createElement as v, 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) {
|
|
6
6
|
for (var t = 1; t < arguments.length; t++) {
|
|
7
7
|
var n = arguments[t];
|
|
8
|
-
for (var r in n)
|
|
9
|
-
Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
|
|
8
|
+
for (var r in n) ({}).hasOwnProperty.call(n, r) && (e[r] = n[r]);
|
|
10
9
|
}
|
|
11
10
|
return e;
|
|
12
|
-
}, y.apply(
|
|
11
|
+
}, y.apply(null, arguments);
|
|
13
12
|
}
|
|
14
13
|
function le(e, [t, n]) {
|
|
15
14
|
return Math.min(n, Math.max(t, e));
|
|
16
15
|
}
|
|
17
|
-
function
|
|
16
|
+
function N(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
|
|
18
17
|
return function(i) {
|
|
19
18
|
if (e == null || e(i), n === !1 || !i.defaultPrevented) return t == null ? void 0 : t(i);
|
|
20
19
|
};
|
|
@@ -39,7 +38,7 @@ function de(e, t = []) {
|
|
|
39
38
|
a
|
|
40
39
|
];
|
|
41
40
|
function u(s) {
|
|
42
|
-
const { scope: d, children: S, ...f } = s, $ = (d == null ? void 0 : d[e][l]) || c, p =
|
|
41
|
+
const { scope: d, children: S, ...f } = s, $ = (d == null ? void 0 : d[e][l]) || c, p = O(
|
|
43
42
|
() => f,
|
|
44
43
|
Object.values(f)
|
|
45
44
|
);
|
|
@@ -62,7 +61,7 @@ function de(e, t = []) {
|
|
|
62
61
|
const o = n.map((a) => /* @__PURE__ */ q(a));
|
|
63
62
|
return function(c) {
|
|
64
63
|
const l = (c == null ? void 0 : c[e]) || o;
|
|
65
|
-
return
|
|
64
|
+
return O(
|
|
66
65
|
() => ({
|
|
67
66
|
[`__scope${e}`]: {
|
|
68
67
|
...c,
|
|
@@ -99,7 +98,7 @@ function Ae(...e) {
|
|
|
99
98
|
...s
|
|
100
99
|
};
|
|
101
100
|
}, {});
|
|
102
|
-
return
|
|
101
|
+
return O(
|
|
103
102
|
() => ({
|
|
104
103
|
[`__scope${t.scopeName}`]: a
|
|
105
104
|
}),
|
|
@@ -113,9 +112,9 @@ function Ae(...e) {
|
|
|
113
112
|
}
|
|
114
113
|
function fe(e) {
|
|
115
114
|
const t = E(e);
|
|
116
|
-
return
|
|
115
|
+
return B(() => {
|
|
117
116
|
t.current = e;
|
|
118
|
-
}),
|
|
117
|
+
}), O(
|
|
119
118
|
() => (...n) => {
|
|
120
119
|
var r;
|
|
121
120
|
return (r = t.current) === null || r === void 0 ? void 0 : r.call(t, ...n);
|
|
@@ -125,7 +124,7 @@ function fe(e) {
|
|
|
125
124
|
}
|
|
126
125
|
function Ie({ prop: e, defaultProp: t, onChange: n = () => {
|
|
127
126
|
} }) {
|
|
128
|
-
const [r, i] =
|
|
127
|
+
const [r, i] = Ne({
|
|
129
128
|
defaultProp: t,
|
|
130
129
|
onChange: n
|
|
131
130
|
}), o = e !== void 0, a = o ? e : r, c = fe(n), l = ce((u) => {
|
|
@@ -144,9 +143,9 @@ function Ie({ prop: e, defaultProp: t, onChange: n = () => {
|
|
|
144
143
|
l
|
|
145
144
|
];
|
|
146
145
|
}
|
|
147
|
-
function
|
|
146
|
+
function Ne({ defaultProp: e, onChange: t }) {
|
|
148
147
|
const n = T(e), [r] = n, i = E(r), o = fe(t);
|
|
149
|
-
return
|
|
148
|
+
return B(() => {
|
|
150
149
|
i.current !== r && (o(r), i.current = r);
|
|
151
150
|
}, [
|
|
152
151
|
r,
|
|
@@ -154,9 +153,9 @@ function Oe({ defaultProp: e, onChange: t }) {
|
|
|
154
153
|
o
|
|
155
154
|
]), n;
|
|
156
155
|
}
|
|
157
|
-
const
|
|
156
|
+
const Oe = /* @__PURE__ */ q(void 0);
|
|
158
157
|
function Te(e) {
|
|
159
|
-
const t = ae(
|
|
158
|
+
const t = ae(Oe);
|
|
160
159
|
return e || t || "ltr";
|
|
161
160
|
}
|
|
162
161
|
function Ke(e) {
|
|
@@ -164,13 +163,13 @@ function Ke(e) {
|
|
|
164
163
|
value: e,
|
|
165
164
|
previous: e
|
|
166
165
|
});
|
|
167
|
-
return
|
|
166
|
+
return O(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [
|
|
168
167
|
e
|
|
169
168
|
]);
|
|
170
169
|
}
|
|
171
170
|
const Ve = globalThis != null && globalThis.document ? Ee : () => {
|
|
172
171
|
};
|
|
173
|
-
function
|
|
172
|
+
function ke(e) {
|
|
174
173
|
const [t, n] = T(void 0);
|
|
175
174
|
return Ve(() => {
|
|
176
175
|
if (e) {
|
|
@@ -202,9 +201,9 @@ function Be(e) {
|
|
|
202
201
|
]), t;
|
|
203
202
|
}
|
|
204
203
|
const U = /* @__PURE__ */ P((e, t) => {
|
|
205
|
-
const { children: n, ...r } = e, i =
|
|
204
|
+
const { children: n, ...r } = e, i = k.toArray(n), o = i.find(ze);
|
|
206
205
|
if (o) {
|
|
207
|
-
const a = o.props.children, c = i.map((l) => l === o ?
|
|
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);
|
|
208
207
|
return /* @__PURE__ */ v(Z, y({}, r, {
|
|
209
208
|
ref: t
|
|
210
209
|
}), /* @__PURE__ */ F(a) ? /* @__PURE__ */ se(a, void 0, c) : null);
|
|
@@ -219,12 +218,12 @@ const Z = /* @__PURE__ */ P((e, t) => {
|
|
|
219
218
|
return /* @__PURE__ */ F(n) ? /* @__PURE__ */ se(n, {
|
|
220
219
|
...Le(r, n.props),
|
|
221
220
|
ref: t ? ue(t, n.ref) : n.ref
|
|
222
|
-
}) :
|
|
221
|
+
}) : k.count(n) > 1 ? k.only(null) : null;
|
|
223
222
|
});
|
|
224
223
|
Z.displayName = "SlotClone";
|
|
225
|
-
const
|
|
224
|
+
const Be = ({ children: e }) => /* @__PURE__ */ v(De, null, e);
|
|
226
225
|
function ze(e) {
|
|
227
|
-
return /* @__PURE__ */ F(e) && e.type ===
|
|
226
|
+
return /* @__PURE__ */ F(e) && e.type === Be;
|
|
228
227
|
}
|
|
229
228
|
function Le(e, t) {
|
|
230
229
|
const n = {
|
|
@@ -267,7 +266,7 @@ const He = [
|
|
|
267
266
|
], Y = He.reduce((e, t) => {
|
|
268
267
|
const n = /* @__PURE__ */ P((r, i) => {
|
|
269
268
|
const { asChild: o, ...a } = r, c = o ? U : t;
|
|
270
|
-
return
|
|
269
|
+
return B(() => {
|
|
271
270
|
window[Symbol.for("radix-ui")] = !0;
|
|
272
271
|
}, []), /* @__PURE__ */ v(c, y({}, a, {
|
|
273
272
|
ref: i
|
|
@@ -428,7 +427,7 @@ const pe = [
|
|
|
428
427
|
"data-disabled": c ? "" : void 0
|
|
429
428
|
}, f, {
|
|
430
429
|
ref: b,
|
|
431
|
-
onPointerDown:
|
|
430
|
+
onPointerDown: N(f.onPointerDown, () => {
|
|
432
431
|
c || (te.current = w);
|
|
433
432
|
}),
|
|
434
433
|
min: r,
|
|
@@ -567,17 +566,17 @@ const pe = [
|
|
|
567
566
|
const { __scopeSlider: n, onSlideStart: r, onSlideMove: i, onSlideEnd: o, onHomeKeyDown: a, onEndKeyDown: c, onStepKeyDown: l, ...u } = e, m = W(z, n);
|
|
568
567
|
return /* @__PURE__ */ v(Y.span, y({}, u, {
|
|
569
568
|
ref: t,
|
|
570
|
-
onKeyDown:
|
|
569
|
+
onKeyDown: N(e.onKeyDown, (s) => {
|
|
571
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());
|
|
572
571
|
}),
|
|
573
|
-
onPointerDown:
|
|
572
|
+
onPointerDown: N(e.onPointerDown, (s) => {
|
|
574
573
|
const d = s.target;
|
|
575
574
|
d.setPointerCapture(s.pointerId), s.preventDefault(), m.thumbs.has(d) ? d.focus() : r(s);
|
|
576
575
|
}),
|
|
577
|
-
onPointerMove:
|
|
576
|
+
onPointerMove: N(e.onPointerMove, (s) => {
|
|
578
577
|
s.target.hasPointerCapture(s.pointerId) && i(s);
|
|
579
578
|
}),
|
|
580
|
-
onPointerUp:
|
|
579
|
+
onPointerUp: N(e.onPointerUp, (s) => {
|
|
581
580
|
const d = s.target;
|
|
582
581
|
d.hasPointerCapture(s.pointerId) && (d.releasePointerCapture(s.pointerId), o(s));
|
|
583
582
|
})
|
|
@@ -609,7 +608,7 @@ const pe = [
|
|
|
609
608
|
const n = Fe(e.__scopeSlider), [r, i] = T(null), o = M(
|
|
610
609
|
t,
|
|
611
610
|
(c) => i(c)
|
|
612
|
-
), a =
|
|
611
|
+
), a = O(
|
|
613
612
|
() => r ? n().findIndex(
|
|
614
613
|
(c) => c.ref.current === r
|
|
615
614
|
) : -1,
|
|
@@ -626,8 +625,8 @@ const pe = [
|
|
|
626
625
|
const { __scopeSlider: n, index: r, ...i } = e, o = W(ie, n), a = ve(ie, n), [c, l] = T(null), u = M(
|
|
627
626
|
t,
|
|
628
627
|
(p) => l(p)
|
|
629
|
-
), m =
|
|
630
|
-
return
|
|
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;
|
|
629
|
+
return B(() => {
|
|
631
630
|
if (c)
|
|
632
631
|
return o.thumbs.add(c), () => {
|
|
633
632
|
o.thumbs.delete(c);
|
|
@@ -658,13 +657,13 @@ const pe = [
|
|
|
658
657
|
style: s === void 0 ? {
|
|
659
658
|
display: "none"
|
|
660
659
|
} : e.style,
|
|
661
|
-
onFocus:
|
|
660
|
+
onFocus: N(e.onFocus, () => {
|
|
662
661
|
o.valueIndexToChangeRef.current = r;
|
|
663
662
|
})
|
|
664
663
|
}))));
|
|
665
664
|
}), tt = (e) => {
|
|
666
665
|
const { value: t, ...n } = e, r = E(null), i = Ke(t);
|
|
667
|
-
return
|
|
666
|
+
return B(() => {
|
|
668
667
|
const o = r.current, a = window.HTMLInputElement.prototype, l = Object.getOwnPropertyDescriptor(a, "value").set;
|
|
669
668
|
if (i !== t && l) {
|
|
670
669
|
const u = new Event("input", {
|