@purpurds/tabs 7.3.0 → 7.4.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,6 +1,6 @@
1
- import { jsx as m, Fragment as qe, jsxs as J } from "react/jsx-runtime";
1
+ import { jsx as m, Fragment as ze, jsxs as J } from "react/jsx-runtime";
2
2
  import * as a from "react";
3
- import O, { forwardRef as we, isValidElement as Ye, useRef as Q, useState as B, Children as z, useEffect as K } from "react";
3
+ import O, { forwardRef as we, isValidElement as Ye, useRef as Q, useState as B, Children as K, useEffect as q } from "react";
4
4
  import "react-dom";
5
5
  function Ze(e) {
6
6
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
@@ -12,7 +12,7 @@ var pe = { exports: {} };
12
12
  http://jedwatson.github.io/classnames
13
13
  */
14
14
  var me;
15
- function He() {
15
+ function Xe() {
16
16
  return me || (me = 1, function(e) {
17
17
  (function() {
18
18
  var t = {}.hasOwnProperty;
@@ -44,8 +44,8 @@ function He() {
44
44
  })();
45
45
  }(pe)), pe.exports;
46
46
  }
47
- var Xe = He();
48
- const Je = /* @__PURE__ */ Ze(Xe), Qe = {
47
+ var He = Xe();
48
+ const Je = /* @__PURE__ */ Ze(He), Qe = {
49
49
  "purpur-icon": "_purpur-icon_8u1lq_1",
50
50
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
51
51
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -193,7 +193,7 @@ var ne = a.forwardRef((e, t) => {
193
193
  return a.Children.count(n) > 1 ? a.Children.only(null) : null;
194
194
  });
195
195
  ne.displayName = "SlotClone";
196
- var at = ({ children: e }) => /* @__PURE__ */ m(qe, { children: e });
196
+ var at = ({ children: e }) => /* @__PURE__ */ m(ze, { children: e });
197
197
  function ut(e) {
198
198
  return a.isValidElement(e) && e.type === at;
199
199
  }
@@ -326,13 +326,13 @@ function Ne(e) {
326
326
  const t = a.useContext(bt);
327
327
  return e || t || "ltr";
328
328
  }
329
- var ee = "rovingFocusGroup.onEntryFocus", gt = { bubbles: !1, cancelable: !0 }, H = "RovingFocusGroup", [oe, Re, ht] = ft(H), [wt, Te] = se(
330
- H,
329
+ var ee = "rovingFocusGroup.onEntryFocus", gt = { bubbles: !1, cancelable: !0 }, X = "RovingFocusGroup", [oe, Re, ht] = ft(X), [wt, Te] = se(
330
+ X,
331
331
  [ht]
332
- ), [Ct, yt] = wt(H), xe = a.forwardRef(
332
+ ), [Ct, yt] = wt(X), xe = a.forwardRef(
333
333
  (e, t) => /* @__PURE__ */ m(oe.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ m(oe.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ m(It, { ...e, ref: t }) }) })
334
334
  );
335
- xe.displayName = H;
335
+ xe.displayName = X;
336
336
  var It = a.forwardRef((e, t) => {
337
337
  const {
338
338
  __scopeRovingFocusGroup: n,
@@ -387,8 +387,8 @@ var It = a.forwardRef((e, t) => {
387
387
  N.current = !0;
388
388
  }),
389
389
  onFocus: A(e.onFocus, (I) => {
390
- const X = !N.current;
391
- if (I.target === I.currentTarget && X && !h) {
390
+ const H = !N.current;
391
+ if (I.target === I.currentTarget && H && !h) {
392
392
  const F = new CustomEvent(ee, gt);
393
393
  if (I.currentTarget.dispatchEvent(F), !F.defaultPrevented) {
394
394
  const L = C().filter((x) => x.focusable), V = L.find((x) => x.active), G = L.find((x) => x.id === g), k = [V, G, ...L].filter(
@@ -511,19 +511,19 @@ function jt(e) {
511
511
  }
512
512
  });
513
513
  return a.useEffect(() => {
514
- const u = q(o.current);
514
+ const u = z(o.current);
515
515
  r.current = c === "mounted" ? u : "none";
516
516
  }, [c]), re(() => {
517
517
  const u = o.current, _ = s.current;
518
518
  if (_ !== e) {
519
- const v = r.current, b = q(u);
519
+ const v = r.current, b = z(u);
520
520
  e ? l("MOUNT") : b === "none" || (u == null ? void 0 : u.display) === "none" ? l("UNMOUNT") : l(_ && v !== b ? "ANIMATION_OUT" : "UNMOUNT"), s.current = e;
521
521
  }
522
522
  }, [e, l]), re(() => {
523
523
  if (t) {
524
524
  let u;
525
525
  const _ = t.ownerDocument.defaultView ?? window, d = (b) => {
526
- const g = q(o.current).includes(b.animationName);
526
+ const g = z(o.current).includes(b.animationName);
527
527
  if (b.target === t && g && (l("ANIMATION_END"), !s.current)) {
528
528
  const y = t.style.animationFillMode;
529
529
  t.style.animationFillMode = "forwards", u = _.setTimeout(() => {
@@ -531,7 +531,7 @@ function jt(e) {
531
531
  });
532
532
  }
533
533
  }, v = (b) => {
534
- b.target === t && (r.current = q(o.current));
534
+ b.target === t && (r.current = z(o.current));
535
535
  };
536
536
  return t.addEventListener("animationstart", v), t.addEventListener("animationcancel", d), t.addEventListener("animationend", d), () => {
537
537
  _.clearTimeout(u), t.removeEventListener("animationstart", v), t.removeEventListener("animationcancel", d), t.removeEventListener("animationend", d);
@@ -545,7 +545,7 @@ function jt(e) {
545
545
  }, [])
546
546
  };
547
547
  }
548
- function q(e) {
548
+ function z(e) {
549
549
  return (e == null ? void 0 : e.animationName) || "none";
550
550
  }
551
551
  function Mt(e) {
@@ -765,13 +765,13 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
765
765
  children: e
766
766
  }
767
767
  )
768
- ), zt = (e) => !!e && Ye(e) && !!e.props.name && !!e.props.tabId, Kt = {
769
- "purpur-tab-header": "_purpur-tab-header_1thzh_1",
770
- "purpur-tab-header--contained": "_purpur-tab-header--contained_1thzh_35",
771
- "purpur-tab-header--contained-negative": "_purpur-tab-header--contained-negative_1thzh_35",
772
- "purpur-tab-header--line": "_purpur-tab-header--line_1thzh_38",
773
- "purpur-tab-header--line-negative": "_purpur-tab-header--line-negative_1thzh_50"
774
- }, qt = ue.bind(Kt), he = "purpur-tab-header", Yt = we(
768
+ ), Kt = (e) => !!e && Ye(e) && !!e.props.name && !!e.props.tabId, qt = {
769
+ "purpur-tab-header": "_purpur-tab-header_ebsfx_1",
770
+ "purpur-tab-header--contained": "_purpur-tab-header--contained_ebsfx_36",
771
+ "purpur-tab-header--contained-negative": "_purpur-tab-header--contained-negative_ebsfx_36",
772
+ "purpur-tab-header--line": "_purpur-tab-header--line_ebsfx_39",
773
+ "purpur-tab-header--line-negative": "_purpur-tab-header--line-negative_ebsfx_51"
774
+ }, zt = ue.bind(qt), he = "purpur-tab-header", Yt = we(
775
775
  ({
776
776
  index: e,
777
777
  tabId: t,
@@ -784,7 +784,7 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
784
784
  Dt,
785
785
  {
786
786
  id: `${t}-trigger`,
787
- className: qt([he, `${he}--${n}${o ? "-negative" : ""}`]),
787
+ className: zt([he, `${he}--${n}${o ? "-negative" : ""}`]),
788
788
  value: t,
789
789
  "data-testid": r,
790
790
  "data-index": e,
@@ -809,7 +809,7 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
809
809
  "purpur-tabs--contained-negative": "_purpur-tabs--contained-negative_j1jjc_123",
810
810
  "purpur-tabs__content-container": "_purpur-tabs__content-container_j1jjc_126",
811
811
  "purpur-tabs--fullWidth": "_purpur-tabs--fullWidth_j1jjc_136"
812
- }, rn = ["line", "contained"], Ht = (e) => new CustomEvent("tabChangeDetail", { detail: { value: e } }), P = ue.bind(Zt), R = "purpur-tabs", Xt = (e, t) => {
812
+ }, rn = ["line", "contained"], Xt = (e) => new CustomEvent("tabChangeDetail", { detail: { value: e } }), P = ue.bind(Zt), R = "purpur-tabs", Ht = (e, t) => {
813
813
  var l;
814
814
  if (typeof (e == null ? void 0 : e.getBoundingClientRect) != "function" || typeof (t == null ? void 0 : t.scroll) != "function")
815
815
  return;
@@ -829,16 +829,16 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
829
829
  value: u,
830
830
  ..._
831
831
  }) => {
832
- const d = Q(null), [v, b] = B(-1), [f, g] = B({}), [y, h] = B(0), [w, j] = B(0), C = z.toArray(e).filter(zt), N = Q(null), D = Q(new Array(C.length)), U = 200, I = t === "line", X = P([
832
+ const d = Q(null), [v, b] = B(-1), [f, g] = B({}), [y, h] = B(0), [w, j] = B(0), C = K.toArray(e).filter(Kt), N = Q(null), D = Q(new Array(C.length)), U = 200, I = t === "line", H = P([
833
833
  R,
834
834
  `${R}--${t}${n ? "-negative" : ""}`,
835
835
  { [`${R}--fullWidth`]: o },
836
836
  r
837
- ]), F = z.map(C, ({ props: { tabId: p } }) => p), L = () => {
837
+ ]), F = K.map(C, ({ props: { tabId: p } }) => p), L = () => {
838
838
  const p = F.findIndex((S) => S === i);
839
839
  return p >= 0 ? p : 0;
840
840
  };
841
- K(() => {
841
+ q(() => {
842
842
  u && G(C.findIndex((p) => p.props.tabId === u));
843
843
  }, [C, u]);
844
844
  const [V, G] = B(L);
@@ -850,7 +850,7 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
850
850
  const p = D.current[V];
851
851
  h((p == null ? void 0 : p.offsetLeft) || 0), j((p == null ? void 0 : p.getBoundingClientRect().width) || 0);
852
852
  }, x = (p) => {
853
- I && !u && G(C.findIndex((S) => S.props.tabId === p)), s == null || s(Ht(p));
853
+ I && !u && G(C.findIndex((S) => S.props.tabId === p)), s == null || s(Xt(p));
854
854
  }, We = (p) => {
855
855
  if (N != null && N.current) {
856
856
  const { scrollLeft: S } = N.current, M = p === "left" ? -200 : U;
@@ -868,7 +868,7 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
868
868
  children: /* @__PURE__ */ m(Ce, { svg: p === "left" ? st : it, size: "md" })
869
869
  }
870
870
  );
871
- return K(() => {
871
+ return q(() => {
872
872
  const p = () => {
873
873
  if (d.current && c) {
874
874
  const M = d.current.offsetHeight;
@@ -880,22 +880,22 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
880
880
  return p(), window.addEventListener("resize", S), () => {
881
881
  window.removeEventListener("resize", S);
882
882
  };
883
- }, [V, c]), K(() => {
883
+ }, [V, c]), q(() => {
884
884
  k();
885
- }, [V, o, C.length, t]), K(() => {
885
+ }, [V, o, C.length, t]), q(() => {
886
886
  const p = (E) => {
887
887
  if (E.every((T) => T.isIntersecting) && E.length === C.length) {
888
888
  g({});
889
889
  return;
890
890
  }
891
891
  E.forEach((T) => {
892
- const fe = Number(T.target.getAttribute("data-index")), ke = fe === 0, ze = fe === C.length - 1;
893
- g((Ke) => ({
894
- ...Ke,
892
+ const fe = Number(T.target.getAttribute("data-index")), ke = fe === 0, Ke = fe === C.length - 1;
893
+ g((qe) => ({
894
+ ...qe,
895
895
  ...ke && {
896
896
  [`${R}__wrapper--scroll-end`]: !T.isIntersecting
897
897
  },
898
- ...ze && {
898
+ ...Ke && {
899
899
  [`${R}__wrapper--scroll-start`]: !T.isIntersecting
900
900
  }
901
901
  }));
@@ -913,7 +913,7 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
913
913
  defaultValue: i ?? C[0].props.tabId,
914
914
  onValueChange: x,
915
915
  "data-testid": l,
916
- className: X,
916
+ className: H,
917
917
  value: u,
918
918
  ..._,
919
919
  children: /* @__PURE__ */ J("div", { className: P(`${R}__container`), children: [
@@ -926,7 +926,7 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
926
926
  },
927
927
  className: P(`${R}__list`),
928
928
  children: [
929
- z.map(C, (p, S) => {
929
+ K.map(C, (p, S) => {
930
930
  const { name: M, tabId: E, "data-testid": de } = p.props;
931
931
  return /* @__PURE__ */ m(
932
932
  Yt,
@@ -938,7 +938,7 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
938
938
  T && (D.current[S] = T);
939
939
  },
940
940
  onFocus: (T) => {
941
- Xt(T.target, N.current);
941
+ Ht(T.target, N.current);
942
942
  },
943
943
  variant: t,
944
944
  negative: n,
@@ -966,9 +966,9 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
966
966
  /* @__PURE__ */ m(
967
967
  "div",
968
968
  {
969
- className: P(`${R}__content-wrapper`),
969
+ className: c ? P(`${R}__content-wrapper`) : "",
970
970
  style: { height: c && v > -1 ? `${v}px` : "auto" },
971
- children: /* @__PURE__ */ m("div", { ref: d, className: P(`${R}__content-container`), children: z.map(C, (p) => p) })
971
+ children: /* @__PURE__ */ m("div", { ref: d, className: P(`${R}__content-container`), children: K.map(C, (p) => p) })
972
972
  }
973
973
  )
974
974
  ] })
@@ -978,7 +978,7 @@ const ue = /* @__PURE__ */ Vt(Ut), Gt = {
978
978
  Jt.Content = kt;
979
979
  export {
980
980
  Jt as Tabs,
981
- Ht as createTabChangeDetailEvent,
981
+ Xt as createTabChangeDetailEvent,
982
982
  rn as tabsVariants
983
983
  };
984
984
  //# sourceMappingURL=tabs.es.js.map