@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.
- 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/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/paths.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -22
- package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +45 -8
- package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +66 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +11 -3
- package/resources/templates/template-workspace/admin/lib/datagrid/column-leaf.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +319 -20
- 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 +20 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +23 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/defined.tsx +20 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +31 -3
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +0 -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 +19 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +116 -16
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +46 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +67 -3
- package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +30 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/labels.tsx +10 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +19 -3
- 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 +19 -0
- 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/repeater/repeater.tsx +82 -60
- package/resources/templates/template-workspace/admin/lib/select/list.tsx +1 -2
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +2 -2
- package/src/paths.ts +4 -3
|
@@ -27,21 +27,21 @@ import { Sheet, SheetClose, SheetContent, SheetFooter, SheetHeader, SheetTitle }
|
|
|
27
27
|
import { Switch } from '../ui/switch'
|
|
28
28
|
import { uic } from '../utils'
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const BlockRepeaterItemsWrapperUI = uic('div', {
|
|
31
31
|
baseClass: 'rounded border border-gray-300 px-4 py-8 flex flex-col',
|
|
32
32
|
})
|
|
33
|
-
|
|
33
|
+
const BlockRepeaterItemUI = uic('div', {
|
|
34
34
|
baseClass: 'relative border-t transition-all group',
|
|
35
35
|
})
|
|
36
|
-
|
|
36
|
+
const BlockRepeaterDragOverlayUI = uic('div', {
|
|
37
37
|
baseClass: 'rounded border border-gray-300 p-4 relative bg-opacity-60 bg-gray-100 backdrop-blur-sm',
|
|
38
38
|
})
|
|
39
|
-
|
|
39
|
+
const BlockRepeaterHandleUI = uic('button', {
|
|
40
40
|
baseClass: 'absolute top-1/2 -left-6 h-6 w-6 flex justify-end align-center opacity-10 hover:opacity-100 transition-opacity -translate-y-1/2',
|
|
41
41
|
beforeChildren: <GripVerticalIcon size={16} />,
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
const BlockRepeaterItemActions = uic('div', {
|
|
45
45
|
baseClass: 'absolute top-1 right-2 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity',
|
|
46
46
|
})
|
|
47
47
|
|
|
@@ -54,6 +54,43 @@ export type DefaultBlockRepeaterProps =
|
|
|
54
54
|
|
|
55
55
|
const [BlockRepeaterEditModeContext, useBlockRepeaterEditMode] = createRequiredContext<boolean>('BlockRepeaterEditMode')
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* The `DefaultBlockRepeater` component is a versatile and customizable block repeater shipped with a UI.
|
|
59
|
+
* It allows for the creation and management of repeatable content blocks within a form.
|
|
60
|
+
* Supports two modes of operation:
|
|
61
|
+
* - **Inline Edit Mode**: By providing only `children`, the blocks can be edited inline.
|
|
62
|
+
* - **Dual-Mode**: By providing both `form` and `children`, the component supports a dual-mode where blocks can be edited in a separate form view.
|
|
63
|
+
*
|
|
64
|
+
* ## Props {@link DefaultBlockRepeaterProps}
|
|
65
|
+
* - field or entities, sortableBy, discriminationField, children
|
|
66
|
+
*
|
|
67
|
+
* ## Example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* <DefaultBlockRepeater field="blocks" sortableBy="order" discriminationField="type">
|
|
70
|
+
* <Block
|
|
71
|
+
* name="text"
|
|
72
|
+
* label={<><TextIcon /> Text</>}
|
|
73
|
+
* form={<>
|
|
74
|
+
* <InputField field="title" label="Title" />
|
|
75
|
+
* <TextareaField field="content" label="Content" />
|
|
76
|
+
* </>}
|
|
77
|
+
* children={<>
|
|
78
|
+
* <div className="flex">
|
|
79
|
+
* <div className="w-64 space-y-2">
|
|
80
|
+
* <h2 className="text-xl font-bold">
|
|
81
|
+
* <Field field="title" />
|
|
82
|
+
* </h2>
|
|
83
|
+
* <p>
|
|
84
|
+
* <Field field="content" />
|
|
85
|
+
* </p>
|
|
86
|
+
* </div>
|
|
87
|
+
* </div>
|
|
88
|
+
* </>
|
|
89
|
+
* }
|
|
90
|
+
* />
|
|
91
|
+
* </DefaultBlockRepeater>
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
57
94
|
export const DefaultBlockRepeater = Component<DefaultBlockRepeaterProps>(({ children, ...props }) => {
|
|
58
95
|
const [editMode, setEditMode] = useState(false)
|
|
59
96
|
return (
|
|
@@ -91,7 +128,7 @@ const ToggleEditMode = ({ setEditMode, editMode }: { setEditMode: (value: boolea
|
|
|
91
128
|
)
|
|
92
129
|
}
|
|
93
130
|
|
|
94
|
-
|
|
131
|
+
const BlockRepeaterSortable = Component<{
|
|
95
132
|
sortableBy: DefaultBlockRepeaterProps['sortableBy']
|
|
96
133
|
}>(({ sortableBy }) => {
|
|
97
134
|
return (
|
|
@@ -129,7 +166,7 @@ export const BlockRepeaterSortable = Component<{
|
|
|
129
166
|
)
|
|
130
167
|
})
|
|
131
168
|
|
|
132
|
-
|
|
169
|
+
const BlockRepeaterAddButtons = ({ index }: { index?: RepeaterAddItemIndex }) => {
|
|
133
170
|
const { blocks } = useBlockRepeaterConfig()
|
|
134
171
|
return (
|
|
135
172
|
<div className="grid grid-cols-[repeat(auto-fill,minmax(110px,1fr))] gap-2">
|
|
@@ -150,7 +187,7 @@ export const BlockRepeaterAddButtons = ({ index }: { index?: RepeaterAddItemInde
|
|
|
150
187
|
}
|
|
151
188
|
|
|
152
189
|
|
|
153
|
-
|
|
190
|
+
const BlockRepeaterContent = () => {
|
|
154
191
|
const entity = useEntity()
|
|
155
192
|
const block = useBlockRepeaterCurrentBlock()
|
|
156
193
|
const children = block?.children
|
|
@@ -14,13 +14,36 @@ import {
|
|
|
14
14
|
} from '@contember/interface'
|
|
15
15
|
import { useEnumOptionsFormatter } from '../labels'
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Props for {@link DataGridHasOneCell}.
|
|
19
|
+
*/
|
|
17
20
|
export type DataGridHasOneCellProps = {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Has-one field to be displayed.
|
|
24
|
+
*/
|
|
18
25
|
field: SugaredRelativeSingleEntity['field']
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Filter identifier. If not provided, the filter is resolved from the field name.
|
|
29
|
+
*/
|
|
19
30
|
filterName?: string
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Cell content in the context of the has-one relation.
|
|
34
|
+
*/
|
|
20
35
|
children: ReactNode
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Custom actions to be displayed in the tooltip.
|
|
39
|
+
*/
|
|
21
40
|
tooltipActions?: ReactNode
|
|
22
41
|
}
|
|
23
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Renders a cell with a has-one relation.
|
|
45
|
+
* Contains a tooltip with filter actions.
|
|
46
|
+
*/
|
|
24
47
|
export const DataGridHasOneCell = Component(({ field, filterName, children, tooltipActions }: DataGridHasOneCellProps) => {
|
|
25
48
|
return (
|
|
26
49
|
<HasOne field={field}>
|
|
@@ -33,13 +56,35 @@ export const DataGridHasOneCell = Component(({ field, filterName, children, tool
|
|
|
33
56
|
)
|
|
34
57
|
})
|
|
35
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Props for {@link DataGridHasManyCell}.
|
|
61
|
+
*/
|
|
36
62
|
export type DataGridHasManyCellProps = {
|
|
63
|
+
/**
|
|
64
|
+
* Has-many field to be displayed.
|
|
65
|
+
*/
|
|
37
66
|
field: SugaredRelativeEntityList['field']
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Filter identifier. If not provided, the filter is resolved from the field name.
|
|
70
|
+
*/
|
|
38
71
|
filterName?: string
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Cell content in the context of the has-many relation.
|
|
75
|
+
*/
|
|
39
76
|
children: ReactNode
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Custom actions to be displayed in the tooltip.
|
|
80
|
+
*/
|
|
40
81
|
tooltipActions?: ReactNode
|
|
41
82
|
}
|
|
42
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Renders a cell with a has-many relation.
|
|
86
|
+
* Contains a tooltip with filter actions.
|
|
87
|
+
*/
|
|
43
88
|
export const DataGridHasManyCell = Component(({ field, filterName, children, tooltipActions }: DataGridHasManyCellProps) => {
|
|
44
89
|
return (
|
|
45
90
|
<div className={'flex flex-wrap gap-2'}>
|
|
@@ -54,13 +99,34 @@ export const DataGridHasManyCell = Component(({ field, filterName, children, too
|
|
|
54
99
|
)
|
|
55
100
|
})
|
|
56
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Props for {@link DataGridEnumCell}.
|
|
104
|
+
*/
|
|
57
105
|
export type DataGridEnumCellProps = {
|
|
106
|
+
/**
|
|
107
|
+
* Field to be displayed.
|
|
108
|
+
*/
|
|
58
109
|
field: SugaredRelativeSingleField['field']
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Filter identifier. If not provided, the filter is resolved from the field name.
|
|
113
|
+
*/
|
|
59
114
|
filterName?: string
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Enum options to be displayed in the tooltip. If not provided, the options are resolved from the enum.
|
|
118
|
+
*/
|
|
60
119
|
options?: Record<string, ReactNode>
|
|
120
|
+
/**
|
|
121
|
+
* Custom actions to be displayed in the tooltip.
|
|
122
|
+
*/
|
|
61
123
|
tooltipActions?: ReactNode
|
|
62
124
|
}
|
|
63
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Renders a cell with an enum value.
|
|
128
|
+
* Contains a tooltip with filter actions.
|
|
129
|
+
*/
|
|
64
130
|
export const DataGridEnumCell = Component(({ field, options, filterName, tooltipActions }: DataGridEnumCellProps) => {
|
|
65
131
|
const enumOptionsProvider = useEnumOptionsFormatter()
|
|
66
132
|
return (
|
|
@@ -7,14 +7,22 @@ import { dict } from '../dict'
|
|
|
7
7
|
import { Component } from '@contember/interface'
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Props for {@link DataGridColumnHeader}.
|
|
12
|
+
*/
|
|
13
|
+
export type DataGridColumnHeaderProps = {
|
|
12
14
|
sortingField?: string
|
|
13
15
|
hidingName?: string
|
|
14
16
|
filterName?: string
|
|
15
17
|
filter?: ReactNode
|
|
16
18
|
children: ReactNode
|
|
17
|
-
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Column header for data grid.
|
|
23
|
+
* Contains filtering, sorting and hiding controls.
|
|
24
|
+
*/
|
|
25
|
+
export const DataGridColumnHeader = Component(({ sortingField, hidingName, children, filter, filterName }: DataGridColumnHeaderProps) => {
|
|
18
26
|
let hasFilter = false
|
|
19
27
|
if (filterName) {
|
|
20
28
|
const [, , { isEmpty }] = useDataViewFilter(filterName)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Component } from '@contember/interface'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { ReactNode } from 'react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface DataGridColumnLeafProps {
|
|
9
|
+
header?: ReactNode
|
|
10
|
+
cell: ReactNode
|
|
11
|
+
name?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export const DataGridColumnLeaf = Component<DataGridColumnLeafProps>(() => {
|
|
18
|
+
throw new Error('DataGridColumnLeaf is not supposed to be rendered')
|
|
19
|
+
}, ({ header, cell }) => {
|
|
20
|
+
return <>{header}{cell}</>
|
|
21
|
+
})
|