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