@contember/create 2.0.0-alpha.8 → 2.0.0-beta.1
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/dist/development/run.cjs +0 -2
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +0 -2
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +1 -8
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +2 -9
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/version.cjs.map +1 -1
- package/dist/development/src/paths.cjs +3 -1
- package/dist/development/src/paths.cjs.map +1 -1
- package/dist/development/src/paths.js +4 -2
- package/dist/development/src/paths.js.map +1 -1
- package/dist/production/run.cjs +0 -2
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +0 -2
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +1 -8
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +2 -9
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/version.cjs.map +1 -1
- package/dist/production/src/paths.cjs +3 -1
- package/dist/production/src/paths.cjs.map +1 -1
- package/dist/production/src/paths.js +4 -2
- package/dist/production/src/paths.js.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +1 -3
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/paths.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -31
- package/resources/templates/template-workspace/.github/scripts/setup-actions-variables.sh +36 -0
- package/resources/templates/template-workspace/.github/workflows/deploy.yaml +23 -0
- package/resources/templates/template-workspace/admin/lib/binding/binding.tsx +12 -2
- package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +34 -23
- package/resources/templates/template-workspace/admin/lib/binding/hooks.tsx +5 -6
- package/resources/templates/template-workspace/admin/lib/binding/identity.tsx +34 -3
- package/resources/templates/template-workspace/admin/lib/binding/navigation-guard-dialog.tsx +39 -0
- package/resources/templates/template-workspace/admin/lib/binding/persist.tsx +10 -60
- package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +109 -39
- package/resources/templates/template-workspace/admin/lib/buttons/link-back-button.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +90 -10
- package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +12 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/column-leaf.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +367 -36
- package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +6 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/export.tsx +9 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +22 -5
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +25 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/defined.tsx +103 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +83 -27
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +1 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +0 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +21 -5
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +170 -43
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +48 -5
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +97 -25
- package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +30 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/labels.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +44 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +8 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +15 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +27 -2
- package/resources/templates/template-workspace/admin/lib/dict.ts +54 -5
- package/resources/templates/template-workspace/admin/lib/dimensions/dimensions.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-canvas.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/editor/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/editor/rich-text-view.tsx +17 -0
- package/resources/templates/template-workspace/admin/lib/field/formatted-field.tsx +10 -0
- package/resources/templates/template-workspace/admin/lib/field/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/form/container.tsx +43 -45
- package/resources/templates/template-workspace/admin/lib/form/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +56 -23
- package/resources/templates/template-workspace/admin/lib/form/select.tsx +61 -30
- package/resources/templates/template-workspace/admin/lib/form/ui.tsx +11 -2
- package/resources/templates/template-workspace/admin/lib/form/upload-repeaters.tsx +188 -0
- package/resources/templates/template-workspace/admin/lib/form/upload.tsx +57 -242
- package/resources/templates/template-workspace/admin/lib/formatting/formatting.ts +23 -0
- package/resources/templates/template-workspace/admin/lib/labels/enum-labels.ts +9 -0
- package/resources/templates/template-workspace/admin/lib/labels/field-labels.ts +7 -0
- package/resources/templates/template-workspace/admin/lib/labels/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +3 -3
- package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +97 -64
- package/resources/templates/template-workspace/admin/lib/select/filter.tsx +3 -2
- package/resources/templates/template-workspace/admin/lib/select/index.ts +0 -1
- package/resources/templates/template-workspace/admin/lib/select/list.tsx +78 -26
- package/resources/templates/template-workspace/admin/lib/select/multi-select.tsx +12 -19
- package/resources/templates/template-workspace/admin/lib/select/select.tsx +40 -23
- package/resources/templates/template-workspace/admin/lib/select/sortable-select.tsx +23 -18
- package/resources/templates/template-workspace/admin/lib/select/ui.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/invite.tsx +5 -3
- package/resources/templates/template-workspace/admin/lib/tenant/forms/memberships-control.tsx +28 -16
- package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset.tsx +9 -6
- package/resources/templates/template-workspace/admin/lib/tenant/forms/passwordless-signin-init.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/passwordless-signin.tsx +59 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/update-project-member.tsx +5 -3
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInvite.ts +1 -1
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-list.tsx +6 -5
- package/resources/templates/template-workspace/admin/lib/tenant/listing/person-list.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/alert-dialog.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/collapsible.tsx +9 -0
- package/resources/templates/template-workspace/admin/lib/ui/dialog.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/input.tsx +14 -10
- package/resources/templates/template-workspace/admin/lib/ui/menu.tsx +2 -3
- package/resources/templates/template-workspace/admin/lib/ui/popover.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/property-list.tsx +33 -0
- package/resources/templates/template-workspace/admin/lib/ui/select.tsx +80 -0
- package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +3 -2
- package/resources/templates/template-workspace/admin/lib/ui/textarea.tsx +9 -1
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +160 -165
- package/resources/templates/template-workspace/admin/lib/utils/createComponentOpenHooks.tsx +38 -0
- package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +3 -3
- package/resources/templates/template-workspace/admin/package.json +21 -20
- package/resources/templates/template-workspace/package.json +3 -3
- package/src/lib/TemplateInstaller.ts +2 -9
- package/src/paths.ts +4 -3
- package/src/run.ts +0 -2
- package/tsconfig.settings.json +0 -4
- package/dist/development/src/lib/PackageDownloader.cjs +0 -33
- package/dist/development/src/lib/PackageDownloader.cjs.map +0 -1
- package/dist/development/src/lib/PackageDownloader.js +0 -33
- package/dist/development/src/lib/PackageDownloader.js.map +0 -1
- package/dist/production/src/lib/PackageDownloader.cjs +0 -33
- package/dist/production/src/lib/PackageDownloader.cjs.map +0 -1
- package/dist/production/src/lib/PackageDownloader.js +0 -33
- package/dist/production/src/lib/PackageDownloader.js.map +0 -1
- package/dist/types/lib/PackageDownloader.d.ts +0 -7
- package/dist/types/lib/PackageDownloader.d.ts.map +0 -1
- package/resources/templates/template-workspace/admin/.env.production +0 -3
- package/resources/templates/template-workspace/admin/lib/select/pagination.tsx +0 -48
- package/src/lib/PackageDownloader.ts +0 -33
- package/types/download-tarball/index.d.ts +0 -7
- package/types/get-package-json-from-registry/index.d.ts +0 -3
- package/types/registry-info/index.d.ts +0 -7
|
@@ -10,22 +10,39 @@ import {
|
|
|
10
10
|
DataViewEnumFilter,
|
|
11
11
|
DataViewHasManyFilter,
|
|
12
12
|
DataViewHasOneFilter,
|
|
13
|
+
DataViewIsDefinedFilter,
|
|
13
14
|
DataViewNumberFilter,
|
|
14
15
|
DataViewTextFilter,
|
|
15
16
|
} from '@contember/react-dataview'
|
|
16
17
|
import { formatBoolean, formatDate, formatDateTime, formatNumber } from '../formatting'
|
|
17
|
-
import { DataGridEnumCell, DataGridHasManyCell,
|
|
18
|
+
import { DataGridEnumCell, DataGridHasManyCell, DataGridHasOneCell } from './cells'
|
|
18
19
|
import { cn } from '../utils'
|
|
19
20
|
import {
|
|
20
21
|
DataGridBooleanFilterControls,
|
|
21
22
|
DataGridDateFilterControls,
|
|
22
23
|
DataGridEnumFilterControls,
|
|
24
|
+
DataGridIsDefinedFilterControls,
|
|
23
25
|
DataGridNumberFilterControls,
|
|
24
26
|
DataGridRelationFilterControls,
|
|
25
27
|
DataGridRelationFilteredItemsList,
|
|
26
28
|
DataGridTextFilterInner,
|
|
27
29
|
} from './filters'
|
|
30
|
+
import { CheckIcon, XIcon } from 'lucide-react'
|
|
31
|
+
import { DataViewFieldLabel, DataViewHasManyLabel, DataViewHasOneLabel } from './labels'
|
|
32
|
+
import { DataGridColumnLeaf } from './column-leaf'
|
|
28
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Renders a column with action buttons. Should be used in a {@link DataGridTable}.
|
|
36
|
+
*
|
|
37
|
+
* ## Example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <DataGridTable>
|
|
40
|
+
* <DataGridActionColumn>
|
|
41
|
+
* <Button>Click me</Button>
|
|
42
|
+
* </DataGridActionColumn>
|
|
43
|
+
* </DataGridTable>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
29
46
|
export const DataGridActionColumn = Component<{ children: ReactNode }>(({ children }) => (
|
|
30
47
|
<DataGridColumnLeaf
|
|
31
48
|
header={<TableHead className="w-0"></TableHead>}
|
|
@@ -33,18 +50,50 @@ export const DataGridActionColumn = Component<{ children: ReactNode }>(({ childr
|
|
|
33
50
|
/>
|
|
34
51
|
))
|
|
35
52
|
|
|
36
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Props for {@link DataGridTextColumn}.
|
|
55
|
+
*/
|
|
37
56
|
export type DataGridTextColumnProps = {
|
|
57
|
+
/**
|
|
58
|
+
* Displayed field.
|
|
59
|
+
*/
|
|
38
60
|
field: string
|
|
39
|
-
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Custom header. If not provided, the label formatter is used.
|
|
64
|
+
*/
|
|
65
|
+
header?: ReactNode
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Custom cell content. If not provided, the field value is displayed.
|
|
69
|
+
*/
|
|
40
70
|
children?: ReactNode
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Custom value formatter.
|
|
74
|
+
*/
|
|
41
75
|
format?: (value: string | null) => ReactNode
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Custom filter. If not provided, a default text filter is used.
|
|
79
|
+
*/
|
|
42
80
|
filter?: ReactNode
|
|
43
81
|
}
|
|
44
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Renders a column with text content and column controls in a header. Should be used in a {@link DataGridTable}.
|
|
85
|
+
*
|
|
86
|
+
* ## Example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* <DataGridTable>
|
|
89
|
+
* <DataGridTextColumn field="title" />
|
|
90
|
+
* <DataGridTextColumn field="description" format={it => it.slice(0, 100)} />
|
|
91
|
+
* </DataGridTable>
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
45
94
|
export const DataGridTextColumn = Component<DataGridTextColumnProps>(({ field, header, children, format, filter }) => (
|
|
46
95
|
<DataGridColumn
|
|
47
|
-
header={header}
|
|
96
|
+
header={header ?? <DataViewFieldLabel field={field}/>}
|
|
48
97
|
sortingField={field}
|
|
49
98
|
name={field}
|
|
50
99
|
children={children ?? <Field field={field} format={format} />}
|
|
@@ -55,17 +104,45 @@ export const DataGridTextColumn = Component<DataGridTextColumnProps>(({ field, h
|
|
|
55
104
|
/>
|
|
56
105
|
))
|
|
57
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Props for {@link DataGridBooleanColumn}.
|
|
109
|
+
*/
|
|
58
110
|
export type DataGridBooleanColumnProps = {
|
|
111
|
+
/**
|
|
112
|
+
* Displayed field.
|
|
113
|
+
*/
|
|
59
114
|
field: string
|
|
60
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Custom header. If not provided, the label formatter is used.
|
|
117
|
+
*/
|
|
118
|
+
header?: ReactNode
|
|
119
|
+
/**
|
|
120
|
+
* Custom cell content. If not provided, the field value is displayed.
|
|
121
|
+
*/
|
|
61
122
|
children?: ReactNode
|
|
123
|
+
/**
|
|
124
|
+
* Custom value formatter.
|
|
125
|
+
*/
|
|
62
126
|
format?: (value: boolean | null) => ReactNode
|
|
127
|
+
/**
|
|
128
|
+
* Custom filter. If not provided, a default boolean filter is used.
|
|
129
|
+
*/
|
|
63
130
|
filter?: ReactNode
|
|
64
131
|
}
|
|
65
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Renders a column with boolean content. Should be used in a {@link DataGridTable}.
|
|
135
|
+
*
|
|
136
|
+
* ## Example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* <DataGridTable>
|
|
139
|
+
* <DataGridBooleanColumn field="isPublished" />
|
|
140
|
+
* </DataGridTable>
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
66
143
|
export const DataGridBooleanColumn = Component<DataGridBooleanColumnProps>(({ field, header, children, format, filter }) => (
|
|
67
144
|
<DataGridColumn
|
|
68
|
-
header={header}
|
|
145
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
69
146
|
sortingField={field}
|
|
70
147
|
name={field}
|
|
71
148
|
children={children ?? <Field field={field} format={format ?? formatBoolean} />}
|
|
@@ -78,17 +155,45 @@ export const DataGridBooleanColumn = Component<DataGridBooleanColumnProps>(({ fi
|
|
|
78
155
|
/>
|
|
79
156
|
))
|
|
80
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Props for {@link DataGridNumberColumn}.
|
|
160
|
+
*/
|
|
81
161
|
export type DataGridNumberColumnProps = {
|
|
162
|
+
/**
|
|
163
|
+
* Displayed field.
|
|
164
|
+
*/
|
|
82
165
|
field: string
|
|
83
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Custom header. If not provided, the label formatter is used.
|
|
168
|
+
*/
|
|
169
|
+
header?: ReactNode
|
|
170
|
+
/**
|
|
171
|
+
* Custom cell content. If not provided, the field value is displayed.
|
|
172
|
+
*/
|
|
84
173
|
children?: ReactNode
|
|
174
|
+
/**
|
|
175
|
+
* Custom value formatter.
|
|
176
|
+
*/
|
|
85
177
|
format?: (value: number | null) => ReactNode
|
|
178
|
+
/**
|
|
179
|
+
* Custom filter. If not provided, a default number filter is used.
|
|
180
|
+
*/
|
|
86
181
|
filter?: ReactNode
|
|
87
182
|
}
|
|
88
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Renders a column with number content. Should be used in a {@link DataGridTable}.
|
|
186
|
+
*
|
|
187
|
+
* ## Example
|
|
188
|
+
* ```tsx
|
|
189
|
+
* <DataGridTable>
|
|
190
|
+
* <DataGridNumberColumn field="price" format={it => it.toFixed(2)} />
|
|
191
|
+
* </DataGridTable>
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
89
194
|
export const DataGridNumberColumn = Component<DataGridNumberColumnProps>(({ field, header, children, format, filter }) => (
|
|
90
195
|
<DataGridColumn
|
|
91
|
-
header={header}
|
|
196
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
92
197
|
sortingField={field}
|
|
93
198
|
name={field}
|
|
94
199
|
children={children ?? <Field field={field} format={format ?? formatNumber} />}
|
|
@@ -100,18 +205,45 @@ export const DataGridNumberColumn = Component<DataGridNumberColumnProps>(({ fiel
|
|
|
100
205
|
</DataViewNumberFilter>}
|
|
101
206
|
/>
|
|
102
207
|
))
|
|
103
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Props for {@link DataGridDateColumn}.
|
|
210
|
+
*/
|
|
104
211
|
export type DataGridDateColumnProps = {
|
|
212
|
+
/**
|
|
213
|
+
* Displayed field.
|
|
214
|
+
*/
|
|
105
215
|
field: string
|
|
106
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Custom header. If not provided, the label formatter is used.
|
|
218
|
+
*/
|
|
219
|
+
header?: ReactNode
|
|
220
|
+
/**
|
|
221
|
+
* Custom cell content. If not provided, the field value is displayed.
|
|
222
|
+
*/
|
|
107
223
|
children?: ReactNode
|
|
224
|
+
/**
|
|
225
|
+
* Custom value formatter. If not provided, the default date formatter is used.
|
|
226
|
+
*/
|
|
108
227
|
format?: (value: string | null) => ReactNode
|
|
228
|
+
/**
|
|
229
|
+
* Custom filter. If not provided, a default date filter is used.
|
|
230
|
+
*/
|
|
109
231
|
filter?: ReactNode
|
|
110
232
|
}
|
|
111
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Renders a column with date content. Should be used in a {@link DataGridTable}.
|
|
236
|
+
*
|
|
237
|
+
* ## Example
|
|
238
|
+
* ```tsx
|
|
239
|
+
* <DataGridTable>
|
|
240
|
+
* <DataGridDateColumn field="createdAt" />
|
|
241
|
+
* </DataGridTable>
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
112
244
|
export const DataGridDateColumn = Component<DataGridDateColumnProps>(({ field, header, children, format, filter }) => (
|
|
113
245
|
<DataGridColumn
|
|
114
|
-
header={header}
|
|
246
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
115
247
|
sortingField={field}
|
|
116
248
|
name={field}
|
|
117
249
|
children={children ?? <Field field={field} format={format ?? formatDate} />}
|
|
@@ -124,18 +256,45 @@ export const DataGridDateColumn = Component<DataGridDateColumnProps>(({ field, h
|
|
|
124
256
|
/>
|
|
125
257
|
))
|
|
126
258
|
|
|
127
|
-
|
|
259
|
+
/**
|
|
260
|
+
* Props for {@link DataGridDateTimeColumn}.
|
|
261
|
+
*/
|
|
128
262
|
export type DataGridDateTimeColumnProps = {
|
|
263
|
+
/**
|
|
264
|
+
* Displayed field.
|
|
265
|
+
*/
|
|
129
266
|
field: string
|
|
130
|
-
|
|
267
|
+
/**
|
|
268
|
+
* Custom header. If not provided, the label formatter is used.
|
|
269
|
+
*/
|
|
270
|
+
header?: ReactNode
|
|
271
|
+
/**
|
|
272
|
+
* Custom cell content. If not provided, the field value is displayed.
|
|
273
|
+
*/
|
|
131
274
|
children?: ReactNode
|
|
275
|
+
/**
|
|
276
|
+
* Custom value formatter. If not provided, the default date-time formatter is used.
|
|
277
|
+
*/
|
|
132
278
|
format?: (value: string | null) => ReactNode
|
|
279
|
+
/**
|
|
280
|
+
* Custom filter. If not provided, a default date filter is used.
|
|
281
|
+
*/
|
|
133
282
|
filter?: ReactNode
|
|
134
283
|
}
|
|
135
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Renders a column with date-time content. Should be used in a {@link DataGridTable}.
|
|
287
|
+
*
|
|
288
|
+
* ## Example
|
|
289
|
+
* ```tsx
|
|
290
|
+
* <DataGridTable>
|
|
291
|
+
* <DataGridDateTimeColumn field="createdAt" />
|
|
292
|
+
* </DataGridTable>
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
136
295
|
export const DataGridDateTimeColumn = Component<DataGridDateTimeColumnProps>(({ field, header, children, format, filter }) => (
|
|
137
296
|
<DataGridColumn
|
|
138
|
-
header={header}
|
|
297
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
139
298
|
sortingField={field}
|
|
140
299
|
name={field}
|
|
141
300
|
children={children ?? <Field field={field} format={format ?? formatDateTime} />}
|
|
@@ -149,18 +308,56 @@ export const DataGridDateTimeColumn = Component<DataGridDateTimeColumnProps>(({
|
|
|
149
308
|
/>
|
|
150
309
|
))
|
|
151
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Props for {@link DataGridEnumColumn}.
|
|
313
|
+
*/
|
|
152
314
|
export type DataGridEnumColumnProps = {
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Displayed field.
|
|
318
|
+
*/
|
|
153
319
|
field: string
|
|
154
|
-
|
|
155
|
-
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Custom header. If not provided, the label formatter is used.
|
|
323
|
+
*/
|
|
324
|
+
header?: ReactNode
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Enum options for value formatting and filter options. If not provided, the options are resolved from the enum.
|
|
328
|
+
*/
|
|
329
|
+
options?: Record<string, ReactNode>
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Custom cell content. If not provided, the field value with a tooltip is displayed.
|
|
333
|
+
*/
|
|
156
334
|
children?: ReactNode
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Custom filter. If not provided, a default enum filter is used.
|
|
338
|
+
*/
|
|
157
339
|
filter?: ReactNode
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Additional actions in the tooltip.
|
|
343
|
+
*/
|
|
158
344
|
tooltipActions?: ReactNode
|
|
159
345
|
}
|
|
160
346
|
|
|
347
|
+
/**
|
|
348
|
+
* Renders a column with enum content. Should be used in a {@link DataGridTable}.
|
|
349
|
+
*
|
|
350
|
+
* ## Example
|
|
351
|
+
* ```tsx
|
|
352
|
+
* <DataGridTable>
|
|
353
|
+
* <DataGridEnumColumn field="status" />
|
|
354
|
+
* <DataGridEnumColumn field="status" options={{ active: 'Active', inactive: 'Inactive' }} />
|
|
355
|
+
* </DataGridTable>
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
161
358
|
export const DataGridEnumColumn = Component<DataGridEnumColumnProps>(({ field, header, options, children, tooltipActions, filter }) => (<>
|
|
162
359
|
<DataGridColumn
|
|
163
|
-
header={header}
|
|
360
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
164
361
|
sortingField={field}
|
|
165
362
|
name={field}
|
|
166
363
|
children={children ?? <DataGridEnumCell field={field} options={options} tooltipActions={tooltipActions} />}
|
|
@@ -173,35 +370,143 @@ export const DataGridEnumColumn = Component<DataGridEnumColumnProps>(({ field, h
|
|
|
173
370
|
/>
|
|
174
371
|
</>))
|
|
175
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Props for {@link DataGridIsDefinedColumn}.
|
|
375
|
+
*/
|
|
376
|
+
export type DataGridIsDefinedColumnProps = {
|
|
377
|
+
/**
|
|
378
|
+
* Displayed field.
|
|
379
|
+
*/
|
|
380
|
+
field: string
|
|
381
|
+
/**
|
|
382
|
+
* Custom header. If not provided, the label formatter is used.
|
|
383
|
+
*/
|
|
384
|
+
header?: ReactNode
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Custom cell content. If not provided, a checkmark or a cross is displayed.
|
|
388
|
+
*/
|
|
389
|
+
children?: ReactNode
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Custom value formatter.
|
|
393
|
+
*/
|
|
394
|
+
format?: (value: boolean) => ReactNode
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Custom filter. If not provided, a default is-defined filter is used.
|
|
398
|
+
*/
|
|
399
|
+
filter?: ReactNode
|
|
400
|
+
filterName?: string
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Renders a column with is-defined content. Should be used in a {@link DataGridTable}.
|
|
405
|
+
*
|
|
406
|
+
* ## Example
|
|
407
|
+
* ```tsx
|
|
408
|
+
* <DataGridTable>
|
|
409
|
+
* <DataGridIsDefinedColumn field="coverImage.url" />
|
|
410
|
+
* </DataGridTable>
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
export const DataGridIsDefinedColumn = Component<DataGridIsDefinedColumnProps>(({ field, header, children, format, filter, filterName }) => (
|
|
414
|
+
<DataGridColumn
|
|
415
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
416
|
+
name={field}
|
|
417
|
+
children={children ?? <Field field={field} format={it => {
|
|
418
|
+
if (format) {
|
|
419
|
+
return format(it !== null)
|
|
420
|
+
}
|
|
421
|
+
return it !== null ? <CheckIcon size={16} /> : <XIcon size={16} />
|
|
422
|
+
}} />}
|
|
423
|
+
filterName={filterName ?? field}
|
|
424
|
+
filter={filter ?? <DataViewIsDefinedFilter field={field} name={filterName}>
|
|
425
|
+
<DataGridIsDefinedFilterControls />
|
|
426
|
+
</DataViewIsDefinedFilter>}
|
|
427
|
+
/>
|
|
428
|
+
))
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Props for {@link DataGridUuidColumn}.
|
|
432
|
+
*/
|
|
176
433
|
export type DataGridUuidColumnProps = {
|
|
434
|
+
/**
|
|
435
|
+
* Displayed field.
|
|
436
|
+
*/
|
|
177
437
|
field: string
|
|
178
|
-
|
|
438
|
+
/**
|
|
439
|
+
* Custom header. If not provided, the label formatter is used.
|
|
440
|
+
*/
|
|
441
|
+
header?: ReactNode
|
|
442
|
+
/**
|
|
443
|
+
* Custom cell content. If not provided, the field value is displayed.
|
|
444
|
+
*/
|
|
179
445
|
children?: ReactNode
|
|
446
|
+
/**
|
|
447
|
+
* Custom value formatter.
|
|
448
|
+
*/
|
|
180
449
|
format?: (value: string | null) => ReactNode
|
|
181
450
|
}
|
|
182
451
|
|
|
183
452
|
|
|
453
|
+
/**
|
|
454
|
+
* Renders a column with UUID content. Should be used in a {@link DataGridTable}.
|
|
455
|
+
*/
|
|
184
456
|
export const DataGridUuidColumn = Component<DataGridUuidColumnProps>(({ field, header, children, format }) => (
|
|
185
457
|
<DataGridColumn
|
|
186
|
-
header={header}
|
|
458
|
+
header={header ?? <DataViewFieldLabel field={field} />}
|
|
187
459
|
sortingField={field}
|
|
188
460
|
name={field}
|
|
189
461
|
children={children ?? <Field field={field} format={format} />}
|
|
190
462
|
/>
|
|
191
463
|
))
|
|
192
464
|
|
|
465
|
+
/**
|
|
466
|
+
* Props for {@link DataGridHasOneColumn}.
|
|
467
|
+
*/
|
|
193
468
|
export type DataGridHasOneColumnProps = {
|
|
469
|
+
/**
|
|
470
|
+
* Has-one relation field.
|
|
471
|
+
*/
|
|
194
472
|
field: SugaredRelativeSingleEntity['field']
|
|
473
|
+
/**
|
|
474
|
+
* Filter identifier. If not provided, the filter is resolved from the field name.
|
|
475
|
+
*/
|
|
195
476
|
filterName?: string
|
|
477
|
+
/**
|
|
478
|
+
* Cell content in the context of the has-one relation.
|
|
479
|
+
*/
|
|
196
480
|
children: ReactNode
|
|
197
|
-
|
|
481
|
+
/**
|
|
482
|
+
* Custom header. If not provided, the label formatter is used.
|
|
483
|
+
*/
|
|
484
|
+
header?: ReactNode
|
|
485
|
+
/**
|
|
486
|
+
* Custom filter. If not provided, a default has-one filter is used.
|
|
487
|
+
*/
|
|
198
488
|
filter?: ReactNode
|
|
489
|
+
/**
|
|
490
|
+
* Additional actions in the tooltip.
|
|
491
|
+
*/
|
|
199
492
|
tooltipActions?: ReactNode
|
|
200
493
|
}
|
|
201
494
|
|
|
495
|
+
/**
|
|
496
|
+
* Renders a column with has-one relation content. Should be used in a {@link DataGridTable}.
|
|
497
|
+
*
|
|
498
|
+
* ## Example
|
|
499
|
+
* ```tsx
|
|
500
|
+
* <DataGridTable>
|
|
501
|
+
* <DataGridHasOneColumn field="author">
|
|
502
|
+
* <Field field="name" />
|
|
503
|
+
* </DataGridHasOneColumn>
|
|
504
|
+
* </DataGridTable>
|
|
505
|
+
* ```
|
|
506
|
+
*/
|
|
202
507
|
export const DataGridHasOneColumn = Component<DataGridHasOneColumnProps>(({ field, header, children, filter, filterName, tooltipActions }) => (
|
|
203
508
|
<DataGridColumn
|
|
204
|
-
header={header}
|
|
509
|
+
header={header ?? <DataViewHasOneLabel field={field} />}
|
|
205
510
|
name={typeof field === 'string' ? field : undefined}
|
|
206
511
|
children={<DataGridHasOneCell field={field} filterName={filterName} tooltipActions={tooltipActions}>{children}</DataGridHasOneCell>}
|
|
207
512
|
filterName={filterName ?? (typeof field === 'string' ? field : undefined)}
|
|
@@ -220,18 +525,51 @@ export const DataGridHasOneColumn = Component<DataGridHasOneColumnProps>(({ fiel
|
|
|
220
525
|
/>
|
|
221
526
|
))
|
|
222
527
|
|
|
528
|
+
/**
|
|
529
|
+
* Props for {@link DataGridHasManyColumn}.
|
|
530
|
+
*/
|
|
223
531
|
export type DataGridHasManyColumnProps = {
|
|
532
|
+
/**
|
|
533
|
+
* Has-many relation field.
|
|
534
|
+
*/
|
|
224
535
|
field: SugaredRelativeEntityList['field']
|
|
536
|
+
/**
|
|
537
|
+
* Filter identifier. If not provided, the filter is resolved from the field name.
|
|
538
|
+
*/
|
|
225
539
|
filterName?: string
|
|
540
|
+
/**
|
|
541
|
+
* Cell content in the context of the has-many relation.
|
|
542
|
+
*/
|
|
226
543
|
children: ReactNode
|
|
227
|
-
|
|
544
|
+
/**
|
|
545
|
+
* Custom header. If not provided, the label formatter is used.
|
|
546
|
+
*/
|
|
547
|
+
header?: ReactNode
|
|
548
|
+
/**
|
|
549
|
+
* Custom filter. If not provided, a default has-many filter is used.
|
|
550
|
+
*/
|
|
228
551
|
filter?: ReactNode
|
|
552
|
+
/**
|
|
553
|
+
* Additional actions in the tooltip.
|
|
554
|
+
*/
|
|
229
555
|
tooltipActions?: ReactNode
|
|
230
556
|
}
|
|
231
557
|
|
|
558
|
+
/**
|
|
559
|
+
* Renders a column with has-many relation content. Should be used in a {@link DataGridTable}.
|
|
560
|
+
*
|
|
561
|
+
* ## Example
|
|
562
|
+
* ```tsx
|
|
563
|
+
* <DataGridTable>
|
|
564
|
+
* <DataGridHasManyColumn field="tags">
|
|
565
|
+
* <Field field="name" />
|
|
566
|
+
* </DataGridHasManyColumn>
|
|
567
|
+
* </DataGridTable>
|
|
568
|
+
* ```
|
|
569
|
+
*/
|
|
232
570
|
export const DataGridHasManyColumn = Component<DataGridHasManyColumnProps>(({ field, header, children, filter, filterName, tooltipActions }) => (
|
|
233
571
|
<DataGridColumn
|
|
234
|
-
header={header}
|
|
572
|
+
header={header ?? <DataViewHasManyLabel field={field} />}
|
|
235
573
|
name={typeof field === 'string' ? field : undefined}
|
|
236
574
|
children={<DataGridHasManyCell field={field} filterName={filterName} tooltipActions={tooltipActions}>{children}</DataGridHasManyCell>}
|
|
237
575
|
filterName={filterName ?? (typeof field === 'string' ? field : undefined)}
|
|
@@ -250,6 +588,9 @@ export const DataGridHasManyColumn = Component<DataGridHasManyColumnProps>(({ fi
|
|
|
250
588
|
/>
|
|
251
589
|
))
|
|
252
590
|
|
|
591
|
+
/**
|
|
592
|
+
* Props for {@link DataGridColumn}.
|
|
593
|
+
*/
|
|
253
594
|
export type DataGridColumnProps = {
|
|
254
595
|
children: ReactNode
|
|
255
596
|
header?: ReactNode
|
|
@@ -262,6 +603,9 @@ export type DataGridColumnProps = {
|
|
|
262
603
|
filterName?: string
|
|
263
604
|
}
|
|
264
605
|
|
|
606
|
+
/**
|
|
607
|
+
* Low-level component for rendering a column in a data grid.
|
|
608
|
+
*/
|
|
265
609
|
export const DataGridColumn = Component<DataGridColumnProps>(({ children, header, name, hidingName, sortingField, cellClassName, headerClassName, filter, filterName }) => {
|
|
266
610
|
const wrapIsVisible = (child: ReactNode) => {
|
|
267
611
|
const resolvedName = hidingName ?? name
|
|
@@ -284,16 +628,3 @@ export const DataGridColumn = Component<DataGridColumnProps>(({ children, header
|
|
|
284
628
|
/>
|
|
285
629
|
)
|
|
286
630
|
})
|
|
287
|
-
|
|
288
|
-
export interface DataGridColumnLeafProps {
|
|
289
|
-
header: ReactNode
|
|
290
|
-
cell: ReactNode
|
|
291
|
-
name?: string
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
export const DataGridColumnLeaf = Component<DataGridColumnLeafProps>(() => {
|
|
295
|
-
throw new Error('DataGridColumnLeaf is not supposed to be rendered')
|
|
296
|
-
}, ({ header, cell }) => {
|
|
297
|
-
return <>{header}{cell}</>
|
|
298
|
-
})
|
|
299
|
-
|
|
@@ -5,6 +5,9 @@ import { ReactNode } from 'react'
|
|
|
5
5
|
import { DataViewVisibilityTrigger, useDataViewElements } from '@contember/react-dataview'
|
|
6
6
|
import { ScrollArea } from '../ui/scroll-area'
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Props for {@link DataGridToolbarVisibleElements}.
|
|
10
|
+
*/
|
|
8
11
|
export interface DataGridToolbarVisibleElementsProps {
|
|
9
12
|
elements?: {
|
|
10
13
|
name: string
|
|
@@ -12,6 +15,9 @@ export interface DataGridToolbarVisibleElementsProps {
|
|
|
12
15
|
}[]
|
|
13
16
|
}
|
|
14
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Control for toggling visibility of columns in data grid.
|
|
20
|
+
*/
|
|
15
21
|
export const DataGridToolbarVisibleElements = ({ elements }: DataGridToolbarVisibleElementsProps) => {
|
|
16
22
|
const globalElements = useDataViewElements()
|
|
17
23
|
|
|
@@ -5,6 +5,15 @@ import * as React from 'react'
|
|
|
5
5
|
import { ReactNode, useMemo } from 'react'
|
|
6
6
|
import { dict } from '../dict'
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Button for exporting data grid to CSV.
|
|
10
|
+
* If no fields are provided, all fields will be exported.
|
|
11
|
+
*
|
|
12
|
+
* ## Example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <DataGridExport />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
8
17
|
export const DataGridAutoExport = ({ fields }: { fields?: ReactNode }) => {
|
|
9
18
|
return (
|
|
10
19
|
<DataViewExportTrigger fields={fields}>
|
|
@@ -9,26 +9,40 @@ 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
|
+
* Props for {@link DataGridBooleanFilter}.
|
|
16
|
+
*/
|
|
17
|
+
export type DataGridBooleanFilterProps =
|
|
15
18
|
& Omit<DataViewBooleanFilterProps, 'children'>
|
|
16
19
|
& {
|
|
17
20
|
label: ReactNode
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Boolean filter for DataGrid with default UI.
|
|
25
|
+
*
|
|
26
|
+
* ## Props {@link DataGridBooleanFilterProps}
|
|
27
|
+
* field, label, ?name
|
|
28
|
+
*
|
|
29
|
+
* ## Example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* <DataGridBooleanFilter field={'locked'} label="Locked" />
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
20
34
|
export const DataGridBooleanFilter = Component(({ label, ...props }: DataGridBooleanFilterProps) => (
|
|
21
35
|
<DataViewBooleanFilter {...props}>
|
|
22
36
|
<DataGridFilterMobileHiding>
|
|
23
37
|
<DataGridSingleFilterUI>
|
|
24
|
-
<DataGridBooleanFilterSelect label={label} />
|
|
38
|
+
<DataGridBooleanFilterSelect label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
25
39
|
<DataGridBooleanFilterList />
|
|
26
40
|
</DataGridSingleFilterUI>
|
|
27
41
|
</DataGridFilterMobileHiding>
|
|
28
42
|
</DataViewBooleanFilter>
|
|
29
43
|
))
|
|
30
44
|
|
|
31
|
-
|
|
45
|
+
const DataGridBooleanFilterList = () => (
|
|
32
46
|
<>
|
|
33
47
|
{[true, false].map(value => (
|
|
34
48
|
<DataViewBooleanFilterTrigger action={'unset'} value={value} key={value.toString()}>
|
|
@@ -47,7 +61,7 @@ export const DataGridBooleanFilterList = () => (
|
|
|
47
61
|
)
|
|
48
62
|
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
const DataGridBooleanFilterSelect = ({ label }: {
|
|
51
65
|
label?: ReactNode
|
|
52
66
|
}) => (
|
|
53
67
|
<Popover>
|
|
@@ -60,6 +74,9 @@ export const DataGridBooleanFilterSelect = ({ label }: {
|
|
|
60
74
|
</Popover>
|
|
61
75
|
)
|
|
62
76
|
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
63
80
|
export const DataGridBooleanFilterControls = () => {
|
|
64
81
|
return (
|
|
65
82
|
<div className={'flex flex-col gap-2'}>
|
|
@@ -4,6 +4,9 @@ import { useDataViewFilterName, useDataViewNullFilter } from '@contember/react-d
|
|
|
4
4
|
import { DataGridFilterSelectItemUI } from '../ui'
|
|
5
5
|
import { dict } from '../../dict'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
7
10
|
export const DataGridNullFilter = ({ name }: {
|
|
8
11
|
name?: string
|
|
9
12
|
}) => {
|