@contember/create 2.0.0-alpha.39 → 2.0.0-alpha.40

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.
Files changed (43) hide show
  1. package/dist/development/src/paths.cjs +3 -1
  2. package/dist/development/src/paths.cjs.map +1 -1
  3. package/dist/development/src/paths.js +4 -2
  4. package/dist/development/src/paths.js.map +1 -1
  5. package/dist/production/src/paths.cjs +3 -1
  6. package/dist/production/src/paths.cjs.map +1 -1
  7. package/dist/production/src/paths.js +4 -2
  8. package/dist/production/src/paths.js.map +1 -1
  9. package/dist/types/paths.d.ts.map +1 -1
  10. package/dist/types/tsconfig.tsbuildinfo +1 -1
  11. package/package.json +2 -22
  12. package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +45 -8
  13. package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +66 -0
  14. package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +11 -3
  15. package/resources/templates/template-workspace/admin/lib/datagrid/column-leaf.tsx +21 -0
  16. package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +319 -20
  17. package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +6 -0
  18. package/resources/templates/template-workspace/admin/lib/datagrid/export.tsx +9 -0
  19. package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +20 -4
  20. package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +3 -0
  21. package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +23 -1
  22. package/resources/templates/template-workspace/admin/lib/datagrid/filters/defined.tsx +20 -4
  23. package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +31 -3
  24. package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +0 -1
  25. package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +0 -1
  26. package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +19 -4
  27. package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +116 -16
  28. package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +46 -4
  29. package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +67 -3
  30. package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +30 -4
  31. package/resources/templates/template-workspace/admin/lib/datagrid/labels.tsx +10 -1
  32. package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +3 -0
  33. package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +19 -3
  34. package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +8 -0
  35. package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +15 -1
  36. package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +13 -0
  37. package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +19 -0
  38. package/resources/templates/template-workspace/admin/lib/editor/index.ts +1 -0
  39. package/resources/templates/template-workspace/admin/lib/editor/rich-text-view.tsx +17 -0
  40. package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +82 -60
  41. package/resources/templates/template-workspace/admin/lib/select/list.tsx +1 -2
  42. package/resources/templates/template-workspace/admin/lib/upload/view.tsx +2 -2
  43. package/src/paths.ts +4 -3
@@ -21,15 +21,28 @@ import {
21
21
  DataGridBooleanFilterControls,
22
22
  DataGridDateFilterControls,
23
23
  DataGridEnumFilterControls,
24
+ DataGridIsDefinedFilterControls,
24
25
  DataGridNumberFilterControls,
25
26
  DataGridRelationFilterControls,
26
27
  DataGridRelationFilteredItemsList,
27
28
  DataGridTextFilterInner,
28
29
  } from './filters'
29
30
  import { CheckIcon, XIcon } from 'lucide-react'
30
- import { DataGridIsDefinedFilterControls } from './filters/defined'
31
31
  import { DataViewFieldLabel, DataViewHasManyLabel, DataViewHasOneLabel } from './labels'
