@contember/create 2.0.0-alpha.19 → 2.0.0-alpha.21
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/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +40 -26
- package/resources/templates/template-workspace/admin/lib/binding/identity.tsx +33 -3
- package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +55 -23
- package/resources/templates/template-workspace/admin/lib/buttons/link-back-button.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/defined.tsx +87 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +4 -2
- package/resources/templates/template-workspace/admin/lib/dict.ts +4 -2
- package/resources/templates/template-workspace/admin/lib/form/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +26 -14
- package/resources/templates/template-workspace/admin/lib/form/select.tsx +13 -6
- package/resources/templates/template-workspace/admin/lib/form/upload-repeaters.tsx +191 -0
- package/resources/templates/template-workspace/admin/lib/form/upload.tsx +48 -230
- package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +3 -3
- package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +4 -4
- package/resources/templates/template-workspace/admin/lib/select/index.ts +0 -1
- package/resources/templates/template-workspace/admin/lib/select/list.tsx +41 -25
- 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/update-project-member.tsx +5 -3
- 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/dialog.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +2 -1
- 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/select.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +157 -162
- package/resources/templates/template-workspace/admin/lib/utils/createComponentOpenHooks.tsx +38 -0
- package/resources/templates/template-workspace/admin/package.json +21 -20
- package/resources/templates/template-workspace/admin/lib/select/pagination.tsx +0 -48
|
@@ -3,11 +3,12 @@ import * as React from 'react'
|
|
|
3
3
|
import { TableCell } from '../../ui/table'
|
|
4
4
|
import { dict } from '../../dict'
|
|
5
5
|
import { MemberList, MemberListController } from './member-list'
|
|
6
|
+
import { RolesConfig } from '../forms'
|
|
6
7
|
|
|
7
8
|
const filter: ProjectMembersFilter = {
|
|
8
9
|
memberType: 'PERSON',
|
|
9
10
|
}
|
|
10
|
-
export const PersonList = (props: { controller?: { current?: MemberListController } }) => (
|
|
11
|
+
export const PersonList = (props: { controller?: { current?: MemberListController }; roles?: RolesConfig }) => (
|
|
11
12
|
<MemberList
|
|
12
13
|
{...props}
|
|
13
14
|
filter={filter}
|
|
@@ -2,9 +2,10 @@ import * as React from 'react'
|
|
|
2
2
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
|
|
3
3
|
import { buttonConfig } from './button'
|
|
4
4
|
import { uic } from '../utils'
|
|
5
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
export const AlertDialog = AlertDialogPrimitive.Root
|
|
8
|
+
export const { Component: AlertDialog, useOpen: useAlertDialogOpenState } = createComponentOpenHooks(AlertDialogPrimitive.Root)
|
|
8
9
|
|
|
9
10
|
export const AlertDialogTrigger = AlertDialogPrimitive.Trigger
|
|
10
11
|
|
|
@@ -2,8 +2,9 @@ import * as React from 'react'
|
|
|
2
2
|
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
|
3
3
|
import { uic } from '../utils/uic'
|
|
4
4
|
import { XIcon } from 'lucide-react'
|
|
5
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
5
6
|
|
|
6
|
-
export const Dialog = DialogPrimitive.Root
|
|
7
|
+
export const { Component: Dialog, useOpen: useDialogOpenState } = createComponentOpenHooks(DialogPrimitive.Root)
|
|
7
8
|
|
|
8
9
|
export const DialogTrigger = DialogPrimitive.Trigger
|
|
9
10
|
|
|
@@ -4,8 +4,9 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'
|
|
|
4
4
|
import { Check, ChevronRight, Circle, MoreHorizontalIcon } from 'lucide-react'
|
|
5
5
|
import { cn, uic } from '../utils'
|
|
6
6
|
import { buttonConfig } from './button'
|
|
7
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
7
8
|
|
|
8
|
-
export const DropdownMenu = DropdownMenuPrimitive.Root
|
|
9
|
+
export const { Component: DropdownMenu, useOpen: useDropdownMenuOpenState } = createComponentOpenHooks(DropdownMenuPrimitive.Root)
|
|
9
10
|
|
|
10
11
|
export const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger
|
|
11
12
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReactNode } from 'react'
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
3
2
|
import { uic } from '../utils'
|
|
4
|
-
import { RoleCondition, useProjectUserRoles } from '@contember/interface'
|
|
3
|
+
import { type RoleCondition, useProjectUserRoles, Link, type RoutingLinkTarget } from '@contember/interface'
|
|
5
4
|
import { createContext } from '@contember/react-utils'
|
|
6
5
|
|
|
7
6
|
export const MenuItemUI = uic('a', {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import * as PopoverPrimitive from '@radix-ui/react-popover'
|
|
3
3
|
import { cn } from '../utils'
|
|
4
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
4
5
|
|
|
5
|
-
const Popover = PopoverPrimitive.Root
|
|
6
|
+
const { Component: Popover, useOpen: usePopoverOpenstate } = createComponentOpenHooks(PopoverPrimitive.Root)
|
|
6
7
|
|
|
7
8
|
const PopoverTrigger = PopoverPrimitive.Trigger
|
|
8
9
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as SelectPrimitive from '@radix-ui/react-select'
|
|
2
2
|
import { Check, ChevronDown, ChevronUp } from 'lucide-react'
|
|
3
3
|
import { uic } from '../utils'
|
|
4
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
4
5
|
|
|
5
|
-
export const Select = SelectPrimitive.Root
|
|
6
|
+
export const { Component: Select, useOpen: useSelectOpenState } = createComponentOpenHooks(SelectPrimitive.Root)
|
|
6
7
|
|
|
7
8
|
export const SelectGroup = SelectPrimitive.Group
|
|
8
9
|
|
|
@@ -2,8 +2,9 @@ import * as React from 'react'
|
|
|
2
2
|
import * as SheetPrimitive from '@radix-ui/react-dialog'
|
|
3
3
|
import { uic } from '../utils/uic'
|
|
4
4
|
import { XIcon } from 'lucide-react'
|
|
5
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
5
6
|
|
|
6
|
-
export const Sheet = SheetPrimitive.Root
|
|
7
|
+
export const { Component: Sheet, useOpen: useSheetOpenState } = createComponentOpenHooks(SheetPrimitive.Root)
|
|
7
8
|
|
|
8
9
|
export const SheetTrigger = SheetPrimitive.Trigger
|
|
9
10
|
|
|
@@ -1,139 +1,141 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { ComponentType, ReactNode } from 'react'
|
|
3
|
-
import { Component, Field,
|
|
4
|
-
import {
|
|
3
|
+
import { Component, Field, FieldView, StaticRender, SugaredRelativeSingleEntity, SugaredRelativeSingleField } from '@contember/interface'
|
|
4
|
+
import {
|
|
5
|
+
AudioFileDataExtractorProps,
|
|
6
|
+
FileUrlDataExtractorProps,
|
|
7
|
+
GenericFileMetadataExtractorProps,
|
|
8
|
+
ImageFileDataExtractorProps,
|
|
9
|
+
UploaderBase,
|
|
10
|
+
VideoFileDataExtractorProps,
|
|
11
|
+
} from '@contember/react-uploader'
|
|
5
12
|
import { formatBytes, formatDate, formatDuration } from '../formatting'
|
|
6
13
|
import { Button } from '../ui/button'
|
|
7
|
-
import { FileIcon, InfoIcon, TrashIcon } from 'lucide-react'
|
|
14
|
+
import { EditIcon, FileIcon, InfoIcon, TrashIcon } from 'lucide-react'
|
|
8
15
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
|
|
9
16
|
import { formatImageResizeUrl } from '../images'
|
|
10
17
|
|
|
18
|
+
export type BaseFileViewProps = {
|
|
19
|
+
baseField?: SugaredRelativeSingleEntity['field']
|
|
20
|
+
actions?: ReactNode
|
|
21
|
+
edit?: ReactNode
|
|
22
|
+
noDestroy?: boolean
|
|
23
|
+
DestroyAction?: ComponentType<{ children: ReactNode }>
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
11
27
|
export type UploadedImageViewProps =
|
|
12
28
|
& FileUrlDataExtractorProps
|
|
13
29
|
& GenericFileMetadataExtractorProps
|
|
14
30
|
& ImageFileDataExtractorProps
|
|
15
|
-
&
|
|
16
|
-
DestroyAction?: ComponentType<{ children: ReactNode }>
|
|
17
|
-
}
|
|
31
|
+
& BaseFileViewProps
|
|
18
32
|
|
|
19
|
-
export const UploadedImageView = Component<UploadedImageViewProps>(({ DestroyAction, ...props }) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
33
|
+
export const UploadedImageView = Component<UploadedImageViewProps>(({ DestroyAction, edit, actions, baseField, ...props }) => (
|
|
34
|
+
<div className="flex items-center justify-center h-40 rounded-md group relative">
|
|
35
|
+
<UploaderBase baseField={baseField}>
|
|
36
|
+
<ImagePreview urlField={props.urlField} />
|
|
37
|
+
</UploaderBase>
|
|
38
|
+
<FileActions baseField={baseField} DestroyAction={DestroyAction} metadata={<ImageMetadata {...props} />} edit={edit} actions={actions} />
|
|
39
|
+
</div>
|
|
40
|
+
))
|
|
41
|
+
|
|
42
|
+
const ImagePreview = Component((props: FileUrlDataExtractorProps) => (
|
|
43
|
+
<FieldView<string> field={props.urlField} render={({ value: url }) => (
|
|
44
|
+
!url ? null : <img src={formatImageResizeUrl(url, { width: 400 })} className="max-w-full max-h-full" />
|
|
45
|
+
)} />
|
|
46
|
+
))
|
|
47
|
+
|
|
48
|
+
const ImageMetadata = Component(({ heightField, widthField, ...props }: UploadedImageViewProps) => (
|
|
49
|
+
<Metadata {...props}>
|
|
50
|
+
<DimensionsMeta widthField={widthField} heightField={heightField} />
|
|
51
|
+
</Metadata>
|
|
52
|
+
))
|
|
35
53
|
|
|
36
|
-
const ImageMetadata = Component(({ heightField, widthField, ...props }: UploadedImageViewProps) => {
|
|
37
|
-
return (
|
|
38
|
-
<Metadata {...props}>
|
|
39
|
-
<DimensionsMeta widthField={widthField} heightField={heightField} />
|
|
40
|
-
</Metadata>
|
|
41
|
-
)
|
|
42
|
-
})
|
|
43
54
|
|
|
44
55
|
|
|
45
56
|
export type UploadedAudioViewProps =
|
|
46
57
|
& FileUrlDataExtractorProps
|
|
47
58
|
& GenericFileMetadataExtractorProps
|
|
48
59
|
& AudioFileDataExtractorProps
|
|
49
|
-
&
|
|
50
|
-
DestroyAction?: ComponentType<{ children: ReactNode }>
|
|
51
|
-
}
|
|
60
|
+
& BaseFileViewProps
|
|
52
61
|
|
|
53
|
-
export const UploadedAudioView = Component<UploadedAudioViewProps>(({ DestroyAction, ...props }) =>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
export const UploadedAudioView = Component<UploadedAudioViewProps>(({ DestroyAction, edit, actions, baseField, ...props }) => (
|
|
63
|
+
<div className="flex items-end justify-center h-40 max-w-80 rounded-md group">
|
|
64
|
+
<UploaderBase baseField={baseField}>
|
|
65
|
+
<AudioPreview urlField={props.urlField} />
|
|
66
|
+
</UploaderBase>
|
|
67
|
+
<FileActions baseField={baseField} DestroyAction={DestroyAction} metadata={<AudioMetadata {...props} />} edit={edit}
|
|
68
|
+
actions={actions} />
|
|
69
|
+
</div>
|
|
70
|
+
))
|
|
71
|
+
|
|
72
|
+
const AudioPreview = Component(({ urlField }: FileUrlDataExtractorProps) => (
|
|
73
|
+
<FieldView<string> field={urlField} render={({ value: url }) => (
|
|
74
|
+
!url ? null : <audio src={url} controls className="max-w-full max-h-full" controlsList="nodownload noremoteplayback noplaybackrate" />
|
|
75
|
+
)} />
|
|
76
|
+
))
|
|
77
|
+
|
|
78
|
+
const AudioMetadata = Component(({ durationField, ...props }: UploadedAudioViewProps) => (
|
|
79
|
+
<Metadata {...props}>
|
|
80
|
+
<MetaField field={durationField} label="Duration:" format={formatDuration} />
|
|
81
|
+
</Metadata>
|
|
82
|
+
))
|
|
69
83
|
|
|
70
|
-
const AudioMetadata = ({ durationField, ...props }: UploadedAudioViewProps) => {
|
|
71
|
-
return (
|
|
72
|
-
<Metadata {...props}>
|
|
73
|
-
<MetaField field={durationField} label="Duration:" format={formatDuration} />
|
|
74
|
-
</Metadata>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
84
|
|
|
78
85
|
|
|
79
86
|
export type UploadedVideoViewProps =
|
|
80
87
|
& FileUrlDataExtractorProps
|
|
81
88
|
& GenericFileMetadataExtractorProps
|
|
82
89
|
& VideoFileDataExtractorProps
|
|
83
|
-
&
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
& BaseFileViewProps
|
|
91
|
+
|
|
92
|
+
export const UploadedVideoView = Component<UploadedVideoViewProps>(({ DestroyAction, edit, actions, baseField, ...props }) => (
|
|
93
|
+
<div className="flex items-center justify-center h-40 max-w-60 rounded-md group">
|
|
94
|
+
<UploaderBase baseField={baseField}>
|
|
95
|
+
<VideoPreview urlField={props.urlField} />
|
|
96
|
+
</UploaderBase>
|
|
97
|
+
<FileActions baseField={baseField} DestroyAction={DestroyAction} metadata={<VideoMetadata {...props} />} edit={edit} actions={actions} />
|
|
98
|
+
</div>
|
|
99
|
+
))
|
|
100
|
+
|
|
101
|
+
const VideoPreview = Component(({ urlField }: FileUrlDataExtractorProps) => (
|
|
102
|
+
<FieldView<string> field={urlField} render={({ value: url }) => (
|
|
103
|
+
!url ? null : <video src={url} controls className="max-w-full max-h-full" controlsList="nodownload noremoteplayback noplaybackrate" />
|
|
104
|
+
)} />
|
|
105
|
+
))
|
|
106
|
+
|
|
107
|
+
const VideoMetadata = Component(({ durationField, widthField, heightField, ...props }: UploadedVideoViewProps) => (
|
|
108
|
+
<Metadata {...props}>
|
|
109
|
+
<MetaField field={durationField} label="Duration:" format={formatDuration} />
|
|
110
|
+
<DimensionsMeta widthField={widthField} heightField={heightField} />
|
|
111
|
+
</Metadata>
|
|
112
|
+
))
|
|
86
113
|
|
|
87
|
-
export const UploadedVideoView = Component<UploadedVideoViewProps>(({ DestroyAction, ...props }) => {
|
|
88
|
-
const url = useField<string>(props.urlField).value
|
|
89
|
-
return (
|
|
90
|
-
<div className="flex items-center justify-center h-40 max-w-60 rounded-md group">
|
|
91
|
-
{url && <video src={url} controls className="max-w-full max-h-full" controlsList="nodownload noremoteplayback noplaybackrate" />}
|
|
92
|
-
<FileActions DestroyAction={DestroyAction}>
|
|
93
|
-
<VideoMetadata {...props} />
|
|
94
|
-
</FileActions>
|
|
95
|
-
</div>
|
|
96
|
-
)
|
|
97
|
-
}, props => {
|
|
98
|
-
return <>
|
|
99
|
-
<Field field={props.urlField} />
|
|
100
|
-
<VideoMetadata {...props} />
|
|
101
|
-
</>
|
|
102
|
-
})
|
|
103
114
|
|
|
104
|
-
const VideoMetadata = Component(({ durationField, widthField, heightField, ...props }: UploadedVideoViewProps) => {
|
|
105
|
-
return (
|
|
106
|
-
<Metadata {...props}>
|
|
107
|
-
<MetaField field={durationField} label="Duration:" format={formatDuration} />
|
|
108
|
-
<DimensionsMeta widthField={widthField} heightField={heightField} />
|
|
109
|
-
</Metadata>
|
|
110
|
-
)
|
|
111
|
-
})
|
|
112
115
|
|
|
113
116
|
export type UploadedAnyViewProps =
|
|
114
117
|
& FileUrlDataExtractorProps
|
|
115
118
|
& GenericFileMetadataExtractorProps
|
|
116
|
-
&
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
})
|
|
119
|
+
& BaseFileViewProps
|
|
120
|
+
|
|
121
|
+
export const UploadedAnyView = Component<UploadedAnyViewProps>(({ DestroyAction, edit, actions, baseField, ...props }) => (
|
|
122
|
+
<div className="flex h-40 w-40 rounded-md group">
|
|
123
|
+
<UploaderBase baseField={baseField}>
|
|
124
|
+
<AnyFilePreview {...props} />
|
|
125
|
+
</UploaderBase>
|
|
126
|
+
<FileActions baseField={baseField} DestroyAction={DestroyAction} metadata={<Metadata {...props} />} edit={edit} actions={actions} />
|
|
127
|
+
</div>
|
|
128
|
+
))
|
|
129
|
+
|
|
130
|
+
const AnyFilePreview = Component(({ urlField, fileNameField }: FileUrlDataExtractorProps & GenericFileMetadataExtractorProps) => <>
|
|
131
|
+
<FieldView<string> field={urlField} render={({ value: url }) => (
|
|
132
|
+
url ? <a href={url ?? '#'} target="_blank" rel="noreferrer"
|
|
133
|
+
className="text-blue-600 hover:text-blue-700 underline overflow-hidden whitespace-nowrap overflow-ellipsis flex flex-col group/anchor flex-1 items-center justify-center">
|
|
134
|
+
<FileIcon className="h-16 w-16 text-gray-400 group-hover/anchor:text-gray-500 transition-all" />
|
|
135
|
+
{fileNameField ? <span><Field field={fileNameField} /></span> : null}
|
|
136
|
+
</a> : null)} />
|
|
137
|
+
<StaticRender>{fileNameField ? <span><Field field={fileNameField} /></span> : null}</StaticRender>
|
|
138
|
+
</>)
|
|
137
139
|
|
|
138
140
|
|
|
139
141
|
type MetadataProps =
|
|
@@ -143,45 +145,33 @@ type MetadataProps =
|
|
|
143
145
|
children?: ReactNode
|
|
144
146
|
}
|
|
145
147
|
|
|
146
|
-
const Metadata = Component(({ children, urlField, fileSizeField, fileNameField, lastModifiedField, fileTypeField }: MetadataProps) =>
|
|
147
|
-
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
})
|
|
148
|
+
const Metadata = Component(({ children, urlField, fileSizeField, fileNameField, lastModifiedField, fileTypeField }: MetadataProps) => (
|
|
149
|
+
<div className="grid grid-cols-[6rem_1fr] gap-2">
|
|
150
|
+
<MetaField field={fileSizeField} label="Size:" format={formatBytes} />
|
|
151
|
+
<MetaField field={fileTypeField} label="Type:" />
|
|
152
|
+
<MetaField field={fileNameField} label="File name:" />
|
|
153
|
+
{children}
|
|
154
|
+
<MetaField field={lastModifiedField} label="Date:" format={formatDate} />
|
|
155
|
+
<MetaField field={urlField} label="URL:" format={url => (
|
|
156
|
+
<a href={url} target="_blank" rel="noreferrer"
|
|
157
|
+
className="text-blue-600 underline overflow-hidden whitespace-nowrap overflow-ellipsis">
|
|
158
|
+
{url.replace(/^(.{15}).*(.{15})$/, '$1…$2')}
|
|
159
|
+
</a>
|
|
160
|
+
)} />
|
|
161
|
+
</div>
|
|
162
|
+
))
|
|
162
163
|
|
|
163
164
|
const DimensionsMeta = Component(({ widthField, heightField }: {
|
|
164
165
|
widthField?: SugaredRelativeSingleField['field']
|
|
165
166
|
heightField?: SugaredRelativeSingleField['field']
|
|
166
167
|
}) => {
|
|
167
|
-
const entity = useEntity()
|
|
168
168
|
if (!widthField || !heightField) {
|
|
169
169
|
return null
|
|
170
170
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
<>
|
|
176
|
-
<span className="font-semibold text-right">Dimensions:</span>
|
|
177
|
-
<span>{width} x {height} px</span>
|
|
178
|
-
</>
|
|
179
|
-
)
|
|
180
|
-
}, ({ widthField, heightField }) => {
|
|
181
|
-
return <>
|
|
182
|
-
{widthField && <Field field={widthField} />}
|
|
183
|
-
{heightField && <Field field={heightField} />}
|
|
184
|
-
</>
|
|
171
|
+
return <FieldView<number, number> fields={[widthField, heightField]} render={(width, height) => <>
|
|
172
|
+
<span className="font-semibold text-right">Dimensions:</span>
|
|
173
|
+
<span>{width.value} x {height.value} px</span>
|
|
174
|
+
</>}/>
|
|
185
175
|
})
|
|
186
176
|
|
|
187
177
|
interface MetaFieldProps {
|
|
@@ -189,44 +179,49 @@ interface MetaFieldProps {
|
|
|
189
179
|
label: ReactNode
|
|
190
180
|
format?: (value: any) => ReactNode
|
|
191
181
|
}
|
|
192
|
-
const MetaField = Component<MetaFieldProps>(({ field, label, format = it => it }) =>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
{format(entity.getField(field).value)}
|
|
199
|
-
</span>
|
|
200
|
-
</>
|
|
201
|
-
) : null
|
|
202
|
-
}, ({ field }) => {
|
|
203
|
-
return field ? <Field field={field} /> : null
|
|
204
|
-
})
|
|
182
|
+
const MetaField = Component<MetaFieldProps>(({ field, label, format = it => it }) => (
|
|
183
|
+
!field ? null : <FieldView<any> field={field} render={value => <>
|
|
184
|
+
<span className="font-semibold text-right">{label}</span>
|
|
185
|
+
<span>{format(value)}</span>
|
|
186
|
+
</>} />
|
|
187
|
+
))
|
|
205
188
|
|
|
206
189
|
|
|
207
|
-
const FileActions = ({ DestroyAction,
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}) => {
|
|
190
|
+
const FileActions = Component(({ DestroyAction, metadata, actions, edit, baseField, noDestroy }: {
|
|
191
|
+
metadata?: ReactNode
|
|
192
|
+
} & BaseFileViewProps) => {
|
|
211
193
|
return (
|
|
212
|
-
<div className="absolute -top-2 -right-1 p-0.5 bg-gray-200 border border-gray-300 rounded shadow flex gap-
|
|
213
|
-
|
|
194
|
+
<div className="absolute -top-2 -right-1 p-0.5 bg-gray-200 border border-gray-300 rounded shadow flex gap-2 opacity-0 transition-opacity group-hover:opacity-100">
|
|
195
|
+
{actions}
|
|
196
|
+
{edit && <Popover>
|
|
214
197
|
<PopoverTrigger asChild>
|
|
215
198
|
<Button variant={'ghost'} size={'sm'} className={'p-0.5 h-5 w-5'} onClick={e => e.stopPropagation()}>
|
|
216
|
-
<
|
|
199
|
+
<EditIcon className="h-4 w-4" />
|
|
217
200
|
</Button>
|
|
218
201
|
</PopoverTrigger>
|
|
219
202
|
<PopoverContent>
|
|
220
|
-
|
|
221
|
-
{children}
|
|
222
|
-
</div>
|
|
203
|
+
{edit}
|
|
223
204
|
</PopoverContent>
|
|
224
|
-
</Popover>
|
|
225
|
-
{
|
|
205
|
+
</Popover>}
|
|
206
|
+
<UploaderBase baseField={baseField}>
|
|
207
|
+
{metadata && <Popover>
|
|
208
|
+
<PopoverTrigger asChild>
|
|
209
|
+
<Button variant={'ghost'} size={'sm'} className={'p-0.5 h-5 w-5'} onClick={e => e.stopPropagation()}>
|
|
210
|
+
<InfoIcon className="h-4 w-4" />
|
|
211
|
+
</Button>
|
|
212
|
+
</PopoverTrigger>
|
|
213
|
+
<PopoverContent>
|
|
214
|
+
<div className="text-sm">
|
|
215
|
+
{metadata}
|
|
216
|
+
</div>
|
|
217
|
+
</PopoverContent>
|
|
218
|
+
</Popover>}
|
|
219
|
+
</UploaderBase>
|
|
220
|
+
{!noDestroy && DestroyAction ? <DestroyAction>
|
|
226
221
|
<Button variant={'ghost'} size={'sm'} className={'p-0.5 h-5 w-5 text-red-500'}>
|
|
227
|
-
<TrashIcon className="h-
|
|
222
|
+
<TrashIcon className="h-4 w-4" />
|
|
228
223
|
</Button>
|
|
229
|
-
</DestroyAction>}
|
|
224
|
+
</DestroyAction> : null}
|
|
230
225
|
</div>
|
|
231
226
|
)
|
|
232
|
-
}
|
|
227
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ComponentType, memo, SetStateAction, useCallback, useState } from 'react'
|
|
2
|
+
import { createRequiredContext } from '@contember/react-utils'
|
|
3
|
+
|
|
4
|
+
export const createComponentOpenHooks = <P extends {
|
|
5
|
+
open?: boolean
|
|
6
|
+
defaultOpen?: boolean
|
|
7
|
+
onOpenChange?(open: boolean): void
|
|
8
|
+
}>(Component: ComponentType<P>): {
|
|
9
|
+
Component: ComponentType<P>
|
|
10
|
+
useOpen: () => [boolean, (value: SetStateAction<boolean>) => void]
|
|
11
|
+
} => {
|
|
12
|
+
const [ctx, useOpen] = createRequiredContext<[boolean, (value: SetStateAction<boolean>) => void]>(`${Component.displayName ?? 'UnnamedComponent'}OpenContext`)
|
|
13
|
+
const WrappedComponent = memo<P>(({ open: openIn, defaultOpen, onOpenChange, ...props }) => {
|
|
14
|
+
const [open, setOpenInternal] = useState(openIn ?? defaultOpen ?? false)
|
|
15
|
+
if (openIn !== undefined && open !== openIn) {
|
|
16
|
+
setOpenInternal(openIn)
|
|
17
|
+
}
|
|
18
|
+
const setOpen = useCallback((value: SetStateAction<boolean>) => {
|
|
19
|
+
setOpenInternal(it => {
|
|
20
|
+
const newValue = typeof value === 'function' ? value(it) : value
|
|
21
|
+
onOpenChange?.(newValue)
|
|
22
|
+
return newValue
|
|
23
|
+
})
|
|
24
|
+
}, [onOpenChange])
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<ctx.Provider value={[open, setOpen]}>
|
|
28
|
+
<Component {...(props as P)} open={open} onOpenChange={setOpen} />
|
|
29
|
+
</ctx.Provider>
|
|
30
|
+
)
|
|
31
|
+
})
|
|
32
|
+
WrappedComponent.displayName = Component.displayName
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
Component: WrappedComponent,
|
|
36
|
+
useOpen,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -36,28 +36,29 @@
|
|
|
36
36
|
"@contember/react-slots": "{version}",
|
|
37
37
|
"@contember/react-uploader": "{version}",
|
|
38
38
|
"@contember/react-uploader-dropzone": "{version}",
|
|
39
|
-
"@radix-ui/react-alert-dialog": "^1.
|
|
40
|
-
"@radix-ui/react-
|
|
41
|
-
"@radix-ui/react-dropdown-menu": "^2.
|
|
42
|
-
"@radix-ui/react-label": "^2.0
|
|
43
|
-
"@radix-ui/react-popover": "^1.
|
|
44
|
-
"@radix-ui/react-
|
|
45
|
-
"@radix-ui/react-progress": "^1.0
|
|
46
|
-
"@radix-ui/react-scroll-area": "^1.0
|
|
47
|
-
"@radix-ui/react-select": "^2.
|
|
48
|
-
"@radix-ui/react-
|
|
49
|
-
"@radix-ui/react-
|
|
50
|
-
"@radix-ui/react-
|
|
51
|
-
"@radix-ui/react-
|
|
52
|
-
"@radix-ui/react-
|
|
53
|
-
"@radix-ui/react-tooltip": "^1.
|
|
39
|
+
"@radix-ui/react-alert-dialog": "^1.1.2",
|
|
40
|
+
"@radix-ui/react-dialog": "^1.1.2",
|
|
41
|
+
"@radix-ui/react-dropdown-menu": "^2.1.2",
|
|
42
|
+
"@radix-ui/react-label": "^2.1.0",
|
|
43
|
+
"@radix-ui/react-popover": "^1.1.2",
|
|
44
|
+
"@radix-ui/react-portal": "^1.1.2",
|
|
45
|
+
"@radix-ui/react-progress": "^1.1.0",
|
|
46
|
+
"@radix-ui/react-scroll-area": "^1.2.0",
|
|
47
|
+
"@radix-ui/react-select": "^2.1.2",
|
|
48
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
49
|
+
"@radix-ui/react-switch": "^1.1.1",
|
|
50
|
+
"@radix-ui/react-toast": "^1.2.2",
|
|
51
|
+
"@radix-ui/react-toggle": "^1.1.0",
|
|
52
|
+
"@radix-ui/react-toggle-group": "^1.1.0",
|
|
53
|
+
"@radix-ui/react-tooltip": "^1.1.3",
|
|
54
54
|
"class-variance-authority": "^0.7.0",
|
|
55
|
-
"
|
|
55
|
+
"clsx": "^2.1.1",
|
|
56
|
+
"lucide-react": "^0.451.0",
|
|
56
57
|
"qrcode-generator": "^1.4.4",
|
|
57
|
-
"react": "^18.
|
|
58
|
-
"react-dom": "^18.
|
|
58
|
+
"react": "^18.3.1",
|
|
59
|
+
"react-dom": "^18.3.1",
|
|
59
60
|
"slate": "^0.103.0",
|
|
60
|
-
"slate-react": "^0.
|
|
61
|
-
"tailwind-merge": "^2.
|
|
61
|
+
"slate-react": "^0.110.0",
|
|
62
|
+
"tailwind-merge": "^2.5.3"
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import { MouseEventHandler } from 'react'
|
|
3
|
-
import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react'
|
|
4
|
-
import { DataViewChangePageTrigger, useDataViewPagingInfo } from '@contember/react-dataview'
|
|
5
|
-
import { Button } from '../ui/button'
|
|
6
|
-
import { dict } from '../dict'
|
|
7
|
-
|
|
8
|
-
export const SelectPagination = () => {
|
|
9
|
-
const scrollToTop: MouseEventHandler = e => {
|
|
10
|
-
const el = (e.target as HTMLElement).closest('[data-radix-scroll-area-viewport]')
|
|
11
|
-
if (el) {
|
|
12
|
-
requestAnimationFrame(() => {
|
|
13
|
-
el.scrollTo({ top: 0, behavior: 'smooth' })
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const pageInfo = useDataViewPagingInfo()
|
|
18
|
-
if ((pageInfo.pagesCount ?? 1) <= 1) {
|
|
19
|
-
return null
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div className="flex gap-6 lg:gap-8 justify-center items-center">
|
|
24
|
-
<div className={'flex gap-1'}>
|
|
25
|
-
<DataViewChangePageTrigger page="previous">
|
|
26
|
-
<Button
|
|
27
|
-
size={'xs'}
|
|
28
|
-
variant="outline"
|
|
29
|
-
onClick={scrollToTop}
|
|
30
|
-
>
|
|
31
|
-
<span className="sr-only">{dict.select.paginationPreviousPage}</span>
|
|
32
|
-
<ChevronLeftIcon className="h-3 w-3"/>
|
|
33
|
-
</Button>
|
|
34
|
-
</DataViewChangePageTrigger>
|
|
35
|
-
<DataViewChangePageTrigger page="next">
|
|
36
|
-
<Button
|
|
37
|
-
size={'xs'}
|
|
38
|
-
variant="outline"
|
|
39
|
-
onClick={scrollToTop}
|
|
40
|
-
>
|
|
41
|
-
<span className="sr-only">{dict.select.paginationNextPage}</span>
|
|
42
|
-
<ChevronRightIcon className="h-3 w-3"/>
|
|
43
|
-
</Button>
|
|
44
|
-
</DataViewChangePageTrigger>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
)
|
|
48
|
-
}
|