@sikka/hawa 0.0.35 → 0.0.36
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/README.md +11 -0
- package/es/index.es.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +10 -9
- package/src/elements/DragDropImages.js +55 -72
- package/src/elements/HawaSelectInput.js +30 -0
- package/src/elements/HawaSnackbar.js +32 -3
- package/src/layout/HawaAppLayout.js +197 -173
- package/src/layout/HawaAppLayout2.js +260 -0
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/main.3f5171ae.iframe.bundle.js +1 -0
- package/storybook-static/vendors~main.3cf4a535.iframe.bundle.js +76 -0
- package/storybook-static/{vendors~main.07e1611f.iframe.bundle.js.LICENSE.txt → vendors~main.3cf4a535.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/vendors~main.3cf4a535.iframe.bundle.js.map +1 -0
- package/storybook-static/main.6eab4ef6.iframe.bundle.js +0 -1
- package/storybook-static/vendors~main.07e1611f.iframe.bundle.js +0 -76
- package/storybook-static/vendors~main.07e1611f.iframe.bundle.js.map +0 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { styled, useTheme } from "@mui/material/styles";
|
|
3
|
+
import Box from "@mui/material/Box";
|
|
4
|
+
import MuiDrawer from "@mui/material/Drawer";
|
|
5
|
+
import MuiAppBar from "@mui/material/AppBar";
|
|
6
|
+
import Toolbar from "@mui/material/Toolbar";
|
|
7
|
+
import List from "@mui/material/List";
|
|
8
|
+
import Typography from "@mui/material/Typography";
|
|
9
|
+
// import Divider from "@mui/material/Divider";
|
|
10
|
+
import IconButton from "@mui/material/IconButton";
|
|
11
|
+
import MenuIcon from "@mui/icons-material/Menu";
|
|
12
|
+
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
13
|
+
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
|
14
|
+
import ListItemButton from "@mui/material/ListItemButton";
|
|
15
|
+
import ListItemText from "@mui/material/ListItemText";
|
|
16
|
+
import Avatar from "@mui/material/Avatar";
|
|
17
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
18
|
+
import { HawaPopMenu } from "../elements/HawaPopMenu";
|
|
19
|
+
|
|
20
|
+
const drawerWidth = 200;
|
|
21
|
+
|
|
22
|
+
const openedMixin = (theme) => ({
|
|
23
|
+
width: drawerWidth,
|
|
24
|
+
transition: theme.transitions.create("width", {
|
|
25
|
+
easing: theme.transitions.easing.sharp,
|
|
26
|
+
duration: theme.transitions.duration.enteringScreen
|
|
27
|
+
}),
|
|
28
|
+
overflowX: "hidden"
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const closedMixin = (theme) => ({
|
|
32
|
+
transition: theme.transitions.create("width", {
|
|
33
|
+
easing: theme.transitions.easing.sharp,
|
|
34
|
+
duration: theme.transitions.duration.leavingScreen
|
|
35
|
+
}),
|
|
36
|
+
overflowX: "hidden",
|
|
37
|
+
width: `calc(${theme.spacing(0)} + 1px)`,
|
|
38
|
+
[theme.breakpoints.up("sm")]: {
|
|
39
|
+
width: `calc(${theme.spacing(8)} + 1px)`
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const DrawerHeader = styled("div")(({ theme, direction }) => ({
|
|
44
|
+
display: "flex",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
justifyContent: direction === "rtl" ? "flex-start" : "flex-end",
|
|
47
|
+
padding: theme.spacing(0, 1),
|
|
48
|
+
// necessary for content to be below app bar
|
|
49
|
+
...theme.mixins.toolbar
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
const AppBar = styled(MuiAppBar, {
|
|
53
|
+
shouldForwardProp: (prop) => prop !== "open"
|
|
54
|
+
})(({ theme, open, direction }) => ({
|
|
55
|
+
zIndex: theme.zIndex.drawer + 1,
|
|
56
|
+
transition: theme.transitions.create(["width", "margin"], {
|
|
57
|
+
easing: theme.transitions.easing.sharp,
|
|
58
|
+
duration: theme.transitions.duration.leavingScreen
|
|
59
|
+
}),
|
|
60
|
+
|
|
61
|
+
...(open && {
|
|
62
|
+
marginLeft: direction === "rtl" ? 0 : drawerWidth,
|
|
63
|
+
marginRight: direction === "rtl" ? drawerWidth : 0,
|
|
64
|
+
width: `calc(100% - ${drawerWidth}px)`,
|
|
65
|
+
transition: theme.transitions.create(["width", "margin"], {
|
|
66
|
+
easing: theme.transitions.easing.sharp,
|
|
67
|
+
duration: theme.transitions.duration.enteringScreen
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
const Drawer = styled(MuiDrawer, {
|
|
73
|
+
shouldForwardProp: (prop) => prop !== "open"
|
|
74
|
+
})(({ theme, open }) => ({
|
|
75
|
+
width: drawerWidth,
|
|
76
|
+
flexShrink: 0,
|
|
77
|
+
whiteSpace: "nowrap",
|
|
78
|
+
boxSizing: "border-box",
|
|
79
|
+
...(open && {
|
|
80
|
+
...openedMixin(theme),
|
|
81
|
+
"& .MuiDrawer-paper": openedMixin(theme)
|
|
82
|
+
}),
|
|
83
|
+
...(!open && {
|
|
84
|
+
...closedMixin(theme),
|
|
85
|
+
"& .MuiDrawer-paper": closedMixin(theme)
|
|
86
|
+
})
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
export function HawaAppLayout(props) {
|
|
90
|
+
const theme = useTheme();
|
|
91
|
+
const [open, setOpen] = React.useState(true);
|
|
92
|
+
const isArabic = props.lang === "ar";
|
|
93
|
+
const [anchorElNav, setAnchorElNav] = React.useState(null);
|
|
94
|
+
const [anchorElUser, setAnchorElUser] = React.useState(null);
|
|
95
|
+
|
|
96
|
+
const handleOpenNavMenu = (event) => setAnchorElNav(event.currentTarget);
|
|
97
|
+
const handleOpenUserMenu = (event) => setAnchorElUser(event.currentTarget);
|
|
98
|
+
const handleCloseNavMenu = () => setAnchorElNav(null);
|
|
99
|
+
const handleCloseUserMenu = () => setAnchorElUser(null);
|
|
100
|
+
const handleDrawerOpen = () => setOpen(true);
|
|
101
|
+
const handleDrawerClose = () => setOpen(false);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
setOpen(!open);
|
|
105
|
+
}, []);
|
|
106
|
+
return (
|
|
107
|
+
<Box sx={{ display: "flex", direction: isArabic ? "rtl" : "ltr" }}>
|
|
108
|
+
<AppBar
|
|
109
|
+
variant="appbar"
|
|
110
|
+
position="fixed"
|
|
111
|
+
open={open}
|
|
112
|
+
direction={isArabic ? "rtl" : "ltr"}
|
|
113
|
+
>
|
|
114
|
+
<Toolbar
|
|
115
|
+
variant="appbar"
|
|
116
|
+
sx={{ paddingLeft: { xs: 3 }, paddingRight: { xs: 3 } }}
|
|
117
|
+
>
|
|
118
|
+
<IconButton
|
|
119
|
+
color="inherit"
|
|
120
|
+
aria-label="open drawer"
|
|
121
|
+
onClick={handleDrawerOpen}
|
|
122
|
+
edge="start"
|
|
123
|
+
s
|
|
124
|
+
sx={{
|
|
125
|
+
marginRight: 5,
|
|
126
|
+
...(open && { display: "none" })
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
<MenuIcon />
|
|
130
|
+
</IconButton>
|
|
131
|
+
|
|
132
|
+
<div
|
|
133
|
+
style={{
|
|
134
|
+
display: "flex",
|
|
135
|
+
flexDirection: "row",
|
|
136
|
+
justifyContent: "space-between",
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
width: "100%",
|
|
139
|
+
margin: 0
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<Typography
|
|
143
|
+
variant="h6"
|
|
144
|
+
noWrap
|
|
145
|
+
component="div"
|
|
146
|
+
sx={{
|
|
147
|
+
display: {
|
|
148
|
+
xs: open ? "none" : "flex",
|
|
149
|
+
sm: "flex"
|
|
150
|
+
}
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
{props.pageTitle}
|
|
154
|
+
</Typography>
|
|
155
|
+
|
|
156
|
+
<Box style={{ position: "absolute", right: 10 }}>
|
|
157
|
+
<Tooltip title="Open settings">
|
|
158
|
+
<IconButton
|
|
159
|
+
onClick={handleOpenUserMenu}
|
|
160
|
+
// sx={{ p: 0 }}
|
|
161
|
+
size="small"
|
|
162
|
+
>
|
|
163
|
+
<Avatar
|
|
164
|
+
style={{ width: 30, height: 30 }}
|
|
165
|
+
fontSize="inherit"
|
|
166
|
+
/>
|
|
167
|
+
</IconButton>
|
|
168
|
+
</Tooltip>
|
|
169
|
+
<HawaPopMenu
|
|
170
|
+
menuItems={props.accountMenu}
|
|
171
|
+
anchor={anchorElUser}
|
|
172
|
+
handleClose={handleCloseUserMenu}
|
|
173
|
+
/>
|
|
174
|
+
</Box>
|
|
175
|
+
</div>
|
|
176
|
+
</Toolbar>
|
|
177
|
+
</AppBar>
|
|
178
|
+
|
|
179
|
+
<Drawer
|
|
180
|
+
// anchor="left"
|
|
181
|
+
|
|
182
|
+
variant="permanent"
|
|
183
|
+
open={open}
|
|
184
|
+
// sx={{ display: { xs: open ? "flex" : "none", md: "flex" } }}
|
|
185
|
+
>
|
|
186
|
+
<DrawerHeader direction={isArabic ? "rtl" : "ltr"}>
|
|
187
|
+
{props.logo}
|
|
188
|
+
<IconButton onClick={handleDrawerClose}>
|
|
189
|
+
{theme.direction === "rtl" ? (
|
|
190
|
+
<ChevronRightIcon />
|
|
191
|
+
) : (
|
|
192
|
+
<ChevronLeftIcon />
|
|
193
|
+
)}
|
|
194
|
+
</IconButton>
|
|
195
|
+
</DrawerHeader>
|
|
196
|
+
{/* <Divider /> */}
|
|
197
|
+
<List
|
|
198
|
+
// sx={{
|
|
199
|
+
// display: {
|
|
200
|
+
// xs: open ? "flex" : "none",
|
|
201
|
+
// sm: open ? "flex" : "none",
|
|
202
|
+
// md: "flex"
|
|
203
|
+
// },
|
|
204
|
+
// flexDirection: "column",
|
|
205
|
+
// padding: 0
|
|
206
|
+
// }}
|
|
207
|
+
>
|
|
208
|
+
{props.pages.map((p, jk) => {
|
|
209
|
+
return (
|
|
210
|
+
<Tooltip
|
|
211
|
+
title={p.text}
|
|
212
|
+
key={jk}
|
|
213
|
+
placement={"right"}
|
|
214
|
+
arrow={true}
|
|
215
|
+
PopperProps={{ style: { opacity: open ? 0 : 1 } }}
|
|
216
|
+
>
|
|
217
|
+
<ListItemButton
|
|
218
|
+
variant={
|
|
219
|
+
props.pageName?.toLowerCase() === p.slug?.toLowerCase() &&
|
|
220
|
+
"clicked"
|
|
221
|
+
}
|
|
222
|
+
onClick={p.action}
|
|
223
|
+
key={p.text}
|
|
224
|
+
sx={{
|
|
225
|
+
minHeight: 48,
|
|
226
|
+
justifyContent: open ? "initial" : "center",
|
|
227
|
+
px: 2.5
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
<p.icon />
|
|
231
|
+
<div style={{ width: 20 }} />
|
|
232
|
+
<ListItemText
|
|
233
|
+
primary={p.text}
|
|
234
|
+
sx={{ opacity: open ? 1 : 0 }}
|
|
235
|
+
/>
|
|
236
|
+
</ListItemButton>
|
|
237
|
+
</Tooltip>
|
|
238
|
+
);
|
|
239
|
+
})}
|
|
240
|
+
</List>
|
|
241
|
+
</Drawer>
|
|
242
|
+
<Box
|
|
243
|
+
onClick={open && (() => setOpen(false))}
|
|
244
|
+
sx={{
|
|
245
|
+
flexGrow: 1,
|
|
246
|
+
p: 3,
|
|
247
|
+
position: "absolute",
|
|
248
|
+
left: {
|
|
249
|
+
xs: open ? 4 : 4,
|
|
250
|
+
sm: open ? drawerWidth + 4 : 70
|
|
251
|
+
},
|
|
252
|
+
right: { xs: 4 }
|
|
253
|
+
}}
|
|
254
|
+
>
|
|
255
|
+
<DrawerHeader />
|
|
256
|
+
<div style={{ marginTop: -10 }}>{props.children}</div>
|
|
257
|
+
</Box>
|
|
258
|
+
</Box>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
@@ -345,4 +345,4 @@
|
|
|
345
345
|
|
|
346
346
|
|
|
347
347
|
|
|
348
|
-
window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.mdx","importPathMatcher":"^\\.[\\\\/](?:src(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.mdx)$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];</script><script src="runtime~main.708d7ac1.iframe.bundle.js"></script><script src="vendors~main.
|
|
348
|
+
window['STORIES'] = [{"titlePrefix":"","directory":"./src","files":"**/*.stories.mdx","importPathMatcher":"^\\.[\\\\/](?:src(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.mdx)$"},{"titlePrefix":"","directory":"./src","files":"**/*.stories.@(js|jsx|ts|tsx)","importPathMatcher":"^\\.[\\\\/](?:src(?:[\\\\/](?!\\.)(?:(?:(?!(?:^|[\\\\/])\\.).)*?)[\\\\/]|[\\\\/]|$)(?!\\.)(?=.)[^\\\\/]*?\\.stories\\.(js|jsx|ts|tsx))$"}];</script><script src="runtime~main.708d7ac1.iframe.bundle.js"></script><script src="vendors~main.3cf4a535.iframe.bundle.js"></script><script src="main.3f5171ae.iframe.bundle.js"></script></body></html>
|