optimized-react-component-library-xyz123 2.8.6 → 2.8.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.
package/dist/index.d.mts CHANGED
@@ -849,7 +849,7 @@ interface NavigationProps {
849
849
  isOpen: boolean;
850
850
  openButtonRef: RefObject<HTMLButtonElement | null>;
851
851
  linkComponent?: ElementType;
852
- setKeyboardNavigationClose?: () => void;
852
+ navigationCloseFocusId?: string;
853
853
  }
854
854
  type Locale = 'sv' | 'en';
855
855
  type Label = Record<Locale, string>;
package/dist/index.d.ts CHANGED
@@ -849,7 +849,7 @@ interface NavigationProps {
849
849
  isOpen: boolean;
850
850
  openButtonRef: RefObject<HTMLButtonElement | null>;
851
851
  linkComponent?: ElementType;
852
- setKeyboardNavigationClose?: () => void;
852
+ navigationCloseFocusId?: string;
853
853
  }
854
854
  type Locale = 'sv' | 'en';
855
855
  type Label = Record<Locale, string>;
package/dist/index.js CHANGED
@@ -3802,8 +3802,8 @@ var Navigation = ({
3802
3802
  activatedLanguage = "sv",
3803
3803
  menuLinks = [],
3804
3804
  openButtonRef = null,
3805
- linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props })
3806
- //setKeyboardNavigationClose,
3805
+ linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props }),
3806
+ navigationCloseFocusId
3807
3807
  }) => {
3808
3808
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3809
3809
  const navRef = (0, import_react16.useRef)(null);
@@ -3811,10 +3811,10 @@ var Navigation = ({
3811
3811
  const handleSubMenu = (label) => {
3812
3812
  setOpenSubMenu(openSubMenu === label ? null : label);
3813
3813
  };
3814
- const handleCloseButton = (type) => {
3814
+ const handleMenuClick = (typeOfInteraction) => {
3815
3815
  var _a, _b;
3816
- setIsMenyOpen && setIsMenyOpen(false);
3817
- type === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : (_b = document.getElementById("page-start")) == null ? void 0 : _b.focus();
3816
+ setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
3817
+ typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
3818
3818
  };
3819
3819
  (0, import_react16.useEffect)(() => {
3820
3820
  if (!isOpen || !navRef.current) return;
@@ -3877,7 +3877,7 @@ var Navigation = ({
3877
3877
  "button",
3878
3878
  {
3879
3879
  className: "pts-navigation-close-button",
3880
- onClick: () => handleCloseButton("close"),
3880
+ onClick: () => handleMenuClick("close"),
3881
3881
  type: "button",
3882
3882
  children: [
3883
3883
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {}) }),
@@ -3896,7 +3896,7 @@ var Navigation = ({
3896
3896
  LinkComponent,
3897
3897
  {
3898
3898
  onClick: () => {
3899
- handleCloseButton("link");
3899
+ handleMenuClick("link");
3900
3900
  },
3901
3901
  href,
3902
3902
  children: label[activatedLanguage]
@@ -3928,7 +3928,7 @@ var Navigation = ({
3928
3928
  LinkComponent,
3929
3929
  {
3930
3930
  onClick: () => {
3931
- handleCloseButton("link");
3931
+ handleMenuClick("link");
3932
3932
  },
3933
3933
  href: href2,
3934
3934
  children: label2[activatedLanguage]
@@ -4038,12 +4038,10 @@ var NavigationHeader = ({
4038
4038
  };
4039
4039
  const [instruction, setInstruction] = (0, import_react18.useState)("");
4040
4040
  (0, import_react18.useEffect)(() => {
4041
- if (!hasBeenOpen) {
4041
+ if (!isMenuOpen)
4042
4042
  return;
4043
- }
4044
- setInstruction(
4045
- isMenuOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
4046
- );
4043
+ const message = activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened";
4044
+ setInstruction(message);
4047
4045
  }, [isMenuOpen, activatedLanguage]);
4048
4046
  const getMenuLabel = () => {
4049
4047
  const labels = {
@@ -4132,8 +4130,7 @@ var NavigationHeader = ({
4132
4130
  isOpen: isMenuOpen,
4133
4131
  openButtonRef: menuButtonFocusRef,
4134
4132
  linkComponent: LinkComponent,
4135
- setKeyboardNavigationClose: () => {
4136
- }
4133
+ navigationCloseFocusId
4137
4134
  }
4138
4135
  )
4139
4136
  ] }),