@pdg/react-admin-layout 1.0.32 → 1.0.34
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/CardLayout/CardLayout.d.ts +1 -1
- package/dist/DefaultLayout/DefaultLayout.d.ts +2 -2
- package/dist/DefaultLayout/DefaultLayout.types.d.ts +8 -4
- package/dist/index.esm.js +104 -142
- package/dist/index.js +103 -141
- package/package.json +2 -2
- package/dist/@types/index.d.ts +0 -1
- package/dist/@types/types.d.ts +0 -13
- package/dist/DefaultLayout/DefaultLayout.style.d.ts +0 -17
- package/dist/DefaultLayout/DefaultLayout.types.private.d.ts +0 -9
- package/dist/DefaultLayout/SideMenu/SideMenu.d.ts +0 -4
- package/dist/DefaultLayout/SideMenu/SideMenu.style.d.ts +0 -5
- package/dist/DefaultLayout/SideMenu/SideMenu.types.d.ts +0 -5
- package/dist/DefaultLayout/SideMenu/index.d.ts +0 -4
- package/dist/DefaultLayout/SideMenuList/SideMenuList.d.ts +0 -4
- package/dist/DefaultLayout/SideMenuList/SideMenuList.style.d.ts +0 -4
- package/dist/DefaultLayout/SideMenuList/SideMenuList.types.d.ts +0 -7
- package/dist/DefaultLayout/SideMenuList/index.d.ts +0 -4
- package/dist/DefaultLayout/SideMenuListItem/SideMenuListItem.d.ts +0 -4
- package/dist/DefaultLayout/SideMenuListItem/SideMenuListItem.types.d.ts +0 -7
- package/dist/DefaultLayout/SideMenuListItem/index.d.ts +0 -4
- package/dist/DefaultLayout/Title.d.ts +0 -9
- package/dist/DefaultLayout/Title.style.d.ts +0 -18
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DefaultLayoutProps } from './DefaultLayout.types';
|
|
3
|
-
declare const DefaultLayout: React.
|
|
2
|
+
import { DefaultLayoutProps as Props } from './DefaultLayout.types';
|
|
3
|
+
declare const DefaultLayout: ({ children, logo, badgeVariant, menu, menuHideScreen: initMenuHideScreen, appBarControl, }: Props) => React.JSX.Element;
|
|
4
4
|
export default DefaultLayout;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { CommonSxProps } from '../@types';
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
2
|
import { BadgeProps } from '@mui/material';
|
|
3
|
+
import { SxProps } from '@mui/system';
|
|
4
|
+
import { Theme } from '@mui/material/styles';
|
|
4
5
|
export interface SubMenuItem {
|
|
5
6
|
id: string;
|
|
6
7
|
name: string;
|
|
@@ -19,11 +20,14 @@ export interface MenuItem {
|
|
|
19
20
|
badgeVariant?: BadgeProps['variant'];
|
|
20
21
|
items?: SubMenuItem[];
|
|
21
22
|
}
|
|
22
|
-
export interface DefaultLayoutProps
|
|
23
|
+
export interface DefaultLayoutProps {
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
className?: string;
|
|
26
|
+
style?: CSSProperties;
|
|
27
|
+
sx?: SxProps<Theme>;
|
|
23
28
|
logo: ReactNode;
|
|
24
29
|
badgeVariant?: BadgeProps['variant'];
|
|
25
30
|
menu?: MenuItem[];
|
|
26
31
|
appBarControl?: ReactNode;
|
|
27
32
|
menuHideScreen?: 'xs' | 'sm' | 'md' | 'lg';
|
|
28
|
-
onMenuClick?(menuItem: MenuItem): void;
|
|
29
33
|
}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Grid,
|
|
1
|
+
import {Grid,styled,ListItemIcon,ListItemButton,Icon,ListItemText,Badge,Collapse,List,useTheme,alpha,Box,Toolbar,Typography,AppBar,Drawer,IconButton}from'@mui/material';import React,{useState,useEffect,useMemo}from'react';import {useLocation,useNavigate}from'react-router-dom';import {ExpandMore,Menu}from'@mui/icons-material';import {notEmpty,empty}from'@pdg/util';import SimpleBar from'simplebar-react';function styleInject(css, ref) {
|
|
2
2
|
if ( ref === void 0 ) ref = {};
|
|
3
3
|
var insertAt = ref.insertAt;
|
|
4
4
|
|
|
@@ -28,13 +28,50 @@ styleInject(css_248z);var CardLayout = function (_a) {
|
|
|
28
28
|
var children = _a.children, _b = _a.backgroundColor, backgroundColor = _b === void 0 ? '#eff3f8' : _b;
|
|
29
29
|
return (React.createElement(Grid, { container: true, direction: 'column', alignItems: 'center', justifyContent: 'center', style: { minHeight: '100vh', backgroundColor: backgroundColor } },
|
|
30
30
|
React.createElement(Grid, { item: true, xs: 12 }, children)));
|
|
31
|
-
}
|
|
31
|
+
};/******************************************************************************
|
|
32
|
+
Copyright (c) Microsoft Corporation.
|
|
33
|
+
|
|
34
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
35
|
+
purpose with or without fee is hereby granted.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
38
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
39
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
40
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
41
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
42
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
43
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
44
|
+
***************************************************************************** */
|
|
45
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
var __assign = function() {
|
|
49
|
+
__assign = Object.assign || function __assign(t) {
|
|
50
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
51
|
+
s = arguments[i];
|
|
52
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
53
|
+
}
|
|
54
|
+
return t;
|
|
55
|
+
};
|
|
56
|
+
return __assign.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
function __makeTemplateObject(cooked, raw) {
|
|
60
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
61
|
+
return cooked;
|
|
62
|
+
}
|
|
63
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
64
|
+
var e = new Error(message);
|
|
65
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
66
|
+
};var StyledExpandMore = styled(ExpandMore)(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n margin-top: auto;\n margin-bottom: auto;\n @keyframes open {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(180deg);\n }\n }\n @keyframes close {\n 0% {\n transform: rotate(180deg);\n }\n 100% {\n transform: rotate(0deg);\n }\n }\n"], ["\n margin-top: auto;\n margin-bottom: auto;\n @keyframes open {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(180deg);\n }\n }\n @keyframes close {\n 0% {\n transform: rotate(180deg);\n }\n 100% {\n transform: rotate(0deg);\n }\n }\n"])));
|
|
67
|
+
var StyledListItemIcon = styled(ListItemIcon)(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["\n min-width: 30px;\n"], ["\n min-width: 30px;\n"])));
|
|
68
|
+
var templateObject_1$4, templateObject_2$2;var SideMenuListItem = function (_a) {
|
|
32
69
|
/********************************************************************************************************************
|
|
33
70
|
* Use
|
|
34
71
|
* ******************************************************************************************************************/
|
|
35
|
-
var info = _a.info, badgeVariant = _a.badgeVariant,
|
|
36
|
-
var theme = useTheme();
|
|
72
|
+
var info = _a.info, badgeVariant = _a.badgeVariant, expandedBackgroundColor = _a.expandedBackgroundColor;
|
|
37
73
|
var location = useLocation();
|
|
74
|
+
var navigate = useNavigate();
|
|
38
75
|
/********************************************************************************************************************
|
|
39
76
|
* State
|
|
40
77
|
* ******************************************************************************************************************/
|
|
@@ -44,7 +81,7 @@ styleInject(css_248z);var CardLayout = function (_a) {
|
|
|
44
81
|
* Effect
|
|
45
82
|
* ******************************************************************************************************************/
|
|
46
83
|
useEffect(function () {
|
|
47
|
-
setIsExpandable(
|
|
84
|
+
setIsExpandable(notEmpty(info.items));
|
|
48
85
|
if (info.items && info.items.find(function (info) { return location.pathname === info.uri; })) {
|
|
49
86
|
setIsExpand(true);
|
|
50
87
|
}
|
|
@@ -67,108 +104,44 @@ styleInject(css_248z);var CardLayout = function (_a) {
|
|
|
67
104
|
}
|
|
68
105
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
106
|
}, [location]);
|
|
70
|
-
/********************************************************************************************************************
|
|
71
|
-
* Function
|
|
72
|
-
* ******************************************************************************************************************/
|
|
73
|
-
var toggleIsExpand = useCallback(function () {
|
|
74
|
-
setIsExpand(function (isExpand) { return !isExpand; });
|
|
75
|
-
}, []);
|
|
76
|
-
/********************************************************************************************************************
|
|
77
|
-
* Memo
|
|
78
|
-
* ******************************************************************************************************************/
|
|
79
|
-
var icon = useMemo(function () {
|
|
80
|
-
return info.icon
|
|
81
|
-
? info.icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })
|
|
82
|
-
: undefined;
|
|
83
|
-
}, [info]);
|
|
84
|
-
var containerStyle = useMemo(function () { return ({
|
|
85
|
-
backgroundColor: isExpandable && isExpand
|
|
86
|
-
? alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2)
|
|
87
|
-
: undefined,
|
|
88
|
-
}); }, [isExpand, isExpandable, theme]);
|
|
89
|
-
var expandIconSx = useMemo(function () {
|
|
90
|
-
return isExpandable && isExpand != null
|
|
91
|
-
? {
|
|
92
|
-
marginTop: 'auto',
|
|
93
|
-
marginBottom: 'auto',
|
|
94
|
-
animation: "".concat(isExpand ? 'open' : 'close', " 0.1s linear"),
|
|
95
|
-
transform: "rotate(".concat(isExpand ? 180 : 0, "deg)"),
|
|
96
|
-
'@keyframes open': {
|
|
97
|
-
'0%': {
|
|
98
|
-
transform: "rotate(0deg)",
|
|
99
|
-
},
|
|
100
|
-
'100%': {
|
|
101
|
-
transform: "rotate(180deg)",
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
'@keyframes close': {
|
|
105
|
-
'0%': {
|
|
106
|
-
transform: "rotate(180deg)",
|
|
107
|
-
},
|
|
108
|
-
'100%': {
|
|
109
|
-
transform: "rotate(0deg)",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
}
|
|
113
|
-
: {
|
|
114
|
-
marginTop: 'auto',
|
|
115
|
-
marginBottom: 'auto',
|
|
116
|
-
};
|
|
117
|
-
}, [isExpandable, isExpand]);
|
|
118
|
-
var collapseStyle = useMemo(function () { return ({
|
|
119
|
-
backgroundColor: isExpand
|
|
120
|
-
? alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2)
|
|
121
|
-
: undefined,
|
|
122
|
-
}); }, [isExpand, theme]);
|
|
123
|
-
var primaryTypographyProps = useMemo(function () { return ({ sx: { fontWeight: info.depth === 1 ? 600 : null } }); }, [info]);
|
|
124
107
|
/********************************************************************************************************************
|
|
125
108
|
* Render
|
|
126
109
|
* ******************************************************************************************************************/
|
|
127
110
|
return (React.createElement(React.Fragment, null,
|
|
128
|
-
React.createElement(ListItemButton, { onClick: isExpandable
|
|
129
|
-
?
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, selected: isExpandable ? false : info.uri === location.pathname, style: containerStyle },
|
|
134
|
-
React.createElement(ListItemIcon, { sx: { minWidth: 30 } }, icon && React.createElement(Icon, { fontSize: 'small' }, icon)),
|
|
135
|
-
React.createElement(ListItemText, { primaryTypographyProps: primaryTypographyProps }, info.badge ? (React.createElement(Badge, { badgeContent: info.badge, color: 'error', variant: badgeVariant !== undefined ? badgeVariant : info.badgeVariant, anchorOrigin: { horizontal: 'left', vertical: 'top' }, slotProps: {
|
|
111
|
+
React.createElement(ListItemButton, { onClick: isExpandable ? function () { return setIsExpand(function (old) { return !old; }); } : function () { return info.uri && navigate(info.uri); }, selected: isExpandable ? false : info.uri === location.pathname, style: {
|
|
112
|
+
backgroundColor: isExpandable && isExpand ? expandedBackgroundColor : undefined,
|
|
113
|
+
} },
|
|
114
|
+
React.createElement(StyledListItemIcon, null, info.icon && React.createElement(Icon, { fontSize: 'small' }, info.icon)),
|
|
115
|
+
React.createElement(ListItemText, { primaryTypographyProps: { style: { fontWeight: info.depth === 1 ? 600 : undefined } } }, info.badge ? (React.createElement(Badge, { badgeContent: info.badge, color: 'error', variant: badgeVariant !== undefined ? badgeVariant : info.badgeVariant, anchorOrigin: { horizontal: 'left', vertical: 'top' }, slotProps: {
|
|
136
116
|
badge: { style: { left: '100%', top: '50%', transform: 'scale(.8) translate(10px, -50%)' } },
|
|
137
117
|
} },
|
|
138
118
|
React.createElement("div", null, info.name))) : (info.name)),
|
|
139
|
-
isExpandable && React.createElement(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
147
|
-
purpose with or without fee is hereby granted.
|
|
148
|
-
|
|
149
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
150
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
151
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
152
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
153
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
154
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
155
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
156
|
-
***************************************************************************** */
|
|
157
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
function __makeTemplateObject(cooked, raw) {
|
|
161
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
162
|
-
return cooked;
|
|
163
|
-
}
|
|
164
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
165
|
-
var e = new Error(message);
|
|
166
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
119
|
+
isExpandable && (React.createElement(StyledExpandMore, { sx: {
|
|
120
|
+
animation: "".concat(isExpand ? 'open' : 'close', " 0.1s linear"),
|
|
121
|
+
transform: "rotate(".concat(isExpand ? 180 : 0, "deg)"),
|
|
122
|
+
} }))),
|
|
123
|
+
isExpandable && (React.createElement(Collapse, { in: isExpand, style: { backgroundColor: isExpand ? expandedBackgroundColor : undefined } }, info.items &&
|
|
124
|
+
info.items.map(function (subInfo, idx) { return React.createElement(SideMenuListItem, { key: idx, badgeVariant: badgeVariant, info: subInfo }); })))));
|
|
167
125
|
};var StyledList = styled(List)(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n padding: 0;\n"], ["\n padding: 0;\n"])));
|
|
168
126
|
var templateObject_1$3;var SideMenuList = function (_a) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
127
|
+
/********************************************************************************************************************
|
|
128
|
+
* Use
|
|
129
|
+
* ******************************************************************************************************************/
|
|
130
|
+
var list = _a.list, badgeVariant = _a.badgeVariant;
|
|
131
|
+
var theme = useTheme();
|
|
132
|
+
/********************************************************************************************************************
|
|
133
|
+
* Variable
|
|
134
|
+
* ******************************************************************************************************************/
|
|
135
|
+
var finalList = list.map(function (item) { return (__assign(__assign({}, item), { icon: item.icon
|
|
136
|
+
? item.icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })
|
|
137
|
+
: undefined })); });
|
|
138
|
+
var expandedBackgroundColor = alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2);
|
|
139
|
+
/********************************************************************************************************************
|
|
140
|
+
* Render
|
|
141
|
+
* ******************************************************************************************************************/
|
|
142
|
+
return (React.createElement(StyledList, null, finalList.map(function (info, idx) { return (React.createElement(SideMenuListItem, { key: idx, info: info, badgeVariant: badgeVariant, expandedBackgroundColor: expandedBackgroundColor })); })));
|
|
143
|
+
};
|
|
144
|
+
var SideMenuList$1 = React.memo(SideMenuList);var StyledSimpleBar = styled(SimpleBar)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n max-height: 100%;\n"], ["\n max-height: 100%;\n"])));
|
|
172
145
|
var StyledLogoContainerBox = styled(Box)(function (_a) {
|
|
173
146
|
var theme = _a.theme;
|
|
174
147
|
return theme.unstable_sx({
|
|
@@ -177,12 +150,13 @@ var StyledLogoContainerBox = styled(Box)(function (_a) {
|
|
|
177
150
|
});
|
|
178
151
|
});
|
|
179
152
|
var templateObject_1$2;var SideMenu = function (_a) {
|
|
180
|
-
var logo = _a.logo, badgeVariant = _a.badgeVariant, list = _a.list
|
|
153
|
+
var logo = _a.logo, badgeVariant = _a.badgeVariant, list = _a.list;
|
|
181
154
|
return (React.createElement(StyledSimpleBar, null,
|
|
182
155
|
React.createElement(StyledLogoContainerBox, null,
|
|
183
156
|
React.createElement(Toolbar, null, logo)),
|
|
184
|
-
list && React.createElement(SideMenuList, { badgeVariant: badgeVariant, list: list
|
|
185
|
-
};
|
|
157
|
+
list && React.createElement(SideMenuList$1, { badgeVariant: badgeVariant, list: list })));
|
|
158
|
+
};
|
|
159
|
+
var SideMenu$1 = React.memo(SideMenu);var StyledContainerBox$1 = styled(Box)(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
|
186
160
|
var StyledHeadContainerBox = styled(Box)(function (_a) {
|
|
187
161
|
var theme = _a.theme;
|
|
188
162
|
return theme.unstable_sx({
|
|
@@ -251,7 +225,7 @@ var StyledMainBox = styled(Box)(function (_a) {
|
|
|
251
225
|
});
|
|
252
226
|
});
|
|
253
227
|
var StyledMainContentDiv = styled('div')(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex: 1;\n"], ["\n display: flex;\n flex-direction: column;\n flex: 1;\n"])));
|
|
254
|
-
var templateObject_1, templateObject_2;var
|
|
228
|
+
var templateObject_1, templateObject_2;var SCREENS = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
255
229
|
var _getNextScreen = function (screen) {
|
|
256
230
|
if (screen === 'xs')
|
|
257
231
|
return 'sm';
|
|
@@ -266,15 +240,16 @@ var DefaultLayout = function (_a) {
|
|
|
266
240
|
/********************************************************************************************************************
|
|
267
241
|
* Use
|
|
268
242
|
* ******************************************************************************************************************/
|
|
269
|
-
var
|
|
243
|
+
var _b, _c, _d, _e, _f, _g;
|
|
244
|
+
var children = _a.children, logo = _a.logo, badgeVariant = _a.badgeVariant, menu = _a.menu, initMenuHideScreen = _a.menuHideScreen, appBarControl = _a.appBarControl;
|
|
270
245
|
var location = useLocation();
|
|
271
246
|
/********************************************************************************************************************
|
|
272
247
|
* State
|
|
273
248
|
* ******************************************************************************************************************/
|
|
274
|
-
var
|
|
275
|
-
var
|
|
276
|
-
var
|
|
277
|
-
var
|
|
249
|
+
var _h = useState(false), isMobileOpen = _h[0], setIsMobileOpen = _h[1];
|
|
250
|
+
var _j = useState({}), menuTitles = _j[0], setMenuTitles = _j[1];
|
|
251
|
+
var _k = useState(), title = _k[0], setTitle = _k[1];
|
|
252
|
+
var _l = useState(initMenuHideScreen || 'sm'), menuHideScreen = _l[0], setMenuHideScreen = _l[1];
|
|
278
253
|
/********************************************************************************************************************
|
|
279
254
|
* Effect
|
|
280
255
|
* ******************************************************************************************************************/
|
|
@@ -297,6 +272,9 @@ var DefaultLayout = function (_a) {
|
|
|
297
272
|
useEffect(function () {
|
|
298
273
|
setMenuHideScreen(initMenuHideScreen || 'sm');
|
|
299
274
|
}, [initMenuHideScreen]);
|
|
275
|
+
useEffect(function () {
|
|
276
|
+
setIsMobileOpen(false);
|
|
277
|
+
}, [location]);
|
|
300
278
|
useEffect(function () {
|
|
301
279
|
if (menuTitles) {
|
|
302
280
|
var titleData = menuTitles[location.pathname];
|
|
@@ -311,35 +289,14 @@ var DefaultLayout = function (_a) {
|
|
|
311
289
|
/********************************************************************************************************************
|
|
312
290
|
* Function
|
|
313
291
|
* ******************************************************************************************************************/
|
|
314
|
-
var toggleIsMobileOpen =
|
|
315
|
-
setIsMobileOpen(function (isMobileOpen) { return !isMobileOpen; });
|
|
316
|
-
}, []);
|
|
292
|
+
var toggleIsMobileOpen = function () { return setIsMobileOpen(function (isMobileOpen) { return !isMobileOpen; }); };
|
|
317
293
|
/********************************************************************************************************************
|
|
318
294
|
* Memo
|
|
319
295
|
* ******************************************************************************************************************/
|
|
320
|
-
var appBarSx = useMemo(function () {
|
|
321
|
-
var width = {};
|
|
322
|
-
var ml = {};
|
|
323
|
-
width[_getNextScreen(menuHideScreen)] = "calc(100% - ".concat(SIDE_MENU_WIDTH, "px)");
|
|
324
|
-
ml[_getNextScreen(menuHideScreen)] = "".concat(SIDE_MENU_WIDTH, "px");
|
|
325
|
-
return { width: width, ml: ml };
|
|
326
|
-
}, [menuHideScreen]);
|
|
327
|
-
var appBarIconButtonSx = useMemo(function () {
|
|
328
|
-
var display = {};
|
|
329
|
-
display[_getNextScreen(menuHideScreen)] = 'none';
|
|
330
|
-
return { mr: 2, display: display };
|
|
331
|
-
}, [menuHideScreen]);
|
|
332
|
-
var sideMenuContainerBoxSx = useMemo(function () {
|
|
333
|
-
var width = {};
|
|
334
|
-
var flexShrink = {};
|
|
335
|
-
width[_getNextScreen(menuHideScreen)] = SIDE_MENU_WIDTH;
|
|
336
|
-
flexShrink[_getNextScreen(menuHideScreen)] = 0;
|
|
337
|
-
return { width: width, flexShrink: flexShrink };
|
|
338
|
-
}, [menuHideScreen]);
|
|
339
296
|
var sideMenuTemporaryDrawerSx = useMemo(function () {
|
|
340
297
|
var found = false;
|
|
341
298
|
return {
|
|
342
|
-
display:
|
|
299
|
+
display: SCREENS.reduce(function (res, screen) {
|
|
343
300
|
if (screen === menuHideScreen) {
|
|
344
301
|
found = true;
|
|
345
302
|
res[screen] = 'block';
|
|
@@ -354,7 +311,7 @@ var DefaultLayout = function (_a) {
|
|
|
354
311
|
var sideMenuPermanentDrawerSx = useMemo(function () {
|
|
355
312
|
var found = false;
|
|
356
313
|
return {
|
|
357
|
-
display:
|
|
314
|
+
display: SCREENS.reduce(function (res, screen) {
|
|
358
315
|
if (screen === menuHideScreen) {
|
|
359
316
|
found = true;
|
|
360
317
|
res[screen] = 'none';
|
|
@@ -366,11 +323,20 @@ var DefaultLayout = function (_a) {
|
|
|
366
323
|
}, {}),
|
|
367
324
|
};
|
|
368
325
|
}, [menuHideScreen]);
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
326
|
+
/********************************************************************************************************************
|
|
327
|
+
* Variable
|
|
328
|
+
* ******************************************************************************************************************/
|
|
329
|
+
var nextMenuScreen = _getNextScreen(menuHideScreen);
|
|
330
|
+
var appBarSx = {
|
|
331
|
+
width: (_b = {}, _b[nextMenuScreen] = "calc(100% - ".concat(SIDE_MENU_WIDTH, "px)"), _b),
|
|
332
|
+
ml: (_c = {}, _c[nextMenuScreen] = "".concat(SIDE_MENU_WIDTH, "px"), _c),
|
|
333
|
+
};
|
|
334
|
+
var appBarIconButtonSx = { mr: 2, display: (_d = {}, _d[nextMenuScreen] = 'none', _d) };
|
|
335
|
+
var sideMenuContainerBoxSx = {
|
|
336
|
+
width: (_e = {}, _e[nextMenuScreen] = SIDE_MENU_WIDTH, _e),
|
|
337
|
+
flexShrink: (_f = {}, _f[nextMenuScreen] = 0, _f),
|
|
338
|
+
};
|
|
339
|
+
var mainBoxSx = { width: (_g = {}, _g[nextMenuScreen] = "calc(100% - ".concat(SIDE_MENU_WIDTH, "px)"), _g) };
|
|
374
340
|
/********************************************************************************************************************
|
|
375
341
|
* Render
|
|
376
342
|
* ******************************************************************************************************************/
|
|
@@ -384,12 +350,8 @@ var DefaultLayout = function (_a) {
|
|
|
384
350
|
React.createElement(StyledSideMenuContainerBox, { component: 'nav', "aria-label": 'mailbox folders', sx: sideMenuContainerBoxSx },
|
|
385
351
|
React.createElement(StyledSideMenuTemporaryDrawer, { variant: 'temporary', open: isMobileOpen, onClose: toggleIsMobileOpen, sx: sideMenuTemporaryDrawerSx, ModalProps: {
|
|
386
352
|
keepMounted: true, // Better open performance on mobile.
|
|
387
|
-
} }, menu &&
|
|
388
|
-
|
|
389
|
-
if (onMenuClick)
|
|
390
|
-
onMenuClick(menuItem);
|
|
391
|
-
} }))),
|
|
392
|
-
React.createElement(StyledSideMenuPermanentDrawer, { variant: 'permanent', open: true, sx: sideMenuPermanentDrawerSx }, menu && React.createElement(SideMenu, { logo: logo, badgeVariant: badgeVariant, list: menu, onClick: onMenuClick }))),
|
|
353
|
+
} }, menu && React.createElement(SideMenu$1, { logo: logo, badgeVariant: badgeVariant, list: menu })),
|
|
354
|
+
React.createElement(StyledSideMenuPermanentDrawer, { variant: 'permanent', open: true, sx: sideMenuPermanentDrawerSx }, menu && React.createElement(SideMenu$1, { logo: logo, badgeVariant: badgeVariant, list: menu }))),
|
|
393
355
|
React.createElement(StyledMainBox, { component: 'main', sx: mainBoxSx },
|
|
394
356
|
React.createElement(Toolbar, null),
|
|
395
357
|
React.createElement(StyledMainContentDiv, null, children))));
|
package/dist/index.js
CHANGED
|
@@ -28,13 +28,50 @@ styleInject(css_248z);var CardLayout = function (_a) {
|
|
|
28
28
|
var children = _a.children, _b = _a.backgroundColor, backgroundColor = _b === void 0 ? '#eff3f8' : _b;
|
|
29
29
|
return (React.createElement(material.Grid, { container: true, direction: 'column', alignItems: 'center', justifyContent: 'center', style: { minHeight: '100vh', backgroundColor: backgroundColor } },
|
|
30
30
|
React.createElement(material.Grid, { item: true, xs: 12 }, children)));
|
|
31
|
-
}
|
|
31
|
+
};/******************************************************************************
|
|
32
|
+
Copyright (c) Microsoft Corporation.
|
|
33
|
+
|
|
34
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
35
|
+
purpose with or without fee is hereby granted.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
38
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
39
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
40
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
41
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
42
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
43
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
44
|
+
***************************************************************************** */
|
|
45
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
var __assign = function() {
|
|
49
|
+
__assign = Object.assign || function __assign(t) {
|
|
50
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
51
|
+
s = arguments[i];
|
|
52
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
53
|
+
}
|
|
54
|
+
return t;
|
|
55
|
+
};
|
|
56
|
+
return __assign.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
function __makeTemplateObject(cooked, raw) {
|
|
60
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
61
|
+
return cooked;
|
|
62
|
+
}
|
|
63
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
64
|
+
var e = new Error(message);
|
|
65
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
66
|
+
};var StyledExpandMore = material.styled(iconsMaterial.ExpandMore)(templateObject_1$4 || (templateObject_1$4 = __makeTemplateObject(["\n margin-top: auto;\n margin-bottom: auto;\n @keyframes open {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(180deg);\n }\n }\n @keyframes close {\n 0% {\n transform: rotate(180deg);\n }\n 100% {\n transform: rotate(0deg);\n }\n }\n"], ["\n margin-top: auto;\n margin-bottom: auto;\n @keyframes open {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(180deg);\n }\n }\n @keyframes close {\n 0% {\n transform: rotate(180deg);\n }\n 100% {\n transform: rotate(0deg);\n }\n }\n"])));
|
|
67
|
+
var StyledListItemIcon = material.styled(material.ListItemIcon)(templateObject_2$2 || (templateObject_2$2 = __makeTemplateObject(["\n min-width: 30px;\n"], ["\n min-width: 30px;\n"])));
|
|
68
|
+
var templateObject_1$4, templateObject_2$2;var SideMenuListItem = function (_a) {
|
|
32
69
|
/********************************************************************************************************************
|
|
33
70
|
* Use
|
|
34
71
|
* ******************************************************************************************************************/
|
|
35
|
-
var info = _a.info, badgeVariant = _a.badgeVariant,
|
|
36
|
-
var theme = material.useTheme();
|
|
72
|
+
var info = _a.info, badgeVariant = _a.badgeVariant, expandedBackgroundColor = _a.expandedBackgroundColor;
|
|
37
73
|
var location = reactRouterDom.useLocation();
|
|
74
|
+
var navigate = reactRouterDom.useNavigate();
|
|
38
75
|
/********************************************************************************************************************
|
|
39
76
|
* State
|
|
40
77
|
* ******************************************************************************************************************/
|
|
@@ -44,7 +81,7 @@ styleInject(css_248z);var CardLayout = function (_a) {
|
|
|
44
81
|
* Effect
|
|
45
82
|
* ******************************************************************************************************************/
|
|
46
83
|
React.useEffect(function () {
|
|
47
|
-
setIsExpandable(
|
|
84
|
+
setIsExpandable(util.notEmpty(info.items));
|
|
48
85
|
if (info.items && info.items.find(function (info) { return location.pathname === info.uri; })) {
|
|
49
86
|
setIsExpand(true);
|
|
50
87
|
}
|
|
@@ -67,108 +104,44 @@ styleInject(css_248z);var CardLayout = function (_a) {
|
|
|
67
104
|
}
|
|
68
105
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
69
106
|
}, [location]);
|
|
70
|
-
/********************************************************************************************************************
|
|
71
|
-
* Function
|
|
72
|
-
* ******************************************************************************************************************/
|
|
73
|
-
var toggleIsExpand = React.useCallback(function () {
|
|
74
|
-
setIsExpand(function (isExpand) { return !isExpand; });
|
|
75
|
-
}, []);
|
|
76
|
-
/********************************************************************************************************************
|
|
77
|
-
* Memo
|
|
78
|
-
* ******************************************************************************************************************/
|
|
79
|
-
var icon = React.useMemo(function () {
|
|
80
|
-
return info.icon
|
|
81
|
-
? info.icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })
|
|
82
|
-
: undefined;
|
|
83
|
-
}, [info]);
|
|
84
|
-
var containerStyle = React.useMemo(function () { return ({
|
|
85
|
-
backgroundColor: isExpandable && isExpand
|
|
86
|
-
? material.alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2)
|
|
87
|
-
: undefined,
|
|
88
|
-
}); }, [isExpand, isExpandable, theme]);
|
|
89
|
-
var expandIconSx = React.useMemo(function () {
|
|
90
|
-
return isExpandable && isExpand != null
|
|
91
|
-
? {
|
|
92
|
-
marginTop: 'auto',
|
|
93
|
-
marginBottom: 'auto',
|
|
94
|
-
animation: "".concat(isExpand ? 'open' : 'close', " 0.1s linear"),
|
|
95
|
-
transform: "rotate(".concat(isExpand ? 180 : 0, "deg)"),
|
|
96
|
-
'@keyframes open': {
|
|
97
|
-
'0%': {
|
|
98
|
-
transform: "rotate(0deg)",
|
|
99
|
-
},
|
|
100
|
-
'100%': {
|
|
101
|
-
transform: "rotate(180deg)",
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
'@keyframes close': {
|
|
105
|
-
'0%': {
|
|
106
|
-
transform: "rotate(180deg)",
|
|
107
|
-
},
|
|
108
|
-
'100%': {
|
|
109
|
-
transform: "rotate(0deg)",
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
}
|
|
113
|
-
: {
|
|
114
|
-
marginTop: 'auto',
|
|
115
|
-
marginBottom: 'auto',
|
|
116
|
-
};
|
|
117
|
-
}, [isExpandable, isExpand]);
|
|
118
|
-
var collapseStyle = React.useMemo(function () { return ({
|
|
119
|
-
backgroundColor: isExpand
|
|
120
|
-
? material.alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2)
|
|
121
|
-
: undefined,
|
|
122
|
-
}); }, [isExpand, theme]);
|
|
123
|
-
var primaryTypographyProps = React.useMemo(function () { return ({ sx: { fontWeight: info.depth === 1 ? 600 : null } }); }, [info]);
|
|
124
107
|
/********************************************************************************************************************
|
|
125
108
|
* Render
|
|
126
109
|
* ******************************************************************************************************************/
|
|
127
110
|
return (React.createElement(React.Fragment, null,
|
|
128
|
-
React.createElement(material.ListItemButton, { onClick: isExpandable
|
|
129
|
-
?
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, selected: isExpandable ? false : info.uri === location.pathname, style: containerStyle },
|
|
134
|
-
React.createElement(material.ListItemIcon, { sx: { minWidth: 30 } }, icon && React.createElement(material.Icon, { fontSize: 'small' }, icon)),
|
|
135
|
-
React.createElement(material.ListItemText, { primaryTypographyProps: primaryTypographyProps }, info.badge ? (React.createElement(material.Badge, { badgeContent: info.badge, color: 'error', variant: badgeVariant !== undefined ? badgeVariant : info.badgeVariant, anchorOrigin: { horizontal: 'left', vertical: 'top' }, slotProps: {
|
|
111
|
+
React.createElement(material.ListItemButton, { onClick: isExpandable ? function () { return setIsExpand(function (old) { return !old; }); } : function () { return info.uri && navigate(info.uri); }, selected: isExpandable ? false : info.uri === location.pathname, style: {
|
|
112
|
+
backgroundColor: isExpandable && isExpand ? expandedBackgroundColor : undefined,
|
|
113
|
+
} },
|
|
114
|
+
React.createElement(StyledListItemIcon, null, info.icon && React.createElement(material.Icon, { fontSize: 'small' }, info.icon)),
|
|
115
|
+
React.createElement(material.ListItemText, { primaryTypographyProps: { style: { fontWeight: info.depth === 1 ? 600 : undefined } } }, info.badge ? (React.createElement(material.Badge, { badgeContent: info.badge, color: 'error', variant: badgeVariant !== undefined ? badgeVariant : info.badgeVariant, anchorOrigin: { horizontal: 'left', vertical: 'top' }, slotProps: {
|
|
136
116
|
badge: { style: { left: '100%', top: '50%', transform: 'scale(.8) translate(10px, -50%)' } },
|
|
137
117
|
} },
|
|
138
118
|
React.createElement("div", null, info.name))) : (info.name)),
|
|
139
|
-
isExpandable && React.createElement(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
147
|
-
purpose with or without fee is hereby granted.
|
|
148
|
-
|
|
149
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
150
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
151
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
152
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
153
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
154
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
155
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
156
|
-
***************************************************************************** */
|
|
157
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
function __makeTemplateObject(cooked, raw) {
|
|
161
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
162
|
-
return cooked;
|
|
163
|
-
}
|
|
164
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
165
|
-
var e = new Error(message);
|
|
166
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
119
|
+
isExpandable && (React.createElement(StyledExpandMore, { sx: {
|
|
120
|
+
animation: "".concat(isExpand ? 'open' : 'close', " 0.1s linear"),
|
|
121
|
+
transform: "rotate(".concat(isExpand ? 180 : 0, "deg)"),
|
|
122
|
+
} }))),
|
|
123
|
+
isExpandable && (React.createElement(material.Collapse, { in: isExpand, style: { backgroundColor: isExpand ? expandedBackgroundColor : undefined } }, info.items &&
|
|
124
|
+
info.items.map(function (subInfo, idx) { return React.createElement(SideMenuListItem, { key: idx, badgeVariant: badgeVariant, info: subInfo }); })))));
|
|
167
125
|
};var StyledList = material.styled(material.List)(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n padding: 0;\n"], ["\n padding: 0;\n"])));
|
|
168
126
|
var templateObject_1$3;var SideMenuList = function (_a) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
127
|
+
/********************************************************************************************************************
|
|
128
|
+
* Use
|
|
129
|
+
* ******************************************************************************************************************/
|
|
130
|
+
var list = _a.list, badgeVariant = _a.badgeVariant;
|
|
131
|
+
var theme = material.useTheme();
|
|
132
|
+
/********************************************************************************************************************
|
|
133
|
+
* Variable
|
|
134
|
+
* ******************************************************************************************************************/
|
|
135
|
+
var finalList = list.map(function (item) { return (__assign(__assign({}, item), { icon: item.icon
|
|
136
|
+
? item.icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })
|
|
137
|
+
: undefined })); });
|
|
138
|
+
var expandedBackgroundColor = material.alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2);
|
|
139
|
+
/********************************************************************************************************************
|
|
140
|
+
* Render
|
|
141
|
+
* ******************************************************************************************************************/
|
|
142
|
+
return (React.createElement(StyledList, null, finalList.map(function (info, idx) { return (React.createElement(SideMenuListItem, { key: idx, info: info, badgeVariant: badgeVariant, expandedBackgroundColor: expandedBackgroundColor })); })));
|
|
143
|
+
};
|
|
144
|
+
var SideMenuList$1 = React.memo(SideMenuList);var StyledSimpleBar = material.styled(SimpleBar)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n max-height: 100%;\n"], ["\n max-height: 100%;\n"])));
|
|
172
145
|
var StyledLogoContainerBox = material.styled(material.Box)(function (_a) {
|
|
173
146
|
var theme = _a.theme;
|
|
174
147
|
return theme.unstable_sx({
|
|
@@ -177,12 +150,13 @@ var StyledLogoContainerBox = material.styled(material.Box)(function (_a) {
|
|
|
177
150
|
});
|
|
178
151
|
});
|
|
179
152
|
var templateObject_1$2;var SideMenu = function (_a) {
|
|
180
|
-
var logo = _a.logo, badgeVariant = _a.badgeVariant, list = _a.list
|
|
153
|
+
var logo = _a.logo, badgeVariant = _a.badgeVariant, list = _a.list;
|
|
181
154
|
return (React.createElement(StyledSimpleBar, null,
|
|
182
155
|
React.createElement(StyledLogoContainerBox, null,
|
|
183
156
|
React.createElement(material.Toolbar, null, logo)),
|
|
184
|
-
list && React.createElement(SideMenuList, { badgeVariant: badgeVariant, list: list
|
|
185
|
-
};
|
|
157
|
+
list && React.createElement(SideMenuList$1, { badgeVariant: badgeVariant, list: list })));
|
|
158
|
+
};
|
|
159
|
+
var SideMenu$1 = React.memo(SideMenu);var StyledContainerBox$1 = material.styled(material.Box)(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
|
|
186
160
|
var StyledHeadContainerBox = material.styled(material.Box)(function (_a) {
|
|
187
161
|
var theme = _a.theme;
|
|
188
162
|
return theme.unstable_sx({
|
|
@@ -251,7 +225,7 @@ var StyledMainBox = material.styled(material.Box)(function (_a) {
|
|
|
251
225
|
});
|
|
252
226
|
});
|
|
253
227
|
var StyledMainContentDiv = material.styled('div')(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n flex: 1;\n"], ["\n display: flex;\n flex-direction: column;\n flex: 1;\n"])));
|
|
254
|
-
var templateObject_1, templateObject_2;var
|
|
228
|
+
var templateObject_1, templateObject_2;var SCREENS = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
255
229
|
var _getNextScreen = function (screen) {
|
|
256
230
|
if (screen === 'xs')
|
|
257
231
|
return 'sm';
|
|
@@ -266,15 +240,16 @@ var DefaultLayout = function (_a) {
|
|
|
266
240
|
/********************************************************************************************************************
|
|
267
241
|
* Use
|
|
268
242
|
* ******************************************************************************************************************/
|
|
269
|
-
var
|
|
243
|
+
var _b, _c, _d, _e, _f, _g;
|
|
244
|
+
var children = _a.children, logo = _a.logo, badgeVariant = _a.badgeVariant, menu = _a.menu, initMenuHideScreen = _a.menuHideScreen, appBarControl = _a.appBarControl;
|
|
270
245
|
var location = reactRouterDom.useLocation();
|
|
271
246
|
/********************************************************************************************************************
|
|
272
247
|
* State
|
|
273
248
|
* ******************************************************************************************************************/
|
|
274
|
-
var
|
|
275
|
-
var
|
|
276
|
-
var
|
|
277
|
-
var
|
|
249
|
+
var _h = React.useState(false), isMobileOpen = _h[0], setIsMobileOpen = _h[1];
|
|
250
|
+
var _j = React.useState({}), menuTitles = _j[0], setMenuTitles = _j[1];
|
|
251
|
+
var _k = React.useState(), title = _k[0], setTitle = _k[1];
|
|
252
|
+
var _l = React.useState(initMenuHideScreen || 'sm'), menuHideScreen = _l[0], setMenuHideScreen = _l[1];
|
|
278
253
|
/********************************************************************************************************************
|
|
279
254
|
* Effect
|
|
280
255
|
* ******************************************************************************************************************/
|
|
@@ -297,6 +272,9 @@ var DefaultLayout = function (_a) {
|
|
|
297
272
|
React.useEffect(function () {
|
|
298
273
|
setMenuHideScreen(initMenuHideScreen || 'sm');
|
|
299
274
|
}, [initMenuHideScreen]);
|
|
275
|
+
React.useEffect(function () {
|
|
276
|
+
setIsMobileOpen(false);
|
|
277
|
+
}, [location]);
|
|
300
278
|
React.useEffect(function () {
|
|
301
279
|
if (menuTitles) {
|
|
302
280
|
var titleData = menuTitles[location.pathname];
|
|
@@ -311,35 +289,14 @@ var DefaultLayout = function (_a) {
|
|
|
311
289
|
/********************************************************************************************************************
|
|
312
290
|
* Function
|
|
313
291
|
* ******************************************************************************************************************/
|
|
314
|
-
var toggleIsMobileOpen =
|
|
315
|
-
setIsMobileOpen(function (isMobileOpen) { return !isMobileOpen; });
|
|
316
|
-
}, []);
|
|
292
|
+
var toggleIsMobileOpen = function () { return setIsMobileOpen(function (isMobileOpen) { return !isMobileOpen; }); };
|
|
317
293
|
/********************************************************************************************************************
|
|
318
294
|
* Memo
|
|
319
295
|
* ******************************************************************************************************************/
|
|
320
|
-
var appBarSx = React.useMemo(function () {
|
|
321
|
-
var width = {};
|
|
322
|
-
var ml = {};
|
|
323
|
-
width[_getNextScreen(menuHideScreen)] = "calc(100% - ".concat(SIDE_MENU_WIDTH, "px)");
|
|
324
|
-
ml[_getNextScreen(menuHideScreen)] = "".concat(SIDE_MENU_WIDTH, "px");
|
|
325
|
-
return { width: width, ml: ml };
|
|
326
|
-
}, [menuHideScreen]);
|
|
327
|
-
var appBarIconButtonSx = React.useMemo(function () {
|
|
328
|
-
var display = {};
|
|
329
|
-
display[_getNextScreen(menuHideScreen)] = 'none';
|
|
330
|
-
return { mr: 2, display: display };
|
|
331
|
-
}, [menuHideScreen]);
|
|
332
|
-
var sideMenuContainerBoxSx = React.useMemo(function () {
|
|
333
|
-
var width = {};
|
|
334
|
-
var flexShrink = {};
|
|
335
|
-
width[_getNextScreen(menuHideScreen)] = SIDE_MENU_WIDTH;
|
|
336
|
-
flexShrink[_getNextScreen(menuHideScreen)] = 0;
|
|
337
|
-
return { width: width, flexShrink: flexShrink };
|
|
338
|
-
}, [menuHideScreen]);
|
|
339
296
|
var sideMenuTemporaryDrawerSx = React.useMemo(function () {
|
|
340
297
|
var found = false;
|
|
341
298
|
return {
|
|
342
|
-
display:
|
|
299
|
+
display: SCREENS.reduce(function (res, screen) {
|
|
343
300
|
if (screen === menuHideScreen) {
|
|
344
301
|
found = true;
|
|
345
302
|
res[screen] = 'block';
|
|
@@ -354,7 +311,7 @@ var DefaultLayout = function (_a) {
|
|
|
354
311
|
var sideMenuPermanentDrawerSx = React.useMemo(function () {
|
|
355
312
|
var found = false;
|
|
356
313
|
return {
|
|
357
|
-
display:
|
|
314
|
+
display: SCREENS.reduce(function (res, screen) {
|
|
358
315
|
if (screen === menuHideScreen) {
|
|
359
316
|
found = true;
|
|
360
317
|
res[screen] = 'none';
|
|
@@ -366,11 +323,20 @@ var DefaultLayout = function (_a) {
|
|
|
366
323
|
}, {}),
|
|
367
324
|
};
|
|
368
325
|
}, [menuHideScreen]);
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
326
|
+
/********************************************************************************************************************
|
|
327
|
+
* Variable
|
|
328
|
+
* ******************************************************************************************************************/
|
|
329
|
+
var nextMenuScreen = _getNextScreen(menuHideScreen);
|
|
330
|
+
var appBarSx = {
|
|
331
|
+
width: (_b = {}, _b[nextMenuScreen] = "calc(100% - ".concat(SIDE_MENU_WIDTH, "px)"), _b),
|
|
332
|
+
ml: (_c = {}, _c[nextMenuScreen] = "".concat(SIDE_MENU_WIDTH, "px"), _c),
|
|
333
|
+
};
|
|
334
|
+
var appBarIconButtonSx = { mr: 2, display: (_d = {}, _d[nextMenuScreen] = 'none', _d) };
|
|
335
|
+
var sideMenuContainerBoxSx = {
|
|
336
|
+
width: (_e = {}, _e[nextMenuScreen] = SIDE_MENU_WIDTH, _e),
|
|
337
|
+
flexShrink: (_f = {}, _f[nextMenuScreen] = 0, _f),
|
|
338
|
+
};
|
|
339
|
+
var mainBoxSx = { width: (_g = {}, _g[nextMenuScreen] = "calc(100% - ".concat(SIDE_MENU_WIDTH, "px)"), _g) };
|
|
374
340
|
/********************************************************************************************************************
|
|
375
341
|
* Render
|
|
376
342
|
* ******************************************************************************************************************/
|
|
@@ -384,12 +350,8 @@ var DefaultLayout = function (_a) {
|
|
|
384
350
|
React.createElement(StyledSideMenuContainerBox, { component: 'nav', "aria-label": 'mailbox folders', sx: sideMenuContainerBoxSx },
|
|
385
351
|
React.createElement(StyledSideMenuTemporaryDrawer, { variant: 'temporary', open: isMobileOpen, onClose: toggleIsMobileOpen, sx: sideMenuTemporaryDrawerSx, ModalProps: {
|
|
386
352
|
keepMounted: true, // Better open performance on mobile.
|
|
387
|
-
} }, menu &&
|
|
388
|
-
|
|
389
|
-
if (onMenuClick)
|
|
390
|
-
onMenuClick(menuItem);
|
|
391
|
-
} }))),
|
|
392
|
-
React.createElement(StyledSideMenuPermanentDrawer, { variant: 'permanent', open: true, sx: sideMenuPermanentDrawerSx }, menu && React.createElement(SideMenu, { logo: logo, badgeVariant: badgeVariant, list: menu, onClick: onMenuClick }))),
|
|
353
|
+
} }, menu && React.createElement(SideMenu$1, { logo: logo, badgeVariant: badgeVariant, list: menu })),
|
|
354
|
+
React.createElement(StyledSideMenuPermanentDrawer, { variant: 'permanent', open: true, sx: sideMenuPermanentDrawerSx }, menu && React.createElement(SideMenu$1, { logo: logo, badgeVariant: badgeVariant, list: menu }))),
|
|
393
355
|
React.createElement(StyledMainBox, { component: 'main', sx: mainBoxSx },
|
|
394
356
|
React.createElement(material.Toolbar, null),
|
|
395
357
|
React.createElement(StyledMainContentDiv, null, children))));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdg/react-admin-layout",
|
|
3
3
|
"title": "React Admin Layout",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.34",
|
|
5
5
|
"description": "Admin Layout for React",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@emotion/styled": "^11.11.5",
|
|
47
47
|
"@mui/icons-material": "^5.15.16",
|
|
48
48
|
"@mui/material": "^5.15.16",
|
|
49
|
-
"@pdg/util": "^1.0.
|
|
49
|
+
"@pdg/util": "^1.0.21",
|
|
50
50
|
"@types/react": "^17.0.0 || ^18.0.0",
|
|
51
51
|
"react": "^17.0.0 || ^18.0.0",
|
|
52
52
|
"react-dom": "^17.0.0 || ^18.0.0",
|
package/dist/@types/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
package/dist/@types/types.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
-
import { SxProps } from '@mui/system';
|
|
3
|
-
import { Theme } from '@mui/material/styles';
|
|
4
|
-
export type PartialPick<T, K extends keyof T> = Partial<Pick<T, K>>;
|
|
5
|
-
export type PartialOmit<T, K extends keyof T> = Partial<Omit<T, K>>;
|
|
6
|
-
export interface CommonProps {
|
|
7
|
-
children?: ReactNode;
|
|
8
|
-
className?: string;
|
|
9
|
-
style?: CSSProperties;
|
|
10
|
-
}
|
|
11
|
-
export interface CommonSxProps extends CommonProps {
|
|
12
|
-
sx?: SxProps<Theme>;
|
|
13
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const SIDE_MENU_WIDTH = 220;
|
|
3
|
-
export declare const StyledContainerBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
4
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
5
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
6
|
-
export declare const StyledAppBar: import("@emotion/styled").StyledComponent<import("@mui/material").AppBarOwnProps & Omit<import("@mui/material").PaperOwnProps, "color" | "position" | "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & {
|
|
7
|
-
ref?: ((instance: HTMLElement | null) => void) | import("react").RefObject<HTMLElement> | null | undefined;
|
|
8
|
-
}, "style" | "className" | "color" | "children" | "position" | "sx" | "classes" | "elevation" | "square" | "variant" | "enableColorOnDark"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
9
|
-
export declare const StyledSideMenuContainerBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
10
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
11
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
12
|
-
export declare const StyledSideMenuTemporaryDrawer: import("@emotion/styled").StyledComponent<import("@mui/material").DrawerProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
13
|
-
export declare const StyledSideMenuPermanentDrawer: import("@emotion/styled").StyledComponent<import("@mui/material").DrawerProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
14
|
-
export declare const StyledMainBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
15
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
16
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
17
|
-
export declare const StyledMainContentDiv: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const StyledSimpleBar: import("@emotion/styled").StyledComponent<import("simplebar-react").Props & import("react").RefAttributes<import("simplebar-core").default | null> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
3
|
-
export declare const StyledLogoContainerBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
4
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
5
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const StyledList: import("@emotion/styled").StyledComponent<import("@mui/material").ListOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & {
|
|
3
|
-
ref?: ((instance: HTMLUListElement | null) => void) | import("react").RefObject<HTMLUListElement> | null | undefined;
|
|
4
|
-
}, "className" | "style" | "classes" | "children" | "dense" | "disablePadding" | "subheader" | "sx"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export declare const StyledContainerBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
3
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
4
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
5
|
-
export declare const StyledHeadContainerBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
6
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
7
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
8
|
-
export declare const StyledHeadIconContainerBox: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
9
|
-
ref?: ((instance: HTMLDivElement | null) => void) | import("react").RefObject<HTMLDivElement> | null | undefined;
|
|
10
|
-
}, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
11
|
-
export declare const StyledHeadIcon: import("@emotion/styled").StyledComponent<import("@mui/material").IconOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
12
|
-
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
13
|
-
}, "style" | "className" | "color" | "children" | "fontSize" | "sx" | "classes" | "baseClassName"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
14
|
-
export declare const StyledHeadTitleTypography: import("@emotion/styled").StyledComponent<import("@mui/material").TypographyOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
15
|
-
ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
|
|
16
|
-
}, "p" | "style" | "className" | "color" | "children" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform" | "sx" | "classes" | "align" | "gutterBottom" | "noWrap" | "paragraph" | "variant" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
|
|
17
|
-
export declare const StyledTitleContainerDiv: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
18
|
-
export declare const StyledTitleIconContainerDiv: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|