optimized-react-component-library-xyz123 2.10.1 → 2.10.3
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 +22 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -847,6 +847,7 @@ interface NavigationHeaderProps {
|
|
|
847
847
|
linkComponent?: ElementType;
|
|
848
848
|
noLogoLink?: boolean;
|
|
849
849
|
navigationCloseFocusId?: string;
|
|
850
|
+
activePath?: string | null;
|
|
850
851
|
}
|
|
851
852
|
|
|
852
853
|
declare const NavigationHeader: FC<NavigationHeaderProps>;
|
|
@@ -859,6 +860,7 @@ interface NavigationProps {
|
|
|
859
860
|
openButtonRef: RefObject<HTMLButtonElement | null>;
|
|
860
861
|
linkComponent?: ElementType;
|
|
861
862
|
navigationCloseFocusId?: string;
|
|
863
|
+
activePath?: string | null;
|
|
862
864
|
}
|
|
863
865
|
type Locale = 'sv' | 'en';
|
|
864
866
|
type Label = Record<Locale, string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -847,6 +847,7 @@ interface NavigationHeaderProps {
|
|
|
847
847
|
linkComponent?: ElementType;
|
|
848
848
|
noLogoLink?: boolean;
|
|
849
849
|
navigationCloseFocusId?: string;
|
|
850
|
+
activePath?: string | null;
|
|
850
851
|
}
|
|
851
852
|
|
|
852
853
|
declare const NavigationHeader: FC<NavigationHeaderProps>;
|
|
@@ -859,6 +860,7 @@ interface NavigationProps {
|
|
|
859
860
|
openButtonRef: RefObject<HTMLButtonElement | null>;
|
|
860
861
|
linkComponent?: ElementType;
|
|
861
862
|
navigationCloseFocusId?: string;
|
|
863
|
+
activePath?: string | null;
|
|
862
864
|
}
|
|
863
865
|
type Locale = 'sv' | 'en';
|
|
864
866
|
type Label = Record<Locale, string>;
|
package/dist/index.js
CHANGED
|
@@ -3966,7 +3966,8 @@ var Navigation = ({
|
|
|
3966
3966
|
menuLinks = [],
|
|
3967
3967
|
openButtonRef = null,
|
|
3968
3968
|
linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("a", { ...props }),
|
|
3969
|
-
navigationCloseFocusId
|
|
3969
|
+
navigationCloseFocusId,
|
|
3970
|
+
activePath = null
|
|
3970
3971
|
}) => {
|
|
3971
3972
|
const closeMenuText = activatedLanguage === "sv" ? "St\xE4ng meny" : "Close menu";
|
|
3972
3973
|
const navRef = (0, import_react16.useRef)(null);
|
|
@@ -3981,7 +3982,18 @@ var Navigation = ({
|
|
|
3981
3982
|
typeOfInteraction === "close" ? (_a = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a.focus() : navigationCloseFocusId && ((_b = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _b.focus());
|
|
3982
3983
|
};
|
|
3983
3984
|
(0, import_react16.useEffect)(() => {
|
|
3984
|
-
|
|
3985
|
+
var _a, _b;
|
|
3986
|
+
if (!isOpen || !navRef.current) {
|
|
3987
|
+
setOpenSubMenu(null);
|
|
3988
|
+
return;
|
|
3989
|
+
}
|
|
3990
|
+
const defaultOpenSubMenu = activePath !== null ? (_b = (_a = menuLinks.find(
|
|
3991
|
+
(link) => {
|
|
3992
|
+
var _a2;
|
|
3993
|
+
return (_a2 = link.children) == null ? void 0 : _a2.some((child) => child.href.indexOf(activePath) !== -1);
|
|
3994
|
+
}
|
|
3995
|
+
)) == null ? void 0 : _a.label[activatedLanguage]) != null ? _b : null : null;
|
|
3996
|
+
setOpenSubMenu(defaultOpenSubMenu);
|
|
3985
3997
|
const nav = navRef.current;
|
|
3986
3998
|
const focusableSelectors = 'a, button, input, textarea, select, [tabindex]:not([tabindex="-1"])';
|
|
3987
3999
|
const focusableElements = nav.querySelectorAll(focusableSelectors);
|
|
@@ -3992,10 +4004,10 @@ var Navigation = ({
|
|
|
3992
4004
|
firstElement.focus();
|
|
3993
4005
|
});
|
|
3994
4006
|
const handleKeyDown = (event) => {
|
|
3995
|
-
var
|
|
4007
|
+
var _a2;
|
|
3996
4008
|
if (event.key === "Escape") {
|
|
3997
4009
|
setIsMenyOpen == null ? void 0 : setIsMenyOpen(false);
|
|
3998
|
-
(
|
|
4010
|
+
(_a2 = openButtonRef == null ? void 0 : openButtonRef.current) == null ? void 0 : _a2.focus();
|
|
3999
4011
|
return;
|
|
4000
4012
|
}
|
|
4001
4013
|
if (event.key !== "Tab") return;
|
|
@@ -4041,6 +4053,7 @@ var Navigation = ({
|
|
|
4041
4053
|
);
|
|
4042
4054
|
});
|
|
4043
4055
|
}, [isOpen, activatedLanguage]);
|
|
4056
|
+
console.log(openSubMenu, "tt");
|
|
4044
4057
|
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_jsx_runtime30.Fragment, { children: [
|
|
4045
4058
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
|
|
4046
4059
|
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
@@ -4186,7 +4199,8 @@ var NavigationHeader = ({
|
|
|
4186
4199
|
},
|
|
4187
4200
|
linkComponent: LinkComponent = (props) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("a", { ...props }),
|
|
4188
4201
|
noLogoLink = false,
|
|
4189
|
-
navigationCloseFocusId
|
|
4202
|
+
navigationCloseFocusId,
|
|
4203
|
+
activePath = null
|
|
4190
4204
|
}) => {
|
|
4191
4205
|
const logoLink = activatedLanguage === "en" ? "https://pts.se/en" : "https://pts.se/";
|
|
4192
4206
|
const hasHeadline = headline && headline.length > 0;
|
|
@@ -4247,7 +4261,7 @@ var NavigationHeader = ({
|
|
|
4247
4261
|
children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { "aria-hidden": "true", children: activatedLanguage === "en" ? /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Logo_en, {}) : /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Logo_sv, {}) })
|
|
4248
4262
|
}
|
|
4249
4263
|
) }),
|
|
4250
|
-
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `${hasHeadline ? "pts-navigation-header-headline-container" : ""}`, children: hasHeadline && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("
|
|
4264
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: `${hasHeadline ? "pts-navigation-header-headline-container" : ""}`, children: hasHeadline && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "pts-site-headline", children: headline }) }),
|
|
4251
4265
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "pts-navigation-header-nav-container", children: (useLanguage || useNavigationMenu || useSearch) && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
|
|
4252
4266
|
useSearch && !isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_jsx_runtime33.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("button", { type: "button", onClick: handleSearchClick, children: [
|
|
4253
4267
|
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { "aria-hidden": "true", className: "pts-navigation-header-icons", children: getSearchIcon() }),
|
|
@@ -4291,7 +4305,8 @@ var NavigationHeader = ({
|
|
|
4291
4305
|
isOpen: isMenuOpen,
|
|
4292
4306
|
openButtonRef: menuButtonFocusRef,
|
|
4293
4307
|
linkComponent: LinkComponent,
|
|
4294
|
-
navigationCloseFocusId
|
|
4308
|
+
navigationCloseFocusId,
|
|
4309
|
+
activePath
|
|
4295
4310
|
}
|
|
4296
4311
|
) }),
|
|
4297
4312
|
isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|