optimized-react-component-library-xyz123 2.8.9 → 2.8.10

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,7 +837,6 @@ interface NavigationHeaderProps {
837
837
  menuLinks: INavigationItem[];
838
838
  linkComponent?: ElementType;
839
839
  noLogoLink?: boolean;
840
- navigationCloseFocusId?: string;
841
840
  }
842
841
 
843
842
  declare const NavigationHeader: FC<NavigationHeaderProps>;
@@ -849,7 +848,6 @@ interface NavigationProps {
849
848
  isOpen: boolean;
850
849
  openButtonRef: RefObject<HTMLButtonElement | null>;
851
850
  linkComponent?: ElementType;
852
- navigationCloseFocusId?: string;
853
851
  }
854
852
  type Locale = 'sv' | 'en';
855
853
  type Label = Record<Locale, string>;
package/dist/index.d.ts CHANGED
@@ -837,7 +837,6 @@ interface NavigationHeaderProps {
837
837
  menuLinks: INavigationItem[];
838
838
  linkComponent?: ElementType;
839
839
  noLogoLink?: boolean;
840
- navigationCloseFocusId?: string;
841
840
  }
842
841
 
843
842
  declare const NavigationHeader: FC<NavigationHeaderProps>;
@@ -849,7 +848,6 @@ interface NavigationProps {
849
848
  isOpen: boolean;
850
849
  openButtonRef: RefObject<HTMLButtonElement | null>;
851
850
  linkComponent?: ElementType;
852
- navigationCloseFocusId?: string;
853
851
  }
854
852
  type Locale = 'sv' | 'en';
855
853
  type Label = Record<Locale, string>;
package/dist/index.js CHANGED
@@ -1507,7 +1507,7 @@ var MenuIcon = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("svg", { wid
1507
1507
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("line", { x1: "0.666504", y1: "7", x2: "20.6665", y2: "7", stroke: "#6E3282", strokeWidth: "2" }),
1508
1508
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("line", { x1: "0.666504", y1: "13", x2: "20.6665", y2: "13", stroke: "#6E3282", strokeWidth: "2" })
1509
1509
  ] });
1510
- var ExpandIcon = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1510
+ var ExpandIcon = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1511
1511
  "path",
1512
1512
  {
1513
1513
  fillRule: "evenodd",
@@ -1516,7 +1516,7 @@ var ExpandIcon = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { xm
1516
1516
  fill: "white"
1517
1517
  }
1518
1518
  ) });
1519
- var CollapseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1519
+ var CollapseIcon = () => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1520
1520
  "path",
