optimized-react-component-library-xyz123 2.8.4 → 2.8.5

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
@@ -3724,7 +3724,6 @@ var Navigation = ({
3724
3724
  }) => {
3725
3725
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3726
3726
  const navRef = useRef3(null);
3727
- const firstVisitRef = useRef3(true);
3728
3727
  const [openSubMenu, setOpenSubMenu] = useState9(null);
3729
3728
  const handleSubMenu = (label) => {
3730
3729
  setOpenSubMenu(openSubMenu === label ? null : label);
@@ -3740,7 +3739,9 @@ var Navigation = ({
3740
3739
  const firstElement = focusableElements[0];
3741
3740
  const lastElement = focusableElements[focusableElements.length - 1];
3742
3741
  if (!firstElement || !lastElement) return;
3743
- firstElement == null ? void 0 : firstElement.focus();
3742
+ requestAnimationFrame(() => {
3743
+ firstElement.focus();
3744
+ });
3744
3745
  const handleKeyDown = (event) => {
3745
3746
  var _a;
3746
3747
  if (event.key === "Escape") {
@@ -3778,101 +3779,85 @@ var Navigation = ({
3778
3779
  }
3779
3780
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
3780
3781
  };
3781
- const [instruction, setInstruction] = useState9("");
3782
- useEffect13(() => {
3783
- if (firstVisitRef.current) {
3784
- firstVisitRef.current = false;
3785
- return;
3786
- }
3787
- setInstruction(
3788
- isOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
3789
- );
3790
- }, [isOpen, activatedLanguage]);
3791
- const handleLinkKeyDown = (event) => {
3792
- if (event.key === "Enter") {
3793
- setKeyboardNavigationClose == null ? void 0 : setKeyboardNavigationClose();
3794
- }
3795
- };
3796
- return /* @__PURE__ */ jsxs24(Fragment18, { children: [
3797
- /* @__PURE__ */ jsx28("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
3798
- /* @__PURE__ */ jsxs24(
3799
- "nav",
3800
- {
3801
- id: "main-navigation",
3802
- ref: navRef,
3803
- "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3804
- className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3805
- inert: !isOpen,
3806
- children: [
3807
- /* @__PURE__ */ jsx28("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ jsxs24(
3808
- "button",
3809
- {
3810
- className: "pts-navigation-close-button",
3811
- onClick: handleCloseButton,
3812
- type: "button",
3813
- children: [
3814
- /* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx28(CloseIcon, {}) }),
3815
- /* @__PURE__ */ jsx28("span", { className: "pts-navigation-close-text", children: closeMenuText })
3816
- ]
3817
- }
3818
- ) }),
3819
- /* @__PURE__ */ jsx28("ul", { className: "pts-navigation-link-list", lang: activatedLanguage, children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ jsxs24(
3820
- "li",
3821
- {
3822
- className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3823
- lang: activatedLanguage,
3824
- children: [
3825
- /* @__PURE__ */ jsx28("div", { children: /* @__PURE__ */ jsxs24("div", { className: "pts-navigation-button", children: [
3826
- /* @__PURE__ */ jsx28("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx28("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx28(
3827
- LinkComponent,
3828
- {
3829
- onClick: handleCloseButton,
3830
- href,
3831
- onKeyDown: handleLinkKeyDown,
3832
- children: label[activatedLanguage]
3833
- }
3834
- ) }),
3835
- children && /* @__PURE__ */ jsx28(
3836
- "button",
3837
- {
3838
- className: `pts-navigation-link-expand-button`,
3839
- onClick: () => handleSubMenu(label[activatedLanguage]),
3840
- "aria-label": getSubMenuAriaLabel(label),
3841
- "aria-expanded": openSubMenu === label[activatedLanguage],
3842
- "aria-controls": "sub-menu-" + index,
3843
- type: "button",
3844
- id: "menu-button-" + index,
3845
- children: openSubMenu === label[activatedLanguage] ? /* @__PURE__ */ jsx28("span", { "aria-hidden": true, className: "pts-contract-icon", children: /* @__PURE__ */ jsx28(MinusIcon, {}) }) : /* @__PURE__ */ jsx28("span", { "aria-hidden": true, className: "pts-expand-icon", children: /* @__PURE__ */ jsx28(AddIcon, {}) })
3846
- }
3847
- )
3848
- ] }) }),
3782
+ return /* @__PURE__ */ jsx28(Fragment18, { children: /* @__PURE__ */ jsxs24(
3783
+ "nav",
3784
+ {
3785
+ id: "main-navigation",
3786
+ ref: navRef,
3787
+ "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3788
+ className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3789
+ inert: !isOpen,
3790
+ children: [
3791
+ /* @__PURE__ */ jsx28("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ jsxs24(
3792
+ "button",
3793
+ {
3794
+ className: "pts-navigation-close-button",
3795
+ onClick: handleCloseButton,
3796
+ type: "button",
3797
+ children: [
3798
+ /* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx28(CloseIcon, {}) }),
3799
+ /* @__PURE__ */ jsx28("span", { className: "pts-navigation-close-text", children: closeMenuText })
3800
+ ]
3801
+ }
3802
+ ) }),
3803
+ /* @__PURE__ */ jsx28("ul", { className: "pts-navigation-link-list", lang: activatedLanguage, children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ jsxs24(
3804
+ "li",
3805
+ {
3806
+ className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3807
+ lang: activatedLanguage,
3808
+ children: [
3809
+ /* @__PURE__ */ jsx28("div", { children: /* @__PURE__ */ jsxs24("div", { className: "pts-navigation-button", children: [
3810
+ /* @__PURE__ */ jsx28("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx28("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx28(
3811
+ LinkComponent,
3812
+ {
3813
+ onClick: () => {
3814
+ handleCloseButton();
3815
+ },
3816
+ href,
3817
+ children: label[activatedLanguage]
3818
+ }
3819
+ ) }),
3849
3820
  children && /* @__PURE__ */ jsx28(
3850
- "div",
3821
+ "button",
3851
3822
  {
3852
- hidden: openSubMenu !== label[activatedLanguage],
3853
- "aria-hidden": openSubMenu !== label[activatedLanguage],
3854
- className: "pts-sub-navigation-container",
3855
- id: "sub-menu-" + index,
3856
- role: "region",
3857
- 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(
3858
- LinkComponent,
3859
- {
3860
- onClick: handleCloseButton,
3861
- href: href2,
3862
- onKeyDown: handleLinkKeyDown,
3863
- children: label2[activatedLanguage]
3864
- }
3865
- ) }, "nav-child-" + index2)) })
3823
+ className: `pts-navigation-link-expand-button`,
3824
+ onClick: () => handleSubMenu(label[activatedLanguage]),
3825
+ "aria-label": getSubMenuAriaLabel(label),
3826
+ "aria-expanded": openSubMenu === label[activatedLanguage],
3827
+ "aria-controls": "sub-menu-" + index,
3828
+ type: "button",
3829
+ id: "menu-button-" + index,
3830
+ children: openSubMenu === label[activatedLanguage] ? /* @__PURE__ */ jsx28("span", { "aria-hidden": true, className: "pts-contract-icon", children: /* @__PURE__ */ jsx28(MinusIcon, {}) }) : /* @__PURE__ */ jsx28("span", { "aria-hidden": true, className: "pts-expand-icon", children: /* @__PURE__ */ jsx28(AddIcon, {}) })
3866
3831
  }
3867
3832
  )
3868
- ]
3869
- },
3870
- "nav-" + index
3871
- )) })
3872
- ]
3873
- }
3874
- )
3875
- ] });
3833
+ ] }) }),
3834
+ children && /* @__PURE__ */ jsx28(
3835
+ "div",
3836
+ {
3837
+ hidden: openSubMenu !== label[activatedLanguage],
3838
+ "aria-hidden": openSubMenu !== label[activatedLanguage],
3839
+ className: "pts-sub-navigation-container",
3840
+ id: "sub-menu-" + index,
3841
+ role: "region",
3842
+ 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(
3843
+ LinkComponent,
3844
+ {
3845
+ onClick: () => {
3846
+ handleCloseButton();
3847
+ },
3848
+ href: href2,
3849
+ children: label2[activatedLanguage]
3850
+ }
3851
+ ) }, "nav-child-" + index2)) })
3852
+ }
3853
+ )
3854
+ ]
3855
+ },
3856
+ "nav-" + index
3857
+ )) })
3858
+ ]
3859
+ }
3860
+ ) });
3876
3861
  };
