@pdg/react-admin-layout 1.0.7 → 1.0.8

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.esm.js CHANGED
@@ -1,4 +1,11 @@
1
- import {Grid,Card,useTheme,ListItemButton,alpha,ListItemIcon,Icon,ListItemText,Collapse,List,Box,Toolbar,Typography,AppBar,IconButton,Drawer}from'@mui/material';import React,{useRef,useEffect,useState}from'react';import {ExpandMore,Menu}from'@mui/icons-material';/******************************************************************************
1
+ import {Grid,useTheme,alpha,ListItemButton,ListItemIcon,Icon,ListItemText,Collapse,styled,List,Box,Toolbar,Typography,AppBar,Drawer,IconButton}from'@mui/material';import React,{useState,useEffect,useCallback,useMemo,useRef}from'react';import {useLocation}from'react-router-dom';import {ExpandMore,Menu}from'@mui/icons-material';var CardLayoutDefaultProps = {
2
+ backgroundColor: '#eff3f8',
3
+ };var CardLayout = function (_a) {
4
+ var children = _a.children, backgroundColor = _a.backgroundColor;
5
+ return (React.createElement(Grid, { container: true, direction: 'column', alignItems: 'center', justifyContent: 'center', style: { minHeight: '100vh', backgroundColor: backgroundColor } },
6
+ React.createElement(Grid, { item: true, xs: 12 }, children)));
7
+ };
8
+ CardLayout.defaultProps = CardLayoutDefaultProps;/******************************************************************************
2
9
  Copyright (c) Microsoft Corporation.
3
10
 
4
11
  Permission to use, copy, modify, and/or distribute this software for any
@@ -13,38 +20,131 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
20
  PERFORMANCE OF THIS SOFTWARE.
14
21
  ***************************************************************************** */
15
22
 
