@applica-software-guru/react-admin 1.1.93 → 1.1.95

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.
Files changed (156) hide show
  1. package/dist/components/AuthWrapper.d.ts.map +1 -1
  2. package/dist/components/Layout/Content.d.ts +5 -0
  3. package/dist/components/Layout/Content.d.ts.map +1 -0
  4. package/dist/components/Layout/Drawer/Drawer.d.ts +8 -0
  5. package/dist/components/Layout/Drawer/Drawer.d.ts.map +1 -0
  6. package/dist/components/Layout/Drawer/DrawerHeader.d.ts +8 -0
  7. package/dist/components/Layout/Drawer/DrawerHeader.d.ts.map +1 -0
  8. package/dist/components/Layout/Drawer/DrawerHeaderStyled.d.ts +4 -0
  9. package/dist/components/Layout/Drawer/DrawerHeaderStyled.d.ts.map +1 -0
  10. package/dist/components/Layout/Drawer/index.d.ts +3 -18
  11. package/dist/components/Layout/Drawer/index.d.ts.map +1 -1
  12. package/dist/components/Layout/Footer.d.ts +11 -10
  13. package/dist/components/Layout/Footer.d.ts.map +1 -1
  14. package/dist/components/Layout/Header/DrawerToggle.d.ts +3 -0
  15. package/dist/components/Layout/Header/DrawerToggle.d.ts.map +1 -0
  16. package/dist/components/Layout/Header/Header.d.ts +8 -0
  17. package/dist/components/Layout/Header/Header.d.ts.map +1 -0
  18. package/dist/components/Layout/Header/Notification/Notification.d.ts +3 -0
  19. package/dist/components/Layout/Header/Notification/Notification.d.ts.map +1 -0
  20. package/dist/components/Layout/Header/Notification/NotificationItem.d.ts +19 -0
  21. package/dist/components/Layout/Header/Notification/NotificationItem.d.ts.map +1 -0
  22. package/dist/components/Layout/Header/Notification/index.d.ts +2 -0
  23. package/dist/components/Layout/Header/Notification/index.d.ts.map +1 -0
  24. package/dist/components/Layout/Header/Profile/Profile.d.ts.map +1 -0
  25. package/dist/components/Layout/Header/Profile/buttons/ChangePasswordButton.d.ts.map +1 -0
  26. package/dist/components/Layout/Header/Profile/buttons/LogoutButton.d.ts.map +1 -0
  27. package/dist/components/Layout/Header/Profile/buttons/StopImpersonateButton.d.ts.map +1 -0
  28. package/dist/components/Layout/Header/Profile/buttons/index.d.ts.map +1 -0
  29. package/dist/components/Layout/Header/Profile/index.d.ts +2 -0
  30. package/dist/components/Layout/Header/Profile/index.d.ts.map +1 -0
  31. package/dist/components/Layout/Header/ResponsiveSection.d.ts +5 -0
  32. package/dist/components/Layout/Header/ResponsiveSection.d.ts.map +1 -0
  33. package/dist/components/Layout/Header/Spacer.d.ts +5 -0
  34. package/dist/components/Layout/Header/Spacer.d.ts.map +1 -0
  35. package/dist/components/Layout/Header/index.d.ts +7 -20
  36. package/dist/components/Layout/Header/index.d.ts.map +1 -1
  37. package/dist/components/Layout/HorizontalBar.d.ts +5 -0
  38. package/dist/components/Layout/HorizontalBar.d.ts.map +1 -0
  39. package/dist/components/Layout/Layout.d.ts +19 -0
  40. package/dist/components/Layout/Layout.d.ts.map +1 -0
  41. package/dist/components/Layout/NavMenu.d.ts +5 -0
  42. package/dist/components/Layout/NavMenu.d.ts.map +1 -0
  43. package/dist/components/Layout/Navigation/NavCollapse.d.ts.map +1 -0
  44. package/dist/components/Layout/{Drawer/DrawerContent/Navigation → Navigation}/NavGroup.d.ts +2 -3
  45. package/dist/components/Layout/Navigation/NavGroup.d.ts.map +1 -0
  46. package/dist/components/Layout/Navigation/NavItem.d.ts.map +1 -0
  47. package/dist/components/Layout/Navigation/Navigation.d.ts +7 -0
  48. package/dist/components/Layout/Navigation/Navigation.d.ts.map +1 -0
  49. package/dist/components/Layout/Navigation/index.d.ts +2 -0
  50. package/dist/components/Layout/Navigation/index.d.ts.map +1 -0
  51. package/dist/components/Layout/Provider.d.ts +84 -0
  52. package/dist/components/Layout/Provider.d.ts.map +1 -0
  53. package/dist/components/Layout/Wrapper.d.ts +6 -0
  54. package/dist/components/Layout/Wrapper.d.ts.map +1 -0
  55. package/dist/components/Layout/index.d.ts +10 -22
  56. package/dist/components/Layout/index.d.ts.map +1 -1
  57. package/dist/components/ra-inputs/AutocompleteArrayInput.d.ts +1 -0
  58. package/dist/components/ra-inputs/AutocompleteArrayInput.d.ts.map +1 -1
  59. package/dist/components/ra-inputs/AutocompleteInput.d.ts +1 -0
  60. package/dist/components/ra-inputs/AutocompleteInput.d.ts.map +1 -1
  61. package/dist/components/ra-lists/List.d.ts.map +1 -1
  62. package/dist/hooks/index.d.ts +2 -0
  63. package/dist/hooks/index.d.ts.map +1 -1
  64. package/dist/hooks/mui.d.ts +7 -0
  65. package/dist/hooks/mui.d.ts.map +1 -0
  66. package/dist/hooks/useRefDimensions.d.ts +13 -0
  67. package/dist/hooks/useRefDimensions.d.ts.map +1 -0
  68. package/dist/react-admin.cjs.js +101 -92
  69. package/dist/react-admin.cjs.js.map +1 -1
  70. package/dist/react-admin.es.js +23530 -20993
  71. package/dist/react-admin.es.js.map +1 -1
  72. package/dist/react-admin.umd.js +102 -93
  73. package/dist/react-admin.umd.js.map +1 -1
  74. package/dist/style.css +1 -1
  75. package/package.json +1 -1
  76. package/src/components/AuthWrapper.jsx +1 -1
  77. package/src/components/Layout/Content.tsx +30 -0
  78. package/src/components/Layout/Drawer/Drawer.tsx +61 -0
  79. package/src/components/Layout/Drawer/DrawerHeader.tsx +31 -0
  80. package/src/components/Layout/Drawer/{DrawerHeader/DrawerHeaderStyled.jsx → DrawerHeaderStyled.jsx} +1 -1
  81. package/src/components/Layout/Drawer/index.ts +3 -0
  82. package/src/components/Layout/Footer.tsx +26 -0
  83. package/src/components/Layout/Header/DrawerToggle.tsx +28 -0
  84. package/src/components/Layout/Header/Header.tsx +43 -0
  85. package/src/components/Layout/Header/{HeaderContent/Notification.jsx → Notification/Notification.tsx} +60 -54
  86. package/src/components/Layout/Header/Notification/NotificationItem.tsx +85 -0
  87. package/src/components/Layout/Header/Notification/index.ts +1 -0
  88. package/src/components/Layout/Header/{HeaderContent → Profile}/Profile.jsx +15 -3
  89. package/src/components/Layout/Header/Profile/index.ts +1 -0
  90. package/src/components/Layout/Header/{HeaderContent/MobileSection.jsx → ResponsiveSection.tsx} +31 -38
  91. package/src/components/Layout/Header/Spacer.tsx +9 -0
  92. package/src/components/Layout/Header/index.ts +7 -0
  93. package/src/components/Layout/HorizontalBar.tsx +39 -0
  94. package/src/components/Layout/Layout.tsx +60 -0
  95. package/src/components/Layout/NavMenu.tsx +12 -0
  96. package/src/components/Layout/{Drawer/DrawerContent/Navigation → Navigation}/NavCollapse.jsx +7 -8
  97. package/src/components/Layout/{Drawer/DrawerContent/Navigation → Navigation}/NavGroup.jsx +8 -19
  98. package/src/components/Layout/{Drawer/DrawerContent/Navigation → Navigation}/NavItem.jsx +7 -8
  99. package/src/components/Layout/Navigation/Navigation.tsx +76 -0
  100. package/src/components/Layout/Navigation/index.ts +1 -0
  101. package/src/components/Layout/Provider.tsx +290 -0
  102. package/src/components/Layout/Wrapper.tsx +16 -0
  103. package/src/components/Layout/index.ts +10 -0
  104. package/src/components/ra-inputs/AutocompleteArrayInput.jsx +5 -2
  105. package/src/components/ra-inputs/AutocompleteInput.jsx +6 -2
  106. package/src/components/ra-lists/List.tsx +1 -5
  107. package/src/hooks/index.jsx +2 -0
  108. package/src/hooks/mui.ts +21 -0
  109. package/src/hooks/useRefDimensions.ts +61 -0
  110. package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavCollapse.d.ts.map +0 -1
  111. package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.d.ts.map +0 -1
  112. package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavItem.d.ts.map +0 -1
  113. package/dist/components/Layout/Drawer/DrawerContent/Navigation/index.d.ts +0 -3
  114. package/dist/components/Layout/Drawer/DrawerContent/Navigation/index.d.ts.map +0 -1
  115. package/dist/components/Layout/Drawer/DrawerContent/index.d.ts +0 -3
  116. package/dist/components/Layout/Drawer/DrawerContent/index.d.ts.map +0 -1
  117. package/dist/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.d.ts +0 -5
  118. package/dist/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.d.ts.map +0 -1
  119. package/dist/components/Layout/Drawer/DrawerHeader/index.d.ts +0 -15
  120. package/dist/components/Layout/Drawer/DrawerHeader/index.d.ts.map +0 -1
  121. package/dist/components/Layout/Drawer/HorizontalBar.d.ts +0 -3
  122. package/dist/components/Layout/Drawer/HorizontalBar.d.ts.map +0 -1
  123. package/dist/components/Layout/Header/HeaderContent/MobileSection.d.ts +0 -3
  124. package/dist/components/Layout/Header/HeaderContent/MobileSection.d.ts.map +0 -1
  125. package/dist/components/Layout/Header/HeaderContent/Notification.d.ts +0 -16
  126. package/dist/components/Layout/Header/HeaderContent/Notification.d.ts.map +0 -1
  127. package/dist/components/Layout/Header/HeaderContent/NotificationItem.d.ts +0 -31
  128. package/dist/components/Layout/Header/HeaderContent/NotificationItem.d.ts.map +0 -1
  129. package/dist/components/Layout/Header/HeaderContent/Profile.d.ts.map +0 -1
  130. package/dist/components/Layout/Header/HeaderContent/buttons/ChangePasswordButton.d.ts.map +0 -1
  131. package/dist/components/Layout/Header/HeaderContent/buttons/LogoutButton.d.ts.map +0 -1
  132. package/dist/components/Layout/Header/HeaderContent/buttons/StopImpersonateButton.d.ts.map +0 -1
  133. package/dist/components/Layout/Header/HeaderContent/buttons/index.d.ts.map +0 -1
  134. package/dist/components/Layout/Header/HeaderContent/index.d.ts +0 -17
  135. package/dist/components/Layout/Header/HeaderContent/index.d.ts.map +0 -1
  136. package/src/components/Layout/Drawer/DrawerContent/Navigation/index.jsx +0 -73
  137. package/src/components/Layout/Drawer/DrawerContent/index.jsx +0 -19
  138. package/src/components/Layout/Drawer/DrawerHeader/index.jsx +0 -39
  139. package/src/components/Layout/Drawer/HorizontalBar.jsx +0 -55
  140. package/src/components/Layout/Drawer/index.jsx +0 -60
  141. package/src/components/Layout/Footer.jsx +0 -18
  142. package/src/components/Layout/Header/HeaderContent/NotificationItem.jsx +0 -97
  143. package/src/components/Layout/Header/HeaderContent/index.jsx +0 -36
  144. package/src/components/Layout/Header/index.jsx +0 -81
  145. package/src/components/Layout/index.jsx +0 -114
  146. /package/dist/components/Layout/Header/{HeaderContent → Profile}/Profile.d.ts +0 -0
  147. /package/dist/components/Layout/Header/{HeaderContent → Profile}/buttons/ChangePasswordButton.d.ts +0 -0
  148. /package/dist/components/Layout/Header/{HeaderContent → Profile}/buttons/LogoutButton.d.ts +0 -0
  149. /package/dist/components/Layout/Header/{HeaderContent → Profile}/buttons/StopImpersonateButton.d.ts +0 -0
  150. /package/dist/components/Layout/Header/{HeaderContent → Profile}/buttons/index.d.ts +0 -0
  151. /package/dist/components/Layout/{Drawer/DrawerContent/Navigation → Navigation}/NavCollapse.d.ts +0 -0
  152. /package/dist/components/Layout/{Drawer/DrawerContent/Navigation → Navigation}/NavItem.d.ts +0 -0
  153. /package/src/components/Layout/Header/{HeaderContent → Profile}/buttons/ChangePasswordButton.tsx +0 -0
  154. /package/src/components/Layout/Header/{HeaderContent → Profile}/buttons/LogoutButton.tsx +0 -0
  155. /package/src/components/Layout/Header/{HeaderContent → Profile}/buttons/StopImpersonateButton.tsx +0 -0
  156. /package/src/components/Layout/Header/{HeaderContent → Profile}/buttons/index.jsx +0 -0
