@purpurds/checkbox 3.2.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.
@@ -1,5 +1,5 @@
1
1
  import { jsxs as z, jsx as f } from "react/jsx-runtime";
2
- import { forwardRef as g, Children as v, isValidElement as x, createElement as p, cloneElement as E, useEffect as C, Fragment as re, useCallback as F, createContext as V, useMemo as A, useContext as _e, useRef as $, useState as I, useLayoutEffect as ge, useReducer as $e } from "react";
2
+ import { forwardRef as _, Children as v, isValidElement as x, createElement as p, cloneElement as E, useEffect as O, Fragment as re, useCallback as Z, createContext as V, useMemo as A, useContext as ge, useRef as $, useState as I, useLayoutEffect as _e, useReducer as $e } from "react";
3
3
  import { flushSync as ye } from "react-dom";
4
4
  function xe(e) {
5
5
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -49,19 +49,19 @@ const Ne = /* @__PURE__ */ xe(we), Se = {
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
- }, Ce = {
52
+ }, Oe = {
53
53
  name: "error-filled",
54
54
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 24" fill="currentColor"><path fill-rule="evenodd" d="M14.268 3.5c-.77-1.333-2.694-1.333-3.464 0l-8.66 15c-.77 1.333.192 3 1.732 3h17.32c1.54 0 2.502-1.667 1.733-3l-8.66-15Zm-.694 5.067-.247 6.876h-1.566l-.247-6.876a1.03 1.03 0 1 1 2.06 0Zm.212 8.917c0 .649-.585 1.234-1.25 1.234-.648 0-1.25-.585-1.25-1.234 0-.633.602-1.234 1.25-1.234.665 0 1.25.601 1.25 1.234Z" clip-rule="evenodd"/></svg>',
55
55
  keywords: ["error-filled"],
56
56
  category: "status"
57
- }, Oe = Ne.bind(Se), G = "purpur-icon", Ae = "md", Pe = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), ke = ({ content: e = "", title: n } = {}) => {
57
+ }, Pe = Ne.bind(Se), G = "purpur-icon", Ae = "md", Ce = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), ke = ({ 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 ${Pe(t)}>${a}${e}</svg>`;
64
+ return `<svg ${Ce(t)}>${a}${e}</svg>`;
65
65
  }, je = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), Ee = ({
66
66
  ["data-testid"]: e,
67
67
  svg: n,
@@ -73,7 +73,7 @@ const Ne = /* @__PURE__ */ xe(we), Se = {
73
73
  const o = ke({
74
74
  content: je(n.svg),
75
75
  title: t
76
- }), u = Oe(a, G, `${G}--${i}`);
76
+ }), u = Pe(a, G, `${G}--${i}`);
77
77
  return /* @__PURE__ */ f(
78
78
  "span",
79
79
  {
@@ -143,7 +143,7 @@ const De = /* @__PURE__ */ Me(Re), K = {
143
143
  "aria-relevant": a,
144
144
  ...i,
145
145
  children: [
146
- /* @__PURE__ */ f(Ee, { svg: Ce, size: "xs", className: K[`${W}__icon`] }),
146
+ /* @__PURE__ */ f(Ee, { svg: Oe, size: "xs", className: K[`${W}__icon`] }),
147
147
  n
148
148
  ]
149
149
  }
@@ -187,8 +187,8 @@ var oe = { exports: {} };
187
187
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
188
188
  })();
189
189
  })(oe);
190
- var Be = oe.exports;
191
- const Le = /* @__PURE__ */ Ie(Be), ze = {
190
+ var Le = oe.exports;
191
+ const Be = /* @__PURE__ */ Ie(Le), ze = {
192
192
  "purpur-icon": "_purpur-icon_8u1lq_1",
193
193
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
194
194
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -206,20 +206,20 @@ const Le = /* @__PURE__ */ Ie(Be), ze = {
206
206
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M3 12c0-1.105.711-2 1.588-2h14.824c.877 0 1.588.895 1.588 2s-.711 2-1.588 2H4.588C3.711 14 3 13.105 3 12Z" clip-rule="evenodd"/></svg>',
207
207
  keywords: ["minus-bold"],
208
208
  category: "utility"
209
- }, He = Le.bind(ze), X = "purpur-icon", Ze = "md", Fe = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), Ve = ({ content: e = "", title: n } = {}) => {
209
+ }, He = Be.bind(ze), X = "purpur-icon", Fe = "md", Ze = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), Ve = ({ content: e = "", title: n } = {}) => {
210
210
  const t = [
211
211
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
212
212
  { name: "fill", value: "currentColor" },
213
213
  { name: "viewBox", value: "0 0 24 24" },
214
214
  n ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
215
215
  ], a = n ? `<title>${n}</title>` : "";
216
- return `<svg ${Fe(t)}>${a}${e}</svg>`;
216
+ return `<svg ${Ze(t)}>${a}${e}</svg>`;
217
217
  }, Ge = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), J = ({
218
218
  ["data-testid"]: e,
219
219
  svg: n,
220
220
  allyTitle: t,
221
221
  className: a = "",
222
- size: i = Ze,
222
+ size: i = Fe,
223
223
  ...r
224
224
  }) => {
225
225
  const o = Ve({
@@ -247,15 +247,15 @@ function T() {
247
247
  return e;
248
248
  }, T.apply(this, arguments);
249
249
  }
250
- function P() {
251
- return P = Object.assign ? Object.assign.bind() : function(e) {
250
+ function C() {
251
+ return C = Object.assign ? Object.assign.bind() : function(e) {
252
252
  for (var n = 1; n < arguments.length; n++) {
253
253
  var t = arguments[n];
254
254
  for (var a in t)
255
255
  Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
256
256
  }
257
257
  return e;
258
- }, P.apply(this, arguments);
258
+ }, C.apply(this, arguments);
259
259
  }
260
260
  function Ke(e, n) {
261
261
  typeof e == "function" ? e(n) : e != null && (e.current = n);
@@ -265,20 +265,20 @@ function We(...e) {
265
265
  (t) => Ke(t, n)
266
266
  );
267
267
  }
268
- const ae = /* @__PURE__ */ g((e, n) => {
268
+ const ae = /* @__PURE__ */ _((e, n) => {
269
269
  const { children: t, ...a } = e, i = v.toArray(t), r = i.find(Je);
270
270
  if (r) {
271
271
  const o = r.props.children, u = i.map((c) => c === r ? v.count(o) > 1 ? v.only(null) : /* @__PURE__ */ x(o) ? o.props.children : null : c);
272
- return /* @__PURE__ */ p(U, P({}, a, {
272
+ return /* @__PURE__ */ p(U, C({}, a, {
273
273
  ref: n
274
274
  }), /* @__PURE__ */ x(o) ? /* @__PURE__ */ E(o, void 0, u) : null);
275
275
  }
276
- return /* @__PURE__ */ p(U, P({}, a, {
276
+ return /* @__PURE__ */ p(U, C({}, a, {
277
277
  ref: n
278
278
  }), t);
279
279
  });
280
280
  ae.displayName = "Slot";
281
- const U = /* @__PURE__ */ g((e, n) => {
281
+ const U = /* @__PURE__ */ _((e, n) => {
282
282
  const { children: t, ...a } = e;
283
283
  return /* @__PURE__ */ x(t) ? /* @__PURE__ */ E(t, {
284
284
  ...Qe(a, t.props),
@@ -329,11 +329,11 @@ const Ye = [
329
329
  "svg",
330
330
  "ul"
331
331
  ], er = Ye.reduce((e, n) => {
332
- const t = /* @__PURE__ */ g((a, i) => {
332
+ const t = /* @__PURE__ */ _((a, i) => {
333
333
  const { asChild: r, ...o } = a, u = r ? ae : n;
334
- return C(() => {
334
+ return O(() => {
335
335
  window[Symbol.for("radix-ui")] = !0;
336
- }, []), /* @__PURE__ */ p(u, P({}, o, {
336
+ }, []), /* @__PURE__ */ p(u, C({}, o, {
337
337
  ref: i
338
338
  }));
339
339
  });
@@ -341,7 +341,7 @@ const Ye = [
341
341
  ...e,
342
342
  [n]: t
343
343
  };
344
- }, {}), rr = /* @__PURE__ */ g((e, n) => /* @__PURE__ */ p(er.label, T({}, e, {
344
+ }, {}), rr = /* @__PURE__ */ _((e, n) => /* @__PURE__ */ p(er.label, T({}, e, {
345
345
  ref: n,
346
346
  onMouseDown: (t) => {
347
347
  var a;
@@ -510,7 +510,7 @@ function ce(...e) {
510
510
  );
511
511
  }
512
512
  function se(...e) {
513
- return F(ce(...e), e);
513
+ return Z(ce(...e), e);
514
514
  }
515
515
  function fr(e, n = []) {
516
516
  let t = [];
@@ -521,18 +521,18 @@ function fr(e, n = []) {
521
521
  o
522
522
  ];
523
523
  function s(l) {
524
- const { scope: d, children: b, ..._ } = l, M = (d == null ? void 0 : d[e][c]) || u, y = A(
525
- () => _,
526
- Object.values(_)
524
+ const { scope: d, children: b, ...g } = l, M = (d == null ? void 0 : d[e][c]) || u, y = A(
525
+ () => g,
526
+ Object.values(g)
527
527
  );
528
528
  return /* @__PURE__ */ p(M.Provider, {
529
529
  value: y
530
530
  }, b);
531
531
  }
532
532
  function h(l, d) {
533
- const b = (d == null ? void 0 : d[e][c]) || u, _ = _e(b);
534
- if (_)
535
- return _;
533
+ const b = (d == null ? void 0 : d[e][c]) || u, g = ge(b);
534
+ if (g)
535
+ return g;
536
536
  if (o !== void 0)
537
537
  return o;
538
538
  throw new Error(`\`${l}\` must be used within \`${r}\``);
@@ -604,7 +604,7 @@ function ee(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
604
604
  }
605
605
  function le(e) {
606
606
  const n = $(e);
607
- return C(() => {
607
+ return O(() => {
608
608
  n.current = e;
609
609
  }), A(
610
610
  () => (...t) => {
@@ -619,7 +619,7 @@ function mr({ prop: e, defaultProp: n, onChange: t = () => {
619
619
  const [a, i] = vr({
620
620
  defaultProp: n,
621
621
  onChange: t
622
- }), r = e !== void 0, o = r ? e : a, u = le(t), c = F((s) => {
622
+ }), r = e !== void 0, o = r ? e : a, u = le(t), c = Z((s) => {
623
623
  if (r) {
624
624
  const l = typeof s == "function" ? s(e) : s;
625
625
  l !== e && u(l);
@@ -638,7 +638,7 @@ function mr({ prop: e, defaultProp: n, onChange: t = () => {
638
638
  }
639
639
  function vr({ defaultProp: e, onChange: n }) {
640
640
  const t = I(e), [a] = t, i = $(a), r = le(n);
641
- return C(() => {
641
+ return O(() => {
642
642
  i.current !== a && (r(a), i.current = a);
643
643
  }, [
644
644
  a,
@@ -655,9 +655,9 @@ function br(e) {
655
655
  e
656
656
  ]);
657
657
  }
658
- const H = globalThis != null && globalThis.document ? ge : () => {
658
+ const H = globalThis != null && globalThis.document ? _e : () => {
659
659
  };
660
- function _r(e) {
660
+ function gr(e) {
661
661
  const [n, t] = I(void 0);
662
662
  return H(() => {
663
663
  if (e) {
@@ -689,7 +689,7 @@ function _r(e) {
689
689
  e
690
690
  ]), n;
691
691
  }
692
- function gr(e, n) {
692
+ function _r(e, n) {
693
693
  return $e((t, a) => {
694
694
  const i = n[t][a];
695
695
  return i ?? t;
@@ -705,7 +705,7 @@ const pe = (e) => {
705
705
  };
706
706
  pe.displayName = "Presence";
707
707
  function $r(e) {
708
- const [n, t] = I(), a = $({}), i = $(e), r = $("none"), o = e ? "mounted" : "unmounted", [u, c] = gr(o, {
708
+ const [n, t] = I(), a = $({}), i = $(e), r = $("none"), o = e ? "mounted" : "unmounted", [u, c] = _r(o, {
709
709
  mounted: {
710
710
  UNMOUNT: "unmounted",
711
711
  ANIMATION_OUT: "unmountSuspended"
@@ -718,7 +718,7 @@ function $r(e) {
718
718
  MOUNT: "mounted"
719
719
  }
720
720
  });
721
- return C(() => {
721
+ return O(() => {
722
722
  const s = q(a.current);
723
723
  r.current = u === "mounted" ? s : "none";
724
724
  }, [
@@ -755,7 +755,7 @@ function $r(e) {
755
755
  "mounted",
756
756
  "unmountSuspended"
757
757
  ].includes(u),
758
- ref: F((s) => {
758
+ ref: Z((s) => {
759
759
  s && (a.current = getComputedStyle(s)), t(s);
760
760
  }, [])
761
761
  };
@@ -773,27 +773,27 @@ function j() {
773
773
  return e;
774
774
  }, j.apply(this, arguments);
775
775
  }
776
- const de = /* @__PURE__ */ g((e, n) => {
776
+ const de = /* @__PURE__ */ _((e, n) => {
777
777
  const { children: t, ...a } = e, i = v.toArray(t), r = i.find(xr);
778
778
  if (r) {
779
779
  const o = r.props.children, u = i.map((c) => c === r ? v.count(o) > 1 ? v.only(null) : /* @__PURE__ */ x(o) ? o.props.children : null : c);
780
- return /* @__PURE__ */ p(Z, j({}, a, {
780
+ return /* @__PURE__ */ p(F, j({}, a, {
781
781
  ref: n
782
782
  }), /* @__PURE__ */ x(o) ? /* @__PURE__ */ E(o, void 0, u) : null);
783
783
  }
784
- return /* @__PURE__ */ p(Z, j({}, a, {
784
+ return /* @__PURE__ */ p(F, j({}, a, {
785
785
  ref: n
786
786
  }), t);
787
787
  });
788
788
  de.displayName = "Slot";
789
- const Z = /* @__PURE__ */ g((e, n) => {
789
+ const F = /* @__PURE__ */ _((e, n) => {
790
790
  const { children: t, ...a } = e;
791
791
  return /* @__PURE__ */ x(t) ? /* @__PURE__ */ E(t, {
792
792
  ...wr(a, t.props),
793
793
  ref: n ? ce(n, t.ref) : t.ref
794
794
  }) : v.count(t) > 1 ? v.only(null) : null;
795
795
  });
796
- Z.displayName = "SlotClone";
796
+ F.displayName = "SlotClone";
797
797
  const yr = ({ children: e }) => /* @__PURE__ */ p(re, null, e);
798
798
  function xr(e) {
799
799
  return /* @__PURE__ */ x(e) && e.type === yr;
@@ -837,9 +837,9 @@ const Nr = [
837
837
  "svg",
838
838
  "ul"
839
839
  ], fe = Nr.reduce((e, n) => {
840
- const t = /* @__PURE__ */ g((a, i) => {
840
+ const t = /* @__PURE__ */ _((a, i) => {
841
841
  const { asChild: r, ...o } = a, u = r ? de : n;
842
- return C(() => {
842
+ return O(() => {
843
843
  window[Symbol.for("radix-ui")] = !0;
844
844
  }, []), /* @__PURE__ */ p(u, j({}, o, {
845
845
  ref: i
@@ -849,25 +849,25 @@ const Nr = [
849
849
  ...e,
850
850
  [n]: t
851
851
  };
852
- }, {}), he = "Checkbox", [Sr, Tr] = fr(he), [Cr, Or] = Sr(he), Ar = /* @__PURE__ */ g((e, n) => {
852
+ }, {}), he = "Checkbox", [Sr, Tr] = fr(he), [Or, Pr] = Sr(he), Ar = /* @__PURE__ */ _((e, n) => {
853
853
  const { __scopeCheckbox: t, name: a, checked: i, defaultChecked: r, required: o, disabled: u, value: c = "on", onCheckedChange: s, ...h } = e, [l, d] = I(null), b = se(
854
854
  n,
855
855
  (m) => d(m)
856
- ), _ = $(!1), M = l ? !!l.closest("form") : !0, [y = !1, B] = mr({
856
+ ), g = $(!1), M = l ? !!l.closest("form") : !0, [y = !1, L] = mr({
857
857
  prop: i,
858
858
  defaultProp: r,
859
859
  onChange: s
860
860
  }), be = $(y);
861
- return C(() => {
861
+ return O(() => {
862
862
  const m = l == null ? void 0 : l.form;
863
863
  if (m) {
864
- const O = () => B(be.current);
865
- return m.addEventListener("reset", O), () => m.removeEventListener("reset", O);
864
+ const P = () => L(be.current);
865
+ return m.addEventListener("reset", P), () => m.removeEventListener("reset", P);
866
866
  }
867
867
  }, [
868
868
  l,
869
- B
870
- ]), /* @__PURE__ */ p(Cr, {
869
+ L
870
+ ]), /* @__PURE__ */ p(Or, {
871
871
  scope: t,
872
872
  state: y,
873
873
  disabled: u
@@ -886,13 +886,13 @@ const Nr = [
886
886
  m.key === "Enter" && m.preventDefault();
887
887
  }),
888
888
  onClick: ee(e.onClick, (m) => {
889
- B(
890
- (O) => S(O) ? !0 : !O
891
- ), M && (_.current = m.isPropagationStopped(), _.current || m.stopPropagation());
889
+ L(
890
+ (P) => S(P) ? !0 : !P
891
+ ), M && (g.current = m.isPropagationStopped(), g.current || m.stopPropagation());
892
892
  })
893
893
  })), M && /* @__PURE__ */ p(jr, {
894
894
  control: l,
895
- bubbles: !_.current,
895
+ bubbles: !g.current,
896
896
  name: a,
897
897
  value: c,
898
898
  checked: y,
@@ -902,8 +902,8 @@ const Nr = [
902
902
  transform: "translateX(-100%)"
903
903
  }
904
904
  }));
905
- }), Pr = "CheckboxIndicator", kr = /* @__PURE__ */ g((e, n) => {
906
- const { __scopeCheckbox: t, forceMount: a, ...i } = e, r = Or(Pr, t);
905
+ }), Cr = "CheckboxIndicator", kr = /* @__PURE__ */ _((e, n) => {
906
+ const { __scopeCheckbox: t, forceMount: a, ...i } = e, r = Pr(Cr, t);
907
907
  return /* @__PURE__ */ p(pe, {
908
908
  present: a || S(r.state) || r.state === !0
909
909
  }, /* @__PURE__ */ p(fe.span, k({
@@ -917,8 +917,8 @@ const Nr = [
917
917
  }
918
918
  })));
919
919
  }), jr = (e) => {
920
- const { control: n, checked: t, bubbles: a = !0, ...i } = e, r = $(null), o = br(t), u = _r(n);
921
- return C(() => {
920
+ const { control: n, checked: t, bubbles: a = !0, ...i } = e, r = $(null), o = br(t), u = gr(n);
921
+ return O(() => {
922
922
  const c = r.current, s = window.HTMLInputElement.prototype, l = Object.getOwnPropertyDescriptor(s, "checked").set;
923
923
  if (o !== t && l) {
924
924
  const d = new Event("click", {
@@ -994,7 +994,7 @@ var ve = { exports: {} };
994
994
  })();
995
995
  })(ve);
996
996
  var Dr = ve.exports;
997
- const L = /* @__PURE__ */ Rr(Dr), w = {
997
+ const B = /* @__PURE__ */ Rr(Dr), w = {
998
998
  "purpur-checkbox": "_purpur-checkbox_10fl8_1",
999
999
  "purpur-checkbox__box": "_purpur-checkbox__box_10fl8_7",
1000
1000
  "purpur-checkbox--error": "_purpur-checkbox--error_10fl8_16",
@@ -1012,14 +1012,14 @@ const L = /* @__PURE__ */ Rr(Dr), w = {
1012
1012
  ...o
1013
1013
  }, u) => {
1014
1014
  const c = a && !n;
1015
- return /* @__PURE__ */ z("div", { className: L([t, w[`${N}__wrapper`]]), children: [
1016
- /* @__PURE__ */ z("div", { className: L([t, w[`${N}__container`]]), children: [
1015
+ return /* @__PURE__ */ z("div", { className: B([t, w[`${N}__wrapper`]]), children: [
1016
+ /* @__PURE__ */ z("div", { className: B([t, w[`${N}__container`]]), children: [
1017
1017
  /* @__PURE__ */ f(
1018
1018
  Er,
1019
1019
  {
1020
1020
  ...o,
1021
1021
  checked: n,
1022
- className: L(w[N], {
1022
+ className: B(w[N], {
1023
1023
  [w[`${N}--error`]]: c
1024
1024
  }),
1025
1025
  "data-testid": e,
@@ -1055,7 +1055,7 @@ const L = /* @__PURE__ */ Rr(Dr), w = {
1055
1055
  ] }),
1056
1056
  c && /* @__PURE__ */ f(qe, { "data-testid": e && `${e}-error-text`, children: a })
1057
1057
  ] });
1058
- }, Ir = g(qr);
1058
+ }, Ir = _(qr);
1059
1059
  Ir.displayName = "Checkbox";
1060
1060
  export {
1061
1061
  Ir as Checkbox