32
-
32
+ import { DataGridColumnLeaf } from './column-leaf'
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
+ */
33
46
  export const DataGridActionColumn = Component<{ children: ReactNode }>(({ children }) => (
34
47
  <DataGridColumnLeaf
35
48
  header={<TableHead className="w-0"></TableHead>}
@@ -37,15 +50,47 @@ export const DataGridActionColumn = Component<{ children: ReactNode }>(({ childr
37
50
  />
38
51
  ))
39
52
 
40
-
53
+ /**
54
+ * Props for {@link DataGridTextColumn}.
55
+ */
41
56
  export type DataGridTextColumnProps = {
57
+ /**
58
+ * Displayed field.
59
+ */
42
60
  field: string
61
+
62
+ /**
63
+ * Custom header. If not provided, the label formatter is used.
64
+ */
43
65
  header?: ReactNode
66
+
67
+ /**
68
+ * Custom cell content. If not provided, the field value is displayed.
69
+ */
44
70
  children?: ReactNode
71
+
72
+ /**
73
+ * Custom value formatter.
74
+ */
45
75
  format?: (value: string | null) => ReactNode
76
+
77
+ /**
78
+ * Custom filter. If not provided, a default text filter is used.
79
+ */
46
80
  filter?: ReactNode
47
81
  }
48
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
+ */
49
94
  export const DataGridTextColumn = Component<DataGridTextColumnProps>(({ field, header, children, format, filter }) => (
50
95
  <DataGridColumn
51
96
  header={header ?? <DataViewFieldLabel field={field}/>}
@@ -59,14 +104,42 @@ export const DataGridTextColumn = Component<DataGridTextColumnProps>(({ field, h
59
104
  />
60
105
  ))
61
106
 
107
+ /**
108
+ * Props for {@link DataGridBooleanColumn}.
109
+ */
62
110
  export type DataGridBooleanColumnProps = {
111
+ /**
112
+ * Displayed field.
113
+ */
63
114
  field: string
115
+ /**
116
+ * Custom header. If not provided, the label formatter is used.
117
+ */
64
118
  header?: ReactNode
119
+ /**
120
+ * Custom cell content. If not provided, the field value is displayed.
121
+ */
65
122
  children?: ReactNode
123
+ /**
124
+ * Custom value formatter.
125
+ */
66
126
  format?: (value: boolean | null) => ReactNode
127
+ /**
128
+ * Custom filter. If not provided, a default boolean filter is used.
129
+ */
67
130
  filter?: ReactNode
68
131
  }
69
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
+ */
70
143
  export const DataGridBooleanColumn = Component<DataGridBooleanColumnProps>(({ field, header, children, format, filter }) => (
71
144
  <DataGridColumn
72
145
  header={header ?? <DataViewFieldLabel field={field} />}
@@ -82,14 +155,42 @@ export const DataGridBooleanColumn = Component<DataGridBooleanColumnProps>(({ fi
82
155
  />
83
156
  ))
84
157
 
158
+ /**
159
+ * Props for {@link DataGridNumberColumn}.
160
+ */
85
161
  export type DataGridNumberColumnProps = {
162
+ /**
163
+ * Displayed field.
164
+ */
86
165
  field: string
166
+ /**
167
+ * Custom header. If not provided, the label formatter is used.
168
+ */
87
169
  header?: ReactNode
170
+ /**
171
+ * Custom cell content. If not provided, the field value is displayed.
172
+ */
88
173
  children?: ReactNode
174
+ /**
175
+ * Custom value formatter.
176
+ */
89
177
  format?: (value: number | null) => ReactNode
178
+ /**
179
+ * Custom filter. If not provided, a default number filter is used.
180
+ */
90
181
  filter?: ReactNode
91
182
  }
92
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
+ */
93
194
  export const DataGridNumberColumn = Component<DataGridNumberColumnProps>(({ field, header, children, format, filter }) => (
94
195
  <DataGridColumn
95
196
  header={header ?? <DataViewFieldLabel field={field} />}
@@ -104,15 +205,42 @@ export const DataGridNumberColumn = Component<DataGridNumberColumnProps>(({ fiel
104
205
  </DataViewNumberFilter>}
105
206
  />
106
207
  ))
107
-
208
+ /**
209
+ * Props for {@link DataGridDateColumn}.
210
+ */
108
211
  export type DataGridDateColumnProps = {
212
+ /**
213
+ * Displayed field.
214
+ */
109
215
  field: string
216
+ /**
217
+ * Custom header. If not provided, the label formatter is used.
218
+ */
110
219
  header?: ReactNode
220
+ /**
221
+ * Custom cell content. If not provided, the field value is displayed.
222
+ */
111
223
  children?: ReactNode
224
+ /**
225
+ * Custom value formatter. If not provided, the default date formatter is used.
226
+ */
112
227
  format?: (value: string | null) => ReactNode
228
+ /**
229
+ * Custom filter. If not provided, a default date filter is used.
230
+ */
113
231
  filter?: ReactNode
114
232
  }
115
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
+ */
116
244
  export const DataGridDateColumn = Component<DataGridDateColumnProps>(({ field, header, children, format, filter }) => (
117
245
  <DataGridColumn
118
246
  header={header ?? <DataViewFieldLabel field={field} />}
@@ -128,15 +256,42 @@ export const DataGridDateColumn = Component<DataGridDateColumnProps>(({ field, h
128
256
  />
129
257
  ))
130
258
 
131
-
259
+ /**
260
+ * Props for {@link DataGridDateTimeColumn}.
261
+ */
132
262
  export type DataGridDateTimeColumnProps = {
263
+ /**
264
+ * Displayed field.
265
+ */
133
266
  field: string
267
+ /**
268
+ * Custom header. If not provided, the label formatter is used.
269
+ */
134
270
  header?: ReactNode
271
+ /**
272
+ * Custom cell content. If not provided, the field value is displayed.
273
+ */
135
274
  children?: ReactNode
275
+ /**
276
+ * Custom value formatter. If not provided, the default date-time formatter is used.
277
+ */
136
278
  format?: (value: string | null) => ReactNode
279
+ /**
280
+ * Custom filter. If not provided, a default date filter is used.
281
+ */
137
282
  filter?: ReactNode
138
283
  }
139
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
+ */
140
295
  export const DataGridDateTimeColumn = Component<DataGridDateTimeColumnProps>(({ field, header, children, format, filter }) => (
141
296
  <DataGridColumn
142
297
  header={header ?? <DataViewFieldLabel field={field} />}
@@ -153,15 +308,53 @@ export const DataGridDateTimeColumn = Component<DataGridDateTimeColumnProps>(({
153
308
  />
154
309
  ))
155
310
 
311
+ /**
312
+ * Props for {@link DataGridEnumColumn}.
313
+ */
156
314
  export type DataGridEnumColumnProps = {
315
+
316
+ /**
317
+ * Displayed field.
318
+ */
157
319
  field: string
320
+
321
+ /**
322
+ * Custom header. If not provided, the label formatter is used.
323
+ */
158
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
+ */
159
329
  options?: Record<string, ReactNode>
330
+
331
+ /**
332
+ * Custom cell content. If not provided, the field value with a tooltip is displayed.
333
+ */
160
334
  children?: ReactNode
335
+
336
+ /**
337
+ * Custom filter. If not provided, a default enum filter is used.
338
+ */
161
339
  filter?: ReactNode
340
+
341
+ /**
342
+ * Additional actions in the tooltip.
343
+ */
162
344
  tooltipActions?: ReactNode
163
345
  }
164
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
+ */
165
358
  export const DataGridEnumColumn = Component<DataGridEnumColumnProps>(({ field, header, options, children, tooltipActions, filter }) => (<>
166
359
  <DataGridColumn
167
360
  header={header ?? <DataViewFieldLabel field={field} />}
@@ -177,16 +370,46 @@ export const DataGridEnumColumn = Component<DataGridEnumColumnProps>(({ field, h
177
370
  />
178
371
  </>))
179
372
 
180
-
373
+ /**
374
+ * Props for {@link DataGridIsDefinedColumn}.
375
+ */
181
376
  export type DataGridIsDefinedColumnProps = {
377
+ /**
378
+ * Displayed field.
379
+ */
182
380
  field: string
381
+ /**
382
+ * Custom header. If not provided, the label formatter is used.
383
+ */
183
384
  header?: ReactNode
385
+
386
+ /**
387
+ * Custom cell content. If not provided, a checkmark or a cross is displayed.
388
+ */
184
389
  children?: ReactNode
390
+
391
+ /**
392
+ * Custom value formatter.
393
+ */
185
394
  format?: (value: boolean) => ReactNode
395
+
396
+ /**
397
+ * Custom filter. If not provided, a default is-defined filter is used.
398
+ */
186
399
  filter?: ReactNode
187
400
  filterName?: string
188
401
  }
189
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
+ */
190
413
  export const DataGridIsDefinedColumn = Component<DataGridIsDefinedColumnProps>(({ field, header, children, format, filter, filterName }) => (
191
414
  <DataGridColumn
192
415
  header={header ?? <DataViewFieldLabel field={field} />}
@@ -204,15 +427,32 @@ export const DataGridIsDefinedColumn = Component<DataGridIsDefinedColumnProps>((
204
427
  />
205
428
  ))
206
429
 
207
-
430
+ /**
431
+ * Props for {@link DataGridUuidColumn}.
432
+ */
208
433
  export type DataGridUuidColumnProps = {
434
+ /**
435
+ * Displayed field.
436
+ */
209
437
  field: string
438
+ /**
439
+ * Custom header. If not provided, the label formatter is used.
440
+ */
210
441
  header?: ReactNode
442
+ /**
443
+ * Custom cell content. If not provided, the field value is displayed.
444
+ */
211
445
  children?: ReactNode
446
+ /**
447
+ * Custom value formatter.
448
+ */
212
449
  format?: (value: string | null) => ReactNode
213
450
  }
214
451
 
215
452
 
453
+ /**
454
+ * Renders a column with UUID content. Should be used in a {@link DataGridTable}.
455
+ */
216
456
  export const DataGridUuidColumn = Component<DataGridUuidColumnProps>(({ field, header, children, format }) => (
217
457
  <DataGridColumn
218
458
  header={header ?? <DataViewFieldLabel field={field} />}
@@ -222,15 +462,48 @@ export const DataGridUuidColumn = Component<DataGridUuidColumnProps>(({ field, h
222
462
  />
223
463
  ))
224
464
 
465
+ /**
466
+ * Props for {@link DataGridHasOneColumn}.
467
+ */
225
468
  export type DataGridHasOneColumnProps = {
469
+ /**
470
+ * Has-one relation field.
471
+ */
226
472
  field: SugaredRelativeSingleEntity['field']
473
+ /**
474
+ * Filter identifier. If not provided, the filter is resolved from the field name.
475
+ */
227
476
  filterName?: string
477
+ /**
478
+ * Cell content in the context of the has-one relation.
479
+ */
228
480
  children: ReactNode
481
+ /**
482
+ * Custom header. If not provided, the label formatter is used.
483
+ */
229
484
  header?: ReactNode
485
+ /**
486
+ * Custom filter. If not provided, a default has-one filter is used.
487
+ */
230
488
  filter?: ReactNode
489
+ /**
490
+ * Additional actions in the tooltip.
491
+ */
231
492
  tooltipActions?: ReactNode
232
493
  }
233
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
+ */
234
507
  export const DataGridHasOneColumn = Component<DataGridHasOneColumnProps>(({ field, header, children, filter, filterName, tooltipActions }) => (
235
508
  <DataGridColumn
236
509
  header={header ?? <DataViewHasOneLabel field={field} />}
@@ -252,15 +525,48 @@ export const DataGridHasOneColumn = Component<DataGridHasOneColumnProps>(({ fiel
252
525
  />
253
526
  ))
254
527
 
528
+ /**
529
+ * Props for {@link DataGridHasManyColumn}.
530
+ */
255
531
  export type DataGridHasManyColumnProps = {
532
+ /**
533
+ * Has-many relation field.
534
+ */
256
535
  field: SugaredRelativeEntityList['field']
536
+ /**
537
+ * Filter identifier. If not provided, the filter is resolved from the field name.
538
+ */
257
539
  filterName?: string
540
+ /**
541
+ * Cell content in the context of the has-many relation.
542
+ */
258
543
  children: ReactNode
544
+ /**
545
+ * Custom header. If not provided, the label formatter is used.
546
+ */
259
547
  header?: ReactNode
548
+ /**
549
+ * Custom filter. If not provided, a default has-many filter is used.
550
+ */
260
551
  filter?: ReactNode
552
+ /**
553
+ * Additional actions in the tooltip.
554
+ */
261
555
  tooltipActions?: ReactNode
262
556
  }
263
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
+ */
264
570
  export const DataGridHasManyColumn = Component<DataGridHasManyColumnProps>(({ field, header, children, filter, filterName, tooltipActions }) => (
265
571
  <DataGridColumn
266
572
  header={header ?? <DataViewHasManyLabel field={field} />}
@@ -282,6 +588,9 @@ export const DataGridHasManyColumn = Component<DataGridHasManyColumnProps>(({ fi
282
588
  />
283
589
  ))
284
590
 
591
+ /**
592
+ * Props for {@link DataGridColumn}.
593
+ */
285
594
  export type DataGridColumnProps = {
286
595
  children: ReactNode
287
596
  header?: ReactNode
@@ -294,6 +603,9 @@ export type DataGridColumnProps = {
294
603
  filterName?: string
295
604
  }
296
605
 
606
+ /**
607
+ * Low-level component for rendering a column in a data grid.
608
+ */
297
609
  export const DataGridColumn = Component<DataGridColumnProps>(({ children, header, name, hidingName, sortingField, cellClassName, headerClassName, filter, filterName }) => {
298
610
  const wrapIsVisible = (child: ReactNode) => {
299
611
  const resolvedName = hidingName ?? name
@@ -316,16 +628,3 @@ export const DataGridColumn = Component<DataGridColumnProps>(({ children, header
316
628
  />
317
629
  )
318
630
  })
319
-
320
- export interface DataGridColumnLeafProps {
321
- header?: ReactNode
322
- cell: ReactNode
323
- name?: string
324
- }
325
-
326
- export const DataGridColumnLeaf = Component<DataGridColumnLeafProps>(() => {
327
- throw new Error('DataGridColumnLeaf is not supposed to be rendered')
328
- }, ({ header, cell }) => {
329
- return <>{header}{cell}</>
330
- })
331
-
@@ -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}>
@@ -11,13 +11,26 @@ import { Component } from '@contember/interface'
11
11
  import { DataGridFilterMobileHiding } from './mobile'
12
12
  import { DataViewFieldLabel } from '../labels'
13
13
 
14
-
15
- type DataGridBooleanFilterProps =
14
+ /**
15
+ * Props for {@link DataGridBooleanFilter}.
16
+ */
17
+ export type DataGridBooleanFilterProps =
16
18
  & Omit<DataViewBooleanFilterProps, 'children'>
17
19
  & {
18
20
  label: ReactNode
19
21
  }
20
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
+ */
21
34
  export const DataGridBooleanFilter = Component(({ label, ...props }: DataGridBooleanFilterProps) => (
22
35
  <DataViewBooleanFilter {...props}>
23
36
  <DataGridFilterMobileHiding>
@@ -29,7 +42,7 @@ export const DataGridBooleanFilter = Component(({ label, ...props }: DataGridBoo
29
42
  </DataViewBooleanFilter>
30
43
  ))
31
44
 
32
- export const DataGridBooleanFilterList = () => (
45
+ const DataGridBooleanFilterList = () => (
33
46
  <>
34
47
  {[true, false].map(value => (
35
48
  <DataViewBooleanFilterTrigger action={'unset'} value={value} key={value.toString()}>
@@ -48,7 +61,7 @@ export const DataGridBooleanFilterList = () => (
48
61
  )
49
62
 
50
63
 
51
- export const DataGridBooleanFilterSelect = ({ label }: {
64
+ const DataGridBooleanFilterSelect = ({ label }: {
52
65
  label?: ReactNode
53
66
  }) => (
54
67
  <Popover>
@@ -61,6 +74,9 @@ export const DataGridBooleanFilterSelect = ({ label }: {
61
74
  </Popover>
62
75
  )
63
76
 
77
+ /**
78
+ * @internal
79
+ */
64
80
  export const DataGridBooleanFilterControls = () => {
65
81
  return (
66
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
  }) => {
@@ -14,6 +14,11 @@ import { Label } from '../../ui/label'
14
14
  import { XIcon } from 'lucide-react'
15
15
  import { DataViewFieldLabel } from '../labels'
16
16
 
17
+ export type DataGridPredefinedDateRange = { start: string; end: string; label: ReactNode }
18
+
19
+ /**
20
+ * Props for {@link DataGridDateFilter}.
21
+ */
17
22
  export type DataGridDateFilterProps =
18
23
  & Omit<DataViewDateFilterProps, 'children'>
19
24
  & {
@@ -21,6 +26,17 @@ export type DataGridDateFilterProps =
21
26
  ranges?: DataGridPredefinedDateRange[]
22
27
  }
23
28
 
29
+ /**
30
+ * Date filter for DataGrid with default UI.
31
+ *
32
+ * ## Props {@link DataGridDateFilterProps}
33
+ * field, label, ?ranges, ?name
34
+ *
35
+ * ## Example
36
+ * ```tsx
37
+ * <DataGridDateFilter field={'createdAt'} label="Created at" />
38
+ * ```
39
+ */
24
40
  export const DataGridDateFilter = Component(({ label, ranges, ...props }: DataGridDateFilterProps) => (
25
41
  <DataViewDateFilter {...props}>
26
42
  <DataGridFilterMobileHiding>
@@ -70,6 +86,9 @@ const DataGridDateFilterList = () => (
70
86
  </>
71
87
  )
72
88
 
89
+ /**
90
+ * Utility function to create a predefined date range
91
+ */
73
92
  export const createDataGridDateRange = (label: ReactNode, dayDeltaStart: number, dayDeltaEnd: number): DataGridPredefinedDateRange => {
74
93
  const start = new Date(new Date().setDate(new Date().getDate() + dayDeltaStart))
75
94
  const end = new Date(new Date().setDate(new Date().getDate() + dayDeltaEnd))
@@ -106,7 +125,7 @@ const DataGridDateFilterSelect = ({ label, ranges = defaultRanges }: {
106
125
  )
107
126
  }
108
127
 
109
- export type DataGridPredefinedDateRange = { start: string; end: string; label: ReactNode }
128
+
110
129
  const DataGridRangeFilter = ({ start, end, label }: DataGridPredefinedDateRange) => {
111
130
  const name = useDataViewFilterName()
112
131
  const [filter, setFilter] = useDataViewFilter<DateRangeFilterArtifacts>(name)
@@ -121,6 +140,9 @@ const DataGridRangeFilter = ({ start, end, label }: DataGridPredefinedDateRange)
121
140
  )
122
141
  }
123
142
 
143
+ /**
144
+ * @internal
145
+ */
124
146
  export const DataGridDateFilterControls = ({ layout }: { layout?: 'row' | 'column' }) => {
125
147
  const id = useId()
126
148
  return (