optimized-react-component-library-xyz123 2.8.3 → 2.8.4
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 +36 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -11
- 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,7 +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 })
|
|
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);
|
|
@@ -3870,6 +3871,11 @@ var Navigation = ({
|
|
|
3870
3871
|
isOpen ? activatedLanguage === "sv" ? "Navigationsmenyn \xF6ppnades" : "Navigation menu opened" : activatedLanguage === "sv" ? "Navigationsmenyn st\xE4ngdes" : "Navigation menu closed"
|
|
3871
3872
|
);
|
|
3872
3873
|
}, [isOpen, activatedLanguage]);
|
|
3874
|
+
const handleLinkKeyDown = (event) => {
|
|
3875
|
+
if (event.key === "Enter") {
|
|
3876
|
+
setKeyboardNavigationClose == null ? void 0 : setKeyboardNavigationClose();
|
|
3877
|
+
}
|
|
3878
|
+
};
|
|
3873
3879
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
3874
3880
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { "aria-live": "polite", className: "sr-only", children: instruction }),
|
|
3875
3881
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(
|
|
@@ -3900,7 +3906,15 @@ var Navigation = ({
|
|
|
3900
3906
|
lang: activatedLanguage,
|
|
3901
3907
|
children: [
|
|
3902
3908
|
/* @__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)(
|
|
3909
|
+
/* @__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)(
|
|
3910
|
+
LinkComponent,
|
|
3911
|
+
{
|
|
3912
|
+
onClick: handleCloseButton,
|
|
3913
|
+
href,
|
|
3914
|
+
onKeyDown: handleLinkKeyDown,
|
|
3915
|
+
children: label[activatedLanguage]
|
|
3916
|
+
}
|
|
3917
|
+
) }),
|
|
3904
3918
|
children && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
3905
3919
|
"button",
|
|
3906
3920
|
{
|
|
@@ -3923,7 +3937,15 @@ var Navigation = ({
|
|
|
3923
3937
|
className: "pts-sub-navigation-container",
|
|
3924
3938
|
id: "sub-menu-" + index,
|
|
3925
3939
|
role: "region",
|
|
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)(
|
|
3940
|
+
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)(
|
|
3941
|
+
LinkComponent,
|
|
3942
|
+
{
|
|
3943
|
+
onClick: handleCloseButton,
|
|
3944
|
+
href: href2,
|
|
3945
|
+
onKeyDown: handleLinkKeyDown,
|
|
3946
|
+
children: label2[activatedLanguage]
|
|
3947
|
+
}
|
|
3948
|
+
) }, "nav-child-" + index2)) })
|
|
3927
3949
|
}
|
|
3928
3950
|
)
|
|
3929
3951
|
]
|
|
@@ -4018,14 +4040,14 @@ var NavigationHeader = ({
|
|
|
4018
4040
|
};
|
|
4019
4041
|
const [isMenuOpen, setIsMenuOpen] = (0, import_react18.useState)(false);
|
|
4020
4042
|
const [hasBeenOpen, setHasBeenOpen] = (0, import_react18.useState)(false);
|
|
4043
|
+
const shouldRestoreFocusRef = (0, import_react18.useRef)(false);
|
|
4021
4044
|
(0, import_react18.useEffect)(() => {
|
|
4022
4045
|
var _a;
|
|
4023
|
-
|
|
4024
|
-
if (!isMenuOpen && navigationCloseFocusId && hasBeenOpen) {
|
|
4046
|
+
if (!isMenuOpen && navigationCloseFocusId && hasBeenOpen && shouldRestoreFocusRef.current) {
|
|
4025
4047
|
(_a = document.getElementById(navigationCloseFocusId)) == null ? void 0 : _a.focus();
|
|
4026
|
-
|
|
4048
|
+
shouldRestoreFocusRef.current = false;
|
|
4027
4049
|
}
|
|
4028
|
-
}, [isMenuOpen]);
|
|
4050
|
+
}, [isMenuOpen, navigationCloseFocusId, hasBeenOpen]);
|
|
4029
4051
|
const handleMenuClick = () => {
|
|
4030
4052
|
setIsMenuOpen((prev) => {
|
|
4031
4053
|
const open = !prev;
|
|
@@ -4119,7 +4141,10 @@ var NavigationHeader = ({
|
|
|
4119
4141
|
menuLinks,
|
|
4120
4142
|
isOpen: isMenuOpen,
|
|
4121
4143
|
openButtonRef: menuButtonFocusRef,
|
|
4122
|
-
linkComponent: LinkComponent
|
|
4144
|
+
linkComponent: LinkComponent,
|
|
4145
|
+
setKeyboardNavigationClose: () => {
|
|
4146
|
+
shouldRestoreFocusRef.current = true;
|
|
4147
|
+
}
|
|
4123
4148
|
}
|
|
4124
4149
|
),
|
|
4125
4150
|
isMenuOpen && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
|
|
@@ -4293,7 +4318,7 @@ var Collapse = ({
|
|
|
4293
4318
|
"aria-controls": contentId,
|
|
4294
4319
|
children: [
|
|
4295
4320
|
`${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, {}) })
|
|
4321
|
+
/* @__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
4322
|
]
|
|
4298
4323
|
}
|
|
4299
4324
|
),
|