@purpurds/tabs 5.20.1 → 5.21.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/tabs.es.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsx as T, jsxs as ee } from "react/jsx-runtime";
2
2
  import * as me from "react";
3
- import E, { createContext as ne, useMemo as H, createElement as g, useContext as _e, useCallback as U, forwardRef as w, Children as P, isValidElement as K, cloneElement as se, Fragment as De, useLayoutEffect as qe, useEffect as N, useRef as R, useState as O, useReducer as Le } from "react";
4
- import { flushSync as Ue } from "react-dom";
5
- function Ve(e) {
3
+ import E, { createContext as ne, useMemo as H, createElement as g, useContext as _e, useCallback as U, forwardRef as w, Children as P, isValidElement as K, cloneElement as se, Fragment as qe, useLayoutEffect as Le, useEffect as N, useRef as R, useState as O, useReducer as Ue } from "react";
4
+ import { flushSync as Ve } from "react-dom";
5
+ function Be(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
7
  }
8
8
  var ge = { exports: {} };
@@ -41,8 +41,8 @@ var ge = { exports: {} };
41
41
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
42
42
  })();
43
43
  })(ge);
44
- var Be = ge.exports;
45
- const Ge = /* @__PURE__ */ Ve(Be), je = {
44
+ var Ge = ge.exports;
45
+ const je = /* @__PURE__ */ Be(Ge), ke = {
46
46
  "purpur-icon": "_purpur-icon_8u1lq_1",
47
47
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
48
48
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -50,36 +50,36 @@ const Ge = /* @__PURE__ */ Ve(Be), je = {
50
50
  "purpur-icon--md": "_purpur-icon--md_8u1lq_16",
51
51
  "purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
52
52
  "purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
53
- }, ke = {
53
+ }, ze = {
54
54
  name: "chevron-left",
55
55
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M16.175 3.905a.9.9 0 0 1-.08 1.27L8.36 12l7.736 6.825a.9.9 0 0 1-1.191 1.35l-8.5-7.5a.9.9 0 0 1 0-1.35l8.5-7.5a.9.9 0 0 1 1.27.08Z" clip-rule="evenodd"/></svg>',
56
56
  keywords: ["chevron-left"],
57
57
  category: "utility"
58
- }, ze = {
58
+ }, Ke = {
59
59
  name: "chevron-right",
60
60
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M7.809 3.924a.9.9 0 0 0 .115 1.267L16.094 12l-8.17 6.809a.9.9 0 0 0 1.152 1.382l9-7.5a.9.9 0 0 0 0-1.382l-9-7.5a.9.9 0 0 0-1.267.115Z" clip-rule="evenodd"/></svg>',
61
61
  keywords: ["chevron-right"],
62
62
  category: "utility"
63
- }, Ke = Ge.bind(je), $e = "purpur-icon", We = "md", Ye = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Ze = ({ content: e = "", title: t } = {}) => {
63
+ }, We = je.bind(ke), $e = "purpur-icon", Ye = "md", Ze = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), He = ({ content: e = "", title: t } = {}) => {
64
64
  const n = [
65
65
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
66
66
  { name: "fill", value: "currentColor" },
67
67
  { name: "viewBox", value: "0 0 24 24" },
68
68
  t ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
69
69
  ], o = t ? `<title>${t}</title>` : "";
70
- return `<svg ${Ye(n)}>${o}${e}</svg>`;
71
- }, He = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), Xe = ({
70
+ return `<svg ${Ze(n)}>${o}${e}</svg>`;
71
+ }, Xe = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), he = ({
72
72
  ["data-testid"]: e,
73
73
  svg: t,
74
74
  allyTitle: n,
75
75
  className: o,
76
- size: s = We,
76
+ size: s = Ye,
77
77
  ...r
78
78
  }) => {
79
- const c = Ze({
80
- content: He(t.svg),
79
+ const c = He({
80
+ content: Xe(t.svg),
81
81
  title: n
82
- }), a = Ke(o, $e, `${$e}--${s}`);
82
+ }), a = We(o, $e, `${$e}--${s}`);
83
83
  return /* @__PURE__ */ T(
84
84
  "span",
85
85
  {
@@ -91,6 +91,7 @@ const Ge = /* @__PURE__ */ Ve(Be), je = {
91
91
  }
92
92
  );
93
93
  };
94
+ he.displayName = "Icon";
94
95
  function C() {
95
96
  return C = Object.assign ? Object.assign.bind() : function(e) {
96
97
  for (var t = 1; t < arguments.length; t++) {
@@ -189,13 +190,13 @@ function Je(...e) {
189
190
  function Qe(e, t) {
190
191
  typeof e == "function" ? e(t) : e != null && (e.current = t);
191
192
  }
192
- function he(...e) {
193
+ function xe(...e) {
193
194
  return (t) => e.forEach(
194
195
  (n) => Qe(n, t)
195
196
  );
196
197
  }
197
198
  function X(...e) {
198
- return U(he(...e), e);
199
+ return U(xe(...e), e);
199
200
  }
200
201
  const J = /* @__PURE__ */ w((e, t) => {
201
202
  const { children: n, ...o } = e, s = P.toArray(n), r = s.find(tt);
@@ -214,11 +215,11 @@ const re = /* @__PURE__ */ w((e, t) => {
214
215
  const { children: n, ...o } = e;
215
216
  return /* @__PURE__ */ K(n) ? /* @__PURE__ */ se(n, {
216
217
  ...nt(o, n.props),
217
- ref: t ? he(t, n.ref) : n.ref
218
+ ref: t ? xe(t, n.ref) : n.ref
218
219
  }) : P.count(n) > 1 ? P.only(null) : null;
219
220
  });
220
221
  re.displayName = "SlotClone";
221
- const et = ({ children: e }) => /* @__PURE__ */ g(De, null, e);
222
+ const et = ({ children: e }) => /* @__PURE__ */ g(qe, null, e);
222
223
  function tt(e) {
223
224
  return /* @__PURE__ */ K(e) && e.type === et;
224
225
  }
@@ -295,11 +296,11 @@ function rt(e) {
295
296
  o
296
297
  ];
297
298
  }
298
- const oe = globalThis != null && globalThis.document ? qe : () => {
299
+ const oe = globalThis != null && globalThis.document ? Le : () => {
299
300
  }, ot = me.useId || (() => {
300
301
  });
301
302
  let ct = 0;
302
- function xe(e) {
303
+ function Ie(e) {
303
304
  const [t, n] = me.useState(ot());
304
305
  return oe(() => {
305
306
  e || n(
@@ -352,7 +353,7 @@ function ie(e) {
352
353
  []
353
354
  );
354
355
  }
355
- function Ie({ prop: e, defaultProp: t, onChange: n = () => {
356
+ function Ce({ prop: e, defaultProp: t, onChange: n = () => {
356
357
  } }) {
357
358
  const [o, s] = at({
358
359
  defaultProp: t,
@@ -384,14 +385,14 @@ function at({ defaultProp: e, onChange: t }) {
384
385
  ]), n;
385
386
  }
386
387
  const it = /* @__PURE__ */ ne(void 0);
387
- function Ce(e) {
388
+ function ye(e) {
388
389
  const t = _e(it);
389
390
  return e || t || "ltr";
390
391
  }
391
392
  const te = "rovingFocusGroup.onEntryFocus", ut = {
392
393
  bubbles: !1,
393
394
  cancelable: !0
394
- }, ue = "RovingFocusGroup", [ce, ye, lt] = rt(ue), [dt, Se] = ae(ue, [
395
+ }, ue = "RovingFocusGroup", [ce, Se, lt] = rt(ue), [dt, we] = ae(ue, [
395
396
  lt
396
397
  ]), [ft, pt] = dt(ue), bt = /* @__PURE__ */ w((e, t) => /* @__PURE__ */ g(ce.Provider, {
397
398
  scope: e.__scopeRovingFocusGroup
@@ -400,11 +401,11 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
400
401
  }, /* @__PURE__ */ g($t, C({}, e, {
401
402
  ref: t
402
403
  }))))), $t = /* @__PURE__ */ w((e, t) => {
403
- const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...p } = e, d = R(null), v = X(t, d), m = Ce(r), [f = null, h] = Ie({
404
+ const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...p } = e, d = R(null), v = X(t, d), m = ye(r), [f = null, h] = Ce({
404
405
  prop: c,
405
406
  defaultProp: a,
406
407
  onChange: u
407
- }), [$, b] = O(!1), _ = ie(i), D = ye(n), y = R(!1), [j, V] = O(0);
408
+ }), [$, b] = O(!1), _ = ie(i), D = Se(n), y = R(!1), [j, V] = O(0);
408
409
  return N(() => {
409
410
  const x = d.current;
410
411
  if (x)
@@ -469,7 +470,7 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
469
470
  ].filter(Boolean).map(
470
471
  (l) => l.ref.current
471
472
  );
472
- we(Y);
473
+ Te(Y);
473
474
  }
474
475
  }
475
476
  y.current = !1;
@@ -480,7 +481,7 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
480
481
  )
481
482
  })));
482
483
  }), vt = "RovingFocusGroupItem", mt = /* @__PURE__ */ w((e, t) => {
483
- const { __scopeRovingFocusGroup: n, focusable: o = !0, active: s = !1, tabStopId: r, ...c } = e, a = xe(), u = r || a, i = pt(vt, n), p = i.currentTabStopId === u, d = ye(n), { onFocusableItemAdd: v, onFocusableItemRemove: m } = i;
484
+ const { __scopeRovingFocusGroup: n, focusable: o = !0, active: s = !1, tabStopId: r, ...c } = e, a = Ie(), u = r || a, i = pt(vt, n), p = i.currentTabStopId === u, d = Se(n), { onFocusableItemAdd: v, onFocusableItemRemove: m } = i;
484
485
  return N(() => {
485
486
  if (o)
486
487
  return v(), () => m();
@@ -526,7 +527,7 @@ const te = "rovingFocusGroup.onEntryFocus", ut = {
526
527
  b = i.loop ? xt(b, _ + 1) : b.slice(_ + 1);
527
528
  }
528
529
  setTimeout(
529
- () => we(b)
530
+ () => Te(b)
530
531
  );
531
532
  }
532
533
  })
@@ -555,7 +556,7 @@ function ht(e, t, n) {
555
556
  ].includes(o)))
556
557
  return _t[o];
557
558
  }
558
- function we(e) {
559
+ function Te(e) {
559
560
  const t = document.activeElement;
560
561
  for (const n of e)
561
562
  if (n === t || (n.focus(), document.activeElement !== t)) return;
@@ -567,12 +568,12 @@ function xt(e, t) {
567
568
  }
568
569
  const It = bt, Ct = mt;
569
570
  function yt(e, t) {
570
- return Le((n, o) => {
571
+ return Ue((n, o) => {
571
572
  const s = t[n][o];
572
573
  return s ?? n;
573
574
  }, e);
574
575
  }
575
- const Te = (e) => {
576
+ const Ne = (e) => {
576
577
  const { present: t, children: n } = e, o = St(t), s = typeof n == "function" ? n({
577
578
  present: o.isPresent
578
579
  }) : P.only(n), r = X(o.ref, s.ref);
@@ -580,7 +581,7 @@ const Te = (e) => {
580
581
  ref: r
581
582
  }) : null;
582
583
  };
583
- Te.displayName = "Presence";
584
+ Ne.displayName = "Presence";
584
585
  function St(e) {
585
586
  const [t, n] = O(), o = R({}), s = R(e), r = R("none"), c = e ? "mounted" : "unmounted", [a, u] = yt(c, {
586
587
  mounted: {
@@ -613,7 +614,7 @@ function St(e) {
613
614
  if (t) {
614
615
  const i = (d) => {
615
616
  const m = Z(o.current).includes(d.animationName);
616
- d.target === t && m && Ue(
617
+ d.target === t && m && Ve(
617
618
  () => u("ANIMATION_END")
618
619
  );
619
620
  }, p = (d) => {
@@ -640,17 +641,17 @@ function St(e) {
640
641
  function Z(e) {
641
642
  return (e == null ? void 0 : e.animationName) || "none";
642
643
  }
643
- const Ne = "Tabs", [wt, nn] = ae(Ne, [
644
- Se
645
- ]), Ae = Se(), [Tt, le] = wt(Ne), Nt = /* @__PURE__ */ w((e, t) => {
646
- const { __scopeTabs: n, value: o, onValueChange: s, defaultValue: r, orientation: c = "horizontal", dir: a, activationMode: u = "automatic", ...i } = e, p = Ce(a), [d, v] = Ie({
644
+ const Ae = "Tabs", [wt, nn] = ae(Ae, [
645
+ we
646
+ ]), Ee = we(), [Tt, le] = wt(Ae), Nt = /* @__PURE__ */ w((e, t) => {
647
+ const { __scopeTabs: n, value: o, onValueChange: s, defaultValue: r, orientation: c = "horizontal", dir: a, activationMode: u = "automatic", ...i } = e, p = ye(a), [d, v] = Ce({
647
648
  prop: o,
648
649
  onChange: s,
649
650
  defaultProp: r
650
651
  });
651
652
  return /* @__PURE__ */ g(Tt, {
652
653
  scope: n,
653
- baseId: xe(),
654
+ baseId: Ie(),
654
655
  value: d,
655
656
  onValueChange: v,
656
657
  orientation: c,
@@ -663,7 +664,7 @@ const Ne = "Tabs", [wt, nn] = ae(Ne, [
663
664
  ref: t
664
665
  })));
665
666
  }), At = "TabsList", Et = /* @__PURE__ */ w((e, t) => {
666
- const { __scopeTabs: n, loop: o = !0, ...s } = e, r = le(At, n), c = Ae(n);
667
+ const { __scopeTabs: n, loop: o = !0, ...s } = e, r = le(At, n), c = Ee(n);
667
668
  return /* @__PURE__ */ g(It, C({
668
669
  asChild: !0
669
670
  }, c, {
@@ -677,7 +678,7 @@ const Ne = "Tabs", [wt, nn] = ae(Ne, [
677
678
  ref: t
678
679
  })));
679
680
  }), Pt = "TabsTrigger", Rt = /* @__PURE__ */ w((e, t) => {
680
- const { __scopeTabs: n, value: o, disabled: s = !1, ...r } = e, c = le(Pt, n), a = Ae(n), u = Ee(c.baseId, o), i = Pe(c.baseId, o), p = o === c.value;
681
+ const { __scopeTabs: n, value: o, disabled: s = !1, ...r } = e, c = le(Pt, n), a = Ee(n), u = Pe(c.baseId, o), i = Re(c.baseId, o), p = o === c.value;
681
682
  return /* @__PURE__ */ g(Ct, C({
682
683
  asChild: !0
683
684
  }, a, {
@@ -709,14 +710,14 @@ const Ne = "Tabs", [wt, nn] = ae(Ne, [
709
710
  })
710
711
  })));
711
712
  }), Mt = "TabsContent", Ft = /* @__PURE__ */ w((e, t) => {
712
- const { __scopeTabs: n, value: o, forceMount: s, children: r, ...c } = e, a = le(Mt, n), u = Ee(a.baseId, o), i = Pe(a.baseId, o), p = o === a.value, d = R(p);
713
+ const { __scopeTabs: n, value: o, forceMount: s, children: r, ...c } = e, a = le(Mt, n), u = Pe(a.baseId, o), i = Re(a.baseId, o), p = o === a.value, d = R(p);
713
714
  return N(() => {
714
715
  const v = requestAnimationFrame(
715
716
  () => d.current = !1
716
717
  );
717
718
  return () => cancelAnimationFrame(v);
718
719
  }, []), /* @__PURE__ */ g(
719
- Te,
720
+ Ne,
720
721
  {
721
722
  present: s || p
722
723
  },
@@ -737,17 +738,17 @@ const Ne = "Tabs", [wt, nn] = ae(Ne, [
737
738
  }), v && r)
738
739
  );
739
740
  });
740
- function Ee(e, t) {
741
+ function Pe(e, t) {
741
742
  return `${e}-trigger-${t}`;
742
743
  }
743
- function Pe(e, t) {
744
+ function Re(e, t) {
744
745
  return `${e}-content-${t}`;
745
746
  }
746
747
  const Ot = Nt, Dt = Et, qt = Rt, Lt = Ft;
747
748
  function Ut(e) {
748
749
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
749
750
  }
750
- var Re = { exports: {} };
751
+ var Me = { exports: {} };
751
752
  /*!
752
753
  Copyright (c) 2018 Jed Watson.
753
754
  Licensed under the MIT License (MIT), see
@@ -782,8 +783,8 @@ var Re = { exports: {} };
782
783
  }
783
784
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
784
785
  })();
785
- })(Re);
786
- var Vt = Re.exports;
786
+ })(Me);
787
+ var Vt = Me.exports;
787
788
  const de = /* @__PURE__ */ Ut(Vt), Bt = {
788
789
  "purpur-tab-content": "_purpur-tab-content_1x2zs_1"
789
790
  }, Gt = de.bind(Bt), jt = "purpur-tab-content", kt = w(
@@ -896,7 +897,7 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
896
897
  "aria-hidden": "true",
897
898
  tabIndex: -1,
898
899
  "data-testid": q("scroll-button"),
899
- children: /* @__PURE__ */ T(Xe, { svg: l === "left" ? ke : ze, size: "md" })
900
+ children: /* @__PURE__ */ T(he, { svg: l === "left" ? ze : Ke, size: "md" })
900
901
  }
901
902
  );
902
903
  return N(() => (window.addEventListener("resize", z), () => {
@@ -910,13 +911,13 @@ const de = /* @__PURE__ */ Ut(Vt), Bt = {
910
911
  return;
911
912
  }
912
913
  M.forEach((A) => {
913
- const be = Number(A.target.getAttribute("data-index")), Me = be === 0, Fe = be === $.length - 1;
914
- d((Oe) => ({
915
- ...Oe,
916
- ...Me && {
914
+ const be = Number(A.target.getAttribute("data-index")), Fe = be === 0, Oe = be === $.length - 1;
915
+ d((De) => ({
916
+ ...De,
917
+ ...Fe && {
917
918
  [`${S}__wrapper--scroll-end`]: !A.isIntersecting
918
919
  },
919
- ...Fe && {
920
+ ...Oe && {
920
921
  [`${S}__wrapper--scroll-start`]: !A.isIntersecting
921
922
  }
922
923
  }));