@purpurds/toggle 4.6.0 → 5.0.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,5 +1,5 @@
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 X, useEffect as A, Fragment as ee, useCallback as B, createContext as Z, useMemo as R, useContext as fe, useRef as D, useState as $, useLayoutEffect as re } from "react";
1
+ import { jsx as x, jsxs as J } from "react/jsx-runtime";
2
+ import { forwardRef as w, Children as y, isValidElement as k, createElement as _, cloneElement as X, useEffect as A, Fragment as ee, useCallback as B, createContext as K, useMemo as R, useContext as fe, useRef as D, useState as $, useLayoutEffect as re } from "react";
3
3
  import "react-dom";
4
4
  function ge(e) {
5
5
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -54,7 +54,7 @@ const be = /* @__PURE__ */ ge(he), _e = {
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
- }, 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 } = {}) => {
57
+ }, me = be.bind(_e), Q = "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" },
@@ -73,7 +73,7 @@ const be = /* @__PURE__ */ ge(he), _e = {
73
73
  const a = xe({
74
74
  content: we(n.svg),
75
75
  title: t
76
- }), u = me(o, J, `${J}--${c}`);
76
+ }), u = me(o, Q, `${Q}--${c}`);
77
77
  return /* @__PURE__ */ x(
78
78
  "span",
79
79
  {
@@ -85,15 +85,15 @@ const be = /* @__PURE__ */ ge(he), _e = {
85
85
  }
86
86
  );
87
87
  };
