@purpurds/accordion 5.13.0 → 5.15.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
- import { HeadingTagType, TitleVariantType } from '@purpurds/heading';
2
1
  import { default as React, ReactNode } from 'react';
2
+ import { HeadingTagType, TitleVariantType } from '@purpurds/heading';
3
3
 
4
4
  export type AccordionProps = {
5
5
  ["data-testid"]?: string;
@@ -1,6 +1,6 @@
1
- import { jsx as y, jsxs as X } from "react/jsx-runtime";
1
+ import { jsx as y, jsxs as W } from "react/jsx-runtime";
2
2
  import * as $e from "react";
3
- import u, { createContext as ee, useMemo as U, createElement as A, useContext as _e, useCallback as H, forwardRef as I, Children as S, isValidElement as V, cloneElement as G, Fragment as qe, useRef as C, useEffect as k, useState as re, useLayoutEffect as Ue, useReducer as Ve } from "react";
3
+ import u, { createContext as ee, useMemo as V, createElement as A, useContext as _e, useCallback as H, forwardRef as I, Children as S, isValidElement as U, cloneElement as G, Fragment as qe, useRef as C, useEffect as k, useState as re, useLayoutEffect as Ve, useReducer as Ue } from "react";
4
4
  import { flushSync as ze } from "react-dom";
5
5
  function Be(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -42,7 +42,7 @@ var me = { exports: {} };
42
42
  })();
43
43
  })(me);
44
44
  var He = me.exports;
