@cullsin/lnc-menu 3.0.16 → 3.0.18
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 +1 -1
- package/dist/src/SideMenu.js +73 -53
- package/package.json +1 -1
package/dist/src/SideMenu.d.ts
CHANGED
|
@@ -8,5 +8,5 @@ interface SideMenuProps {
|
|
|
8
8
|
SampleMgmtIcon: React.ElementType;
|
|
9
9
|
navigate: NavigateFunction;
|
|
10
10
|
}
|
|
11
|
-
declare function SideMenu({ useDrawer, SampleMgmtIcon
|
|
11
|
+
declare function SideMenu({ useDrawer, SampleMgmtIcon }: SideMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
12
12
|
export default SideMenu;
|
package/dist/src/SideMenu.js
CHANGED
|
@@ -2,6 +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 '@mui/icons-material/GroupAddOutlined';
|
|
5
6
|
import AppBar from "@mui/material/AppBar";
|
|
6
7
|
import Box from "@mui/material/Box";
|
|
7
8
|
import Drawer from "@mui/material/Drawer";
|
|
@@ -11,32 +12,69 @@ import ListItemIcon from "@mui/material/ListItemIcon";
|
|
|
11
12
|
import ListItemText from "@mui/material/ListItemText";
|
|
12
13
|
import Menu from "@mui/material/Menu";
|
|
13
14
|
import MenuItem from "@mui/material/MenuItem";
|
|
15
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
14
16
|
import * as React from "react";
|
|
15
|
-
import { useLocation } from "react-router-dom";
|
|
16
|
-
function SideMenu({ useDrawer, SampleMgmtIcon
|
|
17
|
-
const [selectedMainMenu, setSelectedMainMenu] = React.useState(null);
|
|
17
|
+
import { useLocation } from "react-router-dom";
|
|
18
|
+
function SideMenu({ useDrawer, SampleMgmtIcon }) {
|
|
19
|
+
const [selectedMainMenu, setSelectedMainMenu] = React.useState(null);
|
|
18
20
|
const [selectedSubMenuPath, setSelectedSubMenuPath] = React.useState(null);
|
|
19
21
|
const [openMenuIndex, setOpenMenuIndex] = React.useState(null);
|
|
20
22
|
const { isDrawerOpen, toggleDrawer } = useDrawer();
|
|
21
23
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
22
|
-
const location = useLocation();
|
|
23
|
-
|
|
24
|
+
const location = useLocation();
|
|
25
|
+
const menuItems = React.useMemo(() => [
|
|
26
|
+
{
|
|
27
|
+
text: "Home",
|
|
28
|
+
icon: _jsx(DashboardOutlinedIcon, {}),
|
|
29
|
+
subMenu: [{ text: "Dashboard", path: "/super-site/dashboard" }],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
text: "Patient Management",
|
|
33
|
+
icon: _jsx(RecentActorsOutlinedIcon, {}),
|
|
34
|
+
subMenu: [
|
|
35
|
+
{ text: "Patient", path: "/patient/patient-listing" },
|
|
36
|
+
{ text: "Family", path: "/patient/family-listing" },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
text: "Sample Management",
|
|
41
|
+
icon: _jsx(SampleMgmtIcon, {}),
|
|
42
|
+
subMenu: [
|
|
43
|
+
{ text: "Sample Listing", path: "/sample/sample-listing" }
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
text: "Reports",
|
|
48
|
+
icon: _jsx(ArticleOutlinedIcon, {}),
|
|
49
|
+
path: "/variant/",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
text: "Carrier Duo/Trio",
|
|
53
|
+
icon: _jsx(GroupAddOutlinedIcon, {}),
|
|
54
|
+
path: "/carrier-duo-trio/",
|
|
55
|
+
},
|
|
56
|
+
], [SampleMgmtIcon]);
|
|
57
|
+
// Initialize selected menu based on current URL
|
|
24
58
|
React.useEffect(() => {
|
|
25
59
|
const currentPath = location.pathname;
|
|
26
60
|
menuItems.forEach((mainItem) => {
|
|
27
61
|
if (mainItem.subMenu) {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
62
|
+
const match = mainItem.subMenu.find((sub) => sub.path === currentPath);
|
|
63
|
+
if (match) {
|
|
30
64
|
setSelectedMainMenu(mainItem.text);
|
|
31
|
-
setSelectedSubMenuPath(
|
|
32
|
-
return;
|
|
65
|
+
setSelectedSubMenuPath(match.path);
|
|
33
66
|
}
|
|
34
67
|
}
|
|
68
|
+
else if (mainItem.path === currentPath) {
|
|
69
|
+
setSelectedMainMenu(mainItem.text);
|
|
70
|
+
setSelectedSubMenuPath(null);
|
|
71
|
+
}
|
|
35
72
|
});
|
|
36
|
-
|
|
73
|
+
handleMenuClose(); // Close open menu if path changes
|
|
74
|
+
}, [location.pathname]);
|
|
37
75
|
const handleMenuOpen = (event, index) => {
|
|
38
76
|
setAnchorEl(event.currentTarget);
|
|
39
|
-
setOpenMenuIndex(index);
|
|
77
|
+
setOpenMenuIndex(index);
|
|
40
78
|
};
|
|
41
79
|
const handleMenuClose = () => {
|
|
42
80
|
setAnchorEl(null);
|
|
@@ -44,42 +82,12 @@ function SideMenu({ useDrawer, SampleMgmtIcon, navigate }) {
|
|
|
44
82
|
};
|
|
45
83
|
const handleSubMenuItemClick = (path, parentText) => {
|
|
46
84
|
setSelectedMainMenu(parentText);
|
|
47
|
-
setSelectedSubMenuPath(path);
|
|
85
|
+
setSelectedSubMenuPath(path);
|
|
48
86
|
handleMenuClose();
|
|
49
|
-
if (isDrawerOpen)
|
|
87
|
+
if (isDrawerOpen)
|
|
50
88
|
toggleDrawer();
|
|
51
|
-
|
|
52
|
-
// navigating through href
|
|
53
|
-
window.location.href = path;
|
|
89
|
+
window.location.href = path; // Maintain microfrontend transition
|
|
54
90
|
};
|
|
55
|
-
const menuItems = [
|
|
56
|
-
{
|
|
57
|
-
text: "Home",
|
|
58
|
-
icon: _jsx(DashboardOutlinedIcon, {}),
|
|
59
|
-
subMenu: [{ text: "Dashboard", path: "/super-site/dashboard" }],
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
text: "Patient Management",
|
|
63
|
-
icon: _jsx(RecentActorsOutlinedIcon, {}),
|
|
64
|
-
subMenu: [
|
|
65
|
-
{ text: "Patient", path: "/patient/patient-listing" },
|
|
66
|
-
{ text: "Family", path: "/patient/family-listing" },
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
text: "Sample Management",
|
|
71
|
-
icon: _jsx(SampleMgmtIcon, {}),
|
|
72
|
-
subMenu: [
|
|
73
|
-
{ text: "Dashboard", path: "/sample/sample-dashboard" },
|
|
74
|
-
{ text: "Sample Listing", path: "/sample/sample-listing" },
|
|
75
|
-
{
|
|
76
|
-
text: "Single Sample Analysis",
|
|
77
|
-
path: "/sample/single-sample-analysis",
|
|
78
|
-
},
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
{ text: "Reports", icon: _jsx(ArticleOutlinedIcon, {}) },
|
|
82
|
-
];
|
|
83
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: {
|
|
84
92
|
width: isDrawerOpen ? 230 : 64,
|
|
85
93
|
flexShrink: 0,
|
|
@@ -90,15 +98,27 @@ function SideMenu({ useDrawer, SampleMgmtIcon, navigate }) {
|
|
|
90
98
|
bottom: "0",
|
|
91
99
|
borderRight: "1px solid #B1BECB",
|
|
92
100
|
},
|
|
93
|
-
}, children: _jsx(List, { children: menuItems.map((item, index) => (_jsxs(React.Fragment, { children: [_jsxs(ListItem, { button: true, selected: selectedMainMenu === item.text, className: selectedMainMenu === item.text ? "selected" : "", onClick: (event) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
}, children: _jsx(List, { children: menuItems.map((item, index) => (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { title: item.text, placement: "right", disableHoverListener: isDrawerOpen, children: _jsxs(ListItem, { button: true, selected: selectedMainMenu === item.text, className: selectedMainMenu === item.text ? "selected" : "", onClick: (event) => {
|
|
102
|
+
if (item.subMenu) {
|
|
103
|
+
if (openMenuIndex === index) {
|
|
104
|
+
handleMenuClose();
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
handleMenuOpen(event, index);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else if (item.path) {
|
|
111
|
+
setSelectedMainMenu(item.text);
|
|
112
|
+
setSelectedSubMenuPath(null);
|
|
113
|
+
if (isDrawerOpen)
|
|
114
|
+
toggleDrawer();
|
|
115
|
+
window.location.href = item.path;
|
|
116
|
+
}
|
|
117
|
+
else if (item.onClick) {
|
|
118
|
+
item.onClick();
|
|
119
|
+
setSelectedMainMenu(item.text);
|
|
120
|
+
}
|
|
121
|
+
}, children: [_jsx(ListItemIcon, { children: item.icon }), isDrawerOpen && _jsx(ListItemText, { primary: item.text })] }) }), item.subMenu && anchorEl && openMenuIndex === index && (_jsxs(Menu, { className: "app-menu-item", anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleMenuClose, anchorOrigin: {
|
|
102
122
|
vertical: "top",
|
|
103
123
|
horizontal: "left",
|
|
104
124
|
}, transformOrigin: {
|