@campxdev/react-blueprint 2.2.1 → 2.2.2
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/cjs/index.js +1 -1
- package/dist/cjs/types/src/components/Layout/AppLayout/components/Sidebar/interfaces.d.ts +2 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/types/src/components/Layout/AppLayout/components/Sidebar/interfaces.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/DataDisplay/Card/Card.tsx +2 -1
- package/src/components/Layout/AppLayout/components/SideDrawer.tsx +1 -0
- package/src/components/Layout/AppLayout/components/Sidebar/MenuBar.tsx +2 -2
- package/src/components/Layout/AppLayout/components/Sidebar/MenuItem.tsx +28 -3
- package/src/components/Layout/AppLayout/components/Sidebar/interfaces.ts +2 -0
|
@@ -39,6 +39,7 @@ export interface MenuItemProps {
|
|
|
39
39
|
menuItem: SideMenuItemProps;
|
|
40
40
|
currentMenuPath: string | null;
|
|
41
41
|
internalMenuClickHandler: (params: InternalMenuClickHandlerProps) => void;
|
|
42
|
+
onClose?: () => void;
|
|
42
43
|
}
|
|
43
44
|
export interface SubMenuItemProps {
|
|
44
45
|
index: number;
|
|
@@ -50,4 +51,5 @@ export interface MenuBarProps {
|
|
|
50
51
|
menuPosition: number;
|
|
51
52
|
internalMenuClickHandler: (params: InternalMenuClickHandlerProps) => void;
|
|
52
53
|
previousMenuClickHandler: () => void;
|
|
54
|
+
onClose?: () => void;
|
|
53
55
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
} from '@mui/material';
|
|
10
10
|
import { TypographyVariant as Variant } from '@mui/material/styles';
|
|
11
11
|
import { ReactNode } from 'react';
|
|
12
|
-
import { DropDownIcon
|
|
12
|
+
import { DropDownIcon } from '../../Navigation/DropDownMenu/DropDownIcon';
|
|
13
|
+
import { DropdownMenu } from '../../Navigation/DropDownMenu/DropDownMenu';
|
|
13
14
|
import {
|
|
14
15
|
StyledButton,
|
|
15
16
|
StyledCardActions,
|
|
@@ -95,6 +95,7 @@ export const SideDrawer: React.FC<SideDrawerProps> = ({
|
|
|
95
95
|
menuPosition={navigation.menuPosition}
|
|
96
96
|
internalMenuClickHandler={navigation.internalMenuClickHandler}
|
|
97
97
|
previousMenuClickHandler={navigation.previousMenuClickHandler}
|
|
98
|
+
onClose={onClose}
|
|
98
99
|
/>
|
|
99
100
|
</motion.div>
|
|
100
101
|
</Drawer>
|
|
@@ -22,10 +22,10 @@ export const MenuBar: React.FC<MenuBarProps> = ({
|
|
|
22
22
|
menuPosition,
|
|
23
23
|
internalMenuClickHandler,
|
|
24
24
|
previousMenuClickHandler,
|
|
25
|
+
onClose,
|
|
25
26
|
}) => {
|
|
26
27
|
return (
|
|
27
28
|
<MenuBarContainer>
|
|
28
|
-
{/* Menu Header with Back Button */}
|
|
29
29
|
{currentMenuState.title && (
|
|
30
30
|
<MenuHeaderContainer
|
|
31
31
|
direction="row"
|
|
@@ -39,7 +39,6 @@ export const MenuBar: React.FC<MenuBarProps> = ({
|
|
|
39
39
|
</MenuHeaderContainer>
|
|
40
40
|
)}
|
|
41
41
|
|
|
42
|
-
{/* Menu Items */}
|
|
43
42
|
{currentMenuState.menu && currentMenuState.menu.length > 0 && (
|
|
44
43
|
<motion.div
|
|
45
44
|
variants={containerVariants}
|
|
@@ -53,6 +52,7 @@ export const MenuBar: React.FC<MenuBarProps> = ({
|
|
|
53
52
|
menuItem={item}
|
|
54
53
|
currentMenuPath={currentMenuState.path}
|
|
55
54
|
internalMenuClickHandler={internalMenuClickHandler}
|
|
55
|
+
onClose={onClose}
|
|
56
56
|
/>
|
|
57
57
|
))}
|
|
58
58
|
</motion.div>
|
|
@@ -20,6 +20,7 @@ export const MenuItem: React.FC<MenuItemProps> = ({
|
|
|
20
20
|
menuItem,
|
|
21
21
|
currentMenuPath,
|
|
22
22
|
internalMenuClickHandler,
|
|
23
|
+
onClose,
|
|
23
24
|
}) => {
|
|
24
25
|
const { name, path, icon, menu: internalMenu, subMenu } = menuItem;
|
|
25
26
|
const newPath = currentMenuPath ? `${currentMenuPath}${path}` : path;
|
|
@@ -38,6 +39,21 @@ export const MenuItem: React.FC<MenuItemProps> = ({
|
|
|
38
39
|
});
|
|
39
40
|
};
|
|
40
41
|
|
|
42
|
+
// Smart drawer closing logic
|
|
43
|
+
const shouldCloseDrawer = (item: typeof menuItem) => {
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// For desktop, only close if it's a leaf node (no children)
|
|
48
|
+
return !item.menu && !item.subMenu;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const handleNavigationClick = () => {
|
|
52
|
+
if (shouldCloseDrawer(menuItem) && onClose) {
|
|
53
|
+
onClose();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
41
57
|
// Internal menu item (has nested menu)
|
|
42
58
|
if (internalMenu && internalMenu.length > 0) {
|
|
43
59
|
return (
|
|
@@ -110,6 +126,7 @@ export const MenuItem: React.FC<MenuItemProps> = ({
|
|
|
110
126
|
index={subIndex}
|
|
111
127
|
subMenuItem={item}
|
|
112
128
|
subMenuButtonPath={newPath}
|
|
129
|
+
onClose={onClose}
|
|
113
130
|
/>
|
|
114
131
|
))}
|
|
115
132
|
</SubMenuItemContainer>
|
|
@@ -128,7 +145,7 @@ export const MenuItem: React.FC<MenuItemProps> = ({
|
|
|
128
145
|
transition={{ duration: 1 }}
|
|
129
146
|
>
|
|
130
147
|
<MenuItemContainer disablePadding>
|
|
131
|
-
<MenuLink to={newPath} match={match}>
|
|
148
|
+
<MenuLink to={newPath} match={match} onClick={handleNavigationClick}>
|
|
132
149
|
<MenuItemButton>
|
|
133
150
|
<MenuItemIcon>{icon}</MenuItemIcon>
|
|
134
151
|
<Typography variant="button1">{name}</Typography>
|
|
@@ -144,16 +161,24 @@ const SubMenuItem: React.FC<{
|
|
|
144
161
|
index: number;
|
|
145
162
|
subMenuItem: { name: string; path: string };
|
|
146
163
|
subMenuButtonPath: string;
|
|
147
|
-
|
|
164
|
+
onClose?: () => void;
|
|
165
|
+
}> = ({ index, subMenuItem, subMenuButtonPath, onClose }) => {
|
|
148
166
|
const { name, path } = subMenuItem;
|
|
149
167
|
const newPath = `${subMenuButtonPath}${path}`;
|
|
150
168
|
|
|
151
169
|
const resolved = useResolvedPath(newPath);
|
|
152
170
|
const match = useMatch({ path: resolved.pathname, end: false });
|
|
153
171
|
|
|
172
|
+
const handleSubMenuNavigationClick = () => {
|
|
173
|
+
// Always close drawer for submenu items (they are leaf nodes)
|
|
174
|
+
if (onClose) {
|
|
175
|
+
onClose();
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
154
179
|
return (
|
|
155
180
|
<MenuItemContainer key={index} disablePadding>
|
|
156
|
-
<MenuLink to={newPath} match={match} sx={{ margin: '5px 8px 5px 16px' }}>
|
|
181
|
+
<MenuLink to={newPath} match={match} sx={{ margin: '5px 8px 5px 16px' }} onClick={handleSubMenuNavigationClick}>
|
|
157
182
|
<MenuItemButton>
|
|
158
183
|
<Typography variant="button1">{name}</Typography>
|
|
159
184
|
</MenuItemButton>
|
|
@@ -47,6 +47,7 @@ export interface MenuItemProps {
|
|
|
47
47
|
menuItem: SideMenuItemProps;
|
|
48
48
|
currentMenuPath: string | null;
|
|
49
49
|
internalMenuClickHandler: (params: InternalMenuClickHandlerProps) => void;
|
|
50
|
+
onClose?: () => void; // Optional callback to close the drawer
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
export interface SubMenuItemProps {
|
|
@@ -60,4 +61,5 @@ export interface MenuBarProps {
|
|
|
60
61
|
menuPosition: number;
|
|
61
62
|
internalMenuClickHandler: (params: InternalMenuClickHandlerProps) => void;
|
|
62
63
|
previousMenuClickHandler: () => void;
|
|
64
|
+
onClose?: () => void; // Optional callback to close the drawer
|
|
63
65
|
}
|