@contember/create 2.0.0-alpha.28 → 2.0.0-alpha.30
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.
- package/package.json +2 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +22 -21
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/defined.tsx +3 -3
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +13 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/labels.tsx +22 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/create",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.30",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"bin": "dist/production/run.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@contember/cli-common": "2.0.0-alpha.
|
|
7
|
+
"@contember/cli-common": "2.0.0-alpha.30",
|
|
8
8
|
"chalk": "^5.3.0",
|
|
9
9
|
"fs-extra": "^11.2.0",
|
|
10
10
|
"js-yaml": "^4.1.0"
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
} from './filters'
|
|
29
29
|
import { CheckIcon, XIcon } from 'lucide-react'
|
|
30
30
|
import { DataGridIsDefinedFilterControls } from './filters/defined'
|
|
31
|
+
import { DataViewFieldLabel, DataViewHasManyLabel, DataViewHasOneLabel } from './labels'
|
|
31
32
|
|
|
32
33
|
export const DataGridActionColumn = Component<{ children: ReactNode }>(({ children }) => (
|
|
33
34
|
<DataGridColumnLeaf
|
|
@@ -39,7 +40,7 @@ export const DataGridActionColumn = Component<{ children: ReactNode }>(({ childr
|
|
|
39
40
|
|
|
40
41
|
export type DataGridTextColumnProps = {
|
|
41
42
|
field: string
|
|
42
|
-
header
|
|
43
|
+
header?: ReactNode
|
|
43
44
|
children?: ReactNode
|
|
44
45
|
format?: (value: string | null) => ReactNode
|
|
45
46
|
filter?: ReactNode
|
|
@@ -47,7 +48,7 @@ export type DataGridTextColumnProps = {
|
|
|
47
48
|
|
|
48
49
|
export const DataGridTextColumn = Component<DataGridTextColumnProps>(({ field, header, children, format, filter }) => (
|
|
49
50
|
<DataGridColumn
|
|
50
|
-
header={header}
|
|
51
|
+
header={header ?? <DataViewFieldLabel field={field}/>}
|
|
51
52
|
sortingField={field}
|
|
52
53
|
name={field}
|
|
53
54
|
children={children ?? <Field field={field} format={format} />}
|
|
@@ -60,7 +61,7 @@ export const DataGridTextColumn = Component<DataGridTextColumnProps>(({ field, h
|
|
|
60
61
|
|
|
61
62
|
export type DataGridBooleanColumnProps = {
|
|
62
63
|
field: string
|
|
63
|
-
header
|
|
64
|
+
header?: ReactNode
|
|
64
65
|
children?: ReactNode
|
|
65
66
|
format?: (value: boolean | null) => ReactNode
|
|
66
67
|
filter?: ReactNode
|
|
@@ -68,7 +69,7 @@ export type DataGridBooleanColumnProps = {
|
|
|
68
69
|
|
|
69
70
|
export const DataGridBooleanColumn = Component<DataGridBooleanColumnProps>(({ field, header, children, format, filter }) => (
|
|
70
71
|
<DataGridColumn
|
|
71
|
-
header={header}
|
|
72
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
72
73
|
sortingField={field}
|
|
73
74
|
name={field}
|
|
74
75
|
children={children ?? <Field field={field} format={format ?? formatBoolean} />}
|
|
@@ -83,7 +84,7 @@ export const DataGridBooleanColumn = Component<DataGridBooleanColumnProps>(({ fi
|
|
|
83
84
|
|
|
84
85
|
export type DataGridNumberColumnProps = {
|
|
85
86
|
field: string
|
|
86
|
-
header
|
|
87
|
+
header?: ReactNode
|
|
87
88
|
children?: ReactNode
|
|
88
89
|
format?: (value: number | null) => ReactNode
|
|
89
90
|
filter?: ReactNode
|
|
@@ -91,7 +92,7 @@ export type DataGridNumberColumnProps = {
|
|
|
91
92
|
|
|
92
93
|
export const DataGridNumberColumn = Component<DataGridNumberColumnProps>(({ field, header, children, format, filter }) => (
|
|
93
94
|
<DataGridColumn
|
|
94
|
-
header={header}
|
|
95
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
95
96
|
sortingField={field}
|
|
96
97
|
name={field}
|
|
97
98
|
children={children ?? <Field field={field} format={format ?? formatNumber} />}
|
|
@@ -106,7 +107,7 @@ export const DataGridNumberColumn = Component<DataGridNumberColumnProps>(({ fiel
|
|
|
106
107
|
|
|
107
108
|
export type DataGridDateColumnProps = {
|
|
108
109
|
field: string
|
|
109
|
-
header
|
|
110
|
+
header?: ReactNode
|
|
110
111
|
children?: ReactNode
|
|
111
112
|
format?: (value: string | null) => ReactNode
|
|
112
113
|
filter?: ReactNode
|
|
@@ -114,7 +115,7 @@ export type DataGridDateColumnProps = {
|
|
|
114
115
|
|
|
115
116
|
export const DataGridDateColumn = Component<DataGridDateColumnProps>(({ field, header, children, format, filter }) => (
|
|
116
117
|
<DataGridColumn
|
|
117
|
-
header={header}
|
|
118
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
118
119
|
sortingField={field}
|
|
119
120
|
name={field}
|
|
120
121
|
children={children ?? <Field field={field} format={format ?? formatDate} />}
|
|
@@ -130,7 +131,7 @@ export const DataGridDateColumn = Component<DataGridDateColumnProps>(({ field, h
|
|
|
130
131
|
|
|
131
132
|
export type DataGridDateTimeColumnProps = {
|
|
132
133
|
field: string
|
|
133
|
-
header
|
|
134
|
+
header?: ReactNode
|
|
134
135
|
children?: ReactNode
|
|
135
136
|
format?: (value: string | null) => ReactNode
|
|
136
137
|
filter?: ReactNode
|
|
@@ -138,7 +139,7 @@ export type DataGridDateTimeColumnProps = {
|
|
|
138
139
|
|
|
139
140
|
export const DataGridDateTimeColumn = Component<DataGridDateTimeColumnProps>(({ field, header, children, format, filter }) => (
|
|
140
141
|
<DataGridColumn
|
|
141
|
-
header={header}
|
|
142
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
142
143
|
sortingField={field}
|
|
143
144
|
name={field}
|
|
144
145
|
children={children ?? <Field field={field} format={format ?? formatDateTime} />}
|
|
@@ -154,7 +155,7 @@ export const DataGridDateTimeColumn = Component<DataGridDateTimeColumnProps>(({
|
|
|
154
155
|
|
|
155
156
|
export type DataGridEnumColumnProps = {
|
|
156
157
|
field: string
|
|
157
|
-
header
|
|
158
|
+
header?: ReactNode
|
|
158
159
|
options?: Record<string, ReactNode>
|
|
159
160
|
children?: ReactNode
|
|
160
161
|
filter?: ReactNode
|
|
@@ -163,7 +164,7 @@ export type DataGridEnumColumnProps = {
|
|
|
163
164
|
|
|
164
165
|
export const DataGridEnumColumn = Component<DataGridEnumColumnProps>(({ field, header, options, children, tooltipActions, filter }) => (<>
|
|
165
166
|
<DataGridColumn
|
|
166
|
-
header={header}
|
|
167
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
167
168
|
sortingField={field}
|
|
168
169
|
name={field}
|
|
169
170
|
children={children ?? <DataGridEnumCell field={field} options={options} tooltipActions={tooltipActions} />}
|
|
@@ -179,7 +180,7 @@ export const DataGridEnumColumn = Component<DataGridEnumColumnProps>(({ field, h
|
|
|
179
180
|
|
|
180
181
|
export type DataGridIsDefinedColumnProps = {
|
|
181
182
|
field: string
|
|
182
|
-
header
|
|
183
|
+
header?: ReactNode
|
|
183
184
|
children?: ReactNode
|
|
184
185
|
format?: (value: boolean) => ReactNode
|
|
185
186
|
filter?: ReactNode
|
|
@@ -188,7 +189,7 @@ export type DataGridIsDefinedColumnProps = {
|
|
|
188
189
|
|
|
189
190
|
export const DataGridIsDefinedColumn = Component<DataGridIsDefinedColumnProps>(({ field, header, children, format, filter, filterName }) => (
|
|
190
191
|
<DataGridColumn
|
|
191
|
-
header={header}
|
|
192
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
192
193
|
name={field}
|
|
193
194
|
children={children ?? <Field field={field} format={it => {
|
|
194
195
|
if (format) {
|
|
@@ -206,7 +207,7 @@ export const DataGridIsDefinedColumn = Component<DataGridIsDefinedColumnProps>((
|
|
|
206
207
|
|
|
207
208
|
export type DataGridUuidColumnProps = {
|
|
208
209
|
field: string
|
|
209
|
-
header
|
|
210
|
+
header?: ReactNode
|
|
210
211
|
children?: ReactNode
|
|
211
212
|
format?: (value: string | null) => ReactNode
|
|
212
213
|
}
|
|
@@ -214,7 +215,7 @@ export type DataGridUuidColumnProps = {
|
|
|
214
215
|
|
|
215
216
|
export const DataGridUuidColumn = Component<DataGridUuidColumnProps>(({ field, header, children, format }) => (
|
|
216
217
|
<DataGridColumn
|
|
217
|
-
header={header}
|
|
218
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
218
219
|
sortingField={field}
|
|
219
220
|
name={field}
|
|
220
221
|
children={children ?? <Field field={field} format={format} />}
|
|
@@ -225,14 +226,14 @@ export type DataGridHasOneColumnProps = {
|
|
|
225
226
|
field: SugaredRelativeSingleEntity['field']
|
|
226
227
|
filterName?: string
|
|
227
228
|
children: ReactNode
|
|
228
|
-
header
|
|
229
|
+
header?: ReactNode
|
|
229
230
|
filter?: ReactNode
|
|
230
231
|
tooltipActions?: ReactNode
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
export const DataGridHasOneColumn = Component<DataGridHasOneColumnProps>(({ field, header, children, filter, filterName, tooltipActions }) => (
|
|
234
235
|
<DataGridColumn
|
|
235
|
-
header={header}
|
|
236
|
+
header={header ?? <DataViewHasOneLabel field={field} />}
|
|
236
237
|
name={typeof field === 'string' ? field : undefined}
|
|
237
238
|
children={<DataGridHasOneCell field={field} filterName={filterName} tooltipActions={tooltipActions}>{children}</DataGridHasOneCell>}
|
|
238
239
|
filterName={filterName ?? (typeof field === 'string' ? field : undefined)}
|
|
@@ -255,14 +256,14 @@ export type DataGridHasManyColumnProps = {
|
|
|
255
256
|
field: SugaredRelativeEntityList['field']
|
|
256
257
|
filterName?: string
|
|
257
258
|
children: ReactNode
|
|
258
|
-
header
|
|
259
|
+
header?: ReactNode
|
|
259
260
|
filter?: ReactNode
|
|
260
261
|
tooltipActions?: ReactNode
|
|
261
262
|
}
|
|
262
263
|
|
|
263
264
|
export const DataGridHasManyColumn = Component<DataGridHasManyColumnProps>(({ field, header, children, filter, filterName, tooltipActions }) => (
|
|
264
265
|
<DataGridColumn
|
|
265
|
-
header={header}
|
|
266
|
+
header={header ?? <DataViewHasManyLabel field={field} />}
|
|
266
267
|
name={typeof field === 'string' ? field : undefined}
|
|
267
268
|
children={<DataGridHasManyCell field={field} filterName={filterName} tooltipActions={tooltipActions}>{children}</DataGridHasManyCell>}
|
|
268
269
|
filterName={filterName ?? (typeof field === 'string' ? field : undefined)}
|
|
@@ -317,7 +318,7 @@ export const DataGridColumn = Component<DataGridColumnProps>(({ children, header
|
|
|
317
318
|
})
|
|
318
319
|
|
|
319
320
|
export interface DataGridColumnLeafProps {
|
|
320
|
-
header
|
|
321
|
+
header?: ReactNode
|
|
321
322
|
cell: ReactNode
|
|
322
323
|
name?: string
|
|
323
324
|
}
|
|
@@ -9,6 +9,7 @@ import { Button } from '../../ui/button'
|
|
|
9
9
|
import { dict } from '../../dict'
|
|
10
10
|
import { Component } from '@contember/interface'
|
|
11
11
|
import { DataGridFilterMobileHiding } from './mobile'
|
|
12
|
+
import { DataViewFieldLabel } from '../labels'
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
type DataGridBooleanFilterProps =
|
|
@@ -21,7 +22,7 @@ export const DataGridBooleanFilter = Component(({ label, ...props }: DataGridBoo
|
|
|
21
22
|
<DataViewBooleanFilter {...props}>
|
|
22
23
|
<DataGridFilterMobileHiding>
|
|
23
24
|
<DataGridSingleFilterUI>
|
|
24
|
-
<DataGridBooleanFilterSelect label={label} />
|
|
25
|
+
<DataGridBooleanFilterSelect label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
25
26
|
<DataGridBooleanFilterList />
|
|
26
27
|
</DataGridSingleFilterUI>
|
|
27
28
|
</DataGridFilterMobileHiding>
|
|
@@ -12,6 +12,7 @@ import { DataGridFilterMobileHiding } from './mobile'
|
|
|
12
12
|
import { Button } from '../../ui/button'
|
|
13
13
|
import { Label } from '../../ui/label'
|
|
14
14
|
import { XIcon } from 'lucide-react'
|
|
15
|
+
import { DataViewFieldLabel } from '../labels'
|
|
15
16
|
|
|
16
17
|
export type DataGridDateFilterProps =
|
|
17
18
|
& Omit<DataViewDateFilterProps, 'children'>
|
|
@@ -24,7 +25,7 @@ export const DataGridDateFilter = Component(({ label, ranges, ...props }: DataGr
|
|
|
24
25
|
<DataViewDateFilter {...props}>
|
|
25
26
|
<DataGridFilterMobileHiding>
|
|
26
27
|
<DataGridSingleFilterUI>
|
|
27
|
-
<DataGridDateFilterSelect label={label} ranges={ranges} />
|
|
28
|
+
<DataGridDateFilterSelect label={label ?? <DataViewFieldLabel field={props.field} />} ranges={ranges} />
|
|
28
29
|
<DataGridDateFilterList />
|
|
29
30
|
</DataGridSingleFilterUI>
|
|
30
31
|
</DataGridFilterMobileHiding>
|
|
@@ -2,13 +2,13 @@ import * as React from 'react'
|
|
|
2
2
|
import { ReactNode } from 'react'
|
|
3
3
|
import { DataViewBooleanFilterProps, DataViewIsDefinedFilter, DataViewNullFilterTrigger } from '@contember/react-dataview'
|
|
4
4
|
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'
|
|
5
|
-
import {
|
|
5
|
+
import { DataGridFilterSelectTriggerUI, DataGridSingleFilterUI } from '../ui'
|
|
6
6
|
import { dict } from '../../dict'
|
|
7
7
|
import { Component } from '@contember/interface'
|
|
8
8
|
import { DataGridFilterMobileHiding } from './mobile'
|
|
9
9
|
import { CheckIcon, XIcon } from 'lucide-react'
|
|
10
10
|
import { Button } from '../../ui/button'
|
|
11
|
-
import {
|
|
11
|
+
import { DataViewFieldLabel } from '../labels'
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
type DataGridIsDefinedFilterProps =
|
|
@@ -21,7 +21,7 @@ export const DataGridIsDefinedFilter = Component(({ label, ...props }: DataGridI
|
|
|
21
21
|
<DataViewIsDefinedFilter {...props}>
|
|
22
22
|
<DataGridFilterMobileHiding>
|
|
23
23
|
<DataGridSingleFilterUI>
|
|
24
|
-
<DataGridIsDefinedFilterSelect label={label} />
|
|
24
|
+
<DataGridIsDefinedFilterSelect label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
25
25
|
<DataGridIsDefinedFilterList />
|
|
26
26
|
</DataGridSingleFilterUI>
|
|
27
27
|
</DataGridFilterMobileHiding>
|
|
@@ -25,6 +25,7 @@ import { DataGridNullFilter } from './common'
|
|
|
25
25
|
import { dict } from '../../dict'
|
|
26
26
|
import { DataGridFilterMobileHiding } from './mobile'
|
|
27
27
|
import { useEnumOptionsFormatter } from '../../labels'
|
|
28
|
+
import { DataViewFieldLabel } from '../labels'
|
|
28
29
|
|
|
29
30
|
export type DataGridEnumFilterProps =
|
|
30
31
|
& Omit<DataViewEnumFilterProps, 'children'>
|
|
@@ -38,7 +39,7 @@ export const DataGridEnumFilter = Component(({ options, label, ...props }: DataG
|
|
|
38
39
|
<DataViewEnumFilter {...props}>
|
|
39
40
|
<DataGridFilterMobileHiding>
|
|
40
41
|
<DataGridSingleFilterUI>
|
|
41
|
-
<DataGridEnumFilterSelect options={options} label={label} />
|
|
42
|
+
<DataGridEnumFilterSelect options={options} label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
42
43
|
<DataGridEnumFilterList options={options} />
|
|
43
44
|
</DataGridSingleFilterUI>
|
|
44
45
|
</DataGridFilterMobileHiding>
|
|
@@ -18,6 +18,7 @@ import { formatNumber } from '../../formatting'
|
|
|
18
18
|
import { dict } from '../../dict'
|
|
19
19
|
import { Component } from '@contember/interface'
|
|
20
20
|
import { DataGridFilterMobileHiding } from './mobile'
|
|
21
|
+
import { DataViewFieldLabel } from '../labels'
|
|
21
22
|
|
|
22
23
|
export type DataGridNumberFilterProps =
|
|
23
24
|
& Omit<DataViewNumberFilterProps, 'children'>
|
|
@@ -29,7 +30,7 @@ export const DataGridNumberFilter = Component(({ label, ...props }: DataGridNumb
|
|
|
29
30
|
<DataViewNumberFilter {...props}>
|
|
30
31
|
<DataGridFilterMobileHiding>
|
|
31
32
|
<DataGridSingleFilterUI>
|
|
32
|
-
<DataGridNumberFilterSelect label={label} />
|
|
33
|
+
<DataGridNumberFilterSelect label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
33
34
|
<DataGridNumberFilterList />
|
|
34
35
|
</DataGridSingleFilterUI>
|
|
35
36
|
</DataGridFilterMobileHiding>
|
|
@@ -9,18 +9,27 @@ import {
|
|
|
9
9
|
DataViewNullFilterTrigger,
|
|
10
10
|
DataViewRelationFilterList,
|
|
11
11
|
DataViewRelationFilterOptions,
|
|
12
|
-
DataViewRelationFilterTrigger,
|
|
12
|
+
DataViewRelationFilterTrigger,
|
|
13
|
+
DataViewUnionFilterFields,
|
|
13
14
|
useDataViewFilterName,
|
|
14
15
|
useDataViewRelationFilterFactory,
|
|
15
16
|
UseDataViewRelationFilterResult,
|
|
16
17
|
} from '@contember/react-dataview'
|
|
17
18
|
import { Component, EntityId, StaticRender, useEntity } from '@contember/interface'
|
|
18
19
|
import { Popover, PopoverTrigger } from '../../ui/popover'
|
|
19
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
DataGridActiveFilterUI,
|
|
22
|
+
DataGridExcludeActionButtonUI,
|
|
23
|
+
DataGridFilterActionButtonUI,
|
|
24
|
+
DataGridFilterSelectItemUI,
|
|
25
|
+
DataGridFilterSelectTriggerUI,
|
|
26
|
+
DataGridSingleFilterUI,
|
|
27
|
+
} from '../ui'
|
|
20
28
|
import { DataGridNullFilter } from './common'
|
|
21
29
|
import { SelectDefaultFilter, SelectListInner, SelectPopoverContent } from '../../select'
|
|
22
30
|
import { dict } from '../../dict'
|
|
23
31
|
import { DataGridFilterMobileHiding } from './mobile'
|
|
32
|
+
import { DataViewHasManyLabel, DataViewHasOneLabel } from '../labels'
|
|
24
33
|
|
|
25
34
|
|
|
26
35
|
type DataGridRelationFilterInnerProps = {
|
|
@@ -35,7 +44,7 @@ export type DataGridHasOneFilterProps =
|
|
|
35
44
|
export const DataGridHasOneFilter = Component(({ label, children, ...props }: DataGridHasOneFilterProps) => (
|
|
36
45
|
<DataViewHasOneFilter {...props}>
|
|
37
46
|
<DataGridFilterMobileHiding>
|
|
38
|
-
<DataGridRelationFilterInner label={label}>
|
|
47
|
+
<DataGridRelationFilterInner label={label ?? <DataViewHasOneLabel field={props.field} />}>
|
|
39
48
|
{children}
|
|
40
49
|
</DataGridRelationFilterInner>
|
|
41
50
|
</DataGridFilterMobileHiding>
|
|
@@ -50,7 +59,7 @@ export type DataGridHasManyFilterProps =
|
|
|
50
59
|
export const DataGridHasManyFilter = Component(({ label, children, ...props }: DataGridHasManyFilterProps) => (
|
|
51
60
|
<DataViewHasManyFilter {...props} >
|
|
52
61
|
<DataGridFilterMobileHiding>
|
|
53
|
-
<DataGridRelationFilterInner label={label}>
|
|
62
|
+
<DataGridRelationFilterInner label={label ?? <DataViewHasManyLabel field={props.field} />}>
|
|
54
63
|
{children}
|
|
55
64
|
</DataGridRelationFilterInner>
|
|
56
65
|
</DataGridFilterMobileHiding>
|
|
@@ -24,6 +24,7 @@ import { DataGridNullFilter } from './common'
|
|
|
24
24
|
import { dict } from '../../dict'
|
|
25
25
|
import { Component } from '@contember/interface'
|
|
26
26
|
import { DataGridFilterMobileHiding } from './mobile'
|
|
27
|
+
import { DataViewFieldLabel } from '../labels'
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
export type DataGridTextFilterProps =
|
|
@@ -35,7 +36,7 @@ export type DataGridTextFilterProps =
|
|
|
35
36
|
export const DataGridTextFilter = Component(({ label, ...props }: DataGridTextFilterProps) => (
|
|
36
37
|
<DataViewTextFilter {...props}>
|
|
37
38
|
<DataGridFilterMobileHiding>
|
|
38
|
-
<DataGridTextFilterInner label={label} />
|
|
39
|
+
<DataGridTextFilterInner label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
39
40
|
</DataGridFilterMobileHiding>
|
|
40
41
|
</DataViewTextFilter>
|
|
41
42
|
))
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SugaredRelativeEntityList, SugaredRelativeSingleEntity, SugaredRelativeSingleField } from '@contember/interface'
|
|
2
|
+
import { useDataViewTargetFieldSchema, useDataViewTargetHasManySchema, useDataViewTargetHasOneSchema } from '@contember/react-dataview'
|
|
3
|
+
import { useFieldLabelFormatter } from '../labels'
|
|
4
|
+
|
|
5
|
+
export const DataViewFieldLabel = ({ field }: { field: SugaredRelativeSingleField['field'] }) => {
|
|
6
|
+
const { field: targetField, entity } = useDataViewTargetFieldSchema(field)
|
|
7
|
+
const formatter = useFieldLabelFormatter()
|
|
8
|
+
return <>{formatter(entity.name, targetField.name)}</>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export const DataViewHasOneLabel = ({ field }: { field: SugaredRelativeSingleEntity['field'] }) => {
|
|
13
|
+
const { field: targetField, entity } = useDataViewTargetHasOneSchema(field)
|
|
14
|
+
const formatter = useFieldLabelFormatter()
|
|
15
|
+
return <>{formatter(entity.name, targetField.name)}</>
|
|
16
|
+
}
|
|
17
|
+
export const DataViewHasManyLabel = ({ field }: { field: SugaredRelativeEntityList['field'] }) => {
|
|
18
|
+
const { field: targetField, entity } = useDataViewTargetHasManySchema(field)
|
|
19
|
+
const formatter = useFieldLabelFormatter()
|
|
20
|
+
return <>{formatter(entity.name, targetField.name)}</>
|
|
21
|
+
}
|
|
22
|
+
|