@natoora-libs/core 0.2.42 → 0.2.43

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.
@@ -10866,6 +10866,8 @@ var useStyles50 = (0, import_mui56.makeStyles)()((theme) => ({
10866
10866
  }
10867
10867
  }
10868
10868
  }));
10869
+ var CENTER_MIN_WIDTH = 320;
10870
+ var SAFETY_BUFFER = 24;
10869
10871
  var TheToolbar = ({
10870
10872
  imageLogoDarkSmall,
10871
10873
  imageLogoLightSmall,
@@ -10877,9 +10879,48 @@ var TheToolbar = ({
10877
10879
  isAuthenticated = true
10878
10880
  }) => {
10879
10881
  const { classes } = useStyles50();
10882
+ const theme = (0, import_material88.useTheme)();
10883
+ const belowXl = (0, import_material88.useMediaQuery)(theme.breakpoints.down("xl"));
10884
+ const toolbarRef = (0, import_react55.useRef)(null);
10885
+ const leftSectionMeasureRef = (0, import_react55.useRef)(null);
10886
+ const rightSectionMeasureRef = (0, import_react55.useRef)(null);
10887
+ const logoRef = (0, import_react55.useRef)(null);
10888
+ const rightSectionRef = (0, import_react55.useRef)(null);
10889
+ const menuButtonRef = (0, import_react55.useRef)(null);
10890
+ const [hideLeftSection, setHideLeftSection] = (0, import_react55.useState)(false);
10891
+ const [hideRightSection, setHideRightSection] = (0, import_react55.useState)(false);
10892
+ (0, import_react55.useLayoutEffect)(() => {
10893
+ if (belowXl) {
10894
+ setHideLeftSection(true);
10895
+ }
10896
+ const toolbar = toolbarRef.current;
10897
+ const leftMeasure = leftSectionMeasureRef.current;
10898
+ const rightMeasure = rightSectionMeasureRef.current;
10899
+ if (!toolbar) return void 0;
10900
+ const update = () => {
10901
+ const toolbarWidth = toolbar.clientWidth;
10902
+ const leftWidth = leftMeasure?.scrollWidth ?? 0;
10903
+ const rightWidth = rightMeasure?.scrollWidth ?? 0;
10904
+ const logoWidth = logoRef.current?.offsetWidth ?? 0;
10905
+ const menuWidth = menuButtonRef.current?.offsetWidth ?? 0;
10906
+ const availableWithoutLeft = toolbarWidth - logoWidth - menuWidth - CENTER_MIN_WIDTH - SAFETY_BUFFER;
10907
+ const nextHideRight = rightWidth > availableWithoutLeft;
10908
+ setHideRightSection(nextHideRight);
10909
+ if (!belowXl) {
10910
+ const effectiveRightWidth = nextHideRight ? 0 : rightWidth;
10911
+ setHideLeftSection(leftWidth > availableWithoutLeft - effectiveRightWidth);
10912
+ }
10913
+ };
10914
+ update();
10915
+ const observer = new ResizeObserver(update);
10916
+ observer.observe(toolbar);
10917
+ if (leftMeasure) observer.observe(leftMeasure);
10918
+ if (rightMeasure) observer.observe(rightMeasure);
10919
+ return () => observer.disconnect();
10920
+ }, [belowXl, leftSection, rightSection]);
10880
10921
  return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_material88.Box, { children: [
10881
- /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_material88.AppBar, { children: /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_material88.Toolbar, { className: classes.topBar, children: [
10882
- isAuthenticated ? /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10922
+ /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_material88.AppBar, { children: /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_material88.Toolbar, { className: classes.topBar, ref: toolbarRef, children: [
10923
+ isAuthenticated ? /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_material88.Box, { ref: menuButtonRef, sx: { flexShrink: 0, display: "flex" }, children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10883
10924
  RoundButton_default,
10884
10925
  {
10885
10926
  className: classes.menuButton,
@@ -10887,21 +10928,31 @@ var TheToolbar = ({
10887
10928
  noStrokes: true,
10888
10929
  onClick: handleOpen
10889
10930
  }
10890
- ) : null,
10891
- /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_material88.Box, { sx: { display: { xs: "none", lg: "block" }, flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10892
- CompanyLogo_default,
10931
+ ) }) : null,
10932
+ /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10933
+ import_material88.Box,
10893
10934
  {
10894
- size: "small",
10895
- color: "light",
10896
- imageLogoDarkSmall,
10897
- imageLogoLightSmall
10935
+ ref: logoRef,
10936
+ sx: { display: { xs: "none", lg: "block" }, flexShrink: 0 },
10937
+ children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10938
+ CompanyLogo_default,
10939
+ {
10940
+ size: "small",
10941
+ color: "light",
10942
+ imageLogoDarkSmall,
10943
+ imageLogoLightSmall
10944
+ }
10945
+ )
10898
10946
  }
10899
- ) }),
10947
+ ),
10900
10948
  /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10901
10949
  import_material88.Box,
10902
10950
  {
10903
10951
  ml: { xs: 0, lg: 2 },
10904
- sx: { display: { xs: "none", xl: "block" }, flexShrink: 0 },
10952
+ sx: {
10953
+ display: hideLeftSection ? "none" : "block",
10954
+ flexShrink: 0
10955
+ },
10905
10956
  children: leftSection
10906
10957
  }
10907
10958
  ),
@@ -10917,8 +10968,49 @@ var TheToolbar = ({
10917
10968
  children: centerSection
10918
10969
  }
10919
10970
  ) : /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_material88.Box, { sx: { flexGrow: 1 } }),
10920
- /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_material88.Box, { sx: { flexShrink: 0 }, children: rightSection })
10971
+ /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10972
+ import_material88.Box,
10973
+ {
10974
+ ref: rightSectionRef,
10975
+ sx: { flexShrink: 0, display: hideRightSection ? "none" : "block" },
10976
+ children: rightSection
10977
+ }
10978
+ )
10921
10979
  ] }) }),
10980
+ /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10981
+ import_material88.Box,
10982
+ {
10983
+ ref: leftSectionMeasureRef,
10984
+ "aria-hidden": true,
10985
+ sx: {
10986
+ position: "fixed",
10987
+ top: 0,
10988
+ left: 0,
10989
+ visibility: "hidden",
10990
+ pointerEvents: "none",
10991
+ whiteSpace: "nowrap",
10992
+ display: "inline-flex"
10993
+ },
10994
+ children: leftSection
10995
+ }
10996
+ ),
10997
+ /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(
10998
+ import_material88.Box,
10999
+ {
11000
+ ref: rightSectionMeasureRef,
11001
+ "aria-hidden": true,
11002
+ sx: {
11003
+ position: "fixed",
11004
+ top: 0,
11005
+ left: 0,
11006
+ visibility: "hidden",
11007
+ pointerEvents: "none",
11008
+ whiteSpace: "nowrap",
11009
+ display: "inline-flex"
11010
+ },
11011
+ children: rightSection
11012
+ }
11013
+ ),
10922
11014
  LeftDrawer
10923
11015
  ] });
10924
11016
  };