@contember/create 1.4.0-rc.3 → 1.4.0-rc.5
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/src/commands/WorkspaceCreateCommand.d.ts +4 -3
- package/dist/src/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/src/commands/WorkspaceCreateCommand.js +10 -4
- package/dist/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/src/lib/FileSystem.d.ts +14 -0
- package/dist/src/lib/FileSystem.d.ts.map +1 -0
- package/dist/src/lib/FileSystem.js +54 -0
- package/dist/src/lib/FileSystem.js.map +1 -0
- package/dist/src/lib/PackageDownloader.d.ts +7 -0
- package/dist/src/lib/PackageDownloader.d.ts.map +1 -0
- package/dist/src/lib/PackageDownloader.js +32 -0
- package/dist/src/lib/PackageDownloader.js.map +1 -0
- package/dist/src/lib/TemplateInstaller.d.ts +13 -0
- package/dist/src/lib/TemplateInstaller.d.ts.map +1 -0
- package/dist/src/lib/TemplateInstaller.js +75 -0
- package/dist/src/lib/TemplateInstaller.js.map +1 -0
- package/dist/src/lib/pathUtils.d.ts +3 -0
- package/dist/src/lib/pathUtils.d.ts.map +1 -0
- package/dist/src/lib/pathUtils.js +7 -0
- package/dist/src/lib/pathUtils.js.map +1 -0
- package/dist/src/run.js +7 -3
- package/dist/src/run.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -3
- package/resources/templates/template-workspace/.gitignore.dist +3 -0
- package/resources/templates/template-workspace/admin/.env.development +3 -0
- package/resources/templates/template-workspace/admin/.env.production +3 -0
- package/resources/templates/template-workspace/admin/app/components/layout.tsx +32 -0
- package/resources/templates/template-workspace/admin/app/components/logo.tsx +16 -0
- package/resources/templates/template-workspace/admin/app/components/navigation.tsx +1 -0
- package/resources/templates/template-workspace/admin/app/config.ts +27 -0
- package/resources/templates/template-workspace/admin/app/index.html +15 -0
- package/resources/templates/template-workspace/admin/app/index.tsx +40 -0
- package/resources/templates/template-workspace/admin/app/pages/index.tsx +5 -0
- package/resources/templates/template-workspace/admin/index.css +53 -0
- package/resources/templates/template-workspace/admin/index.html +13 -0
- package/resources/templates/template-workspace/admin/index.tsx +268 -0
- package/resources/templates/template-workspace/admin/lib/binding/binding.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +43 -0
- package/resources/templates/template-workspace/admin/lib/binding/hooks.tsx +71 -0
- package/resources/templates/template-workspace/admin/lib/binding/identity.tsx +19 -0
- package/resources/templates/template-workspace/admin/lib/binding/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/binding/persist.tsx +70 -0
- package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +224 -0
- package/resources/templates/template-workspace/admin/lib/block-repeater/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/board/board.tsx +240 -0
- package/resources/templates/template-workspace/admin/lib/board/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/buttons/back-button.tsx +20 -0
- package/resources/templates/template-workspace/admin/lib/buttons/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/buttons/link-back-button.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +64 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +65 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +166 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +42 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/empty.tsx +8 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/export.tsx +17 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +76 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +153 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +115 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +7 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +19 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +100 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +180 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +121 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +61 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +16 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +32 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +10 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +103 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +69 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +66 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/ui.tsx +153 -0
- package/resources/templates/template-workspace/admin/lib/dev/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/dev/login-panel.tsx +56 -0
- package/resources/templates/template-workspace/admin/lib/dev/todo.tsx +14 -0
- package/resources/templates/template-workspace/admin/lib/dict.ts +324 -0
- package/resources/templates/template-workspace/admin/lib/dimensions/dimensions.tsx +135 -0
- package/resources/templates/template-workspace/admin/lib/dimensions/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/editor/block-editor.tsx +111 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/baseEditorPlugins.tsx +66 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/buttons.tsx +83 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-block-toolbar.tsx +17 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-canvas.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-editable-canvas.tsx +50 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-inline-toolbar.tsx +63 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/AnchorRenderer.tsx +36 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/BlockElement.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/HeadingRenderer.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +28 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ListItemRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/OrderedListRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ParagraphRenderer.tsx +15 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ScrollTargetRenderer.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableCellElementRenderer.tsx +20 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableElementRenderer.tsx +96 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableRowElementRenderer.tsx +15 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/index.ts +6 -0
- package/resources/templates/template-workspace/admin/lib/editor/editor-block.tsx +96 -0
- package/resources/templates/template-workspace/admin/lib/editor/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/editor/plugins.tsx +36 -0
- package/resources/templates/template-workspace/admin/lib/editor/rich-text.tsx +54 -0
- package/resources/templates/template-workspace/admin/lib/editor/sortable-block.tsx +51 -0
- package/resources/templates/template-workspace/admin/lib/errors/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/errors/use-error-formatter.ts +26 -0
- package/resources/templates/template-workspace/admin/lib/form/container.tsx +63 -0
- package/resources/templates/template-workspace/admin/lib/form/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +99 -0
- package/resources/templates/template-workspace/admin/lib/form/select.tsx +123 -0
- package/resources/templates/template-workspace/admin/lib/form/ui.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/form/upload.tsx +243 -0
- package/resources/templates/template-workspace/admin/lib/formatting/formatting.ts +62 -0
- package/resources/templates/template-workspace/admin/lib/formatting/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/images/formatImageResizeUrl.ts +23 -0
- package/resources/templates/template-workspace/admin/lib/images/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/layout/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +167 -0
- package/resources/templates/template-workspace/admin/lib/layout/slots.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/outdated-application-dialog/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +41 -0
- package/resources/templates/template-workspace/admin/lib/repeater/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +142 -0
- package/resources/templates/template-workspace/admin/lib/select/create-new.tsx +34 -0
- package/resources/templates/template-workspace/admin/lib/select/filter.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/select/highlight.tsx +16 -0
- package/resources/templates/template-workspace/admin/lib/select/index.ts +7 -0
- package/resources/templates/template-workspace/admin/lib/select/list.tsx +49 -0
- package/resources/templates/template-workspace/admin/lib/select/multi-select.tsx +95 -0
- package/resources/templates/template-workspace/admin/lib/select/pagination.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/select/select.tsx +87 -0
- package/resources/templates/template-workspace/admin/lib/select/sortable-select.tsx +129 -0
- package/resources/templates/template-workspace/admin/lib/select/ui.tsx +80 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/change-my-password.tsx +40 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/common.tsx +94 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/create-api-key.tsx +39 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/index.ts +8 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/invite.tsx +46 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/login.tsx +52 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/memberships-control.tsx +128 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset-request.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset.tsx +44 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/update-project-member.tsx +32 -0
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInvite.ts +28 -0
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInviteUser.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/tenant/index.ts +3 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/api-key-list.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/index.ts +4 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-delete-dialog.tsx +38 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-list.tsx +147 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/person-list.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/tenant/otp/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/tenant/otp/otp-setup.tsx +146 -0
- package/resources/templates/template-workspace/admin/lib/toast/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/toast/toast.tsx +112 -0
- package/resources/templates/template-workspace/admin/lib/toast/toaster.tsx +104 -0
- package/resources/templates/template-workspace/admin/lib/ui/alert-dialog.tsx +59 -0
- package/resources/templates/template-workspace/admin/lib/ui/button.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/ui/card.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/ui/dialog.tsx +51 -0
- package/resources/templates/template-workspace/admin/lib/ui/divider.tsx +11 -0
- package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +108 -0
- package/resources/templates/template-workspace/admin/lib/ui/input.tsx +62 -0
- package/resources/templates/template-workspace/admin/lib/ui/label.tsx +7 -0
- package/resources/templates/template-workspace/admin/lib/ui/loader.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/ui/menu.tsx +103 -0
- package/resources/templates/template-workspace/admin/lib/ui/overlay.tsx +33 -0
- package/resources/templates/template-workspace/admin/lib/ui/popover.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/ui/progress.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/ui/scroll-area.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +67 -0
- package/resources/templates/template-workspace/admin/lib/ui/sortable.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/ui/switch.tsx +10 -0
- package/resources/templates/template-workspace/admin/lib/ui/table.tsx +46 -0
- package/resources/templates/template-workspace/admin/lib/ui/textarea.tsx +18 -0
- package/resources/templates/template-workspace/admin/lib/ui/toggle-group.tsx +44 -0
- package/resources/templates/template-workspace/admin/lib/ui/toggle.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/ui/tooltip.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/upload/dropzone.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/upload/index.ts +3 -0
- package/resources/templates/template-workspace/admin/lib/upload/repeater.tsx +12 -0
- package/resources/templates/template-workspace/admin/lib/upload/ui.tsx +57 -0
- package/resources/templates/template-workspace/admin/lib/upload/upload-progress.tsx +130 -0
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +219 -0
- package/resources/templates/template-workspace/admin/lib/utils/cn.ts +4 -0
- package/resources/templates/template-workspace/admin/lib/utils/dict-format.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/utils/format-image-resize-url.ts +17 -0
- package/resources/templates/template-workspace/admin/lib/utils/formatting.ts +60 -0
- package/resources/templates/template-workspace/admin/lib/utils/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +79 -0
- package/resources/templates/template-workspace/admin/package.json +63 -0
- package/resources/templates/template-workspace/admin/postcss.config.js +6 -0
- package/resources/templates/template-workspace/admin/public/favicon.png +0 -0
- package/resources/templates/template-workspace/admin/tailwind.config.js +73 -0
- package/resources/templates/template-workspace/admin/tsconfig.json +23 -0
- package/resources/templates/template-workspace/admin/vite-env.d.ts +7 -0
- package/resources/templates/template-workspace/admin/vite.config.ts +39 -0
- package/resources/templates/template-workspace/api/index.ts +7 -0
- package/resources/templates/template-workspace/api/migrations/.gitkeep +1 -0
- package/resources/templates/template-workspace/api/model/index.ts +1 -0
- package/resources/templates/template-workspace/api/package.json +16 -0
- package/resources/templates/template-workspace/api/tsconfig.json +10 -0
- package/resources/templates/template-workspace/biome.json +45 -0
- package/resources/templates/template-workspace/client/package.json +16 -0
- package/resources/templates/template-workspace/client/src/index.ts +1 -0
- package/resources/templates/template-workspace/client/tsconfig.json +9 -0
- package/resources/templates/template-workspace/contember.template.yaml +7 -0
- package/resources/templates/template-workspace/docker-compose.yaml +124 -0
- package/resources/templates/template-workspace/package.json +32 -0
- package/resources/templates/template-workspace/scripts/generate-client.sh +8 -0
- package/resources/templates/template-workspace/tsconfig.json +9 -0
- package/resources/templates/template-workspace/tsconfig.settings.json +15 -0
- package/src/commands/WorkspaceCreateCommand.ts +15 -6
- package/src/lib/FileSystem.ts +24 -0
- package/src/lib/PackageDownloader.ts +33 -0
- package/src/lib/TemplateInstaller.ts +102 -0
- package/src/lib/pathUtils.ts +4 -0
- package/src/run.ts +14 -5
- package/tsconfig.settings.json +5 -1
- package/types/download-tarball/index.d.ts +7 -0
- package/types/get-package-json-from-registry/index.d.ts +3 -0
- package/types/registry-info/index.d.ts +7 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AnyFileTypeProps,
|
|
3
|
+
AudioFileTypeProps,
|
|
4
|
+
createAnyFileType,
|
|
5
|
+
createAudioFileType,
|
|
6
|
+
createImageFileType,
|
|
7
|
+
createVideoFileType,
|
|
8
|
+
FileType,
|
|
9
|
+
FileUrlDataExtractorProps,
|
|
10
|
+
ImageFileTypeProps,
|
|
11
|
+
MultiUploader,
|
|
12
|
+
Uploader,
|
|
13
|
+
UploaderBase,
|
|
14
|
+
UploaderBaseFieldProps,
|
|
15
|
+
UploaderHasFile,
|
|
16
|
+
useS3Client,
|
|
17
|
+
VideoFileTypeProps,
|
|
18
|
+
} from '@contember/react-uploader'
|
|
19
|
+
import * as React from 'react'
|
|
20
|
+
import { ReactNode, useId, useMemo, useState } from 'react'
|
|
21
|
+
import { FormContainer, FormContainerProps } from './container'
|
|
22
|
+
import { Component, DisconnectEntityTrigger, EntityView, useEntity } from '@contember/interface'
|
|
23
|
+
import { FormErrorContext, FormFieldIdContext } from '@contember/react-form'
|
|
24
|
+
import {
|
|
25
|
+
UploadedAnyView,
|
|
26
|
+
UploadedAudioView,
|
|
27
|
+
UploadedImageView,
|
|
28
|
+
UploadedVideoView,
|
|
29
|
+
UploaderDropzone,
|
|
30
|
+
UploaderItemUI,
|
|
31
|
+
UploaderRepeaterDragOverlayUI,
|
|
32
|
+
UploaderRepeaterHandleUI,
|
|
33
|
+
UploaderRepeaterItemsWrapperUI,
|
|
34
|
+
UploaderRepeaterItemUI,
|
|
35
|
+
} from '../upload'
|
|
36
|
+
import { UploaderProgress } from '../upload/upload-progress'
|
|
37
|
+
import { Repeater, RepeaterProps, RepeaterRemoveItemTrigger } from '@contember/react-repeater'
|
|
38
|
+
import { RepeaterSortable, RepeaterSortableDragOverlay, RepeaterSortableEachItem, RepeaterSortableItemActivator, RepeaterSortableItemNode } from '@contember/react-repeater-dnd-kit'
|
|
39
|
+
import { UploaderRepeaterDropIndicator } from '../upload/repeater'
|
|
40
|
+
|
|
41
|
+
export type BaseFieldProps =
|
|
42
|
+
& Omit<FormContainerProps, 'children'>
|
|
43
|
+
& UploaderBaseFieldProps
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
export type ImageFieldProps =
|
|
48
|
+
& BaseFieldProps
|
|
49
|
+
& ImageFileTypeProps
|
|
50
|
+
|
|
51
|
+
export const ImageField = Component<ImageFieldProps>(props => {
|
|
52
|
+
return (
|
|
53
|
+
<UploadFieldInner {...props} fileType={createImageFileType(props)}>
|
|
54
|
+
<UploaderItemUI>
|
|
55
|
+
<UploadedImageView {...props} DestroyAction={DisconnectEntityTrigger} />
|
|
56
|
+
</UploaderItemUI>
|
|
57
|
+
</UploadFieldInner>
|
|
58
|
+
)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
export type AudioFieldProps =
|
|
62
|
+
& BaseFieldProps
|
|
63
|
+
& AudioFileTypeProps
|
|
64
|
+
|
|
65
|
+
export const AudioField = Component<AudioFieldProps>(props => {
|
|
66
|
+
return (
|
|
67
|
+
<UploadFieldInner {...props} fileType={createAudioFileType(props)}>
|
|
68
|
+
<UploaderItemUI>
|
|
69
|
+
<UploadedAudioView {...props} DestroyAction={DisconnectEntityTrigger} />
|
|
70
|
+
</UploaderItemUI>
|
|
71
|
+
</UploadFieldInner>
|
|
72
|
+
)
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
export type VideoFieldProps =
|
|
77
|
+
& BaseFieldProps
|
|
78
|
+
& VideoFileTypeProps
|
|
79
|
+
|
|
80
|
+
export const VideoField = Component<VideoFieldProps>(props => {
|
|
81
|
+
return (
|
|
82
|
+
<UploadFieldInner {...props} fileType={createVideoFileType(props)}>
|
|
83
|
+
<UploaderItemUI>
|
|
84
|
+
<UploadedVideoView {...props} DestroyAction={DisconnectEntityTrigger} />
|
|
85
|
+
</UploaderItemUI>
|
|
86
|
+
</UploadFieldInner>
|
|
87
|
+
)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
export type FileFieldProps =
|
|
91
|
+
& BaseFieldProps
|
|
92
|
+
& AnyFileTypeProps
|
|
93
|
+
|
|
94
|
+
export const FileField = Component<FileFieldProps>(props => {
|
|
95
|
+
return (
|
|
96
|
+
<UploadFieldInner {...props} fileType={createAnyFileType(props)}>
|
|
97
|
+
<UploaderItemUI>
|
|
98
|
+
<UploadedAnyView {...props} DestroyAction={DisconnectEntityTrigger} />
|
|
99
|
+
</UploaderItemUI>
|
|
100
|
+
</UploadFieldInner>
|
|
101
|
+
)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
type UploadFieldInnerProps =
|
|
106
|
+
& BaseFieldProps
|
|
107
|
+
& FileUrlDataExtractorProps
|
|
108
|
+
& {
|
|
109
|
+
fileType: FileType
|
|
110
|
+
children: ReactNode
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const UploadFieldInner = Component((({ baseField, label, description, children, fileType, urlField }: UploadFieldInnerProps) => {
|
|
114
|
+
const entity = useEntity()
|
|
115
|
+
const defaultUploader = useS3Client()
|
|
116
|
+
const [fileTypeStable] = useState(fileType)
|
|
117
|
+
const fileTypeWithUploader = useMemo(
|
|
118
|
+
() => ({ ...fileTypeStable, uploader: fileTypeStable?.uploader ?? defaultUploader }),
|
|
119
|
+
[defaultUploader, fileTypeStable],
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
// const errors = type.extractors?.flatMap(it => it.getErrorsHolders?.({
|
|
123
|
+
// environment,
|
|
124
|
+
// entity,
|
|
125
|
+
// }) ?? []).flatMap(it => it.errors?.errors ?? [])
|
|
126
|
+
|
|
127
|
+
const id = useId()
|
|
128
|
+
return (
|
|
129
|
+
<FormFieldIdContext.Provider value={id}>
|
|
130
|
+
<FormErrorContext.Provider value={[]}>
|
|
131
|
+
<FormContainer description={description} label={label}>
|
|
132
|
+
<div className="flex">
|
|
133
|
+
|
|
134
|
+
<Uploader baseField={baseField} fileType={fileTypeWithUploader}>
|
|
135
|
+
<UploaderBase baseField={baseField}>
|
|
136
|
+
<UploaderHasFile>
|
|
137
|
+
<UploaderProgress />
|
|
138
|
+
</UploaderHasFile>
|
|
139
|
+
|
|
140
|
+
<EntityView render={entity => {
|
|
141
|
+
if (entity.getField(urlField).value === null) {
|
|
142
|
+
return <UploaderDropzone inactiveOnUpload />
|
|
143
|
+
} else {
|
|
144
|
+
return <>{children}</>
|
|
145
|
+
}
|
|
146
|
+
}} />
|
|
147
|
+
|
|
148
|
+
</UploaderBase>
|
|
149
|
+
</Uploader>
|
|
150
|
+
</div>
|
|
151
|
+
</FormContainer>
|
|
152
|
+
</FormErrorContext.Provider>
|
|
153
|
+
</FormFieldIdContext.Provider>
|
|
154
|
+
)
|
|
155
|
+
}), ({ fileType, children, baseField }) => {
|
|
156
|
+
return <>
|
|
157
|
+
{children}
|
|
158
|
+
<Uploader baseField={baseField} fileType={fileType}></Uploader>
|
|
159
|
+
</>
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
export type ImageRepeaterField =
|
|
166
|
+
& Omit<FormContainerProps, 'children'>
|
|
167
|
+
& RepeaterProps
|
|
168
|
+
& UploaderBaseFieldProps
|
|
169
|
+
& ImageFileTypeProps
|
|
170
|
+
& {
|
|
171
|
+
children?: React.ReactNode
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export const ImageRepeaterField = Component<ImageRepeaterField>(({ baseField, label, description, children, uploader, ...props }, environment) => {
|
|
175
|
+
const entity = useEntity()
|
|
176
|
+
const defaultUploader = useS3Client()
|
|
177
|
+
uploader ??= defaultUploader
|
|
178
|
+
const [type] = useState(() => createImageFileType({ uploader, ...props }))
|
|
179
|
+
// const errors = type.extractors?.flatMap(it => it.getErrorsHolders?.({
|
|
180
|
+
// environment,
|
|
181
|
+
// entity,
|
|
182
|
+
// }) ?? []).flatMap(it => it.errors?.errors ?? [])
|
|
183
|
+
const id = useId()
|
|
184
|
+
return (
|
|
185
|
+
<FormFieldIdContext.Provider value={id}>
|
|
186
|
+
<FormErrorContext.Provider value={[]}>
|
|
187
|
+
<FormContainer description={description} label={label}>
|
|
188
|
+
<Repeater {...props} initialEntityCount={0}>
|
|
189
|
+
<UploaderRepeaterItemsWrapperUI>
|
|
190
|
+
|
|
191
|
+
<MultiUploader baseField={baseField} fileType={type}>
|
|
192
|
+
<UploaderHasFile>
|
|
193
|
+
<UploaderProgress />
|
|
194
|
+
</UploaderHasFile>
|
|
195
|
+
<UploaderDropzone />
|
|
196
|
+
</MultiUploader>
|
|
197
|
+
|
|
198
|
+
<RepeaterSortable>
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
<RepeaterSortableEachItem>
|
|
202
|
+
<div className="flex">
|
|
203
|
+
<UploaderRepeaterDropIndicator position={'before'} />
|
|
204
|
+
<RepeaterSortableItemNode>
|
|
205
|
+
<UploaderRepeaterItemUI>
|
|
206
|
+
<RepeaterSortableItemActivator>
|
|
207
|
+
<UploaderRepeaterHandleUI />
|
|
208
|
+
</RepeaterSortableItemActivator>
|
|
209
|
+
<UploaderBase baseField={baseField}>
|
|
210
|
+
<UploadedImageView {...props} DestroyAction={RepeaterRemoveItemTrigger} />
|
|
211
|
+
</UploaderBase>
|
|
212
|
+
</UploaderRepeaterItemUI>
|
|
213
|
+
</RepeaterSortableItemNode>
|
|
214
|
+
<UploaderRepeaterDropIndicator position={'after'} />
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
</RepeaterSortableEachItem>
|
|
219
|
+
|
|
220
|
+
<RepeaterSortableDragOverlay>
|
|
221
|
+
<UploaderRepeaterDragOverlayUI>
|
|
222
|
+
<UploaderBase baseField={baseField}>
|
|
223
|
+
<UploadedImageView {...props} DestroyAction={RepeaterRemoveItemTrigger} />
|
|
224
|
+
</UploaderBase>
|
|
225
|
+
</UploaderRepeaterDragOverlayUI>
|
|
226
|
+
</RepeaterSortableDragOverlay>
|
|
227
|
+
|
|
228
|
+
</RepeaterSortable>
|
|
229
|
+
</UploaderRepeaterItemsWrapperUI>
|
|
230
|
+
</Repeater>
|
|
231
|
+
</FormContainer>
|
|
232
|
+
</FormErrorContext.Provider>
|
|
233
|
+
</FormFieldIdContext.Provider>
|
|
234
|
+
)
|
|
235
|
+
}, ({ baseField, label, description, children, ...props }) => {
|
|
236
|
+
const type = createImageFileType(props)
|
|
237
|
+
return <>
|
|
238
|
+
<Repeater {...props} initialEntityCount={0}>
|
|
239
|
+
<Uploader baseField={baseField} fileType={type}></Uploader>
|
|
240
|
+
<UploadedImageView {...props} >{children}</UploadedImageView>
|
|
241
|
+
</Repeater>
|
|
242
|
+
</>
|
|
243
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { dict } from '../dict'
|
|
2
|
+
|
|
3
|
+
export const formatDate = (date: string | null) => {
|
|
4
|
+
if (date === null) {
|
|
5
|
+
return null
|
|
6
|
+
}
|
|
7
|
+
const d = new Date(date)
|
|
8
|
+
return d.toLocaleDateString()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const formatDateTime = (date: string | null) => {
|
|
12
|
+
if (date === null) {
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
15
|
+
const d = new Date(date)
|
|
16
|
+
return d.toLocaleString()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const formatBoolean = (value: boolean | null) => {
|
|
20
|
+
if (value === null) {
|
|
21
|
+
return null
|
|
22
|
+
}
|
|
23
|
+
return value ? dict.boolean.true : dict.boolean.false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const createEnumFormatter = (enumValues: Record<string, string>) => (value: string | null) => {
|
|
27
|
+
if (value === null) {
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
return enumValues[value]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const withFallback =
|
|
34
|
+
<T>(formatter: (value: T) => string, fallback: string) =>
|
|
35
|
+
(value: T | null) => {
|
|
36
|
+
if (value === null) {
|
|
37
|
+
return fallback
|
|
38
|
+
}
|
|
39
|
+
return formatter(value)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const formatNumber = (value: number | null) => {
|
|
43
|
+
if (value === null) {
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
return value.toLocaleString()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const formatBytes = (bytes: number, decimals = 1) => {
|
|
50
|
+
if (bytes === 0) return '0 Bytes'
|
|
51
|
+
const k = 1024
|
|
52
|
+
const dm = decimals + 1 || 3
|
|
53
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
|
54
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
55
|
+
return `${Number.parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const formatDuration = (duration: number) => {
|
|
59
|
+
const minutes = Math.floor(duration / 60)
|
|
60
|
+
const seconds = duration % 60
|
|
61
|
+
return `${minutes}:${seconds.toString().padStart(2, '0')}`
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './formatting'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface ImageResizeOptions {
|
|
2
|
+
width?: number
|
|
3
|
+
height?: number
|
|
4
|
+
blur?: number
|
|
5
|
+
quality?: number
|
|
6
|
+
fit?: 'scale-down' | 'contain' | 'cover' | 'crop' | 'pad'
|
|
7
|
+
format?: 'auto' | 'avif' | 'webp' | 'jpeg' | 'baseline-jpeg' | 'json'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const formatImageResizeUrl = (src: string, options?: ImageResizeOptions) => {
|
|
11
|
+
const url = new URL(src)
|
|
12
|
+
|
|
13
|
+
if (!url.origin.includes('cntmbr.com')) {
|
|
14
|
+
return src
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const { fit, format, ...rest } = options || {}
|
|
18
|
+
const resizeOptions = { ...rest, fit: fit || 'contain', f: format || 'auto' }
|
|
19
|
+
|
|
20
|
+
const urlOptions = Object.keys(resizeOptions).map(key => `${key}=${resizeOptions[key as keyof typeof resizeOptions]}`).join(',')
|
|
21
|
+
|
|
22
|
+
return `${url.origin}/cdn-cgi/image/${urlOptions}${url.pathname}`
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './formatImageResizeUrl'
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { LogOutIcon, Maximize2Icon, MenuIcon, Minimize2Icon, PanelLeftCloseIcon, PanelLeftOpenIcon, PanelRightCloseIcon, PanelRightOpenIcon } from 'lucide-react'
|
|
2
|
+
import { PropsWithChildren, useEffect, useState } from 'react'
|
|
3
|
+
import { useHasActiveSlotsFactory } from '@contember/react-slots'
|
|
4
|
+
import { uic } from '../utils/uic'
|
|
5
|
+
import { SlotTargets } from './slots'
|
|
6
|
+
import { Button } from '../ui/button'
|
|
7
|
+
import { LogoutTrigger } from '@contember/react-identity'
|
|
8
|
+
import { dict } from '../dict'
|
|
9
|
+
import { useCurrentRequest } from '@contember/interface'
|
|
10
|
+
|
|
11
|
+
const LayoutBodyUI = uic('div', { baseClass: 'bg-gray-50 h-full min-h-screen relative py-4 pl-[calc(100vw-100%)]' })
|
|
12
|
+
const LayoutMaxWidthUI = uic('div', {
|
|
13
|
+
baseClass: 'mx-auto transition-all',
|
|
14
|
+
variants: {
|
|
15
|
+
layout: {
|
|
16
|
+
stretch: 'max-w-[calc(100vw-5rem)]',
|
|
17
|
+
default: 'max-w-[100rem]',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
layout: 'default',
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
const LayoutBoxUI = uic('div', { baseClass: 'rounded-xl shadow-lg border bg-white gap-1 flex flex-col lg:flex-row mt-4 relative min-h-[calc(100vh-10rem)]' })
|
|
25
|
+
|
|
26
|
+
const LayoutCenterPanelUI = uic('div', { baseClass: 'flex flex-col flex-2 p-4 gap-2 w-full flex-auto overflow-hidden' })
|
|
27
|
+
const LayoutCenterTopUI = uic('div', { baseClass: 'flex justify-between pb-4 mb-4 border-b' })
|
|
28
|
+
|
|
29
|
+
const LayoutLeftSidebarUI = uic('div', {
|
|
30
|
+
baseClass: 'flex-col lg:border-r bg-neutral-50 border-r-gray-300 lg:w-96 flex-auto gap-2 relative rounded-l-xl',
|
|
31
|
+
variants: {
|
|
32
|
+
visibility: {
|
|
33
|
+
show: 'flex',
|
|
34
|
+
hidden: 'hidden',
|
|
35
|
+
auto: 'hidden lg:flex',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
defaultVariants: {
|
|
39
|
+
visibility: 'auto',
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
const LayoutRightSidebarUI = uic('div', {
|
|
43
|
+
baseClass: ' flex-col p-4 pt-6 gap-2 lg:border-l border-l-gray-300 lg:w-96 flex-auto relative',
|
|
44
|
+
variants: {
|
|
45
|
+
visibility: {
|
|
46
|
+
show: 'flex',
|
|
47
|
+
hidden: 'hidden',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
defaultVariants: {
|
|
51
|
+
visibility: 'show',
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const LayoutTitleUI = uic('h1', { baseClass: 'text-2xl font-bold' })
|
|
56
|
+
|
|
57
|
+
const LayoutFooterUI = uic('div', { baseClass: 'flex justify-end mt-2 mx-4' })
|
|
58
|
+
|
|
59
|
+
const LayoutLeftPanelCloserUI = uic('a', { baseClass: 'hidden lg:flex self-end absolute top-1 right-1 opacity-0 text-gray-400 hover:opacity-100 transition-opacity cursor-pointer' })
|
|
60
|
+
const LayoutLeftPanelOpenerUI = uic('a', { baseClass: 'hidden lg:block absolute top-1 left-1' })
|
|
61
|
+
const LayoutRightPanelCloserUI = uic('a', { baseClass: 'hidden lg:flex self-end absolute top-1 right-1 opacity-0 text-gray-400 hover:opacity-100 transition-opacity cursor-pointer' })
|
|
62
|
+
const LayoutRightPanelOpenerUI = uic('a', { baseClass: 'absolute top-1 right-1' })
|
|
63
|
+
const LayoutSwitcherUI = uic('a', { baseClass: 'hidden lg:flex self-end absolute top-1 right-1 opacity-20 text-gray-400 hover:opacity-100 transition-opacity cursor-pointer' })
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
export const LayoutComponent = ({ children, ...rest }: PropsWithChildren<{}>) => {
|
|
67
|
+
const isActive = useHasActiveSlotsFactory()
|
|
68
|
+
|
|
69
|
+
const [leftSidebarVisibility, setLeftSidebarVisibility] = useState<'show' | 'hidden' | 'auto'>('auto')
|
|
70
|
+
const [layout, setLayout] = useState<'default' | 'stretch'>('default')
|
|
71
|
+
|
|
72
|
+
const request = useCurrentRequest()
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
setLeftSidebarVisibility(it => it === 'show' ? 'auto' : it)
|
|
75
|
+
}, [request])
|
|
76
|
+
|
|
77
|
+
const [rightSidebarVisibility, setRightSidebarVisibility] = useState<'show' | 'hidden'>('show')
|
|
78
|
+
|
|
79
|
+
const hasRightSidebar = isActive('SidebarRightHeader', 'SidebarRightBody', 'SidebarRightFooter', 'Sidebar')
|
|
80
|
+
return (
|
|
81
|
+
<LayoutBodyUI>
|
|
82
|
+
<LayoutSwitcherUI className="absolute top-0.5 right-0.5" onClick={() => setLayout(it => it === 'default' ? 'stretch' : 'default')}>
|
|
83
|
+
{layout === 'default' ? <Maximize2Icon /> : <Minimize2Icon />}
|
|
84
|
+
</LayoutSwitcherUI>
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
<LayoutMaxWidthUI layout={layout}>
|
|
88
|
+
<LayoutBoxUI>
|
|
89
|
+
{leftSidebarVisibility === 'hidden' && (
|
|
90
|
+
<LayoutLeftPanelOpenerUI onClick={() => setLeftSidebarVisibility('auto')}>
|
|
91
|
+
<PanelLeftOpenIcon className="w-4 h-4" />
|
|
92
|
+
</LayoutLeftPanelOpenerUI>
|
|
93
|
+
)}
|
|
94
|
+
{hasRightSidebar && rightSidebarVisibility === 'hidden' ? (
|
|
95
|
+
<LayoutRightPanelOpenerUI onClick={() => setRightSidebarVisibility('show')}>
|
|
96
|
+
<PanelRightOpenIcon className="w-4 h-4" />
|
|
97
|
+
</LayoutRightPanelOpenerUI>
|
|
98
|
+
) : null}
|
|
99
|
+
|
|
100
|
+
<LayoutLeftSidebarUI visibility={leftSidebarVisibility}>
|
|
101
|
+
|
|
102
|
+
<LayoutLeftPanelCloserUI onClick={() => setLeftSidebarVisibility('hidden')}>
|
|
103
|
+
<PanelLeftCloseIcon className="w-4 h-4" />
|
|
104
|
+
</LayoutLeftPanelCloserUI>
|
|
105
|
+
|
|
106
|
+
<div className={'p-4 flex gap-2'}>
|
|
107
|
+
<SlotTargets.Logo />
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div className="px-4">
|
|
111
|
+
<SlotTargets.Navigation />
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
<div className={'mt-auto rounded-bl py-2 px-2 border-t'}>
|
|
115
|
+
<LogoutTrigger>
|
|
116
|
+
<Button variant={'ghost'} size="sm" className="gap-2 hover:underline">
|
|
117
|
+
<LogOutIcon className="w-3 h-3 text-gray-500" /> {dict.logout}
|
|
118
|
+
</Button>
|
|
119
|
+
</LogoutTrigger>
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
</LayoutLeftSidebarUI>
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
<LayoutCenterPanelUI>
|
|
126
|
+
<LayoutCenterTopUI>
|
|
127
|
+
<div className={'flex gap-2'}>
|
|
128
|
+
<SlotTargets.Back />
|
|
129
|
+
<SlotTargets.Title as={LayoutTitleUI} />
|
|
130
|
+
</div>
|
|
131
|
+
<SlotTargets.ContentHeader />
|
|
132
|
+
<div className={'flex gap-2'}>
|
|
133
|
+
<SlotTargets.Actions />
|
|
134
|
+
<div className={'flex flex-col lg:hidden p-4 gap-2 w-full flex-auto'}>
|
|
135
|
+
<a onClick={() => setLeftSidebarVisibility(it => it !== 'show' ? 'show' : 'auto')}><MenuIcon /></a>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
</LayoutCenterTopUI>
|
|
139
|
+
|
|
140
|
+
<div>
|
|
141
|
+
{children}
|
|
142
|
+
</div>
|
|
143
|
+
</LayoutCenterPanelUI>
|
|
144
|
+
{hasRightSidebar ?
|
|
145
|
+
<LayoutRightSidebarUI visibility={rightSidebarVisibility ? 'show' : 'hidden'}>
|
|
146
|
+
<LayoutRightPanelCloserUI onClick={() => setRightSidebarVisibility('hidden')}>
|
|
147
|
+
<PanelRightCloseIcon />
|
|
148
|
+
</LayoutRightPanelCloserUI>
|
|
149
|
+
<div>
|
|
150
|
+
<SlotTargets.Sidebar />
|
|
151
|
+
</div>
|
|
152
|
+
</LayoutRightSidebarUI>
|
|
153
|
+
: null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
</LayoutBoxUI>
|
|
157
|
+
|
|
158
|
+
<LayoutFooterUI>
|
|
159
|
+
<div>
|
|
160
|
+
<SlotTargets.Footer />
|
|
161
|
+
</div>
|
|
162
|
+
</LayoutFooterUI>
|
|
163
|
+
</LayoutMaxWidthUI>
|
|
164
|
+
</LayoutBodyUI>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
LayoutComponent.displayName = 'Layout'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createSlotComponents } from '@contember/react-slots'
|
|
2
|
+
import { useChildrenAsLabel, useDocumentTitle } from '@contember/react-utils'
|
|
3
|
+
import { memo, ReactNode } from 'react'
|
|
4
|
+
|
|
5
|
+
export const [, Slots, SlotTargets] = createSlotComponents([
|
|
6
|
+
'Title',
|
|
7
|
+
'Logo',
|
|
8
|
+
'Navigation',
|
|
9
|
+
'Footer',
|
|
10
|
+
'Back',
|
|
11
|
+
'Content',
|
|
12
|
+
'ContentHeader',
|
|
13
|
+
'Sidebar',
|
|
14
|
+
'Actions',
|
|
15
|
+
])
|
|
16
|
+
export const Title = memo<{ children: ReactNode }>(({ children }) => {
|
|
17
|
+
const titleText = useChildrenAsLabel(children)
|
|
18
|
+
useDocumentTitle(titleText)
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Slots.Title>{children}</Slots.Title>
|
|
22
|
+
)
|
|
23
|
+
})
|
|
24
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './outdated-application-dialog'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ComponentType, useCallback, useState } from 'react'
|
|
2
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader } from '../ui/alert-dialog'
|
|
3
|
+
import { useIsApplicationOutdated } from '@contember/interface'
|
|
4
|
+
import { ClockIcon, RefreshCwIcon } from 'lucide-react'
|
|
5
|
+
import { dict } from '../dict'
|
|
6
|
+
|
|
7
|
+
const postponeTimeoutMs = 60_000 * 5
|
|
8
|
+
const checkIntervalMs = 30_000
|
|
9
|
+
|
|
10
|
+
export const OutdatedApplicationDialog: ComponentType = () => {
|
|
11
|
+
const isOutdated = useIsApplicationOutdated({ checkIntervalMs })
|
|
12
|
+
const [open, setOpen] = useState(true)
|
|
13
|
+
|
|
14
|
+
const postpone = useCallback(() => {
|
|
15
|
+
setOpen(false)
|
|
16
|
+
setTimeout(() => setOpen(true), postponeTimeoutMs)
|
|
17
|
+
}, [])
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<AlertDialog open={isOutdated && open} onOpenChange={it => !it ? postpone() : null}>
|
|
21
|
+
<AlertDialogContent>
|
|
22
|
+
<AlertDialogHeader>{dict.outdatedApplication.title}</AlertDialogHeader>
|
|
23
|
+
<AlertDialogDescription>{dict.outdatedApplication.description}</AlertDialogDescription>
|
|
24
|
+
|
|
25
|
+
<div className="text-sm text-destructive">{dict.outdatedApplication.warning}</div>
|
|
26
|
+
<AlertDialogFooter>
|
|
27
|
+
<AlertDialogCancel onClick={postpone} className="gap-1">
|
|
28
|
+
<ClockIcon className="w-3 h-4"/>
|
|
29
|
+
{dict.outdatedApplication.snooze}
|
|
30
|
+
</AlertDialogCancel>
|
|
31
|
+
<AlertDialogAction onClick={() => window.location.reload()} className="gap-1">
|
|
32
|
+
<RefreshCwIcon className="w-3 h-4" />
|
|
33
|
+
{dict.outdatedApplication.refreshNow}
|
|
34
|
+
</AlertDialogAction>
|
|
35
|
+
</AlertDialogFooter>
|
|
36
|
+
</AlertDialogContent>
|
|
37
|
+
</AlertDialog>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './repeater'
|