@purpurds/checkbox 3.7.0 → 4.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.
@@ -1,7 +1,7 @@
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 O, Fragment as re, useCallback as Z, createContext as V, useMemo as A, useContext as _e, useRef as $, useState as I, useLayoutEffect as ge, useReducer as $e } from "react";
3
- import { flushSync as ye } from "react-dom";
4
- function xe(e) {
1
+ import { jsxs as B, jsx as f } from "react/jsx-runtime";
2
+ import { forwardRef as g, Children as v, isValidElement as y, createElement as p, cloneElement as E, useEffect as O, Fragment as re, useCallback as Z, createContext as V, useMemo as A, useContext as _e, useRef as $, useState as q, useLayoutEffect as ge, useReducer as $e } from "react";
3
+ import { flushSync as xe } from "react-dom";
4
+ function ye(e) {
5
5
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6
6
  }
7
7
  var te = { exports: {} };
@@ -41,7 +41,7 @@ var te = { exports: {} };
41
41
  })();
42
42
  })(te);
43
43
  var we = te.exports;
44
- const Ne = /* @__PURE__ */ xe(we), Se = {
44
+ const Ne = /* @__PURE__ */ ye(we), Se = {
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",
@@ -124,20 +124,20 @@ var ne = { exports: {} };
124
124
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
125
125
  })();
126
126
  })(ne);
