@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
|
@@ -1,12 +1,41 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
2
|
import Snackbar from "@mui/material/Snackbar";
|
|
3
3
|
import AlertTitle from "@mui/material/AlertTitle";
|
|
4
4
|
import Alert from "@mui/material/Alert";
|
|
5
|
+
import { IconButton } from "@mui/material";
|
|
6
|
+
import CloseIcon from "@mui/icons-material/Close";
|
|
5
7
|
|
|
6
8
|
export const HawaSnackbar = (props) => {
|
|
9
|
+
|
|
10
|
+
const [position, setPosition] = useState({vertical : "", horizontal : ""});
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if(props.position){
|
|
14
|
+
const p = props.position.split("-");
|
|
15
|
+
setPosition({vertical : p[0], horizontal : p[1]});
|
|
16
|
+
}
|
|
17
|
+
}, [props.position])
|
|
18
|
+
|
|
7
19
|
return (
|
|
8
|
-
<Snackbar
|
|
9
|
-
|
|
20
|
+
<Snackbar
|
|
21
|
+
open={props.open}
|
|
22
|
+
autoHideDuration={props.duration ? props.duration : null}
|
|
23
|
+
onClose={props.handleClose}
|
|
24
|
+
anchorOrigin={position}
|
|
25
|
+
action={
|
|
26
|
+
<>
|
|
27
|
+
<IconButton
|
|
28
|
+
aria-label="close"
|
|
29
|
+
style={{color: "black"}}
|
|
30
|
+
sx={{ p: 0.5 }}
|
|
31
|
+
onClick={props.handleClose}
|
|
32
|
+
>
|
|
33
|
+
<CloseIcon />
|
|
34
|
+
</IconButton>
|
|
35
|
+
</>
|
|
36
|
+
}
|
|
37
|
+
>
|
|
38
|
+
<Alert icon={false} severity={props.severity} onClose={props.isClosable ? props.handleClose : null}>
|
|
10
39
|
{props.title && <AlertTitle>{props.title}</AlertTitle>}
|
|
11
40
|
{props.text}
|
|
12
41
|
</Alert>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { styled, useTheme } from "@mui/material/styles";
|
|
3
3
|
import Box from "@mui/material/Box";
|
|
4
|
-
import
|
|
4
|
+
import Drawer from "@mui/material/Drawer";
|
|
5
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
5
6
|
import MuiAppBar from "@mui/material/AppBar";
|
|
6
7
|
import Toolbar from "@mui/material/Toolbar";
|
|
7
8
|
import List from "@mui/material/List";
|
|
@@ -11,211 +12,234 @@ import IconButton from "@mui/material/IconButton";
|
|
|
11
12
|
import MenuIcon from "@mui/icons-material/Menu";
|
|
12
13
|
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
13
14
|
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
|
14
|
-
import
|
|
15
|
+
import ListItem from "@mui/material/ListItem";
|
|
16
|
+
import ListItemIcon from "@mui/material/ListItemIcon";
|
|
15
17
|
import ListItemText from "@mui/material/ListItemText";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { HawaPopMenu } from "../elements/HawaPopMenu";
|
|
18
|
+
import InboxIcon from "@mui/icons-material/MoveToInbox";
|
|
19
|
+
import MailIcon from "@mui/icons-material/Mail";
|
|
19
20
|
|
|
20
21
|
const drawerWidth = 240;
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
}));
|
|
23
|
+
const Main = styled("main", { shouldForwardProp: (prop) => prop !== "open" })(
|
|
24
|
+
({ theme, open, direction }) => ({
|
|
25
|
+
flexGrow: 1,
|
|
26
|
+
padding: theme.spacing(3),
|
|
27
|
+
transition: theme.transitions.create("margin", {
|
|
28
|
+
easing: theme.transitions.easing.sharp,
|
|
29
|
+
duration: theme.transitions.duration.leavingScreen
|
|
30
|
+
}),
|
|
31
|
+
marginLeft: direction === "rtl" ? 0 : `-${drawerWidth}px`,
|
|
32
|
+
marginRight: direction === "rtl" ? `-${drawerWidth}px` : 0,
|
|
33
|
+
...(open && {
|
|
34
|
+
transition: theme.transitions.create("margin", {
|
|
35
|
+
easing: theme.transitions.easing.easeOut,
|
|
36
|
+
duration: theme.transitions.duration.enteringScreen
|
|
37
|
+
}),
|
|
38
|
+
marginLeft: direction === "ltr" && 0,
|
|
39
|
+
marginRight: direction === "rtl" && 0
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
);
|
|
51
43
|
|
|
52
44
|
const AppBar = styled(MuiAppBar, {
|
|
53
45
|
shouldForwardProp: (prop) => prop !== "open"
|
|
54
46
|
})(({ theme, open, direction }) => ({
|
|
55
|
-
|
|
56
|
-
transition: theme.transitions.create(["width", "margin"], {
|
|
47
|
+
transition: theme.transitions.create(["margin", "width"], {
|
|
57
48
|
easing: theme.transitions.easing.sharp,
|
|
58
49
|
duration: theme.transitions.duration.leavingScreen
|
|
59
50
|
}),
|
|
60
|
-
|
|
61
51
|
...(open && {
|
|
62
|
-
marginLeft: direction === "rtl" ? 0 : drawerWidth,
|
|
63
|
-
marginRight: direction === "rtl" ? drawerWidth : 0,
|
|
64
52
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
marginLeft: direction === "rtl" ? 0 : `${drawerWidth}px`,
|
|
54
|
+
marginRight: direction === "rtl" ? `${drawerWidth}px` : 0,
|
|
55
|
+
// marginLeft: `${drawerWidth}px`,
|
|
56
|
+
transition: theme.transitions.create(["margin", "width"], {
|
|
57
|
+
easing: theme.transitions.easing.easeOut,
|
|
67
58
|
duration: theme.transitions.duration.enteringScreen
|
|
68
59
|
})
|
|
69
60
|
})
|
|
70
61
|
}));
|
|
71
62
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
...(open && {
|
|
80
|
-
...openedMixin(theme),
|
|
81
|
-
"& .MuiDrawer-paper": openedMixin(theme)
|
|
82
|
-
}),
|
|
83
|
-
...(!open && {
|
|
84
|
-
...closedMixin(theme),
|
|
85
|
-
"& .MuiDrawer-paper": closedMixin(theme)
|
|
86
|
-
})
|
|
63
|
+
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
64
|
+
display: "flex",
|
|
65
|
+
alignItems: "center",
|
|
66
|
+
padding: theme.spacing(0, 1),
|
|
67
|
+
// necessary for content to be below app bar
|
|
68
|
+
...theme.mixins.toolbar,
|
|
69
|
+
justifyContent: "flex-end"
|
|
87
70
|
}));
|
|
88
71
|
|
|
89
|
-
export
|
|
72
|
+
export const HawaAppLayout = (props) => {
|
|
90
73
|
const theme = useTheme();
|
|
91
|
-
const [open, setOpen] = React.useState(
|
|
74
|
+
const [open, setOpen] = React.useState(false);
|
|
92
75
|
const isArabic = props.lang === "ar";
|
|
93
|
-
const
|
|
94
|
-
|
|
76
|
+
const handleDrawerOpen = () => {
|
|
77
|
+
setOpen(true);
|
|
78
|
+
};
|
|
95
79
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const handleCloseUserMenu = () => setAnchorElUser(null);
|
|
100
|
-
const handleDrawerOpen = () => setOpen(true);
|
|
101
|
-
const handleDrawerClose = () => setOpen(false);
|
|
80
|
+
const handleDrawerClose = () => {
|
|
81
|
+
setOpen(false);
|
|
82
|
+
};
|
|
102
83
|
|
|
103
84
|
return (
|
|
104
|
-
<Box sx={{ display: "flex"
|
|
85
|
+
<Box sx={{ display: "flex" }}>
|
|
86
|
+
<CssBaseline />
|
|
105
87
|
<AppBar
|
|
106
|
-
variant="appbar"
|
|
107
88
|
position="fixed"
|
|
108
89
|
open={open}
|
|
109
90
|
direction={isArabic ? "rtl" : "ltr"}
|
|
91
|
+
style={{
|
|
92
|
+
alignItems: isArabic ? "flex-end" : "flex-start",
|
|
93
|
+
justifyContent: "center"
|
|
94
|
+
}}
|
|
110
95
|
>
|
|
111
|
-
<Toolbar
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
96
|
+
<Toolbar>
|
|
97
|
+
{isArabic ? (
|
|
98
|
+
<>
|
|
99
|
+
<Typography variant="h6" noWrap component="div">
|
|
100
|
+
Persistent drawer
|
|
101
|
+
</Typography>
|
|
102
|
+
<IconButton
|
|
103
|
+
color="inherit"
|
|
104
|
+
aria-label="open drawer"
|
|
105
|
+
onClick={handleDrawerOpen}
|
|
106
|
+
edge={isArabic ? "end" : "start"}
|
|
107
|
+
sx={{ mr: 2, ...(open && { display: "none" }) }}
|
|
108
|
+
>
|
|
109
|
+
<MenuIcon />
|
|
110
|
+
</IconButton>
|
|
111
|
+
</>
|
|
112
|
+
) : (
|
|
113
|
+
<>
|
|
114
|
+
<IconButton
|
|
115
|
+
color="inherit"
|
|
116
|
+
aria-label="open drawer"
|
|
117
|
+
onClick={handleDrawerOpen}
|
|
118
|
+
edge={isArabic ? "end" : "start"}
|
|
119
|
+
sx={{
|
|
120
|
+
marginRight: isArabic ? 0 : 2,
|
|
121
|
+
marginLeft: isArabic ? 2 : 0,
|
|
122
|
+
...(open && { display: "none" })
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<MenuIcon />
|
|
126
|
+
</IconButton>
|
|
127
|
+
<Typography variant="h6" noWrap component="div">
|
|
128
|
+
Persistent drawer
|
|
129
|
+
</Typography>
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
132
|
+
</Toolbar>
|
|
133
|
+
</AppBar>
|
|
134
|
+
{!isArabic ? (
|
|
135
|
+
<>
|
|
136
|
+
<Drawer
|
|
121
137
|
sx={{
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
width: drawerWidth,
|
|
139
|
+
flexShrink: 0,
|
|
140
|
+
"& .MuiDrawer-paper": {
|
|
141
|
+
width: drawerWidth,
|
|
142
|
+
boxSizing: "border-box"
|
|
143
|
+
}
|
|
124
144
|
}}
|
|
145
|
+
variant="persistent"
|
|
146
|
+
anchor={isArabic ? "right" : "left"}
|
|
147
|
+
open={open}
|
|
125
148
|
>
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
149
|
+
<DrawerHeader>
|
|
150
|
+
<IconButton onClick={handleDrawerClose}>
|
|
151
|
+
{theme.direction === "ltr" ? (
|
|
152
|
+
<ChevronLeftIcon />
|
|
153
|
+
) : (
|
|
154
|
+
<ChevronRightIcon />
|
|
155
|
+
)}
|
|
156
|
+
</IconButton>
|
|
157
|
+
</DrawerHeader>
|
|
158
|
+
<Divider />
|
|
159
|
+
<List>
|
|
160
|
+
{["Inbox", "Starred", "Send email", "Drafts"].map(
|
|
161
|
+
(text, index) => (
|
|
162
|
+
<ListItem button key={text}>
|
|
163
|
+
<ListItemIcon>
|
|
164
|
+
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
|
|
165
|
+
</ListItemIcon>
|
|
166
|
+
<ListItemText primary={text} />
|
|
167
|
+
</ListItem>
|
|
168
|
+
)
|
|
169
|
+
)}
|
|
170
|
+
</List>
|
|
171
|
+
<Divider />
|
|
172
|
+
<List>
|
|
173
|
+
{["All mail", "Trash", "Spam"].map((text, index) => (
|
|
174
|
+
<ListItem button key={text}>
|
|
175
|
+
<ListItemIcon>
|
|
176
|
+
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
|
|
177
|
+
</ListItemIcon>
|
|
178
|
+
<ListItemText primary={text} />
|
|
179
|
+
</ListItem>
|
|
180
|
+
))}
|
|
181
|
+
</List>
|
|
182
|
+
</Drawer>
|
|
183
|
+
<Main open={open} direction={isArabic ? "rtl" : "ltr"}>
|
|
184
|
+
<DrawerHeader />
|
|
185
|
+
{props.children}
|
|
186
|
+
</Main>
|
|
187
|
+
</>
|
|
188
|
+
) : (
|
|
189
|
+
<>
|
|
190
|
+
<Main open={open} direction={isArabic ? "rtl" : "ltr"}>
|
|
191
|
+
<DrawerHeader />
|
|
192
|
+
{props.children}
|
|
193
|
+
</Main>
|
|
194
|
+
<Drawer
|
|
195
|
+
sx={{
|
|
196
|
+
width: drawerWidth,
|
|
197
|
+
flexShrink: 0,
|
|
198
|
+
"& .MuiDrawer-paper": {
|
|
199
|
+
width: drawerWidth,
|
|
200
|
+
boxSizing: "border-box"
|
|
201
|
+
}
|
|
138
202
|
}}
|
|
203
|
+
variant="persistent"
|
|
204
|
+
anchor={isArabic ? "right" : "left"}
|
|
205
|
+
open={open}
|
|
139
206
|
>
|
|
140
|
-
<
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)}
|
|
177
|
-
</IconButton>
|
|
178
|
-
</DrawerHeader>
|
|
179
|
-
<Divider />
|
|
180
|
-
<List>
|
|
181
|
-
{props.pages.map((p, jk) => {
|
|
182
|
-
return (
|
|
183
|
-
<Tooltip
|
|
184
|
-
title={p.text}
|
|
185
|
-
key={jk}
|
|
186
|
-
placement={"right"}
|
|
187
|
-
arrow={true}
|
|
188
|
-
PopperProps={{ style: { opacity: open ? 0 : 1 } }}
|
|
189
|
-
>
|
|
190
|
-
<ListItemButton
|
|
191
|
-
variant={
|
|
192
|
-
props.pageName?.toLowerCase() === p.slug?.toLowerCase() &&
|
|
193
|
-
"clicked"
|
|
194
|
-
}
|
|
195
|
-
onClick={p.action}
|
|
196
|
-
key={p.text}
|
|
197
|
-
sx={{
|
|
198
|
-
minHeight: 48,
|
|
199
|
-
justifyContent: open ? "initial" : "center",
|
|
200
|
-
px: 2.5
|
|
201
|
-
}}
|
|
202
|
-
>
|
|
203
|
-
<p.icon />
|
|
204
|
-
<div style={{ width: 20 }} />
|
|
205
|
-
<ListItemText
|
|
206
|
-
primary={p.text}
|
|
207
|
-
sx={{ opacity: open ? 1 : 0 }}
|
|
208
|
-
/>
|
|
209
|
-
</ListItemButton>
|
|
210
|
-
</Tooltip>
|
|
211
|
-
);
|
|
212
|
-
})}
|
|
213
|
-
</List>
|
|
214
|
-
</Drawer>
|
|
215
|
-
<Box sx={{ flexGrow: 1, p: 3 }}>
|
|
216
|
-
<DrawerHeader />
|
|
217
|
-
{props.children}
|
|
218
|
-
</Box>
|
|
207
|
+
<DrawerHeader>
|
|
208
|
+
<IconButton onClick={handleDrawerClose}>
|
|
209
|
+
{theme.direction === "ltr" ? (
|
|
210
|
+
<ChevronLeftIcon />
|
|
211
|
+
) : (
|
|
212
|
+
<ChevronRightIcon />
|
|
213
|
+
)}
|
|
214
|
+
</IconButton>
|
|
215
|
+
</DrawerHeader>
|
|
216
|
+
<Divider />
|
|
217
|
+
<List>
|
|
218
|
+
{["Inbox", "Starred", "Send email", "Drafts"].map(
|
|
219
|
+
(text, index) => (
|
|
220
|
+
<ListItem button key={text}>
|
|
221
|
+
<ListItemIcon>
|
|
222
|
+
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
|
|
223
|
+
</ListItemIcon>
|
|
224
|
+
<ListItemText primary={text} />
|
|
225
|
+
</ListItem>
|
|
226
|
+
)
|
|
227
|
+
)}
|
|
228
|
+
</List>
|
|
229
|
+
<Divider />
|
|
230
|
+
<List>
|
|
231
|
+
{["All mail", "Trash", "Spam"].map((text, index) => (
|
|
232
|
+
<ListItem button key={text}>
|
|
233
|
+
<ListItemIcon>
|
|
234
|
+
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
|
|
235
|
+
</ListItemIcon>
|
|
236
|
+
<ListItemText primary={text} />
|
|
237
|
+
</ListItem>
|
|
238
|
+
))}
|
|
239
|
+
</List>
|
|
240
|
+
</Drawer>
|
|
241
|
+
</>
|
|
242
|
+
)}
|
|
219
243
|
</Box>
|
|
220
244
|
);
|
|
221
|
-
}
|
|
245
|
+
};
|