16
- var __assign = function() {
17
- __assign = Object.assign || function __assign(t) {
18
- for (var s, i = 1, n = arguments.length; i < n; i++) {
19
- s = arguments[i];
20
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
23
+ function __makeTemplateObject(cooked, raw) {
24
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
25
+ return cooked;
26
+ }var empty$1 = function (v) {
27
+ var result = false;
28
+ if (v == null) {
29
+ result = true;
30
+ }
31
+ else if (typeof v === 'string') {
32
+ result = v === '';
33
+ }
34
+ else if (typeof v === 'object') {
35
+ if (Array.isArray(v)) {
36
+ result = v.length === 0;
21
37
  }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
-
27
- function __rest(s, e) {
28
- var t = {};
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
30
- t[p] = s[p];
31
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
32
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
33
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
34
- t[p[i]] = s[p[i]];
38
+ else if (!(v instanceof Date)) {
39
+ result = Object.entries(v).length === 0;
35
40
  }
36
- return t;
37
- }var CardLayoutDefaultProps = {
38
- backgroundColor: '#eff3f8',
39
- };var CardLayout = function (_a) {
40
- var children = _a.children, backgroundColor = _a.backgroundColor, otherProps = __rest(_a, ["children", "backgroundColor"]);
41
- return (React.createElement(Grid, { container: true, direction: 'column', justifyContent: 'flex-end', sx: { minHeight: '100vh', backgroundColor: backgroundColor } },
42
- React.createElement(Grid, { item: true, xs: 12 },
43
- React.createElement(Grid, { container: true, justifyContent: 'center', alignItems: 'center', sx: { minHeight: 'calc(100vh - 68px)' } },
44
- React.createElement(Grid, { item: true, sx: { m: { xs: 1, sm: 3 }, mb: 0 } },
45
- React.createElement(Card, __assign({}, otherProps), children))))));
41
+ }
42
+ return result;
46
43
  };
47
- CardLayout.defaultProps = CardLayoutDefaultProps;var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};var propTypes = {exports: {}};var reactIs = {exports: {}};var reactIs_production_min = {};/** @license React v16.13.1
44
+ var notEmpty = function (v) {
45
+ return !empty$1(v);
46
+ };var SideMenuListItem = function (_a) {
47
+ var info = _a.info, onClick = _a.onClick;
48
+ var theme = useTheme();
49
+ var location = useLocation();
50
+ // -------------------------------------------------------------------------------------------------------------------
51
+ var _b = useState(false), isExpandable = _b[0], setIsExpandable = _b[1];
52
+ var _c = useState(false), isExpand = _c[0], setIsExpand = _c[1];
53
+ // -------------------------------------------------------------------------------------------------------------------
54
+ useEffect(function () {
55
+ setIsExpandable(!!info && notEmpty(info.items));
56
+ if (info.items && info.items.find(function (info) { return location.pathname === info.uri; })) {
57
+ setIsExpand(true);
58
+ }
59
+ // eslint-disable-next-line react-hooks/exhaustive-deps
60
+ }, [info]);
61
+ useEffect(function () {
62
+ if (isExpandable && isExpand != null) {
63
+ if (info.uri !== location.pathname) {
64
+ if (info.items && !info.items.find(function (info) { return location.pathname === info.uri; })) {
65
+ if (isExpand) {
66
+ setIsExpand(false);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ if (isExpandable && !isExpand) {
72
+ if (info.items && info.items.find(function (info) { return location.pathname === info.uri; })) {
73
+ setIsExpand(true);
74
+ }
75
+ }
76
+ // eslint-disable-next-line react-hooks/exhaustive-deps
77
+ }, [location]);
78
+ // -------------------------------------------------------------------------------------------------------------------
79
+ var toggleIsExpand = useCallback(function () {
80
+ setIsExpand(function (isExpand) { return !isExpand; });
81
+ }, []);
82
+ // -------------------------------------------------------------------------------------------------------------------
83
+ var icon = useMemo(function () {
84
+ return info.icon
85
+ ? info.icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })
86
+ : undefined;
87
+ }, [info]);
88
+ // -------------------------------------------------------------------------------------------------------------------
89
+ var containerStyle = useMemo(function () { return ({
90
+ backgroundColor: isExpandable && isExpand
91
+ ? alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2)
92
+ : undefined,
93
+ }); }, [isExpand, isExpandable, theme]);
94
+ var expandIconSx = useMemo(function () {
95
+ return isExpandable && isExpand != null
96
+ ? {
97
+ marginTop: 'auto',
98
+ marginBottom: 'auto',
99
+ animation: "".concat(isExpand ? 'open' : 'close', " 0.1s linear"),
100
+ transform: "rotate(".concat(isExpand ? 180 : 0, "deg)"),
101
+ '@keyframes open': {
102
+ '0%': {
103
+ transform: "rotate(0deg)",
104
+ },
105
+ '100%': {
106
+ transform: "rotate(180deg)",
107
+ },
108
+ },
109
+ '@keyframes close': {
110
+ '0%': {
111
+ transform: "rotate(180deg)",
112
+ },
113
+ '100%': {
114
+ transform: "rotate(0deg)",
115
+ },
116
+ },
117
+ }
118
+ : {
119
+ marginTop: 'auto',
120
+ marginBottom: 'auto',
121
+ };
122
+ }, [isExpandable, isExpand]);
123
+ var collapseStyle = useMemo(function () { return ({
124
+ backgroundColor: isExpand
125
+ ? alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2)
126
+ : undefined,
127
+ }); }, [isExpand, theme]);
128
+ var primaryTypographyProps = useMemo(function () { return ({ sx: { fontWeight: info.depth === 1 ? 600 : null } }); }, [info]);
129
+ // -------------------------------------------------------------------------------------------------------------------
130
+ return (React.createElement(React.Fragment, null,
131
+ React.createElement(ListItemButton, { onClick: isExpandable
132
+ ? toggleIsExpand
133
+ : function () {
134
+ if (onClick)
135
+ onClick(info);
136
+ }, selected: isExpandable ? false : info.uri === location.pathname, style: containerStyle },
137
+ React.createElement(ListItemIcon, { sx: { minWidth: 30 } }, icon && React.createElement(Icon, { fontSize: 'small' }, icon)),
138
+ React.createElement(ListItemText, { primaryTypographyProps: primaryTypographyProps }, info.name),
139
+ isExpandable && React.createElement(ExpandMore, { sx: expandIconSx })),
140
+ React.createElement(Collapse, { in: isExpand, style: collapseStyle }, isExpandable &&
141
+ info.items &&
142
+ info.items.map(function (subInfo, idx) { return React.createElement(SideMenuListItem, { key: idx, info: subInfo, onClick: onClick }); }))));
143
+ };var StyledList = styled(List)(templateObject_1$3 || (templateObject_1$3 = __makeTemplateObject(["\n padding: 0;\n"], ["\n padding: 0;\n"])));
144
+ var templateObject_1$3;var SideMenuList = function (_a) {
145
+ var list = _a.list, onClick = _a.onClick;
146
+ return (React.createElement(StyledList, null, list.map(function (info, idx) { return (React.createElement(SideMenuListItem, { key: idx, info: info, onClick: onClick })); })));
147
+ };var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};var propTypes = {exports: {}};var reactIs = {exports: {}};var reactIs_production_min = {};/** @license React v16.13.1
48
148
  * react-is.production.min.js
49
149
  *
50
150
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -2266,7 +2366,7 @@ var getBuiltIn$1 = getBuiltIn$5;
2266
2366
  var inspectSource = inspectSource$2;
2267
2367
 
2268
2368
  var noop = function () { /* empty */ };
2269
- var empty$1 = [];
2369
+ var empty = [];
2270
2370
  var construct = getBuiltIn$1('Reflect', 'construct');
2271
2371
  var constructorRegExp = /^\s*(?:class|function)\b/;
2272
2372
  var exec$1 = uncurryThis$c(constructorRegExp.exec);
@@ -2275,7 +2375,7 @@ var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
2275
2375
  var isConstructorModern = function isConstructor(argument) {
2276
2376
  if (!isCallable$8(argument)) return false;
2277
2377
  try {
2278
- construct(noop, empty$1, argument);
2378
+ construct(noop, empty, argument);
2279
2379
  return true;
2280
2380
  } catch (error) {
2281
2381
  return false;
@@ -7322,106 +7422,15 @@ SimpleBar.propTypes = {
7322
7422
  children: propTypes.exports.oneOfType([propTypes.exports.node, propTypes.exports.func]),
7323
7423
  scrollableNodeProps: propTypes.exports.object,
7324
7424
  tag: propTypes.exports.string
7325
- };var empty = function (v) {
7326
- var result = false;
7327
- if (v == null) {
7328
- result = true;
7329
- }
7330
- else if (typeof v === 'string') {
7331
- result = v === '';
7332
- }
7333
- else if (typeof v === 'object') {
7334
- if (Array.isArray(v)) {
7335
- result = v.length === 0;
7336
- }
7337
- else if (!(v instanceof Date)) {
7338
- result = Object.entries(v).length === 0;
7339
- }
7340
- }
7341
- return result;
7342
- };
7343
- var notEmpty = function (v) {
7344
- return !empty(v);
7345
- };var SideMenuListItem = function (_a) {
7346
- var info = _a.info, onClick = _a.onClick;
7347
- var theme = useTheme();
7348
- var _b = useState(false), isExpandable = _b[0], setIsExpandable = _b[1];
7349
- var _c = useState(false), isExpand = _c[0], setIsExpand = _c[1];
7350
- var _d = useState(null), expandIconSx = _d[0], setExpandIconSx = _d[1];
7351
- useEffect(function () {
7352
- setIsExpandable(!!info && notEmpty(info.items));
7353
- if (info.items && info.items.find(function (info) { return location.pathname === info.uri; })) {
7354
- setIsExpand(true);
7355
- }
7356
- }, [info]);
7357
- useEffect(function () {
7358
- if (isExpandable && isExpand != null) {
7359
- if (info.uri !== location.pathname) {
7360
- if (info.items && !info.items.find(function (info) { return location.pathname === info.uri; })) {
7361
- if (isExpand) {
7362
- setIsExpand(false);
7363
- }
7364
- }
7365
- }
7366
- }
7367
- if (isExpandable && !isExpand) {
7368
- if (info.items && info.items.find(function (info) { return location.pathname === info.uri; })) {
7369
- setIsExpand(true);
7370
- }
7371
- }
7372
- }, [location.pathname]);
7373
- useEffect(function () {
7374
- if (isExpandable && isExpand != null) {
7375
- setExpandIconSx({
7376
- animation: "".concat(isExpand ? 'open' : 'close', " 0.1s linear"),
7377
- transform: "rotate(".concat(isExpand ? 180 : 0, "deg)"),
7378
- '@keyframes open': {
7379
- '0%': {
7380
- transform: "rotate(0deg)",
7381
- },
7382
- '100%': {
7383
- transform: "rotate(180deg)",
7384
- },
7385
- },
7386
- '@keyframes close': {
7387
- '0%': {
7388
- transform: "rotate(180deg)",
7389
- },
7390
- '100%': {
7391
- transform: "rotate(0deg)",
7392
- },
7393
- },
7394
- });
7395
- }
7396
- }, [isExpandable, isExpand]);
7397
- function toggleIsExpand() {
7398
- setIsExpand(function (isExpand) { return !isExpand; });
7399
- }
7400
- return (React.createElement(React.Fragment, null,
7401
- React.createElement(ListItemButton, { onClick: isExpandable
7402
- ? toggleIsExpand
7403
- : function () {
7404
- if (onClick)
7405
- onClick(info);
7406
- }, selected: isExpandable ? false : info.uri === location.pathname, style: {
7407
- backgroundColor: isExpandable && isExpand
7408
- ? alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2)
7409
- : undefined,
7410
- } },
7411
- React.createElement(ListItemIcon, { sx: { minWidth: 30 } }, info.icon && (React.createElement(Icon, { fontSize: 'small' }, info.icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })))),
7412
- React.createElement(ListItemText, { primaryTypographyProps: { sx: { fontWeight: info.depth === 1 ? 600 : null } } }, info.name),
7413
- isExpandable && React.createElement(ExpandMore, { style: { marginTop: 'auto', marginBottom: 'auto' }, sx: expandIconSx })),
7414
- React.createElement(Collapse, { in: isExpand, style: {
7415
- backgroundColor: isExpand
7416
- ? alpha(theme.palette.primary.main, theme.palette.action.selectedOpacity / 2)
7417
- : undefined,
7418
- } }, isExpandable &&
7419
- info.items &&
7420
- info.items.map(function (subInfo, idx) { return React.createElement(SideMenuListItem, { key: idx, info: subInfo, onClick: onClick }); }))));
7421
- };var SideMenuList = function (_a) {
7422
- var list = _a.list, onClick = _a.onClick;
7423
- return (React.createElement(List, { sx: { padding: 0 } }, list.map(function (info, idx) { return (React.createElement(SideMenuListItem, { key: idx, info: info, onClick: onClick })); })));
7424
- };function styleInject(css, ref) {
7425
+ };var StyledSimpleBar = styled(SimpleBar)(templateObject_1$2 || (templateObject_1$2 = __makeTemplateObject(["\n max-height: 100%;\n"], ["\n max-height: 100%;\n"])));
7426
+ var StyledLogoContainerBox = styled(Box)(function (_a) {
7427
+ var theme = _a.theme;
7428
+ return theme.unstable_sx({
7429
+ borderBottom: 'thin solid #f5f5f5',
7430
+ color: 'text.primary',
7431
+ });
7432
+ });
7433
+ var templateObject_1$2;function styleInject(css, ref) {
7425
7434
  if ( ref === void 0 ) ref = {};
7426
7435
  var insertAt = ref.insertAt;
7427
7436
 
@@ -7449,27 +7458,89 @@ var notEmpty = function (v) {
7449
7458
  }var css_248z = "[data-simplebar]{position:relative;flex-direction:column;flex-wrap:wrap;justify-content:flex-start;align-content:flex-start;align-items:flex-start}.simplebar-wrapper{overflow:hidden;width:inherit;height:inherit;max-width:inherit;max-height:inherit}.simplebar-mask{direction:inherit;position:absolute;overflow:hidden;padding:0;margin:0;left:0;top:0;bottom:0;right:0;width:auto!important;height:auto!important;z-index:0}.simplebar-offset{direction:inherit!important;box-sizing:inherit!important;resize:none!important;position:absolute;top:0;left:0;bottom:0;right:0;padding:0;margin:0;-webkit-overflow-scrolling:touch}.simplebar-content-wrapper{direction:inherit;box-sizing:border-box!important;position:relative;display:block;height:100%;width:auto;max-width:100%;max-height:100%;scrollbar-width:none;-ms-overflow-style:none}.simplebar-content-wrapper::-webkit-scrollbar,.simplebar-hide-scrollbar::-webkit-scrollbar{width:0;height:0}.simplebar-content:after,.simplebar-content:before{content:' ';display:table}.simplebar-placeholder{max-height:100%;max-width:100%;width:100%;pointer-events:none}.simplebar-height-auto-observer-wrapper{box-sizing:inherit!important;height:100%;width:100%;max-width:1px;position:relative;float:left;max-height:1px;overflow:hidden;z-index:-1;padding:0;margin:0;pointer-events:none;flex-grow:inherit;flex-shrink:0;flex-basis:0}.simplebar-height-auto-observer{box-sizing:inherit;display:block;opacity:0;position:absolute;top:0;left:0;height:1000%;width:1000%;min-height:1px;min-width:1px;overflow:hidden;pointer-events:none;z-index:-1}.simplebar-track{z-index:1;position:absolute;right:0;bottom:0;pointer-events:none;overflow:hidden}[data-simplebar].simplebar-dragging .simplebar-content{pointer-events:none;user-select:none;-webkit-user-select:none}[data-simplebar].simplebar-dragging .simplebar-track{pointer-events:all}.simplebar-scrollbar{position:absolute;left:0;right:0;min-height:10px}.simplebar-scrollbar:before{position:absolute;content:'';background:#000;border-radius:7px;left:2px;right:2px;opacity:0;transition:opacity .2s .5s linear}.simplebar-scrollbar.simplebar-visible:before{opacity:.5;transition-delay:0s;transition-duration:0s}.simplebar-track.simplebar-vertical{top:0;width:11px}.simplebar-scrollbar:before{top:2px;bottom:2px;left:2px;right:2px}.simplebar-track.simplebar-horizontal{left:0;height:11px}.simplebar-track.simplebar-horizontal .simplebar-scrollbar{right:auto;left:0;top:0;bottom:0;min-height:0;min-width:10px;width:auto}[data-simplebar-direction=rtl] .simplebar-track.simplebar-vertical{right:auto;left:0}.simplebar-dummy-scrollbar-size{direction:rtl;position:fixed;opacity:0;visibility:hidden;height:500px;width:500px;overflow-y:hidden;overflow-x:scroll;-ms-overflow-style:scrollbar!important}.simplebar-dummy-scrollbar-size>div{width:200%;height:200%;margin:10px 0}.simplebar-hide-scrollbar{position:fixed;left:0;visibility:hidden;overflow-y:scroll;scrollbar-width:none;-ms-overflow-style:none}\n";
7450
7459
  styleInject(css_248z);var SideMenu = function (_a) {
7451
7460
  var logo = _a.logo, list = _a.list, onClick = _a.onClick;
7452
- return (React.createElement(SimpleBar, { style: { maxHeight: '100%' } },
7453
- React.createElement(Box, { sx: {
7454
- borderBottom: 'thin solid #f5f5f5',
7455
- color: 'text.primary',
7456
- } },
7461
+ return (React.createElement(StyledSimpleBar, null,
7462
+ React.createElement(StyledLogoContainerBox, null,
7457
7463
  React.createElement(Toolbar, null, logo)),
7458
7464
  list && React.createElement(SideMenuList, { list: list, onClick: onClick })));
7459
- };var Title = function (_a) {
7465
+ };var StyledContainerBox$1 = styled(Box)(templateObject_1$1 || (templateObject_1$1 = __makeTemplateObject(["\n position: relative;\n"], ["\n position: relative;\n"])));
7466
+ var StyledHeadContainerBox = styled(Box)(function (_a) {
7467
+ var theme = _a.theme;
7468
+ return theme.unstable_sx({
7469
+ display: { xs: 'none', sm: 'flex' },
7470
+ alignItems: 'center',
7471
+ opacity: 0.5,
7472
+ });
7473
+ });
7474
+ var StyledHeadIconContainerBox = styled(Box)(templateObject_2$1 || (templateObject_2$1 = __makeTemplateObject(["\n margin-right: 0.25rem;\n line-height: 0;\n"], ["\n margin-right: 0.25rem;\n line-height: 0;\n"])));
7475
+ var StyledHeadIcon = styled(Icon)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-size: 1rem;\n"], ["\n font-size: 1rem;\n"])));
7476
+ var StyledHeadTitleTypography = styled(Typography)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n font-size: 0.7rem;\n"], ["\n font-size: 0.7rem;\n"])));
7477
+ var StyledTitleContainerDiv = styled('div')(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n font-size: 1rem;\n"], ["\n display: flex;\n align-items: center;\n font-size: 1rem;\n"])));
7478
+ var StyledTitleIconContainerDiv = styled('div')(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n flex-shrink: 0;\n display: inline-flex;\n margin-right: 0.3rem;\n"], ["\n flex-shrink: 0;\n display: inline-flex;\n margin-right: 0.3rem;\n"])));
7479
+ var templateObject_1$1, templateObject_2$1, templateObject_3, templateObject_4, templateObject_5, templateObject_6;var Title = function (_a) {
7460
7480
  var title = _a.title, icon = _a.icon, headTitle = _a.headTitle, headIcon = _a.headIcon;
7461
- return (React.createElement(Box, { style: { position: 'relative' } },
7462
- headTitle && (React.createElement(Box, { sx: { display: { xs: 'none', sm: 'flex' }, alignItems: 'center', opacity: 0.5 } },
7463
- headIcon && (React.createElement(Box, { style: { marginRight: '0.25rem', lineHeight: 0 } },
7464
- React.createElement(Icon, { style: { fontSize: '1rem' } }, headIcon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })))),
7465
- React.createElement(Typography, { style: { fontSize: '0.7rem' } }, headTitle))),
7466
- React.createElement("div", { style: { display: 'flex', alignItems: 'center', fontSize: '1rem' } },
7467
- icon && (React.createElement("div", { style: { flexShrink: 0, display: 'inline-flex', marginRight: '0.3rem' } },
7468
- React.createElement(Icon, { fontSize: 'small' }, icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })))),
7481
+ var finalHeadIcon = useMemo(function () {
7482
+ return headIcon
7483
+ ? headIcon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })
7484
+ : undefined;
7485
+ }, [headIcon]);
7486
+ var finalIcon = useMemo(function () { return (icon ? icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); }) : undefined); }, [icon]);
7487
+ return (React.createElement(StyledContainerBox$1, null,
7488
+ headTitle && (React.createElement(StyledHeadContainerBox, null,
7489
+ finalHeadIcon && (React.createElement(StyledHeadIconContainerBox, null,
7490
+ React.createElement(StyledHeadIcon, null, finalHeadIcon))),
7491
+ React.createElement(StyledHeadTitleTypography, null, headTitle))),
7492
+ React.createElement(StyledTitleContainerDiv, null,
7493
+ finalIcon && (React.createElement(StyledTitleIconContainerDiv, null,
7494
+ React.createElement(Icon, { fontSize: 'small' }, finalIcon))),
7469
7495
  React.createElement("div", null, title))));
7470
- };var sideMenuWidth = 220;
7471
- var DefaultLayout = function (_a) {
7496
+ };var SIDE_MENU_WIDTH = 220;
7497
+ var StyledContainerBox = styled(Box)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n height: 100%;\n"], ["\n display: flex;\n height: 100%;\n"])));
7498
+ var StyledAppBar = styled(AppBar)(function (_a) {
7499
+ var theme = _a.theme;
7500
+ return theme.unstable_sx({
7501
+ backdropFilter: 'blur(20px)',
7502
+ backgroundColor: 'rgba(255, 255, 255, 0.7)',
7503
+ color: 'text.primary',
7504
+ borderBottom: 'thin solid #f5f5f5',
7505
+ width: { sm: "calc(100% - ".concat(SIDE_MENU_WIDTH, "px)") },
7506
+ ml: { sm: "".concat(SIDE_MENU_WIDTH, "px") },
7507
+ });
7508
+ });
7509
+ var StyledSideMenuContainerBox = styled(Box)(function (_a) {
7510
+ var theme = _a.theme;
7511
+ return theme.unstable_sx({ width: { sm: SIDE_MENU_WIDTH }, flexShrink: { sm: 0 } });
7512
+ });
7513
+ var StyledSideMenuTemporaryDrawer = styled(Drawer)(function (_a) {
7514
+ var theme = _a.theme;
7515
+ return theme.unstable_sx({
7516
+ display: { xs: 'block', sm: 'none' },
7517
+ '& .MuiDrawer-paper': { boxSizing: 'border-box', width: SIDE_MENU_WIDTH },
7518
+ });
7519
+ });
7520
+ var StyledSideMenuPermanentDrawer = styled(Drawer)(function (_a) {
7521
+ var theme = _a.theme;
7522
+ return theme.unstable_sx({
7523
+ display: { xs: 'none', sm: 'block' },
7524
+ '& .MuiDrawer-paper': { boxSizing: 'border-box', width: SIDE_MENU_WIDTH },
7525
+ });
7526
+ });
7527
+ var StyledMainBox = styled(Box)(function (_a) {
7528
+ var theme = _a.theme;
7529
+ return theme.unstable_sx({
7530
+ flexGrow: 1,
7531
+ p: 2,
7532
+ width: { sm: "calc(100% - ".concat(SIDE_MENU_WIDTH, "px)") },
7533
+ display: 'flex',
7534
+ flexDirection: 'column',
7535
+ minHeight: '100vh',
7536
+ });
7537
+ });
7538
+ var StyledMainContentDiv = styled('div')(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n flex: 1;\n"], ["\n display: flex;\n flex: 1;\n"])));
7539
+ var templateObject_1, templateObject_2;var DefaultLayout = function (_a) {
7540
+ // -------------------------------------------------------------------------------------------------------------------
7472
7541
  var children = _a.children, logo = _a.logo, menu = _a.menu, appBarControl = _a.appBarControl, onMenuClick = _a.onMenuClick;
7542
+ var location = useLocation();
7543
+ // -------------------------------------------------------------------------------------------------------------------
7473
7544
  var _b = useState(false), isMobileOpen = _b[0], setIsMobileOpen = _b[1];
7474
7545
  var _c = useState({}), menuTitles = _c[0], setMenuTitles = _c[1];
7475
7546
  var _d = useState(), title = _d[0], setTitle = _d[1];
@@ -7478,7 +7549,7 @@ var DefaultLayout = function (_a) {
7478
7549
  var menuTitles = {};
7479
7550
  if (menu) {
7480
7551
  menu.forEach(function (info) {
7481
- if (empty(info.uri) && info.items && info.items.length > 0) {
7552
+ if (empty$1(info.uri) && info.items && info.items.length > 0) {
7482
7553
  info.items.map(function (subInfo) {
7483
7554
  menuTitles[subInfo.uri] = { name: subInfo.name, parentName: info.name, parentIcon: info.icon };
7484
7555
  });
@@ -7500,41 +7571,29 @@ var DefaultLayout = function (_a) {
7500
7571
  setTitle(undefined);
7501
7572
  }
7502
7573
  }
7503
- }, [location.pathname, menuTitles]);
7504
- function toggleIsMobileOpen() {
7574
+ }, [location, menuTitles]);
7575
+ // -------------------------------------------------------------------------------------------------------------------
7576
+ var toggleIsMobileOpen = useCallback(function () {
7505
7577
  setIsMobileOpen(function (isMobileOpen) { return !isMobileOpen; });
7506
- }
7578
+ }, []);
7507
7579
  //--------------------------------------------------------------------------------------------------------------------
7508
- return (React.createElement(Box, { sx: { display: 'flex', height: '100%' } },
7509
- React.createElement(AppBar, { position: 'fixed', elevation: 0, sx: {
7510
- backdropFilter: 'blur(20px)',
7511
- backgroundColor: 'rgba(255, 255, 255, 0.7)',
7512
- color: 'text.primary',
7513
- borderBottom: 'thin solid #f5f5f5',
7514
- width: { sm: "calc(100% - ".concat(sideMenuWidth, "px)") },
7515
- ml: { sm: "".concat(sideMenuWidth, "px") },
7516
- } },
7580
+ return (React.createElement(StyledContainerBox, null,
7581
+ React.createElement(StyledAppBar, { position: 'fixed', elevation: 0 },
7517
7582
  React.createElement(Toolbar, null,
7518
7583
  React.createElement(IconButton, { color: 'inherit', "aria-label": 'open drawer', edge: 'start', onClick: toggleIsMobileOpen, sx: { mr: 2, display: { sm: 'none' } } },
7519
7584
  React.createElement(Menu, null)),
7520
7585
  React.createElement(Typography, { variant: 'h6', noWrap: true, component: 'div', sx: { flexGrow: 1 } }, title),
7521
7586
  appBarControl)),
7522
- React.createElement(Box, { component: 'nav', sx: { width: { sm: sideMenuWidth }, flexShrink: { sm: 0 } }, "aria-label": 'mailbox folders' },
7523
- React.createElement(Drawer, { variant: 'temporary', open: isMobileOpen, onClose: toggleIsMobileOpen, ModalProps: {
7587
+ React.createElement(StyledSideMenuContainerBox, { component: 'nav', "aria-label": 'mailbox folders' },
7588
+ React.createElement(StyledSideMenuTemporaryDrawer, { variant: 'temporary', open: isMobileOpen, onClose: toggleIsMobileOpen, ModalProps: {
7524
7589
  keepMounted: true, // Better open performance on mobile.
7525
- }, sx: {
7526
- display: { xs: 'block', sm: 'none' },
7527
- '& .MuiDrawer-paper': { boxSizing: 'border-box', width: sideMenuWidth },
7528
7590
  } }, menu && (React.createElement(SideMenu, { logo: logo, list: menu, onClick: function (menuItem) {
7529
7591
  toggleIsMobileOpen();
7530
7592
  if (onMenuClick)
7531
7593
  onMenuClick(menuItem);
7532
7594
  } }))),
7533
- React.createElement(Drawer, { variant: 'permanent', sx: {
7534
- display: { xs: 'none', sm: 'block' },
7535
- '& .MuiDrawer-paper': { boxSizing: 'border-box', width: sideMenuWidth },
7536
- }, open: true }, menu && React.createElement(SideMenu, { logo: logo, list: menu, onClick: onMenuClick }))),
7537
- React.createElement(Box, { component: 'main', sx: { flexGrow: 1, p: 2, width: { sm: "calc(100% - ".concat(sideMenuWidth, "px)") } } },
7595
+ React.createElement(StyledSideMenuPermanentDrawer, { variant: 'permanent', open: true }, menu && React.createElement(SideMenu, { logo: logo, list: menu, onClick: onMenuClick }))),
7596
+ React.createElement(StyledMainBox, { component: 'main' },
7538
7597
  React.createElement(Toolbar, null),
7539
- children)));
7598
+ React.createElement(StyledMainContentDiv, null, children))));
7540
7599
  };export{CardLayout,DefaultLayout};//# sourceMappingURL=index.esm.js.map