@etsoo/materialui 1.1.14 → 1.1.16
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/lib/pages/LeftDrawer.d.ts +8 -12
- package/lib/pages/LeftDrawer.js +10 -15
- package/package.json +1 -1
- package/src/pages/LeftDrawer.tsx +26 -29
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Left drawer methods
|
|
4
|
-
*/
|
|
5
|
-
export interface LeftDrawerMethods {
|
|
6
|
-
open(): void;
|
|
7
|
-
}
|
|
8
2
|
/**
|
|
9
3
|
* Left drawer props
|
|
10
4
|
*/
|
|
11
|
-
export
|
|
5
|
+
export type LeftDrawerProps = React.PropsWithRef<{
|
|
12
6
|
/**
|
|
13
7
|
* Show when md up
|
|
14
8
|
*/
|
|
@@ -24,12 +18,14 @@ export interface LeftDrawerProps {
|
|
|
24
18
|
/**
|
|
25
19
|
* Application name
|
|
26
20
|
*/
|
|
27
|
-
appName
|
|
21
|
+
appName?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Is open or not
|
|
24
|
+
*/
|
|
25
|
+
open?: boolean;
|
|
28
26
|
/**
|
|
29
27
|
* Minimize hanlder
|
|
30
28
|
*/
|
|
31
29
|
onMinimize?: () => void;
|
|
32
|
-
}
|
|
33
|
-
export declare
|
|
34
|
-
children?: React.ReactNode;
|
|
35
|
-
} & React.RefAttributes<LeftDrawerMethods>>;
|
|
30
|
+
}>;
|
|
31
|
+
export declare function LeftDrawer(props: React.PropsWithChildren<LeftDrawerProps>): JSX.Element;
|
package/lib/pages/LeftDrawer.js
CHANGED
|
@@ -3,31 +3,26 @@ import React from "react";
|
|
|
3
3
|
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
4
4
|
import { DrawerHeader } from "./DrawerHeader";
|
|
5
5
|
import { globalApp } from "../app/ReactApp";
|
|
6
|
-
export
|
|
6
|
+
export function LeftDrawer(props) {
|
|
7
7
|
var _a;
|
|
8
8
|
// Destruct
|
|
9
|
-
const { mdUp, width, appName, onMinimize, children } = props;
|
|
9
|
+
const { mdUp, width, appName = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get("appName"), onMinimize, open = mdUp, children } = props;
|
|
10
10
|
// Menu open/close state
|
|
11
|
-
const [
|
|
11
|
+
const [openLocal, setOpen] = React.useState();
|
|
12
12
|
const handleDrawerClose = () => {
|
|
13
13
|
if (onMinimize)
|
|
14
14
|
onMinimize();
|
|
15
15
|
setOpen(false);
|
|
16
16
|
};
|
|
17
|
-
React.useImperativeHandle(ref, () => ({
|
|
18
|
-
open() {
|
|
19
|
-
setOpen(true);
|
|
20
|
-
}
|
|
21
|
-
}));
|
|
22
17
|
// Ready
|
|
23
18
|
React.useEffect(() => {
|
|
24
|
-
setOpen(
|
|
25
|
-
}, [
|
|
26
|
-
return (React.createElement(Drawer, { sx: {
|
|
27
|
-
width
|
|
19
|
+
setOpen(open);
|
|
20
|
+
}, [open]);
|
|
21
|
+
return (React.createElement(Drawer, { hidden: !openLocal, sx: {
|
|
22
|
+
width,
|
|
28
23
|
flexShrink: 0,
|
|
29
24
|
"& .MuiDrawer-paper": {
|
|
30
|
-
width
|
|
25
|
+
width,
|
|
31
26
|
boxSizing: "border-box"
|
|
32
27
|
}
|
|
33
28
|
}, anchor: "left", variant: mdUp ? "persistent" : "temporary", open: open, onClose: mdUp ? undefined : handleDrawerClose, ModalProps: {
|
|
@@ -36,9 +31,9 @@ export const LeftDrawer = React.forwardRef((props, ref) => {
|
|
|
36
31
|
React.createElement(DrawerHeader, null,
|
|
37
32
|
React.createElement("a", { href: "https://www.etsoo.com", title: (_a = globalApp === null || globalApp === void 0 ? void 0 : globalApp.get("etsoo")) !== null && _a !== void 0 ? _a : "ETSOO", target: "_blank", rel: "noreferrer" },
|
|
38
33
|
React.createElement(Avatar, { src: process.env.PUBLIC_URL + "/logo192.png", variant: "square", sx: { marginLeft: -0.5, marginRight: 1.5, marginBottom: 1 } })),
|
|
39
|
-
React.createElement(Typography, { noWrap: true, component: "div", title: appName }, appName),
|
|
34
|
+
React.createElement(Typography, { noWrap: true, component: "div", title: appName, sx: { flexGrow: 2 } }, appName),
|
|
40
35
|
React.createElement(IconButton, { size: "small", onClick: handleDrawerClose },
|
|
41
36
|
React.createElement(ChevronLeftIcon, null))),
|
|
42
37
|
React.createElement(Divider, null),
|
|
43
38
|
React.createElement(List, { onClick: mdUp ? undefined : handleDrawerClose }, children)));
|
|
44
|
-
}
|
|
39
|
+
}
|
package/package.json
CHANGED
package/src/pages/LeftDrawer.tsx
CHANGED
|
@@ -6,22 +6,15 @@ import {
|
|
|
6
6
|
List,
|
|
7
7
|
Typography
|
|
8
8
|
} from "@mui/material";
|
|
9
|
-
import React
|
|
9
|
+
import React from "react";
|
|
10
10
|
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
11
11
|
import { DrawerHeader } from "./DrawerHeader";
|
|
12
12
|
import { globalApp } from "../app/ReactApp";
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
* Left drawer methods
|
|
16
|
-
*/
|
|
17
|
-
export interface LeftDrawerMethods {
|
|
18
|
-
open(): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
14
|
/**
|
|
22
15
|
* Left drawer props
|
|
23
16
|
*/
|
|
24
|
-
export
|
|
17
|
+
export type LeftDrawerProps = React.PropsWithRef<{
|
|
25
18
|
/**
|
|
26
19
|
* Show when md up
|
|
27
20
|
*/
|
|
@@ -40,47 +33,51 @@ export interface LeftDrawerProps {
|
|
|
40
33
|
/**
|
|
41
34
|
* Application name
|
|
42
35
|
*/
|
|
43
|
-
appName
|
|
36
|
+
appName?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Is open or not
|
|
40
|
+
*/
|
|
41
|
+
open?: boolean;
|
|
44
42
|
|
|
45
43
|
/**
|
|
46
44
|
* Minimize hanlder
|
|
47
45
|
*/
|
|
48
46
|
onMinimize?: () => void;
|
|
49
|
-
}
|
|
47
|
+
}>;
|
|
50
48
|
|
|
51
|
-
export
|
|
52
|
-
LeftDrawerMethods,
|
|
53
|
-
PropsWithChildren<LeftDrawerProps>
|
|
54
|
-
>((props, ref) => {
|
|
49
|
+
export function LeftDrawer(props: React.PropsWithChildren<LeftDrawerProps>) {
|
|
55
50
|
// Destruct
|
|
56
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
mdUp,
|
|
53
|
+
width,
|
|
54
|
+
appName = globalApp?.get("appName"),
|
|
55
|
+
onMinimize,
|
|
56
|
+
open = mdUp,
|
|
57
|
+
children
|
|
58
|
+
} = props;
|
|
57
59
|
|
|
58
60
|
// Menu open/close state
|
|
59
|
-
const [
|
|
61
|
+
const [openLocal, setOpen] = React.useState<boolean>();
|
|
60
62
|
|
|
61
63
|
const handleDrawerClose = () => {
|
|
62
64
|
if (onMinimize) onMinimize();
|
|
63
65
|
setOpen(false);
|
|
64
66
|
};
|
|
65
67
|
|
|
66
|
-
React.useImperativeHandle(ref, () => ({
|
|
67
|
-
open() {
|
|
68
|
-
setOpen(true);
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
71
|
-
|
|
72
68
|
// Ready
|
|
73
69
|
React.useEffect(() => {
|
|
74
|
-
setOpen(
|
|
75
|
-
}, [
|
|
70
|
+
setOpen(open);
|
|
71
|
+
}, [open]);
|
|
76
72
|
|
|
77
73
|
return (
|
|
78
74
|
<Drawer
|
|
75
|
+
hidden={!openLocal}
|
|
79
76
|
sx={{
|
|
80
|
-
width
|
|
77
|
+
width,
|
|
81
78
|
flexShrink: 0,
|
|
82
79
|
"& .MuiDrawer-paper": {
|
|
83
|
-
width
|
|
80
|
+
width,
|
|
84
81
|
boxSizing: "border-box"
|
|
85
82
|
}
|
|
86
83
|
}}
|
|
@@ -105,7 +102,7 @@ export const LeftDrawer = React.forwardRef<
|
|
|
105
102
|
sx={{ marginLeft: -0.5, marginRight: 1.5, marginBottom: 1 }}
|
|
106
103
|
/>
|
|
107
104
|
</a>
|
|
108
|
-
<Typography noWrap component="div" title={appName}>
|
|
105
|
+
<Typography noWrap component="div" title={appName} sx={{ flexGrow: 2 }}>
|
|
109
106
|
{appName}
|
|
110
107
|
</Typography>
|
|
111
108
|
<IconButton size="small" onClick={handleDrawerClose}>
|
|
@@ -116,4 +113,4 @@ export const LeftDrawer = React.forwardRef<
|
|
|
116
113
|
<List onClick={mdUp ? undefined : handleDrawerClose}>{children}</List>
|
|
117
114
|
</Drawer>
|
|
118
115
|
);
|
|
119
|
-
}
|
|
116
|
+
}
|