@purpurds/toggle 3.1.0 → 3.3.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
@@ -159,7 +159,7 @@ function Ae(e, n) {
159
159
  ...r
160
160
  };
161
161
  }
162
- const Ce = [
162
+ const De = [
163
163
  "a",
164
164
  "button",
165
165
  "div",
@@ -176,7 +176,7 @@ const Ce = [
176
176
  "span",
177
177
  "svg",
178
178
  "ul"
179
- ], De = Ce.reduce((e, n) => {
179
+ ], Ce = De.reduce((e, n) => {
180
180
  const r = /* @__PURE__ */ x((o, c) => {
181
181
  const { asChild: t, ...a } = o, u = t ? ne : n;
182
182
  return O(() => {
@@ -189,14 +189,14 @@ const Ce = [
189
189
  ...e,
190
190
  [n]: r
191
191
  };
192
- }, {}), Ne = /* @__PURE__ */ x((e, n) => /* @__PURE__ */ _(De.label, q({}, e, {
192
+ }, {}), Ne = /* @__PURE__ */ x((e, n) => /* @__PURE__ */ _(Ce.label, q({}, e, {
193
193
  ref: n,
194
194
  onMouseDown: (r) => {
195
195
  var o;
196
196
  (o = e.onMouseDown) === null || o === void 0 || o.call(e, r), !r.defaultPrevented && r.detail > 1 && r.preventDefault();
197
197
  }
198
198
  }))), Ee = Ne;
199
- function Re(e) {
199
+ function Me(e) {
200
200
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
201
201
  }
202
202
  var oe = { exports: {} };
@@ -235,8 +235,8 @@ var oe = { exports: {} };
235
235
  e.exports ? (r.default = r, e.exports = r) : window.classNames = r;
236
236
  })();
237
237
  })(oe);
238
- var Me = oe.exports;
239
- const He = /* @__PURE__ */ Re(Me), K = {
238
+ var Re = oe.exports;
239
+ const He = /* @__PURE__ */ Me(Re), K = {
240
240
  "purpur-label": "_purpur-label_1jub8_1",
241
241
  "purpur-label--disabled": "_purpur-label--disabled_1jub8_9"
242
242
  }, Q = "purpur-label", Le = ({
@@ -339,15 +339,15 @@ const Te = /* @__PURE__ */ Xe(Be), L = {
339
339
  ]);
340
340
  return /* @__PURE__ */ w("p", { ...a, className: u, "data-testid": e, children: n });
341
341
  };
342
- function R() {
343
- return R = Object.assign ? Object.assign.bind() : function(e) {
342
+ function M() {
343
+ return M = Object.assign ? Object.assign.bind() : function(e) {
344
344
  for (var n = 1; n < arguments.length; n++) {
345
345
  var r = arguments[n];
346
346
  for (var o in r)
347
347
  Object.prototype.hasOwnProperty.call(r, o) && (e[o] = r[o]);
348
348
  }
349
349
  return e;
350
- }, R.apply(this, arguments);
350
+ }, M.apply(this, arguments);
351
351
  }
352
352
  function qe(e, n, { checkForDefaultPrevented: r = !0 } = {}) {
353
353
  return function(c) {
@@ -363,10 +363,10 @@ function ce(...e) {
363
363
  (r) => Fe(r, n)
364
364
  );
365
365
  }
366
- function Ue(...e) {
366
+ function Ve(...e) {
367
367
  return B(ce(...e), e);
368
368
  }
369
- function Ve(e, n = []) {
369
+ function Ue(e, n = []) {
370
370
  let r = [];
371
371
  function o(t, a) {
372
372
  const u = /* @__PURE__ */ Z(a), i = r.length;
@@ -537,37 +537,37 @@ function Qe(e) {
537
537
  e
538
538
  ]), n;
539
539
  }
540
- function M() {
541
- return M = Object.assign ? Object.assign.bind() : function(e) {
540
+ function R() {
541
+ return R = Object.assign ? Object.assign.bind() : function(e) {
542
542
  for (var n = 1; n < arguments.length; n++) {
543
543
  var r = arguments[n];
544
544
  for (var o in r)
545
545
  Object.prototype.hasOwnProperty.call(r, o) && (e[o] = r[o]);
546
546
  }
547
547
  return e;
548
- }, M.apply(this, arguments);
548
+ }, R.apply(this, arguments);
549
549
  }
550
550
  const ie = /* @__PURE__ */ x((e, n) => {
551
551
  const { children: r, ...o } = e, c = y.toArray(r), t = c.find(et);
552
552
  if (t) {
553
553
  const a = t.props.children, u = c.map((i) => i === t ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */ j(a) ? a.props.children : null : i);
554
- return /* @__PURE__ */ _(U, M({}, o, {
554
+ return /* @__PURE__ */ _(V, R({}, o, {
555
555
  ref: n
556
556
  }), /* @__PURE__ */ j(a) ? /* @__PURE__ */ H(a, void 0, u) : null);
557
557
  }
558
- return /* @__PURE__ */ _(U, M({}, o, {
558
+ return /* @__PURE__ */ _(V, R({}, o, {
559
559
  ref: n
560
560
  }), r);
561
561
  });
562
562
  ie.displayName = "Slot";
563
- const U = /* @__PURE__ */ x((e, n) => {
563
+ const V = /* @__PURE__ */ x((e, n) => {
564
564
  const { children: r, ...o } = e;
565
565
  return /* @__PURE__ */ j(r) ? /* @__PURE__ */ H(r, {
566
566
  ...tt(o, r.props),
567
567
  ref: n ? ce(n, r.ref) : r.ref
568
568
  }) : y.count(r) > 1 ? y.only(null) : null;
569
569
  });
570
- U.displayName = "SlotClone";
570
+ V.displayName = "SlotClone";
571
571
  const Ye = ({ children: e }) => /* @__PURE__ */ _(ee, null, e);
572
572
  function et(e) {
573
573
  return /* @__PURE__ */ j(e) && e.type === Ye;
@@ -615,7 +615,7 @@ const rt = [
615
615
  const { asChild: t, ...a } = o, u = t ? ie : n;
616
616
  return O(() => {
617
617
  window[Symbol.for("radix-ui")] = !0;
618
- }, []), /* @__PURE__ */ _(u, M({}, a, {
618
+ }, []), /* @__PURE__ */ _(u, R({}, a, {
619
619
  ref: c
620
620
  }));
621
621
  });
@@ -623,8 +623,8 @@ const rt = [
623
623
  ...e,
624
624
  [n]: r
625
625
  };
626
- }, {}), le = "Switch", [nt, yt] = Ve(le), [ot, at] = nt(le), ct = /* @__PURE__ */ x((e, n) => {
627
- const { __scopeSwitch: r, name: o, checked: c, defaultChecked: t, required: a, disabled: u, value: i = "on", onCheckedChange: s, ...h } = e, [l, p] = $(null), v = Ue(
626
+ }, {}), le = "Switch", [nt, yt] = Ue(le), [ot, at] = nt(le), ct = /* @__PURE__ */ x((e, n) => {
627
+ const { __scopeSwitch: r, name: o, checked: c, defaultChecked: t, required: a, disabled: u, value: i = "on", onCheckedChange: s, ...h } = e, [l, p] = $(null), v = Ve(
628
628
  n,
629
629
  (m) => p(m)
630
630
  ), f = A(!1), g = l ? !!l.closest("form") : !0, [d = !1, b] = Ge({
@@ -636,7 +636,7 @@ const rt = [
636
636
  scope: r,
637
637
  checked: d,
638
638
  disabled: u
639
- }, /* @__PURE__ */ _(se.button, R({
639
+ }, /* @__PURE__ */ _(se.button, M({
640
640
  type: "button",
641
641
  role: "switch",
642
642
  "aria-checked": d,
@@ -666,7 +666,7 @@ const rt = [
666
666
  }));
667
667
  }), ut = "SwitchThumb", it = /* @__PURE__ */ x((e, n) => {
668
668
  const { __scopeSwitch: r, ...o } = e, c = at(ut, r);
669
- return /* @__PURE__ */ _(se.span, R({
669
+ return /* @__PURE__ */ _(se.span, M({
670
670
  "data-state": pe(c.checked),
671
671
  "data-disabled": c.disabled ? "" : void 0
672
672
  }, o, {
@@ -686,7 +686,7 @@ const rt = [
686
686
  a,
687
687
  r,
688
688
  o
689
- ]), /* @__PURE__ */ _("input", R({
689
+ ]), /* @__PURE__ */ _("input", M({
690
690
  type: "checkbox",
691
691
  "aria-hidden": !0,
692
692
  defaultChecked: r
@@ -780,9 +780,9 @@ const I = /* @__PURE__ */ dt(ft), S = {
780
780
  const k = (Y(b) ? b.touches[0].clientX : b.clientX) - h;
781
781
  if (!k)
782
782
  return;
783
- const C = a + k;
784
- !p && Math.abs(C) && v(!0);
785
- const T = C > t.right ? t.right : C < t.left ? t.left : C;
783
+ const D = a + k;
784
+ !p && Math.abs(D) && v(!0);
785
+ const T = D > t.right ? t.right : D < t.left ? t.left : D;
786
786
  s(T), o == null || o({ x: T });
787
787
  },
788
788
  [o, s, p, h]
@@ -799,12 +799,12 @@ const I = /* @__PURE__ */ dt(ft), S = {
799
799
  style: { ...u, transform: `translateX(${p ? i : a}px)` }
800
800
  }) : null;
801
801
  }, ht = ({ checked: e, onChange: n }) => {
802
- var V, W;
802
+ var U, W;
803
803
  const r = A(null), o = A(null), [c, t] = $(void 0), [a, u] = $(!1), [i, s] = $(0), [h, l] = $(0), [p, v] = $(0);
804
804
  te(() => {
805
- var D, z;
806
- l(((D = o.current) == null ? void 0 : D.clientHeight) || 0), v(((z = r.current) == null ? void 0 : z.clientHeight) || 0);
807
- }, [(V = o.current) == null ? void 0 : V.clientHeight, (W = r.current) == null ? void 0 : W.clientHeight]);
805
+ var C, z;
806
+ l(((C = o.current) == null ? void 0 : C.clientHeight) || 0), v(((z = r.current) == null ? void 0 : z.clientHeight) || 0);
807
+ }, [(U = o.current) == null ? void 0 : U.clientHeight, (W = r.current) == null ? void 0 : W.clientHeight]);
808
808
  const f = (p || 0) - h, g = h + f, d = f / 2, b = g / 2, m = typeof c == "number" && (e ? c < b : c > b);
809
809
  return {
810
810
  trackRef: r,
@@ -812,8 +812,8 @@ const I = /* @__PURE__ */ dt(ft), S = {
812
812
  isDragging: a,
813
813
  bounds: { left: d, right: g },
814
814
  position: e ? g : d,
815
- onDrag: ({ x: D }) => {
816
- t(D), Math.abs((e ? g : d) - D) > 2 && u(!0);
815
+ onDrag: ({ x: C }) => {
816
+ t(C), Math.abs((e ? g : d) - C) > 2 && u(!0);
817
817
  },
818
818
  onStop: () => {
819
819
  u(!1), a && s(Date.now()), m && (n == null || n(!e));