127
- var Re = ne.exports;
128
- const De = /* @__PURE__ */ Me(Re), K = {
127
+ var ze = ne.exports;
128
+ const Re = /* @__PURE__ */ Me(ze), K = {
129
129
  "purpur-field-error-text": "_purpur-field-error-text_1h4gy_1",
130
130
  "purpur-field-error-text__icon": "_purpur-field-error-text__icon_1h4gy_12"
131
- }, W = "purpur-field-error-text", qe = ({
131
+ }, W = "purpur-field-error-text", De = ({
132
132
  ["data-testid"]: e,
133
133
  children: n,
134
134
  className: t,
135
135
  relevant: a = "additions text",
136
136
  ...i
137
- }) => /* @__PURE__ */ z(
137
+ }) => /* @__PURE__ */ B(
138
138
  "div",
139
139
  {
140
- className: De([t, K[W]]),
140
+ className: Re([t, K[W]]),
141
141
  "data-testid": e,
142
142
  "aria-live": "assertive",
143
143
  "aria-relevant": a,
@@ -148,7 +148,7 @@ const De = /* @__PURE__ */ Me(Re), K = {
148
148
  ]
149
149
  }
150
150
  );
151
- function Ie(e) {
151
+ function qe(e) {
152
152
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
153
153
  }
154
154
  var oe = { exports: {} };
@@ -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 Le = oe.exports;
191
- const Be = /* @__PURE__ */ Ie(Le), ze = {
190
+ var Ie = oe.exports;
191
+ const Le = /* @__PURE__ */ qe(Ie), Be = {
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,7 +206,7 @@ const Be = /* @__PURE__ */ Ie(Le), 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 = 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 } = {}) => {
209
+ }, He = Le.bind(Be), 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" },
@@ -268,10 +268,10 @@ function We(...e) {
268
268
  const ae = /* @__PURE__ */ g((e, n) => {
269
269
  const { children: t, ...a } = e, i = v.toArray(t), r = i.find(Je);
270
270
  if (r) {
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);
271
+ const o = r.props.children, u = i.map((c) => c === r ? v.count(o) > 1 ? v.only(null) : /* @__PURE__ */ y(o) ? o.props.children : null : c);
272
272
  return /* @__PURE__ */ p(U, C({}, a, {
273
273
  ref: n
274
- }), /* @__PURE__ */ x(o) ? /* @__PURE__ */ E(o, void 0, u) : null);
274
+ }), /* @__PURE__ */ y(o) ? /* @__PURE__ */ E(o, void 0, u) : null);
275
275
  }
276
276
  return /* @__PURE__ */ p(U, C({}, a, {
277
277
  ref: n
@@ -280,7 +280,7 @@ const ae = /* @__PURE__ */ g((e, n) => {
280
280
  ae.displayName = "Slot";
281
281
  const U = /* @__PURE__ */ g((e, n) => {
282
282
  const { children: t, ...a } = e;
283
- return /* @__PURE__ */ x(t) ? /* @__PURE__ */ E(t, {
283
+ return /* @__PURE__ */ y(t) ? /* @__PURE__ */ E(t, {
284
284
  ...Qe(a, t.props),
285
285
  ref: n ? We(n, t.ref) : t.ref
286
286
  }) : v.count(t) > 1 ? v.only(null) : null;
@@ -288,7 +288,7 @@ const U = /* @__PURE__ */ g((e, n) => {
288
288
  U.displayName = "SlotClone";
289
289
  const Xe = ({ children: e }) => /* @__PURE__ */ p(re, null, e);
290
290
  function Je(e) {
291
- return /* @__PURE__ */ x(e) && e.type === Xe;
291
+ return /* @__PURE__ */ y(e) && e.type === Xe;
292
292
  }
293
293
  function Qe(e, n) {
294
294
  const t = {
@@ -446,20 +446,20 @@ var ue = { exports: {} };
446
446
  })();
447
447
  })(ue);
448
448
  var cr = ue.exports;
449
- const sr = /* @__PURE__ */ ur(cr), R = {
450
- "purpur-paragraph": "_purpur-paragraph_hwaj6_1",
451
- "purpur-paragraph--disabled": "_purpur-paragraph--disabled_hwaj6_7",
452
- "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_hwaj6_10",
453
- "purpur-paragraph--paragraph-100": "_purpur-paragraph--paragraph-100_hwaj6_13",
454
- "purpur-paragraph--paragraph-100-medium": "_purpur-paragraph--paragraph-100-medium_hwaj6_19",
455
- "purpur-paragraph--paragraph-100-bold": "_purpur-paragraph--paragraph-100-bold_hwaj6_26",
456
- "purpur-paragraph--paragraph-200": "_purpur-paragraph--paragraph-200_hwaj6_33",
457
- "purpur-paragraph--preamble-100": "_purpur-paragraph--preamble-100_hwaj6_39",
458
- "purpur-paragraph--preamble-200": "_purpur-paragraph--preamble-200_hwaj6_45",
459
- "purpur-paragraph--additional-100": "_purpur-paragraph--additional-100_hwaj6_51",
460
- "purpur-paragraph--additional-100-medium": "_purpur-paragraph--additional-100-medium_hwaj6_57",
461
- "purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_hwaj6_64",
462
- "purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_hwaj6_71"
449
+ const sr = /* @__PURE__ */ ur(cr), z = {
450
+ "purpur-paragraph": "_purpur-paragraph_1fzxr_1",
451
+ "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1fzxr_7",
452
+ "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1fzxr_10",
453
+ "purpur-paragraph--paragraph-100": "_purpur-paragraph--paragraph-100_1fzxr_13",
454
+ "purpur-paragraph--paragraph-100-medium": "_purpur-paragraph--paragraph-100-medium_1fzxr_19",
455
+ "purpur-paragraph--paragraph-100-bold": "_purpur-paragraph--paragraph-100-bold_1fzxr_26",
456
+ "purpur-paragraph--paragraph-200": "_purpur-paragraph--paragraph-200_1fzxr_33",
457
+ "purpur-paragraph--preamble-100": "_purpur-paragraph--preamble-100_1fzxr_39",
458
+ "purpur-paragraph--preamble-200": "_purpur-paragraph--preamble-200_1fzxr_45",
459
+ "purpur-paragraph--additional-100": "_purpur-paragraph--additional-100_1fzxr_51",
460
+ "purpur-paragraph--additional-100-medium": "_purpur-paragraph--additional-100-medium_1fzxr_57",
461
+ "purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_1fzxr_64",
462
+ "purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_1fzxr_71"
463
463
  }, lr = {
464
464
  PARAGRAPH100: "paragraph-100",
465
465
  PARAGRAPH100MEDIUM: "paragraph-100-medium",
@@ -471,7 +471,7 @@ const sr = /* @__PURE__ */ ur(cr), R = {
471
471
  ADDITIONAL100MEDIUM: "additional-100-medium",
472
472
  OVERLINE100: "overline-100",
473
473
  OVERLINE200: "overline-200"
474
- }, D = "purpur-paragraph", pr = ({
474
+ }, R = "purpur-paragraph", pr = ({
475
475
  ["data-testid"]: e,
476
476
  children: n,
477
477
  className: t = "",
@@ -482,11 +482,11 @@ const sr = /* @__PURE__ */ ur(cr), R = {
482
482
  }) => {
483
483
  const u = sr([
484
484
  t,
485
- R[D],
486
- R[`${D}--${r}`],
485
+ z[R],
486
+ z[`${R}--${r}`],
487
487
  {
488
- [R[`${D}--hyphens`]]: i,
489
- [R[`${D}--disabled`]]: a
488
+ [z[`${R}--hyphens`]]: i,
489
+ [z[`${R}--disabled`]]: a
490
490
  }
491
491
  ]);
492
492
  return /* @__PURE__ */ f("p", { ...o, className: u, "data-testid": e, children: n });
@@ -521,12 +521,12 @@ 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(
524
+ const { scope: d, children: b, ..._ } = l, M = (d == null ? void 0 : d[e][c]) || u, x = A(
525
525
  () => _,
526
526
  Object.values(_)
527
527
  );
528
528
  return /* @__PURE__ */ p(M.Provider, {
529
- value: y
529
+ value: x
530
530
  }, b);
531
531
  }
532
532
  function h(l, d) {
@@ -637,7 +637,7 @@ function mr({ prop: e, defaultProp: n, onChange: t = () => {
637
637
  ];
638
638
  }
639
639
  function vr({ defaultProp: e, onChange: n }) {
640
- const t = I(e), [a] = t, i = $(a), r = le(n);
640
+ const t = q(e), [a] = t, i = $(a), r = le(n);
641
641
  return O(() => {
642
642
  i.current !== a && (r(a), i.current = a);
643
643
  }, [
@@ -658,7 +658,7 @@ function br(e) {
658
658
  const H = globalThis != null && globalThis.document ? ge : () => {
659
659
  };
660
660
  function _r(e) {
661
- const [n, t] = I(void 0);
661
+ const [n, t] = q(void 0);
662
662
  return H(() => {
663
663
  if (e) {
664
664
  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] = q(), a = $({}), i = $(e), r = $("none"), o = e ? "mounted" : "unmounted", [u, c] = gr(o, {
709
709
  mounted: {
710
710
  UNMOUNT: "unmounted",
711
711
  ANIMATION_OUT: "unmountSuspended"
@@ -719,14 +719,14 @@ function $r(e) {
719
719
  }
720
720
  });
721
721
  return O(() => {
722
- const s = q(a.current);
722
+ const s = D(a.current);
723
723
  r.current = u === "mounted" ? s : "none";
724
724
  }, [
725
725
  u
726
726
  ]), H(() => {
727
727
  const s = a.current, h = i.current;
728
728
  if (h !== e) {
729
- const d = r.current, b = q(s);
729
+ const d = r.current, b = D(s);
730
730
  e ? c("MOUNT") : b === "none" || (s == null ? void 0 : s.display) === "none" ? c("UNMOUNT") : c(h && d !== b ? "ANIMATION_OUT" : "UNMOUNT"), i.current = e;
731
731
  }
732
732
  }, [
@@ -735,12 +735,12 @@ function $r(e) {
735
735
  ]), H(() => {
736
736
  if (n) {
737
737
  const s = (l) => {
738
- const b = q(a.current).includes(l.animationName);
739
- l.target === n && b && ye(
738
+ const b = D(a.current).includes(l.animationName);
739
+ l.target === n && b && xe(
740
740
  () => c("ANIMATION_END")
741
741
  );
742
742
  }, h = (l) => {
743
- l.target === n && (r.current = q(a.current));
743
+ l.target === n && (r.current = D(a.current));
744
744
  };
745
745
  return n.addEventListener("animationstart", h), n.addEventListener("animationcancel", s), n.addEventListener("animationend", s), () => {
746
746
  n.removeEventListener("animationstart", h), n.removeEventListener("animationcancel", s), n.removeEventListener("animationend", s);
@@ -760,7 +760,7 @@ function $r(e) {
760
760
  }, [])
761
761
  };
762
762
  }
763
- function q(e) {
763
+ function D(e) {
764
764
  return (e == null ? void 0 : e.animationName) || "none";
765
765
  }
766
766
  function j() {
@@ -774,12 +774,12 @@ function j() {
774
774
  }, j.apply(this, arguments);
775
775
  }
776
776
  const de = /* @__PURE__ */ g((e, n) => {
777
- const { children: t, ...a } = e, i = v.toArray(t), r = i.find(xr);
777
+ const { children: t, ...a } = e, i = v.toArray(t), r = i.find(yr);
778
778
  if (r) {
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);
779
+ const o = r.props.children, u = i.map((c) => c === r ? v.count(o) > 1 ? v.only(null) : /* @__PURE__ */ y(o) ? o.props.children : null : c);
780
780
  return /* @__PURE__ */ p(F, j({}, a, {
781
781
  ref: n
782
- }), /* @__PURE__ */ x(o) ? /* @__PURE__ */ E(o, void 0, u) : null);
782
+ }), /* @__PURE__ */ y(o) ? /* @__PURE__ */ E(o, void 0, u) : null);
783
783
  }
784
784
  return /* @__PURE__ */ p(F, j({}, a, {
785
785
  ref: n
@@ -788,15 +788,15 @@ const de = /* @__PURE__ */ g((e, n) => {
788
788
  de.displayName = "Slot";
789
789
  const F = /* @__PURE__ */ g((e, n) => {
790
790
  const { children: t, ...a } = e;
791
- return /* @__PURE__ */ x(t) ? /* @__PURE__ */ E(t, {
791
+ return /* @__PURE__ */ y(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
796
  F.displayName = "SlotClone";
797
- const yr = ({ children: e }) => /* @__PURE__ */ p(re, null, e);
798
- function xr(e) {
799
- return /* @__PURE__ */ x(e) && e.type === yr;
797
+ const xr = ({ children: e }) => /* @__PURE__ */ p(re, null, e);
798
+ function yr(e) {
799
+ return /* @__PURE__ */ y(e) && e.type === xr;
800
800
  }
801
801
  function wr(e, n) {
802
802
  const t = {
@@ -850,33 +850,33 @@ const Nr = [
850
850
  [n]: t
851
851
  };
852
852
  }, {}), he = "Checkbox", [Sr, Tr] = fr(he), [Or, Pr] = Sr(he), Ar = /* @__PURE__ */ g((e, n) => {
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(
853
+ const { __scopeCheckbox: t, name: a, checked: i, defaultChecked: r, required: o, disabled: u, value: c = "on", onCheckedChange: s, ...h } = e, [l, d] = q(null), b = se(
854
854
  n,
855
855
  (m) => d(m)
856
- ), _ = $(!1), M = l ? !!l.closest("form") : !0, [y = !1, L] = mr({
856
+ ), _ = $(!1), M = l ? !!l.closest("form") : !0, [x = !1, I] = mr({
857
857
  prop: i,
858
858
  defaultProp: r,
859
859
  onChange: s
860
- }), be = $(y);
860
+ }), be = $(x);
861
861
  return O(() => {
862
862
  const m = l == null ? void 0 : l.form;
863
863
  if (m) {
864
- const P = () => L(be.current);
864
+ const P = () => I(be.current);
865
865
  return m.addEventListener("reset", P), () => m.removeEventListener("reset", P);
866
866
  }
867
867
  }, [
868
868
  l,
869
- L
869
+ I
870
870
  ]), /* @__PURE__ */ p(Or, {
871
871
  scope: t,
872
- state: y,
872
+ state: x,
873
873
  disabled: u
874
874
  }, /* @__PURE__ */ p(fe.button, k({
875
875
  type: "button",
876
876
  role: "checkbox",
877
- "aria-checked": S(y) ? "mixed" : y,
877
+ "aria-checked": S(x) ? "mixed" : x,
878
878
  "aria-required": o,
879
- "data-state": me(y),
879
+ "data-state": me(x),
880
880
  "data-disabled": u ? "" : void 0,
881
881
  disabled: u,
882
882
  value: c
@@ -886,7 +886,7 @@ const Nr = [
886
886
  m.key === "Enter" && m.preventDefault();
887
887
  }),
888
888
  onClick: ee(e.onClick, (m) => {
889
- L(
889
+ I(
890
890
  (P) => S(P) ? !0 : !P
891
891
  ), M && (_.current = m.isPropagationStopped(), _.current || m.stopPropagation());
892
892
  })
@@ -895,7 +895,7 @@ const Nr = [
895
895
  bubbles: !_.current,
896
896
  name: a,
897
897
  value: c,
898
- checked: y,
898
+ checked: x,
899
899
  required: o,
900
900
  disabled: u,
901
901
  style: {
@@ -954,7 +954,7 @@ function me(e) {
954
954
  return S(e) ? "indeterminate" : e ? "checked" : "unchecked";
955
955
  }
956
956
  const Er = Ar, Mr = kr;
957
- function Rr(e) {
957
+ function zr(e) {
958
958
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
959
959
  }
960
960
  var ve = { exports: {} };
@@ -993,8 +993,8 @@ var ve = { exports: {} };
993
993
  e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
994
994
  })();
995
995
  })(ve);
996
- var Dr = ve.exports;
997
- const B = /* @__PURE__ */ Rr(Dr), w = {
996
+ var Rr = ve.exports;
997
+ const L = /* @__PURE__ */ zr(Rr), 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",
@@ -1002,7 +1002,7 @@ const B = /* @__PURE__ */ Rr(Dr), w = {
1002
1002
  "purpur-checkbox__label": "_purpur-checkbox__label_10fl8_70",
1003
1003
  "purpur-checkbox__wrapper": "_purpur-checkbox__wrapper_10fl8_73",
1004
1004
  "purpur-checkbox__container": "_purpur-checkbox__container_10fl8_79"
1005
- }, N = "purpur-checkbox", qr = ({
1005
+ }, N = "purpur-checkbox", Dr = ({
1006
1006
  ["data-testid"]: e,
1007
1007
  checked: n,
1008
1008
  className: t,
@@ -1012,14 +1012,14 @@ const B = /* @__PURE__ */ Rr(Dr), w = {
1012
1012
  ...o
1013
1013
  }, u) => {
1014
1014
  const c = a && !n;
1015
- return /* @__PURE__ */ z("div", { className: B([t, w[`${N}__wrapper`]]), children: [
1016
- /* @__PURE__ */ z("div", { className: B([t, w[`${N}__container`]]), children: [
1015
+ return /* @__PURE__ */ B("div", { className: L([t, w[`${N}__wrapper`]]), children: [
1016
+ /* @__PURE__ */ B("div", { className: L([t, w[`${N}__container`]]), children: [
1017
1017
  /* @__PURE__ */ f(
1018
1018
  Er,
1019
1019
  {
1020
1020
  ...o,
1021
1021
  checked: n,
1022
- className: B(w[N], {
1022
+ className: L(w[N], {
1023
1023
  [w[`${N}--error`]]: c
1024
1024
  }),
1025
1025
  "data-testid": e,
@@ -1053,11 +1053,11 @@ const B = /* @__PURE__ */ Rr(Dr), w = {
1053
1053
  }
1054
1054
  )
1055
1055
  ] }),
1056
- c && /* @__PURE__ */ f(qe, { "data-testid": e && `${e}-error-text`, children: a })
1056
+ c && /* @__PURE__ */ f(De, { "data-testid": e && `${e}-error-text`, children: a })
1057
1057
  ] });
1058
- }, Ir = g(qr);
1059
- Ir.displayName = "Checkbox";
1058
+ }, qr = g(Dr);
1059
+ qr.displayName = "Checkbox";
1060
1060
  export {
1061
- Ir as Checkbox
1061
+ qr as Checkbox
1062
1062
  };
1063
1063
  //# sourceMappingURL=checkbox.es.js.map