optimized-react-component-library-xyz123 2.8.3 → 2.8.5
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +109 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/css/darkMode.css +2 -1
- package/src/css/styles.css +13 -2
package/dist/index.d.mts
CHANGED
|
@@ -849,6 +849,7 @@ interface NavigationProps {
|
|
|
849
849
|
isOpen: boolean;
|
|
850
850
|
openButtonRef: RefObject<HTMLButtonElement | null>;
|
|
851
851
|
linkComponent?: ElementType;
|
|
852
|
+
setKeyboardNavigationClose?: () => void;
|
|
852
853
|
}
|
|
853
854
|
type Locale = 'sv' | 'en';
|
|
854
855
|
type Label = Record<Locale, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -849,6 +849,7 @@ interface NavigationProps {
|
|
|
849
849
|
isOpen: boolean;
|
|
850
850
|
openButtonRef: RefObject<HTMLButtonElement | null>;
|
|
851
851
|
linkComponent?: ElementType;
|
|
852
|
+
setKeyboardNavigationClose?: () => void;
|
|
852
853
|
}
|
|
853
854
|
type Locale = 'sv' | 'en';
|
|
854
855
|
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: "
|
|
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)(
|
|
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: "
|
|
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)(
|
|
1520
1520
|
"path",
|
|
1521
1521
|
{
|
|
1522
1522
|
fillRule: "evenodd",
|
|
@@ -3802,11 +3802,11 @@ var Navigation = ({
|
|
|
3802
3802
|
activatedLanguage = "sv",
|
|
3803
3803
|
menuLinks = [],
|
|
3804
3804
|
openButtonRef = null,
|
|
3805
|
-
linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props })
|
|
3805
|
+
linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props }),
|
|
3806
|
+
setKeyboardNavigationClose
|
|
3806
3807
|
}) => {
|
|
3807
3808
|
const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
|
|
3808
3809
|
const navRef = (0, import_react16.useRef)(null);
|
|
3809
|
-
const firstVisitRef = (0, import_react16.useRef)(true);
|
|
3810
3810
|
const [openSubMenu, setOpenSubMenu] = (0, import_react16.useState)(null);
|
|
3811
3811
|
const handleSubMenu = (label) => {
|
|
3812
3812
|
setOpenSubMenu(openSubMenu === label ? null : label);
|
|
@@ -3822,7 +3822,9 @@ var Navigation = ({
|
|
|
3822
3822
|
const firstElement = focusableElements[0];
|
|
3823
3823
|
const lastElement = focusableElements[focusableElements.length - 1];
|
|
3824
3824
|
if (!firstElement || !lastElement) return;
|
|
3825
|
-
|
|
3825
|
+
requestAnimationFrame(() => {
|
|
3826
|
+
firstElement.focus();
|
|
3827
|
+
});
|
|
3826
3828
|
const handleKeyDown = (event) => {
|
|
3827
3829
|
var _a;
|
|
3828
3830
|
if (event.key === "Escape") {
|
|
@@ -3860,80 +3862,85 @@ var Navigation = ({
|
|
|
3860
3862
|
}
|
|
3861
3863
|
return "\xD6ppna undermeny f\xF6r " + label["sv"];
|
|
3862
3864
|
};
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
children: [
|
|
3891
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", {
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
children: [
|
|
3902
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "pts-navigation-button", children: [
|
|
3903
|
-
/* @__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] }) }),
|
|
3904
|
-
children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3905
|
-
"button",
|
|
3906
|
-
{
|
|
3907
|
-
className: `pts-navigation-link-expand-button`,
|
|
3908
|
-
onClick: () => handleSubMenu(label[activatedLanguage]),
|
|
3909
|
-
"aria-label": getSubMenuAriaLabel(label),
|
|
3910
|
-
"aria-expanded": openSubMenu === label[activatedLanguage],
|
|
3911
|
-
"aria-controls": "sub-menu-" + index,
|
|
3912
|
-
type: "button",
|
|
3913
|
-
id: "menu-button-" + index,
|
|
3914
|
-
children: openSubMenu === label[activatedLanguage] ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": true, className: "pts-contract-icon", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MinusIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": true, className: "pts-expand-icon", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AddIcon, {}) })
|
|
3915
|
-
}
|
|
3916
|
-
)
|
|
3917
|
-
] }) }),
|
|
3865
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_jsx_runtime28.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3866
|
+
"nav",
|
|
3867
|
+
{
|
|
3868
|
+
id: "main-navigation",
|
|
3869
|
+
ref: navRef,
|
|
3870
|
+
"aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
|
|
3871
|
+
className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
|
|
3872
|
+
inert: !isOpen,
|
|
3873
|
+
children: [
|
|
3874
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3875
|
+
"button",
|
|
3876
|
+
{
|
|
3877
|
+
className: "pts-navigation-close-button",
|
|
3878
|
+
onClick: handleCloseButton,
|
|
3879
|
+
type: "button",
|
|
3880
|
+
children: [
|
|
3881
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {}) }),
|
|
3882
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "pts-navigation-close-text", children: closeMenuText })
|
|
3883
|
+
]
|
|
3884
|
+
}
|
|
3885
|
+
) }),
|
|
3886
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("ul", { className: "pts-navigation-link-list", lang: activatedLanguage, children: menuLinks && menuLinks.map(({ label, href, children }, index) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3887
|
+
"li",
|
|
3888
|
+
{
|
|
3889
|
+
className: `pts-navigation-link ${openSubMenu === label[activatedLanguage] ? "open" : ""}`,
|
|
3890
|
+
lang: activatedLanguage,
|
|
3891
|
+
children: [
|
|
3892
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "pts-navigation-button", children: [
|
|
3893
|
+
/* @__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)(
|
|
3894
|
+
LinkComponent,
|
|
3895
|
+
{
|
|
3896
|
+
onClick: () => {
|
|
3897
|
+
handleCloseButton();
|
|
3898
|
+
},
|
|
3899
|
+
href,
|
|
3900
|
+
children: label[activatedLanguage]
|
|
3901
|
+
}
|
|
3902
|
+
) }),
|
|
3918
3903
|
children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3919
|
-
"
|
|
3904
|
+
"button",
|
|
3920
3905
|
{
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3906
|
+
className: `pts-navigation-link-expand-button`,
|
|
3907
|
+
onClick: () => handleSubMenu(label[activatedLanguage]),
|
|
3908
|
+
"aria-label": getSubMenuAriaLabel(label),
|
|
3909
|
+
"aria-expanded": openSubMenu === label[activatedLanguage],
|
|
3910
|
+
"aria-controls": "sub-menu-" + index,
|
|
3911
|
+
type: "button",
|
|
3912
|
+
id: "menu-button-" + index,
|
|
3913
|
+
children: openSubMenu === label[activatedLanguage] ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": true, className: "pts-contract-icon", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(MinusIcon, {}) }) : /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": true, className: "pts-expand-icon", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(AddIcon, {}) })
|
|
3927
3914
|
}
|
|
3928
3915
|
)
|
|
3929
|
-
]
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3916
|
+
] }) }),
|
|
3917
|
+
children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3918
|
+
"div",
|
|
3919
|
+
{
|
|
3920
|
+
hidden: openSubMenu !== label[activatedLanguage],
|
|
3921
|
+
"aria-hidden": openSubMenu !== label[activatedLanguage],
|
|
3922
|
+
className: "pts-sub-navigation-container",
|
|
3923
|
+
id: "sub-menu-" + index,
|
|
3924
|
+
role: "region",
|
|
3925
|
+
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)(
|
|
3926
|
+
LinkComponent,
|
|
3927
|
+
{
|
|
3928
|
+
onClick: () => {
|
|
3929
|
+
handleCloseButton();
|
|
3930
|
+
},
|
|
3931
|
+
href: href2,
|
|
3932
|
+
children: label2[activatedLanguage]
|
|
3933
|
+
}
|
|
3934
|
+
) }, "nav-child-" + index2)) })
|
|
3935
|
+
}
|
|
3936
|
+
)
|
|
3937
|
+
]
|
|
3938
|
+
},
|
|
3939
|
+
"nav-" + index
|
|
3940
|
+
)) })
|
|
3941
|
+
]
|
|
3942
|
+
}
|
|
3943
|
+
) });
|
|
3937
3944
|
};
|
|
3938
3945
|
var NavigationStandard_default = Navigation;
|
|
3939
3946
|
|
|
@@ -4004,7 +4011,6 @@ var NavigationHeader = ({
|
|
|
4004
4011
|
}) => {
|
|
4005
4012
|
const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
|
|
4006
4013
|
const hasHeadline = headline && headline.length > 0;
|
|
4007
|
-
const menuButtonFocusRef = (0, import_react18.useRef)(null);
|
|
4008
4014
|
const handleLanguageClick = () => {
|
|
4009
4015
|
if (activatedLanguage === "sv") {
|
|
4010
4016
|
SetActivatedLanguage("en");
|
|
@@ -4018,14 +4024,7 @@ var NavigationHeader = ({
|
|
|
4018
4024
|
};
|
|
4019
4025
|
const [isMenuOpen, setIsMenuOpen] = (0, import_react18.useState)(false);
|
|
4020
4026
|
const [hasBeenOpen, setHasBeenOpen] = (0, import_react18.useState)(false);
|
|
4021
|
-
(0, import_react18.
|
|
4022
|
-
var _a;
|
|
4023
|
-
console.log(navigationCloseFocusId);
|
|
4024
|
-
if (!isMenuOpen && navigationCloseFocusId && hasBeenOpen) {
|
|
4025
|
-
(_a = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _a.focus();
|
|
4026
|
-
console.log(navigationCloseFocusId, document.getElementById(navigationCloseFocusId));
|
|
4027
|
-
}
|
|
4028
|
-
}, [isMenuOpen]);
|
|
4027
|
+
const menuButtonFocusRef = (0, import_react18.useRef)(null);
|
|
4029
4028
|
const handleMenuClick = () => {
|
|
4030
4029
|
setIsMenuOpen((prev) => {
|
|
4031
4030
|
const open = !prev;
|
|
@@ -4035,6 +4034,15 @@ var NavigationHeader = ({
|
|
|
4035
4034
|
return open;
|
|
4036
4035
|
});
|
|
4037
4036
|
};
|
|
4037
|
+
const [instruction, setInstruction] = (0, import_react18.useState)("");
|
|
4038
|
+
(0, import_react18.useEffect)(() => {
|
|
4039
|
+
if (!hasBeenOpen) {
|
|
4040
|
+
return;
|
|
4041
|
+
}
|
|
4042
|
+
setInstruction(
|
|
4043
|
+
isMenuOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
|
|
4044
|
+
);
|
|
4045
|
+
}, [isMenuOpen, activatedLanguage]);
|
|
4038
4046
|
const getMenuLabel = () => {
|
|
4039
4047
|
const labels = {
|
|
4040
4048
|
sv: isMenuOpen ? "St\xE4ng meny" : "Meny",
|
|
@@ -4111,17 +4119,22 @@ var NavigationHeader = ({
|
|
|
4111
4119
|
)
|
|
4112
4120
|
] }) })
|
|
4113
4121
|
] }) }),
|
|
4114
|
-
useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4122
|
+
useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
|
|
4123
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
|
|
4124
|
+
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4125
|
+
NavigationStandard_default,
|
|
4126
|
+
{
|
|
4127
|
+
activatedLanguage,
|
|
4128
|
+
setIsMenyOpen: setIsMenuOpen,
|
|
4129
|
+
menuLinks,
|
|
4130
|
+
isOpen: isMenuOpen,
|
|
4131
|
+
openButtonRef: menuButtonFocusRef,
|
|
4132
|
+
linkComponent: LinkComponent,
|
|
4133
|
+
setKeyboardNavigationClose: () => {
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
)
|
|
4137
|
+
] }),
|
|
4125
4138
|
isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4126
4139
|
"div",
|
|
4127
4140
|
{
|
|
@@ -4293,7 +4306,7 @@ var Collapse = ({
|
|
|
4293
4306
|
"aria-controls": contentId,
|
|
4294
4307
|
children: [
|
|
4295
4308
|
`${isOpen ? closeLabel : openLabel} ${title}`,
|
|
4296
|
-
/* @__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, {}) })
|
|
4309
|
+
/* @__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, {}) })
|
|
4297
4310
|
]
|
|
4298
4311
|
}
|
|
4299
4312
|
),
|