@purpurds/toggle 8.19.0 → 8.20.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/toggle.es.js CHANGED
@@ -1,13 +1,13 @@
1
- import { jsx as g, jsxs as N } from "react/jsx-runtime";
1
+ import { jsx as g, jsxs as O } from "react/jsx-runtime";
2
2
  import * as s from "react";
3
- import { useState as C, useCallback as O, useEffect as E, cloneElement as ie, isValidElement as ae, useRef as z, forwardRef as ue } from "react";
3
+ import { useState as C, useCallback as A, useEffect as E, cloneElement as ue, isValidElement as se, useRef as z, forwardRef as ce } from "react";
4
4
  import "react-dom";
5
- function se(e) {
5
+ function le(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
7
  }
8
- var M = { exports: {} }, j;
9
- function ce() {
10
- return j || (j = 1, (function(e) {
8
+ var j = { exports: {} }, q;
9
+ function pe() {
10
+ return q || (q = 1, (function(e) {
11
11
  (function() {
12
12
  var n = {}.hasOwnProperty;
13
13
  function t() {
@@ -36,10 +36,10 @@ function ce() {
36
36
  }
37
37
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
38
38
  })();
39
- })(M)), M.exports;
39
+ })(j)), j.exports;
40
40
  }
41
- var le = ce();
42
- const pe = /* @__PURE__ */ se(le), de = {
41
+ var de = pe();
42
+ const fe = /* @__PURE__ */ le(de), he = {
43
43
  "purpur-icon": "_purpur-icon_8u1lq_1",
44
44
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
45
45
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -47,53 +47,62 @@ const pe = /* @__PURE__ */ se(le), de = {
47
47
  "purpur-icon--md": "_purpur-icon--md_8u1lq_16",
48
48
  "purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
49
49
  "purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
50
- }, fe = pe.bind(de), q = "purpur-icon", he = "md", ge = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), ve = ({ content: e = "", title: n } = {}) => {
50
+ }, ge = fe.bind(he), B = "purpur-icon", ve = "md", _e = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), me = ({ content: e = "", title: n } = {}) => {
51
51
  const t = [
52
52
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
53
53
  { name: "fill", value: "currentColor" },
54
54
  { name: "viewBox", value: "0 0 24 24" },
55
55
  n ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
56
56
  ], a = n ? `<title>${n}</title>` : "";
57
- return `<svg ${ge(t)}>${a}${e}</svg>`;
58
- }, _e = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), G = ({ svg: e, allyTitle: n, className: t, size: a = he, ...o }) => {
59
- const r = ve({
60
- content: _e(e.svg),
57
+ return `<svg ${_e(t)}>${a}${e}</svg>`;
58
+ }, be = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), J = ({ svg: e, allyTitle: n, className: t, size: a = ve, ...o }) => {
59
+ const r = me({
60
+ content: be(e.svg),
61
61
  title: n
62
- }), i = fe(q, `${q}--${a}`, t);
62
+ }), i = ge(B, `${B}--${a}`, t);
63
63
  return /* @__PURE__ */ g("span", { className: i, dangerouslySetInnerHTML: { __html: r }, ...o });
64
64
  };
65
- G.displayName = "Icon";
66
- const me = {
65
+ J.displayName = "Icon";
66
+ const ye = {
67
67
  name: "checkmark-bold",
68
68
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M21.243 4.176a2 2 0 0 1 .324 2.81l-10.45 13.176a2.092 2.092 0 0 1-3.118.18l-5.413-5.413A2 2 0 1 1 5.414 12.1l3.9 3.9 9.118-11.5a2 2 0 0 1 2.81-.324Z" clip-rule="evenodd"/></svg>',
69
69
  keywords: ["checkmark-bold"],
70
70
  category: "utility"
71
71
  };
72
- function B(e, n) {
72
+ function X(e, n) {
73
73
  if (typeof e == "function")
74
74
  return e(n);
75
75
  e != null && (e.current = n);
76
76
  }
77
- function be(...e) {
77
+ function we(...e) {
78
78
  return (n) => {
79
79
  let t = !1;
80
80
  const a = e.map((o) => {
81
- const r = B(o, n);
81
+ const r = X(o, n);
82
82
  return !t && typeof r == "function" && (t = !0), r;
83
83
  });
84
84
  if (t)
85
85
  return () => {
86
86
  for (let o = 0; o < a.length; o++) {
87
87
  const r = a[o];
88
- typeof r == "function" ? r() : B(e[o], null);
88
+ typeof r == "function" ? r() : X(e[o], null);
89
89
  }
90
90
  };
91
91
  };
92
92
  }
93
+ var Se = /* @__PURE__ */ Symbol.for("react.lazy"), P = s[" use ".trim().toString()];
94
+ function xe(e) {
95
+ return typeof e == "object" && e !== null && "then" in e;
96
+ }
97
+ function K(e) {
98
+ return e != null && typeof e == "object" && "$$typeof" in e && e.$$typeof === Se && "_payload" in e && xe(e._payload);
99
+ }
93
100
  // @__NO_SIDE_EFFECTS__
94
- function ye(e) {
95
- const n = /* @__PURE__ */ we(e), t = s.forwardRef((a, o) => {
96
- const { children: r, ...i } = a, u = s.Children.toArray(r), c = u.find(xe);
101
+ function Ce(e) {
102
+ const n = /* @__PURE__ */ $e(e), t = s.forwardRef((a, o) => {
103
+ let { children: r, ...i } = a;
104
+ K(r) && typeof P == "function" && (r = P(r._payload));
105
+ const u = s.Children.toArray(r), c = u.find(ze);
97
106
  if (c) {
98
107
  const l = c.props.children, d = u.map((p) => p === c ? s.Children.count(l) > 1 ? s.Children.only(null) : s.isValidElement(l) ? l.props.children : null : p);
99
108
  return /* @__PURE__ */ g(n, { ...i, ref: o, children: s.isValidElement(l) ? s.cloneElement(l, void 0, d) : null });
@@ -103,22 +112,22 @@ function ye(e) {
103
112
  return t.displayName = `${e}.Slot`, t;
104
113
  }
105
114
  // @__NO_SIDE_EFFECTS__
106
- function we(e) {
115
+ function $e(e) {
107
116
  const n = s.forwardRef((t, a) => {
108
- const { children: o, ...r } = t;
109
- if (s.isValidElement(o)) {
110
- const i = $e(o), u = Ce(r, o.props);
111
- return o.type !== s.Fragment && (u.ref = a ? be(a, i) : i), s.cloneElement(o, u);
117
+ let { children: o, ...r } = t;
118
+ if (K(o) && typeof P == "function" && (o = P(o._payload)), s.isValidElement(o)) {
119
+ const i = Pe(o), u = Ee(r, o.props);
120
+ return o.type !== s.Fragment && (u.ref = a ? we(a, i) : i), s.cloneElement(o, u);
112
121
  }
113
122
  return s.Children.count(o) > 1 ? s.Children.only(null) : null;
114
123
  });
115
124
  return n.displayName = `${e}.SlotClone`, n;
116
125
  }
117
- var Se = Symbol("radix.slottable");
118
- function xe(e) {
119
- return s.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === Se;
126
+ var Re = /* @__PURE__ */ Symbol("radix.slottable");
127
+ function ze(e) {
128
+ return s.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === Re;
120
129
  }
121
- function Ce(e, n) {
130
+ function Ee(e, n) {
122
131
  const t = { ...n };
123
132
  for (const a in n) {
124
133
  const o = e[a], r = n[a];
@@ -129,11 +138,11 @@ function Ce(e, n) {
129
138
  }
130
139
  return { ...e, ...t };
131
140
  }
132
- function $e(e) {
141
+ function Pe(e) {
133
142
  let n = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, t = n && "isReactWarning" in n && n.isReactWarning;
134
143
  return t ? e.ref : (n = Object.getOwnPropertyDescriptor(e, "ref")?.get, t = n && "isReactWarning" in n && n.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
135
144
  }
136
- var Re = [
145
+ var ke = [
137
146
  "a",
138
147
  "button",
139
148
  "div",
@@ -151,14 +160,14 @@ var Re = [
151
160
  "span",
152
161
  "svg",
153
162
  "ul"
154
- ], ze = Re.reduce((e, n) => {
155
- const t = /* @__PURE__ */ ye(`Primitive.${n}`), a = s.forwardRef((o, r) => {
163
+ ], De = ke.reduce((e, n) => {
164
+ const t = /* @__PURE__ */ Ce(`Primitive.${n}`), a = s.forwardRef((o, r) => {
156
165
  const { asChild: i, ...u } = o, c = i ? t : n;
157
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...u, ref: r });
166
+ return typeof window < "u" && (window[/* @__PURE__ */ Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...u, ref: r });
158
167
  });
159
168
  return a.displayName = `Primitive.${n}`, { ...e, [n]: a };
160
- }, {}), Ee = "Label", J = s.forwardRef((e, n) => /* @__PURE__ */ g(
161
- ze.label,
169
+ }, {}), Ne = "Label", Q = s.forwardRef((e, n) => /* @__PURE__ */ g(
170
+ De.label,
162
171
  {
163
172
  ...e,
164
173
  ref: n,
@@ -167,14 +176,14 @@ var Re = [
167
176
  }
168
177
  }
169
178
  ));
170
- J.displayName = Ee;
171
- var Pe = J;
172
- function ke(e) {
179
+ Q.displayName = Ne;
180
+ var Oe = Q;
181
+ function Ae(e) {
173
182
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
174
183
  }
175
- var X = { exports: {} }, H;
176
- function De() {
177
- return H || (H = 1, (function(e) {
184
+ var H = { exports: {} }, L;
185
+ function Me() {
186
+ return L || (L = 1, (function(e) {
178
187
  (function() {
179
188
  var n = {}.hasOwnProperty;
180
189
  function t() {
@@ -203,32 +212,32 @@ function De() {
203
212
  }
204
213
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
205
214
  })();
206
- })(X)), X.exports;
215
+ })(H)), H.exports;
207
216
  }
208
- var Ne = De();
209
- const Oe = /* @__PURE__ */ ke(Ne), Ae = {
217
+ var je = Me();
218
+ const qe = /* @__PURE__ */ Ae(je), Be = {
210
219
  "purpur-label": "_purpur-label_1x80u_1",
211
220
  "purpur-label--negative": "_purpur-label--negative_1x80u_8",
212
221
  "purpur-label--disabled": "_purpur-label--disabled_1x80u_11"
213
- }, Me = Oe.bind(Ae), k = "purpur-label", je = ({
222
+ }, Xe = qe.bind(Be), D = "purpur-label", He = ({
214
223
  children: e,
215
224
  className: n,
216
225
  disabled: t,
217
226
  negative: a = !1,
218
227
  ...o
219
228
  }) => {
220
- const r = Me(n, k, {
221
- [`${k}--disabled`]: t,
222
- [`${k}--negative`]: a
229
+ const r = Xe(n, D, {
230
+ [`${D}--disabled`]: t,
231
+ [`${D}--negative`]: a
223
232
  });
224
- return /* @__PURE__ */ g(Pe, { className: r, ...o, children: e });
233
+ return /* @__PURE__ */ g(Oe, { className: r, ...o, children: e });
225
234
  };
226
- function qe(e) {
235
+ function Le(e) {
227
236
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
228
237
  }
229
- var L = { exports: {} }, W;
230
- function Be() {
231
- return W || (W = 1, (function(e) {
238
+ var W = { exports: {} }, I;
239
+ function We() {
240
+ return I || (I = 1, (function(e) {
232
241
  (function() {
233
242
  var n = {}.hasOwnProperty;
234
243
  function t() {
@@ -257,10 +266,10 @@ function Be() {
257
266
  }
258
267
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
259
268
  })();
260
- })(L)), L.exports;
269
+ })(W)), W.exports;
261
270
  }
262
- var Xe = Be();
263
- const He = /* @__PURE__ */ qe(Xe), Le = {
271
+ var Ie = We();
272
+ const Te = /* @__PURE__ */ Le(Ie), Ve = {
264
273
  "purpur-paragraph": "_purpur-paragraph_1vz75_1",
265
274
  "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1vz75_7",
266
275
  "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1vz75_10",
@@ -276,56 +285,56 @@ const He = /* @__PURE__ */ qe(Xe), Le = {
276
285
  "purpur-paragraph--additional-100-bold": "_purpur-paragraph--additional-100-bold_1vz75_67",
277
286
  "purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_1vz75_74",
278
287
  "purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_1vz75_82"
279
- }, We = He.bind(Le), Ie = {
288
+ }, Fe = Te.bind(Ve), Ue = {
280
289
  PARAGRAPH100: "paragraph-100"
281
- }, R = "purpur-paragraph", K = ({
290
+ }, R = "purpur-paragraph", Y = ({
282
291
  children: e,
283
292
  className: n,
284
293
  disabled: t,
285
294
  enableHyphenation: a = !1,
286
295
  negative: o = !1,
287
- variant: r = Ie.PARAGRAPH100,
296
+ variant: r = Ue.PARAGRAPH100,
288
297
  ...i
289
298
  }) => {
290
- const u = We(n, R, `${R}--${r}`, {
299
+ const u = Fe(n, R, `${R}--${r}`, {
291
300
  [`${R}--hyphens`]: a,
292
301
  [`${R}--disabled`]: t,
293
302
  [`${R}--negative`]: o
294
303
  });
295
304
  return /* @__PURE__ */ g("p", { ...i, className: u, children: e });
296
305
  };
297
- K.displayName = "Paragraph";
298
- function Te(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
306
+ Y.displayName = "Paragraph";
307
+ function Ze(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
299
308
  return function(o) {
300
309
  if (e?.(o), t === !1 || !o.defaultPrevented)
301
310
  return n?.(o);
302
311
  };
303
312
  }
304
- function I(e, n) {
313
+ function T(e, n) {
305
314
  if (typeof e == "function")
306
315
  return e(n);
307
316
  e != null && (e.current = n);
308
317
  }
309
- function Q(...e) {
318
+ function ee(...e) {
310
319
  return (n) => {
311
320
  let t = !1;
312
321
  const a = e.map((o) => {
313
- const r = I(o, n);
322
+ const r = T(o, n);
314
323
  return !t && typeof r == "function" && (t = !0), r;
315
324
  });
316
325
  if (t)
317
326
  return () => {
318
327
  for (let o = 0; o < a.length; o++) {
319
328
  const r = a[o];
320
- typeof r == "function" ? r() : I(e[o], null);
329
+ typeof r == "function" ? r() : T(e[o], null);
321
330
  }
322
331
  };
323
332
  };
324
333
  }
325
- function Ve(...e) {
326
- return s.useCallback(Q(...e), e);
334
+ function Ge(...e) {
335
+ return s.useCallback(ee(...e), e);
327
336
  }
328
- function Fe(e, n = []) {
337
+ function Je(e, n = []) {
329
338
  let t = [];
330
339
  function a(r, i) {
331
340
  const u = s.createContext(i), c = t.length;
@@ -353,9 +362,9 @@ function Fe(e, n = []) {
353
362
  );
354
363
  };
355
364
  };
356
- return o.scopeName = e, [a, Ue(o, ...n)];
365
+ return o.scopeName = e, [a, Ke(o, ...n)];
357
366
  }
358
- function Ue(...e) {
367
+ function Ke(...e) {
359
368
  const n = e[0];
360
369
  if (e.length === 1) return n;
361
370
  const t = () => {
@@ -373,19 +382,19 @@ function Ue(...e) {
373
382
  };
374
383
  return t.scopeName = n.scopeName, t;
375
384
  }
376
- function Y(e) {
385
+ function re(e) {
377
386
  const n = s.useRef(e);
378
387
  return s.useEffect(() => {
379
388
  n.current = e;
380
389
  }), s.useMemo(() => (...t) => n.current?.(...t), []);
381
390
  }
382
- function Ze({
391
+ function Qe({
383
392
  prop: e,
384
393
  defaultProp: n,
385
394
  onChange: t = () => {
386
395
  }
387
396
  }) {
388
- const [a, o] = Ge({ defaultProp: n, onChange: t }), r = e !== void 0, i = r ? e : a, u = Y(t), c = s.useCallback(
397
+ const [a, o] = Ye({ defaultProp: n, onChange: t }), r = e !== void 0, i = r ? e : a, u = re(t), c = s.useCallback(
389
398
  (l) => {
390
399
  if (r) {
391
400
  const p = typeof l == "function" ? l(e) : l;
@@ -397,24 +406,24 @@ function Ze({
397
406
  );
398
407
  return [i, c];
399
408
  }
400
- function Ge({
409
+ function Ye({
401
410
  defaultProp: e,
402
411
  onChange: n
403
412
  }) {
404
- const t = s.useState(e), [a] = t, o = s.useRef(a), r = Y(n);
413
+ const t = s.useState(e), [a] = t, o = s.useRef(a), r = re(n);
405
414
  return s.useEffect(() => {
406
415
  o.current !== a && (r(a), o.current = a);
407
416
  }, [a, o, r]), t;
408
417
  }
409
- function Je(e) {
418
+ function er(e) {
410
419
  const n = s.useRef({ value: e, previous: e });
411
420
  return s.useMemo(() => (n.current.value !== e && (n.current.previous = n.current.value, n.current.value = e), n.current.previous), [e]);
412
421
  }
413
- var Ke = globalThis?.document ? s.useLayoutEffect : () => {
422
+ var rr = globalThis?.document ? s.useLayoutEffect : () => {
414
423
  };
415
- function Qe(e) {
424
+ function tr(e) {
416
425
  const [n, t] = s.useState(void 0);
417
- return Ke(() => {
426
+ return rr(() => {
418
427
  if (e) {
419
428
  t({ width: e.offsetWidth, height: e.offsetHeight });
420
429
  const a = new ResizeObserver((o) => {
@@ -435,9 +444,9 @@ function Qe(e) {
435
444
  }, [e]), n;
436
445
  }
437
446
  // @__NO_SIDE_EFFECTS__
438
- function Ye(e) {
439
- const n = /* @__PURE__ */ er(e), t = s.forwardRef((a, o) => {
440
- const { children: r, ...i } = a, u = s.Children.toArray(r), c = u.find(tr);
447
+ function nr(e) {
448
+ const n = /* @__PURE__ */ or(e), t = s.forwardRef((a, o) => {
449
+ const { children: r, ...i } = a, u = s.Children.toArray(r), c = u.find(ar);
441
450
  if (c) {
442
451
  const l = c.props.children, d = u.map((p) => p === c ? s.Children.count(l) > 1 ? s.Children.only(null) : s.isValidElement(l) ? l.props.children : null : p);
443
452
  return /* @__PURE__ */ g(n, { ...i, ref: o, children: s.isValidElement(l) ? s.cloneElement(l, void 0, d) : null });
@@ -447,22 +456,22 @@ function Ye(e) {
447
456
  return t.displayName = `${e}.Slot`, t;
448
457
  }
449
458
  // @__NO_SIDE_EFFECTS__
450
- function er(e) {
459
+ function or(e) {
451
460
  const n = s.forwardRef((t, a) => {
452
461
  const { children: o, ...r } = t;
453
462
  if (s.isValidElement(o)) {
454
- const i = or(o), u = nr(r, o.props);
455
- return o.type !== s.Fragment && (u.ref = a ? Q(a, i) : i), s.cloneElement(o, u);
463
+ const i = sr(o), u = ur(r, o.props);
464
+ return o.type !== s.Fragment && (u.ref = a ? ee(a, i) : i), s.cloneElement(o, u);
456
465
  }
457
466
  return s.Children.count(o) > 1 ? s.Children.only(null) : null;
458
467
  });
459
468
  return n.displayName = `${e}.SlotClone`, n;
460
469
  }
461
- var rr = Symbol("radix.slottable");
462
- function tr(e) {
463
- return s.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === rr;
470
+ var ir = /* @__PURE__ */ Symbol("radix.slottable");
471
+ function ar(e) {
472
+ return s.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === ir;
464
473
  }
465
- function nr(e, n) {
474
+ function ur(e, n) {
466
475
  const t = { ...n };
467
476
  for (const a in n) {
468
477
  const o = e[a], r = n[a];
@@ -472,11 +481,11 @@ function nr(e, n) {
472
481
  }
473
482
  return { ...e, ...t };
474
483
  }
475
- function or(e) {
484
+ function sr(e) {
476
485
  let n = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, t = n && "isReactWarning" in n && n.isReactWarning;
477
486
  return t ? e.ref : (n = Object.getOwnPropertyDescriptor(e, "ref")?.get, t = n && "isReactWarning" in n && n.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
478
487
  }
479
- var ir = [
488
+ var cr = [
480
489
  "a",
481
490
  "button",
482
491
  "div",
@@ -493,13 +502,13 @@ var ir = [
493
502
  "span",
494
503
  "svg",
495
504
  "ul"
496
- ], ee = ir.reduce((e, n) => {
497
- const t = /* @__PURE__ */ Ye(`Primitive.${n}`), a = s.forwardRef((o, r) => {
505
+ ], te = cr.reduce((e, n) => {
506
+ const t = /* @__PURE__ */ nr(`Primitive.${n}`), a = s.forwardRef((o, r) => {
498
507
  const { asChild: i, ...u } = o, c = i ? t : n;
499
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...u, ref: r });
508
+ return typeof window < "u" && (window[/* @__PURE__ */ Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...u, ref: r });
500
509
  });
501
510
  return a.displayName = `Primitive.${n}`, { ...e, [n]: a };
502
- }, {}), A = "Switch", [ar] = Fe(A), [ur, sr] = ar(A), re = s.forwardRef(
511
+ }, {}), M = "Switch", [lr] = Je(M), [pr, dr] = lr(M), ne = s.forwardRef(
503
512
  (e, n) => {
504
513
  const {
505
514
  __scopeSwitch: t,
@@ -512,32 +521,32 @@ var ir = [
512
521
  onCheckedChange: l,
513
522
  form: d,
514
523
  ...p
515
- } = e, [f, v] = s.useState(null), h = Ve(n, (y) => v(y)), _ = s.useRef(!1), m = f ? d || !!f.closest("form") : !0, [b = !1, x] = Ze({
524
+ } = e, [f, v] = s.useState(null), h = Ge(n, (y) => v(y)), _ = s.useRef(!1), m = f ? d || !!f.closest("form") : !0, [b = !1, x] = Qe({
516
525
  prop: o,
517
526
  defaultProp: r,
518
527
  onChange: l
519
528
  });
520
- return /* @__PURE__ */ N(ur, { scope: t, checked: b, disabled: u, children: [
529
+ return /* @__PURE__ */ O(pr, { scope: t, checked: b, disabled: u, children: [
521
530
  /* @__PURE__ */ g(
522
- ee.button,
531
+ te.button,
523
532
  {
524
533
  type: "button",
525
534
  role: "switch",
526
535
  "aria-checked": b,
527
536
  "aria-required": i,
528
- "data-state": oe(b),
537
+ "data-state": ae(b),
529
538
  "data-disabled": u ? "" : void 0,
530
539
  disabled: u,
531
540
  value: c,
532
541
  ...p,
533
542
  ref: h,
534
- onClick: Te(e.onClick, (y) => {
543
+ onClick: Ze(e.onClick, (y) => {
535
544
  x((w) => !w), m && (_.current = y.isPropagationStopped(), _.current || y.stopPropagation());
536
545
  })
537
546
  }
538
547
  ),
539
548
  m && /* @__PURE__ */ g(
540
- cr,
549
+ fr,
541
550
  {
542
551
  control: f,
543
552
  bubbles: !_.current,
@@ -553,14 +562,14 @@ var ir = [
553
562
  ] });
554
563
  }
555
564
  );
556
- re.displayName = A;
557
- var te = "SwitchThumb", ne = s.forwardRef(
565
+ ne.displayName = M;
566
+ var oe = "SwitchThumb", ie = s.forwardRef(
558
567
  (e, n) => {
559
- const { __scopeSwitch: t, ...a } = e, o = sr(te, t);
568
+ const { __scopeSwitch: t, ...a } = e, o = dr(oe, t);
560
569
  return /* @__PURE__ */ g(
561
- ee.span,
570
+ te.span,
562
571
  {
563
- "data-state": oe(o.checked),
572
+ "data-state": ae(o.checked),
564
573
  "data-disabled": o.disabled ? "" : void 0,
565
574
  ...a,
566
575
  ref: n
@@ -568,9 +577,9 @@ var te = "SwitchThumb", ne = s.forwardRef(
568
577
  );
569
578
  }
570
579
  );
571
- ne.displayName = te;
572
- var cr = (e) => {
573
- const { control: n, checked: t, bubbles: a = !0, ...o } = e, r = s.useRef(null), i = Je(t), u = Qe(n);
580
+ ie.displayName = oe;
581
+ var fr = (e) => {
582
+ const { control: n, checked: t, bubbles: a = !0, ...o } = e, r = s.useRef(null), i = er(t), u = tr(n);
574
583
  return s.useEffect(() => {
575
584
  const c = r.current, l = window.HTMLInputElement.prototype, p = Object.getOwnPropertyDescriptor(l, "checked").set;
576
585
  if (i !== t && p) {
@@ -597,17 +606,17 @@ var cr = (e) => {
597
606
  }
598
607
  );
599
608
  };
600
- function oe(e) {
609
+ function ae(e) {
601
610
  return e ? "checked" : "unchecked";
602
611
  }
603
- var lr = re, pr = ne;
604
- function dr(e) {
612
+ var hr = ne, gr = ie;
613
+ function vr(e) {
605
614
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
606
615
  }
607
- var D = { exports: {} };
608
- var T;
609
- function fr() {
610
- return T || (T = 1, (function(e) {
616
+ var N = { exports: {} };
617
+ var V;
618
+ function _r() {
619
+ return V || (V = 1, (function(e) {
611
620
  (function() {
612
621
  var n = {}.hasOwnProperty;
613
622
  function t() {
@@ -636,10 +645,10 @@ function fr() {
636
645
  }
637
646
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
638
647
  })();
639
- })(D)), D.exports;
648
+ })(N)), N.exports;
640
649
  }
641
- var hr = fr();
642
- const gr = /* @__PURE__ */ dr(hr), V = (e) => e && "touches" in e, vr = ({
650
+ var mr = _r();
651
+ const br = /* @__PURE__ */ vr(mr), F = (e) => e && "touches" in e, yr = ({
643
652
  children: e,
644
653
  disabled: n,
645
654
  onStart: t,
@@ -652,46 +661,46 @@ const gr = /* @__PURE__ */ dr(hr), V = (e) => e && "touches" in e, vr = ({
652
661
  const [c, l] = C(void 0), [d, p] = C(void 0), [f, v] = C(!1), h = (b) => {
653
662
  if (!n) {
654
663
  b.preventDefault();
655
- const x = V(b.nativeEvent) ? b.nativeEvent.touches[0].clientX : b.nativeEvent.clientX;
664
+ const x = F(b.nativeEvent) ? b.nativeEvent.touches[0].clientX : b.nativeEvent.clientX;
656
665
  p(x), t?.();
657
666
  }
658
- }, _ = O(
667
+ }, _ = A(
659
668
  (b) => {
660
669
  if (typeof d != "number")
661
670
  return;
662
- const y = (V(b) ? b.touches[0].clientX : b.clientX) - d;
671
+ const y = (F(b) ? b.touches[0].clientX : b.clientX) - d;
663
672
  if (!y)
664
673
  return;
665
674
  const w = i + y;
666
675
  !f && Math.abs(w) && v(!0);
667
- const P = w > r.right ? r.right : w < r.left ? r.left : w;
668
- l(P), a?.({ x: P });
676
+ const k = w > r.right ? r.right : w < r.left ? r.left : w;
677
+ l(k), a?.({ x: k });
669
678
  },
670
679
  // eslint-disable-next-line react-hooks/exhaustive-deps
671
680
  [a, l, f, d]
672
- ), m = O(() => {
681
+ ), m = A(() => {
673
682
  p(void 0), l(void 0), v(!1), o?.();
674
683
  }, [o, p]);
675
684
  return E(() => (window.addEventListener("mousemove", _), window.addEventListener("touchmove", _), () => {
676
685
  window.removeEventListener("mousemove", _), window.removeEventListener("touchmove", _);
677
686
  }), [_]), E(() => (window.addEventListener("mouseup", m), window.addEventListener("touchend", m), () => {
678
687
  window.removeEventListener("mouseup", m), window.removeEventListener("touchend", m);
679
- }), [m]), ae(e) ? ie(e, {
688
+ }), [m]), se(e) ? ue(e, {
680
689
  onMouseDown: h,
681
690
  onTouchStart: h,
682
691
  style: { ...u, transform: `translateX(${f ? c : i}px)` }
683
692
  }) : null;
684
- }, F = {
693
+ }, U = {
685
694
  width: void 0,
686
695
  height: void 0
687
696
  };
688
- function U(e) {
689
- const { ref: n, box: t = "content-box", round: a } = e, [{ width: o, height: r }, i] = C(F), u = _r(), c = z({ ...F }), l = z(void 0);
697
+ function Z(e) {
698
+ const { ref: n, box: t = "content-box", round: a } = e, [{ width: o, height: r }, i] = C(U), u = wr(), c = z({ ...U }), l = z(void 0);
690
699
  return l.current = e.onResize, E(() => {
691
700
  if (!n.current || typeof window > "u" || !("ResizeObserver" in window))
692
701
  return;
693
702
  const d = new ResizeObserver(([p]) => {
694
- const f = t === "border-box" ? "borderBoxSize" : t === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize", v = Z(p, f, "inlineSize"), h = Z(p, f, "blockSize");
703
+ const f = t === "border-box" ? "borderBoxSize" : t === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize", v = G(p, f, "inlineSize"), h = G(p, f, "blockSize");
695
704
  if (c.current.width !== v || c.current.height !== h) {
696
705
  const m = {
697
706
  width: v && a ? Math.round(v) : v,
@@ -705,21 +714,21 @@ function U(e) {
705
714
  };
706
715
  }, [t, n, u, a]), { width: o, height: r };
707
716
  }
708
- function Z(e, n, t) {
717
+ function G(e, n, t) {
709
718
  return e[n] ? Array.isArray(e[n]) ? e[n][0][t] : (
710
719
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
711
720
  // @ts-ignore Support Firefox's non-standard behavior
712
721
  e[n][t]
713
722
  ) : n === "contentBoxSize" ? e.contentRect[t === "inlineSize" ? "width" : "height"] : void 0;
714
723
  }
715
- function _r() {
724
+ function wr() {
716
725
  const e = z(!1);
717
726
  return E(() => (e.current = !0, () => {
718
727
  e.current = !1;
719
- }), []), O(() => e.current, []);
728
+ }), []), A(() => e.current, []);
720
729
  }
721
- const mr = ({ checked: e, onChange: n }) => {
722
- const t = z(null), a = z(null), [o, r] = C(void 0), [i, u] = C(!1), [c, l] = C(0), { height: d = 0 } = U({ ref: a, round: !0 }), { height: p = 0 } = U({ ref: t, round: !0 }), f = (p || 0) - d, v = d + f, h = f / 2, _ = v / 2, m = typeof o == "number" && (e ? o < _ : o > _);
730
+ const Sr = ({ checked: e, onChange: n }) => {
731
+ const t = z(null), a = z(null), [o, r] = C(void 0), [i, u] = C(!1), [c, l] = C(0), { height: d = 0 } = Z({ ref: a, round: !0 }), { height: p = 0 } = Z({ ref: t, round: !0 }), f = (p || 0) - d, v = d + f, h = f / 2, _ = v / 2, m = typeof o == "number" && (e ? o < _ : o > _);
723
732
  return {
724
733
  trackRef: t,
725
734
  thumbRef: a,
@@ -736,7 +745,7 @@ const mr = ({ checked: e, onChange: n }) => {
736
745
  Date.now() - c > 50 && n?.(!e), r(void 0);
737
746
  }
738
747
  };
739
- }, br = {
748
+ }, xr = {
740
749
  "purpur-toggle": "_purpur-toggle_zqs8u_1",
741
750
  "purpur-toggle__track": "_purpur-toggle__track_zqs8u_7",
742
751
  "purpur-toggle__checkmark-container": "_purpur-toggle__checkmark-container_zqs8u_45",
@@ -746,7 +755,7 @@ const mr = ({ checked: e, onChange: n }) => {
746
755
  "purpur-toggle__label--right": "_purpur-toggle__label--right_zqs8u_110",
747
756
  "purpur-toggle__label--left": "_purpur-toggle__label--left_zqs8u_113",
748
757
  "purpur-toggle__container": "_purpur-toggle__container_zqs8u_116"
749
- }, $ = gr.bind(br), S = "purpur-toggle", yr = ue(
758
+ }, $ = br.bind(xr), S = "purpur-toggle", Cr = ce(
750
759
  ({
751
760
  ["data-testid"]: e,
752
761
  className: n,
@@ -760,25 +769,25 @@ const mr = ({ checked: e, onChange: n }) => {
760
769
  }, l) => {
761
770
  const [d, p] = C(
762
771
  typeof r == "boolean" ? r : !!u
763
- ), f = !!(typeof r == "boolean" ? r : d), { thumbRef: v, trackRef: h, isDragging: _, onChangeWithDrag: m, ...b } = mr({
772
+ ), f = !!(typeof r == "boolean" ? r : d), { thumbRef: v, trackRef: h, isDragging: _, onChangeWithDrag: m, ...b } = Sr({
764
773
  checked: f,
765
774
  onChange: (y) => {
766
775
  c.disabled || (a?.(y), p(y));
767
776
  }
768
777
  }), x = () => /* @__PURE__ */ g(
769
- je,
778
+ He,
770
779
  {
771
780
  htmlFor: c.id,
772
781
  "data-testid": e && `${e}-label`,
773
782
  disabled: c.disabled,
774
783
  className: $(`${S}__label`, `${S}__label--${o}`),
775
- children: /* @__PURE__ */ g(K, { disabled: c.disabled, children: t })
784
+ children: /* @__PURE__ */ g(Y, { disabled: c.disabled, children: t })
776
785
  }
777
786
  );
778
- return /* @__PURE__ */ N("div", { className: $(n, `${S}__container`), children: [
787
+ return /* @__PURE__ */ O("div", { className: $(n, `${S}__container`), children: [
779
788
  t && o === "left" && x(),
780
789
  /* @__PURE__ */ g(
781
- lr,
790
+ hr,
782
791
  {
783
792
  ...c,
784
793
  ref: l,
@@ -787,10 +796,10 @@ const mr = ({ checked: e, onChange: n }) => {
787
796
  className: $(S),
788
797
  onCheckedChange: m,
789
798
  checked: f,
790
- children: /* @__PURE__ */ N("span", { ref: h, className: $(`${S}__track`), children: [
791
- /* @__PURE__ */ g("span", { className: $(`${S}__checkmark-container`), children: /* @__PURE__ */ g(G, { className: $(`${S}__checkmark`), svg: me, size: "xxs" }) }),
792
- /* @__PURE__ */ g(vr, { disabled: i, ...b, children: /* @__PURE__ */ g(
793
- pr,
799
+ children: /* @__PURE__ */ O("span", { ref: h, className: $(`${S}__track`), children: [
800
+ /* @__PURE__ */ g("span", { className: $(`${S}__checkmark-container`), children: /* @__PURE__ */ g(J, { className: $(`${S}__checkmark`), svg: ye, size: "xxs" }) }),
801
+ /* @__PURE__ */ g(yr, { disabled: i, ...b, children: /* @__PURE__ */ g(
802
+ gr,
794
803
  {
795
804
  ref: v,
796
805
  "data-testid": e && `${e}-thumb`,
@@ -806,8 +815,8 @@ const mr = ({ checked: e, onChange: n }) => {
806
815
  ] });
807
816
  }
808
817
  );
809
- yr.displayName = "Toggle";
818
+ Cr.displayName = "Toggle";
810
819
  export {
811
- yr as Toggle
820
+ Cr as Toggle
812
821
  };
813
822
  //# sourceMappingURL=toggle.es.js.map