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

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.d.mts CHANGED
@@ -847,7 +847,7 @@ interface NavigationHeaderProps {
847
847
  linkComponent?: ElementType;
848
848
  noLogoLink?: boolean;
849
849
  navigationCloseFocusId?: string;
850
- activeSubMenu?: string | null;
850
+ activePath?: string | null;
851
851
  }
852
852
 
853
853
  declare const NavigationHeader: FC<NavigationHeaderProps>;
@@ -860,7 +860,7 @@ interface NavigationProps {
860
860
  openButtonRef: RefObject<HTMLButtonElement | null>;
861
861
  linkComponent?: ElementType;
862
862
  navigationCloseFocusId?: string;
863
- activeSubMenu?: string | null;
863
+ activePath?: string | null;
864
864
  }
865
865
  type Locale = 'sv' | 'en';
866
866
  type Label = Record<Locale, string>;
package/dist/index.d.ts CHANGED
@@ -847,7 +847,7 @@ interface NavigationHeaderProps {
847
847
  linkComponent?: ElementType;
848
848
  noLogoLink?: boolean;
849
849
  navigationCloseFocusId?: string;
850
- activeSubMenu?: string | null;
850
+ activePath?: string | null;
851
851
  }
852
852
 
853
853
  declare const NavigationHeader: FC<NavigationHeaderProps>;
@@ -860,7 +860,7 @@ interface NavigationProps {
860
860
  openButtonRef: RefObject<HTMLButtonElement | null>;
861
861
  linkComponent?: ElementType;
862
862
  navigationCloseFocusId?: string;
863
- activeSubMenu?: string | null;
863
+ activePath?: string | null;
864
864
  }
865
865
  type Locale = 'sv' | 'en';
866
866
  type Label = Record<Locale, string>;
package/dist/index.js CHANGED
@@ -3967,7 +3967,7 @@ var Navigation = ({
3967
3967
  openButtonRef = null,
3968
3968
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("a", { ...props }),
3969
3969
  navigationCloseFocusId,
3970
- activeSubMenu = null
3970
+ activePath = null
3971
3971
  }) => {
3972
3972
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3973
3973
  const navRef = (0, import_react16.useRef)(null);
@@ -3981,12 +3981,24 @@ var Navigation = ({
3981
3981
  setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
3982
3982
  typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
3983
3983
  };
3984
+ (0, import_react16.useEffect)(() => {
3985
+ var _a, _b;
3986
+ if (!isOpen) {
3987
+ setOpenSubMenu(null);
3988
+ return;
3989
+ }
3990
+ const defaultOpenSubMenu = activePath == null ? null : (_b = (_a = menuLinks.find(
3991
+ (link) => {
3992
+ var _a2;
3993
+ return (_a2 = link.children) == null ? void 0 : _a2.some((child) => child.href.includes(activePath));
3994
+ }
3995
+ )) == null ? void 0 : _a.label[activatedLanguage]) != null ? _b : null;
3996
+ setOpenSubMenu(defaultOpenSubMenu);
3997
+ }, [isOpen, activePath, menuLinks, activatedLanguage]);
3984
3998
  (0, import_react16.useEffect)(() => {
3985
3999
  if (!isOpen || !navRef.current) {
3986
- setOpenSubMenu(activeSubMenu);
3987
4000
  return;
3988
4001
  }
3989
- setOpenSubMenu(activeSubMenu);
3990
4002
  const nav = navRef.current;
3991
4003
  const focusableSelectors = 'a, button, input, textarea, select, [tabindex]:not([tabindex="-1"])';
3992
4004
  const focusableElements = nav.querySelectorAll(focusableSelectors);
@@ -4046,7 +4058,6 @@ var Navigation = ({
4046
4058
  );
4047
4059
  });
4048
4060
  }, [isOpen, activatedLanguage]);
4049
- console.log(openSubMenu);
4050
4061
  return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
4051
4062
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
4052
4063
  /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
@@ -4193,7 +4204,7 @@ var NavigationHeader = ({
4193
4204
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("a", { ...props }),
4194
4205
  noLogoLink = false,
4195
4206
  navigationCloseFocusId,
4196
- activeSubMenu = null
4207
+ activePath = null
4197
4208
  }) => {
4198
4209
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
4199
4210
  const hasHeadline = headline && headline.length > 0;
@@ -4299,7 +4310,7 @@ var NavigationHeader = ({
4299
4310
  openButtonRef: menuButtonFocusRef,
4300
4311
  linkComponent: LinkComponent,
4301
4312
  navigationCloseFocusId,
4302
- activeSubMenu
4313
+ activePath
4303
4314
  }
4304
4315
  ) }),
4305
4316
  isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(