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