@applica-software-guru/react-admin 1.5.310 → 1.5.312
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/components/Layout/Header/Profile/HeaderProfile.d.ts +5 -1
- package/dist/components/Layout/Header/Profile/HeaderProfile.d.ts.map +1 -1
- package/dist/components/Layout/Sidebar/Drawer.d.ts +2 -1
- package/dist/components/Layout/Sidebar/Drawer.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +33 -33
- package/dist/react-admin.cjs.js.gz +0 -0
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +1091 -1080
- package/dist/react-admin.es.js.gz +0 -0
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +33 -33
- package/dist/react-admin.umd.js.gz +0 -0
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Layout/Header/Profile/HeaderProfile.tsx +20 -3
- package/src/components/Layout/Sidebar/Drawer.tsx +23 -10
- package/src/components/ra-lists/FilterSidebar/FilterSidebar.tsx +1 -1
package/package.json
CHANGED
|
@@ -6,9 +6,14 @@ import { LogoutOutlined } from '@ant-design/icons';
|
|
|
6
6
|
import { Popper } from '@mui/base';
|
|
7
7
|
import { CardContent, ClickAwayListener, Grid, List, Paper, Stack, Tooltip, Typography, useTheme } from '@mui/material';
|
|
8
8
|
import { useDataProvider, useGetIdentity, useLogout } from 'ra-core';
|
|
9
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
9
|
+
import React, { ReactNode, useCallback, useEffect, useMemo, useState } from 'react';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
interface HeaderProfileProps {
|
|
12
|
+
roles?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function HeaderProfile(props: HeaderProfileProps) {
|
|
16
|
+
const { roles } = props;
|
|
12
17
|
const theme = useTheme();
|
|
13
18
|
const dataProvider = useDataProvider();
|
|
14
19
|
const { identity } = useGetIdentity();
|
|
@@ -26,6 +31,18 @@ function HeaderProfile() {
|
|
|
26
31
|
}
|
|
27
32
|
}, [dataProvider, hasProfilePic]);
|
|
28
33
|
|
|
34
|
+
const userRoles = useMemo(
|
|
35
|
+
() =>
|
|
36
|
+
React.isValidElement(roles) ? (
|
|
37
|
+
roles
|
|
38
|
+
) : roles ? (
|
|
39
|
+
<>{roles}</>
|
|
40
|
+
) : (
|
|
41
|
+
identity?.roles?.map((r: { name: string }) => r.name.replace('ROLE_', '')).join(',')
|
|
42
|
+
),
|
|
43
|
+
[roles, identity]
|
|
44
|
+
);
|
|
45
|
+
|
|
29
46
|
return (
|
|
30
47
|
<>
|
|
31
48
|
<HeaderToggleButton sx={{ p: 0.25, width: 'auto' }} onClick={handleToggle} value="profile" selected={open}>
|
|
@@ -62,7 +79,7 @@ function HeaderProfile() {
|
|
|
62
79
|
<Stack>
|
|
63
80
|
<Typography variant="h6">{identity?.name}</Typography>
|
|
64
81
|
<Typography variant="body2" color="textSecondary">
|
|
65
|
-
{
|
|
82
|
+
{userRoles}
|
|
66
83
|
</Typography>
|
|
67
84
|
</Stack>
|
|
68
85
|
</Stack>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Drawer as MUIDrawer, useMediaQuery, useTheme } from '@mui/material';
|
|
1
|
+
import { Drawer as MUIDrawer, SxProps, useMediaQuery, useTheme } from '@mui/material';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { useSx } from '@/hooks';
|
|
4
3
|
import { isFunction } from 'lodash';
|
|
5
4
|
|
|
6
5
|
type DrawerProps = {
|
|
7
|
-
|
|
6
|
+
sx?: SxProps;
|
|
8
7
|
anchor?: 'left' | 'right' | 'top' | 'bottom';
|
|
9
8
|
variant?: 'temporary' | 'persistent' | 'permanent';
|
|
10
9
|
children: React.ReactNode;
|
|
@@ -12,8 +11,17 @@ type DrawerProps = {
|
|
|
12
11
|
onClose?: () => void;
|
|
13
12
|
};
|
|
14
13
|
|
|
14
|
+
/**
|
|
15
|
+
* The Dialog component in Material UI has a maximum width of 444px at the 'xs' breakpoint.
|
|
16
|
+
* To maintain consistency, we use the same value as the max width for the Drawer component,
|
|
17
|
+
* but only for the 'sm' breakpoint and above.
|
|
18
|
+
* At the 'xs' breakpoint, the Drawer should occupy the full width.
|
|
19
|
+
* @see https://github.com/mui/material-ui/blob/v5.15.17/packages/mui-material/src/Dialog/Dialog.js
|
|
20
|
+
*/
|
|
21
|
+
const MAX_WIDTH = 444;
|
|
22
|
+
|
|
15
23
|
function Drawer(props: DrawerProps) {
|
|
16
|
-
const {
|
|
24
|
+
const { sx, anchor = 'right', variant = 'temporary', open = false, onClose } = props;
|
|
17
25
|
const theme = useTheme();
|
|
18
26
|
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
|
|
19
27
|
const anchorPosition = isMobile ? 'bottom' : anchor;
|
|
@@ -22,15 +30,20 @@ function Drawer(props: DrawerProps) {
|
|
|
22
30
|
onClose();
|
|
23
31
|
}
|
|
24
32
|
}, [onClose]);
|
|
25
|
-
const
|
|
33
|
+
const sxProps = {
|
|
26
34
|
backgroundImage: 'none',
|
|
27
35
|
boxShadow: '-10px 4px 42px 0px rgba(0, 0, 0, 0.25)',
|
|
28
36
|
width: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
sm: '30%'
|
|
38
|
+
},
|
|
39
|
+
maxWidth: {
|
|
40
|
+
sm: MAX_WIDTH
|
|
41
|
+
},
|
|
42
|
+
[theme.breakpoints.down('sm')]: {
|
|
43
|
+
width: '100% !important',
|
|
44
|
+
maxWidth: '100% !important'
|
|
32
45
|
}
|
|
33
|
-
}
|
|
46
|
+
};
|
|
34
47
|
|
|
35
48
|
return (
|
|
36
49
|
<MUIDrawer
|
|
@@ -38,7 +51,7 @@ function Drawer(props: DrawerProps) {
|
|
|
38
51
|
anchor={anchorPosition}
|
|
39
52
|
onClose={handleClose}
|
|
40
53
|
open={open}
|
|
41
|
-
PaperProps={{ sx: sx }}
|
|
54
|
+
PaperProps={{ sx: { ...sxProps, ...sx } }}
|
|
42
55
|
variant={variant}
|
|
43
56
|
>
|
|
44
57
|
{props.children}
|
|
@@ -115,7 +115,7 @@ function FilterSidebar(props: FilterSidebarProps): ReactElement {
|
|
|
115
115
|
}, [values, getValues, watchValues]);
|
|
116
116
|
|
|
117
117
|
return (
|
|
118
|
-
<Sidebar
|
|
118
|
+
<Sidebar sx={{ height: '100%' }} open={sidebarOpen} onClose={closeSidebar}>
|
|
119
119
|
<Sidebar.Header>
|
|
120
120
|
<Sidebar.HeaderText primary={translate('ra.action.add_filter')} />
|
|
121
121
|
<Sidebar.HeaderAction>
|