optimized-react-component-library-xyz123 2.8.22 → 2.9.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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +57 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/css/darkMode.css +3 -2
- package/src/css/styles.css +19 -3
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: "
|
|
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(
|
|
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: "
|
|
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(
|
|
1434
1434
|
"path",
|
|
1435
1435
|
{
|
|
1436
1436
|
fillRule: "evenodd",
|
|
@@ -3880,16 +3880,20 @@ var Navigation = ({
|
|
|
3880
3880
|
activatedLanguage = "sv",
|
|
3881
3881
|
menuLinks = [],
|
|
3882
3882
|
openButtonRef = null,
|
|
3883
|
-
linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx30("a", { ...props })
|
|
3883
|
+
linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx30("a", { ...props }),
|
|
3884
|
+
navigationCloseFocusId
|
|
3884
3885
|
}) => {
|
|
3885
3886
|
const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
|
|
3886
3887
|
const navRef = useRef3(null);
|
|
3888
|
+
const firstVisitRef = useRef3(true);
|
|
3887
3889
|
const [openSubMenu, setOpenSubMenu] = useState9(null);
|
|
3888
3890
|
const handleSubMenu = (label) => {
|
|
3889
3891
|
setOpenSubMenu(openSubMenu === label ? null : label);
|
|
3890
3892
|
};
|
|
3891
|
-
const
|
|
3892
|
-
|
|
3893
|
+
const handleMenuClick = (typeOfInteraction) => {
|
|
3894
|
+
var _a, _b;
|
|
3895
|
+
setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
|
|
3896
|
+
typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
|
|
3893
3897
|
};
|
|
3894
3898
|
useEffect13(() => {
|
|
3895
3899
|
if (!isOpen || !navRef.current) return;
|
|
@@ -3899,7 +3903,9 @@ var Navigation = ({
|
|
|
3899
3903
|
const firstElement = focusableElements[0];
|
|
3900
3904
|
const lastElement = focusableElements[focusableElements.length - 1];
|
|
3901
3905
|
if (!firstElement || !lastElement) return;
|
|
3902
|
-
|
|
3906
|
+
requestAnimationFrame(() => {
|
|
3907
|
+
firstElement.focus();
|
|
3908
|
+
});
|
|
3903
3909
|
const handleKeyDown = (event) => {
|
|
3904
3910
|
var _a;
|
|
3905
3911
|
if (event.key === "Escape") {
|
|
@@ -3937,8 +3943,21 @@ var Navigation = ({
|
|
|
3937
3943
|
}
|
|
3938
3944
|
return "\xD6ppna undermeny f\xF6r " + label["sv"];
|
|
3939
3945
|
};
|
|
3946
|
+
const [instruction, setInstruction] = useState9("");
|
|
3947
|
+
useEffect13(() => {
|
|
3948
|
+
if (firstVisitRef.current) {
|
|
3949
|
+
firstVisitRef.current = false;
|
|
3950
|
+
return;
|
|
3951
|
+
}
|
|
3952
|
+
if (isOpen)
|
|
3953
|
+
requestAnimationFrame(() => {
|
|
3954
|
+
setInstruction(
|
|
3955
|
+
activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened"
|
|
3956
|
+
);
|
|
3957
|
+
});
|
|
3958
|
+
}, [isOpen, activatedLanguage]);
|
|
3940
3959
|
return /* @__PURE__ */ jsxs26(Fragment20, { children: [
|
|
3941
|
-
/* @__PURE__ */ jsx30("div", { "aria-live": "polite", className: "sr-only", children:
|
|
3960
|
+
/* @__PURE__ */ jsx30("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
|
|
3942
3961
|
/* @__PURE__ */ jsxs26(
|
|
3943
3962
|
"nav",
|
|
3944
3963
|
{
|
|
@@ -3947,12 +3966,13 @@ var Navigation = ({
|
|
|
3947
3966
|
"aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
|
|
3948
3967
|
className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
|
|
3949
3968
|
inert: !isOpen,
|
|
3969
|
+
"aria-expanded": isOpen,
|
|
3950
3970
|
children: [
|
|
3951
3971
|
/* @__PURE__ */ jsx30("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ jsxs26(
|
|
3952
3972
|
"button",
|
|
3953
3973
|
{
|
|
3954
3974
|
className: "pts-navigation-close-button",
|
|
3955
|
-
onClick:
|
|
3975
|
+
onClick: () => handleMenuClick("close"),
|
|
3956
3976
|
type: "button",
|
|
3957
3977
|
children: [
|
|
3958
3978
|
/* @__PURE__ */ jsx30("span", { "aria-hidden": "true", children: /* @__PURE__ */ jsx30(CloseIcon, {}) }),
|
|
@@ -3967,7 +3987,14 @@ var Navigation = ({
|
|
|
3967
3987
|
lang: activatedLanguage,
|
|
3968
3988
|
children: [
|
|
3969
3989
|
/* @__PURE__ */ jsx30("div", { children: /* @__PURE__ */ jsxs26("div", { className: "pts-navigation-button", children: [
|
|
3970
|
-
/* @__PURE__ */ jsx30("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx30("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx30(
|
|
3990
|
+
/* @__PURE__ */ jsx30("span", { children: href && href.length === 0 ? /* @__PURE__ */ jsx30("span", { children: label[activatedLanguage] }) : /* @__PURE__ */ jsx30(
|
|
3991
|
+
LinkComponent,
|
|
3992
|
+
{
|
|
3993
|
+
onClick: () => handleMenuClick("link"),
|
|
3994
|
+
href,
|
|
3995
|
+
children: label[activatedLanguage]
|
|
3996
|
+
}
|
|
3997
|
+
) }),
|
|
3971
3998
|
children && /* @__PURE__ */ jsx30(
|
|
3972
3999
|
"button",
|
|
3973
4000
|
{
|
|
@@ -3990,7 +4017,14 @@ var Navigation = ({
|
|
|
3990
4017
|
className: "pts-sub-navigation-container",
|
|
3991
4018
|
id: "sub-menu-" + index,
|
|
3992
4019
|
role: "region",
|
|
3993
|
-
children: /* @__PURE__ */ jsx30("ul", { className: "pts-sub-navigation-list", lang: activatedLanguage, children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ jsx30("li", { className: "pts-sub-navigation-item", lang: activatedLanguage, children: /* @__PURE__ */ jsx30(
|
|
4020
|
+
children: /* @__PURE__ */ jsx30("ul", { className: "pts-sub-navigation-list", lang: activatedLanguage, children: children.map(({ label: label2, href: href2 }, index2) => /* @__PURE__ */ jsx30("li", { className: "pts-sub-navigation-item", lang: activatedLanguage, children: /* @__PURE__ */ jsx30(
|
|
4021
|
+
LinkComponent,
|
|
4022
|
+
{
|
|
4023
|
+
onClick: () => handleMenuClick("link"),
|
|
4024
|
+
href: href2,
|
|
4025
|
+
children: label2[activatedLanguage]
|
|
4026
|
+
}
|
|
4027
|
+
) }, "nav-child-" + index2)) })
|
|
3994
4028
|
}
|
|
3995
4029
|
)
|
|
3996
4030
|
]
|
|
@@ -4066,11 +4100,11 @@ var NavigationHeader = ({
|
|
|
4066
4100
|
SetActivatedLanguage = () => {
|
|
4067
4101
|
},
|
|
4068
4102
|
linkComponent: LinkComponent = (props) => /* @__PURE__ */ jsx33("a", { ...props }),
|
|
4069
|
-
noLogoLink = false
|
|
4103
|
+
noLogoLink = false,
|
|
4104
|
+
navigationCloseFocusId
|
|
4070
4105
|
}) => {
|
|
4071
4106
|
const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
|
|
4072
4107
|
const hasHeadline = headline && headline.length > 0;
|
|
4073
|
-
const menuButtonFocusRef = useRef4(null);
|
|
4074
4108
|
const handleLanguageClick = () => {
|
|
4075
4109
|
if (activatedLanguage === "sv") {
|
|
4076
4110
|
SetActivatedLanguage("en");
|
|
@@ -4083,6 +4117,7 @@ var NavigationHeader = ({
|
|
|
4083
4117
|
else return "Svenska";
|
|
4084
4118
|
};
|
|
4085
4119
|
const [isMenuOpen, setIsMenuOpen] = useState11(false);
|
|
4120
|
+
const menuButtonFocusRef = useRef4(null);
|
|
4086
4121
|
const handleMenuClick = () => {
|
|
4087
4122
|
setIsMenuOpen((prev) => !prev);
|
|
4088
4123
|
};
|
|
@@ -4162,7 +4197,7 @@ var NavigationHeader = ({
|
|
|
4162
4197
|
)
|
|
4163
4198
|
] }) })
|
|
4164
4199
|
] }) }),
|
|
4165
|
-
useNavigationMenu && /* @__PURE__ */ jsx33(
|
|
4200
|
+
useNavigationMenu && /* @__PURE__ */ jsx33(Fragment21, { children: /* @__PURE__ */ jsx33(
|
|
4166
4201
|
NavigationStandard_default,
|
|
4167
4202
|
{
|
|
4168
4203
|
activatedLanguage,
|
|
@@ -4170,9 +4205,10 @@ var NavigationHeader = ({
|
|
|
4170
4205
|
menuLinks,
|
|
4171
4206
|
isOpen: isMenuOpen,
|
|
4172
4207
|
openButtonRef: menuButtonFocusRef,
|
|
4173
|
-
linkComponent: LinkComponent
|
|
4208
|
+
linkComponent: LinkComponent,
|
|
4209
|
+
navigationCloseFocusId
|
|
4174
4210
|
}
|
|
4175
|
-
),
|
|
4211
|
+
) }),
|
|
4176
4212
|
isMenuOpen && /* @__PURE__ */ jsx33(
|
|
4177
4213
|
"div",
|
|
4178
4214
|
{
|
|
@@ -4281,6 +4317,7 @@ var LinkStandard = ({
|
|
|
4281
4317
|
target: openTarget,
|
|
4282
4318
|
rel: openTarget === "_blank" ? "noopener noreferrer" : void 0,
|
|
4283
4319
|
"aria-label": ariaLabel || void 0,
|
|
4320
|
+
lang: activatedLanguage,
|
|
4284
4321
|
children: [
|
|
4285
4322
|
IconComponent && /* @__PURE__ */ jsx36("span", { className: `pts-link-icon-circle ${iconClass} ${customClass}`, "aria-hidden": "true", children: /* @__PURE__ */ jsx36(IconComponent, {}) }),
|
|
4286
4323
|
/* @__PURE__ */ jsx36("span", { className: "pts-standard-link-text", children: linkTitle })
|
|
@@ -4300,15 +4337,15 @@ var LinkList = ({
|
|
|
4300
4337
|
}) => {
|
|
4301
4338
|
const uniqueId = useId();
|
|
4302
4339
|
return /* @__PURE__ */ jsx37("div", { className: "pts-linkList-container", children: /* @__PURE__ */ jsx37("ul", { children: linkArray && linkArray.map((link, index) => {
|
|
4303
|
-
var _a, _b;
|
|
4340
|
+
var _a, _b, _c;
|
|
4304
4341
|
return /* @__PURE__ */ jsx37("li", { children: /* @__PURE__ */ jsx37(
|
|
4305
4342
|
LinkStandard_default,
|
|
4306
4343
|
{
|
|
4307
4344
|
url: link.url,
|
|
4308
4345
|
title: link.title,
|
|
4309
|
-
activatedLanguage: activatedLanguage != null ?
|
|
4310
|
-
ariaLabel: (
|
|
4311
|
-
openTarget: (
|
|
4346
|
+
activatedLanguage: (_a = link.activatedLanguage) != null ? _a : activatedLanguage,
|
|
4347
|
+
ariaLabel: (_b = link.ariaLabel) != null ? _b : void 0,
|
|
4348
|
+
openTarget: (_c = link.openTarget) != null ? _c : "_blank",
|
|
4312
4349
|
linkComponent: LinkComponent
|
|
4313
4350
|
}
|
|
4314
4351
|
) }, uniqueId + "_" + index);
|
|
@@ -4343,7 +4380,7 @@ var Collapse = ({
|
|
|
4343
4380
|
"aria-controls": contentId,
|
|
4344
4381
|
children: [
|
|
4345
4382
|
`${isOpen ? closeLabel : openLabel} ${title}`,
|
|
4346
|
-
/* @__PURE__ */ jsx38("span", { className: "pts-open-close-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ jsx38(CollapseIcon, {}) : /* @__PURE__ */ jsx38(ExpandIcon, {}) })
|
|
4383
|
+
/* @__PURE__ */ jsx38("span", { className: "pts-collapse-open-close-icon", "aria-hidden": "true", children: isOpen ? /* @__PURE__ */ jsx38(CollapseIcon, {}) : /* @__PURE__ */ jsx38(ExpandIcon, {}) })
|
|
4347
4384
|
]
|
|
4348
4385
|
}
|
|
4349
4386
|
),
|