@applica-software-guru/react-admin 1.5.318 → 1.5.320

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/package.json CHANGED
@@ -107,5 +107,5 @@
107
107
  "type": "module",
108
108
  "types": "dist/index.d.ts",
109
109
  "typings": "dist/index.d.ts",
110
- "version": "1.5.318"
110
+ "version": "1.5.320"
111
111
  }
@@ -18,7 +18,6 @@ import {
18
18
  DatagridProps as RaDatagridProps
19
19
  } from 'react-admin';
20
20
  import { Empty } from '@/components/ra-lists/Empty';
21
- import { DropboxOutlined } from '@ant-design/icons';
22
21
 
23
22
  const defaultBulkActionButtons = <BulkDeleteButton />;
24
23
 
@@ -169,7 +168,7 @@ const Datagrid = React.forwardRef((props, ref) => {
169
168
 
170
169
  const DefaultEmpty = (
171
170
  <Empty
172
- icon={<DropboxOutlined style={{ fontSize: '7em', marginBottom: '16px' }} />}
171
+ sx={{ '& .ApplicaEmpty-icon': { fontSize: '7em' } }}
173
172
  title={
174
173
  <Typography variant="subtitle1" style={{ color: 'inherit' }} gutterBottom>
175
174
  {translate('ra.navigation.no_results')}
@@ -1,10 +1,10 @@
1
1
  /* eslint-disable filenames/match-regex */
2
2
  import { DropboxOutlined } from '@ant-design/icons';
3
- import { Box, Typography } from '@mui/material';
4
- import { SxProps, styled } from '@mui/material/styles';
3
+ import { Box, SxProps, Typography, styled } from '@mui/material';
5
4
  import { useGetResourceLabel, useResourceContext, useResourceDefinition, useTranslate } from 'ra-core';
6
5
  import * as React from 'react';
7
6
  import { CreateButton } from '@/components/ra-buttons';
7
+ import clsx from 'clsx';
8
8
 
9
9
  type EmptyProps = {
10
10
  /**
@@ -52,6 +52,39 @@ const StyledToolbar = styled('div')(({ theme }) => ({
52
52
  padding: theme.spacing(2)
53
53
  }));
54
54
 
55
+ const PREFIX = 'ApplicaEmpty';
56
+
57
+ const EmptyClasses = {
58
+ message: `${PREFIX}-message`,
59
+ icon: `${PREFIX}-icon`,
60
+ toolbar: `${PREFIX}-toolbar`
61
+ };
62
+
63
+ const Root = styled('span', {
64
+ name: PREFIX,
65
+ slot: 'Root',
66
+ overridesResolver: (_, styles) => styles.root
67
+ })(({ theme }) => ({
68
+ flex: 1,
69
+ height: 'calc(100vh - 200px)',
70
+ [`& .${EmptyClasses.message}`]: {
71
+ textAlign: 'center',
72
+ opacity: theme.palette.mode === 'light' ? 0.5 : 0.8,
73
+ margin: '0 1em',
74
+ color: theme.palette.mode === 'light' ? 'inherit' : theme.palette.text.primary
75
+ },
76
+
77
+ [`& .${EmptyClasses.icon}`]: {
78
+ fontSize: '9em',
79
+ marginTop: '16px',
80
+ marginBottom: '16px'
81
+ },
82
+
83
+ [`& .${EmptyClasses.toolbar}`]: {
84
+ textAlign: 'center'
85
+ }
86
+ }));
87
+
55
88
  /**
56
89
  * The Empty component is used to display a message when the list is empty.
57
90
  * This component can be used only inside a List component.
@@ -85,7 +118,7 @@ function Empty({
85
118
  const inviteMessage = translate('ra.page.invite');
86
119
 
87
120
  return (
88
- <Root className={className} sx={sx}>
121
+ <Root className={clsx(`${PREFIX}-root`, className)} sx={sx}>
89
122
  <Box className={EmptyClasses.message}>
90
123
  {icon}
91
124
  <Typography variant="h4" paragraph>
@@ -94,50 +127,21 @@ function Empty({
94
127
  _: emptyMessage
95
128
  })}
96
129
  </Typography>
97
- {canCreate ? (
98
- <Typography variant="body1">
99
- {subtitle ||
100
- translate(`resources.${resource}.invite`, {
130
+ {subtitle ||
131
+ (canCreate ? (
132
+ <Typography variant="body1">
133
+ {translate(`resources.${resource}.invite`, {
101
134
  _: inviteMessage
102
135
  })}
103
- </Typography>
104
- ) : null}
136
+ </Typography>
137
+ ) : null)}
105
138
  </Box>
106
- <StyledToolbar className={EmptyClasses.toolbar}>{(canCreate ? <CreateButton /> : null) || actions}</StyledToolbar>
139
+ <StyledToolbar className={EmptyClasses.toolbar}>
140
+ {actions || (canCreate ? <CreateButton disableFloatingButton /> : null)}
141
+ </StyledToolbar>
107
142
  </Root>
108
143
  );
109
144
  }
110
145
 
111
- const PREFIX = 'ApplicaEmpty';
112
-
113
- const EmptyClasses = {
114
- message: `${PREFIX}-message`,
115
- icon: `${PREFIX}-icon`,
116
- toolbar: `${PREFIX}-toolbar`
117
- };
118
-
119
- const Root = styled('span', {
120
- name: PREFIX,
121
- overridesResolver: (_, styles) => styles.root
122
- })(({ theme }) => ({
123
- flex: 1,
124
- height: 'calc(100vh - 200px)',
125
- [`& .${EmptyClasses.message}`]: {
126
- textAlign: 'center',
127
- opacity: theme.palette.mode === 'light' ? 0.5 : 0.8,
128
- margin: '0 1em',
129
- color: theme.palette.mode === 'light' ? 'inherit' : theme.palette.text.primary
130
- },
131
-
132
- [`& .${EmptyClasses.icon}`]: {
133
- fontSize: '9em',
134
- marginBottom: '16px'
135
- },
136
-
137
- [`& .${EmptyClasses.toolbar}`]: {
138
- textAlign: 'center'
139
- }
140
- }));
141
-
142
146
  export { Empty, EmptyClasses };
143
147
  export type { EmptyProps };
@@ -181,12 +181,19 @@ const StyledList = styled(RaList, { slot: 'root' })(({ theme }) => ({
181
181
  paddingTop: 0,
182
182
  paddingBottom: 0
183
183
  },
184
- // Resolve a defect related to the usage of AntDesin icons with Mantis and React-Admin.
184
+ // Resolve a defect related to the usage of AntDesign icons with Mantis and React-Admin.
185
185
  // These two lines are not needed if you are not using AntDesign icons.
186
186
  '& .icon span': {
187
187
  top: -1,
188
188
  left: -1
189
189
  }
190
+ },
191
+ '& .ApplicaEmpty-root': {
192
+ display: 'flex',
193
+ flexDirection: 'column',
194
+ justifyContent: 'center',
195
+ alignItems: 'center',
196
+ height: 'calc(100vh - 260px)'
190
197
  }
191
198
  },
192
199
 
@@ -1,13 +1,21 @@
1
- import { styled } from '@mui/material/styles';
2
- import { SimpleList as RaSimpleList } from 'react-admin';
1
+ import { SimpleList as RaSimpleList, SimpleListProps, useTranslate } from 'react-admin';
2
+ import { Empty } from '@/components/ra-lists/Empty';
3
+ import { Typography } from '@mui/material';
3
4
 
4
- const SimpleList = styled(RaSimpleList, {
5
- name: 'ApplicaSimpleList',
6
- slot: 'root'
7
- })(({ theme }) => ({
8
- padding: theme.spacing(1),
9
- paddingTop: 0,
10
- paddingBottom: 0
11
- }));
5
+ function SimpleList({ empty, ...props }: SimpleListProps): JSX.Element {
6
+ const translate = useTranslate();
7
+ const DefaultEmpty = (
8
+ <Empty
9
+ sx={{ '& .ApplicaEmpty-icon': { fontSize: '7em' } }}
10
+ title={
11
+ <Typography variant="subtitle1" style={{ color: 'inherit' }} gutterBottom>
12
+ {translate('ra.navigation.no_results')}
13
+ </Typography>
14
+ }
15
+ />
16
+ );
17
+
18
+ return <RaSimpleList {...props} empty={empty || DefaultEmpty} />;
19
+ }
12
20
 
13
21
  export { SimpleList };