@contember/create 2.0.0-alpha.24 → 2.0.0-alpha.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +29 -23
- package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +26 -0
- package/resources/templates/template-workspace/admin/lib/form/select.tsx +22 -18
- package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +13 -2
- package/resources/templates/template-workspace/admin/lib/select/list.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/select/multi-select.tsx +6 -4
- package/resources/templates/template-workspace/admin/lib/select/select.tsx +22 -7
- package/resources/templates/template-workspace/admin/lib/ui/textarea.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/create",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.25",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"bin": "dist/production/run.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@contember/cli-common": "2.0.0-alpha.
|
|
7
|
+
"@contember/cli-common": "2.0.0-alpha.25",
|
|
8
8
|
"chalk": "^5.3.0",
|
|
9
9
|
"fs-extra": "^11.2.0",
|
|
10
10
|
"js-yaml": "^4.1.0"
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { DataView,
|
|
1
|
+
import { DataView, DataViewProps } from '@contember/react-dataview'
|
|
2
2
|
import * as React from 'react'
|
|
3
3
|
import { ReactNode } from 'react'
|
|
4
|
-
import { DataGridInitialLoader, DataGridOverlayLoader } from './loader'
|
|
5
4
|
import { Component } from '@contember/interface'
|
|
5
|
+
import { DataGridToolbar } from './toolbar'
|
|
6
|
+
import { DataGridLoader } from './loader'
|
|
7
|
+
import { DataGridTable } from './table'
|
|
8
|
+
import { DataGridPagination } from './pagination'
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
export type DataGridProps =
|
|
9
|
-
& Omit<DataViewProps, 'children'
|
|
12
|
+
& Omit<DataViewProps, 'children'>
|
|
10
13
|
& {
|
|
11
14
|
children: ReactNode
|
|
12
15
|
}
|
|
@@ -32,24 +35,27 @@ export const DataGrid = Component(({ children, ...props }: DataGridProps) => {
|
|
|
32
35
|
)
|
|
33
36
|
})
|
|
34
37
|
|
|
35
|
-
export
|
|
36
|
-
children
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<DataViewLoaderState refreshing loaded>
|
|
42
|
-
<div className="relative">
|
|
43
|
-
<DataViewLoaderState refreshing>
|
|
44
|
-
<DataGridOverlayLoader />
|
|
45
|
-
</DataViewLoaderState>
|
|
46
|
-
{children}
|
|
47
|
-
</div>
|
|
48
|
-
</DataViewLoaderState>
|
|
49
|
-
<DataViewLoaderState initial>
|
|
50
|
-
<DataGridInitialLoader />
|
|
51
|
-
</DataViewLoaderState>
|
|
52
|
-
</>
|
|
53
|
-
)
|
|
54
|
-
|
|
38
|
+
export type DefaultDataGridProps =
|
|
39
|
+
& Omit<DataViewProps, 'children'>
|
|
40
|
+
& {
|
|
41
|
+
children: ReactNode
|
|
42
|
+
toolbar?: ReactNode
|
|
43
|
+
}
|
|
55
44
|
|
|
45
|
+
export const DefaultDataGrid = Component(({ children, toolbar, ...props }: DefaultDataGridProps) => {
|
|
46
|
+
return (
|
|
47
|
+
<DataGrid {...props}>
|
|
48
|
+
<DataGridToolbar>
|
|
49
|
+
{toolbar}
|
|
50
|
+
</DataGridToolbar>
|
|
51
|
+
|
|
52
|
+
<DataGridLoader>
|
|
53
|
+
<DataGridTable>
|
|
54
|
+
{children}
|
|
55
|
+
</DataGridTable>
|
|
56
|
+
</DataGridLoader>
|
|
57
|
+
|
|
58
|
+
<DataGridPagination />
|
|
59
|
+
</DataGrid>
|
|
60
|
+
)
|
|
61
|
+
})
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
2
3
|
import { Loader } from '../ui/loader'
|
|
4
|
+
import { DataViewLoaderState } from '@contember/react-dataview'
|
|
5
|
+
|
|
6
|
+
export interface DataGridLoaderProps {
|
|
7
|
+
children: ReactNode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const DataGridLoader = ({ children }: DataGridLoaderProps) => (
|
|
11
|
+
<>
|
|
12
|
+
<DataViewLoaderState refreshing loaded>
|
|
13
|
+
<div className="relative">
|
|
14
|
+
<DataViewLoaderState refreshing>
|
|
15
|
+
<DataGridOverlayLoader />
|
|
16
|
+
</DataViewLoaderState>
|
|
17
|
+
{children}
|
|
18
|
+
</div>
|
|
19
|
+
</DataViewLoaderState>
|
|
20
|
+
<DataViewLoaderState initial>
|
|
21
|
+
<DataGridInitialLoader />
|
|
22
|
+
</DataViewLoaderState>
|
|
23
|
+
<DataViewLoaderState failed>
|
|
24
|
+
<div>Failed to load data</div>
|
|
25
|
+
</DataViewLoaderState>
|
|
26
|
+
</>
|
|
27
|
+
)
|
|
28
|
+
|
|
3
29
|
|
|
4
30
|
export const DataGridOverlayLoader = () => (
|
|
5
31
|
<Loader position={'absolute'} />
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
SortableMultiSelectInputProps,
|
|
14
14
|
} from '../select'
|
|
15
15
|
import * as React from 'react'
|
|
16
|
+
import { useCallback, useMemo } from 'react'
|
|
16
17
|
import { FormContainer, FormContainerProps } from './container'
|
|
17
18
|
import { FormFieldScope, FormHasManyRelationScope, FormHasOneRelationScope, useFormFieldId } from '@contember/react-form'
|
|
18
|
-
import { Component, Field,
|
|
19
|
+
import { Component, Field, RecursionTerminator, SugaredRelativeSingleField, useEntityBeforePersist, useField } from '@contember/interface'
|
|
19
20
|
import { Popover, PopoverTrigger } from '../ui/popover'
|
|
20
21
|
import { ChevronDownIcon, ChevronUpIcon } from 'lucide-react'
|
|
21
|
-
import { useCallback, useMemo } from 'react'
|
|
22
22
|
import { dict } from '../dict'
|
|
23
23
|
|
|
24
24
|
|
|
@@ -26,15 +26,17 @@ export type SelectFieldProps =
|
|
|
26
26
|
& SelectInputProps
|
|
27
27
|
& Omit<FormContainerProps, 'children'>
|
|
28
28
|
|
|
29
|
-
export const SelectField = Component<SelectFieldProps>(({ field, label, description, children, options, queryField, placeholder, createNewForm, errors, initialSorting, required }) => {
|
|
29
|
+
export const SelectField = Component<SelectFieldProps>(({ field, label, description, children, options, queryField, placeholder, createNewForm, errors, initialSorting, required }, env) => {
|
|
30
30
|
return (
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
<
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
<RecursionTerminator field={{ field, kind: 'hasOne' }}>
|
|
32
|
+
<FormHasOneRelationScope field={field}>
|
|
33
|
+
<FormContainer description={description} label={label} errors={errors} required={required}>
|
|
34
|
+
<SelectInput field={field} queryField={queryField} options={options} placeholder={placeholder} createNewForm={createNewForm} initialSorting={initialSorting} required={required}>
|
|
35
|
+
{children}
|
|
36
|
+
</SelectInput>
|
|
37
|
+
</FormContainer>
|
|
38
|
+
</FormHasOneRelationScope>
|
|
39
|
+
</RecursionTerminator>
|
|
38
40
|
)
|
|
39
41
|
})
|
|
40
42
|
|
|
@@ -44,13 +46,15 @@ export type MultiSelectFieldProps =
|
|
|
44
46
|
|
|
45
47
|
export const MultiSelectField = Component<MultiSelectFieldProps>(({ field, label, description, children, options, queryField, placeholder, createNewForm, errors, initialSorting }) => {
|
|
46
48
|
return (
|
|
47
|
-
<
|
|
48
|
-
<
|
|
49
|
-
<
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
<RecursionTerminator field={{ field, kind: 'hasMany' }}>
|
|
50
|
+
<FormHasManyRelationScope field={field}>
|
|
51
|
+
<FormContainer description={description} label={label} errors={errors}>
|
|
52
|
+
<MultiSelectInput field={field} queryField={queryField} options={options} placeholder={placeholder} createNewForm={createNewForm} initialSorting={initialSorting}>
|
|
53
|
+
{children}
|
|
54
|
+
</MultiSelectInput>
|
|
55
|
+
</FormContainer>
|
|
56
|
+
</FormHasManyRelationScope>
|
|
57
|
+
</RecursionTerminator>
|
|
54
58
|
)
|
|
55
59
|
})
|
|
56
60
|
|
|
@@ -122,7 +126,7 @@ const SelectEnumFieldInner = ({ field, options, placeholder, required }: SelectE
|
|
|
122
126
|
<SelectInputUI id={id ? `${id}-input` : undefined}>
|
|
123
127
|
{selectedValue?.label ?? placeholder ?? <SelectDefaultPlaceholderUI />}
|
|
124
128
|
<SelectInputActionsUI>
|
|
125
|
-
{open ? <ChevronUpIcon /> : <ChevronDownIcon />}
|
|
129
|
+
{open ? <ChevronUpIcon className={'w-4 h-4'} /> : <ChevronDownIcon className={'w-4 h-4'} />}
|
|
126
130
|
</SelectInputActionsUI>
|
|
127
131
|
</SelectInputUI>
|
|
128
132
|
</PopoverTrigger>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component } from '@contember/interface'
|
|
1
|
+
import { Component, RecursionTerminator } from '@contember/interface'
|
|
2
2
|
import {
|
|
3
3
|
Repeater,
|
|
4
4
|
RepeaterAddItemIndex,
|
|
@@ -79,7 +79,18 @@ export type DefaultRepeaterProps =
|
|
|
79
79
|
}
|
|
80
80
|
& RepeaterProps
|
|
81
81
|
|
|
82
|
-
export const DefaultRepeater = Component<DefaultRepeaterProps>(
|
|
82
|
+
export const DefaultRepeater = Component<DefaultRepeaterProps>(props => {
|
|
83
|
+
if ('field' in props) {
|
|
84
|
+
return (
|
|
85
|
+
<RecursionTerminator field={{ field: props.field, kind: 'hasMany' }}>
|
|
86
|
+
<DefaultRepeaterInner {...props}/>
|
|
87
|
+
</RecursionTerminator>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
return <DefaultRepeaterInner {...props}/>
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
export const DefaultRepeaterInner = Component<DefaultRepeaterProps>(({ title, children, addButtonPosition = 'after', ...props }) => {
|
|
83
94
|
const isSortable = props.sortableBy !== undefined
|
|
84
95
|
|
|
85
96
|
if (!isSortable) {
|
|
@@ -53,6 +53,9 @@ export const SelectListInner = Component(({ children, filterToolbar }: SelectLis
|
|
|
53
53
|
<DataViewLoaderState initial>
|
|
54
54
|
<Loader position={'static'} size={'sm'} />
|
|
55
55
|
</DataViewLoaderState>
|
|
56
|
+
<DataViewLoaderState failed>
|
|
57
|
+
<div>Failed to load data</div>
|
|
58
|
+
</DataViewLoaderState>
|
|
56
59
|
</div>
|
|
57
60
|
</DataViewKeyboardEventHandler>
|
|
58
61
|
</DataViewInfiniteLoadProvider>
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from './ui'
|
|
15
15
|
import { ChevronDownIcon } from 'lucide-react'
|
|
16
16
|
import { Popover, PopoverTrigger } from '../ui/popover'
|
|
17
|
-
import { Component, SugaredQualifiedEntityList, SugaredRelativeEntityList } from '@contember/interface'
|
|
17
|
+
import { Component, RecursionTerminatorPortal, SugaredQualifiedEntityList, SugaredRelativeEntityList } from '@contember/interface'
|
|
18
18
|
import { SelectDefaultFilter } from './filter'
|
|
19
19
|
import { SelectListInner } from './list'
|
|
20
20
|
import { MultiSelect, SelectDataView, SelectEachValue, SelectItemTrigger, SelectOption, SelectPlaceholder } from '@contember/react-select'
|
|
@@ -79,9 +79,11 @@ export const MultiSelectInput = Component<MultiSelectInputProps>(({ field, query
|
|
|
79
79
|
</SelectPopoverContent>
|
|
80
80
|
</Popover>
|
|
81
81
|
{createNewForm && (
|
|
82
|
-
<
|
|
83
|
-
{
|
|
84
|
-
|
|
82
|
+
<RecursionTerminatorPortal field={{ field, kind: 'hasMany' }}>
|
|
83
|
+
<CreateEntityDialog trigger={<SelectCreateNewTrigger />}>
|
|
84
|
+
{createNewForm}
|
|
85
|
+
</CreateEntityDialog>
|
|
86
|
+
</RecursionTerminatorPortal>
|
|
85
87
|
)}
|
|
86
88
|
</div>
|
|
87
89
|
</MultiSelect>
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { ReactNode, useCallback } from 'react'
|
|
3
3
|
import { Popover, PopoverTrigger } from '../ui/popover'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Component,
|
|
6
|
+
RecursionTerminatorPortal,
|
|
7
|
+
SugaredQualifiedEntityList,
|
|
8
|
+
SugaredRelativeSingleEntity,
|
|
9
|
+
useEntity,
|
|
10
|
+
useEntityBeforePersist,
|
|
11
|
+
} from '@contember/interface'
|
|
5
12
|
import { Button } from '../ui/button'
|
|
6
|
-
import { SugaredRelativeSingleEntity } from '@contember/interface'
|
|
7
13
|
import { ChevronDownIcon, XIcon } from 'lucide-react'
|
|
8
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
SelectCreateNewTrigger,
|
|
16
|
+
SelectDefaultPlaceholderUI,
|
|
17
|
+
SelectInputActionsUI,
|
|
18
|
+
SelectInputUI,
|
|
19
|
+
SelectInputWrapperUI,
|
|
20
|
+
SelectListItemUI,
|
|
21
|
+
SelectPopoverContent,
|
|
22
|
+
} from './ui'
|
|
9
23
|
import { SelectListInner } from './list'
|
|
10
24
|
import { Select, SelectDataView, SelectEachValue, SelectItemTrigger, SelectOption, SelectPlaceholder } from '@contember/react-select'
|
|
11
25
|
import { CreateEntityDialog } from './create-new'
|
|
@@ -82,9 +96,11 @@ export const SelectInput = Component<SelectInputProps>(({ field, queryField, opt
|
|
|
82
96
|
</SelectPopoverContent>
|
|
83
97
|
</Popover>
|
|
84
98
|
{createNewForm && (
|
|
85
|
-
<
|
|
86
|
-
{
|
|
87
|
-
|
|
99
|
+
<RecursionTerminatorPortal field={{ field, kind: 'hasOne' }}>
|
|
100
|
+
<CreateEntityDialog trigger={<SelectCreateNewTrigger />}>
|
|
101
|
+
{createNewForm}
|
|
102
|
+
</CreateEntityDialog>
|
|
103
|
+
</RecursionTerminatorPortal>
|
|
88
104
|
)}
|
|
89
105
|
</div>
|
|
90
106
|
</Select>
|
|
@@ -96,4 +112,3 @@ export const SelectInput = Component<SelectInputProps>(({ field, queryField, opt
|
|
|
96
112
|
</Select>
|
|
97
113
|
)
|
|
98
114
|
})
|
|
99
|
-
|
|
@@ -3,7 +3,7 @@ import { uic } from '../utils'
|
|
|
3
3
|
import { ComponentProps, forwardRef, useRef } from 'react'
|
|
4
4
|
|
|
5
5
|
export const Textarea = uic('textarea', {
|
|
6
|
-
baseClass: 'w-full rounded-md border border-input
|
|
6
|
+
baseClass: 'w-full bg-background rounded-md border border-input px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
|
|
7
7
|
displayName: 'Textarea',
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -182,7 +182,7 @@ interface MetaFieldProps {
|
|
|
182
182
|
const MetaField = Component<MetaFieldProps>(({ field, label, format = it => it }) => (
|
|
183
183
|
!field ? null : <FieldView<any> field={field} render={value => <>
|
|
184
184
|
<span className="font-semibold text-right">{label}</span>
|
|
185
|
-
<span>{format(value)}</span>
|
|
185
|
+
<span>{format(value.value)}</span>
|
|
186
186
|
</>} />
|
|
187
187
|
))
|
|
188
188
|
|