Skip to content

Commit a701965

Browse files
committed
Fix types
1 parent 10a52cf commit a701965

File tree

2 files changed

+89
-90
lines changed

2 files changed

+89
-90
lines changed

packages/ra-core/src/controller/field/types.ts

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,8 @@
1-
import { ReactElement } from 'react';
2-
import { ExtractRecordPaths, HintedString } from '../../types';
3-
4-
type SortOrder = 'ASC' | 'DESC';
1+
import { ExtractRecordPaths } from '../../types';
52

63
export interface BaseFieldProps<
74
RecordType extends Record<string, any> = Record<string, any>,
85
> {
9-
/**
10-
* The field to use for sorting when users click this column head, if sortable.
11-
*
12-
* @see https://marmelab.com/react-admin/Fields.html#sortby
13-
* @example
14-
* const PostList = () => (
15-
* <List>
16-
* <Datagrid>
17-
* <TextField source="title" />
18-
* <ReferenceField source="author_id" sortBy="author.name">
19-
* <TextField source="name" />
20-
* </ReferenceField>
21-
* </Datagrid>
22-
* </List>
23-
* );
24-
*/
25-
sortBy?: HintedString<ExtractRecordPaths<RecordType>>;
26-
27-
/**
28-
* The order used for sorting when users click this column head, if sortable.
29-
*
30-
* @see https://marmelab.com/react-admin/Fields.html#sortbyorder
31-
* @example
32-
* const PostList = () => (
33-
* <List>
34-
* <Datagrid>
35-
* <TextField source="title" />
36-
* <DateField source="updated_at" sortByOrder="DESC" />
37-
* </Datagrid>
38-
* </List>
39-
* );
40-
*/
41-
sortByOrder?: SortOrder;
42-
436
/**
447
* Name of the property to display.
458
*
@@ -56,57 +19,6 @@ export interface BaseFieldProps<
5619
*/
5720
source: ExtractRecordPaths<RecordType>;
5821

59-
/**
60-
* Label to use as column header when using <Datagrid> or <SimpleShowLayout>.
61-
* Defaults to the capitalized field name. Set to false to disable the label.
62-
*
63-
* @see https://marmelab.com/react-admin/Fields.html#label
64-
* @example
65-
* const PostList = () => (
66-
* <List>
67-
* <Datagrid>
68-
* <TextField source="title" />
69-
* <TextField source="body" label="Content" />
70-
* </Datagrid>
71-
* </List>
72-
* );
73-
*/
74-
label?: string | ReactElement | boolean;
75-
76-
/**
77-
* Set it to false to disable the click handler on the column header when used inside <Datagrid>.
78-
*
79-
* @see https://marmelab.com/react-admin/Fields.html#sortable
80-
* @example
81-
* const PostList = () => (
82-
* <List>
83-
* <Datagrid>
84-
* <TextField source="title" />
85-
* <ReferenceField source="author_id" sortable={false}>
86-
* <TextField source="name" />
87-
* </ReferenceField>
88-
* </Datagrid>
89-
* </List>
90-
* );
91-
*/
92-
sortable?: boolean;
93-
94-
/**
95-
* The text to display when the field value is empty. Defaults to empty string.
96-
*
97-
* @see https://marmelab.com/react-admin/Fields.html#emptytext
98-
* @example
99-
* const PostList = () => (
100-
* <List>
101-
* <Datagrid>
102-
* <TextField source="title" />
103-
* <TextField source="author" emptyText="missing data" />
104-
* </Datagrid>
105-
* </List>
106-
* );
107-
*/
108-
emptyText?: string;
109-
11022
/**
11123
* The current record to use. Defaults to the `RecordContext` value.
11224
*

packages/ra-ui-materialui/src/field/types.ts

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { ReactElement } from 'react';
12
import { TableCellProps } from '@mui/material/TableCell';
2-
import { BaseFieldProps } from 'ra-core';
3+
import { BaseFieldProps, ExtractRecordPaths, HintedString } from 'ra-core';
34

45
type TextAlign = TableCellProps['align'];
6+
type SortOrder = 'ASC' | 'DESC';
57

68
export interface FieldProps<
79
RecordType extends Record<string, any> = Record<string, any>,
@@ -21,6 +23,91 @@ export interface FieldProps<
2123
*/
2224
headerClassName?: string;
2325

26+
/**
27+
* Label to use as column header when using <Datagrid> or <SimpleShowLayout>.
28+
* Defaults to the capitalized field name. Set to false to disable the label.
29+
*
30+
* @see https://marmelab.com/react-admin/Fields.html#label
31+
* @example
32+
* const PostList = () => (
33+
* <List>
34+
* <Datagrid>
35+
* <TextField source="title" />
36+
* <TextField source="body" label="Content" />
37+
* </Datagrid>
38+
* </List>
39+
* );
40+
*/
41+
label?: string | ReactElement | boolean;
42+
43+
/**
44+
* Set it to false to disable the click handler on the column header when used inside <Datagrid>.
45+
*
46+
* @see https://marmelab.com/react-admin/Fields.html#sortable
47+
* @example
48+
* const PostList = () => (
49+
* <List>
50+
* <Datagrid>
51+
* <TextField source="title" />
52+
* <ReferenceField source="author_id" sortable={false}>
53+
* <TextField source="name" />
54+
* </ReferenceField>
55+
* </Datagrid>
56+
* </List>
57+
* );
58+
*/
59+
sortable?: boolean;
60+
61+
/**
62+
* The text to display when the field value is empty. Defaults to empty string.
63+
*
64+
* @see https://marmelab.com/react-admin/Fields.html#emptytext
65+
* @example
66+
* const PostList = () => (
67+
* <List>
68+
* <Datagrid>
69+
* <TextField source="title" />
70+
* <TextField source="author" emptyText="missing data" />
71+
* </Datagrid>
72+
* </List>
73+
* );
74+
*/
75+
emptyText?: string;
76+
77+
/**
78+
* The field to use for sorting when users click this column head, if sortable.
79+
*
80+
* @see https://marmelab.com/react-admin/Fields.html#sortby
81+
* @example
82+
* const PostList = () => (
83+
* <List>
84+
* <Datagrid>
85+
* <TextField source="title" />
86+
* <ReferenceField source="author_id" sortBy="author.name">
87+
* <TextField source="name" />
88+
* </ReferenceField>
89+
* </Datagrid>
90+
* </List>
91+
* );
92+
*/
93+
sortBy?: HintedString<ExtractRecordPaths<RecordType>>;
94+
95+
/**
96+
* The order used for sorting when users click this column head, if sortable.
97+
*
98+
* @see https://marmelab.com/react-admin/Fields.html#sortbyorder
99+
* @example
100+
* const PostList = () => (
101+
* <List>
102+
* <Datagrid>
103+
* <TextField source="title" />
104+
* <DateField source="updated_at" sortByOrder="DESC" />
105+
* </Datagrid>
106+
* </List>
107+
* );
108+
*/
109+
sortByOrder?: SortOrder;
110+
24111
/**
25112
* The text alignment for the cell content, when used inside <Datagrid>.
26113
*

0 commit comments

Comments
 (0)