wcz-layout 5.6.0 → 5.7.0
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/src/components/Button.d.ts +3 -0
- package/dist/src/components/Button.js +9 -0
- package/dist/src/components/Button.js.map +1 -0
- package/dist/src/components/Layout.d.ts +3 -3
- package/dist/src/components/Layout.js +25 -25
- package/dist/src/components/Layout.js.map +1 -1
- package/dist/src/components/LayoutSnackbar.js +6 -6
- package/dist/src/components/LayoutSnackbar.js.map +1 -1
- package/dist/src/components/common/CenteredBox.js +2 -2
- package/dist/src/components/common/CenteredBox.js.map +1 -1
- package/dist/src/components/layout/AccountMenu.d.ts +4 -4
- package/dist/src/components/layout/AccountMenu.js +17 -17
- package/dist/src/components/layout/AccountMenu.js.map +1 -1
- package/dist/src/components/layout/LeftDrawer.d.ts +1 -1
- package/dist/src/components/layout/LeftDrawer.js +24 -24
- package/dist/src/components/layout/LeftDrawer.js.map +1 -1
- package/dist/src/contexts/LayoutContext.d.ts +7 -7
- package/dist/src/contexts/LayoutContext.js +22 -22
- package/dist/src/contexts/LayoutContext.js.map +1 -1
- package/dist/src/contexts/SnackbarContext.d.ts +2 -2
- package/dist/src/contexts/SnackbarContext.js +1 -1
- package/dist/src/contexts/SnackbarContext.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/Fetches.js +10 -10
- package/dist/src/utils/Fetches.js.map +1 -1
- package/dist/src/utils/Helpers.js +2 -2
- package/dist/src/utils/Helpers.js.map +1 -1
- package/dist/src/utils/PersistStorage.js +1 -1
- package/dist/src/utils/PersistStorage.js.map +1 -1
- package/dist/src/utils/UseUser.d.ts +1 -1
- package/dist/src/utils/UseUser.js +7 -7
- package/dist/src/utils/UseUser.js.map +1 -1
- package/dist/src/utils/UserService.d.ts +1 -1
- package/dist/src/utils/UserService.js +19 -19
- package/dist/src/utils/UserService.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/Button.tsx +10 -0
- package/src/components/Layout.tsx +32 -32
- package/src/components/LayoutSnackbar.tsx +6 -6
- package/src/components/common/CenteredBox.tsx +3 -3
- package/src/components/layout/AccountMenu.tsx +41 -41
- package/src/components/layout/LeftDrawer.tsx +29 -29
- package/src/contexts/LayoutContext.tsx +28 -28
- package/src/contexts/SnackbarContext.tsx +2 -2
- package/src/index.ts +1 -0
- package/src/utils/Fetches.ts +10 -10
- package/src/utils/Helpers.ts +2 -2
- package/src/utils/PersistStorage.ts +1 -1
- package/src/utils/UseUser.tsx +8 -8
- package/src/utils/UserService.ts +21 -21
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Button as MaterialButton } from "@mui/material";
|
|
3
|
+
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
|
4
|
+
export const Button = props => {
|
|
5
|
+
const isFetching = !!useIsFetching();
|
|
6
|
+
const isMutating = !!useIsMutating();
|
|
7
|
+
return _jsx(MaterialButton, { ...props, disabled: isFetching || isMutating || props.disabled });
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../src/components/Button.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAe,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAGrE,MAAM,CAAC,MAAM,MAAM,GAA0B,KAAK,CAAC,EAAE;IACjD,MAAM,UAAU,GAAG,CAAC,CAAC,aAAa,EAAE,CAAC;IACrC,MAAM,UAAU,GAAG,CAAC,CAAC,aAAa,EAAE,CAAC;IAErC,OAAO,KAAC,cAAc,OAAK,KAAK,EAAE,QAAQ,EAAE,UAAU,IAAI,UAAU,IAAI,KAAK,CAAC,QAAQ,GAAI,CAAC;AAC/F,CAAC,CAAC","sourcesContent":["import { Button as MaterialButton, ButtonProps } from \"@mui/material\";\r\nimport { useIsFetching, useIsMutating } from \"@tanstack/react-query\";\r\nimport React from \"react\";\r\n\r\nexport const Button: React.FC<ButtonProps> = props => {\r\n const isFetching = !!useIsFetching();\r\n const isMutating = !!useIsMutating();\r\n\r\n return <MaterialButton {...props} disabled={isFetching || isMutating || props.disabled} />;\r\n};"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { LeftDrawerItem } from
|
|
3
|
-
import { ExtendedUser } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LeftDrawerItem } from "../models/LeftDrawerItem";
|
|
3
|
+
import { ExtendedUser } from "../models/User";
|
|
4
4
|
interface LayoutProps {
|
|
5
5
|
title: string;
|
|
6
6
|
appVersion: string;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Menu } from
|
|
4
|
-
import { AppBar as MuiAppBar, Box, Chip, CssBaseline, IconButton, LinearProgress, Toolbar, Typography, useMediaQuery } from
|
|
5
|
-
import { csCZ, enUS } from
|
|
6
|
-
import { createTheme, styled, ThemeProvider } from
|
|
7
|
-
import { useIsFetching, useIsMutating } from
|
|
8
|
-
import { useCallback, useEffect, useState } from
|
|
9
|
-
import { useTranslation } from
|
|
10
|
-
import { useLocation } from
|
|
11
|
-
import { isDevelopment } from
|
|
12
|
-
import { persistStorage } from
|
|
13
|
-
import CenteredBox from
|
|
14
|
-
import AccountMenu from
|
|
15
|
-
import LeftDrawer from
|
|
3
|
+
import { Menu } from "@mui/icons-material";
|
|
4
|
+
import { AppBar as MuiAppBar, Box, Chip, CssBaseline, IconButton, LinearProgress, Toolbar, Typography, useMediaQuery } from "@mui/material";
|
|
5
|
+
import { csCZ, enUS } from "@mui/material/locale";
|
|
6
|
+
import { createTheme, styled, ThemeProvider } from "@mui/material/styles";
|
|
7
|
+
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
|
8
|
+
import { useCallback, useEffect, useState } from "react";
|
|
9
|
+
import { useTranslation } from "react-i18next";
|
|
10
|
+
import { useLocation } from "react-router-dom";
|
|
11
|
+
import { isDevelopment } from "../utils/Helpers";
|
|
12
|
+
import { persistStorage } from "../utils/PersistStorage";
|
|
13
|
+
import CenteredBox from "./common/CenteredBox";
|
|
14
|
+
import AccountMenu from "./layout/AccountMenu";
|
|
15
|
+
import LeftDrawer from "./layout/LeftDrawer";
|
|
16
16
|
//Mode
|
|
17
|
-
const storedMode = (_a = persistStorage.get(
|
|
17
|
+
const storedMode = (_a = persistStorage.get("mode")) !== null && _a !== void 0 ? _a : "system";
|
|
18
18
|
//Drawer
|
|
19
19
|
const drawerWidth = 240;
|
|
20
|
-
const DrawerHeader = styled(
|
|
21
|
-
display:
|
|
22
|
-
alignItems:
|
|
23
|
-
justifyContent:
|
|
20
|
+
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
justifyContent: "flex-end",
|
|
24
24
|
padding: theme.spacing(0, 1),
|
|
25
25
|
// necessary for content to be below app bar
|
|
26
26
|
...theme.mixins.toolbar,
|
|
27
27
|
}));
|
|
28
28
|
const AppBar = styled(MuiAppBar, {
|
|
29
|
-
shouldForwardProp: (prop) => prop !==
|
|
29
|
+
shouldForwardProp: (prop) => prop !== "open",
|
|
30
30
|
})(({ theme, open }) => ({
|
|
31
31
|
zIndex: theme.zIndex.drawer + 1,
|
|
32
|
-
transition: theme.transitions.create([
|
|
32
|
+
transition: theme.transitions.create(["width", "margin"], {
|
|
33
33
|
easing: theme.transitions.easing.sharp,
|
|
34
34
|
duration: theme.transitions.duration.leavingScreen,
|
|
35
35
|
}),
|
|
36
36
|
...(open && {
|
|
37
37
|
marginLeft: drawerWidth,
|
|
38
38
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
39
|
-
transition: theme.transitions.create([
|
|
39
|
+
transition: theme.transitions.create(["width", "margin"], {
|
|
40
40
|
easing: theme.transitions.easing.sharp,
|
|
41
41
|
duration: theme.transitions.duration.enteringScreen,
|
|
42
42
|
}),
|
|
@@ -44,7 +44,7 @@ const AppBar = styled(MuiAppBar, {
|
|
|
44
44
|
}));
|
|
45
45
|
export default function Layout(props) {
|
|
46
46
|
const { primaryColor, secondaryColor, title, appVersion, leftDrawerItems, user, initialized, children } = props;
|
|
47
|
-
const prefersDarkMode = useMediaQuery(
|
|
47
|
+
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
|
|
48
48
|
const [mode, setMode] = useState(storedMode);
|
|
49
49
|
const [leftDrawerOpen, setLeftDrawerOpen] = useState(false);
|
|
50
50
|
const [authorized, setAuthorized] = useState(true);
|
|
@@ -54,11 +54,11 @@ export default function Layout(props) {
|
|
|
54
54
|
const { t, i18n } = useTranslation();
|
|
55
55
|
const theme = createTheme({
|
|
56
56
|
palette: {
|
|
57
|
-
mode: mode ===
|
|
57
|
+
mode: mode === "system" ? prefersDarkMode ? "dark" : "light" : mode,
|
|
58
58
|
primary: { main: primaryColor },
|
|
59
59
|
secondary: { main: secondaryColor },
|
|
60
60
|
},
|
|
61
|
-
}, i18n.language ===
|
|
61
|
+
}, i18n.language === "cs" ? csCZ : enUS);
|
|
62
62
|
useEffect(() => handleUnauthorized(), [location.pathname, initialized, leftDrawerItems]);
|
|
63
63
|
const handleUnauthorized = () => {
|
|
64
64
|
const activePage = leftDrawerItems.find(i => i.path === location.pathname);
|
|
@@ -67,6 +67,6 @@ export default function Layout(props) {
|
|
|
67
67
|
return setAuthorized(true);
|
|
68
68
|
};
|
|
69
69
|
const toggleDrawerOpen = useCallback(() => setLeftDrawerOpen(!leftDrawerOpen), [leftDrawerOpen]);
|
|
70
|
-
return (_jsxs(ThemeProvider, { theme: theme, children: [_jsxs(Box, { sx: { display:
|
|
70
|
+
return (_jsxs(ThemeProvider, { theme: theme, children: [_jsxs(Box, { sx: { display: "flex", position: "sticky" }, children: [_jsx(CssBaseline, {}), _jsx(AppBar, { position: "fixed", open: leftDrawerOpen, children: _jsxs(Toolbar, { children: [_jsx(IconButton, { color: "inherit", onClick: toggleDrawerOpen, edge: "start", sx: { marginRight: 2, ...(leftDrawerOpen && { display: "none" }) }, children: _jsx(Menu, {}) }), _jsx(Typography, { variant: "h6", noWrap: true, component: "div", sx: { flexGrow: 1 }, children: title }), isDevelopment && _jsx(Chip, { color: "secondary", sx: { mr: 1.5 }, label: "Development" }), _jsx(AccountMenu, { mode: mode, setMode: setMode, user: user })] }) }), _jsx(LeftDrawer, { appVersion: appVersion, items: leftDrawerItems, drawerOpen: leftDrawerOpen, setDrawerOpen: setLeftDrawerOpen }), _jsxs(Box, { component: "main", sx: { flex: 1, overflow: "auto" }, children: [_jsx(DrawerHeader, {}), authorized ? children : _jsx(CenteredBox, { label: t("Layout.Unauthorized") })] })] }), (isFetching || isMutating) && _jsx(LinearProgress, { sx: { position: "fixed", bottom: 0, left: 0, right: 0 } })] }));
|
|
71
71
|
}
|
|
72
72
|
//# sourceMappingURL=Layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../src/components/Layout.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAiC,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAsB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/L,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,aAAa,E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port { AppBar as MuiAppBar, AppBarProps as MuiAppBarProps, Box, Chip, CssBaseline, IconButton, LinearProgress, PaletteMode, Theme, Toolbar, Typography, useMediaQuery } from '@mui/material';\r\nimport { csCZ, enUS } from '@mui/material/locale';\r\nimport { createTheme, styled, ThemeProvider } from '@mui/material/styles';\r\nimport { useIsFetching, useIsMutating } from '@tanstack/react-query';\r\nimport React, { useCallback, useEffect, useState } from 'react';\r\nimport { useTranslation } from 'react-i18next';\r\nimport { useLocation } from 'react-router-dom';\r\nimport { LeftDrawerItem } from '../models/LeftDrawerItem';\r\nimport { ExtendedUser } from '../models/User';\r\nimport { isDevelopment } from '../utils/Helpers';\r\nimport { persistStorage } from '../utils/PersistStorage';\r\nimport CenteredBox from './common/CenteredBox';\r\nimport AccountMenu from './layout/AccountMenu';\r\nimport LeftDrawer from './layout/LeftDrawer';\r\n\r\n//Mode\r\nconst storedMode = persistStorage.get('mode') as PaletteMode ?? 'system';\r\n\r\n//Drawer\r\nconst drawerWidth = 240;\r\nconst DrawerHeader = styled('div')(({ theme }) => ({\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'flex-end',\r\n padding: theme.spacing(0, 1),\r\n // necessary for content to be below app bar\r\n ...theme.mixins.toolbar,\r\n}));\r\n\r\n//AppBar\r\ninterface AppBarProps extends MuiAppBarProps {\r\n open?: boolean;\r\n}\r\n\r\nconst AppBar = styled(MuiAppBar, {\r\n shouldForwardProp: (prop) => prop !== 'open',\r\n})<AppBarProps>(({ theme, open }) => ({\r\n zIndex: theme.zIndex.drawer + 1,\r\n transition: theme.transitions.create(['width', 'margin'], {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.leavingScreen,\r\n }),\r\n ...(open && {\r\n marginLeft: drawerWidth,\r\n width: `calc(100% - ${drawerWidth}px)`,\r\n transition: theme.transitions.create(['width', 'margin'], {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.enteringScreen,\r\n }),\r\n }),\r\n}));\r\n\r\n//Layout\r\ninterface LayoutProps {\r\n title: string,\r\n appVersion: string,\r\n leftDrawerItems: LeftDrawerItem[],\r\n primaryColor: string,\r\n secondaryColor: string,\r\n children: React.ReactNode,\r\n user: ExtendedUser,\r\n initialized: boolean\r\n}\r\n\r\nexport default function Layout(props: LayoutProps) {\r\n const { primaryColor, secondaryColor, title, appVersion, leftDrawerItems, user, initialized, children } = props;\r\n const prefersDarkMode: boolean = useMediaQuery('(prefers-color-scheme: dark)');\r\n const [mode, setMode] = useState<PaletteMode | 'system'>(storedMode);\r\n const [leftDrawerOpen, setLeftDrawerOpen] = useState<boolean>(false);\r\n const [authorized, setAuthorized] = useState<boolean>(true);\r\n const isFetching = !!useIsFetching();\r\n const isMutating = !!useIsMutating();\r\n const location = useLocation();\r\n const { t, i18n } = useTranslation();\r\n\r\n const theme: Theme = createTheme({\r\n palette: {\r\n mode: mode === 'system' ? prefersDarkMode ? 'dark' : 'light' : mode,\r\n primary: { main: primaryColor },\r\n secondary: { main: secondaryColor },\r\n },\r\n }, i18n.language === 'cs' ? csCZ : enUS);\r\n\r\n useEffect(() => handleUnauthorized(), [location.pathname, initialized, leftDrawerItems]);\r\n\r\n const handleUnauthorized = () => {\r\n const activePage: LeftDrawerItem | undefined = leftDrawerItems.find(i => i.path === location.pathname);\r\n if (activePage?.hidden)\r\n return setAuthorized(false);\r\n\r\n return setAuthorized(true);\r\n };\r\n\r\n const toggleDrawerOpen = useCallback(() => setLeftDrawerOpen(!leftDrawerOpen), [leftDrawerOpen]);\r\n\r\n return (\r\n <ThemeProvider theme={theme}>\r\n <Box sx={{ display: 'flex', position: 'sticky' }}>\r\n <CssBaseline />\r\n <AppBar position=\"fixed\" open={leftDrawerOpen}>\r\n <Toolbar>\r\n <IconButton color=\"inherit\" onClick={toggleDrawerOpen} edge=\"start\" sx={{ marginRight: 2, ...(leftDrawerOpen && { display: 'none' }) }} >\r\n <Menu />\r\n </IconButton>\r\n\r\n <Typography variant=\"h6\" noWrap component=\"div\" sx={{ flexGrow: 1 }}>{title}</Typography>\r\n\r\n {isDevelopment && <Chip color=\"secondary\" sx={{ mr: 1.5 }} label=\"Development\" />}\r\n\r\n <AccountMenu mode={mode} setMode={setMode} user={user} />\r\n </Toolbar>\r\n </AppBar>\r\n\r\n <LeftDrawer appVersion={appVersion} items={leftDrawerItems} drawerOpen={leftDrawerOpen} setDrawerOpen={setLeftDrawerOpen} />\r\n\r\n <Box component=\"main\" sx={{ flex: 1, overflow: 'auto' }}>\r\n <DrawerHeader />\r\n {authorized ? children : <CenteredBox label={t('Layout.Unauthorized')!} />}\r\n </Box>\r\n </Box>\r\n\r\n {(isFetching || isMutating) && <LinearProgress sx={{ position: 'fixed', bottom: 0, left: 0, right: 0 }} />}\r\n </ThemeProvider>\r\n );\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../src/components/Layout.tsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,SAAS,EAAiC,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAsB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC/L,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,cA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S,EAAC,KAAK,EAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,YAAG,KAAK,GAAc,EAExF,aAAa,IAAI,KAAC,IAAI,IAAC,KAAK,EAAC,WAAW,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,KAAK,EAAC,aAAa,GAAG,EAEjF,KAAC,WAAW,IAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAI,IACnD,GACL,EAET,KAAC,UAAU,IAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,iBAAiB,GAAI,EAE5H,MAAC,GAAG,IAAC,SAAS,EAAC,MAAM,EAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,aACnD,KAAC,YAAY,KAAG,EACf,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAC,WAAW,IAAC,KAAK,EAAE,CAAC,CAAC,qBAAqB,CAAE,GAAI,IACxE,IACJ,EAEL,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,KAAC,cAAc,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAI,IAC9F,CACnB,CAAC;AACN,CAAC","sourcesContent":["import { Menu } from \"@mui/icons-material\";\r\nimport { AppBar as MuiAppBar, AppBarProps as MuiAppBarProps, Box, Chip, CssBaseline, IconButton, LinearProgress, PaletteMode, Theme, Toolbar, Typography, useMediaQuery } from \"@mui/material\";\r\nimport { csCZ, enUS } from \"@mui/material/locale\";\r\nimport { createTheme, styled, ThemeProvider } from \"@mui/material/styles\";\r\nimport { useIsFetching, useIsMutating } from \"@tanstack/react-query\";\r\nimport React, { useCallback, useEffect, useState } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\nimport { useLocation } from \"react-router-dom\";\r\nimport { LeftDrawerItem } from \"../models/LeftDrawerItem\";\r\nimport { ExtendedUser } from \"../models/User\";\r\nimport { isDevelopment } from \"../utils/Helpers\";\r\nimport { persistStorage } from \"../utils/PersistStorage\";\r\nimport CenteredBox from \"./common/CenteredBox\";\r\nimport AccountMenu from \"./layout/AccountMenu\";\r\nimport LeftDrawer from \"./layout/LeftDrawer\";\r\n\r\n//Mode\r\nconst storedMode = persistStorage.get(\"mode\") as PaletteMode ?? \"system\";\r\n\r\n//Drawer\r\nconst drawerWidth = 240;\r\nconst DrawerHeader = styled(\"div\")(({ theme }) => ({\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"flex-end\",\r\n padding: theme.spacing(0, 1),\r\n // necessary for content to be below app bar\r\n ...theme.mixins.toolbar,\r\n}));\r\n\r\n//AppBar\r\ninterface AppBarProps extends MuiAppBarProps {\r\n open?: boolean;\r\n}\r\n\r\nconst AppBar = styled(MuiAppBar, {\r\n shouldForwardProp: (prop) => prop !== \"open\",\r\n})<AppBarProps>(({ theme, open }) => ({\r\n zIndex: theme.zIndex.drawer + 1,\r\n transition: theme.transitions.create([\"width\", \"margin\"], {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.leavingScreen,\r\n }),\r\n ...(open && {\r\n marginLeft: drawerWidth,\r\n width: `calc(100% - ${drawerWidth}px)`,\r\n transition: theme.transitions.create([\"width\", \"margin\"], {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.enteringScreen,\r\n }),\r\n }),\r\n}));\r\n\r\n//Layout\r\ninterface LayoutProps {\r\n title: string,\r\n appVersion: string,\r\n leftDrawerItems: LeftDrawerItem[],\r\n primaryColor: string,\r\n secondaryColor: string,\r\n children: React.ReactNode,\r\n user: ExtendedUser,\r\n initialized: boolean\r\n}\r\n\r\nexport default function Layout(props: LayoutProps) {\r\n const { primaryColor, secondaryColor, title, appVersion, leftDrawerItems, user, initialized, children } = props;\r\n const prefersDarkMode: boolean = useMediaQuery(\"(prefers-color-scheme: dark)\");\r\n const [mode, setMode] = useState<PaletteMode | \"system\">(storedMode);\r\n const [leftDrawerOpen, setLeftDrawerOpen] = useState<boolean>(false);\r\n const [authorized, setAuthorized] = useState<boolean>(true);\r\n const isFetching = !!useIsFetching();\r\n const isMutating = !!useIsMutating();\r\n const location = useLocation();\r\n const { t, i18n } = useTranslation();\r\n\r\n const theme: Theme = createTheme({\r\n palette: {\r\n mode: mode === \"system\" ? prefersDarkMode ? \"dark\" : \"light\" : mode,\r\n primary: { main: primaryColor },\r\n secondary: { main: secondaryColor },\r\n },\r\n }, i18n.language === \"cs\" ? csCZ : enUS);\r\n\r\n useEffect(() => handleUnauthorized(), [location.pathname, initialized, leftDrawerItems]);\r\n\r\n const handleUnauthorized = () => {\r\n const activePage: LeftDrawerItem | undefined = leftDrawerItems.find(i => i.path === location.pathname);\r\n if (activePage?.hidden)\r\n return setAuthorized(false);\r\n\r\n return setAuthorized(true);\r\n };\r\n\r\n const toggleDrawerOpen = useCallback(() => setLeftDrawerOpen(!leftDrawerOpen), [leftDrawerOpen]);\r\n\r\n return (\r\n <ThemeProvider theme={theme}>\r\n <Box sx={{ display: \"flex\", position: \"sticky\" }}>\r\n <CssBaseline />\r\n <AppBar position=\"fixed\" open={leftDrawerOpen}>\r\n <Toolbar>\r\n <IconButton color=\"inherit\" onClick={toggleDrawerOpen} edge=\"start\" sx={{ marginRight: 2, ...(leftDrawerOpen && { display: \"none\" }) }} >\r\n <Menu />\r\n </IconButton>\r\n\r\n <Typography variant=\"h6\" noWrap component=\"div\" sx={{ flexGrow: 1 }}>{title}</Typography>\r\n\r\n {isDevelopment && <Chip color=\"secondary\" sx={{ mr: 1.5 }} label=\"Development\" />}\r\n\r\n <AccountMenu mode={mode} setMode={setMode} user={user} />\r\n </Toolbar>\r\n </AppBar>\r\n\r\n <LeftDrawer appVersion={appVersion} items={leftDrawerItems} drawerOpen={leftDrawerOpen} setDrawerOpen={setLeftDrawerOpen} />\r\n\r\n <Box component=\"main\" sx={{ flex: 1, overflow: \"auto\" }}>\r\n <DrawerHeader />\r\n {authorized ? children : <CenteredBox label={t(\"Layout.Unauthorized\")!} />}\r\n </Box>\r\n </Box>\r\n\r\n {(isFetching || isMutating) && <LinearProgress sx={{ position: \"fixed\", bottom: 0, left: 0, right: 0 }} />}\r\n </ThemeProvider>\r\n );\r\n}\r\n"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Alert, AlertTitle, Snackbar } from
|
|
3
|
-
import { Fragment, useCallback, useContext } from
|
|
4
|
-
import { SnackbarContext } from
|
|
2
|
+
import { Alert, AlertTitle, Snackbar } from "@mui/material";
|
|
3
|
+
import { Fragment, useCallback, useContext } from "react";
|
|
4
|
+
import { SnackbarContext } from "../contexts/SnackbarContext";
|
|
5
5
|
export const LayoutSnackbar = () => {
|
|
6
6
|
const { snackbar, setSnackbar } = useContext(SnackbarContext);
|
|
7
7
|
const handleOnSnackbarClose = useCallback((_event, reason) => {
|
|
8
|
-
if (reason ===
|
|
8
|
+
if (reason === "clickaway")
|
|
9
9
|
return;
|
|
10
|
-
setSnackbar({ ...snackbar, message:
|
|
10
|
+
setSnackbar({ ...snackbar, message: "" });
|
|
11
11
|
}, [snackbar]);
|
|
12
|
-
return (_jsx(Snackbar, { open: !!snackbar.message, autoHideDuration: snackbar.autoHideDuration === undefined ? 6000 : snackbar.autoHideDuration, onClose: handleOnSnackbarClose, children: _jsx(Alert, { onClose: handleOnSnackbarClose, severity: snackbar.severity, sx: { width:
|
|
12
|
+
return (_jsx(Snackbar, { open: !!snackbar.message, autoHideDuration: snackbar.autoHideDuration === undefined ? 6000 : snackbar.autoHideDuration, onClose: handleOnSnackbarClose, children: _jsx(Alert, { onClose: handleOnSnackbarClose, severity: snackbar.severity, sx: { width: "100%" }, variant: "filled", children: snackbar.description ?
|
|
13
13
|
_jsxs(Fragment, { children: [_jsx(AlertTitle, { children: snackbar.message }), snackbar.description] })
|
|
14
14
|
:
|
|
15
15
|
snackbar.message }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutSnackbar.js","sourceRoot":"","sources":["../../../src/components/LayoutSnackbar.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAkB,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,CAAC,MAAM,cAAc,GAAa,GAAG,EAAE;IACzC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAE9D,MAAM,qBAAqB,GAAG,WAAW,CAAC,CAAC,MAA+B,EAAE,MAAe,EAAE,EAAE;QAC3F,IAAI,MAAM,KAAK,WAAW;YAAE,OAAO;QACnC,WAAW,CAAC,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACH,KAAC,QAAQ,IAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,EAAE,qBAAqB,YAC5J,KAAC,KAAK,IAAC,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAC,QAAQ,YACtG,QAAQ,CAAC,WAAW,CAAC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EAAE,MAAM,EAAE,EAAE,OAAO,EAAC,QAAQ,YACtG,QAAQ,CAAC,WAAW,CAAC,CAAC;gBACnB,MAAC,QAAQ,eACL,KAAC,UAAU,cAAE,QAAQ,CAAC,OAAO,GAAc,EAC1C,QAAQ,CAAC,WAAW,IACd;gBACX,CAAC;oBACD,QAAQ,CAAC,OAAO,GAEhB,GACD,CACd,CAAC;AACN,CAAC,CAAC","sourcesContent":["import { Alert, AlertTitle, Snackbar } from \"@mui/material\";\r\nimport { Fragment, SyntheticEvent, useCallback, useContext } from \"react\";\r\nimport { SnackbarContext } from \"../contexts/SnackbarContext\";\r\n\r\nexport const LayoutSnackbar: React.FC = () => {\r\n const { snackbar, setSnackbar } = useContext(SnackbarContext);\r\n\r\n const handleOnSnackbarClose = useCallback((_event?: SyntheticEvent | Event, reason?: string) => {\r\n if (reason === \"clickaway\") return;\r\n setSnackbar({ ...snackbar, message: \"\" });\r\n }, [snackbar]);\r\n\r\n return (\r\n <Snackbar open={!!snackbar.message} autoHideDuration={snackbar.autoHideDuration === undefined ? 6000 : snackbar.autoHideDuration} onClose={handleOnSnackbarClose}>\r\n <Alert onClose={handleOnSnackbarClose} severity={snackbar.severity} sx={{ width: \"100%\" }} variant=\"filled\">\r\n {snackbar.description ?\r\n <Fragment>\r\n <AlertTitle>{snackbar.message}</AlertTitle>\r\n {snackbar.description}\r\n </Fragment>\r\n :\r\n snackbar.message\r\n }\r\n </Alert>\r\n </Snackbar>\r\n );\r\n};"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, CircularProgress, Typography } from
|
|
2
|
+
import { Box, CircularProgress, Typography } from "@mui/material";
|
|
3
3
|
export default function CenteredBox(props) {
|
|
4
4
|
const { label, circularProgress } = props;
|
|
5
|
-
return (_jsx(Box, { sx: { position:
|
|
5
|
+
return (_jsx(Box, { sx: { position: "relative", height: { xs: "calc(100vh - 56px)", sm: "calc(100vh - 64px)" } }, children: _jsxs(Box, { sx: { position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)" }, children: [label && _jsx(Typography, { variant: "h6", children: label }), circularProgress && _jsx(CircularProgress, {})] }) }));
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=CenteredBox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CenteredBox.js","sourceRoot":"","sources":["../../../../src/components/common/CenteredBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOlE,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAuB;IACvD,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAE1C,OAAO,CACH,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,YAC7F,MAAC,GAAG,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAE,aACzF,KAAK,IAAI,KAAC,UAAU,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,GAAc,EACtD,gBAAgB,IAAI,KAAC,gBAAgB,KAAG,IACvC,GACJ,CACT,CAAC;AACN,CAAC","sourcesContent":["import { Box, CircularProgress, Typography } from
|
|
1
|
+
{"version":3,"file":"CenteredBox.js","sourceRoot":"","sources":["../../../../src/components/common/CenteredBox.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOlE,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAuB;IACvD,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,KAAK,CAAC;IAE1C,OAAO,CACH,KAAC,GAAG,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,YAC7F,MAAC,GAAG,IAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAE,aACzF,KAAK,IAAI,KAAC,UAAU,IAAC,OAAO,EAAC,IAAI,YAAE,KAAK,GAAc,EACtD,gBAAgB,IAAI,KAAC,gBAAgB,KAAG,IACvC,GACJ,CACT,CAAC;AACN,CAAC","sourcesContent":["import { Box, CircularProgress, Typography } from \"@mui/material\";\r\n\r\ninterface CenteredBoxProps {\r\n label?: string,\r\n circularProgress?: boolean\r\n}\r\n\r\nexport default function CenteredBox(props: CenteredBoxProps) {\r\n const { label, circularProgress } = props;\r\n\r\n return (\r\n <Box sx={{ position: \"relative\", height: { xs: \"calc(100vh - 56px)\", sm: \"calc(100vh - 64px)\" } }}>\r\n <Box sx={{ position: \"absolute\", top: \"50%\", left: \"50%\", transform: \"translate(-50%, -50%)\" }}>\r\n {label && <Typography variant=\"h6\">{label}</Typography>}\r\n {circularProgress && <CircularProgress />}\r\n </Box>\r\n </Box>\r\n );\r\n}"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PaletteMode } from
|
|
2
|
-
import { ExtendedUser } from
|
|
1
|
+
import { PaletteMode } from "@mui/material";
|
|
2
|
+
import { ExtendedUser } from "../../models/User";
|
|
3
3
|
interface AccountMenuProps {
|
|
4
|
-
mode: PaletteMode |
|
|
5
|
-
setMode: (mode: PaletteMode |
|
|
4
|
+
mode: PaletteMode | "system";
|
|
5
|
+
setMode: (mode: PaletteMode | "system") => void;
|
|
6
6
|
user: ExtendedUser;
|
|
7
7
|
}
|
|
8
8
|
export default function AccountMenu(props: AccountMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AccountCircle, ArrowBack, Brightness4, ChevronRight, DarkMode, LightMode, Login, Logout, SettingsBrightness, Translate } from
|
|
3
|
-
import { Avatar, Box, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, ListSubheader, Menu, Typography } from
|
|
4
|
-
import { grey } from
|
|
5
|
-
import { Fragment, useCallback, useRef, useState } from
|
|
6
|
-
import { useTranslation } from
|
|
7
|
-
import { persistStorage } from
|
|
2
|
+
import { AccountCircle, ArrowBack, Brightness4, ChevronRight, DarkMode, LightMode, Login, Logout, SettingsBrightness, Translate } from "@mui/icons-material";
|
|
3
|
+
import { Avatar, Box, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, ListSubheader, Menu, Typography } from "@mui/material";
|
|
4
|
+
import { grey } from "@mui/material/colors";
|
|
5
|
+
import { Fragment, useCallback, useRef, useState } from "react";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { persistStorage } from "../../utils/PersistStorage";
|
|
8
8
|
const drawerWidth = 240;
|
|
9
9
|
export default function AccountMenu(props) {
|
|
10
10
|
const { mode, setMode, user } = props;
|
|
11
11
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
12
|
-
const [tab, setTab] = useState(
|
|
12
|
+
const [tab, setTab] = useState("settings");
|
|
13
13
|
const open = Boolean(anchorEl);
|
|
14
14
|
const accountButtonElement = useRef(null);
|
|
15
15
|
const { t, i18n } = useTranslation();
|
|
@@ -20,14 +20,14 @@ export default function AccountMenu(props) {
|
|
|
20
20
|
const changeMode = useCallback((newMode) => () => {
|
|
21
21
|
setMode(newMode);
|
|
22
22
|
closeMenu();
|
|
23
|
-
persistStorage.set(
|
|
23
|
+
persistStorage.set("mode", newMode);
|
|
24
24
|
}, []);
|
|
25
25
|
const getNameInitials = () => {
|
|
26
|
-
const splittedName = user.name.split(
|
|
27
|
-
return `${splittedName[0][0]}${splittedName.length > 1 ? splittedName[1][0] :
|
|
26
|
+
const splittedName = user.name.split(" ");
|
|
27
|
+
return `${splittedName[0][0]}${splittedName.length > 1 ? splittedName[1][0] : ""}`;
|
|
28
28
|
};
|
|
29
29
|
const openMenu = useCallback((e) => setAnchorEl(e.currentTarget), []);
|
|
30
|
-
const closeMenu = useCallback(() => { setAnchorEl(null); setTimeout(() => setTab(
|
|
30
|
+
const closeMenu = useCallback(() => { setAnchorEl(null); setTimeout(() => setTab("settings"), 300); }, []);
|
|
31
31
|
const login = useCallback(() => {
|
|
32
32
|
user.login()
|
|
33
33
|
.catch(console.error);
|
|
@@ -37,15 +37,15 @@ export default function AccountMenu(props) {
|
|
|
37
37
|
.catch(console.error);
|
|
38
38
|
}, []);
|
|
39
39
|
const changeTab = useCallback((newTab) => () => setTab(newTab), []);
|
|
40
|
-
const settings = (_jsxs(List, { component: "nav", subheader: _jsx(ListSubheader, { sx: { backgroundColor:
|
|
41
|
-
const theme = (_jsxs(List, { subheader: _jsxs(ListSubheader, { onClick: changeTab(
|
|
42
|
-
const language = (_jsxs(List, { subheader: _jsxs(ListSubheader, { onClick: changeTab(
|
|
40
|
+
const settings = (_jsxs(List, { component: "nav", subheader: _jsx(ListSubheader, { sx: { backgroundColor: "transparent" }, children: t("Layout.Settings") }), children: [_jsxs(ListItemButton, { onClick: changeTab("theme"), sx: { py: 0.3 }, children: [_jsx(ListItemIcon, { children: _jsx(Brightness4, {}) }), _jsx(ListItemText, { primary: t("Layout.Appearance"), secondary: t(`Layout.${mode.charAt(0).toUpperCase() + mode.slice(1)}`) }), _jsx(ChevronRight, {})] }), _jsxs(ListItemButton, { onClick: changeTab("language"), sx: { py: 0.3 }, children: [_jsx(ListItemIcon, { children: _jsx(Translate, {}) }), _jsx(ListItemText, { primary: t("Layout.Language"), secondary: i18n.resolvedLanguage === "en" ? "English" : "Čeština" }), _jsx(ChevronRight, {})] })] }));
|
|
41
|
+
const theme = (_jsxs(List, { subheader: _jsxs(ListSubheader, { onClick: changeTab("settings"), sx: { backgroundColor: "transparent", display: "flex", alignItems: "center", px: 1, cursor: "pointer" }, children: [_jsx(IconButton, { size: "small", sx: { mr: 0.5 }, children: _jsx(ArrowBack, { fontSize: "small" }) }), " ", t("Layout.Appearance")] }), children: [_jsxs(ListItemButton, { onClick: changeMode("light"), disabled: mode === "light", children: [_jsx(ListItemIcon, { children: _jsx(LightMode, {}) }), _jsx(ListItemText, { primary: t("Layout.Light") })] }), _jsxs(ListItemButton, { onClick: changeMode("dark"), disabled: mode === "dark", children: [_jsx(ListItemIcon, { children: _jsx(DarkMode, {}) }), _jsx(ListItemText, { primary: t("Layout.Dark") })] }), _jsxs(ListItemButton, { onClick: changeMode("system"), disabled: mode === "system", children: [_jsx(ListItemIcon, { children: _jsx(SettingsBrightness, {}) }), _jsx(ListItemText, { primary: t("Layout.System") })] })] }));
|
|
42
|
+
const language = (_jsxs(List, { subheader: _jsxs(ListSubheader, { onClick: changeTab("settings"), sx: { backgroundColor: "transparent", display: "flex", alignItems: "center", px: 1, cursor: "pointer" }, children: [_jsx(IconButton, { size: "small", sx: { mr: 0.5 }, children: _jsx(ArrowBack, { fontSize: "small" }) }), " ", t("Layout.Language")] }), children: [_jsx(ListItemButton, { onClick: changeLanguage("en"), disabled: i18n.resolvedLanguage === "en", children: _jsx(ListItemText, { primary: "English" }) }), _jsx(ListItemButton, { onClick: changeLanguage("cs"), disabled: i18n.resolvedLanguage === "cs", children: _jsx(ListItemText, { primary: "\u010Ce\u0161tina" }) })] }));
|
|
43
43
|
return (_jsxs(Fragment, { children: [_jsx(IconButton, { color: "inherit", onClick: openMenu, edge: "end", ref: accountButtonElement, children: user.name ?
|
|
44
|
-
_jsx(Avatar, { sx: { bgcolor:
|
|
44
|
+
_jsx(Avatar, { sx: { bgcolor: "white", color: grey[800], width: 32, height: 32, }, children: _jsx(Typography, { variant: "subtitle2", sx: { fontWeight: "bold", lineHeight: 0 }, children: getNameInitials() }) })
|
|
45
45
|
:
|
|
46
46
|
_jsx(AccountCircle, {}) }), _jsx(Menu, { anchorEl: anchorEl, open: open, onClose: closeMenu, children: _jsxs(Box, { sx: { width: drawerWidth }, role: "presentation", children: [_jsx(List, { "aria-labelledby": "account-menu", children: user.name ?
|
|
47
|
-
_jsxs(Fragment, { children: [_jsx(ListItem, { children: _jsx(ListItemText, { primary: user.name, secondary: _jsxs("span", { children: [_jsx("span", { children: user.id }), _jsx("br", {}), _jsx("span", { children: user.department })] }) }) }), _jsxs(ListItemButton, { onClick: logout, children: [_jsx(ListItemIcon, { children: _jsx(Logout, { color: "error" }) }), _jsx(ListItemText, { primary: t(
|
|
47
|
+
_jsxs(Fragment, { children: [_jsx(ListItem, { children: _jsx(ListItemText, { primary: user.name, secondary: _jsxs("span", { children: [_jsx("span", { children: user.id }), _jsx("br", {}), _jsx("span", { children: user.department })] }) }) }), _jsxs(ListItemButton, { onClick: logout, children: [_jsx(ListItemIcon, { children: _jsx(Logout, { color: "error" }) }), _jsx(ListItemText, { primary: t("Layout.Logout") })] })] })
|
|
48
48
|
:
|
|
49
|
-
_jsxs(ListItemButton, { onClick: login, children: [_jsx(ListItemIcon, { children: _jsx(Login, { color: "success" }) }), _jsx(ListItemText, { primary: t(
|
|
49
|
+
_jsxs(ListItemButton, { onClick: login, children: [_jsx(ListItemIcon, { children: _jsx(Login, { color: "success" }) }), _jsx(ListItemText, { primary: t("Layout.LogIn") })] }) }), tab === "settings" && settings, tab === "theme" && theme, tab === "language" && language] }) })] }));
|
|
50
50
|
}
|
|
51
51
|
//# sourceMappingURL=AccountMenu.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountMenu.js","sourceRoot":"","sources":["../../../../src/components/layout/AccountMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,SAA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AC/B,IAAI,CAAC,IAAI,CAAC,CAAC;gCACR,MAAC,QAAQ,eACL,KAAC,QAAQ,cACL,KAAC,YAAY,IAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EACvC,2BACI,yBAAO,IAAI,CAAC,EAAE,GAAQ,EACtB,cAAM,EACN,yBAAO,IAAI,CAAC,UAAU,GAAQ,IAC3B,GACP,GACG,EAEX,MAAC,cAAc,IAAC,OAAO,EAAE,MAAM,aAC3B,KAAC,YAAY,cAAC,KAAC,MAAM,IAAC,KAAK,EAAC,OAAO,GAAG,GAAe,EACrD,KAAC,YAAY,IAAC,OAAO,EAAE,CAAC,CAAC,eAAe,CAAC,GAAI,IAChC,IACV;gCACX,CAAC;oCACD,MAAC,cAAc,IAAC,OAAO,EAAE,KAAK,aAC1B,KAAC,YAAY,cAAC,KAAC,KAAK,IAAC,KAAK,EAAC,SAAS,GAAG,GAAe,EACtD,KAAC,YAAY,IAAC,OAAO,EAAE,CAAC,CAAC,cAAc,CAAC,GAAI,IAC/B,GAElB,EAEN,GAAG,KAAK,UAAU,IAAI,QAAQ,EAC9B,GAAG,KAAK,OAAO,IAAI,KAAK,EACxB,GAAG,KAAK,UAAU,IAAI,QAAQ,IAC7B,GACH,IACA,CACd,CAAC;AACN,CAAC","sourcesContent":["import { AccountCircle, ArrowBack, Brightness4, ChevronRight, DarkMode, LightMode, Login, Logout, SettingsBrightness, Translate } from '@mui/icons-material';\r\nimport { Avatar, Box, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, ListSubheader, Menu, PaletteMode, Typography } from '@mui/material';\r\nimport { grey } from '@mui/material/colors';\r\nimport { Fragment, useCallback, useRef, useState } from 'react';\r\nimport { useTranslation } from 'react-i18next';\r\nimport { ExtendedUser } from '../../models/User';\r\nimport { persistStorage } from '../../utils/PersistStorage';\r\n\r\nconst drawerWidth = 240;\r\ntype TabType = 'settings' | 'theme' | 'language';\r\n\r\ninterface AccountMenuProps {\r\n mode: PaletteMode | 'system',\r\n setMode: (mode: PaletteMode | 'system') => void,\r\n user: ExtendedUser\r\n}\r\n\r\nexport default function AccountMenu(props: AccountMenuProps) {\r\n const { mode, setMode, user } = props;\r\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\r\n const [tab, setTab] = useState<TabType>('settings');\r\n const open = Boolean(anchorEl);\r\n const accountButtonElement = useRef<HTMLButtonElement>(null);\r\n const { t, i18n } = useTranslation();\r\n\r\n const changeLanguage = useCallback((newLanguage: 'en' | 'cs') => () => {\r\n i18n.changeLanguage(newLanguage)\r\n .finally(() => closeMenu());\r\n }, []);\r\n\r\n const changeMode = useCallback((newMode: PaletteMode | 'system') => () => {\r\n setMode(newMode);\r\n closeMenu();\r\n persistStorage.set('mode', newMode);\r\n }, []);\r\n\r\n const getNameInitials = (): string => {\r\n const splittedName: string[] = user.name.split(' ');\r\n return `${splittedName[0][0]}${splittedName.length > 1 ? splittedName[1][0] : ''}`;\r\n };\r\n\r\n const openMenu = useCallback((e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => setAnchorEl(e.currentTarget), []);\r\n const closeMenu = useCallback(() => { setAnchorEl(null); setTimeout(() => setTab('settings'), 300); }, []);\r\n\r\n const login = useCallback(() => {\r\n user.login()\r\n .catch(console.error);\r\n }, []);\r\n\r\n const logout = useCallback(() => {\r\n user.logout()\r\n .catch(console.error);\r\n }, []);\r\n\r\n const changeTab = useCallback((newTab: TabType) => () => setTab(newTab), []);\r\n\r\n const settings = (\r\n <List component=\"nav\" subheader={<ListSubheader sx={{ backgroundColor: 'transparent' }}>{t('Layout.Settings')}</ListSubheader>}>\r\n <ListItemButton onClick={changeTab('theme')} sx={{ py: 0.3 }}>\r\n <ListItemIcon>\r\n <Brightness4 />\r\n </ListItemIcon>\r\n <ListItemText primary={t('Layout.Appearance')} secondary={t(`Layout.${mode.charAt(0).toUpperCase() + mode.slice(1)}`)} />\r\n <ChevronRight />\r\n </ListItemButton>\r\n\r\n <ListItemButton onClick={changeTab('language')} sx={{ py: 0.3 }}>\r\n <ListItemIcon>\r\n <Translate />\r\n </ListItemIcon>\r\n <ListItemText primary={t('Layout.Language')} secondary={i18n.resolvedLanguage === 'en' ? 'English' : 'Čeština'} />\r\n <ChevronRight />\r\n </ListItemButton>\r\n </List>\r\n );\r\n\r\n const theme = (\r\n <List subheader={\r\n <ListSubheader onClick={changeTab('settings')} sx={{ backgroundColor: 'transparent', display: 'flex', alignItems: 'center', px: 1, cursor: 'pointer' }}>\r\n <IconButton size=\"small\" sx={{ mr: 0.5 }}>\r\n <ArrowBack fontSize=\"small\" />\r\n </IconButton> {t('Layout.Appearance')}\r\n </ListSubheader>\r\n }>\r\n <ListItemButton onClick={changeMode('light')} disabled={mode === 'light'}>\r\n <ListItemIcon>\r\n <LightMode />\r\n </ListItemIcon>\r\n <ListItemText primary={t('Layout.Light')} />\r\n </ListItemButton>\r\n <ListItemButton onClick={changeMode('dark')} disabled={mode === 'dark'}>\r\n <ListItemIcon>\r\n <DarkMode />\r\n </ListItemIcon>\r\n <ListItemText primary={t('Layout.Dark')} />\r\n </ListItemButton>\r\n <ListItemButton onClick={changeMode('system')} disabled={mode === 'system'}>\r\n <ListItemIcon>\r\n <SettingsBrightness />\r\n </ListItemIcon>\r\n <ListItemText primary={t('Layout.System')} />\r\n </ListItemButton>\r\n </List>\r\n );\r\n\r\n const language = (\r\n <List subheader={\r\n <ListSubheader onClick={changeTab('settings')} sx={{ backgroundColor: 'transparent', display: 'flex', alignItems: 'center', px: 1, cursor: 'pointer' }}>\r\n <IconButton size=\"small\" sx={{ mr: 0.5 }}>\r\n <ArrowBack fontSize=\"small\" />\r\n </IconButton> {t('Layout.Language')}\r\n </ListSubheader>\r\n }>\r\n <ListItemButton onClick={changeLanguage('en')} disabled={i18n.resolvedLanguage === 'en'}>\r\n <ListItemText primary=\"English\" />\r\n </ListItemButton>\r\n <ListItemButton onClick={changeLanguage('cs')} disabled={i18n.resolvedLanguage === 'cs'}>\r\n <ListItemText primary=\"Čeština\" />\r\n </ListItemButton>\r\n </List>\r\n );\r\n\r\n return (\r\n <Fragment>\r\n <IconButton color=\"inherit\" onClick={openMenu} edge=\"end\" ref={accountButtonElement}>\r\n {user.name ?\r\n <Avatar sx={{ bgcolor: 'white', color: grey[800], width: 32, height: 32, }}>\r\n <Typography variant=\"subtitle2\" sx={{ fontWeight: 'bold', lineHeight: 0 }}>\r\n {getNameInitials()}\r\n </Typography>\r\n </Avatar>\r\n :\r\n <AccountCircle />\r\n }\r\n </IconButton>\r\n\r\n <Menu anchorEl={anchorEl} open={open} onClose={closeMenu}>\r\n <Box sx={{ width: drawerWidth }} role=\"presentation\">\r\n <List aria-labelledby=\"account-menu\">\r\n {user.name ?\r\n <Fragment>\r\n <ListItem>\r\n <ListItemText primary={user.name} secondary={\r\n <span>\r\n <span>{user.id}</span>\r\n <br />\r\n <span>{user.department}</span>\r\n </span>\r\n } />\r\n </ListItem>\r\n\r\n <ListItemButton onClick={logout}>\r\n <ListItemIcon><Logout color=\"error\" /></ListItemIcon>\r\n <ListItemText primary={t('Layout.Logout')} />\r\n </ListItemButton>\r\n </Fragment>\r\n :\r\n <ListItemButton onClick={login}>\r\n <ListItemIcon><Login color=\"success\" /></ListItemIcon>\r\n <ListItemText primary={t('Layout.LogIn')} />\r\n </ListItemButton>\r\n }\r\n </List>\r\n\r\n {tab === 'settings' && settings}\r\n {tab === 'theme' && theme}\r\n {tab === 'language' && language}\r\n </Box>\r\n </Menu>\r\n </Fragment>\r\n );\r\n}"]}
|
|
1
|
+
{"version":3,"file":"AccountMenu.js","sourceRoot":"","sources":["../../../../src/components/layout/AccountMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC7J,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE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AAS,EACvC,2BACI,yBAAO,IAAI,CAAC,EAAE,GAAQ,EACtB,cAAM,EACN,yBAAO,IAAI,CAAC,UAAU,GAAQ,IAC3B,GACP,GACG,EAEX,MAAC,cAAc,IAAC,OAAO,EAAE,MAAM,aAC3B,KAAC,YAAY,cAAC,KAAC,MAAM,IAAC,KAAK,EAAC,OAAO,GAAG,GAAe,EACrD,KAAC,YAAY,IAAC,OAAO,EAAE,CAAC,CAAC,eAAe,CAAC,GAAI,IAChC,IACV;gCACX,CAAC;oCACD,MAAC,cAAc,IAAC,OAAO,EAAE,KAAK,aAC1B,KAAC,YAAY,cAAC,KAAC,KAAK,IAAC,KAAK,EAAC,SAAS,GAAG,GAAe,EACtD,KAAC,YAAY,IAAC,OAAO,EAAE,CAAC,CAAC,cAAc,CAAC,GAAI,IAC/B,GAElB,EAEN,GAAG,KAAK,UAAU,IAAI,QAAQ,EAC9B,GAAG,KAAK,OAAO,IAAI,KAAK,EACxB,GAAG,KAAK,UAAU,IAAI,QAAQ,IAC7B,GACH,IACA,CACd,CAAC;AACN,CAAC","sourcesContent":["import { AccountCircle, ArrowBack, Brightness4, ChevronRight, DarkMode, LightMode, Login, Logout, SettingsBrightness, Translate } from \"@mui/icons-material\";\r\nimport { Avatar, Box, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, ListSubheader, Menu, PaletteMode, Typography } from \"@mui/material\";\r\nimport { grey } from \"@mui/material/colors\";\r\nimport { Fragment, useCallback, useRef, useState } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\nimport { ExtendedUser } from \"../../models/User\";\r\nimport { persistStorage } from \"../../utils/PersistStorage\";\r\n\r\nconst drawerWidth = 240;\r\ntype TabType = \"settings\" | \"theme\" | \"language\";\r\n\r\ninterface AccountMenuProps {\r\n mode: PaletteMode | \"system\",\r\n setMode: (mode: PaletteMode | \"system\") => void,\r\n user: ExtendedUser\r\n}\r\n\r\nexport default function AccountMenu(props: AccountMenuProps) {\r\n const { mode, setMode, user } = props;\r\n const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);\r\n const [tab, setTab] = useState<TabType>(\"settings\");\r\n const open = Boolean(anchorEl);\r\n const accountButtonElement = useRef<HTMLButtonElement>(null);\r\n const { t, i18n } = useTranslation();\r\n\r\n const changeLanguage = useCallback((newLanguage: \"en\" | \"cs\") => () => {\r\n i18n.changeLanguage(newLanguage)\r\n .finally(() => closeMenu());\r\n }, []);\r\n\r\n const changeMode = useCallback((newMode: PaletteMode | \"system\") => () => {\r\n setMode(newMode);\r\n closeMenu();\r\n persistStorage.set(\"mode\", newMode);\r\n }, []);\r\n\r\n const getNameInitials = (): string => {\r\n const splittedName: string[] = user.name.split(\" \");\r\n return `${splittedName[0][0]}${splittedName.length > 1 ? splittedName[1][0] : \"\"}`;\r\n };\r\n\r\n const openMenu = useCallback((e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => setAnchorEl(e.currentTarget), []);\r\n const closeMenu = useCallback(() => { setAnchorEl(null); setTimeout(() => setTab(\"settings\"), 300); }, []);\r\n\r\n const login = useCallback(() => {\r\n user.login()\r\n .catch(console.error);\r\n }, []);\r\n\r\n const logout = useCallback(() => {\r\n user.logout()\r\n .catch(console.error);\r\n }, []);\r\n\r\n const changeTab = useCallback((newTab: TabType) => () => setTab(newTab), []);\r\n\r\n const settings = (\r\n <List component=\"nav\" subheader={<ListSubheader sx={{ backgroundColor: \"transparent\" }}>{t(\"Layout.Settings\")}</ListSubheader>}>\r\n <ListItemButton onClick={changeTab(\"theme\")} sx={{ py: 0.3 }}>\r\n <ListItemIcon>\r\n <Brightness4 />\r\n </ListItemIcon>\r\n <ListItemText primary={t(\"Layout.Appearance\")} secondary={t(`Layout.${mode.charAt(0).toUpperCase() + mode.slice(1)}`)} />\r\n <ChevronRight />\r\n </ListItemButton>\r\n\r\n <ListItemButton onClick={changeTab(\"language\")} sx={{ py: 0.3 }}>\r\n <ListItemIcon>\r\n <Translate />\r\n </ListItemIcon>\r\n <ListItemText primary={t(\"Layout.Language\")} secondary={i18n.resolvedLanguage === \"en\" ? \"English\" : \"Čeština\"} />\r\n <ChevronRight />\r\n </ListItemButton>\r\n </List>\r\n );\r\n\r\n const theme = (\r\n <List subheader={\r\n <ListSubheader onClick={changeTab(\"settings\")} sx={{ backgroundColor: \"transparent\", display: \"flex\", alignItems: \"center\", px: 1, cursor: \"pointer\" }}>\r\n <IconButton size=\"small\" sx={{ mr: 0.5 }}>\r\n <ArrowBack fontSize=\"small\" />\r\n </IconButton> {t(\"Layout.Appearance\")}\r\n </ListSubheader>\r\n }>\r\n <ListItemButton onClick={changeMode(\"light\")} disabled={mode === \"light\"}>\r\n <ListItemIcon>\r\n <LightMode />\r\n </ListItemIcon>\r\n <ListItemText primary={t(\"Layout.Light\")} />\r\n </ListItemButton>\r\n <ListItemButton onClick={changeMode(\"dark\")} disabled={mode === \"dark\"}>\r\n <ListItemIcon>\r\n <DarkMode />\r\n </ListItemIcon>\r\n <ListItemText primary={t(\"Layout.Dark\")} />\r\n </ListItemButton>\r\n <ListItemButton onClick={changeMode(\"system\")} disabled={mode === \"system\"}>\r\n <ListItemIcon>\r\n <SettingsBrightness />\r\n </ListItemIcon>\r\n <ListItemText primary={t(\"Layout.System\")} />\r\n </ListItemButton>\r\n </List>\r\n );\r\n\r\n const language = (\r\n <List subheader={\r\n <ListSubheader onClick={changeTab(\"settings\")} sx={{ backgroundColor: \"transparent\", display: \"flex\", alignItems: \"center\", px: 1, cursor: \"pointer\" }}>\r\n <IconButton size=\"small\" sx={{ mr: 0.5 }}>\r\n <ArrowBack fontSize=\"small\" />\r\n </IconButton> {t(\"Layout.Language\")}\r\n </ListSubheader>\r\n }>\r\n <ListItemButton onClick={changeLanguage(\"en\")} disabled={i18n.resolvedLanguage === \"en\"}>\r\n <ListItemText primary=\"English\" />\r\n </ListItemButton>\r\n <ListItemButton onClick={changeLanguage(\"cs\")} disabled={i18n.resolvedLanguage === \"cs\"}>\r\n <ListItemText primary=\"Čeština\" />\r\n </ListItemButton>\r\n </List>\r\n );\r\n\r\n return (\r\n <Fragment>\r\n <IconButton color=\"inherit\" onClick={openMenu} edge=\"end\" ref={accountButtonElement}>\r\n {user.name ?\r\n <Avatar sx={{ bgcolor: \"white\", color: grey[800], width: 32, height: 32, }}>\r\n <Typography variant=\"subtitle2\" sx={{ fontWeight: \"bold\", lineHeight: 0 }}>\r\n {getNameInitials()}\r\n </Typography>\r\n </Avatar>\r\n :\r\n <AccountCircle />\r\n }\r\n </IconButton>\r\n\r\n <Menu anchorEl={anchorEl} open={open} onClose={closeMenu}>\r\n <Box sx={{ width: drawerWidth }} role=\"presentation\">\r\n <List aria-labelledby=\"account-menu\">\r\n {user.name ?\r\n <Fragment>\r\n <ListItem>\r\n <ListItemText primary={user.name} secondary={\r\n <span>\r\n <span>{user.id}</span>\r\n <br />\r\n <span>{user.department}</span>\r\n </span>\r\n } />\r\n </ListItem>\r\n\r\n <ListItemButton onClick={logout}>\r\n <ListItemIcon><Logout color=\"error\" /></ListItemIcon>\r\n <ListItemText primary={t(\"Layout.Logout\")} />\r\n </ListItemButton>\r\n </Fragment>\r\n :\r\n <ListItemButton onClick={login}>\r\n <ListItemIcon><Login color=\"success\" /></ListItemIcon>\r\n <ListItemText primary={t(\"Layout.LogIn\")} />\r\n </ListItemButton>\r\n }\r\n </List>\r\n\r\n {tab === \"settings\" && settings}\r\n {tab === \"theme\" && theme}\r\n {tab === \"language\" && language}\r\n </Box>\r\n </Menu>\r\n </Fragment>\r\n );\r\n}"]}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ChevronLeft, ChevronRight } from
|
|
3
|
-
import { Box, Divider, Drawer as MuiDrawer, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, SwipeableDrawer, Typography } from
|
|
4
|
-
import { styled, useTheme } from
|
|
5
|
-
import { Fragment, useCallback, useMemo } from
|
|
6
|
-
import { useTranslation } from
|
|
7
|
-
import { useLocation, useNavigate } from
|
|
2
|
+
import { ChevronLeft, ChevronRight } from "@mui/icons-material";
|
|
3
|
+
import { Box, Divider, Drawer as MuiDrawer, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, SwipeableDrawer, Typography } from "@mui/material";
|
|
4
|
+
import { styled, useTheme } from "@mui/material/styles";
|
|
5
|
+
import { Fragment, useCallback, useMemo } from "react";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
8
8
|
const drawerWidth = 240;
|
|
9
9
|
const openedMixin = (theme) => ({
|
|
10
10
|
width: drawerWidth,
|
|
11
|
-
transition: theme.transitions.create(
|
|
11
|
+
transition: theme.transitions.create("width", {
|
|
12
12
|
easing: theme.transitions.easing.sharp,
|
|
13
13
|
duration: theme.transitions.duration.enteringScreen,
|
|
14
14
|
}),
|
|
15
|
-
overflowX:
|
|
15
|
+
overflowX: "hidden",
|
|
16
16
|
});
|
|
17
17
|
const closedMixin = (theme) => ({
|
|
18
|
-
transition: theme.transitions.create(
|
|
18
|
+
transition: theme.transitions.create("width", {
|
|
19
19
|
easing: theme.transitions.easing.sharp,
|
|
20
20
|
duration: theme.transitions.duration.leavingScreen,
|
|
21
21
|
}),
|
|
22
|
-
overflowX:
|
|
22
|
+
overflowX: "hidden",
|
|
23
23
|
width: `calc(${theme.spacing(7)} + 1px)`,
|
|
24
|
-
[theme.breakpoints.up(
|
|
24
|
+
[theme.breakpoints.up("sm")]: {
|
|
25
25
|
width: `calc(${theme.spacing(8.4)} + 1px)`,
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
|
-
const DrawerHeader = styled(
|
|
29
|
-
display:
|
|
30
|
-
alignItems:
|
|
31
|
-
justifyContent:
|
|
28
|
+
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
29
|
+
display: "flex",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
justifyContent: "flex-end",
|
|
32
32
|
padding: theme.spacing(0, 1),
|
|
33
33
|
// necessary for content to be below app bar
|
|
34
34
|
...theme.mixins.toolbar,
|
|
35
35
|
}));
|
|
36
|
-
const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !==
|
|
36
|
+
const Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== "open" })(({ theme, open }) => ({
|
|
37
37
|
width: drawerWidth,
|
|
38
38
|
flexShrink: 0,
|
|
39
|
-
whiteSpace:
|
|
40
|
-
boxSizing:
|
|
39
|
+
whiteSpace: "nowrap",
|
|
40
|
+
boxSizing: "border-box",
|
|
41
41
|
...(open && {
|
|
42
42
|
...openedMixin(theme),
|
|
43
|
-
|
|
43
|
+
"& .MuiDrawer-paper": openedMixin(theme),
|
|
44
44
|
}),
|
|
45
45
|
...(!open && {
|
|
46
46
|
...closedMixin(theme),
|
|
47
|
-
|
|
47
|
+
"& .MuiDrawer-paper": closedMixin(theme),
|
|
48
48
|
}),
|
|
49
49
|
}));
|
|
50
|
-
const isExternalUrl = (url) => url.startsWith(
|
|
50
|
+
const isExternalUrl = (url) => url.startsWith("http://") || url.startsWith("https://");
|
|
51
51
|
export default function LeftDrawer(props) {
|
|
52
52
|
const { appVersion, drawerOpen, setDrawerOpen, items } = props;
|
|
53
53
|
const theme = useTheme();
|
|
@@ -61,11 +61,11 @@ export default function LeftDrawer(props) {
|
|
|
61
61
|
if (location.pathname === path)
|
|
62
62
|
return window.location.reload();
|
|
63
63
|
if (isExternalUrl(path))
|
|
64
|
-
return window.open(path,
|
|
64
|
+
return window.open(path, "_blank");
|
|
65
65
|
navigate(path);
|
|
66
66
|
}, [location.pathname]);
|
|
67
|
-
const menuItems = (_jsx(List, { children: items.filter(item => !item.hidden).map(item => _jsxs(Fragment, { children: [_jsx(ListItem, { disablePadding: true, sx: { display:
|
|
67
|
+
const menuItems = (_jsx(List, { children: items.filter(item => !item.hidden).map(item => _jsxs(Fragment, { children: [_jsx(ListItem, { disablePadding: true, sx: { display: "block" }, onClick: handleMenuItemClick(item.path), children: _jsxs(ListItemButton, { selected: location.pathname === item.path, children: [_jsx(ListItemIcon, { children: item.icon }), _jsx(ListItemText, { primary: t(item.title) })] }) }), item.divider && _jsx(Divider, { sx: { my: 1 } })] }, item.path)) }));
|
|
68
68
|
const hasItems = useMemo(() => (items.filter(item => !item.hidden).length > 1), [items]);
|
|
69
|
-
return (_jsxs(Fragment, { children: [_jsxs(Drawer, { variant: "permanent", open: drawerOpen, sx: { display: { xs:
|
|
69
|
+
return (_jsxs(Fragment, { children: [_jsxs(Drawer, { variant: "permanent", open: drawerOpen, sx: { display: { xs: "none", sm: hasItems ? "inherit" : "none" } }, children: [_jsxs(DrawerHeader, { children: [_jsxs(Typography, { sx: { flexGrow: 1, textAlign: "center", marginLeft: 3 }, children: [t("Layout.Version"), ": ", appVersion] }), _jsx(IconButton, { onClick: closeDrawer, children: theme.direction === "rtl" ? _jsx(ChevronRight, {}) : _jsx(ChevronLeft, {}) })] }), _jsx(Divider, {}), menuItems] }), _jsx(SwipeableDrawer, { anchor: "left", open: drawerOpen, onClose: closeDrawer, onOpen: openDrawer, sx: { display: { xs: "inherit", sm: hasItems ? "none" : "inherit" } }, children: _jsxs(Box, { sx: { width: drawerWidth }, role: "presentation", children: [_jsxs(Typography, { sx: { textAlign: "center", my: 1.5 }, children: [t("Layout.Version"), ": ", appVersion] }), menuItems] }) })] }));
|
|
70
70
|
}
|
|
71
71
|
//# sourceMappingURL=LeftDrawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeftDrawer.js","sourceRoot":"","sources":["../../../../src/components/layout/LeftDrawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,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AAC,GAAG,IAAC,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,IAAI,EAAC,cAAc,aAChD,MAAC,UAAU,IAAC,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,EAAE,aAAG,CAAC,CAAC,gBAAgB,CAAC,QAAI,UAAU,IAAc,EACjG,SAAS,IACR,GACQ,IACX,CACd,CAAC;AACN,CAAC","sourcesContent":["import { ChevronLeft, ChevronRight } from '@mui/icons-material';\r\nimport { Box, Divider, Drawer as MuiDrawer, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, SwipeableDrawer, Typography } from '@mui/material';\r\nimport { CSSObject, styled, Theme, useTheme } from '@mui/material/styles';\r\nimport { Fragment, useCallback, useMemo } from 'react';\r\nimport { useTranslation } from 'react-i18next';\r\nimport { useLocation, useNavigate } from 'react-router-dom';\r\nimport { LeftDrawerItem as LeftDrawerItemModel } from '../../models/LeftDrawerItem';\r\n\r\nconst drawerWidth = 240;\r\n\r\nconst openedMixin = (theme: Theme): CSSObject => ({\r\n width: drawerWidth,\r\n transition: theme.transitions.create('width', {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.enteringScreen,\r\n }),\r\n overflowX: 'hidden',\r\n});\r\n\r\nconst closedMixin = (theme: Theme): CSSObject => ({\r\n transition: theme.transitions.create('width', {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.leavingScreen,\r\n }),\r\n overflowX: 'hidden',\r\n width: `calc(${theme.spacing(7)} + 1px)`,\r\n [theme.breakpoints.up('sm')]: {\r\n width: `calc(${theme.spacing(8.4)} + 1px)`,\r\n },\r\n});\r\n\r\nconst DrawerHeader = styled('div')(({ theme }) => ({\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'flex-end',\r\n padding: theme.spacing(0, 1),\r\n // necessary for content to be below app bar\r\n ...theme.mixins.toolbar,\r\n}));\r\n\r\nconst Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== 'open' })(\r\n ({ theme, open }) => ({\r\n width: drawerWidth,\r\n flexShrink: 0,\r\n whiteSpace: 'nowrap',\r\n boxSizing: 'border-box',\r\n ...(open && {\r\n ...openedMixin(theme),\r\n '& .MuiDrawer-paper': openedMixin(theme),\r\n }),\r\n ...(!open && {\r\n ...closedMixin(theme),\r\n '& .MuiDrawer-paper': closedMixin(theme),\r\n }),\r\n }),\r\n);\r\n\r\nconst isExternalUrl = (url: string) => url.startsWith('http://') || url.startsWith('https://');\r\n\r\ninterface LeftDrawerProps {\r\n appVersion: string,\r\n drawerOpen: boolean,\r\n setDrawerOpen: (drawerOpen: boolean) => void,\r\n items: LeftDrawerItemModel[]\r\n}\r\n\r\nexport default function LeftDrawer(props: LeftDrawerProps) {\r\n const { appVersion, drawerOpen, setDrawerOpen, items } = props;\r\n const theme = useTheme();\r\n const { t } = useTranslation();\r\n const navigate = useNavigate();\r\n const location = useLocation();\r\n\r\n const openDrawer = useCallback(() => setDrawerOpen(true), []);\r\n const closeDrawer = useCallback(() => setDrawerOpen(false), []);\r\n\r\n const handleMenuItemClick = useCallback((path: string) => () => {\r\n setDrawerOpen(false);\r\n\r\n if (location.pathname === path)\r\n return window.location.reload();\r\n\r\n if (isExternalUrl(path))\r\n return window.open(path, '_blank');\r\n\r\n navigate(path);\r\n }, [location.pathname]);\r\n\r\n const menuItems = (\r\n <List>\r\n {items.filter(item => !item.hidden).map(item =>\r\n <Fragment key={item.path}>\r\n <ListItem disablePadding sx={{ display: 'block' }} onClick={handleMenuItemClick(item.path)}>\r\n <ListItemButton selected={location.pathname === item.path}>\r\n <ListItemIcon>\r\n {item.icon}\r\n </ListItemIcon>\r\n <ListItemText primary={t(item.title)} />\r\n </ListItemButton>\r\n </ListItem>\r\n\r\n {item.divider && <Divider sx={{ my: 1 }} />}\r\n </Fragment>\r\n )}\r\n </List>\r\n );\r\n\r\n const hasItems: boolean = useMemo(() => (items.filter(item => !item.hidden).length > 1), [items]);\r\n return (\r\n <Fragment>\r\n <Drawer variant=\"permanent\" open={drawerOpen} sx={{ display: { xs: 'none', sm: hasItems ? 'inherit' : 'none' } }}>\r\n <DrawerHeader>\r\n <Typography sx={{ flexGrow: 1, textAlign: 'center', marginLeft: 3 }}>{t('Layout.Version')}: {appVersion}</Typography>\r\n <IconButton onClick={closeDrawer}>\r\n {theme.direction === 'rtl' ? <ChevronRight /> : <ChevronLeft />}\r\n </IconButton>\r\n </DrawerHeader>\r\n <Divider />\r\n {menuItems}\r\n </Drawer>\r\n\r\n <SwipeableDrawer anchor=\"left\" open={drawerOpen} onClose={closeDrawer} onOpen={openDrawer} sx={{ display: { xs: 'inherit', sm: hasItems ? 'none' : 'inherit' } }}>\r\n <Box sx={{ width: drawerWidth }} role=\"presentation\">\r\n <Typography sx={{ textAlign: 'center', my: 1.5 }}>{t('Layout.Version')}: {appVersion}</Typography>\r\n {menuItems}\r\n </Box>\r\n </SwipeableDrawer>\r\n </Fragment>\r\n );\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"LeftDrawer.js","sourceRoot":"","sources":["../../../../src/components/layout/LeftDrawer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvK,OAAO,EAAa,MAAM,EAAS,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG5D,MAAM,WAAW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eft, ChevronRight } from \"@mui/icons-material\";\r\nimport { Box, Divider, Drawer as MuiDrawer, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, SwipeableDrawer, Typography } from \"@mui/material\";\r\nimport { CSSObject, styled, Theme, useTheme } from \"@mui/material/styles\";\r\nimport { Fragment, useCallback, useMemo } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\nimport { useLocation, useNavigate } from \"react-router-dom\";\r\nimport { LeftDrawerItem as LeftDrawerItemModel } from \"../../models/LeftDrawerItem\";\r\n\r\nconst drawerWidth = 240;\r\n\r\nconst openedMixin = (theme: Theme): CSSObject => ({\r\n width: drawerWidth,\r\n transition: theme.transitions.create(\"width\", {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.enteringScreen,\r\n }),\r\n overflowX: \"hidden\",\r\n});\r\n\r\nconst closedMixin = (theme: Theme): CSSObject => ({\r\n transition: theme.transitions.create(\"width\", {\r\n easing: theme.transitions.easing.sharp,\r\n duration: theme.transitions.duration.leavingScreen,\r\n }),\r\n overflowX: \"hidden\",\r\n width: `calc(${theme.spacing(7)} + 1px)`,\r\n [theme.breakpoints.up(\"sm\")]: {\r\n width: `calc(${theme.spacing(8.4)} + 1px)`,\r\n },\r\n});\r\n\r\nconst DrawerHeader = styled(\"div\")(({ theme }) => ({\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n justifyContent: \"flex-end\",\r\n padding: theme.spacing(0, 1),\r\n // necessary for content to be below app bar\r\n ...theme.mixins.toolbar,\r\n}));\r\n\r\nconst Drawer = styled(MuiDrawer, { shouldForwardProp: (prop) => prop !== \"open\" })(\r\n ({ theme, open }) => ({\r\n width: drawerWidth,\r\n flexShrink: 0,\r\n whiteSpace: \"nowrap\",\r\n boxSizing: \"border-box\",\r\n ...(open && {\r\n ...openedMixin(theme),\r\n \"& .MuiDrawer-paper\": openedMixin(theme),\r\n }),\r\n ...(!open && {\r\n ...closedMixin(theme),\r\n \"& .MuiDrawer-paper\": closedMixin(theme),\r\n }),\r\n }),\r\n);\r\n\r\nconst isExternalUrl = (url: string) => url.startsWith(\"http://\") || url.startsWith(\"https://\");\r\n\r\ninterface LeftDrawerProps {\r\n appVersion: string,\r\n drawerOpen: boolean,\r\n setDrawerOpen: (drawerOpen: boolean) => void,\r\n items: LeftDrawerItemModel[]\r\n}\r\n\r\nexport default function LeftDrawer(props: LeftDrawerProps) {\r\n const { appVersion, drawerOpen, setDrawerOpen, items } = props;\r\n const theme = useTheme();\r\n const { t } = useTranslation();\r\n const navigate = useNavigate();\r\n const location = useLocation();\r\n\r\n const openDrawer = useCallback(() => setDrawerOpen(true), []);\r\n const closeDrawer = useCallback(() => setDrawerOpen(false), []);\r\n\r\n const handleMenuItemClick = useCallback((path: string) => () => {\r\n setDrawerOpen(false);\r\n\r\n if (location.pathname === path)\r\n return window.location.reload();\r\n\r\n if (isExternalUrl(path))\r\n return window.open(path, \"_blank\");\r\n\r\n navigate(path);\r\n }, [location.pathname]);\r\n\r\n const menuItems = (\r\n <List>\r\n {items.filter(item => !item.hidden).map(item =>\r\n <Fragment key={item.path}>\r\n <ListItem disablePadding sx={{ display: \"block\" }} onClick={handleMenuItemClick(item.path)}>\r\n <ListItemButton selected={location.pathname === item.path}>\r\n <ListItemIcon>\r\n {item.icon}\r\n </ListItemIcon>\r\n <ListItemText primary={t(item.title)} />\r\n </ListItemButton>\r\n </ListItem>\r\n\r\n {item.divider && <Divider sx={{ my: 1 }} />}\r\n </Fragment>\r\n )}\r\n </List>\r\n );\r\n\r\n const hasItems: boolean = useMemo(() => (items.filter(item => !item.hidden).length > 1), [items]);\r\n return (\r\n <Fragment>\r\n <Drawer variant=\"permanent\" open={drawerOpen} sx={{ display: { xs: \"none\", sm: hasItems ? \"inherit\" : \"none\" } }}>\r\n <DrawerHeader>\r\n <Typography sx={{ flexGrow: 1, textAlign: \"center\", marginLeft: 3 }}>{t(\"Layout.Version\")}: {appVersion}</Typography>\r\n <IconButton onClick={closeDrawer}>\r\n {theme.direction === \"rtl\" ? <ChevronRight /> : <ChevronLeft />}\r\n </IconButton>\r\n </DrawerHeader>\r\n <Divider />\r\n {menuItems}\r\n </Drawer>\r\n\r\n <SwipeableDrawer anchor=\"left\" open={drawerOpen} onClose={closeDrawer} onOpen={openDrawer} sx={{ display: { xs: \"inherit\", sm: hasItems ? \"none\" : \"inherit\" } }}>\r\n <Box sx={{ width: drawerWidth }} role=\"presentation\">\r\n <Typography sx={{ textAlign: \"center\", my: 1.5 }}>{t(\"Layout.Version\")}: {appVersion}</Typography>\r\n {menuItems}\r\n </Box>\r\n </SwipeableDrawer>\r\n </Fragment>\r\n );\r\n}\r\n"]}
|