@purpurds/toggle 5.20.1 → 5.21.1

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,7 +1,7 @@
1
1
  import { jsx as x, jsxs as G } from "react/jsx-runtime";
2
- import { forwardRef as w, Children as y, isValidElement as k, createElement as _, cloneElement as L, useEffect as N, Fragment as K, useCallback as X, createContext as Z, useMemo as H, useContext as de, useRef as C, useState as $, useLayoutEffect as Q } from "react";
2
+ import { forwardRef as w, Children as y, isValidElement as k, createElement as _, cloneElement as L, useEffect as D, Fragment as K, useCallback as X, createContext as Z, useMemo as H, useContext as fe, useRef as C, useState as $, useLayoutEffect as Q } from "react";
3
3
  import "react-dom";
4
- function fe(e) {
4
+ function ge(e) {
5
5
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6
6
  }
7
7
  var ee = { exports: {} };
@@ -40,8 +40,8 @@ var ee = { exports: {} };
40
40
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
41
41
  })();
42
42
  })(ee);
43
- var ge = ee.exports;
44
- const he = /* @__PURE__ */ fe(ge), be = {
43
+ var he = ee.exports;
44
+ const be = /* @__PURE__ */ ge(he), _e = {
45
45
  "purpur-icon": "_purpur-icon_8u1lq_1",
46
46
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
47
47
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -49,31 +49,31 @@ const he = /* @__PURE__ */ fe(ge), be = {
49
49
  "purpur-icon--md": "_purpur-icon--md_8u1lq_16",
50
50
  "purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
51
51
  "purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
52
- }, _e = {
52
+ }, ve = {
53
53
  name: "checkmark-bold",
54
54
  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>',
55
55
  keywords: ["checkmark-bold"],
56
56
  category: "utility"
57
- }, ve = he.bind(be), J = "purpur-icon", me = "md", $e = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), ye = ({ content: e = "", title: n } = {}) => {
57
+ }, me = be.bind(_e), J = "purpur-icon", $e = "md", ye = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), xe = ({ content: e = "", title: n } = {}) => {
58
58
  const t = [
59
59
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
60
60
  { name: "fill", value: "currentColor" },
61
61
  { name: "viewBox", value: "0 0 24 24" },
62
62
  n ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
63
63
  ], a = n ? `<title>${n}</title>` : "";
64
- return `<svg ${$e(t)}>${a}${e}</svg>`;
65
- }, xe = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), we = ({
64
+ return `<svg ${ye(t)}>${a}${e}</svg>`;
65
+ }, we = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), re = ({
66
66
  ["data-testid"]: e,
67
67
  svg: n,
68
68
  allyTitle: t,
69
69
  className: a,
70
- size: c = me,
70
+ size: c = $e,
71
71
  ...r
72
72
  }) => {
73
- const o = ye({
74
- content: xe(n.svg),
73
+ const o = xe({
74
+ content: we(n.svg),
75
75
  title: t
76
- }), u = ve(a, J, `${J}--${c}`);
76
+ }), u = me(a, J, `${J}--${c}`);
77
77
  return /* @__PURE__ */ x(
78
78
  "span",
79
79
  {
@@ -85,6 +85,7 @@ const he = /* @__PURE__ */ fe(ge), be = {
85
85
  }
86
86
  );
87
87
  };
88
+ re.displayName = "Icon";
88
89
  function E() {
89
90
  return E = Object.assign ? Object.assign.bind() : function(e) {
90
91
  for (var n = 1; n < arguments.length; n++) {
@@ -102,7 +103,7 @@ function Pe(...e) {
102
103
  (t) => Se(t, n)
103
104
  );
104
105
  }
105
- const re = /* @__PURE__ */ w((e, n) => {
106
+ const te = /* @__PURE__ */ w((e, n) => {
106
107
  const { children: t, ...a } = e, c = y.toArray(t), r = c.find(Ae);
107
108
  if (r) {
108
109
  const o = r.props.children, u = c.map((i) => i === r ? y.count(o) > 1 ? y.only(null) : /* @__PURE__ */ k(o) ? o.props.children : null : i);
@@ -114,11 +115,11 @@ const re = /* @__PURE__ */ w((e, n) => {
114
115
  ref: n
115
116
  }), t);
116
117
  });
117
- re.displayName = "Slot";
118
+ te.displayName = "Slot";
118
119
  const F = /* @__PURE__ */ w((e, n) => {
119
120
  const { children: t, ...a } = e;
120
121
  return /* @__PURE__ */ k(t) ? /* @__PURE__ */ L(t, {
121
- ...De(a, t.props),
122
+ ...Ne(a, t.props),
122
123
  ref: n ? Pe(n, t.ref) : t.ref
123
124
  }) : y.count(t) > 1 ? y.only(null) : null;
124
125
  });
@@ -127,7 +128,7 @@ const ke = ({ children: e }) => /* @__PURE__ */ _(K, null, e);
127
128
  function Ae(e) {
128
129
  return /* @__PURE__ */ k(e) && e.type === ke;
129
130
  }
130
- function De(e, n) {
131
+ function Ne(e, n) {
131
132
  const t = {
132
133
  ...n
133
134
  };
@@ -148,7 +149,7 @@ function De(e, n) {
148
149
  ...t
149
150
  };
150
151
  }
151
- const Ne = [
152
+ const De = [
152
153
  "a",
153
154
  "button",
154
155
  "div",
@@ -165,10 +166,10 @@ const Ne = [
165
166
  "span",
166
167
  "svg",
167
168
  "ul"
168
- ], Ce = Ne.reduce((e, n) => {
169
+ ], Ce = De.reduce((e, n) => {
169
170
  const t = /* @__PURE__ */ w((a, c) => {
170
- const { asChild: r, ...o } = a, u = r ? re : n;
171
- return N(() => {
171
+ const { asChild: r, ...o } = a, u = r ? te : n;
172
+ return D(() => {
172
173
  window[Symbol.for("radix-ui")] = !0;
173
174
  }, []), /* @__PURE__ */ _(u, E({}, o, {
174
175
  ref: c
@@ -188,7 +189,7 @@ const Ne = [
188
189
  function Re(e) {
189
190
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
190
191
  }
191
- var te = { exports: {} };
192
+ var ne = { exports: {} };
192
193
  /*!
193
194
  Copyright (c) 2018 Jed Watson.
194
195
  Licensed under the MIT License (MIT), see
@@ -223,8 +224,8 @@ var te = { exports: {} };
223
224
  }
224
225
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
225
226
  })();
226
- })(te);
227
- var Me = te.exports;
227
+ })(ne);
228
+ var Me = ne.exports;
228
229
  const je = /* @__PURE__ */ Re(Me), z = {
229
230
  "purpur-label": "_purpur-label_12cfi_1",
230
231
  "purpur-label--negative": "_purpur-label--negative_12cfi_9",
@@ -251,7 +252,7 @@ const je = /* @__PURE__ */ Re(Me), z = {
251
252
  function Le(e) {
252
253
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
253
254
  }
254
- var ne = { exports: {} };
255
+ var oe = { exports: {} };
255
256
  /*!
256
257
  Copyright (c) 2018 Jed Watson.
257
258
  Licensed under the MIT License (MIT), see
@@ -286,8 +287,8 @@ var ne = { exports: {} };
286
287
  }
287
288
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
288
289
  })();
289
- })(ne);
290
- var Xe = ne.exports;
290
+ })(oe);
291
+ var Xe = oe.exports;
291
292
  const Be = /* @__PURE__ */ Le(Xe), M = {
292
293
  "purpur-paragraph": "_purpur-paragraph_1rh57_1",
293
294
  "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
@@ -314,7 +315,7 @@ const Be = /* @__PURE__ */ Le(Xe), M = {
314
315
  ADDITIONAL100MEDIUM: "additional-100-medium",
315
316
  OVERLINE100: "overline-100",
316
317
  OVERLINE200: "overline-200"
317
- }, j = "purpur-paragraph", oe = ({
318
+ }, j = "purpur-paragraph", ae = ({
318
319
  ["data-testid"]: e,
319
320
  children: n,
320
321
  className: t,
@@ -336,15 +337,15 @@ const Be = /* @__PURE__ */ Le(Xe), M = {
336
337
  ]);
337
338
  return /* @__PURE__ */ x("p", { ...u, className: i, "data-testid": e, children: n });
338
339
  };
339
- oe.displayName = "Paragraph";
340
- function D() {
341
- return D = Object.assign ? Object.assign.bind() : function(e) {
340
+ ae.displayName = "Paragraph";
341
+ function N() {
342
+ return N = Object.assign ? Object.assign.bind() : function(e) {
342
343
  for (var n = 1; n < arguments.length; n++) {
343
344
  var t = arguments[n];
344
345
  for (var a in t) ({}).hasOwnProperty.call(t, a) && (e[a] = t[a]);
345
346
  }
346
347
  return e;
347
- }, D.apply(null, arguments);
348
+ }, N.apply(null, arguments);
348
349
  }
349
350
  function ze(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
350
351
  return function(c) {
@@ -354,13 +355,13 @@ function ze(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
354
355
  function Ie(e, n) {
355
356
  typeof e == "function" ? e(n) : e != null && (e.current = n);
356
357
  }
357
- function ae(...e) {
358
+ function ce(...e) {
358
359
  return (n) => e.forEach(
359
360
  (t) => Ie(t, n)
360
361
  );
361
362
  }
362
363
  function qe(...e) {
363
- return X(ae(...e), e);
364
+ return X(ce(...e), e);
364
365
  }
365
366
  function Fe(e, n = []) {
366
367
  let t = [];
@@ -380,7 +381,7 @@ function Fe(e, n = []) {
380
381
  }, v);
381
382
  }
382
383
  function h(l, p) {
383
- const v = (p == null ? void 0 : p[e][i]) || u, f = de(v);
384
+ const v = (p == null ? void 0 : p[e][i]) || u, f = fe(v);
384
385
  if (f) return f;
385
386
  if (o !== void 0) return o;
386
387
  throw new Error(`\`${l}\` must be used within \`${r}\``);
@@ -443,9 +444,9 @@ function Ue(...e) {
443
444
  };
444
445
  return t.scopeName = n.scopeName, t;
445
446
  }
446
- function ce(e) {
447
+ function ue(e) {
447
448
  const n = C(e);
448
- return N(() => {
449
+ return D(() => {
449
450
  n.current = e;
450
451
  }), H(
451
452
  () => (...t) => {
@@ -460,7 +461,7 @@ function Ve({ prop: e, defaultProp: n, onChange: t = () => {
460
461
  const [a, c] = We({
461
462
  defaultProp: n,
462
463
  onChange: t
463
- }), r = e !== void 0, o = r ? e : a, u = ce(t), i = X((s) => {
464
+ }), r = e !== void 0, o = r ? e : a, u = ue(t), i = X((s) => {
464
465
  if (r) {
465
466
  const l = typeof s == "function" ? s(e) : s;
466
467
  l !== e && u(l);
@@ -477,8 +478,8 @@ function Ve({ prop: e, defaultProp: n, onChange: t = () => {
477
478
  ];
478
479
  }
479
480
  function We({ defaultProp: e, onChange: n }) {
480
- const t = $(e), [a] = t, c = C(a), r = ce(n);
481
- return N(() => {
481
+ const t = $(e), [a] = t, c = C(a), r = ue(n);
482
+ return D(() => {
482
483
  c.current !== a && (r(a), c.current = a);
483
484
  }, [
484
485
  a,
@@ -528,24 +529,24 @@ function Je(e) {
528
529
  e
529
530
  ]), n;
530
531
  }
531
- const ue = /* @__PURE__ */ w((e, n) => {
532
+ const ie = /* @__PURE__ */ w((e, n) => {
532
533
  const { children: t, ...a } = e, c = y.toArray(t), r = c.find(Ke);
533
534
  if (r) {
534
535
  const o = r.props.children, u = c.map((i) => i === r ? y.count(o) > 1 ? y.only(null) : /* @__PURE__ */ k(o) ? o.props.children : null : i);
535
- return /* @__PURE__ */ _(U, D({}, a, {
536
+ return /* @__PURE__ */ _(U, N({}, a, {
536
537
  ref: n
537
538
  }), /* @__PURE__ */ k(o) ? /* @__PURE__ */ L(o, void 0, u) : null);
538
539
  }
539
- return /* @__PURE__ */ _(U, D({}, a, {
540
+ return /* @__PURE__ */ _(U, N({}, a, {
540
541
  ref: n
541
542
  }), t);
542
543
  });
543
- ue.displayName = "Slot";
544
+ ie.displayName = "Slot";
544
545
  const U = /* @__PURE__ */ w((e, n) => {
545
546
  const { children: t, ...a } = e;
546
547
  return /* @__PURE__ */ k(t) ? /* @__PURE__ */ L(t, {
547
548
  ...Qe(a, t.props),
548
- ref: n ? ae(n, t.ref) : t.ref
549
+ ref: n ? ce(n, t.ref) : t.ref
549
550
  }) : y.count(t) > 1 ? y.only(null) : null;
550
551
  });
551
552
  U.displayName = "SlotClone";
@@ -591,12 +592,12 @@ const er = [
591
592
  "span",
592
593
  "svg",
593
594
  "ul"
594
- ], ie = er.reduce((e, n) => {
595
+ ], se = er.reduce((e, n) => {
595
596
  const t = /* @__PURE__ */ w((a, c) => {
596
- const { asChild: r, ...o } = a, u = r ? ue : n;
597
- return N(() => {
597
+ const { asChild: r, ...o } = a, u = r ? ie : n;
598
+ return D(() => {
598
599
  window[Symbol.for("radix-ui")] = !0;
599
- }, []), /* @__PURE__ */ _(u, D({}, o, {
600
+ }, []), /* @__PURE__ */ _(u, N({}, o, {
600
601
  ref: c
601
602
  }));
602
603
  });
@@ -604,7 +605,7 @@ const er = [
604
605
  ...e,
605
606
  [n]: t
606
607
  };
607
- }, {}), se = "Switch", [rr, mr] = Fe(se), [tr, nr] = rr(se), or = /* @__PURE__ */ w((e, n) => {
608
+ }, {}), le = "Switch", [rr, mr] = Fe(le), [tr, nr] = rr(le), or = /* @__PURE__ */ w((e, n) => {
608
609
  const { __scopeSwitch: t, name: a, checked: c, defaultChecked: r, required: o, disabled: u, value: i = "on", onCheckedChange: s, ...h } = e, [l, p] = $(null), v = qe(
609
610
  n,
610
611
  (m) => p(m)
@@ -617,12 +618,12 @@ const er = [
617
618
  scope: t,
618
619
  checked: d,
619
620
  disabled: u
620
- }, /* @__PURE__ */ _(ie.button, D({
621
+ }, /* @__PURE__ */ _(se.button, N({
621
622
  type: "button",
622
623
  role: "switch",
623
624
  "aria-checked": d,
624
625
  "aria-required": o,
625
- "data-state": le(d),
626
+ "data-state": pe(d),
626
627
  "data-disabled": u ? "" : void 0,
627
628
  disabled: u,
628
629
  value: i
@@ -647,15 +648,15 @@ const er = [
647
648
  }));
648
649
  }), ar = "SwitchThumb", cr = /* @__PURE__ */ w((e, n) => {
649
650
  const { __scopeSwitch: t, ...a } = e, c = nr(ar, t);
650
- return /* @__PURE__ */ _(ie.span, D({
651
- "data-state": le(c.checked),
651
+ return /* @__PURE__ */ _(se.span, N({
652
+ "data-state": pe(c.checked),
652
653
  "data-disabled": c.disabled ? "" : void 0
653
654
  }, a, {
654
655
  ref: n
655
656
  }));
656
657
  }), ur = (e) => {
657
658
  const { control: n, checked: t, bubbles: a = !0, ...c } = e, r = C(null), o = Ge(t), u = Je(n);
658
- return N(() => {
659
+ return D(() => {
659
660
  const i = r.current, s = window.HTMLInputElement.prototype, l = Object.getOwnPropertyDescriptor(s, "checked").set;
660
661
  if (o !== t && l) {
661
662
  const p = new Event("click", {
@@ -667,7 +668,7 @@ const er = [
667
668
  o,
668
669
  t,
669
670
  a
670
- ]), /* @__PURE__ */ _("input", D({
671
+ ]), /* @__PURE__ */ _("input", N({
671
672
  type: "checkbox",
672
673
  "aria-hidden": !0,
673
674
  defaultChecked: t
@@ -684,14 +685,14 @@ const er = [
684
685
  }
685
686
  }));
686
687
  };
687
- function le(e) {
688
+ function pe(e) {
688
689
  return e ? "checked" : "unchecked";
689
690
  }
690
691
  const ir = or, sr = cr;
691
692
  function lr(e) {
692
693
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
693
694
  }
694
- var pe = { exports: {} };
695
+ var de = { exports: {} };
695
696
  /*!
696
697
  Copyright (c) 2018 Jed Watson.
697
698
  Licensed under the MIT License (MIT), see
@@ -726,8 +727,8 @@ var pe = { exports: {} };
726
727
  }
727
728
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
728
729
  })();
729
- })(pe);
730
- var pr = pe.exports;
730
+ })(de);
731
+ var pr = de.exports;
731
732
  const q = /* @__PURE__ */ lr(pr), S = {
732
733
  "purpur-toggle": "_purpur-toggle_1xng6_1",
733
734
  "purpur-toggle__track": "_purpur-toggle__track_1xng6_7",
@@ -770,9 +771,9 @@ const q = /* @__PURE__ */ lr(pr), S = {
770
771
  ), d = X(() => {
771
772
  l(void 0), s(void 0), v(!1), c == null || c();
772
773
  }, [c, l]);
773
- return N(() => (window.addEventListener("mousemove", g), window.addEventListener("touchmove", g), () => {
774
+ return D(() => (window.addEventListener("mousemove", g), window.addEventListener("touchmove", g), () => {
774
775
  window.removeEventListener("mousemove", g), window.removeEventListener("touchmove", g);
775
- }), [g]), N(() => (window.addEventListener("mouseup", d), window.addEventListener("touchend", d), () => {
776
+ }), [g]), D(() => (window.addEventListener("mouseup", d), window.addEventListener("touchend", d), () => {
776
777
  window.removeEventListener("mouseup", d), window.removeEventListener("touchend", d);
777
778
  }), [d]), k(e) ? L(y.only(e), {
778
779
  onMouseDown: f,
@@ -831,7 +832,7 @@ const q = /* @__PURE__ */ lr(pr), S = {
831
832
  S[`${P}__label`],
832
833
  S[`${P}__label--${c}`]
833
834
  ),
834
- children: /* @__PURE__ */ x(oe, { variant: "paragraph-100", disabled: i.disabled, children: t })
835
+ children: /* @__PURE__ */ x(ae, { variant: "paragraph-100", disabled: i.disabled, children: t })
835
836
  }
836
837
  );
837
838
  return /* @__PURE__ */ G("div", { className: q([n, S[`${P}__container`]]), children: [
@@ -848,10 +849,10 @@ const q = /* @__PURE__ */ lr(pr), S = {
848
849
  checked: p,
849
850
  children: /* @__PURE__ */ G("span", { ref: f, className: S[`${P}__track`], children: [
850
851
  /* @__PURE__ */ x("span", { className: S[`${P}__checkmark-container`], children: /* @__PURE__ */ x(
851
- we,
852
+ re,
852
853
  {
853
854
  className: S[`${P}__checkmark`],
854
- svg: _e,
855
+ svg: ve,
855
856
  size: "xxs"
856
857
  }
857
858
  ) }),