@doist/reactist 28.0.0 → 28.1.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.
@@ -2776,7 +2776,7 @@ function ModalActions(_ref5) {
2776
2776
  }, children));
2777
2777
  }
2778
2778
 
2779
- var modules_40c67f5b = {"tab":"_9f64e89a","fullTabList":"_49fe8e5a","track":"_1f449e3a","selected":"a8ac92b1","tab-neutral":"_6c6b8a2b","tab-themed":"_0eddd76d","track-neutral":"be66f12e","track-themed":"d21ccd50","selected-neutral":"_33211e81","selected-themed":"_4d1cbd10"};
2779
+ var modules_40c67f5b = {"tab":"_33c9c271","fullTabList":"_479349aa","track":"_2862a4ba","selected":"_1161c811","tab-neutral":"_9502e79a","tab-themed":"c39f1053","track-neutral":"b3554a83","track-themed":"_511b0be0","selected-neutral":"c81dc609","selected-themed":"_87552972"};
2780
2780
 
2781
2781
  const _excluded$5 = ["children", "space", "width", "align", "exceptionallySetClassName"],
2782
2782
  _excluded2$1 = ["children", "id", "renderMode"];
@@ -2855,35 +2855,63 @@ function TabList(_ref2) {
2855
2855
  } = _ref2,
2856
2856
  props = _objectWithoutProperties(_ref2, _excluded$5);
2857
2857
 
2858
+ const tabListRef = React__namespace.useRef(null);
2859
+ const tabListPrevWidthRef = React__namespace.useRef(0);
2858
2860
  const tabContextValue = React__namespace.useContext(TabsContext);
2859
2861
  const [selectedTabElement, setSelectedTabElement] = React__namespace.useState(null);
2860
2862
  const [selectedTabStyle, setSelectedTabStyle] = React__namespace.useState({});
2861
- const tabListRef = React__namespace.useRef(null);
2862
2863
  const selectedId = tabContextValue == null ? void 0 : tabContextValue.tabStore.useState('selectedId');
2863
- React__namespace.useLayoutEffect(() => {
2864
- function updateSelectedTabStyle() {
2865
- if (!selectedId || !tabListRef.current) {
2866
- return;
2867
- }
2864
+ const updateSelectedTabPosition = React__namespace.useCallback(function updateSelectedTabPositionCallback() {
2865
+ if (!selectedId || !tabListRef.current) {
2866
+ return;
2867
+ }
2868
2868
 
2869
- const tabs = tabListRef.current.querySelectorAll('[role="tab"]');
2870
- const selectedTab = Array.from(tabs).find(tab => tab.getAttribute('id') === selectedId);
2869
+ const tabs = tabListRef.current.querySelectorAll('[role="tab"]');
2870
+ const selectedTab = Array.from(tabs).find(tab => tab.getAttribute('id') === selectedId);
2871
+
2872
+ if (selectedTab) {
2873
+ setSelectedTabElement(selectedTab);
2874
+ setSelectedTabStyle({
2875
+ left: selectedTab.offsetLeft + "px",
2876
+ width: selectedTab.offsetWidth + "px"
2877
+ });
2878
+ }
2879
+ }, [selectedId]);
2880
+ React__namespace.useEffect(function updateSelectedTabPositionOnTabChange() {
2881
+ updateSelectedTabPosition();
2882
+ }, // `selectedId` is a dependency to ensure the effect runs when the selected tab changes
2883
+ [selectedId, updateSelectedTabPosition]);
2884
+ React__namespace.useEffect(function observeTabListWidthChange() {
2885
+ let animationFrameId = null;
2886
+ const tabListObserver = new ResizeObserver(([entry]) => {
2887
+ const width = entry == null ? void 0 : entry.contentRect.width;
2888
+
2889
+ if (width && tabListPrevWidthRef.current !== width) {
2890
+ tabListPrevWidthRef.current = width;
2891
+
2892
+ if (animationFrameId !== null) {
2893
+ cancelAnimationFrame(animationFrameId);
2894
+ }
2871
2895
 
2872
- if (selectedTab) {
2873
- setSelectedTabElement(selectedTab);
2874
- setSelectedTabStyle({
2875
- left: selectedTab.offsetLeft + "px",
2876
- width: selectedTab.offsetWidth + "px"
2896
+ animationFrameId = requestAnimationFrame(() => {
2897
+ updateSelectedTabPosition();
2898
+ animationFrameId = null;
2877
2899
  });
2878
2900
  }
2901
+ });
2902
+
2903
+ if (tabListRef.current) {
2904
+ tabListObserver.observe(tabListRef.current);
2879
2905
  }
2880
2906
 
2881
- updateSelectedTabStyle();
2882
- window.addEventListener('resize', updateSelectedTabStyle);
2883
- return function cleanupEventListener() {
2884
- window.removeEventListener('resize', updateSelectedTabStyle);
2907
+ return function cleanupResizeObserver() {
2908
+ if (animationFrameId) {
2909
+ cancelAnimationFrame(animationFrameId);
2910
+ }
2911
+
2912
+ tabListObserver.disconnect();
2885
2913
  };
2886
- }, [selectedId]);
2914
+ }, [updateSelectedTabPosition]);
2887
2915
 
2888
2916
  if (!tabContextValue) {
2889
2917
  return null;