-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathListBase.tsx
49 lines (47 loc) · 1.35 KB
/
ListBase.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as React from 'react';
import { ReactNode } from 'react';
import useListController, { ListProps } from './useListController';
import ListContextProvider from './ListContextProvider';
/**
* Call useListController and put the value in a ListContext
*
* Base class for <List> components, without UI.
*
* Accepts any props accepted by useListController:
* - filter: permanent filter applied to the list
* - filters: Filter element, to display the filters
* - filterDefaultValues: object;
* - perPage: Number of results per page
* - sort: Default sort
* - exporter: exported function
*
* @example // Custom list layout
*
* const PostList = props => (
* <BaseList {...props} perPage={10}>
* <div>
* List metrics...
* </div>
* <Grid container>
* <Grid item xs={8}>
* <SimpleList primaryText={record => record.title} />
* </Grid>
* <Grid item xs={4}>
* List instructions...
* </Grid>
* </Grid>
* <div>
* Post related links...
* </div>
* </BaseList>
* );
*/
const ListBase = ({
children,
...props
}: ListProps & { children: ReactNode }) => (
<ListContextProvider value={useListController(props)}>
{children}
</ListContextProvider>
);
export default ListBase;