optimized-react-component-library-xyz123 2.8.8 → 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.mjs CHANGED
@@ -1421,7 +1421,7 @@ var MenuIcon = () => /* @__PURE__ */ jsxs13("svg", { width: "15", height: "15",
1421
1421
  /* @__PURE__ */ jsx16("line", { x1: "0.666504", y1: "7", x2: "20.6665", y2: "7", stroke: "#6E3282", strokeWidth: "2" }),
1422
1422
  /* @__PURE__ */ jsx16("line", { x1: "0.666504", y1: "13", x2: "20.6665", y2: "13", stroke: "#6E3282", strokeWidth: "2" })
1423
1423
  ] });
1424
- var ExpandIcon = () => /* @__PURE__ */ jsx16("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx16(
1424
+ var ExpandIcon = () => /* @__PURE__ */ jsx16("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsx16(
1425
1425
  "path",
1426
1426
  {
1427
1427
  fillRule: "evenodd",
@@ -1430,7 +1430,7 @@ var ExpandIcon = () => /* @__PURE__ */ jsx16("svg", { xmlns: "http://www.w3.org/
1430
1430
  fill: "white"
1431
1431
  }
1432
1432
  ) });
1433
- var CollapseIcon = () => /* @__PURE__ */ jsx16("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx16(
1433
+ var CollapseIcon = () => /* @__PURE__ */ jsx16("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "16", viewBox: "0 0 16 16", fill: "none", children: /* @__PURE__ */ jsx16(
1434
1434
  "path",
1435
1435
  {
1436
1436
  fillRule: "evenodd",
@@ -1906,7 +1906,9 @@ import { jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
1906
1906
  var TextBody = ({ data }) => {
1907
1907
  return /* @__PURE__ */ jsxs15("div", { className: "pts-textBody-container", children: [
1908
1908
  /* @__PURE__ */ jsxs15("div", { className: `${!data.body || !data.linksForMoreInfo ? "" : "pts-textbody-createspace"}`, children: [
1909
- data.body && /* @__PURE__ */ jsx18("div", { dangerouslySetInnerHTML: { __html: DOMPurify5.sanitize(data.body) } }),
1909
+ data.body && /* @__PURE__ */ jsx18("div", { dangerouslySetInnerHTML: { __html: DOMPurify5.sanitize(data.body, {
1910
+ ALLOWED_ATTR: ["target", "href"]
1911
+ }) } }),
1910
1912
  data.linksForMoreInfo && data.linksForMoreInfo.length > 1 && /* @__PURE__ */ jsx18("ul", { className: "pts-moreinfo-list", children: data.linksForMoreInfo.map((link, index) => /* @__PURE__ */ jsx18("li", { className: index > 0 ? "notFirstInList" : "", children: /* @__PURE__ */ jsxs15(
1911
1913
  "a",
1912
1914
  {
@@ -3719,8 +3721,7 @@ var Navigation = ({
3719
3721
  activatedLanguage = "sv",
3720
3722
  menuLinks = [],
3721
3723
  openButtonRef = null,
3722
- linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx28("a", { ...props }),
3723
- navigationCloseFocusId
3724
+ linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx28("a", { ...props })
3724
3725
  }) => {
3725
3726
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3726
3727
  const navRef = useRef3(null);
@@ -3728,10 +3729,8 @@ var Navigation = ({
3728
3729
  const handleSubMenu = (label) => {
3729
3730
  setOpenSubMenu(openSubMenu === label ? null : label);
3730
3731
  };
3731
- const handleMenuClick = (typeOfInteraction) => {
3732
- var _a, _b;
3733
- setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
3734
- typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
3732
+ const handleCloseButton = () => {
3733
+ setIsMenyOpen && setIsMenyOpen(false);
3735
3734
  };
3736
3735
  useEffect13(() => {
3737
3736
  if (!isOpen || !navRef.current) return;
@@ -3741,9 +3740,7 @@ var Navigation = ({
3741
3740
  const firstElement = focusableElements[0];
3742
3741
  const lastElement = focusableElements[focusableElements.length - 1];
3743
3742
  if (!firstElement || !lastElement) return;
3744
- requestAnimationFrame(() => {
3745
- firstElement.focus();
3746
- });
3743
+ firstElement == null ? void 0 : firstElement.focus();
3747
3744
  const handleKeyDown = (event) => {
3748
3745
  var _a;
3749
3746
  if (event.key === "Escape") {
@@ -3781,82 +3778,70 @@ var Navigation = ({
3781
3778
  }
3782
3779
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
3783
3780
  };
3784
- return /* @__PURE__ */ jsx28(Fragment18, { children: /* @__PURE__ */ jsxs24(
3785
- "nav",
3786
- {
3787
- id: "main-navigation",
3788
- ref: navRef,
3789
- "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3790
- className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3791
- inert: !isOpen,
3792
- "aria-expanded": isOpen,
3793
- children: [
3794
- /* @__PURE__ */ jsx28("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ jsxs24(
3795
- "button",
3796
- {
3797
- className: "pts-navigation-close-button",
3798
- onClick: () => handleMenuClick("close"),
3799
- type: "button",
3800
- children: [
3801
- /* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx28(CloseIcon, {}) }),
3802
- /* @__PURE__ */ jsx28("span", { className: "pts-navigation-close-text", children: closeMenuText })
3803
- ]
3804
- }
3805
- ) }),
3806
- /* @__PURE__ */ jsx28("ul", { className: "pts-navigation-link-list", lang: activatedLanguage, children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ jsxs24(
3807
- "li",
3808
- {
3809
- className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3810
- lang: activatedLanguage,
3811
- children: [
3812
- /* @__PURE__ */ jsx28("div", { children: /* @__PURE__ */ jsxs24("div", { className: "pts-navigation-button", children: [
3813
- /* @__PURE__ */ jsx28("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx28("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx28(
3814
- LinkComponent,
3815
- {
3816
- onClick: () => handleMenuClick("link"),
3817
- href,
3818
- children: label[activatedLanguage]
3819
- }
3820
- ) }),
3781
+ return /* @__PURE__ */ jsxs24(Fragment18, { children: [
3782
+ /* @__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" }),
3783
+ /* @__PURE__ */ jsxs24(
3784
+ "nav",
3785
+ {
3786
+ id: "main-navigation",
3787
+ ref: navRef,
3788
+ "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3789
+ className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3790
+ inert: !isOpen,
3791
+ children: [
3792
+ /* @__PURE__ */ jsx28("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ jsxs24(
3793
+ "button",
3794
+ {
3795
+ className: "pts-navigation-close-button",
3796
+ onClick: handleCloseButton,
3797
+ type: "button",
3798
+ children: [
3799
+ /* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx28(CloseIcon, {}) }),
3800
+ /* @__PURE__ */ jsx28("span", { className: "pts-navigation-close-text", children: closeMenuText })
3801
+ ]
3802
+ }
3803
+ ) }),
3804
+ /* @__PURE__ */ jsx28("ul", { className: "pts-navigation-link-list", lang: activatedLanguage, children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ jsxs24(
3805
+ "li",
3806
+ {
3807
+ className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
3808
+ lang: activatedLanguage,
3809
+ children: [
3810
+ /* @__PURE__ */ jsx28("div", { children: /* @__PURE__ */ jsxs24("div", { className: "pts-navigation-button", children: [
3811
+ /* @__PURE__ */ jsx28("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx28("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx28(LinkComponent, { onClick: handleCloseButton, href, children: label[activatedLanguage] }) }),
3812
+ children && /* @__PURE__ */ jsx28(
3813
+ "button",
3814
+ {
3815
+ className: `pts-navigation-link-expand-button`,
3816
+ onClick: () => handleSubMenu(label[activatedLanguage]),
3817
+ "aria-label": getSubMenuAriaLabel(label),
3818
+ "aria-expanded": openSubMenu === label[activatedLanguage],
3819
+ "aria-controls": "sub-menu-" + index,
3820
+ type: "button",
3821
+ id: "menu-button-" + index,
3822
+ 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, {}) })
3823
+ }
3824
+ )
3825
+ ] }) }),
3821
3826
  children && /* @__PURE__ */ jsx28(
3822
- "button",
3827
+ "div",
3823
3828
  {
3824
- className: `pts-navigation-link-expand-button`,
3825
- onClick: () => handleSubMenu(label[activatedLanguage]),
3826
- "aria-label": getSubMenuAriaLabel(label),
3827
- "aria-expanded": openSubMenu === label[activatedLanguage],
3828
- "aria-controls": "sub-menu-" + index,
3829
- type: "button",
3830
- id: "menu-button-" + index,
3831
- 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, {}) })
3829
+ hidden: openSubMenu !== label[activatedLanguage],
3830
+ "aria-hidden": openSubMenu !== label[activatedLanguage],
3831
+ className: "pts-sub-navigation-container",
3832
+ id: "sub-menu-" + index,
3833
+ role: "region",
3834
+ 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(LinkComponent, { onClick: handleCloseButton, href: href2, children: label2[activatedLanguage] }) }, "nav-child-" + index2)) })
3832
3835
  }
3833
3836
  )
3834
- ] }) }),
3835
- children && /* @__PURE__ */ jsx28(
3836
- "div",
3837
- {
3838
- hidden: openSubMenu !== label[activatedLanguage],
3839
- "aria-hidden": openSubMenu !== label[activatedLanguage],
3840
- className: "pts-sub-navigation-container",
3841
- id: "sub-menu-" + index,
3842
- role: "region",
3843
- 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(
3844
- LinkComponent,
3845
- {
3846
- onClick: () => handleMenuClick("link"),
3847
- href: href2,
3848
- children: label2[activatedLanguage]
3849
- }
3850
- ) }, "nav-child-" + index2)) })
3851
- }
3852
- )
3853
- ]
3854
- },
3855
- "nav-" + index
3856
- )) })
3857
- ]
3858
- }
3859
- ) });
3837
+ ]
3838
+ },
3839
+ "nav-" + index
3840
+ )) })
3841
+ ]
3842
+ }
3843
+ )
3844
+ ] });
3860
3845
  };
3861
3846
  var NavigationStandard_default = Navigation;
3862
3847
 
@@ -3922,11 +3907,11 @@ var NavigationHeader = ({
3922
3907
  SetActivatedLanguage = () => {
3923
3908
  },
3924
3909
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx31("a", { ...props }),
3925
- noLogoLink = false,
3926
- navigationCloseFocusId
3910
+ noLogoLink = false
3927
3911
  }) => {
3928
3912
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
3929
3913
  const hasHeadline = headline && headline.length > 0;
3914
+ const menuButtonFocusRef = useRef4(null);
3930
3915
  const handleLanguageClick = () => {
3931
3916
  if (activatedLanguage === "sv") {
3932
3917
  SetActivatedLanguage("en");
@@ -3939,7 +3924,6 @@ var NavigationHeader = ({
3939
3924
  else return "Svenska";
3940
3925
  };
3941
3926
  const [isMenuOpen, setIsMenuOpen] = useState11(false);
3942
- const menuButtonFocusRef = useRef4(null);
3943
3927
  const handleMenuClick = () => {
3944
3928
  setIsMenuOpen((prev) => !prev);
3945
3929
  };
@@ -4019,7 +4003,7 @@ var NavigationHeader = ({
4019
4003
  )
4020
4004
  ] }) })
4021
4005
  ] }) }),
