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.js CHANGED
@@ -3807,7 +3807,6 @@ var Navigation = ({
3807
3807
  }) => {
3808
3808
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3809
3809
  const navRef = (0, import_react16.useRef)(null);
3810
- const firstVisitRef = (0, import_react16.useRef)(true);
3811
3810
  const [openSubMenu, setOpenSubMenu] = (0, import_react16.useState)(null);
3812
3811
  const handleSubMenu = (label) => {
3813
3812
  setOpenSubMenu(openSubMenu === label ? null : label);
@@ -3823,7 +3822,9 @@ var Navigation = ({
3823
3822
  const firstElement = focusableElements[0];
3824
3823
  const lastElement = focusableElements[focusableElements.length - 1];
3825
3824
  if (!firstElement || !lastElement) return;
3826
- firstElement == null ? void 0 : firstElement.focus();
3825
+ requestAnimationFrame(() => {
3826
+ firstElement.focus();
3827
+ });
3827
3828
  const handleKeyDown = (event) => {
3828
3829
  var _a;
3829
3830
  if (event.key === "Escape") {
@@ -3861,101 +3862,85 @@ var Navigation = ({
3861
3862
  }
3862
3863
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
3863
3864
  };
3864
- const [instruction, setInstruction] = (0, import_react16.useState)("");
3865
- (0, import_react16.useEffect)(() => {
3866
- if (firstVisitRef.current) {
3867
- firstVisitRef.current = false;
3868
- return;
3869
- }
3870
- setInstruction(
3871
- isOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
3872
- );
3873
- }, [isOpen, activatedLanguage]);
3874
- const handleLinkKeyDown = (event) => {
3875
- if (event.key === "Enter") {
3876
- setKeyboardNavigationClose == null ? void 0 : setKeyboardNavigationClose();
3877
- }
3878
- };
3879
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
3880
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
3881
- /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3882
- "nav",
3883
- {
3884
- id: "main-navigation",
3885
- ref: navRef,
3886
- "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3887
- className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3888
- inert: !isOpen,
3889
- children: [
3890
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3891
- "button",
3892
- {
3893
- className: "pts-navigation-close-button",
3894
- onClick: handleCloseButton,
3895
- type: "button",
3896
- children: [
3897
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {}) }),
3898
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "pts-navigation-close-text", children: closeMenuText })
3899
- ]
3900
- }
3901
- ) }),
3902
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("ul", { className: "pts-navigation-link-list", lang: activatedLanguage, children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3903
- "li",
3904
- {
3905
- className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3906
- lang: activatedLanguage,
3907
- children: [
3908
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "pts-navigation-button", children: [
3909
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: href && href.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3910
- LinkComponent,
3911
- {
3912
- onClick: handleCloseButton,
3913
- href,
3914
- onKeyDown: handleLinkKeyDown,
3915
- children: label[activatedLanguage]
3916
- }
3917
- ) }),
3918
- children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3919
- "button",
3920
- {
3921
- className: `pts-navigation-link-expand-button`,
3922
- onClick: () => handleSubMenu(label[activatedLanguage]),
3923
- "aria-label": getSubMenuAriaLabel(label),
3924
- "aria-expanded": openSubMenu === label[activatedLanguage],
3925
- "aria-controls": "sub-menu-" + index,
3926
- type: "button",
3927
- id: "menu-button-" + index,
3928
- children: openSubMenu === label[activatedLanguage] ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": true, className: "pts-contract-icon", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MinusIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": true, className: "pts-expand-icon", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AddIcon, {}) })
3929
- }
3930
- )
3931
- ] }) }),
3865
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3866
+ "nav",
3867
+ {
3868
+ id: "main-navigation",
3869
+ ref: navRef,
3870
+ "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3871
+ className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3872
+ inert: !isOpen,
3873
+ children: [
3874
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3875
+ "button",
3876
+ {
3877
+ className: "pts-navigation-close-button",
3878
+ onClick: handleCloseButton,
3879
+ type: "button",
3880
+ children: [
3881
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {}) }),
3882
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "pts-navigation-close-text", children: closeMenuText })
3883
+ ]
3884
+ }
3885
+ ) }),
3886
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("ul", { className: "pts-navigation-link-list", lang: activatedLanguage, children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3887
+ "li",
3888
+ {
3889
+ className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3890
+ lang: activatedLanguage,
3891
+ children: [
3892
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "pts-navigation-button", children: [
3893
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: href && href.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3894
+ LinkComponent,
3895
+ {
3896
+ onClick: () => {
3897
+ handleCloseButton();
3898
+ },
3899
+ href,
3900
+ children: label[activatedLanguage]
3901
+ }
3902
+ ) }),
3932
3903
  children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3933
- "div",
3904
+ "button",
3934
3905
  {
3935
- hidden: openSubMenu !== label[activatedLanguage],
3936
- "aria-hidden": openSubMenu !== label[activatedLanguage],
3937
- className: "pts-sub-navigation-container",
3938
- id: "sub-menu-" + index,
3939
- role: "region",
3940
- children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("ul", { className: "pts-sub-navigation-list", lang: activatedLanguage, children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("li", { className: "pts-sub-navigation-item", lang: activatedLanguage, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3941
- LinkComponent,
3942
- {
3943
- onClick: handleCloseButton,
3944
- href: href2,
3945
- onKeyDown: handleLinkKeyDown,
3946
- children: label2[activatedLanguage]
3947
- }
3948
- ) }, "nav-child-" + index2)) })
3906
+ className: `pts-navigation-link-expand-button`,
3907
+ onClick: () => handleSubMenu(label[activatedLanguage]),
3908
+ "aria-label": getSubMenuAriaLabel(label),
3909
+ "aria-expanded": openSubMenu === label[activatedLanguage],
3910
+ "aria-controls": "sub-menu-" + index,
3911
+ type: "button",
3912
+ id: "menu-button-" + index,
3913
+ children: openSubMenu === label[activatedLanguage] ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": true, className: "pts-contract-icon", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MinusIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": true, className: "pts-expand-icon", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AddIcon, {}) })
3949
3914
  }
