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