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

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
  {
@@ -2120,6 +2122,8 @@ var RadioCollapseItem = ({
2120
2122
  (0, import_react10.useEffect)(() => {
2121
2123
  if (questionAnswer === value) {
2122
2124
  setIsOpen(true);
2125
+ } else {
2126
+ setIsOpen(false);
2123
2127
  }
2124
2128
  }, [questionAnswer, value]);
2125
2129
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "pts-radio-option", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "pts-radio-collapse", children: [
@@ -2138,7 +2142,7 @@ var RadioCollapseItem = ({
2138
2142
  }
2139
2143
  ),
2140
2144
  /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("label", { htmlFor: `${groupId}-option-${index}`, id: `${groupId}-label-${index}`, children: label }),
2141
- optionText && optionText.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2145
+ optionText && optionText.length > 0 && questionAnswer === value && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2142
2146
  "button",
2143
2147
  {
2144
2148
  className: `pts-radio-collapse-button ${isOpen ? "open" : ""}`,
@@ -2149,6 +2153,7 @@ var RadioCollapseItem = ({
2149
2153
  "aria-controls": contentId,
2150
2154
  "aria-label": buttonLabel,
2151
2155
  "aria-describedby": isOpen ? contentId : void 0,
2156
+ tabIndex: questionAnswer === value ? 0 : -1,
2152
2157
  children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "pts-open-close-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(CollapseIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ExpandIcon, {}) })
2153
2158
  }
2154
2159
  )
@@ -2158,6 +2163,7 @@ var RadioCollapseItem = ({
2158
2163
  {
2159
2164
  className: `pts-radio-collapse-body ${isOpen ? "open" : "hidden"}`,
2160
2165
  id: contentId,
2166
+ hidden: !isOpen,
2161
2167
  role: "region",
2162
2168
  "aria-labelledby": `${groupId}-label-${index}`,
2163
2169
  inert: !isOpen,
@@ -3802,20 +3808,16 @@ var Navigation = ({
3802
3808
  activatedLanguage = "sv",
3803
3809
  menuLinks = [],
3804
3810
  openButtonRef = null,
3805
- linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props }),
3806
- navigationCloseFocusId
3811
+ linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props })
3807
3812
  }) => {
3808
3813
  const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
3809
3814
  const navRef = (0, import_react16.useRef)(null);
3810
- const firstVisitRef = (0, import_react16.useRef)(true);
3811
3815
  const [openSubMenu, setOpenSubMenu] = (0, import_react16.useState)(null);
3812
3816
  const handleSubMenu = (label) => {
3813
3817
  setOpenSubMenu(openSubMenu === label ? null : label);
3814
3818
  };
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());
3819
+ const handleCloseButton = () => {
3820
+ setIsMenyOpen && setIsMenyOpen(false);
3819
3821
  };
3820
3822
  (0, import_react16.useEffect)(() => {
3821
3823
  if (!isOpen || !navRef.current) return;
@@ -3825,9 +3827,7 @@ var Navigation = ({
3825
3827
  const firstElement = focusableElements[0];
3826
3828
  const lastElement = focusableElements[focusableElements.length - 1];
3827
3829
  if (!firstElement || !lastElement) return;
3828
- requestAnimationFrame(() => {
3829
- firstElement.focus();
3830
- });
3830
+ firstElement == null ? void 0 : firstElement.focus();
3831
3831
  const handleKeyDown = (event) => {
3832
3832
  var _a;
3833
3833
  if (event.key === "Escape") {
@@ -3865,21 +3865,8 @@ var Navigation = ({
3865
3865
  }
3866
3866
  return "\xD6ppna undermeny f\xF6r " + label["sv"];
3867
3867
  };
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
3868
  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 }),
3869
+ /* @__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
3870
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3884
3871
  "nav",
3885
3872
  {
@@ -3888,13 +3875,12 @@ var Navigation = ({
3888
3875
  "aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
3889
3876
  className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
3890
3877
  inert: !isOpen,
3891
- "aria-expanded": isOpen,
3892
3878
  children: [
3893
3879
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
3894
3880
  "button",
3895
3881
  {
3896
3882
  className: "pts-navigation-close-button",
3897
- onClick: () => handleMenuClick("close"),
3883
+ onClick: handleCloseButton,
3898
3884
  type: "button",
3899
3885
  children: [
3900
3886
  /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {}) }),
@@ -3909,14 +3895,7 @@ var Navigation = ({
3909
3895
  lang: activatedLanguage,
3910
3896
  children: [
3911
3897
  /* @__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
- ) }),
3898
+ /* @__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
3899
  children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
3921
3900
  "button",
3922
3901
  {
@@ -3939,14 +3918,7 @@ var Navigation = ({
3939
3918
  className: "pts-sub-navigation-container",
3940
3919
  id: "sub-menu-" + index,
3941
3920
  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)) })
3921
+ 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
3922
  }
3951
3923
  )
3952
3924
  ]
@@ -4022,11 +3994,11 @@ var NavigationHeader = ({
4022
3994
  SetActivatedLanguage = () => {
4023
3995
  },
4024
3996
  linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("a", { ...props }),
4025
- noLogoLink = false,
4026
- navigationCloseFocusId
3997
+ noLogoLink = false
4027
3998
  }) => {
4028
3999
  const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
4029
4000
  const hasHeadline = headline && headline.length > 0;
4001
+ const menuButtonFocusRef = (0, import_react18.useRef)(null);
4030
4002
  const handleLanguageClick = () => {
4031
4003
  if (activatedLanguage === "sv") {
4032
4004
  SetActivatedLanguage("en");
@@ -4039,7 +4011,6 @@ var NavigationHeader = ({
4039
4011
  else return "Svenska";
4040
4012
  };
4041
4013
  const [isMenuOpen, setIsMenuOpen] = (0, import_react18.useState)(false);
4042
- const menuButtonFocusRef = (0, import_react18.useRef)(null);
4043
4014
  const handleMenuClick = () => {
4044
4015
  setIsMenuOpen((prev) => !prev);
4045
4016
  };
@@ -4119,7 +4090,7 @@ var NavigationHeader = ({
4119
4090
  )
4120
4091
  ] }) })
4121
4092
  ] }) }),
4122
- useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4093
+ useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4123
4094
  NavigationStandard_default,
4124
4095
  {
4125
4096
  activatedLanguage,
@@ -4127,10 +4098,9 @@ var NavigationHeader = ({
4127
4098
  menuLinks,
4128
4099
  isOpen: isMenuOpen,
4129
4100
  openButtonRef: menuButtonFocusRef,
4130
- linkComponent: LinkComponent,
4131
- navigationCloseFocusId
4101
+ linkComponent: LinkComponent
4132
4102
  }
4133
- ) }),
4103
+ ),
4134
4104
  isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
4135
4105
  "div",
4136
4106
  {
@@ -4239,7 +4209,6 @@ var LinkStandard = ({
4239
4209
  target: openTarget,
4240
4210
  rel: openTarget === "_blank" ? "noopener noreferrer" : void 0,
4241
4211
  "aria-label": ariaLabel || void 0,
4242
- lang: activatedLanguage,
4243
4212
  children: [
4244
4213
  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
4214
  /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "pts-standard-link-text", children: linkTitle })
@@ -4259,15 +4228,15 @@ var LinkList = ({
4259
4228
  }) => {
4260
4229
  const uniqueId = (0, import_react19.useId)();
4261
4230
  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;
4231
+ var _a, _b;
4263
4232
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4264
4233
  LinkStandard_default,
4265
4234
  {
4266
4235
  url: link.url,
4267
4236
  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",
4237
+ activatedLanguage: activatedLanguage != null ? activatedLanguage : "sv",
4238
+ ariaLabel: (_a = link.ariaLabel) != null ? _a : void 0,
4239
+ openTarget: (_b = link.openTarget) != null ? _b : "_blank",
4271
4240
  linkComponent: LinkComponent
4272
4241
  }
4273
4242
  ) }, uniqueId + "_" + index);
@@ -4302,7 +4271,7 @@ var Collapse = ({
4302
4271
  "aria-controls": contentId,
4303
4272
  children: [
4304
4273
  `${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, {}) })
4274
+ /* @__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
4275
  ]
4307
4276
  }
4308
4277
  ),