@applica-software-guru/react-admin 1.3.125 → 1.3.127

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 (50) hide show
  1. package/dist/ApplicaAdmin.d.ts +14 -29
  2. package/dist/ApplicaAdmin.d.ts.map +1 -1
  3. package/dist/components/Layout/Content.d.ts +4 -1
  4. package/dist/components/Layout/Content.d.ts.map +1 -1
  5. package/dist/components/Layout/Error.d.ts +27 -0
  6. package/dist/components/Layout/Error.d.ts.map +1 -0
  7. package/dist/components/Layout/Layout.d.ts +3 -0
  8. package/dist/components/Layout/Layout.d.ts.map +1 -1
  9. package/dist/components/Layout/index.d.ts +1 -0
  10. package/dist/components/Layout/index.d.ts.map +1 -1
  11. package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts +2 -2
  12. package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts.map +1 -1
  13. package/dist/components/ra-lists/List.d.ts +19 -18
  14. package/dist/components/ra-lists/List.d.ts.map +1 -1
  15. package/dist/components/ra-lists/ListView.d.ts +257 -0
  16. package/dist/components/ra-lists/ListView.d.ts.map +1 -0
  17. package/dist/dev/CatchResult.d.ts +17 -0
  18. package/dist/dev/CatchResult.d.ts.map +1 -0
  19. package/dist/dev/ErrorEventHandler.d.ts +13 -0
  20. package/dist/dev/ErrorEventHandler.d.ts.map +1 -0
  21. package/dist/dev/index.d.ts +4 -2
  22. package/dist/dev/index.d.ts.map +1 -1
  23. package/dist/dev/useErrorEventCatcher.d.ts +12 -0
  24. package/dist/dev/useErrorEventCatcher.d.ts.map +1 -0
  25. package/dist/react-admin.cjs.js +63 -63
  26. package/dist/react-admin.cjs.js.map +1 -1
  27. package/dist/react-admin.es.js +9776 -9184
  28. package/dist/react-admin.es.js.map +1 -1
  29. package/dist/react-admin.umd.js +66 -66
  30. package/dist/react-admin.umd.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/ApplicaAdmin.tsx +19 -33
  33. package/src/components/Layout/Content.tsx +37 -16
  34. package/src/components/Layout/Error.tsx +81 -0
  35. package/src/components/Layout/Layout.tsx +3 -2
  36. package/src/components/Layout/index.ts +1 -0
  37. package/src/components/ra-forms/TableForm/TableFormIterator.tsx +76 -27
  38. package/src/components/ra-forms/TableForm/TableFormIteratorItem.tsx +2 -2
  39. package/src/components/ra-lists/List.tsx +117 -2
  40. package/src/components/ra-lists/ListView.tsx +369 -0
  41. package/src/components/ra-pages/GenericErrorPage.tsx +1 -1
  42. package/src/dev/CatchResult.ts +32 -0
  43. package/src/dev/ErrorEventHandler.ts +51 -0
  44. package/src/dev/index.ts +4 -2
  45. package/src/dev/useErrorEventCatcher.ts +50 -0
  46. package/src/playground/components/pages/CustomPage.jsx +6 -0
  47. package/dist/dev/useCliErrorCatcher.d.ts +0 -59
  48. package/dist/dev/useCliErrorCatcher.d.ts.map +0 -1
  49. package/src/dev/useCliErrorCatcher.ts +0 -142
  50. /package/src/assets/{genericError.png → generic-error.png} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applica-software-guru/react-admin",
3
- "version": "1.3.125",
3
+ "version": "1.3.127",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  import { AdminProps, AuthProvider, DataProvider } from 'react-admin';
2
2
  import { AppConfigProvider, MenuConfigProvider, MenuPropTypes, ThemeConfig, ThemeConfigProvider } from './contexts';
3
- import { CatchResult, useCliErrorCatcher } from './dev';
3
+ import { CatchResult, useErrorEventCatcher } from './dev';
4
4
  import { GenericErrorPage, Layout, LoginPage, MainIcon, Notification, SmallIcon } from './components';
5
5
  import React, { useMemo } from 'react';
6
6
  import { useI18nProvider } from './i18n';
@@ -9,7 +9,7 @@ import { MenuProps } from './types';
9
9
  import PropTypes from 'prop-types';
10
10
  import { QueryClient } from 'react-query';
