@purpurds/toggle 6.12.5 → 7.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../src/toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAYlE,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,GAAG;IAC9E;;SAEK;IACL,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC;IACxB;;SAEK;IACL,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC;IAC7B,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB;;SAEK;IACL,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;SAEK;IACL,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;SAEK;IACL,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;SAEK;IACL,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;SAEK;IACL,EAAE,EAAE,MAAM,CAAC;IACX;;SAEK;IACL,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;SAEK;IACL,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC;;SAEK;IACL,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;SAEK;IACL,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC;;SAEK;IACL,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;SAEK;IACL,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAuFF,eAAO,MAAM,MAAM;IA5IjB;;SAEK;mBACY,MAAM;IACvB;;SAEK;wBACiB,MAAM;oBACV,MAAM;IACxB;;SAEK;cACK,OAAO;IACjB;;SAEK;qBACY,OAAO;IACx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C;AAqFF,eAAO,MAAM,MAAM;IA1IjB;;SAEK;mBACY,MAAM;IACvB;;SAEK;wBACiB,MAAM;oBACV,MAAM;IACxB;;SAEK;cACK,OAAO;IACjB;;SAEK;qBACY,OAAO;IACxB;;SAEK;eACM,OAAO;IAClB;;SAEK;kBACS,OAAO;IACrB;;SAEK;QACD,MAAM;IACV;;SAEK;YACG,MAAM;IACd;;SAEK;oBACW,MAAM,GAAG,OAAO;IAChC;;SAEK;WACE,MAAM;IACb;;SAEK;eACM,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI;IACrC;;SAEK;eACM,OAAO;IAClB;;SAEK;YACG,MAAM;2CAsFiC,CAAC"}
package/dist/toggle.es.js CHANGED
@@ -1,19 +1,19 @@
1
- import { jsx as f, Fragment as ee, jsxs as z } from "react/jsx-runtime";
1
+ import { jsx as f, Fragment as ee, jsxs as j } from "react/jsx-runtime";
2
2
  import * as s from "react";
3
3
  import { useState as $, useCallback as A, useEffect as E, cloneElement as fe, isValidElement as he, useRef as k, forwardRef as ge } from "react";
4
4
  import "react-dom";
5
5
  function me(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
7
  }
