|
1 | 1 | import * as React from 'react'; |
2 | 2 | import { ReactElement } from 'react'; |
3 | 3 | import { ListBase, ListBaseProps, RaRecord } from 'ra-core'; |
| 4 | +import { useThemeProps } from '@mui/material/styles'; |
4 | 5 |
|
5 | 6 | import { ListView, ListViewProps } from './ListView'; |
6 | 7 | import { Loading } from '../layout'; |
@@ -55,42 +56,53 @@ import { Loading } from '../layout'; |
55 | 56 | * </List> |
56 | 57 | * ); |
57 | 58 | */ |
58 | | -export const List = <RecordType extends RaRecord = any>({ |
59 | | - debounce, |
60 | | - disableAuthentication, |
61 | | - disableSyncWithLocation, |
62 | | - exporter, |
63 | | - filter = defaultFilter, |
64 | | - filterDefaultValues, |
65 | | - loading = defaultLoading, |
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 | | - loading={loading} |
81 | | - perPage={perPage} |
82 | | - queryOptions={queryOptions} |
83 | | - resource={resource} |
84 | | - sort={sort} |
85 | | - storeKey={storeKey} |
86 | | - > |
87 | | - <ListView<RecordType> {...rest} /> |
88 | | - </ListBase> |
89 | | -); |
| 59 | +export const List = <RecordType extends RaRecord = any>( |
| 60 | + props: ListProps<RecordType> |
| 61 | +): ReactElement => { |
| 62 | + const { |
| 63 | + debounce, |
| 64 | + disableAuthentication, |
| 65 | + disableSyncWithLocation, |
| 66 | + exporter, |
| 67 | + filter = defaultFilter, |
| 68 | + filterDefaultValues, |
| 69 | + loading = defaultLoading, |
| 70 | + perPage = 10, |
| 71 | + queryOptions, |
| 72 | + resource, |
| 73 | + sort, |
| 74 | + storeKey, |
| 75 | + ...rest |
| 76 | + } = useThemeProps({ |
| 77 | + props: props, |
| 78 | + name: PREFIX, |
| 79 | + }); |
| 80 | + |
| 81 | + return ( |
| 82 | + <ListBase<RecordType> |
| 83 | + debounce={debounce} |
| 84 | + disableAuthentication={disableAuthentication} |
| 85 | + disableSyncWithLocation={disableSyncWithLocation} |
| 86 | + exporter={exporter} |
| 87 | + filter={filter} |
| 88 | + filterDefaultValues={filterDefaultValues} |
| 89 | + loading={loading} |
| 90 | + perPage={perPage} |
| 91 | + queryOptions={queryOptions} |
| 92 | + resource={resource} |
| 93 | + sort={sort} |
| 94 | + storeKey={storeKey} |
| 95 | + > |
| 96 | + <ListView<RecordType> {...rest} /> |
| 97 | + </ListBase> |
| 98 | + ); |
| 99 | +}; |
90 | 100 |
|
91 | 101 | export interface ListProps<RecordType extends RaRecord = any> |
92 | 102 | extends ListBaseProps<RecordType>, |
93 | 103 | ListViewProps {} |
94 | 104 |
|
95 | 105 | const defaultFilter = {}; |
96 | 106 | const defaultLoading = <Loading />; |
| 107 | + |
| 108 | +const PREFIX = 'RaList'; // Types declared in ListView. |
0 commit comments