3950
3915
  )
3951
- ]
3952
- },
3953
- "nav-" + index
3954
- )) })
3955
- ]
3956
- }
3957
- )
3958
- ] });
3916
+ ] }) }),
3917
+ children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3918
+ "div",
3919
+ {
3920
+ hidden: openSubMenu !== label[activatedLanguage],
3921
+ "aria-hidden": openSubMenu !== label[activatedLanguage],
3922
+ className: "pts-sub-navigation-container",
3923
+ id: "sub-menu-" + index,
3924
+ role: "region",
3925
+ children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("ul", { className: "pts-sub-navigation-list", lang: activatedLanguage, children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("li", { className: "pts-sub-navigation-item", lang: activatedLanguage, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3926
+ LinkComponent,
3927
+ {
3928
+ onClick: () => {
3929
+ handleCloseButton();
3930
+ },
3931
+ href: href2,
3932
+ children: label2[activatedLanguage]
3933
+ }
3934
+ ) }, "nav-child-" + index2)) })
3935
+ }
3936
+ )
3937
+ ]
3938
+ },
3939
+ "nav-" + index
3940
+ )) })
3941
+ ]
3942
+ }
3943
+ ) });
3959
3944
  };
3960
3945
  var NavigationStandard_default = Navigation;
3961
3946
 
@@ -4026,7 +4011,6 @@ var NavigationHeader = ({
4026
4011
  }) => {
4027
4012
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
4028
4013
  const hasHeadline = headline && headline.length > 0;
4029
- const menuButtonFocusRef = (0, import_react18.useRef)(null);
4030
4014
  const handleLanguageClick = () => {
4031
4015
  if (activatedLanguage === "sv") {
4032
4016
  SetActivatedLanguage("en");
@@ -4040,14 +4024,7 @@ var NavigationHeader = ({
4040
4024
  };
4041
4025
  const [isMenuOpen, setIsMenuOpen] = (0, import_react18.useState)(false);
4042
4026
  const [hasBeenOpen, setHasBeenOpen] = (0, import_react18.useState)(false);
4043
- const shouldRestoreFocusRef = (0, import_react18.useRef)(false);
4044
- (0, import_react18.useEffect)(() => {
4045
- var _a;
4046
- if (!isMenuOpen && navigationCloseFocusId && hasBeenOpen && shouldRestoreFocusRef.current) {
4047
- (_a = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _a.focus();
4048
- shouldRestoreFocusRef.current = false;
4049
- }
4050
- }, [isMenuOpen, navigationCloseFocusId, hasBeenOpen]);
4027
+ const menuButtonFocusRef = (0, import_react18.useRef)(null);
4051
4028
  const handleMenuClick = () => {
4052
4029
  setIsMenuOpen((prev) => {
4053
4030
  const open = !prev;
@@ -4057,6 +4034,15 @@ var NavigationHeader = ({
4057
4034
  return open;
4058
4035
  });
4059
4036
  };
4037
+ const [instruction, setInstruction] = (0, import_react18.useState)("");
4038
+ (0, import_react18.useEffect)(() => {
4039
+ if (!hasBeenOpen) {
4040
+ return;
4041
+ }
4042
+ setInstruction(
4043
+ isMenuOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
4044
+ );
4045
+ }, [isMenuOpen, activatedLanguage]);
4060
4046
  const getMenuLabel = () => {
4061
4047
  const labels = {
4062
4048
  sv: isMenuOpen ? "St\xE4ng meny" : "Meny",
@@ -4133,20 +4119,22 @@ var NavigationHeader = ({
4133
4119
  )
4134
4120
  ] }) })
4135
4121
  ] }) }),
4136
- useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4137
- NavigationStandard_default,
4138
- {
4139
- activatedLanguage,
4140
- setIsMenyOpen: setIsMenuOpen,
4141
- menuLinks,
4142
- isOpen: isMenuOpen,
4143
- openButtonRef: menuButtonFocusRef,
4144
- linkComponent: LinkComponent,
4145
- setKeyboardNavigationClose: () => {
4146
- shouldRestoreFocusRef.current = true;
4122
+ useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
4123
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
4124
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4125
+ NavigationStandard_default,
4126
+ {
4127
+ activatedLanguage,
4128
+ setIsMenyOpen: setIsMenuOpen,
4129
+ menuLinks,
4130
+ isOpen: isMenuOpen,
4131
+ openButtonRef: menuButtonFocusRef,
4132
+ linkComponent: LinkComponent,
4133
+ setKeyboardNavigationClose: () => {
4134
+ }
4147
4135
  }
4148
- }
4149
- ),
4136
+ )
4137
+ ] }),
4150
4138
  isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4151
4139
  "div",
4152
4140
  {