@purpurds/tabs 5.14.0 → 5.15.1

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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { TabChangeDetail, TabsCmp, TabsVariant } from './tabs.utils';
2
- import { TabContent } from './tab-content';
3
1
  import { ReactElement } from 'react';
2
+ import { TabContent } from './tab-content';
3
+ import { TabChangeDetail, TabsCmp, TabsVariant } from './tabs.utils';
4
4
 
5
5
  type TabsProps = {
6
6
  children: Array<ReactElement<typeof TabContent>> | ReactElement<typeof TabContent>;
package/dist/tabs.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as w, jsxs as ee } from "react/jsx-runtime";
2
2
  import * as ve from "react";
3
- import A, { createContext as ne, useMemo as W, createElement as x, useContext as me, useCallback as V, forwardRef as S, Children as E, isValidElement as k, cloneElement as se, Fragment as Fe, useLayoutEffect as De, useEffect as P, useRef as R, useState as D, useReducer as qe } from "react";
3
+ import A, { createContext as ne, useMemo as W, createElement as x, useContext as me, useCallback as V, forwardRef as S, Children as E, isValidElement as k, cloneElement as se, Fragment as Oe, useLayoutEffect as De, useEffect as P, useRef as R, useState as D, useReducer as qe } from "react";
4
4
  import { flushSync as Le } from "react-dom";
5
5
  function Ue(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -42,7 +42,7 @@ var _e = { exports: {} };
42
42
  })();
43
43
  })(_e);
44
44
  var Ve = _e.exports;
45
- const Be = /* @__PURE__ */ Ue(Ve), je = {
45
+ const Be = /* @__PURE__ */ Ue(Ve), Ge = {
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,7 +50,7 @@ const Be = /* @__PURE__ */ Ue(Ve), 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
- }, Ge = {
53
+ }, je = {
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"],
@@ -60,7 +60,7 @@ const Be = /* @__PURE__ */ Ue(Ve), je = {
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
- }, ze = Be.bind(je), be = "purpur-icon", Ke = "md", We = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Ye = ({ content: e = "", title: t } = {}) => {
63
+ }, ze = Be.bind(Ge), be = "purpur-icon", Ke = "md", We = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Ye = ({ 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" },
@@ -95,13 +95,12 @@ function I() {
95
95
  return I = Object.assign ? Object.assign.bind() : function(e) {
96
96
  for (var t = 1; t < arguments.length; t++) {
97
97
  var n = arguments[t];
98
- for (var o in n)
99
- Object.prototype.hasOwnProperty.call(n, o) && (e[o] = n[o]);
98
+ for (var o in n) ({}).hasOwnProperty.call(n, o) && (e[o] = n[o]);
100
99
  }
101
100
  return e;
102
- }, I.apply(this, arguments);
101
+ }, I.apply(null, arguments);
103
102
  }
104
- function O(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
103
+ function F(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
105
104
  return function(s) {
106
105
  if (e == null || e(s), n === !1 || !s.defaultPrevented) return t == null ? void 0 : t(s);
107
106
  };
@@ -219,7 +218,7 @@ const re = /* @__PURE__ */ S((e, t) => {
219
218
  }) : E.count(n) > 1 ? E.only(null) : null;
220
219
  });
221
220
  re.displayName = "SlotClone";
222
- const Qe = ({ children: e }) => /* @__PURE__ */ x(Fe, null, e);
221
+ const Qe = ({ children: e }) => /* @__PURE__ */ x(Oe, null, e);
223
222
  function et(e) {
224
223
  return /* @__PURE__ */ k(e) && e.type === Qe;
225
224
  }
@@ -263,13 +262,13 @@ function nt(e) {
263
262
  ref: h
264
263
  }, m);
265
264
  }), i = e + "CollectionItemSlot", p = "data-radix-collection-item", l = /* @__PURE__ */ A.forwardRef((v, d) => {
266
- const { scope: b, children: m, ..._ } = v, h = A.useRef(null), F = Y(d, h), T = r(i, b);
265
+ const { scope: b, children: m, ..._ } = v, h = A.useRef(null), O = Y(d, h), T = r(i, b);
267
266
  return A.useEffect(() => (T.itemMap.set(h, {
268
267
  ref: h,
269
268
  ..._
270
269
  }), () => void T.itemMap.delete(h))), /* @__PURE__ */ A.createElement(Z, {
271
270
  [p]: "",
272
- ref: F
271
+ ref: O
273
272
  }, m);
274
273
  });
