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

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
@@ -837,6 +837,7 @@ interface NavigationHeaderProps {
837
837
  menuLinks: INavigationItem[];
838
838
  linkComponent?: ElementType;
839
839
  noLogoLink?: boolean;
840
+ navigationCloseFocusId?: string;
840
841
  }
841
842
 
842
843
  declare const NavigationHeader: FC<NavigationHeaderProps>;
package/dist/index.d.ts CHANGED
@@ -837,6 +837,7 @@ interface NavigationHeaderProps {
837
837
  menuLinks: INavigationItem[];
838
838
  linkComponent?: ElementType;
839
839
  noLogoLink?: boolean;
840
+ navigationCloseFocusId?: string;
840
841
  }
841
842
 
842
843
  declare const NavigationHeader: FC<NavigationHeaderProps>;
package/dist/index.js CHANGED
@@ -3806,6 +3806,7 @@ var Navigation = ({
3806
3806
  }) => {
3807
3807
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3808
3808
  const navRef = (0, import_react16.useRef)(null);
3809
+ const firstVisitRef = (0, import_react16.useRef)(true);
3809
3810
  const [openSubMenu, setOpenSubMenu] = (0, import_react16.useState)(null);
3810
3811
  const handleSubMenu = (label) => {
3811
3812
  setOpenSubMenu(openSubMenu === label ? null : label);
@@ -3859,8 +3860,15 @@ var Navigation = ({
3859
3860
  }
3860
3861
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
3861
3862
  };
3863
+ const setInstruction = () => {
3864
+ if (firstVisitRef.current) {
3865
+ firstVisitRef.current = false;
3866
+ return "";
3867
+ }
3868
+ return isOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed";
3869
+ };
3862
3870
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
3863
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-live": "polite", className: "sr-only", children: isOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed" }),
3871
+ /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-live": "polite", className: "sr-only", children: setInstruction() }),
3864
3872
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3865
3873
  "nav",
3866
3874
  {
@@ -3988,7 +3996,8 @@ var NavigationHeader = ({
3988
3996
  SetActivatedLanguage = () => {
3989
3997
  },
3990
3998
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("a", { ...props }),
3991
- noLogoLink = false
3999
+ noLogoLink = false,
4000
+ navigationCloseFocusId
3992
4001
  }) => {
3993
4002
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
3994
4003
  const hasHeadline = headline && headline.length > 0;
@@ -4005,8 +4014,23 @@ var NavigationHeader = ({
4005
4014
  else return "Svenska";
4006
4015
  };
4007
4016
  const [isMenuOpen, setIsMenuOpen] = (0, import_react18.useState)(false);
4017
+ const [hasBeenOpen, setHasBeenOpen] = (0, import_react18.useState)(false);
4018
+ (0, import_react18.useEffect)(() => {
4019
+ var _a;
4020
+ console.log(navigationCloseFocusId);
4021
+ if (!isMenuOpen && navigationCloseFocusId && hasBeenOpen) {
4022
+ (_a = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _a.focus();
4023
+ console.log(navigationCloseFocusId, document.getElementById(navigationCloseFocusId));
4024
+ }
4025
+ }, [isMenuOpen]);
4008
4026
  const handleMenuClick = () => {
4009
- setIsMenuOpen((prev) => !prev);
4027
+ setIsMenuOpen((prev) => {
4028
+ const open = !prev;
4029
+ if (open) {
4030
+ setHasBeenOpen(true);
4031
+ }
4032
+ return open;
4033
+ });
4010
4034
  };
4011
4035
  const getMenuLabel = () => {
4012
4036
  const labels = {
@@ -4203,6 +4227,7 @@ var LinkStandard = ({
4203
4227
  target: openTarget,
4204
4228
  rel: openTarget === "_blank" ? "noopener noreferrer" : void 0,
4205
4229
  "aria-label": ariaLabel || void 0,
4230
+ lang: activatedLanguage,
4206
4231
  children: [
4207
4232
  IconComponent && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: `pts-link-icon-circle ${iconClass} ${customClass}`, "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(IconComponent, {}) }),
4208
4233
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "pts-standard-link-text", children: linkTitle })
@@ -4222,15 +4247,15 @@ var LinkList = ({
4222
4247
  }) => {
4223
4248
  const uniqueId = (0, import_react19.useId)();
4224
4249
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "pts-linkList-container", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("ul", { children: linkArray && linkArray.map((link, index) => {
4225
- var _a, _b;
4250
+ var _a, _b, _c;
4226
4251
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4227
4252
  LinkStandard_default,
4228
4253
  {
4229
4254
  url: link.url,
4230
4255
  title: link.title,
4231
- activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv",
4232
- ariaLabel: (_a = link.ariaLabel) != null ? _a : void 0,
4233
- openTarget: (_b = link.openTarget) != null ? _b : "_blank",
4256
+ activatedLanguage: (_a = link.activatedLanguage) != null ? _a : activatedLanguage,
4257
+ ariaLabel: (_b = link.ariaLabel) != null ? _b : void 0,
4258
+ openTarget: (_c = link.openTarget) != null ? _c : "_blank",
4234
4259
  linkComponent: LinkComponent
4235
4260
  }
4236
4261
  ) }, uniqueId + "_" + index);