3877
3862
  var NavigationStandard_default = Navigation;
3878
3863
 
@@ -3943,7 +3928,6 @@ var NavigationHeader = ({
3943
3928
  }) => {
3944
3929
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
3945
3930
  const hasHeadline = headline && headline.length > 0;
3946
- const menuButtonFocusRef = useRef4(null);
3947
3931
  const handleLanguageClick = () => {
3948
3932
  if (activatedLanguage === "sv") {
3949
3933
  SetActivatedLanguage("en");
@@ -3957,14 +3941,7 @@ var NavigationHeader = ({
3957
3941
  };
3958
3942
  const [isMenuOpen, setIsMenuOpen] = useState11(false);
3959
3943
  const [hasBeenOpen, setHasBeenOpen] = useState11(false);
3960
- const shouldRestoreFocusRef = useRef4(false);
3961
- useEffect14(() => {
3962
- var _a;
3963
- if (!isMenuOpen && navigationCloseFocusId && hasBeenOpen && shouldRestoreFocusRef.current) {
3964
- (_a = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _a.focus();
3965
- shouldRestoreFocusRef.current = false;
3966
- }
3967
- }, [isMenuOpen, navigationCloseFocusId, hasBeenOpen]);
3944
+ const menuButtonFocusRef = useRef4(null);
3968
3945
  const handleMenuClick = () => {
3969
3946
  setIsMenuOpen((prev) => {
3970
3947
  const open = !prev;
@@ -3974,6 +3951,15 @@ var NavigationHeader = ({
3974
3951
  return open;
3975
3952
  });
3976
3953
  };
3954
+ const [instruction, setInstruction] = useState11("");
3955
+ useEffect14(() => {
3956
+ if (!hasBeenOpen) {
3957
+ return;
3958
+ }
3959
+ setInstruction(
3960
+ isMenuOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
3961
+ );
3962
+ }, [isMenuOpen, activatedLanguage]);
3977
3963
  const getMenuLabel = () => {
3978
3964
  const labels = {
3979
3965
  sv: isMenuOpen ? "St\xE4ng meny" : "Meny",
@@ -4050,20 +4036,22 @@ var NavigationHeader = ({
4050
4036
  )
4051
4037
  ] }) })
4052
4038
  ] }) }),