88
- function q() {
89
- return q = Object.assign ? Object.assign.bind() : function(e) {
88
+ function V() {
89
+ return V = Object.assign ? Object.assign.bind() : function(e) {
90
90
  for (var n = 1; n < arguments.length; n++) {
91
91
  var t = arguments[n];
92
92
  for (var o in t)
93
93
  Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
94
94
  }
95
95
  return e;
96
- }, q.apply(this, arguments);
96
+ }, V.apply(this, arguments);
97
97
  }
98
98
  function M() {
99
99
  return M = Object.assign ? Object.assign.bind() : function(e) {
@@ -117,23 +117,23 @@ const ne = /* @__PURE__ */ w((e, n) => {
117
117
  const { children: t, ...o } = e, c = y.toArray(t), r = c.find(Ae);
118
118
  if (r) {
119
119
  const a = r.props.children, u = c.map((i) => i === r ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */ k(a) ? a.props.children : null : i);
120
- return /* @__PURE__ */ _(F, M({}, o, {
120
+ return /* @__PURE__ */ _(U, M({}, o, {
121
121
  ref: n
122
122
  }), /* @__PURE__ */ k(a) ? /* @__PURE__ */ X(a, void 0, u) : null);
123
123
  }
124
- return /* @__PURE__ */ _(F, M({}, o, {
124
+ return /* @__PURE__ */ _(U, M({}, o, {
125
125
  ref: n
126
126
  }), t);
127
127
  });
128
128
  ne.displayName = "Slot";
129
- const F = /* @__PURE__ */ w((e, n) => {
129
+ const U = /* @__PURE__ */ w((e, n) => {
130
130
  const { children: t, ...o } = e;
131
131
  return /* @__PURE__ */ k(t) ? /* @__PURE__ */ X(t, {
132
132
  ...De(o, t.props),
133
133
  ref: n ? ke(n, t.ref) : t.ref
134
134
  }) : y.count(t) > 1 ? y.only(null) : null;
135
135
  });
136
- F.displayName = "SlotClone";
136
+ U.displayName = "SlotClone";
137
137
  const Oe = ({ children: e }) => /* @__PURE__ */ _(ee, null, e);
138
138
  function Ae(e) {
139
139
  return /* @__PURE__ */ k(e) && e.type === Oe;
@@ -189,7 +189,7 @@ const Ce = [
189
189
  ...e,
190
190
  [n]: t
191
191
  };
192
- }, {}), Ne = /* @__PURE__ */ w((e, n) => /* @__PURE__ */ _(Ee.label, q({}, e, {
192
+ }, {}), Ne = /* @__PURE__ */ w((e, n) => /* @__PURE__ */ _(Ee.label, V({}, e, {
193
193
  ref: n,
194
194
  onMouseDown: (t) => {
195
195
  var o;
@@ -236,23 +236,28 @@ var oe = { exports: {} };
236
236
  })();
237
237
  })(oe);
238
238
  var Me = oe.exports;
239
- const He = /* @__PURE__ */ Re(Me), K = {
240
- "purpur-label": "_purpur-label_1tkut_1",
241
- "purpur-label--disabled": "_purpur-label--disabled_1tkut_9"
242
- }, Q = "purpur-label", Le = ({
239
+ const He = /* @__PURE__ */ Re(Me), I = {
240
+ "purpur-label": "_purpur-label_12cfi_1",
241
+ "purpur-label--negative": "_purpur-label--negative_12cfi_9",
242
+ "purpur-label--disabled": "_purpur-label--disabled_12cfi_12"
243
+ }, q = "purpur-label", Le = ({
243
244
  children: e,
244
245
  className: n,
245
246
  htmlFor: t,
246
247
  "data-testid": o,
247
248
  disabled: c,
248
- ...r
249
+ negative: r = !1,
250
+ ...a
249
251
  }) => {
250
- const a = He([
252
+ const u = He([
251
253
  n,
252
- K[Q],
253
- { [K[`${Q}--disabled`]]: c }
254
+ I[q],
255
+ {
256
+ [I[`${q}--disabled`]]: c,
257
+ [I[`${q}--negative`]]: r
258
+ }
254
259
  ]);
255
- return /* @__PURE__ */ x(je, { className: a, "data-testid": o, htmlFor: t, ...r, children: e });
260
+ return /* @__PURE__ */ x(je, { className: u, "data-testid": o, htmlFor: t, ...a, children: e });
256
261
  };
257
262
  function Xe(e) {
258
263
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -372,7 +377,7 @@ function Ve(...e) {
372
377
  function Ue(e, n = []) {
373
378
  let t = [];
374
379
  function o(r, a) {
375
- const u = /* @__PURE__ */ Z(a), i = t.length;
380
+ const u = /* @__PURE__ */ K(a), i = t.length;
376
381
  t = [
377
382
  ...t,
378
383
  a
@@ -400,7 +405,7 @@ function Ue(e, n = []) {
400
405
  ];
401
406
  }
402
407
  const c = () => {
403
- const r = t.map((a) => /* @__PURE__ */ Z(a));
408
+ const r = t.map((a) => /* @__PURE__ */ K(a));
404
409
  return function(u) {
405
410
  const i = (u == null ? void 0 : u[e]) || r;
406
411
  return R(
@@ -554,23 +559,23 @@ const ie = /* @__PURE__ */ w((e, n) => {
554
559
  const { children: t, ...o } = e, c = y.toArray(t), r = c.find(er);
555
560
  if (r) {
556
561
  const a = r.props.children, u = c.map((i) => i === r ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */ k(a) ? a.props.children : null : i);
557
- return /* @__PURE__ */ _(V, L({}, o, {
562
+ return /* @__PURE__ */ _(W, L({}, o, {
558
563
  ref: n
559
564
  }), /* @__PURE__ */ k(a) ? /* @__PURE__ */ X(a, void 0, u) : null);
560
565
  }
561
- return /* @__PURE__ */ _(V, L({}, o, {
566
+ return /* @__PURE__ */ _(W, L({}, o, {
562
567
  ref: n
563
568
  }), t);
564
569
  });
565
570
  ie.displayName = "Slot";
566
- const V = /* @__PURE__ */ w((e, n) => {
571
+ const W = /* @__PURE__ */ w((e, n) => {
567
572
  const { children: t, ...o } = e;
568
573
  return /* @__PURE__ */ k(t) ? /* @__PURE__ */ X(t, {
569
574
  ...rr(o, t.props),
570
575
  ref: n ? ce(n, t.ref) : t.ref
571
576
  }) : y.count(t) > 1 ? y.only(null) : null;
572
577
  });
573
- V.displayName = "SlotClone";
578
+ W.displayName = "SlotClone";
574
579
  const Ye = ({ children: e }) => /* @__PURE__ */ _(ee, null, e);
575
580
  function er(e) {
576
581
  return /* @__PURE__ */ k(e) && e.type === Ye;
@@ -750,7 +755,7 @@ var de = { exports: {} };
750
755
  })();
751
756
  })(de);
752
757
  var fr = de.exports;
753
- const I = /* @__PURE__ */ dr(fr), S = {
758
+ const F = /* @__PURE__ */ dr(fr), S = {
754
759
  "purpur-toggle": "_purpur-toggle_1xng6_1",
755
760
  "purpur-toggle__track": "_purpur-toggle__track_1xng6_7",
756
761
  "purpur-toggle__checkmark-container": "_purpur-toggle__checkmark-container_1xng6_45",
@@ -802,12 +807,12 @@ const I = /* @__PURE__ */ dr(fr), S = {
802
807
  style: { ...u, transform: `translateX(${p ? i : a}px)` }
803
808
  }) : null;
804
809
  }, hr = ({ checked: e, onChange: n }) => {
805
- var U, W;
810
+ var G, Z;
806
811
  const t = D(null), o = D(null), [c, r] = $(void 0), [a, u] = $(!1), [i, s] = $(0), [h, l] = $(0), [p, v] = $(0);
807
812
  re(() => {
808
813
  var E, z;
809
814
  l(((E = o.current) == null ? void 0 : E.clientHeight) || 0), v(((z = t.current) == null ? void 0 : z.clientHeight) || 0);
810
- }, [(U = o.current) == null ? void 0 : U.clientHeight, (W = t.current) == null ? void 0 : W.clientHeight]);
815
+ }, [(G = o.current) == null ? void 0 : G.clientHeight, (Z = t.current) == null ? void 0 : Z.clientHeight]);
811
816
  const f = (p || 0) - h, g = h + f, d = f / 2, b = g / 2, m = typeof c == "number" && (e ? c < b : c > b);
812
817
  return {
813
818
  trackRef: t,
@@ -849,14 +854,14 @@ const I = /* @__PURE__ */ dr(fr), S = {
849
854
  htmlFor: i.id,
850
855
  "data-testid": e && `${e}-label`,
851
856
  disabled: i.disabled,
852
- className: I(
857
+ className: F(
853
858
  S[`${P}__label`],
854
859
  S[`${P}__label--${c}`]
855
860
  ),
856
861
  children: /* @__PURE__ */ x(Ie, { variant: "paragraph-100", disabled: i.disabled, children: t })
857
862
  }
858
863
  );
859
- return /* @__PURE__ */ G("div", { className: I([n, S[`${P}__container`]]), children: [
864
+ return /* @__PURE__ */ J("div", { className: F([n, S[`${P}__container`]]), children: [
860
865
  t && c === "left" && m(),
861
866
  /* @__PURE__ */ x(
862
867
  lr,
@@ -868,7 +873,7 @@ const I = /* @__PURE__ */ dr(fr), S = {
868
873
  className: S[P],
869
874
  onCheckedChange: d,
870
875
  checked: p,
871
- children: /* @__PURE__ */ G("span", { ref: f, className: S[`${P}__track`], children: [
876
+ children: /* @__PURE__ */ J("span", { ref: f, className: S[`${P}__track`], children: [
872
877
  /* @__PURE__ */ x("span", { className: S[`${P}__checkmark-container`], children: /* @__PURE__ */ x(
873
878
  Se,
874
879
  {
@@ -882,7 +887,7 @@ const I = /* @__PURE__ */ dr(fr), S = {
882
887
  {
883
888
  ref: v,
884
889
  "data-testid": e && `${e}-thumb`,
885
- className: I([
890
+ className: F([
886
891
  S[`${P}__thumb`],
887
892
  {
888
893
  [S[`${P}__thumb--dragging`]]: g