optimized-react-component-library-xyz123 2.8.5 → 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
@@ -3803,7 +3803,7 @@ var Navigation = ({
3803
3803
  menuLinks = [],
3804
3804
  openButtonRef = null,
3805
3805
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props }),
3806
- setKeyboardNavigationClose
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,8 +3811,10 @@ var Navigation = ({
3811
3811
  const handleSubMenu = (label) => {
3812
3812
  setOpenSubMenu(openSubMenu === label ? null : label);
3813
3813
  };
3814
- const handleCloseButton = () => {
3815
- setIsMenyOpen && setIsMenyOpen(false);
3814
+ const handleMenuClick = (typeOfInteraction) => {
3815
+ var _a, _b;
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());
3816
3818
  };
3817
3819
  (0, import_react16.useEffect)(() => {
3818
3820
  if (!isOpen || !navRef.current) return;
@@ -3875,7 +3877,7 @@ var Navigation = ({
3875
3877
  "button",
3876
3878
  {
3877
3879
  className: "pts-navigation-close-button",
3878
- onClick: handleCloseButton,
3880
+ onClick: () => handleMenuClick("close"),
3879
3881
  type: "button",
3880
3882
  children: [
3881
3883
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {}) }),
@@ -3894,7 +3896,7 @@ var Navigation = ({
3894
3896
  LinkComponent,
3895
3897
  {
3896
3898
  onClick: () => {
3897
- handleCloseButton();
3899
+ handleMenuClick("link");
3898
3900
  },
3899
3901
  href,
3900
3902
  children: label[activatedLanguage]
@@ -3926,7 +3928,7 @@ var Navigation = ({
3926
3928
  LinkComponent,
3927
3929
  {
3928
3930
  onClick: () => {
3929
- handleCloseButton();
3931
+ handleMenuClick("link");
3930
3932
  },
3931
3933
  href: href2,
3932
3934
  children: label2[activatedLanguage]
@@ -4036,12 +4038,10 @@ var NavigationHeader = ({
4036
4038
  };
4037
4039
  const [instruction, setInstruction] = (0, import_react18.useState)("");
4038
4040
  (0, import_react18.useEffect)(() => {
4039
- if (!hasBeenOpen) {
4041
+ if (!isMenuOpen)
4040
4042
  return;
4041
- }
4042
- setInstruction(
4043
- isMenuOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
4044
- );
4043
+ const message = activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened";
4044
+ setInstruction(message);
4045
4045
  }, [isMenuOpen, activatedLanguage]);
4046
4046
  const getMenuLabel = () => {
4047
4047
  const labels = {
@@ -4130,8 +4130,7 @@ var NavigationHeader = ({
4130
4130
  isOpen: isMenuOpen,
4131
4131
  openButtonRef: menuButtonFocusRef,
4132
4132
  linkComponent: LinkComponent,
4133
- setKeyboardNavigationClose: () => {
4134
- }
4133
+ navigationCloseFocusId
4135
4134
  }
4136
4135
  )
4137
4136
  ] }),