@purpurds/tabs 3.2.0 → 3.3.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.es.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsx as N, jsxs as J } from "react/jsx-runtime";
2
2
  import * as fe from "react";
3
- import E, { createContext as ee, useMemo as Y, createElement as g, useContext as pe, useCallback as U, forwardRef as T, Children as P, isValidElement as G, cloneElement as oe, Fragment as Pe, useLayoutEffect as Re, useEffect as R, useRef as M, useState as D, useReducer as Me } from "react";
4
- import { flushSync as Oe } from "react-dom";
5
- function Fe(e) {
3
+ import E, { createContext as ee, useMemo as Y, createElement as g, useContext as pe, useCallback as U, forwardRef as T, Children as P, isValidElement as k, cloneElement as oe, Fragment as Pe, useLayoutEffect as Re, useEffect as R, useRef as M, useState as D, useReducer as Me } from "react";
4
+ import { flushSync as Fe } from "react-dom";
5
+ function Oe(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
7
7
  }
8
8
  var be = { exports: {} };
@@ -42,7 +42,7 @@ var be = { exports: {} };
42
42
  })();
43
43
  })(be);
44
44
  var De = be.exports;
45
- const qe = /* @__PURE__ */ Fe(De), Le = {
45
+ const qe = /* @__PURE__ */ Oe(De), Le = {
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",
@@ -60,14 +60,14 @@ const qe = /* @__PURE__ */ Fe(De), Le = {
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
- }, Be = qe.bind(Le), le = "purpur-icon", je = "md", ke = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), Ge = ({ content: e = "", title: t } = {}) => {
63
+ }, Be = qe.bind(Le), le = "purpur-icon", je = "md", Ge = (e) => e.filter((t) => Object.keys(t).length >= 1).map((t) => `${t.name}="${t.value}"`).join(" "), ke = ({ 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 ${ke(n)}>${o}${e}</svg>`;
70
+ return `<svg ${Ge(n)}>${o}${e}</svg>`;
71
71
  }, Ke = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), ze = ({
72
72
  ["data-testid"]: e,
73
73
  svg: t,
@@ -76,7 +76,7 @@ const qe = /* @__PURE__ */ Fe(De), Le = {
76
76
  size: s = je,
77
77
  ...r
78
78
  }) => {
79
- const c = Ge({
79
+ const c = ke({
80
80
  content: Ke(t.svg),
81
81
  title: n
82
82
  }), a = Be(o, le, `${le}--${s}`);
@@ -101,7 +101,7 @@ function y() {
101
101
  return e;
102
102
  }, y.apply(this, arguments);
103
103
  }
104
- function O(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
104
+ function F(e, t, { checkForDefaultPrevented: n = !0 } = {}) {
105
105
  return function(s) {
106
106
  if (e == null || e(s), n === !1 || !s.defaultPrevented)
107
107
  return t == null ? void 0 : t(s);
@@ -199,33 +199,33 @@ function $e(...e) {
199
199
  (n) => Ye(n, t)
200
200
  );
201
201
  }
202
- function Z(...e) {
202
+ function H(...e) {
203
203
  return U($e(...e), e);
204
204
  }
205
- const H = /* @__PURE__ */ T((e, t) => {
206
- const { children: n, ...o } = e, s = P.toArray(n), r = s.find(He);
205
+ const Z = /* @__PURE__ */ T((e, t) => {
206
+ const { children: n, ...o } = e, s = P.toArray(n), r = s.find(Ze);
207
207
  if (r) {
208
- const c = r.props.children, a = s.map((u) => u === r ? P.count(c) > 1 ? P.only(null) : /* @__PURE__ */ G(c) ? c.props.children : null : u);
208
+ const c = r.props.children, a = s.map((u) => u === r ? P.count(c) > 1 ? P.only(null) : /* @__PURE__ */ k(c) ? c.props.children : null : u);
209
209
  return /* @__PURE__ */ g(te, y({}, o, {
210
210
  ref: t
211
- }), /* @__PURE__ */ G(c) ? /* @__PURE__ */ oe(c, void 0, a) : null);
211
+ }), /* @__PURE__ */ k(c) ? /* @__PURE__ */ oe(c, void 0, a) : null);
212
212
  }
213
213
  return /* @__PURE__ */ g(te, y({}, o, {
214
214
  ref: t
215
215
  }), n);
216
216
  });
217
- H.displayName = "Slot";
217
+ Z.displayName = "Slot";
218
218
  const te = /* @__PURE__ */ T((e, t) => {
219
219
  const { children: n, ...o } = e;
220
- return /* @__PURE__ */ G(n) ? /* @__PURE__ */ oe(n, {
220
+ return /* @__PURE__ */ k(n) ? /* @__PURE__ */ oe(n, {
221
221
  ...Xe(o, n.props),
222
222
  ref: t ? $e(t, n.ref) : n.ref
223
223
  }) : P.count(n) > 1 ? P.only(null) : null;
224
224
  });
225
225
  te.displayName = "SlotClone";
226
- const Ze = ({ children: e }) => /* @__PURE__ */ g(Pe, null, e);
227
- function He(e) {
228
- return /* @__PURE__ */ G(e) && e.type === Ze;
226
+ const He = ({ children: e }) => /* @__PURE__ */ g(Pe, null, e);
227
+ function Ze(e) {
228
+ return /* @__PURE__ */ k(e) && e.type === He;
229
229
  }
230
230
  function Xe(e, t) {
231
231
  const n = {
@@ -262,18 +262,18 @@ function Je(e) {
262
262
  collectionRef: _
263
263
  }, b);
264
264
  }, a = e + "CollectionSlot", u = /* @__PURE__ */ E.forwardRef((m, d) => {
265
- const { scope: b, children: _ } = m, v = r(a, b), h = Z(d, v.collectionRef);
266
- return /* @__PURE__ */ E.createElement(H, {
265
+ const { scope: b, children: _ } = m, v = r(a, b), h = H(d, v.collectionRef);
266
+ return /* @__PURE__ */ E.createElement(Z, {
267
267
  ref: h
268
268
  }, _);
269
269
  }), i = e + "CollectionItemSlot", f = "data-radix-collection-item", l = /* @__PURE__ */ E.forwardRef((m, d) => {
270
- const { scope: b, children: _, ...v } = m, h = E.useRef(null), F = Z(d, h), A = r(i, b);
270
+ const { scope: b, children: _, ...v } = m, h = E.useRef(null), O = H(d, h), A = r(i, b);
271
271
  return E.useEffect(() => (A.itemMap.set(h, {
272
272
  ref: h,
273
273
  ...v
274
- }), () => void A.itemMap.delete(h))), /* @__PURE__ */ E.createElement(H, {
274
+ }), () => void A.itemMap.delete(h))), /* @__PURE__ */ E.createElement(Z, {
275
275
  [f]: "",
276
- ref: F
276
+ ref: O
277
277
  }, _);
278
278
  });
279
279
  function $(m) {
@@ -332,9 +332,9 @@ const tt = [
332
332
  "span",
333
333
  "svg",
334
334
  "ul"
335
- ], k = tt.reduce((e, t) => {
335
+ ], G = tt.reduce((e, t) => {
336
336
  const n = /* @__PURE__ */ T((o, s) => {
337
- const { asChild: r, ...c } = o, a = r ? H : t;
337
+ const { asChild: r, ...c } = o, a = r ? Z : t;
338
338
  return R(() => {
339
339
  window[Symbol.for("radix-ui")] = !0;
340
340
  }, []), /* @__PURE__ */ g(a, y({}, c, {
@@ -407,11 +407,11 @@ const Q = "rovingFocusGroup.onEntryFocus", ot = {
407
407
  }, /* @__PURE__ */ g(lt, y({}, e, {
408
408
  ref: t
409
409
  }))))), lt = /* @__PURE__ */ T((e, t) => {
410
- const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...f } = e, l = M(null), $ = Z(t, l), m = _e(r), [d = null, b] = me({
410
+ const { __scopeRovingFocusGroup: n, orientation: o, loop: s = !1, dir: r, currentTabStopId: c, defaultCurrentTabStopId: a, onCurrentTabStopIdChange: u, onEntryFocus: i, ...f } = e, l = M(null), $ = H(t, l), m = _e(r), [d = null, b] = me({
411
411
  prop: c,
412
412
  defaultProp: a,
413
413
  onChange: u
414
- }), [_, v] = D(!1), h = se(i), F = he(n), A = M(!1), [V, B] = D(0);
414
+ }), [_, v] = D(!1), h = se(i), O = he(n), A = M(!1), [V, B] = D(0);
415
415
  return R(() => {
416
416
  const x = l.current;
417
417
  if (x)
@@ -446,7 +446,7 @@ const Q = "rovingFocusGroup.onEntryFocus", ot = {
446
446
  ),
447
447
  []
448
448
  )
449
- }, /* @__PURE__ */ g(k.div, y({
449
+ }, /* @__PURE__ */ g(G.div, y({
450
450
  tabIndex: _ || V === 0 ? -1 : 0,
451
451
  "data-orientation": o
452
452
  }, f, {
@@ -455,15 +455,15 @@ const Q = "rovingFocusGroup.onEntryFocus", ot = {
455
455
  outline: "none",
456
456
  ...e.style
457
457
  },
458
- onMouseDown: O(e.onMouseDown, () => {
458
+ onMouseDown: F(e.onMouseDown, () => {
459
459
  A.current = !0;
460
460
  }),
461
- onFocus: O(e.onFocus, (x) => {
461
+ onFocus: F(e.onFocus, (x) => {
462
462
  const X = !A.current;
463
463
  if (x.target === x.currentTarget && X && !_) {
464
464
  const K = new CustomEvent(Q, ot);
465
465
  if (x.currentTarget.dispatchEvent(K), !K.defaultPrevented) {
466
- const j = F().filter(
466
+ const j = O().filter(
467
467
  (C) => C.focusable
468
468
  ), p = j.find(
469
469
  (C) => C.active
@@ -481,7 +481,7 @@ const Q = "rovingFocusGroup.onEntryFocus", ot = {
481
481
  }
482
482
  A.current = !1;
483
483
  }),
484
- onBlur: O(
484
+ onBlur: F(
485
485
  e.onBlur,
486
486
  () => v(!1)
487
487
  )
@@ -500,19 +500,19 @@ const Q = "rovingFocusGroup.onEntryFocus", ot = {
500
500
  id: u,
501
501
  focusable: o,
502
502
  active: s
503
- }, /* @__PURE__ */ g(k.span, y({
503
+ }, /* @__PURE__ */ g(G.span, y({
504
504
  tabIndex: f ? 0 : -1,
505
505
  "data-orientation": i.orientation
506
506
  }, c, {
507
507
  ref: t,
508
- onMouseDown: O(e.onMouseDown, (d) => {
508
+ onMouseDown: F(e.onMouseDown, (d) => {
509
509
  o ? i.onItemFocus(u) : d.preventDefault();
510
510
  }),
511
- onFocus: O(
511
+ onFocus: F(
512
512
  e.onFocus,
513
513
  () => i.onItemFocus(u)
514
514
  ),
515
- onKeyDown: O(e.onKeyDown, (d) => {
515
+ onKeyDown: F(e.onKeyDown, (d) => {
516
516
  if (d.key === "Tab" && d.shiftKey) {
517
517
  i.onItemShiftTab();
518
518
  return;
@@ -585,7 +585,7 @@ function ht(e, t) {
585
585
  const Ce = (e) => {
586
586
  const { present: t, children: n } = e, o = gt(t), s = typeof n == "function" ? n({
587
587
  present: o.isPresent
588
- }) : P.only(n), r = Z(o.ref, s.ref);
588
+ }) : P.only(n), r = H(o.ref, s.ref);
589
589
  return typeof n == "function" || o.isPresent ? /* @__PURE__ */ oe(s, {
590
590
  ref: r
591
591
  }) : null;
@@ -623,7 +623,7 @@ function gt(e) {
623
623
  if (t) {
624
624
  const i = (l) => {
625
625
  const m = W(o.current).includes(l.animationName);
626
- l.target === t && m && Oe(
626
+ l.target === t && m && Fe(
627
627
  () => u("ANIMATION_END")
628
628
  );
629
629
  }, f = (l) => {
@@ -666,7 +666,7 @@ const Ie = "Tabs", [xt, Xt] = ce(Ie, [
666
666
  orientation: c,
667
667
  dir: f,
668
668
  activationMode: u
669
- }, /* @__PURE__ */ g(k.div, y({
669
+ }, /* @__PURE__ */ g(G.div, y({
670
670
  dir: f,
671
671
  "data-orientation": c
672
672
  }, i, {
@@ -680,7 +680,7 @@ const Ie = "Tabs", [xt, Xt] = ce(Ie, [
680
680
  orientation: r.orientation,
681
681
  dir: r.dir,
682
682
  loop: o
683
- }), /* @__PURE__ */ g(k.div, y({
683
+ }), /* @__PURE__ */ g(G.div, y({
684
684
  role: "tablist",
685
685
  "aria-orientation": r.orientation
686
686
  }, s, {
@@ -693,7 +693,7 @@ const Ie = "Tabs", [xt, Xt] = ce(Ie, [
693
693
  }, a, {
694
694
  focusable: !s,
695
695
  active: f
696
- }), /* @__PURE__ */ g(k.button, y({
696
+ }), /* @__PURE__ */ g(G.button, y({
697
697
  type: "button",
698
698
  role: "tab",
699
699
  "aria-selected": f,
@@ -704,16 +704,16 @@ const Ie = "Tabs", [xt, Xt] = ce(Ie, [
704
704
  id: u
705
705
  }, r, {
706
706
  ref: t,
707
- onMouseDown: O(e.onMouseDown, (l) => {
707
+ onMouseDown: F(e.onMouseDown, (l) => {
708
708
  !s && l.button === 0 && l.ctrlKey === !1 ? c.onValueChange(o) : l.preventDefault();
709
709
  }),
710
- onKeyDown: O(e.onKeyDown, (l) => {
710
+ onKeyDown: F(e.onKeyDown, (l) => {
711
711
  [
712
712
  " ",
713
713
  "Enter"
714
714
  ].includes(l.key) && c.onValueChange(o);
715
715
  }),
716
- onFocus: O(e.onFocus, () => {
716
+ onFocus: F(e.onFocus, () => {
717
717
  const l = c.activationMode !== "manual";
718
718
  !f && !s && l && c.onValueChange(o);
719
719
  })
@@ -730,7 +730,7 @@ const Ie = "Tabs", [xt, Xt] = ce(Ie, [
730
730
  {
731
731
  present: s || f
732
732
  },
733
- ({ present: $ }) => /* @__PURE__ */ g(k.div, y({
733
+ ({ present: $ }) => /* @__PURE__ */ g(G.div, y({
734
734
  "data-state": f ? "active" : "inactive",
735
735
  "data-orientation": a.orientation,
736
736
  role: "tabpanel",
@@ -754,7 +754,7 @@ function we(e, t) {
754
754
  return `${e}-content-${t}`;
755
755
  }
756
756
  const Et = It, Pt = St, Rt = Tt, Mt = At;
757
- function Ot(e) {
757
+ function Ft(e) {
758
758
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
759
759
  }
760
760
  var Te = { exports: {} };
@@ -793,8 +793,8 @@ var Te = { exports: {} };
793
793
  e.exports ? (n.default = n, e.exports = n) : window.classNames = n;
794
794
  })();
795
795
  })(Te);
796
- var Ft = Te.exports;
797
- const ue = /* @__PURE__ */ Ot(Ft), Dt = {
796
+ var Ot = Te.exports;
797
+ const ue = /* @__PURE__ */ Ft(Ot), Dt = {
798
798
  "purpur-tab-content": "_purpur-tab-content_rbfjg_1"
799
799
  }, qt = ue.bind(Dt), Lt = "purpur-tab-content", Ut = T(
800
800
  ({ children: e, tabId: t, "data-testid": n, className: o, ...s }, r) => /* @__PURE__ */ N(
@@ -808,13 +808,13 @@ const ue = /* @__PURE__ */ Ot(Ft), Dt = {
808
808
  children: e
809
809
  }
810
810
  )
811
- ), Vt = (e) => !!e && G(e) && !!e.props.name && !!e.props.tabId, Bt = {
811
+ ), Vt = (e) => !!e && k(e) && !!e.props.name && !!e.props.tabId, Bt = {
812
812
  "purpur-tab-header": "_purpur-tab-header_1hk4f_1",
813
813
  "purpur-tab-header--contained": "_purpur-tab-header--contained_1hk4f_32",
814
814
  "purpur-tab-header--contained-negative": "_purpur-tab-header--contained-negative_1hk4f_32",
815
815
  "purpur-tab-header--line": "_purpur-tab-header--line_1hk4f_35",
816
816
  "purpur-tab-header--line-negative": "_purpur-tab-header--line-negative_1hk4f_47"
817
- }, jt = ue.bind(Bt), de = "purpur-tab-header", kt = T(
817
+ }, jt = ue.bind(Bt), de = "purpur-tab-header", Gt = T(
818
818
  ({ index: e, tabId: t, variant: n, onFocus: o, "data-testid": s, children: r }, c) => /* @__PURE__ */ N(
819
819
  Rt,
820
820
  {
@@ -828,7 +828,7 @@ const ue = /* @__PURE__ */ Ot(Ft), Dt = {
828
828
  children: r
829
829
  }
830
830
  )
831
- ), Gt = {
831
+ ), kt = {
832
832
  "purpur-tabs__wrapper": "_purpur-tabs__wrapper_1dpqy_1",
833
833
  "purpur-tabs__scroll-button": "_purpur-tabs__scroll-button_1dpqy_9",
834
834
  "purpur-tabs__scroll-button--left": "_purpur-tabs__scroll-button--left_1dpqy_63",
@@ -843,7 +843,7 @@ const ue = /* @__PURE__ */ Ot(Ft), Dt = {
843
843
  "purpur-tabs--contained-negative": "_purpur-tabs--contained-negative_1dpqy_103",
844
844
  "purpur-tabs__content-container": "_purpur-tabs__content-container_1dpqy_106",
845
845
  "purpur-tabs--fullWidth": "_purpur-tabs--fullWidth_1dpqy_115"
846
- }, Jt = ["line", "line-negative", "contained", "contained-negative"], Kt = (e) => new CustomEvent("tabChangeDetail", { detail: { value: e } }), L = ue.bind(Gt), w = "purpur-tabs", zt = (e, t) => {
846
+ }, Jt = ["line", "line-negative", "contained", "contained-negative"], Kt = (e) => new CustomEvent("tabChangeDetail", { detail: { value: e } }), L = ue.bind(kt), w = "purpur-tabs", zt = (e, t) => {
847
847
  var u;
848
848
  if (typeof (e == null ? void 0 : e.getBoundingClientRect) != "function" || typeof (t == null ? void 0 : t.scroll) != "function")
849
849
  return;
@@ -859,7 +859,7 @@ const ue = /* @__PURE__ */ Ot(Ft), Dt = {
859
859
  "data-testid": r,
860
860
  ...c
861
861
  }) => {
862
- const [a, u] = D(0), [i, f] = D({}), [l, $] = D(0), [m, d] = D(0), b = P.toArray(e).filter(Vt), _ = M(), v = M(new Array(b.length)), h = 200, F = t === "line" || t === "line-negative", A = L([
862
+ const [a, u] = D(0), [i, f] = D({}), [l, $] = D(0), [m, d] = D(0), b = P.toArray(e).filter(Vt), _ = M(), v = M(new Array(b.length)), h = 200, O = t === "line" || t === "line-negative", A = L([
863
863
  w,
864
864
  `${w}--${t}`,
865
865
  { [`${w}--fullWidth`]: n },
@@ -868,12 +868,12 @@ const ue = /* @__PURE__ */ Ot(Ft), Dt = {
868
868
  if (new Set(V).size !== V.length)
869
869
  throw new Error("tabId must be unique");
870
870
  const B = (p, I) => I || r ? `${I || r}-${p}` : void 0, x = () => {
871
- if (!F)
871
+ if (!O)
872
872
  return;
873
873
  const p = v.current[a];
874
874
  $((p == null ? void 0 : p.offsetLeft) || 0), d((p == null ? void 0 : p.getBoundingClientRect().width) || 0);
875
875
  }, X = (p) => {
876
- F && u(b.findIndex((I) => I.props.tabId === p)), o == null || o(Kt(p));
876
+ O && u(b.findIndex((I) => I.props.tabId === p)), o == null || o(Kt(p));
877
877
  }, K = (p) => {
878
878
  if (_ != null && _.current) {
879
879
  const { scrollLeft: I } = _.current, S = p === "left" ? -h : h;
@@ -941,7 +941,7 @@ const ue = /* @__PURE__ */ Ot(Ft), Dt = {
941
941
  P.map(b, (p, I) => {
942
942
  const { name: S, tabId: z, "data-testid": C } = p.props;
943
943
  return /* @__PURE__ */ N(
944
- kt,
944
+ Gt,
945
945
  {
946
946
  "data-testid": B("header", C),
947
947
  index: I,
@@ -957,7 +957,7 @@ const ue = /* @__PURE__ */ Ot(Ft), Dt = {
957
957
  }
958
958
  );
959
959
  }),
960
- F && /* @__PURE__ */ N(
960
+ O && /* @__PURE__ */ N(
961
961
  "div",
962
962
  {
963
963
  className: L(`${w}__selected-border`),