11import * as React from 'react' ;
22import { ReactElement } from 'react' ;
33import { InfiniteListBase , InfiniteListBaseProps , RaRecord } from 'ra-core' ;
4+ import { useThemeProps } from '@mui/material/styles' ;
45
56import { InfinitePagination } from './pagination' ;
67import { ListView , ListViewProps } from './ListView' ;
@@ -59,39 +60,48 @@ import { Loading } from '../layout';
5960 * </List>
6061 * );
6162 */
62- export const InfiniteList = < RecordType extends RaRecord = any > ( {
63- debounce,
64- disableAuthentication,
65- disableSyncWithLocation,
66- exporter,
67- filter = defaultFilter ,
68- filterDefaultValues,
69- loading = defaultLoading ,
70- pagination = defaultPagination ,
71- perPage = 10 ,
72- queryOptions,
73- resource,
74- sort,
75- storeKey,
76- ...rest
77- } : InfiniteListProps < RecordType > ) : ReactElement => (
78- < InfiniteListBase < RecordType >
79- debounce = { debounce }
80- disableAuthentication = { disableAuthentication }
81- disableSyncWithLocation = { disableSyncWithLocation }
82- exporter = { exporter }
83- filter = { filter }
84- filterDefaultValues = { filterDefaultValues }
85- loading = { loading }
86- perPage = { perPage }
87- queryOptions = { queryOptions }
88- resource = { resource }
89- sort = { sort }
90- storeKey = { storeKey }
91- >
92- < ListView < RecordType > { ...rest } pagination = { pagination } />
93- </ InfiniteListBase >
94- ) ;
63+ export const InfiniteList = < RecordType extends RaRecord = any > (
64+ props : InfiniteListProps < RecordType >
65+ ) : ReactElement => {
66+ const {
67+ debounce,
68+ disableAuthentication,
69+ disableSyncWithLocation,
70+ exporter,
71+ filter = defaultFilter ,
72+ filterDefaultValues,
73+ loading = defaultLoading ,
74+ pagination = defaultPagination ,
75+ perPage = 10 ,
76+ queryOptions,
77+ resource,
78+ sort,
79+ storeKey,
80+ ...rest
81+ } = useThemeProps ( {
82+ props : props ,
83+ name : PREFIX ,
84+ } ) ;
85+
86+ return (
87+ < InfiniteListBase < RecordType >
88+ debounce = { debounce }
89+ disableAuthentication = { disableAuthentication }
90+ disableSyncWithLocation = { disableSyncWithLocation }
91+ exporter = { exporter }
92+ filter = { filter }
93+ filterDefaultValues = { filterDefaultValues }
94+ loading = { loading }
95+ perPage = { perPage }
96+ queryOptions = { queryOptions }
97+ resource = { resource }
98+ sort = { sort }
99+ storeKey = { storeKey }
100+ >
101+ < ListView < RecordType > { ...rest } pagination = { pagination } />
102+ </ InfiniteListBase >
103+ ) ;
104+ } ;
95105
96106const defaultPagination = < InfinitePagination /> ;
97107const defaultFilter = { } ;
@@ -100,3 +110,17 @@ const defaultLoading = <Loading />;
100110export interface InfiniteListProps < RecordType extends RaRecord = any >
101111 extends InfiniteListBaseProps < RecordType > ,
102112 ListViewProps { }
113+
114+ const PREFIX = 'RaInfiniteList' ;
115+
116+ declare module '@mui/material/styles' {
117+ interface ComponentsPropsList {
118+ [ PREFIX ] : Partial < InfiniteListProps > ;
119+ }
120+
121+ interface Components {
122+ [ PREFIX ] ?: {
123+ defaultProps ?: ComponentsPropsList [ typeof PREFIX ] ;
124+ } ;
125+ }
126+ }
0 commit comments