@contember/create 2.0.0-alpha.38 → 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
@@ -10,13 +10,26 @@ import { CheckIcon, XIcon } from 'lucide-react'
10
10
  import { Button } from '../../ui/button'
11
11
  import { DataViewFieldLabel } from '../labels'
12
12
 
13
-
14
- type DataGridIsDefinedFilterProps =
13
+ /**
14
+ * Props for {@link DataGridIsDefinedFilter}.
15
+ */
16
+ export type DataGridIsDefinedFilterProps =
15
17
  & Omit<DataViewBooleanFilterProps, 'children'>
16
18
  & {
17
19
  label: ReactNode
18
20
  }
19
21
 
22
+ /**
23
+ * Is defined filter for DataGrid with default UI.
24
+ *
25
+ * ## Props {@link DataGridIsDefinedFilterProps}
26
+ * field, label, ?name
27
+ *
28
+ * ## Example
29
+ * ```tsx
30
+ * <DataGridIsDefinedFilter field={'deletedAt'} label="Is Deleted?" />
31
+ * ```
32
+ */
20
33
  export const DataGridIsDefinedFilter = Component(({ label, ...props }: DataGridIsDefinedFilterProps) => (
21
34
  <DataViewIsDefinedFilter {...props}>
22
35
  <DataGridFilterMobileHiding>
@@ -28,7 +41,7 @@ export const DataGridIsDefinedFilter = Component(({ label, ...props }: DataGridI
28
41
  </DataViewIsDefinedFilter>
29
42
  ))
30
43
 
31
- export const DataGridIsDefinedFilterList = () => (
44
+ const DataGridIsDefinedFilterList = () => (
32
45
  <>
33
46
  <DataViewNullFilterTrigger action={'unset'}>
34
47
  <Button variant={'outline'} size="sm" className={'space-x-1 data-[current="none"]:hidden data-[current="include"]:hidden h-6'}>
@@ -52,7 +65,7 @@ export const DataGridIsDefinedFilterList = () => (
52
65
  )
53
66
 
54
67
 
55
- export const DataGridIsDefinedFilterSelect = ({ label }: {
68
+ const DataGridIsDefinedFilterSelect = ({ label }: {
56
69
  label?: ReactNode
57
70
  }) => (
58
71
  <Popover>
@@ -65,6 +78,9 @@ export const DataGridIsDefinedFilterSelect = ({ label }: {
65
78
  </Popover>
66
79
  )
67
80
 
81
+ /**
82
+ * @internal
83
+ */
68
84
  export const DataGridIsDefinedFilterControls = () => {
69
85
  return (
70
86
  <div className={'flex flex-col gap-2'}>
@@ -27,6 +27,9 @@ import { DataGridFilterMobileHiding } from './mobile'
27
27
  import { useEnumOptionsFormatter } from '../../labels'
28
28
  import { DataViewFieldLabel } from '../labels'
29
29
 
30
+ /**
31
+ * Props for {@link DataGridEnumFilter}.
32
+ */
30
33
  export type DataGridEnumFilterProps =
31
34
  & Omit<DataViewEnumFilterProps, 'children'>
32
35
  & {
@@ -34,6 +37,17 @@ export type DataGridEnumFilterProps =
34
37
  label?: ReactNode
35
38
  }
36
39
 
40
+ /**
41
+ * Enum filter for DataGrid with default UI.
42
+ *
43
+ * ## Props {@link DataGridEnumFilterProps}
44
+ * field, label, ?name, ?options
45
+ *
46
+ * ## Example
47
+ * ```tsx
48
+ * <DataGridEnumFilter field={'status'} />
49
+ * ```
50
+ */
37
51
  export const DataGridEnumFilter = Component(({ options, label, ...props }: DataGridEnumFilterProps) =>
38
52
  (
39
53
  <DataViewEnumFilter {...props}>
@@ -46,7 +60,18 @@ export const DataGridEnumFilter = Component(({ options, label, ...props }: DataG
46
60
  </DataViewEnumFilter>
47
61
  ))
48
62
 
49
- export const DataGridEnumFieldTooltip = ({ children, actions, value, ...props }: Omit<DataViewEnumFilterProps, 'children'> & { children: ReactNode; value: string; actions?: ReactNode }) => (
63
+ /**
64
+ * Props for {@link DataGridEnumFieldTooltip}.
65
+ */
66
+ export type DataGridEnumFieldTooltipProps = Omit<DataViewEnumFilterProps, 'children'>
67
+ /**
68
+ * Component for rendering a value with a tooltip that allows to include/exclude the value from the filter.
69
+ * Used in {@link DataGridEnumColumn} but can be used in custom columns as well.
70
+ *
71
+ * ## Props {@link DataGridEnumFieldTooltipProps}
72
+ * field, label, ?name, ?options
73
+ */
74
+ export const DataGridEnumFieldTooltip = ({ children, actions, value, ...props }: DataGridEnumFieldTooltipProps & { children: ReactNode; value: string; actions?: ReactNode }) => (
50
75
  <DataViewEnumFilter {...props}>
51
76
  <TooltipProvider>
52
77
  <Tooltip>
@@ -70,7 +95,7 @@ export const DataGridEnumFieldTooltip = ({ children, actions, value, ...props }:
70
95
  )
71
96
 
72
97
 
73
- export const DataGridEnumFilterList = ({ options }: {
98
+ const DataGridEnumFilterList = ({ options }: {
74
99
  options?: Record<string, ReactNode>
75
100
  }) => {
76
101
  const resolvedOptions = useEnumOptions(options)
@@ -111,7 +136,7 @@ const DataGridEnumFilterSelectItem = ({ value, children, filterFactory }: {
111
136
  )
112
137
 
113
138
  }
114
- export const DataGridEnumFilterSelect = ({ options, label }: {
139
+ const DataGridEnumFilterSelect = ({ options, label }: {
115
140
  options?: Record<string, ReactNode>
116
141
  label?: ReactNode
117
142
  }) => {
@@ -127,6 +152,9 @@ export const DataGridEnumFilterSelect = ({ options, label }: {
127
152
  )
128
153
  }
129
154
 
155
+ /**
156
+ * @internal
157
+ */
130
158
  export const DataGridEnumFilterControls = ({ options }: {
131
159
  options?: Record<string, ReactNode>
132
160
  }) => {
@@ -2,7 +2,6 @@ export * from './boolean'
2
2
  export * from './date'
3
3
  export * from './defined'
4
4
  export * from './enum'
5
- export * from './mobile'
6
5
  export * from './number'
7
6
  export * from './relation'
8
7
  export * from './text'
@@ -2,7 +2,6 @@ import { useDataViewFilter, useDataViewFilteringState, useDataViewFilterName } f
2
2
  import * as React from 'react'
3
3
  import { createContext, ReactNode, useContext } from 'react'
4
4
 
5
-
6
5
  export const DataGridShowFiltersContext = createContext(true)
7
6
 
8
7
  export const DataGridFilterMobileHiding = ({ name, children }: { name?: string; children: ReactNode }) => {
@@ -20,12 +20,25 @@ import { Component } from '@contember/interface'
20
20
  import { DataGridFilterMobileHiding } from './mobile'
21
21
  import { DataViewFieldLabel } from '../labels'
22
22
 
23
+ /**
24
+ * Props for {@link DataGridNumberFilter}.
25
+ */
23
26
  export type DataGridNumberFilterProps =
24
27
  & Omit<DataViewNumberFilterProps, 'children'>
25
28
  & {
26
29
  label: ReactNode
27
30
  }
28
-
31
+ /**
32
+ * Number filter for DataGrid with default UI.
33
+ *
34
+ * ## Props {@link DataGridNumberFilterProps}
35
+ * field, label, ?name
36
+ *
37
+ * ## Example
38
+ * ```tsx
39
+ * <DataGridNumberFilter field={'views'} label="Views" />
40
+ * ```
41
+ */
29
42
  export const DataGridNumberFilter = Component(({ label, ...props }: DataGridNumberFilterProps) => (
30
43
  <DataViewNumberFilter {...props}>
31
44
  <DataGridFilterMobileHiding>
@@ -56,7 +69,7 @@ const DataGridNumberFilterRange = () => {
56
69
  }
57
70
 
58
71
 
59
- export const DataGridNumberFilterList = () => (
72
+ const DataGridNumberFilterList = () => (
60
73
  <>
61
74
  <DataViewNumberFilterResetTrigger>
62
75
  <DataGridActiveFilterUI>
@@ -73,7 +86,7 @@ export const DataGridNumberFilterList = () => (
73
86
  )
74
87
 
75
88
 
76
- export const DataGridNumberFilterSelect = ({ label }: {
89
+ const DataGridNumberFilterSelect = ({ label }: {
77
90
  label?: ReactNode
78
91
  }) => (
79
92
  <Popover>
@@ -86,7 +99,9 @@ export const DataGridNumberFilterSelect = ({ label }: {
86
99
  </Popover>
87
100
  )
88
101
 
89
-
102
+ /**
103
+ * @internal
104
+ */
90
105
  export const DataGridNumberFilterControls = () => {
91
106
  return (
92
107
  <div className={'flex flex-col gap-4'}>
@@ -32,16 +32,28 @@ import { DataGridFilterMobileHiding } from './mobile'
32
32
  import { DataViewHasManyLabel, DataViewHasOneLabel } from '../labels'
33
33
  import { createRequiredContext } from '@contember/react-utils'
34
34
 
35
-
36
- type DataGridRelationFilterInnerProps = {
37
- children: ReactNode
38
- label: ReactNode
39
- }
40
-
35
+ /**
36
+ * Props for {@link DataGridHasOneFilter}.
37
+ */
41
38
  export type DataGridHasOneFilterProps =
42
39
  & DataViewHasOneFilterProps
43
- & DataGridRelationFilterInnerProps
44
-
40
+ & {
41
+ children: ReactNode
42
+ label: ReactNode
43
+ }
44
+ /**
45
+ * Has one filter for DataGrid with default UI.
46
+ *
47
+ * ## Props {@link DataGridHasOneFilterProps}
48
+ * field, label, children, ?name, ?options
49
+ *
50
+ * ## Example
51
+ * ```tsx
52
+ * <DataGridHasOneFilter field={'author'} label="Author">
53
+ * <Field field="name" />
54
+ * </DataGridHasOneFilter>
55
+ * ```
56
+ */
45
57
  export const DataGridHasOneFilter = Component(({ label, children, ...props }: DataGridHasOneFilterProps) => (
46
58
  <DataViewHasOneFilter {...props}>
47
59
  <DataGridFilterMobileHiding>
@@ -52,11 +64,28 @@ export const DataGridHasOneFilter = Component(({ label, children, ...props }: Da
52
64
  </DataViewHasOneFilter>
53
65
  ))
54
66
 
55
-
67
+ /**
68
+ * Props for {@link DataGridHasManyFilter}.
69
+ */
56
70
  export type DataGridHasManyFilterProps =
57
71
  & DataViewHasManyFilterProps
58
- & DataGridRelationFilterInnerProps
59
-
72
+ & {
73
+ children: ReactNode
74
+ label: ReactNode
75
+ }
76
+ /**
77
+ * Has many filter for DataGrid with default UI.
78
+ *
79
+ * ## Props {@link DataGridHasManyFilterProps}
80
+ * field, label, children, ?name, ?options
81
+ *
82
+ * ## Example
83
+ * ```tsx
84
+ * <DataGridHasManyFilter field={'tags'} label="Tags">
85
+ * <Field field="name" />
86
+ * </DataGridHasManyFilter>
87
+ * ```
88
+ */
60
89
  export const DataGridHasManyFilter = Component(({ label, children, ...props }: DataGridHasManyFilterProps) => (
61
90
  <DataViewHasManyFilter {...props} >
62
91
  <DataGridFilterMobileHiding>
@@ -67,7 +96,10 @@ export const DataGridHasManyFilter = Component(({ label, children, ...props }: D
67
96
  </DataViewHasManyFilter>
68
97
  ))
69
98
 
70
- const DataGridRelationFilterInner = Component(({ children, label }: DataGridRelationFilterInnerProps) => {
99
+ const DataGridRelationFilterInner = Component(({ children, label }: {
100
+ children: ReactNode
101
+ label: ReactNode
102
+ }) => {
71
103
  return (
72
104
  <DataGridSingleFilterUI>
73
105
  <DataGridRelationFilterSelect label={label}>
@@ -80,7 +112,39 @@ const DataGridRelationFilterInner = Component(({ children, label }: DataGridRela
80
112
  )
81
113
  }, () => null)
82
114
 
83
- export const DataGridHasOneTooltip = Component(({ children, actions, ...props }: DataViewHasOneFilterProps & { children: ReactNode; actions?: ReactNode }) => (<>
115
+ /**
116
+ * Props for {@link DataGridHasOneTooltip}.
117
+ */
118
+ export type DataGridHasOneTooltipProps =
119
+ & DataViewHasOneFilterProps
120
+ & {
121
+ children: ReactNode
122
+ /**
123
+ * Custom actions to render in the tooltip.
124
+ */
125
+ actions?: ReactNode
126
+ }
127
+
128
+ /**
129
+ * Component for rendering a value with a tooltip that allows to include/exclude the value from the filter.
130
+ * Used in DataGridHasOneColumn, but can be used in custom columns as well.
131
+ *
132
+ * ## Props {@link DataGridHasOneTooltipProps}
133
+ * field, children, ?name, ?options, ?actions
134
+ *
135
+ * ## Example
136
+ * ```tsx
137
+ * <HasOne field="category">
138
+ * <DataGridHasOneTooltip field={'category'}>
139
+ * <button className="text-lg font-semibold text-gray-600">
140
+ * <Field field="category.name" />
141
+ * </button>
142
+ * </button>
143
+ * </DataGridHasOneTooltip>
144
+ * </HasOne>
145
+ * ```
146
+ */
147
+ export const DataGridHasOneTooltip = Component<DataGridHasOneTooltipProps>(({ children, actions, ...props }) => (<>
84
148
  <DataViewHasOneFilter {...props}>
85
149
  <DataGridRelationFieldTooltipInner actions={actions}>
86
150
  {children}
@@ -91,7 +155,38 @@ export const DataGridHasOneTooltip = Component(({ children, actions, ...props }:
91
155
  </StaticRender>
92
156
  </>))
93
157
 
94
- export const DataGridHasManyTooltip = Component<DataViewHasManyFilterProps & { children: ReactNode; actions?: ReactNode }>(({ children, actions, ...props }, env) => {
158
+ /**
159
+ * Props for {@link DataGridHasManyTooltip}.
160
+ */
161
+ export type DataGridHasManyTooltipProps =
162
+ & DataViewHasManyFilterProps
163
+ & {
164
+ children: ReactNode
165
+ /**
166
+ * Custom actions to render in the tooltip.
167
+ */
168
+ actions?: ReactNode
169
+ }
170
+
171
+ /**
172
+ * Component for rendering a value with a tooltip that allows to include/exclude the value from the filter.
173
+ * Used in DataGridHasManyColumn, but can be used in custom columns as well.
174
+ *
175
+ * ## Props {@link DataGridHasManyTooltipProps}
176
+ * field, children, ?name, ?options, ?actions
177
+ *
178
+ * ## Example
179
+ * ```tsx
180
+ * <HasMany field="tags">
181
+ * <DataGridHasManyTooltip field={'tags'}>
182
+ * <button className="text-sm border rounded px-2 py-1">
183
+ * <Field field="name" />
184
+ * </button>
185
+ * </DataGridHasManyTooltip>
186
+ * </HasMany>
187
+ * ```
188
+ */
189
+ export const DataGridHasManyTooltip = Component<DataGridHasManyTooltipProps>(({ children, actions, ...props }) => {
95
190
  return (<>
96
191
  <DataViewHasManyFilter {...props}>
97
192
  <DataGridRelationFieldTooltipInner actions={actions}>
@@ -125,6 +220,9 @@ const DataGridRelationFieldTooltipInner = Component(({ children, actions }: { ch
125
220
  </TooltipProvider>
126
221
  ))
127
222
 
223
+ /**
224
+ * @internal
225
+ */
128
226
  export const DataGridRelationFilteredItemsList = ({ children }: {
129
227
  children: ReactNode
130
228
  }) => (
@@ -171,7 +269,7 @@ const DataGridRelationFilterSelectItem = forwardRef<HTMLButtonElement, DataGridR
171
269
  })
172
270
 
173
271
 
174
- export const DataGridRelationFilterSelect = ({ children, queryField, label }: {
272
+ const DataGridRelationFilterSelect = ({ children, queryField, label }: {
175
273
  queryField?: DataViewUnionFilterFields
176
274
  children: ReactNode
177
275
  label?: ReactNode
@@ -192,7 +290,9 @@ export const DataGridRelationFilterSelect = ({ children, queryField, label }: {
192
290
  )
193
291
  }
194
292
 
195
-
293
+ /**
294
+ * @internal
295
+ */
196
296
  export const DataGridRelationFilterControls = ({ children, queryField }: {
197
297
  queryField?: DataViewUnionFilterFields
198
298
  children: ReactNode
@@ -26,13 +26,26 @@ import { Component } from '@contember/interface'
26
26
  import { DataGridFilterMobileHiding } from './mobile'
27
27
  import { DataViewFieldLabel } from '../labels'
28
28
 
29
-
29
+ /**
30
+ * Props for {@link DataGridTextFilter}.
31
+ */
30
32
  export type DataGridTextFilterProps =
31
33
  & Omit<DataViewTextFilterProps, 'children'>
32
34
  & {
33
35
  label?: React.ReactNode
34
36
  }
35
37
 
38
+ /**
39
+ * Text filter for DataGrid with default UI.
40
+ *
41
+ * ## Props {@link DataGridTextFilterProps}
42
+ * field, label, ?name
43
+ *
44
+ * ## Example
45
+ * ```tsx
46
+ * <DataGridTextFilter field={'name'} label="Name" />
47
+ * ```
48
+ */
36
49
  export const DataGridTextFilter = Component(({ label, ...props }: DataGridTextFilterProps) => (
37
50
  <DataViewTextFilter {...props}>
38
51
  <DataGridFilterMobileHiding>
@@ -41,12 +54,26 @@ export const DataGridTextFilter = Component(({ label, ...props }: DataGridTextFi
41
54
  </DataViewTextFilter>
42
55
  ))
43
56
 
57
+ /**
58
+ * Props for {@link DataGridUnionTextFilter}.
59
+ */
44
60
  export type DataGridUnionTextFilterProps =
45
61
  & Omit<DataViewUnionTextFilterProps, 'children'>
46
62
  & {
47
63
  label?: React.ReactNode
48
64
  }
49
65
 
66
+ /**
67
+ * Text filter which filters multiple fields at once for DataGrid with default UI.
68
+ *
69
+ * ## Props {@link DataGridUnionTextFilterProps}
70
+ * fields, label, ?name
71
+ *
72
+ * ## Example
73
+ * ```tsx
74
+ * <DataGridUnionTextFilter fields={['name', 'description']} label="Name or description" />
75
+ * ```
76
+ */
50
77
  export const DataGridUnionTextFilter = Component(({ label, ...props }: DataGridUnionTextFilterProps) => (
51
78
  <DataViewUnionTextFilter {...props}>
52
79
  <DataGridFilterMobileHiding>
@@ -54,10 +81,22 @@ export const DataGridUnionTextFilter = Component(({ label, ...props }: DataGridU
54
81
  </DataGridFilterMobileHiding>
55
82
  </DataViewUnionTextFilter>
56
83
  ))
57
-
58
- export const DataGridQueryFilter = Component(({ label }: {
84
+ /**
85
+ * Props for {@link DataGridQueryFilter}.
86
+ */
87
+ export type DataGridQueryFilterProps = {
59
88
  label?: React.ReactNode
60
- }) => (
89
+ }
90
+
91
+ /**
92
+ * Universal text filter for DataGrid with default UI. By default, it filters all text fields.
93
+ *
94
+ * ## Example
95
+ * ```tsx
96
+ * <DataGridQueryFilter label="Search" />
97
+ * ```
98
+ */
99
+ export const DataGridQueryFilter = Component(({ label }: DataGridQueryFilterProps) => (
61
100
  <DataViewHasFilterType name={DataViewQueryFilterName}>
62
101
  <DataViewFilterScope name={DataViewQueryFilterName}>
63
102
  <DataGridFilterMobileHiding>
@@ -67,6 +106,9 @@ export const DataGridQueryFilter = Component(({ label }: {
67
106
  </DataViewHasFilterType>
68
107
  ))
69
108
 
109
+ /**
110
+ * @internal
111
+ */
70
112
  export const DataGridTextFilterInner = ({ label }: {
71
113
  label?: React.ReactNode
72
114
  }) => {
@@ -7,14 +7,16 @@ import { DataGridLoader } from './loader'
7
7
  import { DataGridTable } from './table'
8
8
  import { DataGridPagination } from './pagination'
9
9
 
10
-
10
+ /**
11
+ * Props for {@link DataGrid}.
12
+ */
11
13
  export type DataGridProps =
12
14
  & Omit<DataViewProps, 'children'>
13
15
  & {
14
16
  children: ReactNode
15
17
  }
16
18
 
17
- export const dataGridDefaultStorages: Partial<DataGridProps> = {
19
+ const dataGridDefaultStorages: Partial<DataGridProps> = {
18
20
  filteringStateStorage: 'session',
19
21
  sortingStateStorage: 'session',
20
22
  currentPageStateStorage: 'session',
@@ -22,6 +24,53 @@ export const dataGridDefaultStorages: Partial<DataGridProps> = {
22
24
  pagingSettingsStorage: 'local',
23
25
  }
24
26
 
27
+ /**
28
+ * Base DataGrid component. The UI is up to you.
29
+ *
30
+ * ## Props {@link DataGridProps}
31
+ * Primary: children, entities
32
+ * Optional: queryField, filterTypes, dataViewKey, onSelectHighlighted
33
+ * Initial values: initialFilters, initialSorting, initialSelection, initialItemsPerPage
34
+ * Storage settings: filteringStateStorage, sortingStateStorage, currentPageStateStorage, selectionStateStorage, pagingSettingsStorage
35
+ *
36
+ * ## Example
37
+ * ```tsx
38
+ * <DataGrid
39
+ * entities="GridArticle"
40
+ * initialSorting={{
41
+ * publishedAt: 'asc',
42
+ * }}
43
+ * >
44
+ * <DataGridToolbar>
45
+ * <DataGridQueryFilter />
46
+ * <DataGridEnumFilter field={'state'} />
47
+ * <DataGridHasOneFilter field={'author'} label="Author">
48
+ * <Field field="name" />
49
+ * </DataGridHasOneFilter>
50
+ * </DataGridToolbar>
51
+ * <DataGridLoader>
52
+ * <DataGridTable>
53
+ * <DataGridActionColumn><Button>Show detail</Button></DataGridActionColumn>
54
+ * <DataGridTextColumn header="Title" field="title" />
55
+ * <DataGridEnumColumn field="state" />
56
+ * <DataGridDateColumn header="Published at" field="publishedAt" />
57
+ * <DataGridHasOneColumn header="Author" field="author">
58
+ * <Field field="name" />
59
+ * </DataGridHasOneColumn>
60
+ * </DataGridTable>
61
+ * <DataGridTiles>
62
+ * <MyCustomTile />
63
+ * </DataGridTiles>
64
+ * <DataViewLayout name="rows" label='Rows'>
65
+ * <DataViewEachRow>
66
+ * <MyCustomRow />
67
+ * </DataViewEachRow>
68
+ * </DataViewLayout>
69
+ * </DataGridLoader>
70
+ * <DataGridPagination />
71
+ * </DataGrid>
72
+ * ```
73
+ */
25
74
  export const DataGrid = Component(({ children, ...props }: DataGridProps) => {
26
75
  return (
27
76
  <DataView
@@ -35,6 +84,9 @@ export const DataGrid = Component(({ children, ...props }: DataGridProps) => {
35
84
  )
36
85
  })
37
86
 
87
+ /**
88
+ * Props for {@link DefaultDataGrid}.
89
+ */
38
90
  export type DefaultDataGridProps =
39
91
  & Omit<DataViewProps, 'children'>
40
92
  & {
@@ -42,7 +94,19 @@ export type DefaultDataGridProps =
42
94
  toolbar?: ReactNode
43
95
  }
44
96
 
45
- export const DefaultDataGrid = Component(({ children, toolbar, ...props }: DefaultDataGridProps) => {
97
+ /**
98
+ * Default DataGrid with toolbar, loader, table and pagination.
99
+ *
100
+ * ## Example
101
+ * ```tsx
102
+ * <DefaultDataGrid entities="GridArticle">
103
+ * <DataGridActionColumn><Button>Show detail</Button></DataGridActionColumn>
104
+ * <DataGridTextColumn header="Title" field="title" />
105
+ * <DataGridEnumColumn header="State" field="state" options={GridArticleStateLabels} />
106
+ * </DefaultDataGrid>
107
+ * ```
108
+ */
109
+ export const DefaultDataGrid = Component(({ children, toolbar, ...props }: DefaultDataGridProps) => {
46
110
  return (
47
111
  <DataGrid {...props}>
48
112
  <DataGridToolbar>
@@ -1,16 +1,42 @@
1
- export * from './filters'
1
+ export {
2
+ type DataGridBooleanFilterProps,
3
+ DataGridBooleanFilter,
4
+ type DataGridDateFilterProps,
5
+ DataGridDateFilter,
6
+ type DataGridPredefinedDateRange,
7
+ createDataGridDateRange,
8
+ type DataGridIsDefinedFilterProps,
9
+ DataGridIsDefinedFilter,
10
+ type DataGridEnumFilterProps,
11
+ DataGridEnumFilter,
12
+ type DataGridEnumFieldTooltipProps,
13
+ DataGridEnumFieldTooltip,
14
+ type DataGridNumberFilterProps,
15
+ DataGridNumberFilter,
16
+ type DataGridTextFilterProps,
17
+ DataGridTextFilter,
18
+ type DataGridUnionTextFilterProps,
19
+ DataGridUnionTextFilter,
20
+ type DataGridQueryFilterProps,
21
+ DataGridQueryFilter,
22
+ type DataGridHasManyFilterProps,
23
+ DataGridHasManyFilter,
24
+ type DataGridHasManyTooltipProps,
25
+ DataGridHasManyTooltip,
26
+ type DataGridHasOneFilterProps,
27
+ DataGridHasOneFilter,
28
+ type DataGridHasOneTooltipProps,
29
+ DataGridHasOneTooltip,
30
+ } from './filters'
2
31
 
3
32
  export * from './cells'
4
- export * from './column-header'
5
33
  export * from './columns'
6
- export * from './elements'
7
34
  export * from './empty'
8
35
  export * from './export'
9
36
  export * from './grid'
10
37
  export * from './layout-switcher'
11
38
  export * from './loader'
12
39
  export * from './pagination'
13
- export * from './ui'
14
40
  export * from './tiles'
15
41
  export * from './toolbar'
16
42
  export * from './table'
@@ -2,18 +2,27 @@ import { SugaredRelativeEntityList, SugaredRelativeSingleEntity, SugaredRelative
2
2
  import { useDataViewTargetFieldSchema, useDataViewTargetHasManySchema, useDataViewTargetHasOneSchema } from '@contember/react-dataview'
3
3
  import { useFieldLabelFormatter } from '../labels'
4
4
 
5
+ /**
6
+ * Utility component that renders a label for a field.
7
+ */
5
8
  export const DataViewFieldLabel = ({ field }: { field: SugaredRelativeSingleField['field'] }) => {
6
9
  const { field: targetField, entity } = useDataViewTargetFieldSchema(field)
7
10
  const formatter = useFieldLabelFormatter()
8
11
  return <>{formatter(entity.name, targetField.name)}</>
9
12
  }
10
13
 
11
-
14
+ /**
15
+ * Utility component that renders a label for a has-one relation.
16
+ */
12
17
  export const DataViewHasOneLabel = ({ field }: { field: SugaredRelativeSingleEntity['field'] }) => {
13
18
  const { field: targetField, entity } = useDataViewTargetHasOneSchema(field)
14
19
  const formatter = useFieldLabelFormatter()
15
20
  return <>{formatter(entity.name, targetField.name)}</>
16
21
  }
22
+
23
+ /**
24
+ * Utility component that renders a label for a has-many relation.
25
+ */
17
26
  export const DataViewHasManyLabel = ({ field }: { field: SugaredRelativeEntityList['field'] }) => {
18
27
  const { field: targetField, entity } = useDataViewTargetHasManySchema(field)
19
28
  const formatter = useFieldLabelFormatter()
@@ -12,6 +12,9 @@ const LayoutSwitchButton = uic(Button, {
12
12
  },
13
13
  })
14
14
 
15
+ /**
16
+ * Layout switcher UI for data grid. Displays buttons for each layout.
17
+ */
15
18
  export const DataGridLayoutSwitcher = () => {
16
19
  const layouts = useDataViewSelectionState().layouts
17
20