@contember/create 2.1.0-beta.2 → 2.2.0-alpha.1
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/run.cjs.map +1 -1
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +2 -2
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/FileSystem.cjs +1 -2
- package/dist/development/src/lib/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/FileSystem.js +1 -2
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +16 -16
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/development/src/lib/version.cjs +2 -2
- package/dist/development/src/lib/version.cjs.map +1 -1
- package/dist/development/src/lib/version.js.map +1 -1
- package/dist/development/src/paths.cjs +3 -3
- package/dist/development/src/paths.cjs.map +1 -1
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +2 -2
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/FileSystem.cjs +1 -2
- package/dist/production/src/lib/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/FileSystem.js +1 -2
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +16 -16
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/production/src/lib/version.cjs +2 -2
- package/dist/production/src/lib/version.cjs.map +1 -1
- package/dist/production/src/lib/version.js.map +1 -1
- package/dist/production/src/paths.cjs +3 -3
- package/dist/production/src/paths.cjs.map +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/index.d.ts.map +1 -1
- package/dist/types/lib/FileSystem.d.ts +3 -2
- package/dist/types/lib/FileSystem.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/resources/templates/default/admin/lib/binding/binding.tsx +19 -4
- package/resources/templates/default/admin/lib/binding/delete.tsx +37 -3
- package/resources/templates/default/admin/lib/binding/hooks.tsx +65 -3
- package/resources/templates/default/admin/lib/binding/identity.tsx +17 -4
- package/resources/templates/default/admin/lib/binding/index.ts +5 -5
- package/resources/templates/default/admin/lib/binding/navigation-guard-dialog.tsx +15 -3
- package/resources/templates/default/admin/lib/binding/persist.tsx +27 -5
- package/resources/templates/default/admin/lib/block-repeater/block-repeater.tsx +15 -11
- package/resources/templates/default/admin/lib/block-repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/board/board.tsx +2 -2
- package/resources/templates/default/admin/lib/board/index.ts +1 -1
- package/resources/templates/default/admin/lib/buttons/back-button.tsx +22 -2
- package/resources/templates/default/admin/lib/buttons/index.ts +2 -2
- package/resources/templates/default/admin/lib/buttons/link-back-button.tsx +11 -2
- package/resources/templates/default/admin/lib/datagrid/cells.tsx +3 -3
- package/resources/templates/default/admin/lib/datagrid/column-header.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/columns.tsx +28 -14
- package/resources/templates/default/admin/lib/datagrid/elements.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/empty.tsx +1 -1
- package/resources/templates/default/admin/lib/datagrid/export.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/boolean.tsx +13 -13
- package/resources/templates/default/admin/lib/datagrid/filters/common.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/date.tsx +37 -16
- package/resources/templates/default/admin/lib/datagrid/filters/defined.tsx +13 -12
- package/resources/templates/default/admin/lib/datagrid/filters/enum.tsx +56 -22
- package/resources/templates/default/admin/lib/datagrid/filters/index.ts +7 -7
- package/resources/templates/default/admin/lib/datagrid/filters/mobile.tsx +18 -0
- package/resources/templates/default/admin/lib/datagrid/filters/number.tsx +10 -13
- package/resources/templates/default/admin/lib/datagrid/filters/relation.tsx +8 -8
- package/resources/templates/default/admin/lib/datagrid/filters/text.tsx +9 -9
- package/resources/templates/default/admin/lib/datagrid/grid.tsx +31 -23
- package/resources/templates/default/admin/lib/datagrid/index.ts +12 -12
- package/resources/templates/default/admin/lib/datagrid/labels.tsx +22 -4
- package/resources/templates/default/admin/lib/datagrid/layout-switcher.tsx +10 -4
- package/resources/templates/default/admin/lib/datagrid/loader.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/pagination.tsx +16 -6
- package/resources/templates/default/admin/lib/datagrid/table.tsx +8 -6
- package/resources/templates/default/admin/lib/datagrid/tiles.tsx +6 -5
- package/resources/templates/default/admin/lib/datagrid/toolbar.tsx +15 -19
- package/resources/templates/default/admin/lib/datagrid/ui.tsx +3 -3
- package/resources/templates/default/admin/lib/dev/index.ts +2 -2
- package/resources/templates/default/admin/lib/dev/login-panel.tsx +12 -3
- package/resources/templates/default/admin/lib/dev/todo.tsx +12 -0
- package/resources/templates/default/admin/lib/dict.ts +0 -261
- package/resources/templates/default/admin/lib/dimensions/dimensions.tsx +85 -4
- package/resources/templates/default/admin/lib/dimensions/index.ts +1 -1
- package/resources/templates/default/admin/lib/editor/block-editor.tsx +72 -3
- package/resources/templates/default/admin/lib/editor/common/baseEditorPlugins.tsx +54 -11
- package/resources/templates/default/admin/lib/editor/common/buttons.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/editor-block-toolbar.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HeadingRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/ListItemRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/OrderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/TableElementRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/editor-block.tsx +54 -3
- package/resources/templates/default/admin/lib/editor/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/plugins.tsx +46 -2
- package/resources/templates/default/admin/lib/editor/rich-text-view.tsx +44 -0
- package/resources/templates/default/admin/lib/editor/rich-text.tsx +31 -3
- package/resources/templates/default/admin/lib/editor/sortable-block.tsx +34 -2
- package/resources/templates/default/admin/lib/errors/index.ts +1 -1
- package/resources/templates/default/admin/lib/errors/use-error-formatter.ts +22 -1
- package/resources/templates/default/admin/lib/field/formatted-field.tsx +16 -1
- package/resources/templates/default/admin/lib/field/index.ts +2 -1
- package/resources/templates/default/admin/lib/field/list-field.tsx +56 -0
- package/resources/templates/default/admin/lib/form/container.tsx +33 -3
- package/resources/templates/default/admin/lib/form/index.ts +6 -5
- package/resources/templates/default/admin/lib/form/inputs.tsx +105 -6
- package/resources/templates/default/admin/lib/form/labels.tsx +1 -1
- package/resources/templates/default/admin/lib/form/select.tsx +162 -5
- package/resources/templates/default/admin/lib/form/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/form/upload-repeaters.tsx +159 -5
- package/resources/templates/default/admin/lib/form/upload.tsx +116 -3
- package/resources/templates/default/admin/lib/formatting/formatting.ts +106 -1
- package/resources/templates/default/admin/lib/formatting/index.ts +1 -1
- package/resources/templates/default/admin/lib/images/formatImageResizeUrl.ts +19 -0
- package/resources/templates/default/admin/lib/images/index.ts +1 -1
- package/resources/templates/default/admin/lib/index.ts +54 -0
- package/resources/templates/default/admin/lib/labels/index.ts +2 -2
- package/resources/templates/default/admin/lib/layout/index.ts +3 -3
- package/resources/templates/default/admin/lib/layout/layout-boxed.tsx +5 -5
- package/resources/templates/default/admin/lib/layout/layout.tsx +3 -3
- package/resources/templates/default/admin/lib/outdated-application-dialog/index.ts +1 -1
- package/resources/templates/default/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/repeater/repeater.tsx +26 -9
- package/resources/templates/default/admin/lib/select/create-new.tsx +19 -3
- package/resources/templates/default/admin/lib/select/filter.tsx +8 -2
- package/resources/templates/default/admin/lib/select/highlight.tsx +16 -0
- package/resources/templates/default/admin/lib/select/index.ts +6 -6
- package/resources/templates/default/admin/lib/select/list.tsx +30 -6
- package/resources/templates/default/admin/lib/select/multi-select.tsx +41 -4
- package/resources/templates/default/admin/lib/select/select.tsx +44 -6
- package/resources/templates/default/admin/lib/select/sortable-select.tsx +15 -6
- package/resources/templates/default/admin/lib/select/ui.tsx +100 -4
- package/resources/templates/default/admin/lib/tenant/dict.ts +324 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-password.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +3 -3
- package/resources/templates/default/admin/lib/tenant/forms/confirm-email-change.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/forms/create-api-key.tsx +5 -5
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +12 -8
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +5 -5
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/password-reset-request.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/password-reset.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin-init.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/request-email-verification.tsx +35 -0
- package/resources/templates/default/admin/lib/tenant/forms/update-project-member.tsx +14 -5
- package/resources/templates/default/admin/lib/tenant/forms/verify-email.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInvite.ts +41 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInviteUser.tsx +32 -3
- package/resources/templates/default/admin/lib/tenant/index.ts +3 -3
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +3 -3
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +4 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +3 -3
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +8 -8
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +1 -1
- package/resources/templates/default/admin/lib/tenant/otp/otp-setup.tsx +6 -6
- package/resources/templates/default/admin/lib/toast/index.ts +2 -2
- package/resources/templates/default/admin/lib/toast/toast.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/alert-dialog.tsx +114 -3
- package/resources/templates/default/admin/lib/ui/avatar.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/button.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/card.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/collapsible.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/dimension.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/divider.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dropdown.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/input.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/label.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/loader.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/menu.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/overlay.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/popover.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/progress.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/property-list.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/scroll-area.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/select.tsx +44 -2
- package/resources/templates/default/admin/lib/ui/separator.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sheet.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/sidebar.tsx +8 -8
- package/resources/templates/default/admin/lib/ui/skeleton.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sortable.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/switch.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/table.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/textarea.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/toggle-group.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/toggle.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/tooltip.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/dropzone.tsx +20 -3
- package/resources/templates/default/admin/lib/upload/index.ts +3 -3
- package/resources/templates/default/admin/lib/upload/repeater.tsx +5 -1
- package/resources/templates/default/admin/lib/upload/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/upload-progress.tsx +6 -6
- package/resources/templates/default/admin/lib/upload/view.tsx +4 -4
- package/resources/templates/default/admin/lib/utils/cn.ts +18 -0
- package/resources/templates/default/admin/lib/utils/createComponentOpenHooks.tsx +33 -0
- package/resources/templates/default/admin/lib/utils/index.ts +2 -2
- package/resources/templates/default/admin/lib/utils/uic.tsx +59 -0
- package/resources/templates/default/admin/lib/utils/use-mobile.ts +19 -0
- package/resources/templates/default/scripts/assemble-ui-lib.mjs +132 -0
- package/resources/templates/default/scripts/update-ui-lib.sh +101 -185
- package/src/commands/WorkspaceCreateCommand.ts +3 -3
- package/src/commands/index.ts +1 -1
- package/src/lib/FileSystem.ts +2 -2
- package/src/lib/TemplateInstaller.ts +1 -1
- package/src/lib/version.ts +1 -1
- package/src/run.ts +4 -4
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
} from '@contember/react-uploader'
|
|
19
19
|
import * as React from 'react'
|
|
20
20
|
import { ReactNode, useMemo, useState } from 'react'
|
|
21
|
-
import { FormContainer, FormContainerProps } from './container'
|
|
21
|
+
import { FormContainer, FormContainerProps } from './container.js'
|
|
22
22
|
import { Component, DisconnectEntityTrigger, EntityView, useEntity } from '@contember/interface'
|
|
23
23
|
import { FormFieldStateProvider } from '@contember/react-form'
|
|
24
|
-
import { UploadedAnyView, UploadedAudioView, UploadedImageView, UploadedVideoView, UploaderDropzone, UploaderItemUI } from '../upload'
|
|
25
|
-
import { UploaderProgress } from '../upload/upload-progress'
|
|
24
|
+
import { UploadedAnyView, UploadedAudioView, UploadedImageView, UploadedVideoView, UploaderDropzone, UploaderItemUI } from '../upload/index.js'
|
|
25
|
+
import { UploaderProgress } from '../upload/upload-progress.js'
|
|
26
26
|
|
|
27
27
|
export type BaseUploadFieldProps =
|
|
28
28
|
& Omit<FormContainerProps, 'children'>
|
|
@@ -39,6 +39,44 @@ export type ImageFieldProps =
|
|
|
39
39
|
& BaseUploadFieldProps
|
|
40
40
|
& ImageFileTypeProps
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* ImageField component - Specialized file upload for images
|
|
44
|
+
*
|
|
45
|
+
* ## Requirements
|
|
46
|
+
* - Must be used within an Entity context (`<EntitySubTree />` or `<EntityListSubTree />`).
|
|
47
|
+
*
|
|
48
|
+
* ## Features
|
|
49
|
+
* - Handles image file uploads with preview
|
|
50
|
+
* - Supports common image formats (from ImageFileTypeProps)
|
|
51
|
+
* - Integrated drag-and-drop zone
|
|
52
|
+
* - Auto-generated preview using UploadedImageView
|
|
53
|
+
* - Optional custom destruction control
|
|
54
|
+
*
|
|
55
|
+
* ## Example: Basic usage
|
|
56
|
+
* ```tsx
|
|
57
|
+
* <ImageField
|
|
58
|
+
* label="Profile Picture"
|
|
59
|
+
* urlField="avatar.url"
|
|
60
|
+
* dropzonePlaceholder="Drag image here"
|
|
61
|
+
* />
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* ## Example: With baseField and metadata fields
|
|
65
|
+
* ```tsx
|
|
66
|
+
* <ImageField
|
|
67
|
+
* baseField="image"
|
|
68
|
+
* urlField="url"
|
|
69
|
+
* widthField="width"
|
|
70
|
+
* heightField="height"
|
|
71
|
+
* fileNameField="fileName"
|
|
72
|
+
* fileSizeField="fileSize"
|
|
73
|
+
* fileTypeField="fileType"
|
|
74
|
+
* lastModifiedField="lastModified"
|
|
75
|
+
* label="Image file"
|
|
76
|
+
* description="Some description of the image file."
|
|
77
|
+
* />
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
42
80
|
export const ImageField = Component<ImageFieldProps>(props => (
|
|
43
81
|
<UploadFieldInner {...props} fileType={createImageFileType(props)}>
|
|
44
82
|
{props.children ?? <UploadedImageView {...props} DestroyAction={DisconnectEntityTrigger} />}
|
|
@@ -49,6 +87,32 @@ export type AudioFieldProps =
|
|
|
49
87
|
& BaseUploadFieldProps
|
|
50
88
|
& AudioFileTypeProps
|
|
51
89
|
|
|
90
|
+
/**
|
|
91
|
+
* `AudioField` is a specialized upload component for handling audio files. It provides built-in file validation, an audio preview, and metadata tracking.
|
|
92
|
+
*
|
|
93
|
+
* ## Example: Basic usage
|
|
94
|
+
* ```tsx
|
|
95
|
+
* <AudioField
|
|
96
|
+
* label="Podcast File"
|
|
97
|
+
* urlField="audio.url"
|
|
98
|
+
* />
|
|
99
|
+
* ```
|
|
100
|
+
*
|
|
101
|
+
* ## Example: With metadata fields
|
|
102
|
+
* ```tsx
|
|
103
|
+
* <AudioField
|
|
104
|
+
* label="Podcast File"
|
|
105
|
+
* baseField="audio"
|
|
106
|
+
* urlField="url"
|
|
107
|
+
* durationField="duration"
|
|
108
|
+
* fileNameField="fileName"
|
|
109
|
+
* fileSizeField="fileSize"
|
|
110
|
+
* fileTypeField="fileType"
|
|
111
|
+
* lastModifiedField="lastModified"
|
|
112
|
+
* accept={{ 'audio/*': ['.mp3', '.wav', '.ogg'] }}
|
|
113
|
+
* />
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
52
116
|
export const AudioField = Component<AudioFieldProps>(props => (
|
|
53
117
|
<UploadFieldInner {...props} fileType={createAudioFileType(props)}>
|
|
54
118
|
{props.children ?? <UploadedAudioView {...props} DestroyAction={DisconnectEntityTrigger} />}
|
|
@@ -59,6 +123,32 @@ export type VideoFieldProps =
|
|
|
59
123
|
& BaseUploadFieldProps
|
|
60
124
|
& VideoFileTypeProps
|
|
61
125
|
|
|
126
|
+
/**
|
|
127
|
+
* `VideoField` is a specialized upload component for handling video files with built-in preview capabilities.
|
|
128
|
+
*
|
|
129
|
+
* ## Example: Basic usage
|
|
130
|
+
* ```tsx
|
|
131
|
+
* <VideoField
|
|
132
|
+
* label="Demo Video"
|
|
133
|
+
* urlField="video.url"
|
|
134
|
+
* />
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* ## Example: With metadata fields
|
|
138
|
+
* ```tsx
|
|
139
|
+
* <VideoField
|
|
140
|
+
* label="Demo Video"
|
|
141
|
+
* baseField="video"
|
|
142
|
+
* urlField="url"
|
|
143
|
+
* durationField="duration"
|
|
144
|
+
* fileNameField="fileName"
|
|
145
|
+
* fileSizeField="fileSize"
|
|
146
|
+
* fileTypeField="fileType"
|
|
147
|
+
* lastModifiedField="lastModified"
|
|
148
|
+
* accept={{ 'video/*': ['.mp4', '.webm', '.ogg'] }}
|
|
149
|
+
* />
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
62
152
|
export const VideoField = Component<VideoFieldProps>(props => (
|
|
63
153
|
<UploadFieldInner {...props} fileType={createVideoFileType(props)}>
|
|
64
154
|
{props.children ?? <UploadedVideoView {...props} DestroyAction={DisconnectEntityTrigger} />}
|
|
@@ -69,6 +159,29 @@ export type FileFieldProps =
|
|
|
69
159
|
& BaseUploadFieldProps
|
|
70
160
|
& AnyFileTypeProps
|
|
71
161
|
|
|
162
|
+
/**
|
|
163
|
+
* `FileField` is a generic file upload component that supports any file type.
|
|
164
|
+
*
|
|
165
|
+
* ## Example: Basic usage
|
|
166
|
+
* ```tsx
|
|
167
|
+
* <FileField label="Document" urlField="file.url" />
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* ## Example: With metadata fields and custom dropzone placeholder
|
|
171
|
+
* ```tsx
|
|
172
|
+
* <FileField
|
|
173
|
+
* label="Document"
|
|
174
|
+
* baseField="document"
|
|
175
|
+
* urlField="file.url"
|
|
176
|
+
* fileNameField="fileName"
|
|
177
|
+
* fileSizeField="fileSize"
|
|
178
|
+
* fileTypeField="fileType"
|
|
179
|
+
* lastModifiedField="lastModified"
|
|
180
|
+
* dropzonePlaceholder="Drag PDF here"
|
|
181
|
+
* accept={{ 'application/*': ['.pdf'] }}
|
|
182
|
+
* />
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
72
185
|
export const FileField = Component<FileFieldProps>(props => (
|
|
73
186
|
<UploadFieldInner {...props} fileType={createAnyFileType(props)}>
|
|
74
187
|
{props.children ?? <UploadedAnyView {...props} DestroyAction={DisconnectEntityTrigger} />}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { SchemaColumn } from '@contember/interface'
|
|
2
|
-
import { dict } from '
|
|
2
|
+
import { dict } from '~/lib'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Formats a date string into a localized date format.
|
|
6
|
+
*
|
|
7
|
+
* Converts ISO date strings to human-readable date format using browser locale settings.
|
|
8
|
+
* Handles null values gracefully.
|
|
9
|
+
*
|
|
10
|
+
* ## Example
|
|
11
|
+
* ```ts
|
|
12
|
+
* formatDate('2023-10-05') // '10/5/2023' (en-US locale)
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
4
15
|
export const formatDate = (date: string | null) => {
|
|
5
16
|
if (date === null) {
|
|
6
17
|
return null
|
|
@@ -9,6 +20,16 @@ export const formatDate = (date: string | null) => {
|
|
|
9
20
|
return d.toLocaleDateString()
|
|
10
21
|
}
|
|
11
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Formats a date string with a time component in a localized format.
|
|
25
|
+
*
|
|
26
|
+
* Shows both date and time including hours, minutes, and seconds. Respects system timezone.
|
|
27
|
+
*
|
|
28
|
+
* ## Example
|
|
29
|
+
* ```ts
|
|
30
|
+
* formatDateTime('2023-10-05T14:30:00') // '10/5/2023, 2:30:00 PM'
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
12
33
|
export const formatDateTime = (date: string | null) => {
|
|
13
34
|
if (date === null) {
|
|
14
35
|
return null
|
|
@@ -17,6 +38,16 @@ export const formatDateTime = (date: string | null) => {
|
|
|
17
38
|
return d.toLocaleString()
|
|
18
39
|
}
|
|
19
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Converts boolean values to localized strings using the application dictionary.
|
|
43
|
+
*
|
|
44
|
+
* Returns null for null input.
|
|
45
|
+
*
|
|
46
|
+
* ## Example
|
|
47
|
+
* ```ts
|
|
48
|
+
* formatBoolean(true) // 'Yes' (depending on dict)
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
20
51
|
export const formatBoolean = (value: boolean | null) => {
|
|
21
52
|
if (value === null) {
|
|
22
53
|
return null
|
|
@@ -24,6 +55,17 @@ export const formatBoolean = (value: boolean | null) => {
|
|
|
24
55
|
return value ? dict.boolean.true : dict.boolean.false
|
|
25
56
|
}
|
|
26
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Factory function that creates an enum value to label converter.
|
|
60
|
+
*
|
|
61
|
+
* Maps enum keys to human-readable labels. Handles null values and is case-sensitive.
|
|
62
|
+
*
|
|
63
|
+
* ## Example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const formatStatus = createEnumFormatter({ DRAFT: 'Draft', PUBLISHED: 'Published' })
|
|
66
|
+
* formatStatus('DRAFT') // 'Draft'
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
27
69
|
export const createEnumFormatter = (enumValues: Record<string, string>) => (value: string | null) => {
|
|
28
70
|
if (value === null) {
|
|
29
71
|
return null
|
|
@@ -31,6 +73,15 @@ export const createEnumFormatter = (enumValues: Record<string, string>) => (valu
|
|
|
31
73
|
return enumValues[value]
|
|
32
74
|
}
|
|
33
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Wraps a formatter to provide a fallback value for null inputs.
|
|
78
|
+
*
|
|
79
|
+
* ## Example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const safeFormat = withFallback(formatDate, 'Unknown date')
|
|
82
|
+
* safeFormat(null) // 'Unknown date'
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
34
85
|
export const withFallback = <T>(formatter: (value: T) => string, fallback: string) => (value: T | null) => {
|
|
35
86
|
if (value === null) {
|
|
36
87
|
return fallback
|
|
@@ -38,6 +89,16 @@ export const withFallback = <T>(formatter: (value: T) => string, fallback: strin
|
|
|
38
89
|
return formatter(value)
|
|
39
90
|
}
|
|
40
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Formats numbers with locale-aware thousand separators.
|
|
94
|
+
*
|
|
95
|
+
* Handles integers and floats. Respects browser locale.
|
|
96
|
+
*
|
|
97
|
+
* ## Example
|
|
98
|
+
* ```ts
|
|
99
|
+
* formatNumber(1234.5) // '1,234.5' (en-US)
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
41
102
|
export const formatNumber = (value: number | null) => {
|
|
42
103
|
if (value === null) {
|
|
43
104
|
return null
|
|
@@ -45,6 +106,16 @@ export const formatNumber = (value: number | null) => {
|
|
|
45
106
|
return value.toLocaleString()
|
|
46
107
|
}
|
|
47
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Converts raw byte counts to human-readable file sizes.
|
|
111
|
+
*
|
|
112
|
+
* Automatically selects the appropriate unit (KB, MB, GB, etc.) and supports configurable decimal precision.
|
|
113
|
+
*
|
|
114
|
+
* ## Example
|
|
115
|
+
* ```ts
|
|
116
|
+
* formatBytes(2048) // '2.0 KB'
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
48
119
|
export const formatBytes = (bytes: number, decimals = 1) => {
|
|
49
120
|
if (bytes === 0) return '0 Bytes'
|
|
50
121
|
const k = 1024
|
|
@@ -54,16 +125,50 @@ export const formatBytes = (bytes: number, decimals = 1) => {
|
|
|
54
125
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]
|
|
55
126
|
}
|
|
56
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Converts a duration in seconds to `mm:ss` format.
|
|
130
|
+
*
|
|
131
|
+
* Pads seconds with a leading zero. Handles durations over 60 minutes correctly.
|
|
132
|
+
*
|
|
133
|
+
* ## Example
|
|
134
|
+
* ```ts
|
|
135
|
+
* formatDuration(125) // '2:05'
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
57
138
|
export const formatDuration = (duration: number) => {
|
|
58
139
|
const minutes = Math.floor(duration / 60)
|
|
59
140
|
const seconds = duration % 60
|
|
60
141
|
return `${minutes}:${seconds.toString().padStart(2, '0')}`
|
|
61
142
|
}
|
|
62
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Pretty-prints a JSON value with 2-space indentation.
|
|
146
|
+
*
|
|
147
|
+
* ## Example
|
|
148
|
+
* ```ts
|
|
149
|
+
* formatJson({ key: 'value' }) // '{\n "key": "value"\n}'
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
63
152
|
export const formatJson = (value: any) => {
|
|
64
153
|
return JSON.stringify(value, null, 2)
|
|
65
154
|
}
|
|
66
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Selects the appropriate formatter based on a schema column type.
|
|
158
|
+
*
|
|
159
|
+
* Mapping:
|
|
160
|
+
* - `Date` → {@link formatDate}
|
|
161
|
+
* - `DateTime` → {@link formatDateTime}
|
|
162
|
+
* - `Bool` → {@link formatBoolean}
|
|
163
|
+
* - `Integer` / `Float` → {@link formatNumber}
|
|
164
|
+
* - `Json` → {@link formatJson}
|
|
165
|
+
* - Other → identity formatter
|
|
166
|
+
*
|
|
167
|
+
* ## Example
|
|
168
|
+
* ```ts
|
|
169
|
+
* getFormatter({ type: 'Date' })('2023-10-05') // formatted date string
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
67
172
|
export const getFormatter = (schema: SchemaColumn) => {
|
|
68
173
|
switch (schema.type) {
|
|
69
174
|
case 'Date':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './formatting'
|
|
1
|
+
export * from './formatting.js'
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
export interface ImageResizeOptions {
|
|
2
|
+
/** Target width in pixels */
|
|
2
3
|
width?: number
|
|
4
|
+
/** Target height in pixels */
|
|
3
5
|
height?: number
|
|
6
|
+
/** Gaussian blur radius (0-100) */
|
|
4
7
|
blur?: number
|
|
8
|
+
/** Output quality (1-100) */
|
|
5
9
|
quality?: number
|
|
10
|
+
/** Resize behavior */
|
|
6
11
|
fit?: 'scale-down' | 'contain' | 'cover' | 'crop' | 'pad'
|
|
12
|
+
/** Output format */
|
|
7
13
|
format?: 'auto' | 'avif' | 'webp' | 'jpeg' | 'baseline-jpeg' | 'json'
|
|
8
14
|
}
|
|
9
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Generates an optimized image URL using on-demand image processing.
|
|
18
|
+
*
|
|
19
|
+
* Only processes Contember-hosted images (URLs containing `cntmbr.com`).
|
|
20
|
+
* For external images the original URL is returned unchanged.
|
|
21
|
+
* Defaults to `contain` fit and `auto` format when not specified.
|
|
22
|
+
*
|
|
23
|
+
* ## Example
|
|
24
|
+
* ```ts
|
|
25
|
+
* formatImageResizeUrl('https://cdn.cntmbr.com/image.jpg', { width: 300 })
|
|
26
|
+
* // 'https://cdn.cntmbr.com/cdn-cgi/image/width=300,fit=contain,f=auto/image.jpg'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
10
29
|
export const formatImageResizeUrl = (src: string, options?: ImageResizeOptions) => {
|
|
11
30
|
const url = new URL(src)
|
|
12
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './formatImageResizeUrl'
|
|
1
|
+
export * from './formatImageResizeUrl.js'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export * from './dict.js'
|
|
2
|
+
export * from './form/index.js'
|
|
3
|
+
export * from './toast/index.js'
|
|
4
|
+
export * from './utils/index.js'
|
|
5
|
+
|
|
6
|
+
export * from './ui/alert-dialog.js'
|
|
7
|
+
export * from './ui/avatar.js'
|
|
8
|
+
export * from './ui/button.js'
|
|
9
|
+
export * from './ui/card.js'
|
|
10
|
+
export * from './ui/collapsible.js'
|
|
11
|
+
export * from './ui/dialog.js'
|
|
12
|
+
export * from './ui/dimension.js'
|
|
13
|
+
export * from './ui/divider.js'
|
|
14
|
+
export * from './ui/dropdown.js'
|
|
15
|
+
export * from './ui/input.js'
|
|
16
|
+
export * from './ui/label.js'
|
|
17
|
+
export * from './ui/loader.js'
|
|
18
|
+
export * from './ui/menu.js'
|
|
19
|
+
export * from './ui/overlay.js'
|
|
20
|
+
export * from './ui/popover.js'
|
|
21
|
+
export * from './ui/progress.js'
|
|
22
|
+
export * from './ui/property-list.js'
|
|
23
|
+
export * from './ui/scroll-area.js'
|
|
24
|
+
export * from './ui/select.js'
|
|
25
|
+
export * from './ui/separator.js'
|
|
26
|
+
export * from './ui/sheet.js'
|
|
27
|
+
export * from './ui/sidebar.js'
|
|
28
|
+
export * from './ui/skeleton.js'
|
|
29
|
+
export * from './ui/sortable.js'
|
|
30
|
+
export * from './ui/switch.js'
|
|
31
|
+
export * from './ui/table.js'
|
|
32
|
+
export * from './ui/textarea.js'
|
|
33
|
+
export * from './ui/toggle.js'
|
|
34
|
+
export * from './ui/toggle-group.js'
|
|
35
|
+
export * from './ui/tooltip.js'
|
|
36
|
+
export * from './tenant'
|
|
37
|
+
|
|
38
|
+
export * from './binding/index.js'
|
|
39
|
+
export * from './block-repeater/index.js'
|
|
40
|
+
export * from './board/index.js'
|
|
41
|
+
export * from './buttons/index.js'
|
|
42
|
+
export * from './datagrid/index.js'
|
|
43
|
+
export * from './dev/index.js'
|
|
44
|
+
export * from './dimensions/index.js'
|
|
45
|
+
export * from './editor/index.js'
|
|
46
|
+
export * from './field/index.js'
|
|
47
|
+
export * from './formatting/index.js'
|
|
48
|
+
export * from './images/index.js'
|
|
49
|
+
export * from './labels/index.js'
|
|
50
|
+
export * from './layout/index.js'
|
|
51
|
+
export * from './outdated-application-dialog/index.js'
|
|
52
|
+
export * from './repeater/index.js'
|
|
53
|
+
export * from './select/index.js'
|
|
54
|
+
export * from './upload/index.js'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './field-labels'
|
|
2
|
-
export * from './enum-labels'
|
|
1
|
+
export * from './field-labels.js'
|
|
2
|
+
export * from './enum-labels.js'
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './layout-boxed'
|
|
2
|
-
export * from './layout'
|
|
3
|
-
export * from './slots'
|
|
1
|
+
export * from './layout-boxed.js'
|
|
2
|
+
export * from './layout.js'
|
|
3
|
+
export * from './slots.js'
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
PanelRightOpenIcon,
|
|
14
14
|
} from 'lucide-react'
|
|
15
15
|
import { PropsWithChildren, useEffect, useState } from 'react'
|
|
16
|
-
import { dict } from '
|
|
17
|
-
import { Button } from '
|
|
18
|
-
import { SidebarProvider } from '
|
|
19
|
-
import { uic } from '
|
|
20
|
-
import { SlotTargets } from './slots'
|
|
16
|
+
import { dict } from '~/lib'
|
|
17
|
+
import { Button } from '~/lib'
|
|
18
|
+
import { SidebarProvider } from '~/lib'
|
|
19
|
+
import { uic } from '~/lib'
|
|
20
|
+
import { SlotTargets } from './slots.js'
|
|
21
21
|
|
|
22
22
|
const LayoutBodyUI = uic('div', { baseClass: 'bg-gray-50 h-full min-h-screen relative py-4 pl-[calc(100vw-100%)]' })
|
|
23
23
|
const LayoutMaxWidthUI = uic('div', {
|
|
@@ -2,7 +2,7 @@ import { Link } from '@contember/interface'
|
|
|
2
2
|
import { useHasActiveSlotsFactory } from '@contember/react-slots'
|
|
3
3
|
import { dataAttribute } from '@contember/utilities'
|
|
4
4
|
import { PropsWithChildren } from 'react'
|
|
5
|
-
import { Separator } from '
|
|
5
|
+
import { Separator } from '~/lib'
|
|
6
6
|
import {
|
|
7
7
|
Sidebar,
|
|
8
8
|
SidebarContent,
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
SidebarProvider,
|
|
20
20
|
SidebarRail,
|
|
21
21
|
SidebarTrigger,
|
|
22
|
-
} from '
|
|
23
|
-
import { SlotTargets } from './slots'
|
|
22
|
+
} from '~/lib'
|
|
23
|
+
import { SlotTargets } from './slots.js'
|
|
24
24
|
|
|
25
25
|
export const LayoutComponent = ({ children }: PropsWithChildren) => {
|
|
26
26
|
const isActive = useHasActiveSlotsFactory()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './outdated-application-dialog'
|
|
1
|
+
export * from './outdated-application-dialog.js'
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
AlertDialogDescription,
|
|
8
8
|
AlertDialogFooter,
|
|
9
9
|
AlertDialogHeader,
|
|
10
|
-
} from '
|
|
10
|
+
} from '~/lib'
|
|
11
11
|
import { useIsApplicationOutdated } from '@contember/interface'
|
|
12
12
|
import { ClockIcon, RefreshCwIcon } from 'lucide-react'
|
|
13
|
-
import { dict } from '
|
|
13
|
+
import { dict } from '~/lib'
|
|
14
14
|
|
|
15
15
|
const postponeTimeoutMs = 60_000 * 5
|
|
16
16
|
const checkIntervalMs = 30_000
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './repeater'
|
|
1
|
+
export * from './repeater.js'
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
RepeaterSortableItemNode,
|
|
18
18
|
} from '@contember/react-repeater-dnd-kit'
|
|
19
19
|
import { GripVerticalIcon, PlusCircleIcon, Trash2Icon } from 'lucide-react'
|
|
20
|
-
import { Button } from '
|
|
21
|
-
import { uic } from '
|
|
22
|
-
import { DropIndicator } from '
|
|
23
|
-
import { dict } from '
|
|
20
|
+
import { Button } from '~/lib'
|
|
21
|
+
import { uic } from '~/lib'
|
|
22
|
+
import { DropIndicator } from '~/lib'
|
|
23
|
+
import { dict } from '~/lib'
|
|
24
24
|
import { ReactNode } from 'react'
|
|
25
25
|
|
|
26
26
|
const RepeaterWrapperUI = uic('div', {
|
|
@@ -41,6 +41,10 @@ const RepeaterEmptyUI = uic('div', {
|
|
|
41
41
|
baseClass: 'italic text-sm text-gray-600',
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* A visual indicator for sortable repeater items,
|
|
46
|
+
* showing where an item will be dropped. It adapts its placement based on the `position` prop.
|
|
47
|
+
*/
|
|
44
48
|
export const RepeaterDropIndicator = ({ position }: { position: 'before' | 'after' }) => (
|
|
45
49
|
<div className={'relative'}>
|
|
46
50
|
<RepeaterSortableDropIndicator position={position}>
|
|
@@ -49,6 +53,11 @@ export const RepeaterDropIndicator = ({ position }: { position: 'before' | 'afte
|
|
|
49
53
|
</div>
|
|
50
54
|
)
|
|
51
55
|
|
|
56
|
+
/**
|
|
57
|
+
* A button that adds a new item to a repeater at a specified index.
|
|
58
|
+
* It wraps the `RepeaterAddItemTrigger` and displays customizable content.
|
|
59
|
+
* By default, it shows a plus icon alongside a localized label.
|
|
60
|
+
*/
|
|
52
61
|
export const RepeaterAddItemButton = ({ children, index }: { children?: React.ReactNode; index?: RepeaterAddItemIndex }) => (
|
|
53
62
|
<RepeaterAddItemTrigger index={index}>
|
|
54
63
|
<div>
|
|
@@ -65,7 +74,9 @@ export const RepeaterAddItemButton = ({ children, index }: { children?: React.Re
|
|
|
65
74
|
)
|
|
66
75
|
|
|
67
76
|
/**
|
|
68
|
-
* A button that removes
|
|
77
|
+
* A button that removes an item from a repeater.
|
|
78
|
+
* It wraps the `RepeaterRemoveItemTrigger` and displays a customizable child element.
|
|
79
|
+
* By default, it shows a trash icon that turns red on hover.
|
|
69
80
|
*/
|
|
70
81
|
export const RepeaterRemoveItemButton = ({ children }: { children?: React.ReactNode }) => (
|
|
71
82
|
<RepeaterRemoveItemTrigger>
|
|
@@ -86,13 +97,22 @@ export const RepeaterItemActions = uic('div', {
|
|
|
86
97
|
baseClass: 'absolute top-1 right-2 flex gap-2',
|
|
87
98
|
})
|
|
88
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Props for the {@link DefaultRepeater} component.
|
|
102
|
+
*/
|
|
89
103
|
export type DefaultRepeaterProps =
|
|
90
104
|
& {
|
|
105
|
+
/**
|
|
106
|
+
* Optional repeater title.
|
|
107
|
+
*/
|
|
91
108
|
title?: ReactNode
|
|
92
109
|
/**
|
|
93
|
-
*
|
|
110
|
+
* Optional position of the add button.
|
|
94
111
|
*/
|
|
95
112
|
addButtonPosition?: 'none' | 'after' | 'before' | 'around'
|
|
113
|
+
/**
|
|
114
|
+
* Optional label of the add button.
|
|
115
|
+
*/
|
|
96
116
|
addButtonLabel?: ReactNode
|
|
97
117
|
}
|
|
98
118
|
& RepeaterProps
|
|
@@ -100,9 +120,6 @@ export type DefaultRepeaterProps =
|
|
|
100
120
|
/**
|
|
101
121
|
* DefaultRepeater is a wrapper around Repeater that provides a default UI for a list of items.
|
|
102
122
|
*
|
|
103
|
-
* ## Props {@link DefaultRepeaterProps}
|
|
104
|
-
* - field or entities, sortableBy or orderBy, addButtonPosition, title
|
|
105
|
-
*
|
|
106
123
|
* ## Example
|
|
107
124
|
* ```tsx
|
|
108
125
|
* <DefaultRepeater entities="RepeaterItem" sortableBy="order" title="Foo items" addButtonPosition="around">
|
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { ReactElement, ReactNode } from 'react'
|
|
3
|
-
import { Button } from '
|
|
3
|
+
import { Button } from '~/lib'
|
|
4
4
|
import { SelectItemTrigger, SelectNewItem } from '@contember/react-select'
|
|
5
|
-
import { dict } from '
|
|
6
|
-
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogTrigger } from '
|
|
5
|
+
import { dict } from '~/lib'
|
|
6
|
+
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogTrigger } from '~/lib'
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* `CreateEntityDialog` is a modal component that facilitates the creation of a new entity.
|
|
10
|
+
* It integrates entity selection functionality with confirmation and cancellation actions.
|
|
11
|
+
*
|
|
12
|
+
* ## Example: Basic usage
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <CreateEntityDialog
|
|
15
|
+
* trigger={<Button>Create New Entity</Button>}
|
|
16
|
+
* >
|
|
17
|
+
* <EntityForm />
|
|
18
|
+
* </CreateEntityDialog>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @group SelectInput
|
|
22
|
+
* @group MultiSelectInput
|
|
23
|
+
*/
|
|
8
24
|
export const CreateEntityDialog = ({ trigger, children }: { trigger: ReactElement; children: ReactNode }) => {
|
|
9
25
|
return (
|
|
10
26
|
<Dialog>
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { Input } from '
|
|
2
|
+
import { Input } from '~/lib'
|
|
3
3
|
import { DataViewHasFilterType, DataViewQueryFilterName, DataViewTextFilterInput } from '@contember/react-dataview'
|
|
4
|
-
import { dict } from '
|
|
4
|
+
import { dict } from '~/lib'
|
|
5
5
|
import { memo } from 'react'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* `SelectDefaultFilter` is component for filtering data in a `SelectDataView`.
|
|
9
|
+
* It checks if a specific filter type exists and, if so, renders a text input for filtering.
|
|
10
|
+
*
|
|
11
|
+
* @group SelectInput
|
|
12
|
+
*/
|
|
7
13
|
export const SelectDefaultFilter = memo(() => (
|
|
8
14
|
<DataViewHasFilterType name={DataViewQueryFilterName}>
|
|
9
15
|
<DataViewTextFilterInput name={DataViewQueryFilterName}>
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { useCallback } from 'react'
|
|
2
2
|
import { DataViewHighlightEvent } from '@contember/react-dataview'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* `useOnHighlight` is a hook that returns a callback function to handle the highlight event of a data view.
|
|
6
|
+
*
|
|
7
|
+
* ## Requirements
|
|
8
|
+
* - Must be used within an Entity context (`<EntitySubTree />` or `<EntityListSubTree />`).
|
|
9
|
+
*
|
|
10
|
+
* ## Usage
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const onHighlight = useOnHighlight()
|
|
13
|
+
* ...
|
|
14
|
+
* <DataView onHighlight={onHighlight} />
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @group SelectInput
|
|
18
|
+
* @group MultiSelectInput
|
|
19
|
+
*/
|
|
4
20
|
export const useOnHighlight = () => {
|
|
5
21
|
return useCallback((event: DataViewHighlightEvent) => {
|
|
6
22
|
const scrollArea = event.element.closest('[data-radix-scroll-area-viewport]')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './filter'
|
|
2
|
-
export * from './list'
|
|
3
|
-
export * from './multi-select'
|
|
4
|
-
export * from './select'
|
|
5
|
-
export * from './sortable-select'
|
|
6
|
-
export * from './ui'
|
|
1
|
+
export * from './filter.js'
|
|
2
|
+
export * from './list.js'
|
|
3
|
+
export * from './multi-select.js'
|
|
4
|
+
export * from './select.js'
|
|
5
|
+
export * from './sortable-select.js'
|
|
6
|
+
export * from './ui.js'
|