@cullsin/lnc-menu 3.0.20 → 3.0.21
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/src/SideMenu.d.ts +3 -2
- package/dist/src/SideMenu.js +9 -9
- package/package.json +1 -1
package/dist/src/SideMenu.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { NavigateFunction } from "react-router-dom";
|
|
2
|
+
import { Location, NavigateFunction } from "react-router-dom";
|
|
3
3
|
interface SideMenuProps {
|
|
4
4
|
useDrawer: () => {
|
|
5
5
|
isDrawerOpen: boolean;
|
|
@@ -7,6 +7,7 @@ interface SideMenuProps {
|
|
|
7
7
|
};
|
|
8
8
|
SampleMgmtIcon: React.ElementType;
|
|
9
9
|
navigate: NavigateFunction;
|
|
10
|
+
location: Location;
|
|
10
11
|
}
|
|
11
|
-
declare function SideMenu({ useDrawer, SampleMgmtIcon }: SideMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare function SideMenu({ useDrawer, SampleMgmtIcon, location }: SideMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export default SideMenu;
|
package/dist/src/SideMenu.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import ArticleOutlinedIcon from "@mui/icons-material/ArticleOutlined";
|
|
3
3
|
import DashboardOutlinedIcon from "@mui/icons-material/DashboardOutlined";
|
|
4
4
|
import RecentActorsOutlinedIcon from "@mui/icons-material/RecentActorsOutlined";
|
|
5
|
-
import GroupAddOutlinedIcon from
|
|
5
|
+
import GroupAddOutlinedIcon from "@mui/icons-material/GroupAddOutlined";
|
|
6
6
|
import AppBar from "@mui/material/AppBar";
|
|
7
7
|
import Box from "@mui/material/Box";
|
|
8
8
|
import Drawer from "@mui/material/Drawer";
|
|
@@ -14,14 +14,12 @@ import Menu from "@mui/material/Menu";
|
|
|
14
14
|
import MenuItem from "@mui/material/MenuItem";
|
|
15
15
|
import Tooltip from "@mui/material/Tooltip";
|
|
16
16
|
import * as React from "react";
|
|
17
|
-
|
|
18
|
-
function SideMenu({ useDrawer, SampleMgmtIcon }) {
|
|
17
|
+
function SideMenu({ useDrawer, SampleMgmtIcon, location }) {
|
|
19
18
|
const [selectedMainMenu, setSelectedMainMenu] = React.useState(null);
|
|
20
19
|
const [selectedSubMenuPath, setSelectedSubMenuPath] = React.useState(null);
|
|
21
20
|
const [openMenuIndex, setOpenMenuIndex] = React.useState(null);
|
|
22
21
|
const { isDrawerOpen, toggleDrawer } = useDrawer();
|
|
23
22
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
24
|
-
const location = useLocation();
|
|
25
23
|
const menuItems = React.useMemo(() => [
|
|
26
24
|
{
|
|
27
25
|
text: "Home",
|
|
@@ -54,23 +52,25 @@ function SideMenu({ useDrawer, SampleMgmtIcon }) {
|
|
|
54
52
|
path: "/carrier-duo-trio/",
|
|
55
53
|
},
|
|
56
54
|
], [SampleMgmtIcon]);
|
|
57
|
-
// Initialize selected menu based on current
|
|
55
|
+
// Initialize selected menu based on current path
|
|
58
56
|
React.useEffect(() => {
|
|
59
57
|
const currentPath = location.pathname;
|
|
60
|
-
|
|
58
|
+
for (const mainItem of menuItems) {
|
|
61
59
|
if (mainItem.subMenu) {
|
|
62
60
|
const match = mainItem.subMenu.find((sub) => sub.path === currentPath);
|
|
63
61
|
if (match) {
|
|
64
62
|
setSelectedMainMenu(mainItem.text);
|
|
65
63
|
setSelectedSubMenuPath(match.path);
|
|
64
|
+
return;
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
else if (mainItem.path === currentPath) {
|
|
69
68
|
setSelectedMainMenu(mainItem.text);
|
|
70
69
|
setSelectedSubMenuPath(null);
|
|
70
|
+
return;
|
|
71
71
|
}
|
|
72
|
-
}
|
|
73
|
-
handleMenuClose();
|
|
72
|
+
}
|
|
73
|
+
handleMenuClose();
|
|
74
74
|
}, [location.pathname]);
|
|
75
75
|
const handleMenuOpen = (event, index) => {
|
|
76
76
|
setAnchorEl(event.currentTarget);
|
|
@@ -86,7 +86,7 @@ function SideMenu({ useDrawer, SampleMgmtIcon }) {
|
|
|
86
86
|
handleMenuClose();
|
|
87
87
|
if (isDrawerOpen)
|
|
88
88
|
toggleDrawer();
|
|
89
|
-
window.location.href = path;
|
|
89
|
+
window.location.href = path;
|
|
90
90
|
};
|
|
91
91
|
return (_jsxs(Box, { sx: { flexGrow: 1 }, children: [_jsx(AppBar, { sx: { position: "fixed", top: 0 } }), _jsx(Drawer, { open: isDrawerOpen, variant: "permanent", className: "parent-container", sx: {
|
|
92
92
|
width: isDrawerOpen ? 230 : 64,
|