optimized-react-component-library-xyz123 2.10.2 → 2.10.3

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/index.mjs CHANGED
@@ -3882,7 +3882,7 @@ var Navigation = ({
3882
3882
  openButtonRef = null,
3883
3883
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx30("a", { ...props }),
3884
3884
  navigationCloseFocusId,
3885
- activeSubMenu = null
3885
+ activePath = null
3886
3886
  }) => {
3887
3887
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3888
3888
  const navRef = useRef3(null);
@@ -3897,11 +3897,18 @@ var Navigation = ({
3897
3897
  typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
3898
3898
  };
3899
3899
  useEffect13(() => {
3900
+ var _a, _b;
3900
3901
  if (!isOpen || !navRef.current) {
3901
- setOpenSubMenu(activeSubMenu);
3902
+ setOpenSubMenu(null);
3902
3903
  return;
3903
3904
  }
3904
- setOpenSubMenu(activeSubMenu);
3905
+ const defaultOpenSubMenu = activePath !== null ? (_b = (_a = menuLinks.find(
3906
+ (link) => {
3907
+ var _a2;
3908
+ return (_a2 = link.children) == null ? void 0 : _a2.some((child) => child.href.indexOf(activePath) !== -1);
3909
+ }
3910
+ )) == null ? void 0 : _a.label[activatedLanguage]) != null ? _b : null : null;
3911
+ setOpenSubMenu(defaultOpenSubMenu);
3905
3912
  const nav = navRef.current;
3906
3913
  const focusableSelectors = 'a, button, input, textarea, select, [tabindex]:not([tabindex="-1"])';
3907
3914
  const focusableElements = nav.querySelectorAll(focusableSelectors);
@@ -3912,10 +3919,10 @@ var Navigation = ({
3912
3919
  firstElement.focus();
3913
3920
  });
3914
3921
  const handleKeyDown = (event) => {
3915
- var _a;
3922
+ var _a2;
3916
3923
  if (event.key === "Escape") {
3917
3924
  setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
3918
- (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus();
3925
+ (_a2 = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a2.focus();
3919
3926
  return;
3920
3927
  }
3921
3928
  if (event.key !== "Tab") return;
@@ -3961,7 +3968,7 @@ var Navigation = ({
3961
3968
  );
3962
3969
  });
3963
3970
  }, [isOpen, activatedLanguage]);
3964
- console.log(openSubMenu);
3971
+ console.log(openSubMenu, "tt");
3965
3972
  return /* @__PURE__ */ jsxs26(Fragment20, { children: [
3966
3973
  /* @__PURE__ */ jsx30("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
3967
3974
  /* @__PURE__ */ jsxs26(
@@ -4108,7 +4115,7 @@ var NavigationHeader = ({
4108
4115
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx33("a", { ...props }),
4109
4116
  noLogoLink = false,
4110
4117
  navigationCloseFocusId,
4111
- activeSubMenu = null
4118
+ activePath = null
4112
4119
  }) => {
4113
4120
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
4114
4121
  const hasHeadline = headline && headline.length > 0;
@@ -4214,7 +4221,7 @@ var NavigationHeader = ({
4214
4221
  openButtonRef: menuButtonFocusRef,
4215
4222
  linkComponent: LinkComponent,
4216
4223
  navigationCloseFocusId,
4217
- activeSubMenu
4224
+ activePath
4218
4225
  }
4219
4226
  ) }),
4220
4227
  isMenuOpen && /* @__PURE__ */ jsx33(