optimized-react-component-library-xyz123 2.8.6 → 2.8.8
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 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +22 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -849,7 +849,7 @@ interface NavigationProps {
|
|
|
849
849
|
isOpen: boolean;
|
|
850
850
|
openButtonRef: RefObject<HTMLButtonElement | null>;
|
|
851
851
|
linkComponent?: ElementType;
|
|
852
|
-
|
|
852
|
+
navigationCloseFocusId?: string;
|
|
853
853
|
}
|
|
854
854
|
type Locale = 'sv' | 'en';
|
|
855
855
|
type Label = Record<Locale, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -849,7 +849,7 @@ interface NavigationProps {
|
|
|
849
849
|
isOpen: boolean;
|
|
850
850
|
openButtonRef: RefObject<HTMLButtonElement | null>;
|
|
851
851
|
linkComponent?: ElementType;
|
|
852
|
-
|
|
852
|
+
navigationCloseFocusId?: string;
|
|
853
853
|
}
|
|
854
854
|
type Locale = 'sv' | 'en';
|
|
855
855
|
type Label = Record<Locale, string>;
|
package/dist/index.js
CHANGED
|
@@ -3802,8 +3802,8 @@ 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 })
|
|
3806
|
-
|
|
3805
|
+
linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("a", { ...props }),
|
|
3806
|
+
navigationCloseFocusId
|
|
3807
3807
|
}) => {
|
|
3808
3808
|
const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
|
|
3809
3809
|
const navRef = (0, import_react16.useRef)(null);
|
|
@@ -3811,10 +3811,10 @@ var Navigation = ({
|
|
|
3811
3811
|
const handleSubMenu = (label) => {
|
|
3812
3812
|
setOpenSubMenu(openSubMenu === label ? null : label);
|
|
3813
3813
|
};
|
|
3814
|
-
const
|
|
3814
|
+
const handleMenuClick = (typeOfInteraction) => {
|
|
3815
3815
|
var _a, _b;
|
|
3816
|
-
setIsMenyOpen
|
|
3817
|
-
|
|
3816
|
+
setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
|
|
3817
|
+
typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
|
|
3818
3818
|
};
|
|
3819
3819
|
(0, import_react16.useEffect)(() => {
|
|
3820
3820
|
if (!isOpen || !navRef.current) return;
|
|
@@ -3872,12 +3872,13 @@ var Navigation = ({
|
|
|
3872
3872
|
"aria-label": activatedLanguage === "sv" ? "Huvudnavigation" : "Main navigation",
|
|
3873
3873
|
className: `pts-navigation-menu-container ${isOpen ? "open" : ""}`,
|
|
3874
3874
|
inert: !isOpen,
|
|
3875
|
+
"aria-expanded": isOpen,
|
|
3875
3876
|
children: [
|
|
3876
3877
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "pts-navigation-close-container ", id: "menu-close", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
3877
3878
|
"button",
|
|
3878
3879
|
{
|
|
3879
3880
|
className: "pts-navigation-close-button",
|
|
3880
|
-
onClick: () =>
|
|
3881
|
+
onClick: () => handleMenuClick("close"),
|
|
3881
3882
|
type: "button",
|
|
3882
3883
|
children: [
|
|
3883
3884
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CloseIcon, {}) }),
|
|
@@ -3895,9 +3896,7 @@ var Navigation = ({
|
|
|
3895
3896
|
/* @__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)(
|
|
3896
3897
|
LinkComponent,
|
|
3897
3898
|
{
|
|
3898
|
-
onClick: () =>
|
|
3899
|
-
handleCloseButton("link");
|
|
3900
|
-
},
|
|
3899
|
+
onClick: () => handleMenuClick("link"),
|
|
3901
3900
|
href,
|
|
3902
3901
|
children: label[activatedLanguage]
|
|
3903
3902
|
}
|
|
@@ -3927,9 +3926,7 @@ var Navigation = ({
|
|
|
3927
3926
|
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)(
|
|
3928
3927
|
LinkComponent,
|
|
3929
3928
|
{
|
|
3930
|
-
onClick: () =>
|
|
3931
|
-
handleCloseButton("link");
|
|
3932
|
-
},
|
|
3929
|
+
onClick: () => handleMenuClick("link"),
|
|
3933
3930
|
href: href2,
|
|
3934
3931
|
children: label2[activatedLanguage]
|
|
3935
3932
|
}
|
|
@@ -4025,26 +4022,10 @@ var NavigationHeader = ({
|
|
|
4025
4022
|
else return "Svenska";
|
|
4026
4023
|
};
|
|
4027
4024
|
const [isMenuOpen, setIsMenuOpen] = (0, import_react18.useState)(false);
|
|
4028
|
-
const [hasBeenOpen, setHasBeenOpen] = (0, import_react18.useState)(false);
|
|
4029
4025
|
const menuButtonFocusRef = (0, import_react18.useRef)(null);
|
|
4030
4026
|
const handleMenuClick = () => {
|
|
4031
|
-
setIsMenuOpen((prev) =>
|
|
4032
|
-
const open = !prev;
|
|
4033
|
-
if (open) {
|
|
4034
|
-
setHasBeenOpen(true);
|
|
4035
|
-
}
|
|
4036
|
-
return open;
|
|
4037
|
-
});
|
|
4027
|
+
setIsMenuOpen((prev) => !prev);
|
|
4038
4028
|
};
|
|
4039
|
-
const [instruction, setInstruction] = (0, import_react18.useState)("");
|
|
4040
|
-
(0, import_react18.useEffect)(() => {
|
|
4041
|
-
if (!hasBeenOpen) {
|
|
4042
|
-
return;
|
|
4043
|
-
}
|
|
4044
|
-
setInstruction(
|
|
4045
|
-
isMenuOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
|
|
4046
|
-
);
|
|
4047
|
-
}, [isMenuOpen, activatedLanguage]);
|
|
4048
4029
|
const getMenuLabel = () => {
|
|
4049
4030
|
const labels = {
|
|
4050
4031
|
sv: isMenuOpen ? "St\xE4ng meny" : "Meny",
|
|
@@ -4121,22 +4102,18 @@ var NavigationHeader = ({
|
|
|
4121
4102
|
)
|
|
4122
4103
|
] }) })
|
|
4123
4104
|
] }) }),
|
|
4124
|
-
useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
)
|
|
4139
|
-
] }),
|
|
4105
|
+
useNavigationMenu && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4106
|
+
NavigationStandard_default,
|
|
4107
|
+
{
|
|
4108
|
+
activatedLanguage,
|
|
4109
|
+
setIsMenyOpen: setIsMenuOpen,
|
|
4110
|
+
menuLinks,
|
|
4111
|
+
isOpen: isMenuOpen,
|
|
4112
|
+
openButtonRef: menuButtonFocusRef,
|
|
4113
|
+
linkComponent: LinkComponent,
|
|
4114
|
+
navigationCloseFocusId
|
|
4115
|
+
}
|
|
4116
|
+
) }),
|
|
4140
4117
|
isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
4141
4118
|
"div",
|
|
4142
4119
|
{
|