8
- var L = { exports: {} };
8
+ var W = { 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 V;
14
+ var L;
15
15
  function ve() {
16
- return V || (V = 1, function(e) {
16
+ return L || (L = 1, function(e) {
17
17
  (function() {
18
18
  var n = {}.hasOwnProperty;
19
19
  function t() {
@@ -42,7 +42,7 @@ function ve() {
42
42
  }
43
43
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
44
44
  })();
45
- }(L)), L.exports;
45
+ }(W)), W.exports;
46
46
  }
47
47
  var _e = ve();
48
48
  const be = /* @__PURE__ */ me(_e), ye = {
@@ -53,7 +53,7 @@ const be = /* @__PURE__ */ me(_e), ye = {
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
- }, we = be.bind(ye), q = "purpur-icon", Se = "md", xe = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), Ce = ({ content: e = "", title: n } = {}) => {
56
+ }, we = be.bind(ye), V = "purpur-icon", Se = "md", xe = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), Ce = ({ 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" },
@@ -72,11 +72,10 @@ const be = /* @__PURE__ */ me(_e), ye = {
72
72
  const i = Ce({
73
73
  content: $e(n.svg),
74
74
  title: t
75
- }), u = we(a, q, `${q}--${o}`);
75
+ }), u = we(a, V, `${V}--${o}`);
76
76
  return /* @__PURE__ */ f(
77
77
  "span",
78
78
  {
79
- "aria-label": t,
80
79
  className: u,
81
80
  "data-testid": e,
82
81
  dangerouslySetInnerHTML: { __html: i },
@@ -116,20 +115,20 @@ var te = s.forwardRef((e, n) => {
116
115
  const { children: t, ...a } = e, o = s.Children.toArray(t), r = o.find(Ee);
117
116
  if (r) {
118
117
  const i = r.props.children, u = o.map((c) => c === r ? s.Children.count(i) > 1 ? s.Children.only(null) : s.isValidElement(i) ? i.props.children : null : c);
119
- return /* @__PURE__ */ f(X, { ...a, ref: n, children: s.isValidElement(i) ? s.cloneElement(i, void 0, u) : null });
118
+ return /* @__PURE__ */ f(q, { ...a, ref: n, children: s.isValidElement(i) ? s.cloneElement(i, void 0, u) : null });
120
119
  }
121
- return /* @__PURE__ */ f(X, { ...a, ref: n, children: t });
120
+ return /* @__PURE__ */ f(q, { ...a, ref: n, children: t });
122
121
  });
123
122
  te.displayName = "Slot";
124
- var X = s.forwardRef((e, n) => {
123
+ var q = s.forwardRef((e, n) => {
125
124
  const { children: t, ...a } = e;
126
125
  if (s.isValidElement(t)) {
127
- const o = De(t), r = Ne(a, t.props);
126
+ const o = ze(t), r = Ne(a, t.props);
128
127
  return t.type !== s.Fragment && (r.ref = n ? Pe(n, o) : o), s.cloneElement(t, r);
129
128
  }
130
129
  return s.Children.count(t) > 1 ? s.Children.only(null) : null;
131
130
  });
132
- X.displayName = "SlotClone";
131
+ q.displayName = "SlotClone";
133
132
  var ke = ({ children: e }) => /* @__PURE__ */ f(ee, { children: e });
134
133
  function Ee(e) {
135
134
  return s.isValidElement(e) && e.type === ke;
@@ -144,12 +143,12 @@ function Ne(e, n) {
144
143
  }
145
144
  return { ...e, ...t };
146
145
  }
147
- function De(e) {
146
+ function ze(e) {
148
147
  var n, t;
149
148
  let a = (n = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : n.get, o = a && "isReactWarning" in a && a.isReactWarning;
150
149
  return o ? e.ref : (a = (t = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : t.get, o = a && "isReactWarning" in a && a.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
151
150
  }
152
- var Oe = [
151
+ var De = [
153
152
  "a",
154
153
  "button",
155
154
  "div",
@@ -166,14 +165,14 @@ var Oe = [
166
165
  "span",
167
166
  "svg",
168
167
  "ul"
169
- ], Me = Oe.reduce((e, n) => {
168
+ ], Oe = De.reduce((e, n) => {
170
169
  const t = s.forwardRef((a, o) => {
171
170
  const { asChild: r, ...i } = a, u = r ? te : n;
172
171
  return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(u, { ...i, ref: o });
173
172
  });
174
173
  return t.displayName = `Primitive.${n}`, { ...e, [n]: t };
175
- }, {}), je = "Label", ne = s.forwardRef((e, n) => /* @__PURE__ */ f(
176
- Me.label,
174
+ }, {}), Me = "Label", ne = s.forwardRef((e, n) => /* @__PURE__ */ f(
175
+ Oe.label,
177
176
  {
178
177
  ...e,
179
178
  ref: n,
@@ -183,8 +182,8 @@ var Oe = [
183
182
  }
184
183
  }
185
184
  ));
186
- ne.displayName = je;
187
- var ze = ne;
185
+ ne.displayName = Me;
186
+ var je = ne;
188
187
  function Ae(e) {
189
188
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
190
189
  }
@@ -195,7 +194,7 @@ var T = { exports: {} };
195
194
  http://jedwatson.github.io/classnames
196
195
  */
197
196
  var F;
198
- function Xe() {
197
+ function qe() {
199
198
  return F || (F = 1, function(e) {
200
199
  (function() {
201
200
  var n = {}.hasOwnProperty;
@@ -227,30 +226,29 @@ function Xe() {
227
226
  })();
228
227
  }(T)), T.exports;
229
228
  }
230
- var Be = Xe();
231
- const We = /* @__PURE__ */ Ae(Be), D = {
229
+ var Xe = qe();
230
+ const Be = /* @__PURE__ */ Ae(Xe), z = {
232
231
  "purpur-label": "_purpur-label_1jndl_1",
233
232
  "purpur-label--negative": "_purpur-label--negative_1jndl_8",
234
233
  "purpur-label--disabled": "_purpur-label--disabled_1jndl_11"
235
- }, O = "purpur-label", Le = ({
234
+ }, D = "purpur-label", We = ({
236
235
  children: e,
237
236
  className: n,
238
- htmlFor: t,
239
- disabled: a,
240
- negative: o = !1,
241
- ...r
237
+ disabled: t,
238
+ negative: a = !1,
239
+ ...o
242
240
  }) => {
243
- const i = We([
241
+ const r = Be([
244
242
  n,
245
- D[O],
243
+ z[D],
246
244
  {
247
- [D[`${O}--disabled`]]: a,
248
- [D[`${O}--negative`]]: o
245
+ [z[`${D}--disabled`]]: t,
246
+ [z[`${D}--negative`]]: a
249
247
  }
250
248
  ]);
251
- return /* @__PURE__ */ f(ze, { className: i, htmlFor: t, ...r, children: e });
249
+ return /* @__PURE__ */ f(je, { className: r, ...o, children: e });
252
250
  };
253
- function Ve(e) {
251
+ function Le(e) {
254
252
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
255
253
  }
256
254
  var I = { exports: {} };
@@ -260,7 +258,7 @@ var I = { exports: {} };
260
258
  http://jedwatson.github.io/classnames
261
259
  */
262
260
  var U;
263
- function qe() {
261
+ function Ve() {
264
262
  return U || (U = 1, function(e) {
265
263
  (function() {
266
264
  var n = {}.hasOwnProperty;
@@ -292,8 +290,8 @@ function qe() {
292
290
  })();
293
291
  }(I)), I.exports;
294
292
  }
295
- var He = qe();
296
- const Te = /* @__PURE__ */ Ve(He), R = {
293
+ var He = Ve();
294
+ const Te = /* @__PURE__ */ Le(He), R = {
297
295
  "purpur-paragraph": "_purpur-paragraph_1rh57_1",
298
296
  "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
299
297
  "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
@@ -481,12 +479,12 @@ var ue = s.forwardRef((e, n) => {
481
479
  const { children: t, ...a } = e, o = s.Children.toArray(t), r = o.find(tr);
482
480
  if (r) {
483
481
  const i = r.props.children, u = o.map((c) => c === r ? s.Children.count(i) > 1 ? s.Children.only(null) : s.isValidElement(i) ? i.props.children : null : c);
484
- return /* @__PURE__ */ f(B, { ...a, ref: n, children: s.isValidElement(i) ? s.cloneElement(i, void 0, u) : null });
482
+ return /* @__PURE__ */ f(X, { ...a, ref: n, children: s.isValidElement(i) ? s.cloneElement(i, void 0, u) : null });
485
483
  }
486
- return /* @__PURE__ */ f(B, { ...a, ref: n, children: t });
484
+ return /* @__PURE__ */ f(X, { ...a, ref: n, children: t });
487
485
  });
488
486
  ue.displayName = "Slot";
489
- var B = s.forwardRef((e, n) => {
487
+ var X = s.forwardRef((e, n) => {
490
488
  const { children: t, ...a } = e;
491
489
  if (s.isValidElement(t)) {
492
490
  const o = or(t), r = nr(a, t.props);
@@ -494,7 +492,7 @@ var B = s.forwardRef((e, n) => {
494
492
  }
495
493
  return s.Children.count(t) > 1 ? s.Children.only(null) : null;
496
494
  });
497
- B.displayName = "SlotClone";
495
+ X.displayName = "SlotClone";
498
496
  var rr = ({ children: e }) => /* @__PURE__ */ f(ee, { children: e });
499
497
  function tr(e) {
500
498
  return s.isValidElement(e) && e.type === rr;
@@ -537,7 +535,7 @@ var ar = [
537
535
  return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(u, { ...i, ref: o });
538
536
  });
539
537
  return t.displayName = `Primitive.${n}`, { ...e, [n]: t };
540
- }, {}), W = "Switch", [ir, xr] = Ze(W), [ur, sr] = ir(W), ce = s.forwardRef(
538
+ }, {}), B = "Switch", [ir, xr] = Ze(B), [ur, sr] = ir(B), ce = s.forwardRef(
541
539
  (e, n) => {
542
540
  const {
543
541
  __scopeSwitch: t,
@@ -555,7 +553,7 @@ var ar = [
555
553
  defaultProp: r,
556
554
  onChange: l
557
555
  });
558
- return /* @__PURE__ */ z(ur, { scope: t, checked: _, disabled: u, children: [
556
+ return /* @__PURE__ */ j(ur, { scope: t, checked: _, disabled: u, children: [
559
557
  /* @__PURE__ */ f(
560
558
  se.button,
561
559
  {
@@ -591,7 +589,7 @@ var ar = [
591
589
  ] });
592
590
  }
593
591
  );
594
- ce.displayName = W;
592
+ ce.displayName = B;
595
593
  var le = "SwitchThumb", pe = s.forwardRef(
596
594
  (e, n) => {
597
595
  const { __scopeSwitch: t, ...a } = e, o = sr(le, t);
@@ -642,7 +640,7 @@ var lr = ce, pr = pe;
642
640
  function dr(e) {
643
641
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
644
642
  }
645
- var M = { exports: {} };
643
+ var O = { exports: {} };
646
644
  /*!
647
645
  Copyright (c) 2018 Jed Watson.
648
646
  Licensed under the MIT License (MIT), see
@@ -679,10 +677,10 @@ function fr() {
679
677
  }
680
678
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
681
679
  })();
682
- }(M)), M.exports;
680
+ }(O)), O.exports;
683
681
  }
684
682
  var hr = fr();
685
- const j = /* @__PURE__ */ dr(hr), J = (e) => e && "touches" in e, gr = ({
683
+ const M = /* @__PURE__ */ dr(hr), J = (e) => e && "touches" in e, gr = ({
686
684
  children: e,
687
685
  disabled: n,
688
686
  onStart: t,
@@ -780,15 +778,15 @@ const vr = ({ checked: e, onChange: n }) => {
780
778
  }
781
779
  };
782
780
  }, S = {
783
- "purpur-toggle": "_purpur-toggle_1xng6_1",
784
- "purpur-toggle__track": "_purpur-toggle__track_1xng6_7",
785
- "purpur-toggle__checkmark-container": "_purpur-toggle__checkmark-container_1xng6_45",
786
- "purpur-toggle__thumb": "_purpur-toggle__thumb_1xng6_60",
787
- "purpur-toggle__thumb--dragging": "_purpur-toggle__thumb--dragging_1xng6_80",
788
- "purpur-toggle__checkmark": "_purpur-toggle__checkmark_1xng6_45",
789
- "purpur-toggle__label--right": "_purpur-toggle__label--right_1xng6_100",
790
- "purpur-toggle__label--left": "_purpur-toggle__label--left_1xng6_103",
791
- "purpur-toggle__container": "_purpur-toggle__container_1xng6_106"
781
+ "purpur-toggle": "_purpur-toggle_zqs8u_1",
782
+ "purpur-toggle__track": "_purpur-toggle__track_zqs8u_7",
783
+ "purpur-toggle__checkmark-container": "_purpur-toggle__checkmark-container_zqs8u_45",
784
+ "purpur-toggle__thumb": "_purpur-toggle__thumb_zqs8u_60",
785
+ "purpur-toggle__thumb--dragging": "_purpur-toggle__thumb--dragging_zqs8u_85",
786
+ "purpur-toggle__checkmark": "_purpur-toggle__checkmark_zqs8u_45",
787
+ "purpur-toggle__label--right": "_purpur-toggle__label--right_zqs8u_110",
788
+ "purpur-toggle__label--left": "_purpur-toggle__label--left_zqs8u_113",
789
+ "purpur-toggle__container": "_purpur-toggle__container_zqs8u_116"
792
790
  }, x = "purpur-toggle", _r = ({
793
791
  ["data-testid"]: e,
794
792
  className: n,
@@ -808,19 +806,19 @@ const vr = ({ checked: e, onChange: n }) => {
808
806
  c.disabled || (a == null || a(y), d(y));
809
807
  }
810
808
  }), C = () => /* @__PURE__ */ f(
811
- Le,
809
+ We,
812
810
  {
813
811
  htmlFor: c.id,
814
812
  "data-testid": e && `${e}-label`,
815
813
  disabled: c.disabled,
816
- className: j(
814
+ className: M(
817
815
  S[`${x}__label`],
818
816
  S[`${x}__label--${o}`]
819
817
  ),
820
- children: /* @__PURE__ */ f(oe, { variant: "paragraph-100", disabled: c.disabled, children: t })
818
+ children: /* @__PURE__ */ f(oe, { disabled: c.disabled, children: t })
821
819
  }
822
820
  );
823
- return /* @__PURE__ */ z("div", { className: j([n, S[`${x}__container`]]), children: [
821
+ return /* @__PURE__ */ j("div", { className: M([n, S[`${x}__container`]]), children: [
824
822
  t && o === "left" && C(),
825
823
  /* @__PURE__ */ f(
826
824
  lr,
@@ -832,7 +830,7 @@ const vr = ({ checked: e, onChange: n }) => {
832
830
  className: S[x],
833
831
  onCheckedChange: b,
834
832
  checked: p,
835
- children: /* @__PURE__ */ z("span", { ref: h, className: S[`${x}__track`], children: [
833
+ children: /* @__PURE__ */ j("span", { ref: h, className: S[`${x}__track`], children: [
836
834
  /* @__PURE__ */ f("span", { className: S[`${x}__checkmark-container`], children: /* @__PURE__ */ f(
837
835
  re,
838
836
  {
@@ -846,7 +844,7 @@ const vr = ({ checked: e, onChange: n }) => {
846
844
  {
847
845
  ref: g,
848
846
  "data-testid": e && `${e}-thumb`,
849
- className: j([
847
+ className: M([
850
848
  S[`${x}__thumb`],
851
849
  {
852
850
  [S[`${x}__thumb--dragging`]]: m