@purpurds/slider 8.2.2 → 8.2.3

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/slider.es.js CHANGED
@@ -1,73 +1,73 @@
1
- import { jsx as g, Fragment as be, jsxs as Q } from "react/jsx-runtime";
2
- import * as a from "react";
3
- import E, { forwardRef as ye, useId as we } from "react";
1
+ import { jsx as S, jsxs as J } from "react/jsx-runtime";
2
+ import * as l from "react";
3
+ import D, { forwardRef as ge, useId as be } from "react";
4
4
  import "react-dom";
5
- function ee(e, [t, n]) {
5
+ function Q(e, [t, n]) {
6
6
  return Math.min(n, Math.max(t, e));
7
7
  }
8
- function I(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
8
+ function N(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
9
9
  return function(i) {
10
10
  if (e == null || e(i), n === !1 || !i.defaultPrevented)
11
11
  return t == null ? void 0 : t(i);
12
12
  };
13
13
  }
14
- function Z(e, t) {
14
+ function G(e, t) {
15
15
  if (typeof e == "function")
16
16
  return e(t);
17
17
  e != null && (e.current = t);
18
18
  }
19
- function te(...e) {
19
+ function ee(...e) {
20
20
  return (t) => {
21
21
  let n = !1;
22
22
  const o = e.map((i) => {
23
- const r = Z(i, t);
23
+ const r = G(i, t);
24
24
  return !n && typeof r == "function" && (n = !0), r;
25
25
  });
26
26
  if (n)
27
27
  return () => {
28
28
  for (let i = 0; i < o.length; i++) {
29
29
  const r = o[i];
30
- typeof r == "function" ? r() : Z(e[i], null);
30
+ typeof r == "function" ? r() : G(e[i], null);
31
31
  }
32
32
  };
33
33
  };
34
34
  }
35
- function D(...e) {
36
- return a.useCallback(te(...e), e);
35
+ function I(...e) {
36
+ return l.useCallback(ee(...e), e);
37
37
  }
38
- function ne(e, t = []) {
38
+ function te(e, t = []) {
39
39
  let n = [];
40
40
  function o(r, s) {
41
- const c = a.createContext(s), u = n.length;
41
+ const c = l.createContext(s), u = n.length;
42
42
  n = [...n, s];
43
- const d = (l) => {
44
- var p;
45
- const { scope: f, children: v, ...m } = l, h = ((p = f == null ? void 0 : f[e]) == null ? void 0 : p[u]) || c, S = a.useMemo(() => m, Object.values(m));
46
- return /* @__PURE__ */ g(h.Provider, { value: S, children: v });
43
+ const d = (a) => {
44
+ var h;
45
+ const { scope: f, children: y, ..._ } = a, m = ((h = f == null ? void 0 : f[e]) == null ? void 0 : h[u]) || c, p = l.useMemo(() => _, Object.values(_));
46
+ return /* @__PURE__ */ S(m.Provider, { value: p, children: y });
47
47
  };
48
48
  d.displayName = r + "Provider";
49
- function y(l, f) {
50
- var h;
51
- const v = ((h = f == null ? void 0 : f[e]) == null ? void 0 : h[u]) || c, m = a.useContext(v);
52
- if (m) return m;
49
+ function g(a, f) {
50
+ var m;
51
+ const y = ((m = f == null ? void 0 : f[e]) == null ? void 0 : m[u]) || c, _ = l.useContext(y);
52
+ if (_) return _;
53
53
  if (s !== void 0) return s;
54
- throw new Error(`\`${l}\` must be used within \`${r}\``);
54
+ throw new Error(`\`${a}\` must be used within \`${r}\``);
55
55
  }
56
- return [d, y];
56
+ return [d, g];
57
57
  }
58
58
  const i = () => {
59
- const r = n.map((s) => a.createContext(s));
59
+ const r = n.map((s) => l.createContext(s));
60
60
  return function(c) {
61
61
  const u = (c == null ? void 0 : c[e]) || r;
62
- return a.useMemo(
62
+ return l.useMemo(
63
63
  () => ({ [`__scope${e}`]: { ...c, [e]: u } }),
64
64
  [c, u]
65
65
  );
66
66
  };
67
67
  };
68
- return i.scopeName = e, [o, Ce(i, ...t)];
68
+ return i.scopeName = e, [o, ye(i, ...t)];
69
69
  }
70
- function Ce(...e) {
70
+ function ye(...e) {
71
71
  const t = e[0];
72
72
  if (e.length === 1) return t;
73
73
  const n = () => {
@@ -77,19 +77,19 @@ function Ce(...e) {
77
77
  }));
78
78
  return function(r) {
79
79
  const s = o.reduce((c, { useScope: u, scopeName: d }) => {
80
- const l = u(r)[`__scope${d}`];
81
- return { ...c, ...l };
80
+ const a = u(r)[`__scope${d}`];
81
+ return { ...c, ...a };
82
82
  }, {});
83
- return a.useMemo(() => ({ [`__scope${t.scopeName}`]: s }), [s]);
83
+ return l.useMemo(() => ({ [`__scope${t.scopeName}`]: s }), [s]);
84
84
  };
85
85
  };
86
86
  return n.scopeName = t.scopeName, n;
87
87
  }
88
- function re(e) {
89
- const t = a.useRef(e);
90
- return a.useEffect(() => {
88
+ function ne(e) {
89
+ const t = l.useRef(e);
90
+ return l.useEffect(() => {
91
91
  t.current = e;
92
- }), a.useMemo(() => (...n) => {
92
+ }), l.useMemo(() => (...n) => {
93
93
  var o;
94
94
  return (o = t.current) == null ? void 0 : o.call(t, ...n);
95
95
  }, []);
@@ -100,11 +100,11 @@ function _e({
100
100
  onChange: n = () => {
101
101
  }
102
102
  }) {
103
- const [o, i] = Re({ defaultProp: t, onChange: n }), r = e !== void 0, s = r ? e : o, c = re(n), u = a.useCallback(
103
+ const [o, i] = Ce({ defaultProp: t, onChange: n }), r = e !== void 0, s = r ? e : o, c = ne(n), u = l.useCallback(
104
104
  (d) => {
105
105
  if (r) {
106
- const l = typeof d == "function" ? d(e) : d;
107
- l !== e && c(l);
106
+ const a = typeof d == "function" ? d(e) : d;
107
+ a !== e && c(a);
108
108
  } else
109
109
  i(d);
110
110
  },
@@ -112,29 +112,29 @@ function _e({
112
112
  );
113
113
  return [s, u];
114
114
  }
115
- function Re({
115
+ function Ce({
116
116
  defaultProp: e,
117
117
  onChange: t
118
118
  }) {
119
- const n = a.useState(e), [o] = n, i = a.useRef(o), r = re(t);
120
- return a.useEffect(() => {
119
+ const n = l.useState(e), [o] = n, i = l.useRef(o), r = ne(t);
120
+ return l.useEffect(() => {
121
121
  i.current !== o && (r(o), i.current = o);
122
122
  }, [o, i, r]), n;
123
123
  }
124
- var xe = a.createContext(void 0);
125
- function Pe(e) {
126
- const t = a.useContext(xe);
124
+ var we = l.createContext(void 0);
125
+ function xe(e) {
126
+ const t = l.useContext(we);
127
127
  return e || t || "ltr";
128
128
  }
129
- function Ee(e) {
130
- const t = a.useRef({ value: e, previous: e });
131
- return a.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]);
129
+ function Re(e) {
130
+ const t = l.useRef({ value: e, previous: e });
131
+ return l.useMemo(() => (t.current.value !== e && (t.current.previous = t.current.value, t.current.value = e), t.current.previous), [e]);
132
132
  }
133
- var De = globalThis != null && globalThis.document ? a.useLayoutEffect : () => {
133
+ var Pe = globalThis != null && globalThis.document ? l.useLayoutEffect : () => {
134
134
  };
135
- function Me(e) {
136
- const [t, n] = a.useState(void 0);
137
- return De(() => {
135
+ function Ee(e) {
136
+ const [t, n] = l.useState(void 0);
137
+ return Pe(() => {
138
138
  if (e) {
139
139
  n({ width: e.offsetWidth, height: e.offsetHeight });
140
140
  const o = new ResizeObserver((i) => {
@@ -154,29 +154,35 @@ function Me(e) {
154
154
  n(void 0);
155
155
  }, [e]), t;
156
156
  }
157
- var B = a.forwardRef((e, t) => {
158
- const { children: n, ...o } = e, i = a.Children.toArray(n), r = i.find(Ie);
159
- if (r) {
160
- const s = r.props.children, c = i.map((u) => u === r ? a.Children.count(s) > 1 ? a.Children.only(null) : a.isValidElement(s) ? s.props.children : null : u);
161
- return /* @__PURE__ */ g(H, { ...o, ref: t, children: a.isValidElement(s) ? a.cloneElement(s, void 0, c) : null });
162
- }
163
- return /* @__PURE__ */ g(H, { ...o, ref: t, children: n });
164
- });
165
- B.displayName = "Slot";
166
- var H = a.forwardRef((e, t) => {
167
- const { children: n, ...o } = e;
168
- if (a.isValidElement(n)) {
169
- const i = Oe(n), r = Ne(o, n.props);
170
- return n.type !== a.Fragment && (r.ref = t ? te(t, i) : i), a.cloneElement(n, r);
171
- }
172
- return a.Children.count(n) > 1 ? a.Children.only(null) : null;
173
- });
174
- H.displayName = "SlotClone";
175
- var Ae = ({ children: e }) => /* @__PURE__ */ g(be, { children: e });
176
- function Ie(e) {
177
- return a.isValidElement(e) && e.type === Ae;
157
+ // @__NO_SIDE_EFFECTS__
158
+ function F(e) {
159
+ const t = /* @__PURE__ */ De(e), n = l.forwardRef((o, i) => {
160
+ const { children: r, ...s } = o, c = l.Children.toArray(r), u = c.find(Me);
161
+ if (u) {
162
+ const d = u.props.children, g = c.map((a) => a === u ? l.Children.count(d) > 1 ? l.Children.only(null) : l.isValidElement(d) ? d.props.children : null : a);
163
+ return /* @__PURE__ */ S(t, { ...s, ref: i, children: l.isValidElement(d) ? l.cloneElement(d, void 0, g) : null });
164
+ }
165
+ return /* @__PURE__ */ S(t, { ...s, ref: i, children: r });
166
+ });
167
+ return n.displayName = `${e}.Slot`, n;
178
168
  }
179
- function Ne(e, t) {
169
+ // @__NO_SIDE_EFFECTS__
170
+ function De(e) {
171
+ const t = l.forwardRef((n, o) => {
172
+ const { children: i, ...r } = n;
173
+ if (l.isValidElement(i)) {
174
+ const s = Ne(i), c = Ae(r, i.props);
175
+ return i.type !== l.Fragment && (c.ref = o ? ee(o, s) : s), l.cloneElement(i, c);
176
+ }
177
+ return l.Children.count(i) > 1 ? l.Children.only(null) : null;
178
+ });
179
+ return t.displayName = `${e}.SlotClone`, t;
180
+ }
181
+ var Ie = Symbol("radix.slottable");
182
+ function Me(e) {
183
+ return l.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === Ie;
184
+ }
185
+ function Ae(e, t) {
180
186
  const n = { ...t };
181
187
  for (const o in t) {
182
188
  const i = e[o], r = t[o];
@@ -186,12 +192,12 @@ function Ne(e, t) {
186
192
  }
187
193
  return { ...e, ...n };
188
194
  }
189
- function Oe(e) {
195
+ function Ne(e) {
190
196
  var o, i;
191
197
  let t = (o = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : o.get, n = t && "isReactWarning" in t && t.isReactWarning;
192
198
  return n ? e.ref : (t = (i = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : i.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
193
199
  }
194
- var Te = [
200
+ var Oe = [
195
201
  "a",
196
202
  "button",
197
203
  "div",
@@ -208,61 +214,61 @@ var Te = [
208
214
  "span",
209
215
  "svg",
210
216
  "ul"
211
- ], z = Te.reduce((e, t) => {
212
- const n = a.forwardRef((o, i) => {
213
- const { asChild: r, ...s } = o, c = r ? B : t;
214
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...s, ref: i });
217
+ ], K = Oe.reduce((e, t) => {
218
+ const n = /* @__PURE__ */ F(`Primitive.${t}`), o = l.forwardRef((i, r) => {
219
+ const { asChild: s, ...c } = i, u = s ? n : t;
220
+ return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ S(u, { ...c, ref: r });
215
221
  });
216
- return n.displayName = `Primitive.${t}`, { ...e, [t]: n };
222
+ return o.displayName = `Primitive.${t}`, { ...e, [t]: o };
217
223
  }, {});
218
- function Ve(e) {
219
- const t = e + "CollectionProvider", [n, o] = ne(t), [i, r] = n(
224
+ function Te(e) {
225
+ const t = e + "CollectionProvider", [n, o] = te(t), [i, r] = n(
220
226
  t,
221
227
  { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
222
- ), s = (v) => {
223
- const { scope: m, children: h } = v, S = E.useRef(null), p = E.useRef(/* @__PURE__ */ new Map()).current;
224
- return /* @__PURE__ */ g(i, { scope: m, itemMap: p, collectionRef: S, children: h });
228
+ ), s = (m) => {
229
+ const { scope: p, children: h } = m, C = D.useRef(null), b = D.useRef(/* @__PURE__ */ new Map()).current;
230
+ return /* @__PURE__ */ S(i, { scope: p, itemMap: b, collectionRef: C, children: h });
225
231
  };
226
232
  s.displayName = t;
227
- const c = e + "CollectionSlot", u = E.forwardRef(
228
- (v, m) => {
229
- const { scope: h, children: S } = v, p = r(c, h), C = D(m, p.collectionRef);
230
- return /* @__PURE__ */ g(B, { ref: C, children: S });
233
+ const c = e + "CollectionSlot", u = /* @__PURE__ */ F(c), d = D.forwardRef(
234
+ (m, p) => {
235
+ const { scope: h, children: C } = m, b = r(c, h), v = I(p, b.collectionRef);
236
+ return /* @__PURE__ */ S(u, { ref: v, children: C });
231
237
  }
232
238
  );
233
- u.displayName = c;
234
- const d = e + "CollectionItemSlot", y = "data-radix-collection-item", l = E.forwardRef(
235
- (v, m) => {
236
- const { scope: h, children: S, ...p } = v, C = E.useRef(null), w = D(m, C), b = r(d, h);
237
- return E.useEffect(() => (b.itemMap.set(C, { ref: C, ...p }), () => void b.itemMap.delete(C))), /* @__PURE__ */ g(B, { [y]: "", ref: w, children: S });
239
+ d.displayName = c;
240
+ const g = e + "CollectionItemSlot", a = "data-radix-collection-item", f = /* @__PURE__ */ F(g), y = D.forwardRef(
241
+ (m, p) => {
242
+ const { scope: h, children: C, ...b } = m, v = D.useRef(null), x = I(p, v), R = r(g, h);
243
+ return D.useEffect(() => (R.itemMap.set(v, { ref: v, ...b }), () => void R.itemMap.delete(v))), /* @__PURE__ */ S(f, { [a]: "", ref: x, children: C });
238
244
  }
239
245
  );
240
- l.displayName = d;
241
- function f(v) {
242
- const m = r(e + "CollectionConsumer", v);
243
- return E.useCallback(() => {
244
- const S = m.collectionRef.current;
245
- if (!S) return [];
246
- const p = Array.from(S.querySelectorAll(`[${y}]`));
247
- return Array.from(m.itemMap.values()).sort(
248
- (b, R) => p.indexOf(b.ref.current) - p.indexOf(R.ref.current)
246
+ y.displayName = g;
247
+ function _(m) {
248
+ const p = r(e + "CollectionConsumer", m);
249
+ return D.useCallback(() => {
250
+ const C = p.collectionRef.current;
251
+ if (!C) return [];
252
+ const b = Array.from(C.querySelectorAll(`[${a}]`));
253
+ return Array.from(p.itemMap.values()).sort(
254
+ (R, T) => b.indexOf(R.ref.current) - b.indexOf(T.ref.current)
249
255
  );
250
- }, [m.collectionRef, m.itemMap]);
256
+ }, [p.collectionRef, p.itemMap]);
251
257
  }
252
258
  return [
253
- { Provider: s, Slot: u, ItemSlot: l },
254
- f,
259
+ { Provider: s, Slot: d, ItemSlot: y },
260
+ _,
255
261
  o
256
262
  ];
257
263
  }
258
- var oe = ["PageUp", "PageDown"], ie = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], se = {
264
+ var re = ["PageUp", "PageDown"], oe = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"], ie = {
259
265
  "from-left": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
260
266
  "from-right": ["Home", "PageDown", "ArrowDown", "ArrowRight"],
261
267
  "from-bottom": ["Home", "PageDown", "ArrowDown", "ArrowLeft"],
262
268
  "from-top": ["Home", "PageDown", "ArrowUp", "ArrowLeft"]
263
- }, N = "Slider", [W, ke, Be] = Ve(N), [ce, ft] = ne(N, [
264
- Be
265
- ]), [ze, K] = ce(N), ae = a.forwardRef(
269
+ }, O = "Slider", [H, Ve, ke] = Te(O), [se] = te(O, [
270
+ ke
271
+ ]), [Be, L] = se(O), ce = l.forwardRef(
266
272
  (e, t) => {
267
273
  const {
268
274
  name: n,
@@ -273,80 +279,80 @@ var oe = ["PageUp", "PageDown"], ie = ["ArrowUp", "ArrowDown", "ArrowLeft", "Arr
273
279
  disabled: c = !1,
274
280
  minStepsBetweenThumbs: u = 0,
275
281
  defaultValue: d = [o],
276
- value: y,
277
- onValueChange: l = () => {
282
+ value: g,
283
+ onValueChange: a = () => {
278
284
  },
279
285
  onValueCommit: f = () => {
280
286
  },
281
- inverted: v = !1,
282
- form: m,
283
- ...h
284
- } = e, S = a.useRef(/* @__PURE__ */ new Set()), p = a.useRef(0), w = s === "horizontal" ? Ke : Le, [b = [], R] = _e({
285
- prop: y,
287
+ inverted: y = !1,
288
+ form: _,
289
+ ...m
290
+ } = e, p = l.useRef(/* @__PURE__ */ new Set()), h = l.useRef(0), b = s === "horizontal" ? ze : Ke, [v = [], x] = _e({
291
+ prop: g,
286
292
  defaultProp: d,
287
- onChange: (_) => {
293
+ onChange: (w) => {
288
294
  var M;
289
- (M = [...S.current][p.current]) == null || M.focus(), l(_);
295
+ (M = [...p.current][h.current]) == null || M.focus(), a(w);
290
296
  }
291
- }), L = a.useRef(b);
292
- function $(_) {
293
- const x = We(b, _);
294
- O(_, x);
297
+ }), R = l.useRef(v);
298
+ function T(w) {
299
+ const P = He(v, w);
300
+ V(w, P);
295
301
  }
296
- function ve(_) {
297
- O(_, p.current);
302
+ function Se(w) {
303
+ V(w, h.current);
298
304
  }
299
- function ge() {
300
- const _ = L.current[p.current];
301
- b[p.current] !== _ && f(b);
305
+ function ve() {
306
+ const w = R.current[h.current];
307
+ v[h.current] !== w && f(v);
302
308
  }
303
- function O(_, x, { commit: M } = { commit: !1 }) {
304
- const X = Xe(r), j = Ge(Math.round((_ - o) / r) * r + o, X), T = ee(j, [o, i]);
305
- R((A = []) => {
306
- const P = Fe(A, T, x);
307
- if (qe(P, u * r)) {
308
- p.current = P.indexOf(T);
309
- const G = String(P) !== String(A);
310
- return G && M && f(P), G ? P : A;
309
+ function V(w, P, { commit: M } = { commit: !1 }) {
310
+ const q = qe(r), $ = Xe(Math.round((w - o) / r) * r + o, q), k = Q($, [o, i]);
311
+ x((A = []) => {
312
+ const E = je(A, k, P);
313
+ if (Ye(E, u * r)) {
314
+ h.current = E.indexOf(k);
315
+ const X = String(E) !== String(A);
316
+ return X && M && f(E), X ? E : A;
311
317
  } else
312
318
  return A;
313
319
  });
314
320
  }
315
- return /* @__PURE__ */ g(
316
- ze,
321
+ return /* @__PURE__ */ S(
322
+ Be,
317
323
  {
318
324
  scope: e.__scopeSlider,
319
325
  name: n,
320
326
  disabled: c,
321
327
  min: o,
322
328
  max: i,
323
- valueIndexToChangeRef: p,
324
- thumbs: S.current,
325
- values: b,
329
+ valueIndexToChangeRef: h,
330
+ thumbs: p.current,
331
+ values: v,
326
332
  orientation: s,
327
- form: m,
328
- children: /* @__PURE__ */ g(W.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ g(W.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ g(
329
- w,
333
+ form: _,
334
+ children: /* @__PURE__ */ S(H.Provider, { scope: e.__scopeSlider, children: /* @__PURE__ */ S(H.Slot, { scope: e.__scopeSlider, children: /* @__PURE__ */ S(
335
+ b,
330
336
  {
331
337
  "aria-disabled": c,
332
338
  "data-disabled": c ? "" : void 0,
333
- ...h,
339
+ ...m,
334
340
  ref: t,
335
- onPointerDown: I(h.onPointerDown, () => {
336
- c || (L.current = b);
341
+ onPointerDown: N(m.onPointerDown, () => {
342
+ c || (R.current = v);
337
343
  }),
338
344
  min: o,
339
345
  max: i,
340
- inverted: v,
341
- onSlideStart: c ? void 0 : $,
342
- onSlideMove: c ? void 0 : ve,
343
- onSlideEnd: c ? void 0 : ge,
344
- onHomeKeyDown: () => !c && O(o, 0, { commit: !0 }),
345
- onEndKeyDown: () => !c && O(i, b.length - 1, { commit: !0 }),
346
- onStepKeyDown: ({ event: _, direction: x }) => {
346
+ inverted: y,
347
+ onSlideStart: c ? void 0 : T,
348
+ onSlideMove: c ? void 0 : Se,
349
+ onSlideEnd: c ? void 0 : ve,
350
+ onHomeKeyDown: () => !c && V(o, 0, { commit: !0 }),
351
+ onEndKeyDown: () => !c && V(i, v.length - 1, { commit: !0 }),
352
+ onStepKeyDown: ({ event: w, direction: P }) => {
347
353
  if (!c) {
348
- const j = oe.includes(_.key) || _.shiftKey && ie.includes(_.key) ? 10 : 1, T = p.current, A = b[T], P = r * j * x;
349
- O(A + P, T, { commit: !0 });
354
+ const $ = re.includes(w.key) || w.shiftKey && oe.includes(w.key) ? 10 : 1, k = h.current, A = v[k], E = r * $ * P;
355
+ V(A + E, k, { commit: !0 });
350
356
  }
351
357
  }
352
358
  }
@@ -355,13 +361,13 @@ var oe = ["PageUp", "PageDown"], ie = ["ArrowUp", "ArrowDown", "ArrowLeft", "Arr
355
361
  );
356
362
  }
357
363
  );
358
- ae.displayName = N;
359
- var [le, ue] = ce(N, {
364
+ ce.displayName = O;
365
+ var [le, ae] = se(O, {
360
366
  startEdge: "left",
361
367
  endEdge: "right",
362
368
  size: "width",
363
369
  direction: 1
364
- }), Ke = a.forwardRef(
370
+ }), ze = l.forwardRef(
365
371
  (e, t) => {
366
372
  const {
367
373
  min: n,
@@ -372,52 +378,52 @@ var [le, ue] = ce(N, {
372
378
  onSlideMove: c,
373
379
  onSlideEnd: u,
374
380
  onStepKeyDown: d,
375
- ...y
376
- } = e, [l, f] = a.useState(null), v = D(t, (w) => f(w)), m = a.useRef(void 0), h = Pe(i), S = h === "ltr", p = S && !r || !S && r;
377
- function C(w) {
378
- const b = m.current || l.getBoundingClientRect(), R = [0, b.width], $ = q(R, p ? [n, o] : [o, n]);
379
- return m.current = b, $(w - b.left);
381
+ ...g
382
+ } = e, [a, f] = l.useState(null), y = I(t, (b) => f(b)), _ = l.useRef(void 0), m = xe(i), p = m === "ltr", h = p && !r || !p && r;
383
+ function C(b) {
384
+ const v = _.current || a.getBoundingClientRect(), x = [0, v.width], T = Y(x, h ? [n, o] : [o, n]);
385
+ return _.current = v, T(b - v.left);
380
386
  }
381
- return /* @__PURE__ */ g(
387
+ return /* @__PURE__ */ S(
382
388
  le,
383
389
  {
384
390
  scope: e.__scopeSlider,
385
- startEdge: p ? "left" : "right",
386
- endEdge: p ? "right" : "left",
387
- direction: p ? 1 : -1,
391
+ startEdge: h ? "left" : "right",
392
+ endEdge: h ? "right" : "left",
393
+ direction: h ? 1 : -1,
388
394
  size: "width",
389
- children: /* @__PURE__ */ g(
390
- de,
395
+ children: /* @__PURE__ */ S(
396
+ ue,
391
397
  {
392
- dir: h,
398
+ dir: m,
393
399
  "data-orientation": "horizontal",
394
- ...y,
395
- ref: v,
400
+ ...g,
401
+ ref: y,
396
402
  style: {
397
- ...y.style,
403
+ ...g.style,
398
404
  "--radix-slider-thumb-transform": "translateX(-50%)"
399
405
  },
400
- onSlideStart: (w) => {
401
- const b = C(w.clientX);
402
- s == null || s(b);
406
+ onSlideStart: (b) => {
407
+ const v = C(b.clientX);
408
+ s == null || s(v);
403
409
  },
404
- onSlideMove: (w) => {
405
- const b = C(w.clientX);
406
- c == null || c(b);
410
+ onSlideMove: (b) => {
411
+ const v = C(b.clientX);
412
+ c == null || c(v);
407
413
  },
408
414
  onSlideEnd: () => {
409
- m.current = void 0, u == null || u();
415
+ _.current = void 0, u == null || u();
410
416
  },
411
- onStepKeyDown: (w) => {
412
- const R = se[p ? "from-left" : "from-right"].includes(w.key);
413
- d == null || d({ event: w, direction: R ? -1 : 1 });
417
+ onStepKeyDown: (b) => {
418
+ const x = ie[h ? "from-left" : "from-right"].includes(b.key);
419
+ d == null || d({ event: b, direction: x ? -1 : 1 });
414
420
  }
415
421
  }
416
422
  )
417
423
  }
418
424
  );
419
425
  }
420
- ), Le = a.forwardRef(
426
+ ), Ke = l.forwardRef(
421
427
  (e, t) => {
422
428
  const {
423
429
  min: n,
@@ -428,50 +434,50 @@ var [le, ue] = ce(N, {
428
434
  onSlideEnd: c,
429
435
  onStepKeyDown: u,
430
436
  ...d
431
- } = e, y = a.useRef(null), l = D(t, y), f = a.useRef(void 0), v = !i;
432
- function m(h) {
433
- const S = f.current || y.current.getBoundingClientRect(), p = [0, S.height], w = q(p, v ? [o, n] : [n, o]);
434
- return f.current = S, w(h - S.top);
437
+ } = e, g = l.useRef(null), a = I(t, g), f = l.useRef(void 0), y = !i;
438
+ function _(m) {
439
+ const p = f.current || g.current.getBoundingClientRect(), h = [0, p.height], b = Y(h, y ? [o, n] : [n, o]);
440
+ return f.current = p, b(m - p.top);
435
441
  }
436
- return /* @__PURE__ */ g(
442
+ return /* @__PURE__ */ S(
437
443
  le,
438
444
  {
439
445
  scope: e.__scopeSlider,
440
- startEdge: v ? "bottom" : "top",
441
- endEdge: v ? "top" : "bottom",
446
+ startEdge: y ? "bottom" : "top",
447
+ endEdge: y ? "top" : "bottom",
442
448
  size: "height",
443
- direction: v ? 1 : -1,
444
- children: /* @__PURE__ */ g(
445
- de,
449
+ direction: y ? 1 : -1,
450
+ children: /* @__PURE__ */ S(
451
+ ue,
446
452
  {
447
453
  "data-orientation": "vertical",
448
454
  ...d,
449
- ref: l,
455
+ ref: a,
450
456
  style: {
451
457
  ...d.style,
452
458
  "--radix-slider-thumb-transform": "translateY(50%)"
453
459
  },
454
- onSlideStart: (h) => {
455
- const S = m(h.clientY);
456
- r == null || r(S);
460
+ onSlideStart: (m) => {
461
+ const p = _(m.clientY);
462
+ r == null || r(p);
457
463
  },
458
- onSlideMove: (h) => {
459
- const S = m(h.clientY);
460
- s == null || s(S);
464
+ onSlideMove: (m) => {
465
+ const p = _(m.clientY);
466
+ s == null || s(p);
461
467
  },
462
468
  onSlideEnd: () => {
463
469
  f.current = void 0, c == null || c();
464
470
  },
465
- onStepKeyDown: (h) => {
466
- const p = se[v ? "from-bottom" : "from-top"].includes(h.key);
467
- u == null || u({ event: h, direction: p ? -1 : 1 });
471
+ onStepKeyDown: (m) => {
472
+ const h = ie[y ? "from-bottom" : "from-top"].includes(m.key);
473
+ u == null || u({ event: m, direction: h ? -1 : 1 });
468
474
  }
469
475
  }
470
476
  )
471
477
  }
472
478
  );
473
479
  }
474
- ), de = a.forwardRef(
480
+ ), ue = l.forwardRef(
475
481
  (e, t) => {
476
482
  const {
477
483
  __scopeSlider: n,
@@ -482,34 +488,34 @@ var [le, ue] = ce(N, {
482
488
  onEndKeyDown: c,
483
489
  onStepKeyDown: u,
484
490
  ...d
485
- } = e, y = K(N, n);
486
- return /* @__PURE__ */ g(
487
- z.span,
491
+ } = e, g = L(O, n);
492
+ return /* @__PURE__ */ S(
493
+ K.span,
488
494
  {
489
495
  ...d,
490
496
  ref: t,
491
- onKeyDown: I(e.onKeyDown, (l) => {
492
- l.key === "Home" ? (s(l), l.preventDefault()) : l.key === "End" ? (c(l), l.preventDefault()) : oe.concat(ie).includes(l.key) && (u(l), l.preventDefault());
497
+ onKeyDown: N(e.onKeyDown, (a) => {
498
+ a.key === "Home" ? (s(a), a.preventDefault()) : a.key === "End" ? (c(a), a.preventDefault()) : re.concat(oe).includes(a.key) && (u(a), a.preventDefault());
493
499
  }),
494
- onPointerDown: I(e.onPointerDown, (l) => {
495
- const f = l.target;
496
- f.setPointerCapture(l.pointerId), l.preventDefault(), y.thumbs.has(f) ? f.focus() : o(l);
500
+ onPointerDown: N(e.onPointerDown, (a) => {
501
+ const f = a.target;
502
+ f.setPointerCapture(a.pointerId), a.preventDefault(), g.thumbs.has(f) ? f.focus() : o(a);
497
503
  }),
498
- onPointerMove: I(e.onPointerMove, (l) => {
499
- l.target.hasPointerCapture(l.pointerId) && i(l);
504
+ onPointerMove: N(e.onPointerMove, (a) => {
505
+ a.target.hasPointerCapture(a.pointerId) && i(a);
500
506
  }),
501
- onPointerUp: I(e.onPointerUp, (l) => {
502
- const f = l.target;
503
- f.hasPointerCapture(l.pointerId) && (f.releasePointerCapture(l.pointerId), r(l));
507
+ onPointerUp: N(e.onPointerUp, (a) => {
508
+ const f = a.target;
509
+ f.hasPointerCapture(a.pointerId) && (f.releasePointerCapture(a.pointerId), r(a));
504
510
  })
505
511
  }
506
512
  );
507
513
  }
508
- ), fe = "SliderTrack", pe = a.forwardRef(
514
+ ), de = "SliderTrack", fe = l.forwardRef(
509
515
  (e, t) => {
510
- const { __scopeSlider: n, ...o } = e, i = K(fe, n);
511
- return /* @__PURE__ */ g(
512
- z.span,
516
+ const { __scopeSlider: n, ...o } = e, i = L(de, n);
517
+ return /* @__PURE__ */ S(
518
+ K.span,
513
519
  {
514
520
  "data-disabled": i.disabled ? "" : void 0,
515
521
  "data-orientation": i.orientation,
@@ -519,14 +525,14 @@ var [le, ue] = ce(N, {
519
525
  );
520
526
  }
521
527
  );
522
- pe.displayName = fe;
523
- var U = "SliderRange", me = a.forwardRef(
528
+ fe.displayName = de;
529
+ var W = "SliderRange", pe = l.forwardRef(
524
530
  (e, t) => {
525
- const { __scopeSlider: n, ...o } = e, i = K(U, n), r = ue(U, n), s = a.useRef(null), c = D(t, s), u = i.values.length, d = i.values.map(
526
- (f) => Se(f, i.min, i.max)
527
- ), y = u > 1 ? Math.min(...d) : 0, l = 100 - Math.max(...d);
528
- return /* @__PURE__ */ g(
529
- z.span,
531
+ const { __scopeSlider: n, ...o } = e, i = L(W, n), r = ae(W, n), s = l.useRef(null), c = I(t, s), u = i.values.length, d = i.values.map(
532
+ (f) => he(f, i.min, i.max)
533
+ ), g = u > 1 ? Math.min(...d) : 0, a = 100 - Math.max(...d);
534
+ return /* @__PURE__ */ S(
535
+ K.span,
530
536
  {
531
537
  "data-orientation": i.orientation,
532
538
  "data-disabled": i.disabled ? "" : void 0,
@@ -534,65 +540,65 @@ var U = "SliderRange", me = a.forwardRef(
534
540
  ref: c,
535
541
  style: {
536
542
  ...e.style,
537
- [r.startEdge]: y + "%",
538
- [r.endEdge]: l + "%"
543
+ [r.startEdge]: g + "%",
544
+ [r.endEdge]: a + "%"
539
545
  }
540
546
  }
541
547
  );
542
548
  }
543
549
  );
544
- me.displayName = U;
545
- var Y = "SliderThumb", he = a.forwardRef(
550
+ pe.displayName = W;
551
+ var U = "SliderThumb", me = l.forwardRef(
546
552
  (e, t) => {
547
- const n = ke(e.__scopeSlider), [o, i] = a.useState(null), r = D(t, (c) => i(c)), s = a.useMemo(
553
+ const n = Ve(e.__scopeSlider), [o, i] = l.useState(null), r = I(t, (c) => i(c)), s = l.useMemo(
548
554
  () => o ? n().findIndex((c) => c.ref.current === o) : -1,
549
555
  [n, o]
550
556
  );
551
- return /* @__PURE__ */ g($e, { ...e, ref: r, index: s });
557
+ return /* @__PURE__ */ S(Le, { ...e, ref: r, index: s });
552
558
  }
553
- ), $e = a.forwardRef(
559
+ ), Le = l.forwardRef(
554
560
  (e, t) => {
555
- const { __scopeSlider: n, index: o, name: i, ...r } = e, s = K(Y, n), c = ue(Y, n), [u, d] = a.useState(null), y = D(t, (C) => d(C)), l = u ? s.form || !!u.closest("form") : !0, f = Me(u), v = s.values[o], m = v === void 0 ? 0 : Se(v, s.min, s.max), h = He(o, s.values.length), S = f == null ? void 0 : f[c.size], p = S ? Ue(S, m, c.direction) : 0;
556
- return a.useEffect(() => {
561
+ const { __scopeSlider: n, index: o, name: i, ...r } = e, s = L(U, n), c = ae(U, n), [u, d] = l.useState(null), g = I(t, (C) => d(C)), a = u ? s.form || !!u.closest("form") : !0, f = Ee(u), y = s.values[o], _ = y === void 0 ? 0 : he(y, s.min, s.max), m = Fe(o, s.values.length), p = f == null ? void 0 : f[c.size], h = p ? We(p, _, c.direction) : 0;
562
+ return l.useEffect(() => {
557
563
  if (u)
558
564
  return s.thumbs.add(u), () => {
559
565
  s.thumbs.delete(u);
560
566
  };
561
- }, [u, s.thumbs]), /* @__PURE__ */ Q(
567
+ }, [u, s.thumbs]), /* @__PURE__ */ J(
562
568
  "span",
563
569
  {
564
570
  style: {
565
571
  transform: "var(--radix-slider-thumb-transform)",
566
572
  position: "absolute",
567
- [c.startEdge]: `calc(${m}% + ${p}px)`
573
+ [c.startEdge]: `calc(${_}% + ${h}px)`
568
574
  },
569
575
  children: [
570
- /* @__PURE__ */ g(W.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ g(
571
- z.span,
576
+ /* @__PURE__ */ S(H.ItemSlot, { scope: e.__scopeSlider, children: /* @__PURE__ */ S(
577
+ K.span,
572
578
  {
573
579
  role: "slider",
574
- "aria-label": e["aria-label"] || h,
580
+ "aria-label": e["aria-label"] || m,
575
581
  "aria-valuemin": s.min,
576
- "aria-valuenow": v,
582
+ "aria-valuenow": y,
577
583
  "aria-valuemax": s.max,
578
584
  "aria-orientation": s.orientation,
579
585
  "data-orientation": s.orientation,
580
586
  "data-disabled": s.disabled ? "" : void 0,
581
587
  tabIndex: s.disabled ? void 0 : 0,
582
588
  ...r,
583
- ref: y,
584
- style: v === void 0 ? { display: "none" } : e.style,
585
- onFocus: I(e.onFocus, () => {
589
+ ref: g,
590
+ style: y === void 0 ? { display: "none" } : e.style,
591
+ onFocus: N(e.onFocus, () => {
586
592
  s.valueIndexToChangeRef.current = o;
587
593
  })
588
594
  }
589
595
  ) }),
590
- l && /* @__PURE__ */ g(
591
- je,
596
+ a && /* @__PURE__ */ S(
597
+ $e,
592
598
  {
593
599
  name: i ?? (s.name ? s.name + (s.values.length > 1 ? "[]" : "") : void 0),
594
600
  form: s.form,
595
- value: v
601
+ value: y
596
602
  },
597
603
  o
598
604
  )
@@ -601,74 +607,74 @@ var Y = "SliderThumb", he = a.forwardRef(
601
607
  );
602
608
  }
603
609
  );
604
- he.displayName = Y;
605
- var je = (e) => {
606
- const { value: t, ...n } = e, o = a.useRef(null), i = Ee(t);
607
- return a.useEffect(() => {
610
+ me.displayName = U;
611
+ var $e = (e) => {
612
+ const { value: t, ...n } = e, o = l.useRef(null), i = Re(t);
613
+ return l.useEffect(() => {
608
614
  const r = o.current, s = window.HTMLInputElement.prototype, u = Object.getOwnPropertyDescriptor(s, "value").set;
609
615
  if (i !== t && u) {
610
616
  const d = new Event("input", { bubbles: !0 });
611
617
  u.call(r, t), r.dispatchEvent(d);
612
618
  }
613
- }, [i, t]), /* @__PURE__ */ g("input", { style: { display: "none" }, ...n, ref: o, defaultValue: t });
619
+ }, [i, t]), /* @__PURE__ */ S("input", { style: { display: "none" }, ...n, ref: o, defaultValue: t });
614
620
  };
615
- function Fe(e = [], t, n) {
621
+ function je(e = [], t, n) {
616
622
  const o = [...e];
617
623
  return o[n] = t, o.sort((i, r) => i - r);
618
624
  }
619
- function Se(e, t, n) {
625
+ function he(e, t, n) {
620
626
  const r = 100 / (n - t) * (e - t);
621
- return ee(r, [0, 100]);
627
+ return Q(r, [0, 100]);
622
628
  }
623
- function He(e, t) {
629
+ function Fe(e, t) {
624
630
  return t > 2 ? `Value ${e + 1} of ${t}` : t === 2 ? ["Minimum", "Maximum"][e] : void 0;
625
631
  }
626
- function We(e, t) {
632
+ function He(e, t) {
627
633
  if (e.length === 1) return 0;
628
634
  const n = e.map((i) => Math.abs(i - t)), o = Math.min(...n);
629
635
  return n.indexOf(o);
630
636
  }
631
- function Ue(e, t, n) {
632
- const o = e / 2, r = q([0, 50], [0, o]);
637
+ function We(e, t, n) {
638
+ const o = e / 2, r = Y([0, 50], [0, o]);
633
639
  return (o - r(t) * n) * n;
634
640
  }
635
- function Ye(e) {
641
+ function Ue(e) {
636
642
  return e.slice(0, -1).map((t, n) => e[n + 1] - t);
637
643
  }
638
- function qe(e, t) {
644
+ function Ye(e, t) {
639
645
  if (t > 0) {
640
- const n = Ye(e);
646
+ const n = Ue(e);
641
647
  return Math.min(...n) >= t;
642
648
  }
643
649
  return !0;
644
650
  }
645
- function q(e, t) {
651
+ function Y(e, t) {
646
652
  return (n) => {
647
653
  if (e[0] === e[1] || t[0] === t[1]) return t[0];
648
654
  const o = (t[1] - t[0]) / (e[1] - e[0]);
649
655
  return t[0] + o * (n - e[0]);
650
656
  };
651
657
  }
652
- function Xe(e) {
658
+ function qe(e) {
653
659
  return (String(e).split(".")[1] || "").length;
654
660
  }
655
- function Ge(e, t) {
661
+ function Xe(e, t) {
656
662
  const n = Math.pow(10, t);
657
663
  return Math.round(e * n) / n;
658
664
  }
659
- var Ze = ae, Je = pe, Qe = me, et = he;
660
- function tt(e) {
665
+ var Ge = ce, Ze = fe, Je = pe, Qe = me;
666
+ function et(e) {
661
667
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
662
668
  }
663
- var F = { exports: {} };
669
+ var j = { exports: {} };
664
670
  /*!
665
671
  Copyright (c) 2018 Jed Watson.
666
672
  Licensed under the MIT License (MIT), see
667
673
  http://jedwatson.github.io/classnames
668
674
  */
669
- var J;
670
- function nt() {
671
- return J || (J = 1, function(e) {
675
+ var Z;
676
+ function tt() {
677
+ return Z || (Z = 1, (function(e) {
672
678
  (function() {
673
679
  var t = {}.hasOwnProperty;
674
680
  function n() {
@@ -697,15 +703,15 @@ function nt() {
697
703
  }
698
704
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
699
705
  })();
700
- }(F)), F.exports;
706
+ })(j)), j.exports;
701
707
  }
702
- var rt = nt();
703
- const ot = /* @__PURE__ */ tt(rt), it = {
708
+ var nt = tt();
709
+ const rt = /* @__PURE__ */ et(nt), ot = {
704
710
  "purpur-slider": "_purpur-slider_14tuk_1",
705
711
  "purpur-slider__track": "_purpur-slider__track_14tuk_17",
706
712
  "purpur-slider__range": "_purpur-slider__range_14tuk_17",
707
713
  "purpur-slider__thumb": "_purpur-slider__thumb_14tuk_43"
708
- }, V = ot.bind(it), pt = ["horizontal", "vertical"], k = "purpur-slider", st = (e) => String(e), ct = ({
714
+ }, B = rt.bind(ot), dt = ["horizontal", "vertical"], z = "purpur-slider", it = (e) => String(e), st = ({
709
715
  "aria-label": e,
710
716
  "aria-valuetext": t,
711
717
  className: n,
@@ -714,34 +720,34 @@ const ot = /* @__PURE__ */ tt(rt), it = {
714
720
  value: r,
715
721
  ...s
716
722
  }, c) => {
717
- const u = we(), d = r || o;
718
- return /* @__PURE__ */ Q(
719
- Ze,
723
+ const u = be(), d = r || o;
724
+ return /* @__PURE__ */ J(
725
+ Ge,
720
726
  {
721
727
  ...s,
722
728
  id: i || u,
723
729
  ref: c,
724
- className: V(k, n),
730
+ className: B(z, n),
725
731
  value: r,
726
732
  defaultValue: o,
727
733
  children: [
728
- /* @__PURE__ */ g(Je, { className: V(`${k}__track`), children: /* @__PURE__ */ g(Qe, { className: V(`${k}__range`) }) }),
729
- d == null ? void 0 : d.map((y, l) => /* @__PURE__ */ g(
730
- et,
734
+ /* @__PURE__ */ S(Ze, { className: B(`${z}__track`), children: /* @__PURE__ */ S(Je, { className: B(`${z}__range`) }) }),
735
+ d == null ? void 0 : d.map((g, a) => /* @__PURE__ */ S(
736
+ Qe,
731
737
  {
732
- className: V(`${k}__thumb`),
738
+ className: B(`${z}__thumb`),
733
739
  "aria-label": e,
734
740
  "aria-valuetext": t
735
741
  },
736
- st(l)
742
+ it(a)
737
743
  ))
738
744
  ]
739
745
  }
740
746
  );
741
- }, at = ye(ct);
742
- at.displayName = "Slider";
747
+ }, ct = ge(st);
748
+ ct.displayName = "Slider";
743
749
  export {
744
- pt as SLIDER_ORIENTATION,
745
- at as Slider
750
+ dt as SLIDER_ORIENTATION,
751
+ ct as Slider
746
752
  };
747
753
  //# sourceMappingURL=slider.es.js.map