4022
- useNavigationMenu && /* @__PURE__ */ jsx31(Fragment19, { children: /* @__PURE__ */ jsx31(
4006
+ useNavigationMenu && /* @__PURE__ */ jsx31(
4023
4007
  NavigationStandard_default,
4024
4008
  {
4025
4009
  activatedLanguage,
@@ -4027,10 +4011,9 @@ var NavigationHeader = ({
4027
4011
  menuLinks,
4028
4012
  isOpen: isMenuOpen,
4029
4013
  openButtonRef: menuButtonFocusRef,
4030
- linkComponent: LinkComponent,
4031
- navigationCloseFocusId
4014
+ linkComponent: LinkComponent
4032
4015
  }
4033
- ) }),
4016
+ ),
4034
4017
  isMenuOpen && /* @__PURE__ */ jsx31(
4035
4018
  "div",
4036
4019
  {
@@ -4139,7 +4122,6 @@ var LinkStandard = ({
4139
4122
  target: openTarget,
4140
4123
  rel: openTarget === "_blank" ? "noopener noreferrer" : void 0,
4141
4124
  "aria-label": ariaLabel || void 0,
4142
- lang: activatedLanguage,
4143
4125
  children: [
4144
4126
  IconComponent && /* @__PURE__ */ jsx34("span", { className: `pts-link-icon-circle ${iconClass} ${customClass}`, "aria-hidden": "true", children: /* @__PURE__ */ jsx34(IconComponent, {}) }),
4145
4127
  /* @__PURE__ */ jsx34("span", { className: "pts-standard-link-text", children: linkTitle })
@@ -4159,15 +4141,15 @@ var LinkList = ({
4159
4141
  }) => {
4160
4142
  const uniqueId = useId();
4161
4143
  return /* @__PURE__ */ jsx35("div", { className: "pts-linkList-container", children: /* @__PURE__ */ jsx35("ul", { children: linkArray && linkArray.map((link, index) => {
4162
- var _a, _b, _c;
4144
+ var _a, _b;
4163
4145
  return /* @__PURE__ */ jsx35("li", { children: /* @__PURE__ */ jsx35(
4164
4146
  LinkStandard_default,
4165
4147
  {
4166
4148
  url: link.url,
4167
4149
  title: link.title,
4168
- activatedLanguage: (_a = link.activatedLanguage) != null ? _a : activatedLanguage,
4169
- ariaLabel: (_b = link.ariaLabel) != null ? _b : void 0,
4170
- openTarget: (_c = link.openTarget) != null ? _c : "_blank",
4150
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv",
4151
+ ariaLabel: (_a = link.ariaLabel) != null ? _a : void 0,
4152
+ openTarget: (_b = link.openTarget) != null ? _b : "_blank",
4171
4153
  linkComponent: LinkComponent
4172
4154
  }
4173
4155
  ) }, uniqueId + "_" + index);
@@ -4202,7 +4184,7 @@ var Collapse = ({
4202
4184
  "aria-controls": contentId,
4203
4185
  children: [
4204
4186
  `${isOpen ? closeLabel : openLabel} ${title}`,
4205
- /* @__PURE__ */ jsx36("span", { className: "pts-collapse-open-close-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ jsx36(CollapseIcon, {}) : /* @__PURE__ */ jsx36(ExpandIcon, {}) })
4187
+ /* @__PURE__ */ jsx36("span", { className: "pts-open-close-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ jsx36(CollapseIcon, {}) : /* @__PURE__ */ jsx36(ExpandIcon, {}) })
4206
4188
  ]
4207
4189
  }
4208
4190
  ),