11
11
  import { ThemeCustomization } from './themes';
12
-
12
+ import { IErrorEventHandler } from './dev/ErrorEventHandler';
13
13
  const queryClient = new QueryClient({
14
14
  defaultOptions: {
15
15
  queries: {
@@ -80,6 +80,16 @@ export type ApplicaAdminProps = AdminProps & {
80
80
  * Il provider di dati da utilizzare nell'applicazione.
81
81
  */
82
82
  authProvider: AuthProvider;
83
+ /**
84
+ * Indica l'eventuale handler da utilizzare per la gestione degli errori.
85
+ * Di default è eseguita una chiamata PUT /api/ui/error con il messaggio di errore "error".
86
+ * Puoi implementare un tuo handler per gestire gli errori in modo diverso.
87
+ */
88
+ errorHandler?: IErrorEventHandler | undefined;
89
+ /**
90
+ * Indica il componente da visualizzare in caso di errore.
91
+ */
92
+ error: React.Component;
83
93
  /**
84
94
  * Indica il nome della risorsa REST da utilizzare per la gestione delle notifiche.
85
95
  * @default "entities/notification"
@@ -123,34 +133,7 @@ export type ApplicaAdminProps = AdminProps & {
123
133
  };
124
134
 
125
135
  /**
126
- * Definisce un'applicazione super figa basata su React Admi, Mantis Theme ed il nostro stile.
127
- * Ogni applicazione che crei dovrebbe partire con un 'C'era una volta un ApplicaAdmin'.
128
- *
129
- * @example
130
- * // Esempio di utilizzo
131
- * import { ApplicaAdmin } from '@applica-software-guru/react-admin';
132
- * import { createAuthProvider } from '@applica-software-guru/iam-client';
133
- * import { createDataProvider } from '@applica-software-guru/crud-client';
134
- * import * as entities from './entities';
135
- *
136
- * const apiUrl = "https://bimbobruno.applica.guru/api";
137
- * const authProvider = createAuthProvider({ apiUrl });
138
- * const getToken = async () => await authProvider.getToken();
139
- * const getHeaders = async () => await authProvider.getHeaders();
140
- *
141
- * const dataProvider = createDataProvider({ apiUrl, getToken, getHeaders });
142
- *
143
- * const App = () => (
144
- * <ApplicaAdmin
145
- * apiUrl="https://api.applica.software-guru.it"
146
- * dataProvider={dataProvider}
147
- * authProvider={authProvider}
148
- * menu={menu}
149
- * name="Applica Admin"
150
- * version="1.0.0">
151
- * <Resource name="entities/user" {...entities.user} />
152
- * </ApplicaAdmin>
153
- *
136
+ * Definisce un'applicazione super figa basata su React Admin, Mantis Theme ed il nostro stile.
154
137
  * @param {ApplicaAdminProps}
155
138
  * @returns {React.ReactElement}
156
139
  */
@@ -169,15 +152,17 @@ const ApplicaAdmin = ({
169
152
  version,
170
153
  dataProvider,
171
154
  authProvider,
155
+ errorHandler,
156
+ error,
172
157
  notification,
173
158
  enableNotification,
174
159
  enableRegistration,
175
160
  enablePasswordRecover,
176
161
  ...props
177
162
  }: ApplicaAdminProps) => {
178
- useCliErrorCatcher({
163
+ useErrorEventCatcher({
179
164
  apiUrl,
180
- endpoint: '/cli/error',
165
+ errorHandler,
181
166
  catcherFn: (error: any): CatchResult => {
182
167
  const errorMessage = error?.toString();
183
168
  const knownErrors = [
@@ -224,10 +209,11 @@ const ApplicaAdmin = ({
224
209
  logoIcon={_logoIcon}
225
210
  notification={notification}
226
211
  enableNotification={enableNotification}
212
+ error={error}
227
213
  />
228
214
  );
229
215
  },
230
- [logoMain, logoIcon, name, version, notification, enableNotification]
216
+ [logoMain, logoIcon, name, version, error, notification, enableNotification]
231
217
  );
232
218
  const i18nProvider = useI18nProvider({
233
219
  apiUrl: apiUrl,
@@ -1,29 +1,50 @@
1
1
  import { Box, Container, Toolbar } from '@mui/material';
2
2
  import { useLayoutDrawerState, useLayoutMediaState } from './Provider';
3
3
  import { useThemeConfig } from '../../hooks';
4
+ import { Loading } from 'ra-ui-materialui';
5
+ import { ErrorInfo, Suspense, useState } from 'react';
6
+ import { ErrorBoundary } from 'react-error-boundary';
7
+ import Error, { ErrorProps } from './Error';
4
8
 
5
- type ILayoutContentProps = React.PropsWithChildren;
9
+ type ILayoutContentProps = React.PropsWithChildren & {
10
+ error?: React.ComponentType<ErrorProps>;
11
+ };
6
12
 
7
13
  function LayoutContent(props: ILayoutContentProps) {
8
14
  const { width } = useLayoutDrawerState(),
9
15
  { horizontal } = useLayoutMediaState(),
10
16
  { container } = useThemeConfig();
17
+ // @ts-ignore
18
+ const [errorInfo, setErrorInfo] = useState<ErrorInfo>(null);
19
+ const handleError = (error: Error, info: ErrorInfo) => {
20
+ setErrorInfo(info);
21
+ };
22
+
11
23
  return (
12
- <Box component="main" sx={{ width: `calc(100% - ${width}px)`, flexGrow: 1, p: { xs: 0, sm: 2, lg: 1 }, pt: { lg: 2 } }}>
13
- <Toolbar sx={{ mt: horizontal ? 8 : 'inherit' }} /> {/*Hugh...*/}
14
- <Container
15
- maxWidth={container ? 'xl' : false}
16
- sx={{
17
- ...(container && { px: { xs: 0, sm: 2 } }),
18
- position: 'relative',
19
- minHeight: 'calc(100vh - 110px)',
20
- display: 'flex',
21
- flexDirection: 'column'
22
- }}
23
- >
24
- {props.children}
25
- </Container>
26
- </Box>
24
+ <ErrorBoundary
25
+ onError={handleError}
26
+ fallbackRender={({ error, resetErrorBoundary }) => (
27
+ <Error error={error} errorComponent={props.error} errorInfo={errorInfo} resetErrorBoundary={resetErrorBoundary} />
28
+ )}
29
+ >
30
+ <Suspense fallback={<Loading />}>
31
+ <Box component="main" sx={{ width: `calc(100% - ${width}px)`, flexGrow: 1, p: { xs: 0, sm: 2, lg: 1 }, pt: { lg: 2 } }}>
32
+ <Toolbar sx={{ mt: horizontal ? 8 : 'inherit' }} /> {/*Hugh...*/}
33
+ <Container
34
+ maxWidth={container ? 'xl' : false}
35
+ sx={{
36
+ ...(container && { px: { xs: 0, sm: 2 } }),
37
+ position: 'relative',
38
+ minHeight: 'calc(100vh - 110px)',
39
+ display: 'flex',
40
+ flexDirection: 'column'
41
+ }}
42
+ >
43
+ {props.children}
44
+ </Container>
45
+ </Box>
46
+ </Suspense>
47
+ </ErrorBoundary>
27
48
  );
28
49
  }
29
50
 
@@ -0,0 +1,81 @@
1
+ import { Container, Stack, Typography, Button, useTheme } from '@mui/material';
2
+ import PropTypes from 'prop-types';
3
+ // @ts-ignore
4
+ import imgSrc from '../../assets/generic-error.png';
5
+ import { Title, TitlePropType, useResetErrorBoundaryOnLocationChange } from 'ra-ui-materialui';
6
+ import { ComponentType, ErrorInfo, HtmlHTMLAttributes, useCallback } from 'react';
7
+ import { TitleComponent, useTranslate } from 'ra-core';
8
+ import { FallbackProps } from 'react-error-boundary';
9
+ import History from '@mui/icons-material/History';
10
+
11
+ export type ErrorBoundaryProps = InternalErrorProps & {
12
+ errorComponent?: ComponentType<ErrorProps>;
13
+ title?: TitleComponent;
14
+ resetErrorBoundary?: null | (() => void);
15
+ };
16
+
17
+ function goBack() {
18
+ window.history.go(-1);
19
+ }
20
+ function Error(props: ErrorBoundaryProps) {
21
+ const { error, errorComponent: ErrorComponent, errorInfo, resetErrorBoundary, title } = props;
22
+ const translate = useTranslate();
23
+ const theme = useTheme();
24
+ const isProduction = process.env.NODE_ENV === 'production';
25
+
26
+ useResetErrorBoundaryOnLocationChange(resetErrorBoundary);
27
+
28
+ const handleBack = useCallback(() => {
29
+ goBack();
30
+ }, []);
31
+
32
+ if (ErrorComponent) {
33
+ return <ErrorComponent error={error} errorInfo={errorInfo} title={title} />;
34
+ }
35
+
36
+ return (
37
+ <Container>
38
+ <Stack alignItems="center" px={2} py={{ xs: 4, sm: 8 }} spacing={2} textAlign="center">
39
+ {title && <Title title={title} />}
40
+ <img src={imgSrc} style={{ width: '100%', maxWidth: 450, marginTop: theme.spacing(4) }} />
41
+ <Typography variant="h2">{translate(isProduction ? 'ra.page.error' : error.message, { _: error.message })}</Typography>
42
+ {!isProduction && <Typography variant="caption">{translate('ra.message.error_more_info')}</Typography>}
43
+ {errorInfo && (
44
+ <Typography
45
+ variant="body1"
46
+ component="pre"
47
+ textAlign={isProduction ? 'center' : 'start'}
48
+ fontFamily={isProduction ? 'inherit' : 'monospace'}
49
+ sx={{
50
+ whiteSpace: 'pre-wrap',
51
+ wordBreak: 'break-word'
52
+ }}
53
+ >
54
+ {isProduction ? translate('ra.message.error') : errorInfo?.componentStack?.substring(0, 250) + '...'}
55
+ </Typography>
56
+ )}
57
+
58
+ <Button variant="contained" startIcon={<History />} onClick={handleBack}>
59
+ {translate('ra.action.back')}
60
+ </Button>
61
+ </Stack>
62
+ </Container>
63
+ );
64
+ }
65
+ Error.propTypes = {
66
+ className: PropTypes.string,
67
+ error: PropTypes.object.isRequired,
68
+ errorInfo: PropTypes.object,
69
+ title: TitlePropType
70
+ };
71
+
72
+ interface InternalErrorProps extends Omit<HtmlHTMLAttributes<HTMLDivElement>, 'title'>, FallbackProps, ErrorProps {
73
+ className?: string;
74
+ }
75
+
76
+ export interface ErrorProps extends Pick<FallbackProps, 'error'> {
77
+ errorInfo?: ErrorInfo;
78
+ title?: TitleComponent;
79
+ }
80
+
81
+ export default Error;
@@ -4,7 +4,7 @@ import { Breadcrumbs } from '../@extended';
4
4
  import { Footer } from './Footer';
5
5
  import { LayoutContent } from './Content';
6
6
  import { LayoutWrapper } from './Wrapper';
7
- import { LoadingIndicator } from 'ra-ui-materialui';
7
+ import { ErrorProps, LoadingIndicator } from 'ra-ui-materialui';
8
8
  import { NavMenu } from './NavMenu';
9
9
  import { Navigation } from './Navigation';
10
10
  import { Outlet } from 'react-router-dom';
@@ -15,6 +15,7 @@ type ILayoutProps = React.PropsWithChildren<{
15
15
  name: string;
16
16
  version: string;
17
17
  copy?: string;
18
+ error?: React.ComponentType<ErrorProps>;
18
19
  }>;
19
20
 
20
21
  const Layout = withLayoutProvider(function Layout(props: ILayoutProps) {
@@ -34,7 +35,7 @@ const Layout = withLayoutProvider(function Layout(props: ILayoutProps) {
34
35
  <NavMenu>
35
36
  <Navigation />
36
37
  </NavMenu>
37
- <LayoutContent>
38
+ <LayoutContent error={props.error}>
38
39
  {!isLoading && (
39
40
  //@ts-ignore
40
41
  <Breadcrumbs
@@ -8,3 +8,4 @@ export * from './Navigation';
8
8
  export * from './NavMenu';
9
9
  export * from './Provider';
10
10
  export * from './Wrapper';
11
+ export * from './Error'
@@ -15,14 +15,14 @@ import {
15
15
  TableRow,
16
16
  Typography
17
17
  } from '@mui/material';
18
- import { RaRecord, useRecordContext, useTranslate, useTranslateLabel } from 'ra-core';
18
+ import { FormDataConsumer, RaRecord, useRecordContext, useTranslate, useTranslateLabel } from 'ra-core';
19
19
  import { styled, useTheme } from '@mui/material/styles';
20
20
 
21
21
  import { PlusCircleOutlined } from '@ant-design/icons';
22
22
  import PropTypes from 'prop-types';
23
23
  import { TableFormIteratorContext } from './TableFormIteratorContext';
24
24
  import { TableFormIteratorItem } from './TableFormIteratorItem';
25
- import { UseFieldArrayReturn } from 'react-hook-form';
25
+ import { UseFieldArrayReturn, useFormContext } from 'react-hook-form';
26
26
  import get from 'lodash/get';
27
27
 
28
28
  /**
@@ -44,13 +44,27 @@ import get from 'lodash/get';
44
44
  * @returns
45
45
  */
46
46
  const TableFormIterator = (props: TableFormIteratorProps) => {
47
- const { children, resource, source, label, disableActions = false, disableAdd = false, disableRemove = false, className, empty, template = {} } = props;
47
+ const {
48
+ children,
49
+ resource,
50
+ source,
51
+ label,
52
+ disableActions = false,
53
+ disableAdd = false,
54
+ disableRemove = false,
55
+ className,
56
+ empty,
57
+ template = {}
58
+ } = props;
48
59
  const [confirmIsOpen, setConfirmIsOpen] = useState<boolean>(false);
49
- const { fields, remove, replace } = useArrayInput(props);
60
+ const { fields, remove, replace, append } = useArrayInput(props);
61
+ const { resetField } = useFormContext();
62
+
50
63
  const theme = useTheme();
51
64
  const translate = useTranslate();
52
65
  const record = useRecordContext(props);
53
- const initialDefaultValue = useRef({});
66
+ const initialDefaultValue = useRef(template || {});
67
+
54
68
  const translateLabel = useTranslateLabel();
55
69
  const removeField = useCallback(
56
70
  (index: number) => {
@@ -66,6 +80,50 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
66
80
  for (const k in initialDefaultValue.current) initialDefaultValue.current[k] = null;
67
81
  }
68
82
 
83
+ const addField = useCallback(
84
+ (item: any = undefined) => {
85
+ let defaultValue = item;
86
+ if (item == null) {
87
+ defaultValue = initialDefaultValue.current;
88
+ if (
89
+ Children.count(children) === 1 &&
90
+ React.isValidElement(Children.only(children)) &&
91
+ // @ts-ignore
92
+ !Children.only(children).props.source &&
93
+ // Make sure it's not a FormDataConsumer
94
+ // @ts-ignore
95
+ Children.map(children, (input) => React.isValidElement(input) && input.type !== FormDataConsumer).some(Boolean)
96
+ ) {
97
+ // ArrayInput used for an array of scalar values
98
+ // (e.g. tags: ['foo', 'bar'])
99
+ defaultValue = '';
100
+ } else {
101
+ // ArrayInput used for an array of objects
102
+ // (e.g. authors: [{ firstName: 'John', lastName: 'Doe' }, { firstName: 'Jane', lastName: 'Doe' }])
103
+ defaultValue = defaultValue || ({} as Record<string, unknown>);
104
+ Children.forEach(children, (input) => {
105
+ if (React.isValidElement(input) && input.type !== FormDataConsumer && input.props.source) {
106
+ defaultValue[input.props.source] = input.props.defaultValue ?? null;
107
+ }
108
+ });
109
+ }
110
+ }
111
+ const newField = { ...defaultValue, ...template };
112
+ append(newField);
113
+ // Make sure the newly added inputs are not considered dirty by react-hook-form
114
+ resetField(`${source}.${fields.length}`, { defaultValue });
115
+ },
116
+ [append, children, resetField, source, fields.length, template]
117
+ );
118
+
119
+ // add field and call the onClick event of the button passed as addButton prop
120
+ const handleAddButtonClick = (originalOnClickHandler: any) => (event: MouseEvent) => {
121
+ addField();
122
+ if (originalOnClickHandler) {
123
+ originalOnClickHandler(event);
124
+ }
125
+ };
126
+
69
127
  const handleArrayClear = useCallback(() => {
70
128
  replace([]);
71
129
  setConfirmIsOpen(false);
@@ -95,7 +153,7 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
95
153
  source,
96
154
  disableAdd,
97
155
  template,
98
- addButton: props?.addButton,
156
+ onClick: handleAddButtonClick((props?.addButton as any)?.props?.onClick)
99
157
  })}
100
158
 
101
159
  <TableContainer component={Paper} sx={{ mt: 2, border: `1px solid ${tableBorderColor}` }}>
@@ -177,34 +235,25 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
177
235
  };
178
236
 
179
237
  const AddTableRow = (props: any) => {
180
- const { label, disableAdd, template = {} } = props;
181
- const { append } = useArrayInput(props);
238
+ const { label, disableAdd, onClick } = props;
182
239
  const theme = useTheme();
183
240
  // @ts-ignore
184
241
  const tableBorderColor = theme.palette.mode === 'dark' ? theme.palette.grey.A400 : theme.palette.grey.A800;
185
242
  const iconColor = theme.palette.mode === 'light' ? '#000000' : '#FFFFFF';
186
243
 
187
- const handleAddButtonClick = useCallback((
188
- originalOnClickHandler: React.MouseEventHandler<Element>
189
- ) => (event: React.MouseEvent<Element, MouseEvent>) => {
190
- append(template);
191
- originalOnClickHandler && originalOnClickHandler(event);
192
- }, [append, template]);
193
-
194
244
  return (
195
245
  <Stack justifyContent={'space-between'} alignItems={'center'} flexDirection={'row'}>
196
- <Typography>{label}</Typography>
197
- {!disableAdd && (
198
- React.isValidElement(props?.addButton) ?
246
+ {label !== false && <Typography>{label}</Typography>}
247
+ {!disableAdd &&
248
+ (React.isValidElement(props?.addButton) ? (
199
249
  React.cloneElement(props?.addButton, {
200
- onClick: handleAddButtonClick(
201
- props?.addButton?.props.onClick
202
- ),
203
- }) :
204
- <IconButton size="small" color="secondary" sx={{ border: `1px solid ${tableBorderColor}` }} onClick={() => append(template)}>
250
+ onClick: onClick
251
+ })
252
+ ) : (
253
+ <IconButton size="small" color="secondary" sx={{ border: `1px solid ${tableBorderColor}` }} onClick={onClick}>
205
254
  <PlusCircleOutlined style={{ color: iconColor }} />
206
255
  </IconButton>
207
- )}
256
+ ))}
208
257
  </Stack>
209
258
  );
210
259
  };
@@ -222,7 +271,7 @@ const StyledTableFormIterator = styled(TableFormIterator, {
222
271
  }));
223
272
 
224
273
  AddTableRow.propTypes = {
225
- label: PropTypes.string,
274
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
226
275
  source: PropTypes.string,
227
276
  defaultValue: PropTypes.any
228
277
  };
@@ -237,7 +286,7 @@ TableFormIterator.propTypes = {
237
286
  formState: PropTypes.object,
238
287
  record: PropTypes.object,
239
288
  source: PropTypes.string,
240
- label: PropTypes.string,
289
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
241
290
  resource: PropTypes.string,
242
291
  translate: PropTypes.func,
243
292
  disableAdd: PropTypes.bool,
@@ -261,7 +310,7 @@ export interface TableFormIteratorProps extends Partial<UseFieldArrayReturn> {
261
310
  submitFailed?: boolean;
262
311
  };
263
312
  record?: RaRecord;
264
- label?: string;
313
+ label?: string | boolean;
265
314
  resource?: string;
266
315
  source?: string;
267
316
  sx?: SxProps;
@@ -47,14 +47,14 @@ export const TableFormIteratorItem = React.forwardRef((props: TableFormIteratorI
47
47
  resource,
48
48
  disabled,
49
49
  ...inputProps,
50
- label: false
50
+ label: ''
51
51
  })}
52
52
  </TableCell>
53
53
  );
54
54
  })}
55
55
 
56
56
  {!disableActions && (
57
- <TableCell sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', border: 0, pt: 2 }}>
57
+ <TableCell sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', border: 0, pt: 2.5 }}>
58
58
  <ActionsMenu horizontal>
59
59
  <Typography color="error" onClick={() => setConfirmIsOpen(true)}>
60
60
  {translate('ra.action.delete')}
@@ -1,7 +1,122 @@
1
- import { ListProps, List as RaList } from 'react-admin';
2
-
1
+ import { TitlePropType, ListProps } from 'react-admin';
3
2
  import MainCard from '../MainCard';
4
3
  import { styled } from '@mui/system';
4
+ import { ReactElement } from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { ListBase, RaRecord } from 'ra-core';
7
+ import { ListView } from './ListView';
8
+
9
+ /**
10
+ * List page component
11
+ *
12
+ * The <List> component renders the list layout (title, buttons, filters, pagination),
13
+ * and fetches the list of records from the REST API.
14
+ *
15
+ * It then delegates the rendering of the list of records to its child component.
16
+ * Usually, it's a <Datagrid>, responsible for displaying a table with one row for each post.
17
+ *
18
+ * The <List> component accepts the following props:
19
+ *
20
+ * - actions
21
+ * - aside: Side Component
22
+ * - children: List Layout
23
+ * - component
24
+ * - disableAuthentication
25
+ * - disableSyncWithLocation
26
+ * - empty: Empty Page Component
27
+ * - emptyWhileLoading
28
+ * - exporter
29
+ * - filters: Filter Inputs
30
+ * - filter: Permanent Filter
31
+ * - filterDefaultValues
32
+ * - pagination: Pagination Component
33
+ * - perPage: Pagination Size
34
+ * - queryOptions
35
+ * - sort: Default Sort Field & Order
36
+ * - title
37
+ * - sx: CSS API
38
+ *
39
+ * @example
40
+ * const postFilters = [
41
+ * <TextInput label="Search" source="q" alwaysOn />,
42
+ * <TextInput label="Title" source="title" />
43
+ * ];
44
+ * export const PostList = () => (
45
+ * <List
46
+ * title="List of posts"
47
+ * sort={{ field: 'published_at' }}
48
+ * filter={{ is_published: true }}
49
+ * filters={postFilters}
50
+ * >
51
+ * <Datagrid>
52
+ * <TextField source="id" />
53
+ * <TextField source="title" />
54
+ * <EditButton />
55
+ * </Datagrid>
56
+ * </List>
57
+ * );
58
+ */
59
+ const RaList = <RecordType extends RaRecord = any>({
60
+ debounce,
61
+ disableAuthentication,
62
+ disableSyncWithLocation,
63
+ exporter,
64
+ filter = defaultFilter,
65
+ filterDefaultValues,
66
+ perPage = 10,
67
+ queryOptions,
68
+ resource,
69
+ sort,
70
+ storeKey,
71
+ ...rest
72
+ }: ListProps<RecordType>): ReactElement => (
73
+ <ListBase<RecordType>
74
+ debounce={debounce}
75
+ disableAuthentication={disableAuthentication}
76
+ disableSyncWithLocation={disableSyncWithLocation}
77
+ exporter={exporter}
78
+ filter={filter}
79
+ filterDefaultValues={filterDefaultValues}
80
+ perPage={perPage}
81
+ queryOptions={queryOptions}
82
+ resource={resource}
83
+ sort={sort}
84
+ storeKey={storeKey}
85
+ >
86
+ <ListView<RecordType> {...rest} />
87
+ </ListBase>
88
+ );
89
+
90
+ // export interface ListProps<RecordType extends RaRecord = any> extends ListControllerProps<RecordType>, ListViewProps {}
91
+
92
+ RaList.propTypes = {
93
+ // the props you can change
94
+ // @ts-ignore-line
95
+ actions: PropTypes.oneOfType([PropTypes.bool, PropTypes.element]),
96
+ aside: PropTypes.element,
97
+ children: PropTypes.node.isRequired,
98
+ className: PropTypes.string,
99
+ emptyWhileLoading: PropTypes.bool,
100
+ filter: PropTypes.object,
101
+ filterDefaultValues: PropTypes.object,
102
+ filters: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)]),
103
+ // @ts-ignore-line
104
+ pagination: PropTypes.oneOfType([PropTypes.element, PropTypes.bool]),
105
+ perPage: PropTypes.number,
106
+ //@ts-ignore-line
107
+ sort: PropTypes.shape({
108
+ field: PropTypes.string,
109
+ order: PropTypes.oneOf(['ASC', 'DESC'] as const)
110
+ }),
111
+ sx: PropTypes.any,
112
+ title: TitlePropType,
113
+ // the props managed by react-admin
114
+ disableSyncWithLocation: PropTypes.bool,
115
+ hasCreate: PropTypes.bool,
116
+ resource: PropTypes.string
117
+ };
118
+
119
+ const defaultFilter = {};
5
120
 
6
121
  const ApplicaStyledList = styled(RaList, {
7
122
  name: 'RaApplicaList',