@purpurds/tabs 4.5.0 → 4.5.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
@@ -398,7 +398,7 @@ function he(e) {
398
398
  const ee = "rovingFocusGroup.onEntryFocus", st = {
399
399
  bubbles: !1,
400
400
  cancelable: !0
401
- }, ie = "RovingFocusGroup", [oe, xe, at] = et(ie), [it, Ce] = se(ie, [
401
+ }, ie = "RovingFocusGroup", [oe, xe, at] = et(ie), [it, Ie] = se(ie, [
402
402
  at
403
403
  ]), [ut, lt] = it(ie), dt = /* @__PURE__ */ T((e, t) => /* @__PURE__ */ g(oe.Provider, {
404
404
  scope: e.__scopeRovingFocusGroup
@@ -413,9 +413,9 @@ const ee = "rovingFocusGroup.onEntryFocus", st = {
413
413
  onChange: u
414
414
  }), [h, m] = O(!1), _ = ae(i), U = xe(n), S = P(!1), [j, G] = O(0);
415
415
  return R(() => {
416
- const C = d.current;
417
- if (C)
418
- return C.addEventListener(ee, _), () => C.removeEventListener(ee, _);
416
+ const I = d.current;
417
+ if (I)
418
+ return I.addEventListener(ee, _), () => I.removeEventListener(ee, _);
419
419
  }, [
420
420
  _
421
421
  ]), /* @__PURE__ */ g(ut, {
@@ -425,7 +425,7 @@ const ee = "rovingFocusGroup.onEntryFocus", st = {
425
425
  loop: s,
426
426
  currentTabStopId: l,
427
427
  onItemFocus: L(
428
- (C) => $(C),
428
+ (I) => $(I),
429
429
  [
430
430
  $
431
431
  ]
@@ -436,13 +436,13 @@ const ee = "rovingFocusGroup.onEntryFocus", st = {
436
436
  ),
437
437
  onFocusableItemAdd: L(
438
438
  () => G(
439
- (C) => C + 1
439
+ (I) => I + 1
440
440
  ),
441
441
  []
442
442
  ),
443
443
  onFocusableItemRemove: L(
444
444
  () => G(
445
- (C) => C - 1
445
+ (I) => I - 1
446
446
  ),
447
447
  []
448
448
  )
@@ -458,25 +458,25 @@ const ee = "rovingFocusGroup.onEntryFocus", st = {
458
458
  onMouseDown: M(e.onMouseDown, () => {
459
459
  S.current = !0;
460
460
  }),
461
- onFocus: M(e.onFocus, (C) => {
461
+ onFocus: M(e.onFocus, (I) => {
462
462
  const k = !S.current;
463
- if (C.target === C.currentTarget && k && !h) {
463
+ if (I.target === I.currentTarget && k && !h) {
464
464
  const V = new CustomEvent(ee, st);
465
- if (C.currentTarget.dispatchEvent(V), !V.defaultPrevented) {
465
+ if (I.currentTarget.dispatchEvent(V), !V.defaultPrevented) {
466
466
  const z = U().filter(
467
467
  (x) => x.focusable
468
468
  ), J = z.find(
469
469
  (x) => x.active
470
470
  ), W = z.find(
471
471
  (x) => x.id === l
472
- ), I = [
472
+ ), C = [
473
473
  J,
474
474
  W,
475
475
  ...z
476
476
  ].filter(Boolean).map(
477
477
  (x) => x.ref.current
478
478
  );
479
- Ie(I);
479
+ Ce(C);
480
480
  }
481
481
  }
482
482
  S.current = !1;
@@ -535,7 +535,7 @@ const ee = "rovingFocusGroup.onEntryFocus", st = {
535
535
  m = i.loop ? _t(m, _ + 1) : m.slice(_ + 1);
536
536
  }
537
537
  setTimeout(
538
- () => Ie(m)
538
+ () => Ce(m)
539
539
  );
540
540
  }
541
541
  })
@@ -564,7 +564,7 @@ function mt(e, t, n) {
564
564
  ].includes(o)))
565
565
  return $t[o];
566
566
  }
567
- function Ie(e) {
567
+ function Ce(e) {
568
568
  const t = document.activeElement;
569
569
  for (const n of e)
570
570
  if (n === t || (n.focus(), document.activeElement !== t))
@@ -583,7 +583,7 @@ function xt(e, t) {
583
583
  }, e);
584
584
  }
585
585
  const ye = (e) => {
586
- const { present: t, children: n } = e, o = Ct(t), s = typeof n == "function" ? n({
586
+ const { present: t, children: n } = e, o = It(t), s = typeof n == "function" ? n({
587
587
  present: o.isPresent
588
588
  }) : E.only(n), r = H(o.ref, s.ref);
589
589
  return typeof n == "function" || o.isPresent ? /* @__PURE__ */ ce(s, {
@@ -591,7 +591,7 @@ const ye = (e) => {
591
591
  }) : null;
592
592
  };
593
593
  ye.displayName = "Presence";
594
- function Ct(e) {
594
+ function It(e) {
595
595
  const [t, n] = O(), o = P({}), s = P(e), r = P("none"), c = e ? "mounted" : "unmounted", [a, u] = xt(c, {
596
596
  mounted: {
597
597
  UNMOUNT: "unmounted",
@@ -650,9 +650,9 @@ function Ct(e) {
650
650
  function Y(e) {
651
651
  return (e == null ? void 0 : e.animationName) || "none";
652
652
  }
653
- const Se = "Tabs", [It, Qt] = se(Se, [
654
- Ce
655
- ]), we = Ce(), [yt, ue] = It(Se), St = /* @__PURE__ */ T((e, t) => {
653
+ const Se = "Tabs", [Ct, Qt] = se(Se, [
654
+ Ie
655
+ ]), we = Ie(), [yt, ue] = Ct(Se), St = /* @__PURE__ */ T((e, t) => {
656
656
  const { __scopeTabs: n, value: o, onValueChange: s, defaultValue: r, orientation: c = "horizontal", dir: a, activationMode: u = "automatic", ...i } = e, f = he(a), [d, b] = ge({
657
657
  prop: o,
658
658
  onChange: s,
@@ -865,20 +865,20 @@ const le = /* @__PURE__ */ Dt(qt), Lt = {
865
865
  `${w}--${t}`,
866
866
  { [`${w}--fullWidth`]: n },
867
867
  s
868
- ]), S = E.map(l, ({ props: { tabId: p } }) => p), j = () => S.findIndex((p) => p === r) || 0, [G, C] = O(j);
868
+ ]), S = E.map(l, ({ props: { tabId: p } }) => p), j = () => S.findIndex((p) => p === r) || 0, [G, I] = O(j);
869
869
  if (new Set(S).size !== S.length)
870
870
  throw new Error("tabId must be unique");
871
- const k = (p, I) => I || c ? `${I || c}-${p}` : void 0, V = () => {
871
+ const k = (p, C) => C || c ? `${C || c}-${p}` : void 0, V = () => {
872
872
  if (!_)
873
873
  return;
874
874
  const p = h.current[G];
875
875
  d((p == null ? void 0 : p.offsetLeft) || 0), v((p == null ? void 0 : p.getBoundingClientRect().width) || 0);
876
876
  }, z = (p) => {
877
- _ && C(l.findIndex((I) => I.props.tabId === p)), o == null || o(Wt(p));
877
+ _ && I(l.findIndex((C) => C.props.tabId === p)), o == null || o(Wt(p));
878
878
  }, J = (p) => {
879
879
  if ($ != null && $.current) {
880
- const { scrollLeft: I } = $.current, x = p === "left" ? -m : m;
881
- $.current.scroll({ left: I + x, behavior: "smooth" });
880
+ const { scrollLeft: C } = $.current, x = p === "left" ? -m : m;
881
+ $.current.scroll({ left: C + x, behavior: "smooth" });
882
882
  }
883
883
  }, W = ({ side: p }) => /* @__PURE__ */ N(
884
884
  "button",
@@ -914,17 +914,17 @@ const le = /* @__PURE__ */ Dt(qt), Lt = {
914
914
  }
915
915
  }));
916
916
  });
917
- }, I = new IntersectionObserver(p, {
917
+ }, C = new IntersectionObserver(p, {
918
918
  threshold: [0.99],
919
919
  root: $.current
920
920
  });
921
- return h.current.forEach((x) => I.observe(x)), () => {
922
- h.current.forEach((x) => I.unobserve(x));
921
+ return h.current.forEach((x) => C.observe(x)), () => {
922
+ h.current.forEach((x) => C.unobserve(x));
923
923
  };
924
924
  }, [l.length]), /* @__PURE__ */ N(
925
925
  Pt,
926
926
  {
927
- defaultValue: r,
927
+ defaultValue: r ?? l[0].props.tabId,
928
928
  onValueChange: z,
929
929
  "data-testid": c,
930
930
  className: U,
@@ -939,16 +939,16 @@ const le = /* @__PURE__ */ Dt(qt), Lt = {
939
939
  },
940
940
  className: q(`${w}__list`),
941
941
  children: [
942
- E.map(l, (p, I) => {
942
+ E.map(l, (p, C) => {
943
943
  const { name: x, tabId: de, "data-testid": F } = p.props;
944
944
  return /* @__PURE__ */ N(
945
945
  zt,
946
946
  {
947
947
  "data-testid": k("header", F),
948
- index: I,
948
+ index: C,
949
949
  tabId: de,
950
950
  ref: (D) => {
951
- D && (h.current[I] = D);
951
+ D && (h.current[C] = D);
952
952
  },
953
953
  onFocus: (D) => {
954
954
  Yt(D.target, $.current);