275
274
  function $(v) {
@@ -327,7 +326,7 @@ const ct = [
327
326
  "span",
328
327
  "svg",
329
328
  "ul"
330
- ], G = ct.reduce((e, t) => {
329
+ ], j = ct.reduce((e, t) => {
331
330
  const n = /* @__PURE__ */ S((o, s) => {
332
331
  const { asChild: r, ...c } = o, a = r ? Z : t;
333
332
  return P(() => {
@@ -405,7 +404,7 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
405
404
  prop: c,
406
405
  defaultProp: a,
407
406
  onChange: u
408
- }), [m, _] = D(!1), h = ie(i), F = Ie(n), T = R(!1), [q, z] = D(0);
407
+ }), [m, _] = D(!1), h = ie(i), O = Ie(n), T = R(!1), [q, z] = D(0);
409
408
  return P(() => {
410
409
  const C = l.current;
411
410
  if (C)
@@ -440,7 +439,7 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
440
439
  ),
441
440
  []
442
441
  )
443
- }, /* @__PURE__ */ x(G.div, I({
442
+ }, /* @__PURE__ */ x(j.div, I({
444
443
  tabIndex: m || q === 0 ? -1 : 0,
445
444
  "data-orientation": o
446
445
  }, p, {
@@ -449,15 +448,15 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
449
448
  outline: "none",
450
449
  ...e.style
451
450
  },
452
- onMouseDown: O(e.onMouseDown, () => {
451
+ onMouseDown: F(e.onMouseDown, () => {
453
452
  T.current = !0;
454
453
  }),
455
- onFocus: O(e.onFocus, (C) => {
454
+ onFocus: F(e.onFocus, (C) => {
456
455
  const H = !T.current;
457
456
  if (C.target === C.currentTarget && H && !m) {
458
457
  const B = new CustomEvent(te, it);
459
458
  if (C.currentTarget.dispatchEvent(B), !B.defaultPrevented) {
460
- const L = F().filter(
459
+ const L = O().filter(
461
460
  (g) => g.focusable
462
461
  ), X = L.find(
463
462
  (g) => g.active
@@ -475,7 +474,7 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
475
474
  }
476
475
  T.current = !1;
477
476
  }),
478
- onBlur: O(
477
+ onBlur: F(
479
478
  e.onBlur,
480
479
  () => _(!1)
481
480
  )
@@ -494,19 +493,19 @@ const te = "rovingFocusGroup.onEntryFocus", it = {
494
493
  id: u,
495
494
  focusable: o,
496
495
  active: s
497
- }, /* @__PURE__ */ x(G.span, I({
496
+ }, /* @__PURE__ */ x(j.span, I({
498
497
  tabIndex: p ? 0 : -1,
499
498
  "data-orientation": i.orientation
500
499
  }, c, {
501
500
  ref: t,
502
- onMouseDown: O(e.onMouseDown, (d) => {
501
+ onMouseDown: F(e.onMouseDown, (d) => {
503
502
  o ? i.onItemFocus(u) : d.preventDefault();
504
503
  }),
505
- onFocus: O(
504
+ onFocus: F(
506
505
  e.onFocus,
507
506
  () => i.onItemFocus(u)
508
507
  ),
509
- onKeyDown: O(e.onKeyDown, (d) => {
508
+ onKeyDown: F(e.onKeyDown, (d) => {
510
509
  if (d.key === "Tab" && d.shiftKey) {
511
510
  i.onItemShiftTab();
512
511
  return;
@@ -657,7 +656,7 @@ const Te = "Tabs", [St, tn] = ae(Te, [
657
656
  orientation: c,
658
657
  dir: p,
659
658
  activationMode: u
660
- }, /* @__PURE__ */ x(G.div, I({
659
+ }, /* @__PURE__ */ x(j.div, I({
661
660
  dir: p,
662
661
  "data-orientation": c
663
662
  }, i, {
@@ -671,7 +670,7 @@ const Te = "Tabs", [St, tn] = ae(Te, [
671
670
  orientation: r.orientation,
672
671
  dir: r.dir,
673
672
  loop: o
674
- }), /* @__PURE__ */ x(G.div, I({
673
+ }), /* @__PURE__ */ x(j.div, I({
675
674
  role: "tablist",
676
675
  "aria-orientation": r.orientation
677
676
  }, s, {
@@ -684,7 +683,7 @@ const Te = "Tabs", [St, tn] = ae(Te, [
684
683
  }, a, {
685
684
  focusable: !s,
686
685
  active: p
687
- }), /* @__PURE__ */ x(G.button, I({
686
+ }), /* @__PURE__ */ x(j.button, I({
688
687
  type: "button",
689
688
  role: "tab",
690
689
  "aria-selected": p,
@@ -695,16 +694,16 @@ const Te = "Tabs", [St, tn] = ae(Te, [
695
694
  id: u
696
695
  }, r, {
697
696
  ref: t,
698
- onMouseDown: O(e.onMouseDown, (l) => {
697
+ onMouseDown: F(e.onMouseDown, (l) => {
699
698
  !s && l.button === 0 && l.ctrlKey === !1 ? c.onValueChange(o) : l.preventDefault();
700
699
  }),
701
- onKeyDown: O(e.onKeyDown, (l) => {
700
+ onKeyDown: F(e.onKeyDown, (l) => {
702
701
  [
703
702
  " ",
704
703
  "Enter"
705
704
  ].includes(l.key) && c.onValueChange(o);
706
705
  }),
707
- onFocus: O(e.onFocus, () => {
706
+ onFocus: F(e.onFocus, () => {
708
707
  const l = c.activationMode !== "manual";
709
708
  !p && !s && l && c.onValueChange(o);
710
709
  })
@@ -721,7 +720,7 @@ const Te = "Tabs", [St, tn] = ae(Te, [
721
720
  {
722
721
  present: s || p
723
722
  },
724
- ({ present: $ }) => /* @__PURE__ */ x(G.div, I({
723
+ ({ present: $ }) => /* @__PURE__ */ x(j.div, I({
725
724
  "data-state": p ? "active" : "inactive",
726
725
  "data-orientation": a.orientation,
727
726
  role: "tabpanel",
@@ -744,7 +743,7 @@ function Ae(e, t) {
744
743
  function Ee(e, t) {
745
744
  return `${e}-content-${t}`;
746
745
  }
747
- const Ot = Tt, Ft = At, Dt = Pt, qt = Mt;
746
+ const Ft = Tt, Ot = At, Dt = Pt, qt = Mt;
748
747
  function Lt(e) {
749
748
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
750
749
  }
@@ -787,12 +786,12 @@ var Pe = { exports: {} };
787
786
  var Ut = Pe.exports;
788
787
  const de = /* @__PURE__ */ Lt(Ut), Vt = {
789
788
  "purpur-tab-content": "_purpur-tab-content_1x2zs_1"
790
- }, Bt = de.bind(Vt), jt = "purpur-tab-content", Gt = S(
789
+ }, Bt = de.bind(Vt), Gt = "purpur-tab-content", jt = S(
791
790
  ({ children: e, tabId: t, "data-testid": n, className: o, ...s }, r) => /* @__PURE__ */ w(
792
791
  qt,
793
792
  {
794
793
  ref: r,
795
- className: Bt([jt, o]),
794
+ className: Bt([Gt, o]),
796
795
  "data-testid": n,
797
796
  value: t,
798
797
  ...s,
@@ -860,7 +859,7 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
860
859
  "data-testid": a,
861
860
  ...u
862
861
  }) => {
863
- const [i, p] = D({}), [l, $] = D(0), [v, d] = D(0), b = E.toArray(e).filter(kt), m = R(), _ = R(new Array(b.length)), h = 200, F = t === "line", T = U([
862
+ const [i, p] = D({}), [l, $] = D(0), [v, d] = D(0), b = E.toArray(e).filter(kt), m = R(), _ = R(new Array(b.length)), h = 200, O = t === "line", T = U([
864
863
  y,
865
864
  `${y}--${t}${n ? "-negative" : ""}`,
866
865
  { [`${y}--fullWidth`]: o },
@@ -872,16 +871,16 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
872
871
  if (new Set(q).size !== q.length)
873
872
  throw new Error("tabId must be unique");
874
873
  const B = (f, g) => g || a ? `${g || a}-${f}` : void 0, L = () => {
875
- if (!F)
874
+ if (!O)
876
875
  return;
877
876
  const f = _.current[C];
878
877
  $((f == null ? void 0 : f.offsetLeft) || 0), d((f == null ? void 0 : f.getBoundingClientRect().width) || 0);
879
878
  }, X = (f) => {
880
- F && H(b.findIndex((g) => g.props.tabId === f)), s == null || s(Zt(f));
879
+ O && H(b.findIndex((g) => g.props.tabId === f)), s == null || s(Zt(f));
881
880
  }, J = (f) => {
882
881
  if (m != null && m.current) {
883
- const { scrollLeft: g } = m.current, j = f === "left" ? -h : h;
884
- m.current.scroll({ left: g + j, behavior: "smooth" });
882
+ const { scrollLeft: g } = m.current, G = f === "left" ? -h : h;
883
+ m.current.scroll({ left: g + G, behavior: "smooth" });
885
884
  }
886
885
  }, Q = ({ side: f }) => /* @__PURE__ */ w(
887
886
  "button",
@@ -892,7 +891,7 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
892
891
  "aria-hidden": "true",
893
892
  tabIndex: -1,
894
893
  "data-testid": B("scroll-button"),
895
- children: /* @__PURE__ */ w(He, { svg: f === "left" ? Ge : ke, size: "md" })
894
+ children: /* @__PURE__ */ w(He, { svg: f === "left" ? je : ke, size: "md" })
896
895
  }
897
896
  );
898
897
  return P(() => (window.addEventListener("resize", L), () => {
@@ -907,8 +906,8 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
907
906
  }
908
907
  M.forEach((N) => {
909
908
  const pe = Number(N.target.getAttribute("data-index")), Re = pe === 0, Me = pe === b.length - 1;
910
- p((Oe) => ({
911
- ...Oe,
909
+ p((Fe) => ({
910
+ ...Fe,
912
911
  ...Re && {
913
912
  [`${y}__wrapper--scroll-end`]: !N.isIntersecting
914
913
  },
@@ -920,12 +919,12 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
920
919
  }, g = new IntersectionObserver(f, {
921
920
  threshold: [0.99],
922
921
  root: m.current
923
- }), j = _.current;
924
- return j.forEach((M) => g.observe(M)), () => {
925
- j.forEach((M) => g.unobserve(M));
922
+ }), G = _.current;
923
+ return G.forEach((M) => g.observe(M)), () => {
924
+ G.forEach((M) => g.unobserve(M));
926
925
  };
927
926
  }, [b.length]), /* @__PURE__ */ w(
928
- Ot,
927
+ Ft,
929
928
  {
930
929
  defaultValue: c ?? b[0].props.tabId,
931
930
  onValueChange: X,
@@ -935,7 +934,7 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
935
934
  children: /* @__PURE__ */ ee("div", { className: U(`${y}__container`), children: [
936
935
  /* @__PURE__ */ ee("div", { className: U([`${y}__wrapper`, i]), children: [
937
936
  /* @__PURE__ */ ee(
938
- Ft,
937
+ Ot,
939
938
  {
940
939
  ref: (f) => {
941
940
  m.current = f;
@@ -943,7 +942,7 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
943
942
  className: U(`${y}__list`),
944
943
  children: [
945
944
  E.map(b, (f, g) => {
946
- const { name: j, tabId: M, "data-testid": fe } = f.props;
945
+ const { name: G, tabId: M, "data-testid": fe } = f.props;
947
946
  return /* @__PURE__ */ w(
948
947
  Wt,
949
948
  {
@@ -958,11 +957,11 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
958
957
  },
959
958
  variant: t,
960
959
  negative: n,
961
- children: j
960
+ children: G
962
961
  }
963
962
  );
964
963
  }),
965
- F && /* @__PURE__ */ w(
964
+ O && /* @__PURE__ */ w(
966
965
  "div",
967
966
  {
968
967
  className: U(`${y}__selected-border`),
@@ -984,7 +983,7 @@ const de = /* @__PURE__ */ Lt(Ut), Vt = {
984
983
  }
985
984
  );
986
985
  };
987
- Xt.Content = Gt;
986
+ Xt.Content = jt;
988
987
  export {
989
988
  Xt as Tabs,
990
989
  Zt as createTabChangeDetailEvent,