4053
- useNavigationMenu && /* @__PURE__ */ jsx31(
4054
- NavigationStandard_default,
4055
- {
4056
- activatedLanguage,
4057
- setIsMenyOpen: setIsMenuOpen,
4058
- menuLinks,
4059
- isOpen: isMenuOpen,
4060
- openButtonRef: menuButtonFocusRef,
4061
- linkComponent: LinkComponent,
4062
- setKeyboardNavigationClose: () => {
4063
- shouldRestoreFocusRef.current = true;
4039
+ useNavigationMenu && /* @__PURE__ */ jsxs27(Fragment19, { children: [
4040
+ /* @__PURE__ */ jsx31("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
4041
+ /* @__PURE__ */ jsx31(
4042
+ NavigationStandard_default,
4043
+ {
4044
+ activatedLanguage,
4045
+ setIsMenyOpen: setIsMenuOpen,
4046
+ menuLinks,
4047
+ isOpen: isMenuOpen,
4048
+ openButtonRef: menuButtonFocusRef,
4049
+ linkComponent: LinkComponent,
4050
+ setKeyboardNavigationClose: () => {
4051
+ }
4064
4052
  }
4065
- }
4066
- ),
4053
+ )
4054
+ ] }),
4067
4055
  isMenuOpen && /* @__PURE__ */ jsx31(
4068
4056
  "div",
4069
4057
  {