1521
1521
  {
1522
1522
  fillRule: "evenodd",
@@ -1992,7 +1992,9 @@ var import_jsx_runtime18 = require("react/jsx-runtime");
1992
1992
  var TextBody = ({ data }) => {
1993
1993
  return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "pts-textBody-container", children: [
1994
1994
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `${!data.body || !data.linksForMoreInfo ? "" : "pts-textbody-createspace"}`, children: [
1995
- data.body && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { dangerouslySetInnerHTML: { __html: import_dompurify5.default.sanitize(data.body) } }),
1995
+ data.body && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { dangerouslySetInnerHTML: { __html: import_dompurify5.default.sanitize(data.body, {
1996
+ ALLOWED_ATTR: ["target", "href"]
1997
+ }) } }),
1996
1998
  data.linksForMoreInfo && data.linksForMoreInfo.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("ul", { className: "pts-moreinfo-list", children: data.linksForMoreInfo.map((link, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("li", { className: index > 0 ? "notFirstInList" : "", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1997
1999
  "a",
1998
2000
  {
@@ -3802,20 +3804,16 @@ var Navigation = ({
3802
3804
  activatedLanguage = "sv",
3803
3805
  menuLinks = [],
3804
3806
  openButtonRef = null,
3805
- linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props }),
3806
- navigationCloseFocusId
3807
+ linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props })
3807
3808
  }) => {
3808
3809
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3809
3810
  const navRef = (0, import_react16.useRef)(null);
3810
- const firstVisitRef = (0, import_react16.useRef)(true);
3811
3811
  const [openSubMenu, setOpenSubMenu] = (0, import_react16.useState)(null);
3812
3812
  const handleSubMenu = (label) => {
3813
3813
  setOpenSubMenu(openSubMenu === label ? null : label);
3814
3814
  };
3815
- const handleMenuClick = (typeOfInteraction) => {
3816
- var _a, _b;
3817
- setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
3818
- typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
3815
+ const handleCloseButton = () => {
3816
+ setIsMenyOpen && setIsMenyOpen(false);
3819
3817
  };
3820
3818
  (0, import_react16.useEffect)(() => {
3821
3819
  if (!isOpen || !navRef.current) return;
@@ -3825,9 +3823,7 @@ var Navigation = ({
3825
3823
  const firstElement = focusableElements[0];
3826
3824
  const lastElement = focusableElements[focusableElements.length - 1];
3827
3825
  if (!firstElement || !lastElement) return;
3828
- requestAnimationFrame(() => {
3829
- firstElement.focus();
3830
- });
3826
+ firstElement == null ? void 0 : firstElement.focus();
3831
3827
  const handleKeyDown = (event) => {
3832
3828
  var _a;
3833
3829
  if (event.key === "Escape") {
@@ -3865,21 +3861,8 @@ var Navigation = ({
3865
3861
  }
3866
3862
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
3867
3863
  };
3868
- const [instruction, setInstruction] = (0, import_react16.useState)("");
3869
- (0, import_react16.useEffect)(() => {
3870
- if (firstVisitRef.current) {
3871
- firstVisitRef.current = false;
3872
- return;
3873
- }
3874
- if (isOpen)
3875
- requestAnimationFrame(() => {
3876
- setInstruction(
3877
- activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened"
3878
- );
3879
- });
3880
- }, [isOpen, activatedLanguage]);
3881
3864
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
3882
- /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
3865
+ /* @__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" }),
3883
3866
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3884
3867
  "nav",
3885
3868
  {
@@ -3888,13 +3871,12 @@ var Navigation = ({
3888
3871
  "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3889
3872
  className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3890
3873
  inert: !isOpen,
3891
- "aria-expanded": isOpen,
3892
3874
  children: [
3893
3875
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3894
3876
  "button",
3895
3877
  {
3896
3878
  className: "pts-navigation-close-button",
3897
- onClick: () => handleMenuClick("close"),
3879
+ onClick: handleCloseButton,
3898
3880
  type: "button",
3899
3881
  children: [
3900
3882
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {}) }),
@@ -3909,14 +3891,7 @@ var Navigation = ({
3909
3891
  lang: activatedLanguage,
3910
3892
  children: [
3911
3893
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "pts-navigation-button", children: [
3912
- /* @__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)(
3913
- LinkComponent,
3914
- {
3915
- onClick: () => handleMenuClick("link"),
3916
- href,
3917
- children: label[activatedLanguage]
3918
- }
3919
- ) }),
3894
+ /* @__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)(LinkComponent, { onClick: handleCloseButton, href, children: label[activatedLanguage] }) }),
3920
3895
  children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3921
3896
  "button",
3922
3897
  {
@@ -3939,14 +3914,7 @@ var Navigation = ({
3939
3914
  className: "pts-sub-navigation-container",
3940
3915
  id: "sub-menu-" + index,
3941
3916
  role: "region",
3942
- 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)(
3943
- LinkComponent,
3944
- {
3945
- onClick: () => handleMenuClick("link"),
3946
- href: href2,
3947
- children: label2[activatedLanguage]
3948
- }
3949
- ) }, "nav-child-" + index2)) })
3917
+ 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)(LinkComponent, { onClick: handleCloseButton, href: href2, children: label2[activatedLanguage] }) }, "nav-child-" + index2)) })
3950
3918
  }
3951
3919
  )
3952
3920
  ]
@@ -4022,11 +3990,11 @@ var NavigationHeader = ({
4022
3990
  SetActivatedLanguage = () => {
4023
3991
  },
4024
3992
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("a", { ...props }),
4025
- noLogoLink = false,
4026
- navigationCloseFocusId
3993
+ noLogoLink = false
4027
3994
  }) => {
4028
3995
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
4029
3996
  const hasHeadline = headline && headline.length > 0;
3997
+ const menuButtonFocusRef = (0, import_react18.useRef)(null);
4030
3998
  const handleLanguageClick = () => {
4031
3999
  if (activatedLanguage === "sv") {
4032
4000
  SetActivatedLanguage("en");
@@ -4039,7 +4007,6 @@ var NavigationHeader = ({
4039
4007
  else return "Svenska";
4040
4008
  };
4041
4009
  const [isMenuOpen, setIsMenuOpen] = (0, import_react18.useState)(false);
4042
- const menuButtonFocusRef = (0, import_react18.useRef)(null);
4043
4010
  const handleMenuClick = () => {
4044
4011
  setIsMenuOpen((prev) => !prev);
4045
4012
  };
@@ -4119,7 +4086,7 @@ var NavigationHeader = ({
4119
4086
  )
4120
4087
  ] }) })
4121
4088
  ] }) }),
4122
- useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4089
+ useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4123
4090
  NavigationStandard_default,
4124
4091
  {
4125
4092
  activatedLanguage,
@@ -4127,10 +4094,9 @@ var NavigationHeader = ({
4127
4094
  menuLinks,
4128
4095
  isOpen: isMenuOpen,
4129
4096
  openButtonRef: menuButtonFocusRef,
4130
- linkComponent: LinkComponent,
4131
- navigationCloseFocusId
4097
+ linkComponent: LinkComponent
4132
4098
  }
4133
- ) }),
4099
+ ),
4134
4100
  isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4135
4101
  "div",
4136
4102
  {
@@ -4239,7 +4205,6 @@ var LinkStandard = ({
4239
4205
  target: openTarget,
4240
4206
  rel: openTarget === "_blank" ? "noopener noreferrer" : void 0,
4241
4207
  "aria-label": ariaLabel || void 0,
4242
- lang: activatedLanguage,
4243
4208
  children: [
4244
4209
  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, {}) }),
4245
4210
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "pts-standard-link-text", children: linkTitle })
@@ -4259,15 +4224,15 @@ var LinkList = ({
4259
4224
  }) => {
4260
4225
  const uniqueId = (0, import_react19.useId)();
4261
4226
  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) => {
4262
- var _a, _b, _c;
4227
+ var _a, _b;
4263
4228
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4264
4229
  LinkStandard_default,
4265
4230
  {
4266
4231
  url: link.url,
4267
4232
  title: link.title,
4268
- activatedLanguage: (_a = link.activatedLanguage) != null ? _a : activatedLanguage,
4269
- ariaLabel: (_b = link.ariaLabel) != null ? _b : void 0,
4270
- openTarget: (_c = link.openTarget) != null ? _c : "_blank",
4233
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv",
4234
+ ariaLabel: (_a = link.ariaLabel) != null ? _a : void 0,
4235
+ openTarget: (_b = link.openTarget) != null ? _b : "_blank",
4271
4236
  linkComponent: LinkComponent
4272
4237
  }
4273
4238
  ) }, uniqueId + "_" + index);
@@ -4302,7 +4267,7 @@ var Collapse = ({
4302
4267
  "aria-controls": contentId,
4303
4268
  children: [
4304
4269
  `${isOpen ? closeLabel : openLabel} ${title}`,
4305
- /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "pts-collapse-open-close-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CollapseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ExpandIcon, {}) })
4270
+ /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "pts-open-close-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(CollapseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ExpandIcon, {}) })
4306
4271
  ]
4307
4272
  }
4308
4273
  ),