45
- const Ge = /* @__PURE__ */ Be(He), j = {
45
+ const Ge = /* @__PURE__ */ Be(He), L = {
46
46
  "purpur-heading": "_purpur-heading_k9fhq_1",
47
47
  "purpur-heading--hyphens": "_purpur-heading--hyphens_k9fhq_8",
48
48
  "purpur-heading--negative": "_purpur-heading--negative_k9fhq_11",
@@ -67,7 +67,7 @@ const Ge = /* @__PURE__ */ Be(He), j = {
67
67
  TITLE600: "title-600",
68
68
  TITLE700: "title-700",
69
69
  SUBSECTION100: "subsection-100"
70
- }, L = "purpur-heading", oe = ({
70
+ }, j = "purpur-heading", oe = ({
71
71
  ["data-testid"]: e,
72
72
  children: r,
73
73
  className: n = "",
@@ -79,11 +79,11 @@ const Ge = /* @__PURE__ */ Be(He), j = {
79
79
  }) => {
80
80
  const s = t, l = Ge([
81
81
  n,
82
- j[L],
83
- j[`${L}--${a}`],
82
+ L[j],
83
+ L[`${j}--${a}`],
84
84
  {
85
- [j[`${L}--hyphens`]]: o,
86
- [j[`${L}--negative`]]: c
85
+ [L[`${j}--hyphens`]]: o,
86
+ [L[`${j}--negative`]]: c
87
87
  }
88
88
  ]);
89
89
  return /* @__PURE__ */ y(s, { ...i, className: l, "data-testid": e, children: r });
@@ -93,11 +93,10 @@ function h() {
93
93
  return h = Object.assign ? Object.assign.bind() : function(e) {
94
94
  for (var r = 1; r < arguments.length; r++) {
95
95
  var n = arguments[r];
96
- for (var o in n)
97
- Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
96
+ for (var o in n) ({}).hasOwnProperty.call(n, o) && (e[o] = n[o]);
98
97
  }
99
98
  return e;
100
- }, h.apply(this, arguments);
99
+ }, h.apply(null, arguments);
101
100
  }
102
101
  function ae(e, r = []) {
103
102
  let n = [];
@@ -108,7 +107,7 @@ function ae(e, r = []) {
108
107
  a
109
108
  ];
110
109
  function l(p) {
111
- const { scope: _, children: f, ...b } = p, x = (_ == null ? void 0 : _[e][s]) || i, g = U(
110
+ const { scope: _, children: f, ...b } = p, x = (_ == null ? void 0 : _[e][s]) || i, g = V(
112
111
  () => b,
113
112
  Object.values(b)
114
113
  );
@@ -131,7 +130,7 @@ function ae(e, r = []) {
131
130
  const t = n.map((a) => /* @__PURE__ */ ee(a));
132
131
  return function(i) {
133
132
  const s = (i == null ? void 0 : i[e]) || t;
134
- return U(
133
+ return V(
135
134
  () => ({
136
135
  [`__scope${e}`]: {
137
136
  ...i,
@@ -168,7 +167,7 @@ function Ke(...e) {
168
167
  ...p
169
168
  };
170
169
  }, {});
171
- return U(
170
+ return V(
172
171
  () => ({
173
172
  [`__scope${r.scopeName}`]: a
174
173
  }),
@@ -180,24 +179,24 @@ function Ke(...e) {
180
179
  };
181
180
  return n.scopeName = r.scopeName, n;
182
181
  }
183
- function Ze(e, r) {
182
+ function Ye(e, r) {
184
183
  typeof e == "function" ? e(r) : e != null && (e.current = r);
185
184
  }
186
185
  function he(...e) {
187
186
  return (r) => e.forEach(
188
- (n) => Ze(n, r)
187
+ (n) => Ye(n, r)
189
188
  );
190
189
  }
191
190
  function M(...e) {
192
191
  return H(he(...e), e);
193
192
  }
194
193
  const z = /* @__PURE__ */ I((e, r) => {
195
- const { children: n, ...o } = e, c = S.toArray(n), t = c.find(Ye);
194
+ const { children: n, ...o } = e, c = S.toArray(n), t = c.find(Je);
196
195
  if (t) {
197
- const a = t.props.children, i = c.map((s) => s === t ? S.count(a) > 1 ? S.only(null) : /* @__PURE__ */ V(a) ? a.props.children : null : s);
196
+ const a = t.props.children, i = c.map((s) => s === t ? S.count(a) > 1 ? S.only(null) : /* @__PURE__ */ U(a) ? a.props.children : null : s);
198
197
  return /* @__PURE__ */ A(te, h({}, o, {
199
198
  ref: r
200
- }), /* @__PURE__ */ V(a) ? /* @__PURE__ */ G(a, void 0, i) : null);
199
+ }), /* @__PURE__ */ U(a) ? /* @__PURE__ */ G(a, void 0, i) : null);
201
200
  }
202
201
  return /* @__PURE__ */ A(te, h({}, o, {
203
202
  ref: r
@@ -206,17 +205,17 @@ const z = /* @__PURE__ */ I((e, r) => {
206
205
  z.displayName = "Slot";
207
206
  const te = /* @__PURE__ */ I((e, r) => {
208
207
  const { children: n, ...o } = e;
209
- return /* @__PURE__ */ V(n) ? /* @__PURE__ */ G(n, {
210
- ...Je(o, n.props),
208
+ return /* @__PURE__ */ U(n) ? /* @__PURE__ */ G(n, {
209
+ ...Xe(o, n.props),
211
210
  ref: r ? he(r, n.ref) : n.ref
212
211
  }) : S.count(n) > 1 ? S.only(null) : null;
213
212
  });
214
213
  te.displayName = "SlotClone";
215
- const We = ({ children: e }) => /* @__PURE__ */ A(qe, null, e);
216
- function Ye(e) {
217
- return /* @__PURE__ */ V(e) && e.type === We;
214
+ const Ze = ({ children: e }) => /* @__PURE__ */ A(qe, null, e);
215
+ function Je(e) {
216
+ return /* @__PURE__ */ U(e) && e.type === Ze;
218
217
  }
219
- function Je(e, r) {
218
+ function Xe(e, r) {
220
219
  const n = {
221
220
  ...r
222
221
  };
@@ -298,7 +297,7 @@ function ve(e) {
298
297
  const r = C(e);
299
298
  return k(() => {
300
299
  r.current = e;
301
- }), U(
300
+ }), V(
302
301
  () => (...n) => {
303
302
  var o;
304
303
  return (o = r.current) === null || o === void 0 ? void 0 : o.call(r, ...n);
@@ -308,7 +307,7 @@ function ve(e) {
308
307
  }
309
308
  function ce({ prop: e, defaultProp: r, onChange: n = () => {
310
309
  } }) {
311
- const [o, c] = Xe({
310
+ const [o, c] = We({
312
311
  defaultProp: r,
313
312
  onChange: n
314
313
  }), t = e !== void 0, a = t ? e : o, i = ve(n), s = H((l) => {
@@ -327,7 +326,7 @@ function ce({ prop: e, defaultProp: r, onChange: n = () => {
327
326
  s
328
327
  ];
329
328
  }
330
- function Xe({ defaultProp: e, onChange: r }) {
329
+ function We({ defaultProp: e, onChange: r }) {
331
330
  const n = re(e), [o] = n, c = C(o), t = ve(r);
332
331
  return k(() => {
333
332
  c.current !== o && (t(o), c.current = o);
@@ -367,10 +366,10 @@ const et = [
367
366
  ...e,
368
367
  [r]: n
369
368
  };
370
- }, {}), B = globalThis != null && globalThis.document ? Ue : () => {
369
+ }, {}), B = globalThis != null && globalThis.document ? Ve : () => {
371
370
  };
372
371
  function tt(e, r) {
373
- return Ve((n, o) => {
372
+ return Ue((n, o) => {
374
373
  const c = r[n][o];
375
374
  return c ?? n;
376
375
  }, e);
@@ -646,18 +645,18 @@ const [Ie, vt] = F(P), [Pe, xt] = F(P, {
646
645
  const { __scopeAccordion: n, disabled: o, dir: c, orientation: t = "vertical", ...a } = e, i = u.useRef(null), s = M(i, r), l = ht(n), p = _t(c) === "ltr", _ = ge(e.onKeyDown, (f) => {
647
646
  var b;
648
647
  if (!mt.includes(f.key)) return;
649
- const x = f.target, g = l().filter((Y) => {
650
- var J;
651
- return !((J = Y.ref.current) !== null && J !== void 0 && J.disabled);
648
+ const x = f.target, g = l().filter((J) => {
649
+ var X;
650
+ return !((X = J.ref.current) !== null && X !== void 0 && X.disabled);
652
651
  }), m = g.findIndex(
653
- (Y) => Y.ref.current === x
652
+ (J) => J.ref.current === x
654
653
  ), $ = g.length;
655
654
  if (m === -1) return;
656
655
  f.preventDefault();
657
656
  let v = m;
658
- const N = 0, O = $ - 1, Z = () => {
657
+ const N = 0, O = $ - 1, Y = () => {
659
658
  v = m + 1, v > O && (v = N);
660
- }, W = () => {
659
+ }, Z = () => {
661
660
  v = m - 1, v < N && (v = O);
662
661
  };
663
662
  switch (f.key) {
@@ -668,20 +667,20 @@ const [Ie, vt] = F(P), [Pe, xt] = F(P, {
668
667
  v = O;
669
668
  break;
670
669
  case "ArrowRight":
671
- t === "horizontal" && (p ? Z() : W());
670
+ t === "horizontal" && (p ? Y() : Z());
672
671
  break;
673
672
  case "ArrowDown":
674
- t === "vertical" && Z();
673
+ t === "vertical" && Y();
675
674
  break;
676
675
  case "ArrowLeft":
677
- t === "horizontal" && (p ? W() : Z());
676
+ t === "horizontal" && (p ? Z() : Y());
678
677
  break;
679
678
  case "ArrowUp":
680
- t === "vertical" && W();
679
+ t === "vertical" && Z();
681
680
  break;
682
681
  }
683
- const Le = v % $;
684
- (b = g[Le].ref.current) === null || b === void 0 || b.focus();
682
+ const je = v % $;
683
+ (b = g[je].ref.current) === null || b === void 0 || b.focus();
685
684
  });
686
685
  return /* @__PURE__ */ u.createElement(Ct, {
687
686
  scope: n,
@@ -752,7 +751,7 @@ function Se(e) {
752
751
  return e ? "open" : "closed";
753
752
  }
754
753
  const Rt = Ee, Tt = Et, Mt = Pt, kt = wt, Dt = Ot;
755
- function jt(e) {
754
+ function Lt(e) {
756
755
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
757
756
  }
758
757
  var Oe = { exports: {} };
@@ -791,13 +790,13 @@ var Oe = { exports: {} };
791
790
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
792
791
  })();
793
792
  })(Oe);
794
- var Lt = Oe.exports;
795
- const Re = /* @__PURE__ */ jt(Lt), qt = {
793
+ var jt = Oe.exports;
794
+ const Re = /* @__PURE__ */ Lt(jt), qt = {
796
795
  "purpur-accordion": "_purpur-accordion_u887g_1",
797
796
  "purpur-accordion__title": "_purpur-accordion__title_u887g_4",
798
797
  "purpur-accordion--negative": "_purpur-accordion--negative_u887g_13"
799
798
  };
800
- function Ut(e) {
799
+ function Vt(e) {
801
800
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
802
801
  }
803
802
  var Te = { exports: {} };
@@ -836,8 +835,8 @@ var Te = { exports: {} };
836
835
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
837
836
  })();
838
837
  })(Te);
839
- var Vt = Te.exports;
840
- const zt = /* @__PURE__ */ Ut(Vt), Bt = {
838
+ var Ut = Te.exports;
839
+ const zt = /* @__PURE__ */ Vt(Ut), Bt = {
841
840
  "purpur-icon": "_purpur-icon_8u1lq_1",
842
841
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
843
842
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -851,14 +850,14 @@ const zt = /* @__PURE__ */ Ut(Vt), Bt = {
851
850
  keywords: ["chevron-down"],
852
851
  category: "utility"
853
852
  }, Me = (e) => /* @__PURE__ */ y(
854
- Yt,
853
+ Jt,
855
854
  {
856
855
  ...e,
857
856
  svg: Ht
858
857
  }
859
858
  );
860
859
  Me.displayName = "IconChevronDown";
861
- const Gt = zt.bind(Bt), fe = "purpur-icon", Ft = "md", Kt = (e) => e.filter((r) => Object.keys(r).length >= 1).map((r) => `${r.name}="${r.value}"`).join(" "), Zt = ({ content: e = "", title: r } = {}) => {
860
+ const Gt = zt.bind(Bt), fe = "purpur-icon", Ft = "md", Kt = (e) => e.filter((r) => Object.keys(r).length >= 1).map((r) => `${r.name}="${r.value}"`).join(" "), Yt = ({ content: e = "", title: r } = {}) => {
862
861
  const n = [
863
862
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
864
863
  { name: "fill", value: "currentColor" },
@@ -866,7 +865,7 @@ const Gt = zt.bind(Bt), fe = "purpur-icon", Ft = "md", Kt = (e) => e.filter((r)
866
865
  r ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
867
866
  ], o = r ? `<title>${r}</title>` : "";
868
867
  return `<svg ${Kt(n)}>${o}${e}</svg>`;
869
- }, Wt = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), Yt = ({
868
+ }, Zt = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), Jt = ({
870
869
  ["data-testid"]: e,
871
870
  svg: r,
872
871
  allyTitle: n,
@@ -874,8 +873,8 @@ const Gt = zt.bind(Bt), fe = "purpur-icon", Ft = "md", Kt = (e) => e.filter((r)
874
873
  size: c = Ft,
875
874
  ...t
876
875
  }) => {
877
- const a = Zt({
878
- content: Wt(r.svg),
876
+ const a = Yt({
877
+ content: Zt(r.svg),
879
878
  title: n
880
879
  }), i = Gt(o, fe, `${fe}--${c}`);
881
880
  return /* @__PURE__ */ y(
@@ -889,7 +888,7 @@ const Gt = zt.bind(Bt), fe = "purpur-icon", Ft = "md", Kt = (e) => e.filter((r)
889
888
  }
890
889
  );
891
890
  };
892
- function Jt(e) {
891
+ function Xt(e) {
893
892
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
894
893
  }
895
894
  var ke = { exports: {} };
@@ -929,7 +928,7 @@ var ke = { exports: {} };
929
928
  })();
930
929
  })(ke);
931
930
  var Qt = ke.exports;
932
- const Xt = /* @__PURE__ */ Jt(Qt), R = {
931
+ const Wt = /* @__PURE__ */ Xt(Qt), R = {
933
932
  "purpur-paragraph": "_purpur-paragraph_1rh57_1",
934
933
  "purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
935
934
  "purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
@@ -965,7 +964,7 @@ const Xt = /* @__PURE__ */ Jt(Qt), R = {
965
964
  variant: a = en.PARAGRAPH100,
966
965
  ...i
967
966
  }) => {
968
- const s = Xt([
967
+ const s = Wt([
969
968
  n,
970
969
  R[T],
971
970
  R[`${T}--${a}`],
@@ -1006,8 +1005,8 @@ const tn = "_slideDown_aukzj_1", nn = "_slideUp_aukzj_1", rn = {
1006
1005
  [`${E}--negative`]: c
1007
1006
  }
1008
1007
  ]);
1009
- return /* @__PURE__ */ X(Tt, { className: s, value: n, ...a, children: [
1010
- /* @__PURE__ */ y(Mt, { className: w(`${E}__header`), asChild: !0, children: /* @__PURE__ */ y(oe, { tag: o, variant: "title-100", className: w(`${E}__title`), children: /* @__PURE__ */ X(
1008
+ return /* @__PURE__ */ W(Tt, { className: s, value: n, ...a, children: [
1009
+ /* @__PURE__ */ y(Mt, { className: w(`${E}__header`), asChild: !0, children: /* @__PURE__ */ y(oe, { tag: o, variant: "title-100", className: w(`${E}__title`), children: /* @__PURE__ */ W(
1011
1010
  kt,
1012
1011
  {
1013
1012
  ref: i,
@@ -1022,7 +1021,7 @@ const tn = "_slideDown_aukzj_1", nn = "_slideUp_aukzj_1", rn = {
1022
1021
  /* @__PURE__ */ y(Dt, { className: w(`${E}__content`, r), children: /* @__PURE__ */ y("div", { className: w(`${E}__contentText`), children: typeof e == "string" ? /* @__PURE__ */ y(De, { variant: "paragraph-200", children: e }) : e }) })
1023
1022
  ] });
1024
1023
  }
1025
- ), be = Re.bind(qt), Q = "purpur-accordion", je = ({
1024
+ ), be = Re.bind(qt), Q = "purpur-accordion", Le = ({
1026
1025
  ["data-testid"]: e,
1027
1026
  children: r,
1028
1027
  className: n,
@@ -1040,14 +1039,14 @@ const tn = "_slideDown_aukzj_1", nn = "_slideUp_aukzj_1", rn = {
1040
1039
  ]), s = () => S.map(r, (l) => G(l, {
1041
1040
  negative: o
1042
1041
  }));
1043
- return /* @__PURE__ */ X(Rt, { className: i, type: "multiple", "data-testid": e, children: [
1042
+ return /* @__PURE__ */ W(Rt, { className: i, type: "multiple", "data-testid": e, children: [
1044
1043
  c ? /* @__PURE__ */ y(oe, { tag: t, variant: a, className: be(`${Q}__title`), children: c }) : null,
1045
1044
  s()
1046
1045
  ] });
1047
1046
  };
1048
- je.Item = on;
1049
- je.displayName = "Accordion";
1047
+ Le.Item = on;
1048
+ Le.displayName = "Accordion";
1050
1049
  export {
1051
- je as Accordion
1050
+ Le as Accordion
1052
1051
  };
1053
1052
  //# sourceMappingURL=accordion.es.js.map