@oliasoft-open-source/react-ui-library 3.3.6 → 3.3.7

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.
Files changed (2) hide show
  1. package/dist/index.js +29 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12798,6 +12798,7 @@ const styles$z = {
12798
12798
  const DrawerTabs = ({
12799
12799
  tabs: tabs2,
12800
12800
  activeTab,
12801
+ open,
12801
12802
  background,
12802
12803
  handleTabClick,
12803
12804
  width,
@@ -12807,7 +12808,7 @@ const DrawerTabs = ({
12807
12808
  children: [/* @__PURE__ */ jsx("div", {
12808
12809
  className: styles$z.tabs,
12809
12810
  children: tabs2.map((tab2, index2) => /* @__PURE__ */ jsx("div", {
12810
- className: cx(styles$z.tab, activeTab === index2 && styles$z.active),
12811
+ className: cx(styles$z.tab, activeTab === index2 && open ? styles$z.active : ""),
12811
12812
  style: {
12812
12813
  background
12813
12814
  },
@@ -12823,7 +12824,7 @@ const DrawerTabs = ({
12823
12824
  },
12824
12825
  className: styles$z.tabsContent,
12825
12826
  "data-testid": testId && `${testId}-content-${index2}`,
12826
- children: active2 && tab2.content
12827
+ children: active2 && open && tab2.content
12827
12828
  }, index2);
12828
12829
  })]
12829
12830
  });
@@ -14871,6 +14872,8 @@ reactResizable.exports = function() {
14871
14872
  };
14872
14873
  var Resizable = reactResizable.exports.Resizable = Resizable$2.default;
14873
14874
  reactResizable.exports.ResizableBox = ResizableBox$1.default;
14875
+ const TABS_WIDTH = 37;
14876
+ const MIN_OPEN_WIDTH = 240;
14874
14877
  const ResizeHandle = React__default.forwardRef((props, ref2) => {
14875
14878
  const {
14876
14879
  handleAxis,
@@ -14888,32 +14891,38 @@ const DrawerResizeWrapper = ({
14888
14891
  width,
14889
14892
  right: right2,
14890
14893
  onResize,
14891
- open
14894
+ setOpen
14892
14895
  }) => {
14893
14896
  const [isResizing2, setIsResizing] = useState(false);
14894
- const MINIMUM_OPEN_WIDTH = 100;
14895
14897
  const MAXIMUM_OPEN_WIDTH = window.innerWidth / 2;
14896
14898
  const handleResize = (event, {
14897
14899
  node,
14898
14900
  size: size2,
14899
14901
  handle
14900
14902
  }) => {
14901
- if (open) {
14902
- onResize(size2.width);
14903
- }
14903
+ onResize(size2.width);
14904
14904
  };
14905
14905
  return onResize ? /* @__PURE__ */ jsx(Resizable, {
14906
14906
  width,
14907
14907
  height: 100,
14908
- minConstraints: [MINIMUM_OPEN_WIDTH, null],
14908
+ minConstraints: [TABS_WIDTH, null],
14909
14909
  maxConstraints: [MAXIMUM_OPEN_WIDTH, null],
14910
14910
  onResize: handleResize,
14911
- handle: open ? /* @__PURE__ */ jsx(ResizeHandle, {}) : null,
14911
+ handle: /* @__PURE__ */ jsx(ResizeHandle, {}),
14912
14912
  resizeHandles: right2 ? ["w"] : ["e"],
14913
14913
  axis: "x",
14914
14914
  className: isResizing2 ? styles$z.isResizing : "",
14915
- onResizeStart: () => setIsResizing(true),
14916
- onResizeStop: () => setIsResizing(false),
14915
+ onResizeStart: () => {
14916
+ setOpen(true);
14917
+ onResize(width);
14918
+ setIsResizing(true);
14919
+ },
14920
+ onResizeStop: () => {
14921
+ setIsResizing(false);
14922
+ if (width < TABS_WIDTH + 50) {
14923
+ setOpen(false);
14924
+ }
14925
+ },
14917
14926
  children
14918
14927
  }) : /* @__PURE__ */ jsx(Fragment, {
14919
14928
  children
@@ -14957,18 +14966,19 @@ const Drawer = ({
14957
14966
  const isStandardButton = button2 === true;
14958
14967
  const isCustomButton = !isStandardButton && isValidElement(button2);
14959
14968
  const [open, setOpen] = setOpenProp ? [openProp, setOpenProp] : isStandardButton || tabs2 ? useState(openProp) : [openProp, null];
14960
- const [activeTab, setActiveTab] = setActiveTabProp ? [activeTabProp, setActiveTabProp] : useState(open ? defaultTabIndex : null);
14969
+ const [activeTab, setActiveTab] = setActiveTabProp ? [activeTabProp, setActiveTabProp] : useState(defaultTabIndex);
14961
14970
  const openWidth = Array.isArray(width) ? width[activeTab] : width;
14962
- const TABS_WIDTH = 37;
14963
14971
  const currentWidth = open ? openWidth : tabs2 ? TABS_WIDTH : closedWidth;
14964
14972
  const handleTabClick = (index2) => {
14965
- if (activeTab === index2) {
14966
- setActiveTab(null);
14973
+ if (activeTab === index2 && open) {
14967
14974
  setOpen(false);
14968
- } else {
14969
- setActiveTab(index2);
14975
+ } else if (!open) {
14970
14976
  setOpen(true);
14977
+ if (onResize && width < MIN_OPEN_WIDTH) {
14978
+ onResize(MIN_OPEN_WIDTH);
14979
+ }
14971
14980
  }
14981
+ setActiveTab(index2);
14972
14982
  if (getActiveTab) {
14973
14983
  getActiveTab(tabs2[index2]);
14974
14984
  }
@@ -14976,7 +14986,7 @@ const Drawer = ({
14976
14986
  return /* @__PURE__ */ jsx(DrawerResizeWrapper, {
14977
14987
  width: currentWidth,
14978
14988
  onResize,
14979
- open,
14989
+ setOpen,
14980
14990
  right: right2,
14981
14991
  children: /* @__PURE__ */ jsxs("div", {
14982
14992
  className: cx(styles$z.drawer, shadow2 ? styles$z.shadow : "", fixed2 ? styles$z.fixed : styles$z.inline, right2 ? styles$z.right : styles$z.left),
@@ -14994,6 +15004,7 @@ const Drawer = ({
14994
15004
  width: openWidth,
14995
15005
  testId,
14996
15006
  tabs: tabs2,
15007
+ open,
14997
15008
  activeTab,
14998
15009
  background,
14999
15010
  handleTabClick
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "3.3.6",
3
+ "version": "3.3.7",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",