@doist/reactist 27.5.0 → 28.0.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.
@@ -2776,9 +2776,9 @@ function ModalActions(_ref5) {
2776
2776
  }, children));
2777
2777
  }
2778
2778
 
2779
- var modules_40c67f5b = {"tab":"faa5b46e","track":"_93de0ded","tab-neutral":"_82a91995","tab-themed":"f150e9da","track-neutral":"_10f229b4","track-themed":"_54f03992"};
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"};
2780
2780
 
2781
- const _excluded$5 = ["children", "space"],
2781
+ const _excluded$5 = ["children", "space", "width", "align", "exceptionallySetClassName"],
2782
2782
  _excluded2$1 = ["children", "id", "renderMode"];
2783
2783
  const TabsContext = /*#__PURE__*/React__namespace.createContext(null);
2784
2784
  /**
@@ -2819,6 +2819,7 @@ function Tabs({
2819
2819
  const Tab = /*#__PURE__*/React__namespace.forwardRef(function Tab({
2820
2820
  children,
2821
2821
  id,
2822
+ disabled,
2822
2823
  exceptionallySetClassName,
2823
2824
  render,
2824
2825
  onClick
@@ -2833,6 +2834,7 @@ const Tab = /*#__PURE__*/React__namespace.forwardRef(function Tab({
2833
2834
  return /*#__PURE__*/React__namespace.createElement(react.Tab, {
2834
2835
  id: id,
2835
2836
  ref: ref,
2837
+ disabled: disabled,
2836
2838
  store: tabStore,
2837
2839
  render: render,
2838
2840
  className: className,
@@ -2846,11 +2848,42 @@ const Tab = /*#__PURE__*/React__namespace.forwardRef(function Tab({
2846
2848
  function TabList(_ref2) {
2847
2849
  let {
2848
2850
  children,
2849
- space
2851
+ space,
2852
+ width = 'maxContent',
2853
+ align = 'start',
2854
+ exceptionallySetClassName
2850
2855
  } = _ref2,
2851
2856
  props = _objectWithoutProperties(_ref2, _excluded$5);
2852
2857
 
2853
2858
  const tabContextValue = React__namespace.useContext(TabsContext);
2859
+ const [selectedTabElement, setSelectedTabElement] = React__namespace.useState(null);
2860
+ const [selectedTabStyle, setSelectedTabStyle] = React__namespace.useState({});
2861
+ const tabListRef = React__namespace.useRef(null);
2862
+ 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
+ }
2868
+
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
+ }
2880
+
2881
+ updateSelectedTabStyle();
2882
+ window.addEventListener('resize', updateSelectedTabStyle);
2883
+ return function cleanupEventListener() {
2884
+ window.removeEventListener('resize', updateSelectedTabStyle);
2885
+ };
2886
+ }, [selectedId]);
2854
2887
 
2855
2888
  if (!tabContextValue) {
2856
2889
  return null;
@@ -2860,20 +2893,35 @@ function TabList(_ref2) {
2860
2893
  tabStore,
2861
2894
  variant
2862
2895
  } = tabContextValue;
2896
+ const justifyContentAlignMap = {
2897
+ start: 'flexStart',
2898
+ end: 'flexEnd',
2899
+ center: 'center'
2900
+ };
2863
2901
  return (
2864
2902
  /*#__PURE__*/
2865
- // The extra <div> prevents <Inline>'s negative margins from collapsing when used in a flex container
2866
- // which will render the track with the wrong height
2867
- React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement(react.TabList, _objectSpread2({
2903
+ // This extra <Box> not only provides alignment for the tabs, but also prevents <Inline>'s
2904
+ // negative margins from collapsing when used in a flex container which will render the
2905
+ // track with the wrong height
2906
+ React__namespace.createElement(Box$1, {
2907
+ display: "flex",
2908
+ justifyContent: width === 'full' ? 'center' : justifyContentAlignMap[align]
2909
+ }, /*#__PURE__*/React__namespace.createElement(react.TabList, _objectSpread2({
2868
2910
  store: tabStore,
2869
2911
  render: /*#__PURE__*/React__namespace.createElement(Box$1, {
2870
2912
  position: "relative",
2871
- width: "maxContent"
2872
- })
2913
+ width: width,
2914
+ className: exceptionallySetClassName
2915
+ }),
2916
+ ref: tabListRef
2873
2917
  }, props), /*#__PURE__*/React__namespace.createElement(Box$1, {
2874
2918
  className: [modules_40c67f5b.track, modules_40c67f5b["track-" + variant]]
2875
- }), /*#__PURE__*/React__namespace.createElement(Inline, {
2876
- space: space
2919
+ }), selectedTabElement ? /*#__PURE__*/React__namespace.createElement(Box$1, {
2920
+ className: [modules_40c67f5b.selected, modules_40c67f5b["selected-" + variant]],
2921
+ style: selectedTabStyle
2922
+ }) : null, /*#__PURE__*/React__namespace.createElement(Inline, {
2923
+ space: space,
2924
+ exceptionallySetClassName: classNames__default["default"](width === 'full' ? modules_40c67f5b.fullTabList : null)
2877
2925
  }, children)))
2878
2926
  );
2879
2927
  }