optimized-react-component-library-xyz123 2.8.1 → 2.8.3

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 { useRef as useRef4, useState as useState11 } from "react";
3711
+ import { useEffect as useEffect14, 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";
@@ -3723,6 +3723,7 @@ var Navigation = ({
3723
3723
  }) => {
3724
3724
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3725
3725
  const navRef = useRef3(null);
3726
+ const firstVisitRef = useRef3(true);
3726
3727
  const [openSubMenu, setOpenSubMenu] = useState9(null);
3727
3728
  const handleSubMenu = (label) => {
3728
3729
  setOpenSubMenu(openSubMenu === label ? null : label);
@@ -3776,8 +3777,18 @@ var Navigation = ({
3776
3777
  }
3777
3778
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
3778
3779
  };
3780
+ const [instruction, setInstruction] = useState9("");
3781
+ useEffect13(() => {
3782
+ if (firstVisitRef.current) {
3783
+ firstVisitRef.current = false;
3784
+ return;
3785
+ }
3786
+ setInstruction(
3787
+ isOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
3788
+ );
3789
+ }, [isOpen, activatedLanguage]);
3779
3790
  return /* @__PURE__ */ jsxs24(Fragment18, { children: [
3780
- /* @__PURE__ */ jsx28("div", { "aria-live": "polite", className: "sr-only", children: isOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed" }),
3791
+ /* @__PURE__ */ jsx28("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
3781
3792
  /* @__PURE__ */ jsxs24(
3782
3793
  "nav",
3783
3794
  {
@@ -3905,7 +3916,8 @@ var NavigationHeader = ({
3905
3916
  SetActivatedLanguage = () => {
3906
3917
  },
3907
3918
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx31("a", { ...props }),
3908
- noLogoLink = false
3919
+ noLogoLink = false,
3920
+ navigationCloseFocusId
3909
3921
  }) => {
3910
3922
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
3911
3923
  const hasHeadline = headline && headline.length > 0;
@@ -3922,8 +3934,23 @@ var NavigationHeader = ({
3922
3934
  else return "Svenska";
3923
3935
  };
3924
3936
  const [isMenuOpen, setIsMenuOpen] = useState11(false);
3937
+ const [hasBeenOpen, setHasBeenOpen] = useState11(false);
3938
+ useEffect14(() => {
3939
+ var _a;
3940
+ console.log(navigationCloseFocusId);
3941
+ if (!isMenuOpen && navigationCloseFocusId && hasBeenOpen) {
3942
+ (_a = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _a.focus();
3943
+ console.log(navigationCloseFocusId, document.getElementById(navigationCloseFocusId));
3944
+ }
3945
+ }, [isMenuOpen]);
3925
3946
  const handleMenuClick = () => {
3926
- setIsMenuOpen((prev) => !prev);
3947
+ setIsMenuOpen((prev) => {
3948
+ const open = !prev;
3949
+ if (open) {
3950
+ setHasBeenOpen(true);
3951
+ }
3952
+ return open;
3953
+ });
3927
3954
  };
3928
3955
  const getMenuLabel = () => {
3929
3956
  const labels = {
@@ -4120,6 +4147,7 @@ var LinkStandard = ({
4120
4147
  target: openTarget,
4121
4148
  rel: openTarget === "_blank" ? "noopener noreferrer" : void 0,
4122
4149
  "aria-label": ariaLabel || void 0,
4150
+ lang: activatedLanguage,
4123
4151
  children: [
4124
4152
  IconComponent && /* @__PURE__ */ jsx34("span", { className: `pts-link-icon-circle ${iconClass} ${customClass}`, "aria-hidden": "true", children: /* @__PURE__ */ jsx34(IconComponent, {}) }),
4125
4153
  /* @__PURE__ */ jsx34("span", { className: "pts-standard-link-text", children: linkTitle })
@@ -4139,15 +4167,15 @@ var LinkList = ({
4139
4167
  }) => {
4140
4168
  const uniqueId = useId();
4141
4169
  return /* @__PURE__ */ jsx35("div", { className: "pts-linkList-container", children: /* @__PURE__ */ jsx35("ul", { children: linkArray && linkArray.map((link, index) => {
4142
- var _a, _b;
4170
+ var _a, _b, _c;
4143
4171
  return /* @__PURE__ */ jsx35("li", { children: /* @__PURE__ */ jsx35(
4144
4172
  LinkStandard_default,
4145
4173
  {
4146
4174
  url: link.url,
4147
4175
  title: link.title,
4148
- activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv",
4149
- ariaLabel: (_a = link.ariaLabel) != null ? _a : void 0,
4150
- openTarget: (_b = link.openTarget) != null ? _b : "_blank",
4176
+ activatedLanguage: (_a = link.activatedLanguage) != null ? _a : activatedLanguage,
4177
+ ariaLabel: (_b = link.ariaLabel) != null ? _b : void 0,
4178
+ openTarget: (_c = link.openTarget) != null ? _c : "_blank",
4151
4179
  linkComponent: LinkComponent
4152
4180
  }
4153
4181
  ) }, uniqueId + "_" + index);