optimized-react-component-library-xyz123 2.8.6 → 2.8.8

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
@@ -3708,7 +3708,7 @@ var Header = ({
3708
3708
  var HeaderStandard_default = Header;
3709
3709
 
3710
3710
  // src/components/layout/NavigationHeaderStandard/NavigationHeaderStandard.tsx
3711
- import { useEffect as useEffect14, useRef as useRef4, useState as useState11 } from "react";
3711
+ import { useRef as useRef4, useState as useState11 } from "react";
3712
3712
 
3713
3713
  // src/components/layout/NavigationStandard/NavigationStandard.tsx
3714
3714
  import { useEffect as useEffect13, useState as useState9, useRef as useRef3 } from "react";
@@ -3719,8 +3719,8 @@ var Navigation = ({
3719
3719
  activatedLanguage = "sv",
3720
3720
  menuLinks = [],
3721
3721
  openButtonRef = null,
3722
- linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx28("a", { ...props })
3723
- //setKeyboardNavigationClose,
3722
+ linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx28("a", { ...props }),
3723
+ navigationCloseFocusId
3724
3724
  }) => {
3725
3725
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3726
3726
  const navRef = useRef3(null);
@@ -3728,10 +3728,10 @@ var Navigation = ({
3728
3728
  const handleSubMenu = (label) => {
3729
3729
  setOpenSubMenu(openSubMenu === label ? null : label);
3730
3730
  };
3731
- const handleCloseButton = (type) => {
3731
+ const handleMenuClick = (typeOfInteraction) => {
3732
3732
  var _a, _b;
3733
- setIsMenyOpen && setIsMenyOpen(false);
3734
- type === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : (_b = document.getElementById("page-start")) == null ? void 0 : _b.focus();
3733
+ setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
3734
+ typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
3735
3735
  };
3736
3736
  useEffect13(() => {
3737
3737
  if (!isOpen || !navRef.current) return;
@@ -3789,12 +3789,13 @@ var Navigation = ({
3789
3789
  "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3790
3790
  className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3791
3791
  inert: !isOpen,
3792
+ "aria-expanded": isOpen,
3792
3793
  children: [
3793
3794
  /* @__PURE__ */ jsx28("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ jsxs24(
3794
3795
  "button",
3795
3796
  {
3796
3797
  className: "pts-navigation-close-button",
3797
- onClick: () => handleCloseButton("close"),
3798
+ onClick: () => handleMenuClick("close"),
3798
3799
  type: "button",
3799
3800
  children: [
3800
3801
  /* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx28(CloseIcon, {}) }),
@@ -3812,9 +3813,7 @@ var Navigation = ({
3812
3813
  /* @__PURE__ */ jsx28("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx28("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx28(
3813
3814
  LinkComponent,
3814
3815
  {
3815
- onClick: () => {
3816
- handleCloseButton("link");
3817
- },
3816
+ onClick: () => handleMenuClick("link"),
3818
3817
  href,
3819
3818
  children: label[activatedLanguage]
3820
3819
  }
@@ -3844,9 +3843,7 @@ var Navigation = ({
3844
3843
  children: /* @__PURE__ */ jsx28("ul", { className: "pts-sub-navigation-list", lang: activatedLanguage, children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ jsx28("li", { className: "pts-sub-navigation-item", lang: activatedLanguage, children: /* @__PURE__ */ jsx28(
3845
3844
  LinkComponent,
3846
3845
  {
3847
- onClick: () => {
3848
- handleCloseButton("link");
3849
- },
3846
+ onClick: () => handleMenuClick("link"),
3850
3847
  href: href2,
3851
3848
  children: label2[activatedLanguage]
3852
3849
  }
@@ -3942,26 +3939,10 @@ var NavigationHeader = ({
3942
3939
  else return "Svenska";
3943
3940
  };
3944
3941
  const [isMenuOpen, setIsMenuOpen] = useState11(false);
3945
- const [hasBeenOpen, setHasBeenOpen] = useState11(false);
3946
3942
  const menuButtonFocusRef = useRef4(null);
3947
3943
  const handleMenuClick = () => {
3948
- setIsMenuOpen((prev) => {
3949
- const open = !prev;
3950
- if (open) {
3951
- setHasBeenOpen(true);
3952
- }
3953
- return open;
3954
- });
3944
+ setIsMenuOpen((prev) => !prev);
3955
3945
  };
3956
- const [instruction, setInstruction] = useState11("");
3957
- useEffect14(() => {
3958
- if (!hasBeenOpen) {
3959
- return;
3960
- }
3961
- setInstruction(
3962
- isMenuOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
3963
- );
3964
- }, [isMenuOpen, activatedLanguage]);
3965
3946
  const getMenuLabel = () => {
3966
3947
  const labels = {
3967
3948
  sv: isMenuOpen ? "St\xE4ng meny" : "Meny",
@@ -4038,22 +4019,18 @@ var NavigationHeader = ({
4038
4019
  )
4039
4020
  ] }) })
4040
4021
  ] }) }),
4041
- useNavigationMenu && /* @__PURE__ */ jsxs27(Fragment19, { children: [
4042
- /* @__PURE__ */ jsx31("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
4043
- /* @__PURE__ */ jsx31(
4044
- NavigationStandard_default,
4045
- {
4046
- activatedLanguage,
4047
- setIsMenyOpen: setIsMenuOpen,
4048
- menuLinks,
4049
- isOpen: isMenuOpen,
4050
- openButtonRef: menuButtonFocusRef,
4051
- linkComponent: LinkComponent,
4052
- setKeyboardNavigationClose: () => {
4053
- }
4054
- }
4055
- )
4056
- ] }),
4022
+ useNavigationMenu && /* @__PURE__ */ jsx31(Fragment19, { children: /* @__PURE__ */ jsx31(
4023
+ NavigationStandard_default,
4024
+ {
4025
+ activatedLanguage,
4026
+ setIsMenyOpen: setIsMenuOpen,
4027
+ menuLinks,
4028
+ isOpen: isMenuOpen,
4029
+ openButtonRef: menuButtonFocusRef,
4030
+ linkComponent: LinkComponent,
4031
+ navigationCloseFocusId
4032
+ }
4033
+ ) }),
4057
4034
  isMenuOpen && /* @__PURE__ */ jsx31(
4058
4035
  "div",
4059
4036
  {