@@ -1,45 +1,38 @@
1
1
  import { AppBar, Box, ClickAwayListener, Paper, Popper, Toolbar } from '@mui/material';
2
- import { IconButton, Transitions } from '../../../@extended';
3
- import { useEffect, useRef, useState } from 'react';
4
-
2
+ import { IconButton, Transitions } from '../../@extended';
3
+ import { useRef, useState, useCallback } from 'react';
5
4
  import { MoreOutlined } from '@ant-design/icons';
6
- import Profile from './Profile';
7
5
  import { useTheme } from '@mui/material/styles';
6
+ import { useLayoutMediaState, useLayoutThemeState } from '../Provider';
8
7
 
9
- const MobileSection = () => {
10
- const theme = useTheme();
11
-
12
- const [open, setOpen] = useState(false);
13
- const anchorRef = useRef(null);
14
-
15
- const handleToggle = () => {
16
- setOpen((prevOpen) => !prevOpen);
17
- };
18
-
19
- const handleClose = (event) => {
20
- if (anchorRef.current && anchorRef.current.contains(event.target)) {
21
- return;
22
- }
23
- setOpen(false);
24
- };
25
-
26
- const prevOpen = useRef(open);
27
- useEffect(() => {
28
- if (prevOpen.current === true && open === false) {
29
- anchorRef.current.focus();
30
- }
31
-
32
- prevOpen.current = open;
33
- }, [open]);
8
+ type IResponsiveSectionProps = React.PropsWithChildren;
34
9
 
35
- const iconBackColorOpen = theme.palette.mode === 'dark' ? 'grey.200' : 'grey.300';
36
- const iconBackColor = theme.palette.mode === 'dark' ? 'background.default' : 'grey.100';
10
+ const ResponsiveSection = (props: IResponsiveSectionProps) => {
11
+ const theme = useTheme(),
12
+ { downMd } = useLayoutMediaState(),
13
+ { iconColor, iconColorOpen } = useLayoutThemeState(),
14
+ [open, setOpen] = useState(false),
15
+ anchorRef = useRef(null),
16
+ handleToggle = useCallback(() => {
17
+ setOpen(!open);
18
+ }, [open]),
19
+ //@ts-ignore
20
+ handleClose = useCallback((event) => {
21
+ //@ts-ignore
22
+ if (anchorRef.current && anchorRef.current.contains(event.target)) {
23
+ return;
24
+ }
25
+ setOpen(false);
26
+ }, []);
37
27
 
38
- return (
28
+ return !downMd ? (
29
+ <>{props.children}</>
30
+ ) : (
39
31
  <>
40
- <Box sx={{ flexShrink: 0, ml: 0.75 }}>
32
+ <Box sx={{ flexShrink: 0 }}>
33
+ {/*@ts-ignore*/}
41
34
  <IconButton
42
- sx={{ color: 'text.primary', bgcolor: open ? iconBackColorOpen : iconBackColor }}
35
+ sx={{ color: 'text.primary', bgcolor: open ? iconColorOpen : iconColor }}
43
36
  aria-label="open more menu"
44
37
  ref={anchorRef}
45
38
  aria-controls={open ? 'menu-list-grow' : undefined}
@@ -71,13 +64,13 @@ const MobileSection = () => {
71
64
  }}
72
65
  >
73
66
  {({ TransitionProps }) => (
67
+ //@ts-ignore
74
68
  <Transitions type="fade" in={open} {...TransitionProps}>
69
+ {/*@ts-ignore*/}
75
70
  <Paper sx={{ boxShadow: theme.customShadows.z1 }}>
76
71
  <ClickAwayListener onClickAway={handleClose}>
77
72
  <AppBar color="inherit">
78
- <Toolbar>
79
- <Profile />
80
- </Toolbar>
73
+ <Toolbar>{props.children}</Toolbar>
81
74
  </AppBar>
82
75
  </ClickAwayListener>
83
76
  </Paper>
@@ -88,4 +81,4 @@ const MobileSection = () => {
88
81
  );
89
82
  };
90
83
 
91
- export default MobileSection;
84
+ export { ResponsiveSection };
@@ -0,0 +1,9 @@
1
+ import { Box, BoxProps } from '@mui/material';
2
+
3
+ type IHeaderSpacerProps = BoxProps;
4
+
5
+ function HeaderSpacer(props: IHeaderSpacerProps) {
6
+ return <Box {...props} flex={1} />;
7
+ }
8
+
9
+ export { HeaderSpacer };
@@ -0,0 +1,7 @@
1
+ export * from './AppBarStyled';
2
+ export * from './DrawerToggle';
3
+ export * from './Header';
4
+ export * from './Notification';
5
+ export * from './Profile';
6
+ export * from './ResponsiveSection';
7
+ export * from './Spacer';
@@ -0,0 +1,39 @@
1
+ import { AppBar, Box, Container, useScrollTrigger, useTheme } from '@mui/material';
2
+ import { useThemeConfig } from '../../hooks';
3
+
4
+ type IHorizontalBarProps = React.PropsWithChildren;
5
+
6
+ function HorizontalBar(props: IHorizontalBarProps) {
7
+ const theme = useTheme(),
8
+ trigger = useScrollTrigger({
9
+ disableHysteresis: true,
10
+ threshold: 0
11
+ }),
12
+ { container } = useThemeConfig();
13
+
14
+ //@ts-ignore
15
+ theme.shadows[4] = theme.customShadows.z1;
16
+
17
+ return (
18
+ <AppBar
19
+ elevation={trigger ? 4 : 0}
20
+ sx={{
21
+ top: 60,
22
+ bgcolor: theme.palette.background.paper,
23
+ width: '100%',
24
+ height: 62,
25
+ justifyContent: 'center',
26
+ borderTop: `1px solid ${theme.palette.divider}`,
27
+ borderBottom: `1px solid ${theme.palette.divider}`,
28
+ zIndex: 1098,
29
+ color: theme.palette.grey[500]
30
+ }}
31
+ >
32
+ <Container maxWidth={container ? 'xl' : false}>
33
+ <Box sx={{ display: 'flex', alignItems: 'center' }}>{props.children}</Box>
34
+ </Container>
35
+ </AppBar>
36
+ );
37
+ }
38
+
39
+ export { HorizontalBar };
@@ -0,0 +1,60 @@
1
+ import { LoadingIndicator } from 'ra-ui-materialui';
2
+ import { Header, HeaderNotification, HeaderProfile, HeaderSpacer, ResponsiveSection } from './Header';
3
+ import { withLayoutProvider } from './Provider';
4
+ import { LayoutWrapper } from './Wrapper';
5
+ import { LayoutContent } from './Content';
6
+ import { Footer } from './Footer';
7
+ import { useBreadcrumbs } from '../../hooks';
8
+ import { Breadcrumbs } from '../@extended';
9
+ import { Outlet } from 'react-router-dom';
10
+ import { NavMenu } from './NavMenu';
11
+ import { Navigation } from './Navigation';
12
+
13
+ type ILayoutProps = React.PropsWithChildren<{
14
+ name: string;
15
+ version: string;
16
+ }>;
17
+
18
+ const Layout = withLayoutProvider(function Layout(props: ILayoutProps) {
19
+ const { name, version } = props,
20
+ { isLoading, navigation, breadcrumbs } = useBreadcrumbs();
21
+
22
+ return (
23
+ <LayoutWrapper>
24
+ <Header>
25
+ <HeaderSpacer />
26
+ <LoadingIndicator />
27
+ <HeaderNotification />
28
+ <ResponsiveSection>
29
+ <HeaderProfile />
30
+ </ResponsiveSection>
31
+ </Header>
32
+ <NavMenu>
33
+ <Navigation />
34
+ </NavMenu>
35
+ <LayoutContent>
36
+ {!isLoading && (
37
+ //@ts-ignore
38
+ <Breadcrumbs
39
+ titleBottom
40
+ mode="breadcrumbs"
41
+ navigation={navigation}
42
+ breadcrumbs={breadcrumbs}
43
+ card={false}
44
+ divider={false}
45
+ icon
46
+ icons
47
+ home={false}
48
+ />
49
+ )}
50
+ {props.children}
51
+ <Outlet />
52
+ <Footer name={name} version={version} />
53
+ </LayoutContent>
54
+ </LayoutWrapper>
55
+ );
56
+ });
57
+
58
+ export type { ILayoutProps };
59
+
60
+ export { Layout };
@@ -0,0 +1,12 @@
1
+ import { Drawer } from './Drawer';
2
+ import { HorizontalBar } from './HorizontalBar';
3
+ import { useLayoutMediaState } from './Provider';
4
+
5
+ type INavMenuProps = React.PropsWithChildren;
6
+
7
+ function NavMenu(props: INavMenuProps) {
8
+ const { horizontal } = useLayoutMediaState();
9
+ return !horizontal ? <Drawer>{props.children}</Drawer> : <HorizontalBar>{props.children}</HorizontalBar>;
10
+ }
11
+
12
+ export { NavMenu };
@@ -9,17 +9,17 @@ import {
9
9
  ListItemText,
10
10
  Paper,
11
11
  Popper,
12
- Typography,
13
- useMediaQuery
12
+ Typography
14
13
  } from '@mui/material';
15
- import { Dot, Transitions } from '../../../../@extended';
16
- import React, { useEffect, useMemo, useState } from 'react';
14
+ import { Dot, Transitions } from '../../@extended';
15
+ import { useEffect, useMemo, useState } from 'react';
17
16
  import { styled, useTheme } from '@mui/material/styles';
18
17
  import { useLocation, useNavigate } from 'react-router-dom';
19
- import { useMenuConfig, useThemeConfig } from '../../../../../hooks';
18
+ import { useMenuConfig } from '../../../hooks';
20
19
 
21
20
  import NavItem from './NavItem';
22
21
  import PropTypes from 'prop-types';
22
+ import { useLayoutMediaState } from '../Provider';
23
23
 
24
24
  const PopperStyled = styled(Popper)(({ theme }) => ({
25
25
  overflow: 'visible',
@@ -44,9 +44,8 @@ const PopperStyled = styled(Popper)(({ theme }) => ({
44
44
  const NavCollapse = ({ menu, level, parentId, setSelectedItems, selectedItems, setSelectedLevel, selectedLevel }) => {
45
45
  const theme = useTheme();
46
46
  const { activeItem } = useMenuConfig();
47
- const downLG = useMediaQuery(theme.breakpoints.down('lg'));
47
+ const { horizontal } = useLayoutMediaState();
48
48
  const { drawerOpen } = useMenuConfig();
49
- const { menuOrientation, isVerticalLayout } = useThemeConfig();
50
49
  const Navigation = useNavigate();
51
50
 
52
51
  const [open, setOpen] = useState(false);
@@ -182,7 +181,7 @@ const NavCollapse = ({ menu, level, parentId, setSelectedItems, selectedItems, s
182
181
 
183
182
  return (
184
183
  <>
185
- {isVerticalLayout(menuOrientation) || downLG ? (
184
+ {!horizontal ? (
186
185
  <>
187
186
  <ListItemButton
188
187
  disableRipple
@@ -1,25 +1,15 @@
1
- import {
2
- Box,
3
- ClickAwayListener,
4
- List,
5
- ListItemButton,
6
- ListItemIcon,
7
- ListItemText,
8
- Paper,
9
- Popper,
10
- Typography,
11
- useMediaQuery
12
- } from '@mui/material';
1
+ import { Box, ClickAwayListener, List, ListItemButton, ListItemIcon, ListItemText, Paper, Popper, Typography } from '@mui/material';
13
2
  import { DownOutlined, RightOutlined } from '@ant-design/icons';
14
3
  import { Fragment, useEffect, useState } from 'react';
15
4
  import { styled, useTheme } from '@mui/material/styles';
16
- import { useMenuConfig, useThemeConfig } from '../../../../../hooks';
5
+ import { useMenuConfig } from '../../../hooks';
17
6
 
18
7
  import NavCollapse from './NavCollapse';
19
8
  import NavItem from './NavItem';
20
9
  import PropTypes from 'prop-types';
21
- import { Transitions } from '../../../../@extended';
10
+ import { Transitions } from '../../@extended';
22
11
  import { useTranslate } from 'react-admin';
12
+ import { useLayoutMediaState } from '../Provider';
23
13
 
24
14
  const PopperStyled = styled(Popper)(({ theme }) => ({
25
15
  overflow: 'visible',
@@ -45,11 +35,10 @@ const NavGroup = ({ item, lastItem, remItems, lastItemId, setSelectedItems, sele
45
35
  const theme = useTheme();
46
36
  const translate = useTranslate();
47
37
  const { pathname } = { pathname: '' }; // useLocation()
48
- const { menuOrientation, isVerticalLayout } = useThemeConfig();
38
+ const { horizontal, downLg } = useLayoutMediaState();
49
39
  const menu = useMenuConfig();
50
40
  const { drawerOpen, selectedID } = menu;
51
41
  const { activeID } = useMenuConfig();
52
- const downLG = useMediaQuery(theme.breakpoints.down('lg'));
53
42
 
54
43
  const [anchorEl, setAnchorEl] = useState(null);
55
44
  const [currentItem, setCurrentItem] = useState(item);
@@ -68,7 +57,7 @@ const NavGroup = ({ item, lastItem, remItems, lastItemId, setSelectedItems, sele
68
57
  }
69
58
  }
70
59
  // eslint-disable-next-line react-hooks/exhaustive-deps
71
- }, [item, lastItem, downLG]);
60
+ }, [item, lastItem, downLg]);
72
61
 
73
62
  const checkOpenForParent = (child, id) => {
74
63
  child.forEach((ele) => {
@@ -206,7 +195,7 @@ const NavGroup = ({ item, lastItem, remItems, lastItemId, setSelectedItems, sele
206
195
 
207
196
  return (
208
197
  <>
209
- {isVerticalLayout(menuOrientation) || downLG ? (
198
+ {!horizontal ? (
210
199
  <List
211
200
  subheader={
212
201
  item.title &&
@@ -335,4 +324,4 @@ NavGroup.propTypes = {
335
324
  selectedLevel: PropTypes.number
336
325
  };
337
326
 
338
- export default NavGroup;
327
+ export { NavGroup };
@@ -1,20 +1,19 @@
1
- import { Avatar, Chip, ListItemButton, ListItemIcon, ListItemText, Typography, useMediaQuery } from '@mui/material';
1
+ import { Avatar, Chip, ListItemButton, ListItemIcon, ListItemText, Typography } from '@mui/material';
2
2
  import { Link, useLocation } from 'react-router-dom';
3
3
  import { forwardRef, useEffect } from 'react';
4
- import { useMenuConfig, useThemeConfig } from '../../../../../hooks';
4
+ import { useMenuConfig } from '../../../hooks';
5
5
 
6
- import { Dot } from '../../../../@extended';
6
+ import { Dot } from '../../@extended';
7
7
  import PropTypes from 'prop-types';
8
8
  import { useTheme } from '@mui/material/styles';
9
+ import { useLayoutMediaState } from '../Provider';
9
10
 
10
11
  const NavItem = ({ item, level }) => {
11
12
  const theme = useTheme();
12
13
 
13
- const { menuOrientation, isVerticalLayout } = useThemeConfig();
14
+ const { horizontal, downLg } = useLayoutMediaState();
14
15
  const { drawerOpen, openItem, activeItem, openDrawer } = useMenuConfig();
15
16
 
16
- const downLG = useMediaQuery(theme.breakpoints.down('lg'));
17
-
18
17
  let itemTarget = '_self';
19
18
  if (item.target) {
20
19
  itemTarget = '_blank';
@@ -44,7 +43,7 @@ const NavItem = ({ item, level }) => {
44
43
  const iconSelectedColor = theme.palette.mode === 'dark' && drawerOpen ? 'text.primary' : 'primary.main';
45
44
  return (
46
45
  <>
47
- {isVerticalLayout(menuOrientation) || downLG ? (
46
+ {!horizontal ? (
48
47
  <ListItemButton
49
48
  {...listItemProps}
50
49
  disabled={item.disabled}
@@ -79,7 +78,7 @@ const NavItem = ({ item, level }) => {
79
78
  }
80
79
  })
81
80
  }}
82
- {...(downLG && {
81
+ {...(downLg && {
83
82
  onClick: () => openDrawer(false)
84
83
  })}
85
84
  >
@@ -0,0 +1,76 @@
1
+ import { useState } from 'react';
2
+ import _ from 'lodash';
3
+ import { Box, SxProps, Typography } from '@mui/material';
4
+ import { useMenu, useSx, useThemeConfig } from '../../../hooks';
5
+ import { useLayoutDrawerState, useLayoutMediaState } from '../Provider';
6
+ import { NavGroup } from './NavGroup';
7
+
8
+ type INavigationProps = {
9
+ sx?: SxProps;
10
+ };
11
+
12
+ type IItem = { title: any; elements: any; icon: any };
13
+
14
+ function Navigation(props: INavigationProps) {
15
+ const { horizontal } = useLayoutMediaState(),
16
+ { open } = useLayoutDrawerState(),
17
+ { menu, isLoading } = useMenu(),
18
+ [selectedItems, setSelectedItems] = useState<string>(''),
19
+ [selectedLevel, setSelectedLevel] = useState<number>(0),
20
+ { horizontalMaxItems } = useThemeConfig(),
21
+ lastItem = horizontal ? horizontalMaxItems : null;
22
+
23
+ let lastItemIndex = isLoading ? 0 : (menu ?? []).length - 1,
24
+ remItems: Array<IItem> = [],
25
+ lastItemId: string;
26
+
27
+ if (!isLoading && lastItem && lastItem < (menu ?? []).length) {
28
+ lastItemId = (menu ?? [])[lastItem - 1].id;
29
+ lastItemIndex = lastItem - 1;
30
+ remItems = (menu ?? []).slice(lastItem - 1, (menu ?? []).length).map((item) => ({
31
+ title: item.title,
32
+ elements: item.children,
33
+ icon: item.icon
34
+ }));
35
+ }
36
+
37
+ const sx = useSx(props, {
38
+ pt: open ? (horizontal ? 0 : 2) : 0,
39
+ '& > ul:first-of-type': { mt: 0 },
40
+ display: horizontal ? { xs: 'block', lg: 'flex' } : 'block'
41
+ });
42
+
43
+ return (
44
+ <Box sx={sx}>
45
+ {!isLoading &&
46
+ _.map((menu ?? []).slice(0, lastItemIndex + 1), (item) => {
47
+ const { type } = item;
48
+
49
+ switch (type) {
50
+ case 'group':
51
+ return (
52
+ <NavGroup
53
+ key={item.id}
54
+ item={item}
55
+ setSelectedItems={setSelectedItems}
56
+ setSelectedLevel={setSelectedLevel}
57
+ selectedLevel={selectedLevel}
58
+ selectedItems={selectedItems}
59
+ lastItem={lastItem}
60
+ remItems={remItems}
61
+ lastItemId={lastItemId}
62
+ />
63
+ );
64
+ default:
65
+ return (
66
+ <Typography key={item.id} variant="h6" color="error" align="center">
67
+ Fix - Navigation Group
68
+ </Typography>
69
+ );
70
+ }
71
+ })}
72
+ </Box>
73
+ );
74
+ }
75
+
76
+ export { Navigation };
@@ -0,0 +1 @@
1
+ export * from './Navigation';