@contember/create 2.1.0-rc.3 → 2.2.0-alpha.10
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/CLAUDE.md +22 -0
- package/dist/development/run.cjs +7 -7
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +8 -8
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js +28 -14
- 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 +79 -67
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +72 -60
- 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 +7 -7
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +8 -8
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js +28 -14
- 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 +79 -67
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +72 -60
- 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 +16 -4
- 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 +10 -2
- 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/README.md +3 -1
- package/resources/templates/default/admin/app/components/navigation.tsx +95 -8
- package/resources/templates/default/admin/app/pages/tenant.tsx +328 -77
- package/resources/templates/default/admin/entrypoint/components/login.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLinkSent.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +1 -1
- 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/config/auth-policy-list.tsx +86 -0
- package/resources/templates/default/admin/lib/tenant/config/common.tsx +71 -0
- package/resources/templates/default/admin/lib/tenant/config/identity-provider-list.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/config/index.ts +5 -0
- package/resources/templates/default/admin/lib/tenant/config/mail-template-list.tsx +108 -0
- package/resources/templates/default/admin/lib/tenant/config/tenant-config-view.tsx +182 -0
- package/resources/templates/default/admin/lib/tenant/dict.ts +770 -0
- package/resources/templates/default/admin/lib/tenant/errors.ts +10 -0
- package/resources/templates/default/admin/lib/tenant/forms/add-project-member.tsx +57 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-password.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/change-my-profile.tsx +40 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-profile.tsx +55 -0
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +12 -5
- 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/create-global-api-key.tsx +69 -0
- package/resources/templates/default/admin/lib/tenant/forms/global-roles-control.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +23 -8
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +46 -8
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +8 -14
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +7 -5
- package/resources/templates/default/admin/lib/tenant/forms/mfa-code-fields.tsx +81 -0
- 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 +8 -14
- package/resources/templates/default/admin/lib/tenant/forms/request-email-verification.tsx +35 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-person-password.tsx +58 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-project-secret.tsx +59 -0
- package/resources/templates/default/admin/lib/tenant/forms/sign-up.tsx +73 -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/index.ts +2 -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/idp/identity-provider-connections.tsx +124 -0
- package/resources/templates/default/admin/lib/tenant/idp/index.ts +1 -0
- package/resources/templates/default/admin/lib/tenant/index.ts +10 -3
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +161 -23
- package/resources/templates/default/admin/lib/tenant/listing/auth-log-list.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/global-api-key-list.tsx +149 -0
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +11 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +28 -19
- package/resources/templates/default/admin/lib/tenant/listing/mfa.tsx +29 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-actions.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-detail.tsx +141 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +17 -6
- package/resources/templates/default/admin/lib/tenant/listing/persons-list.tsx +128 -0
- package/resources/templates/default/admin/lib/tenant/listing/project-secret-list.tsx +82 -0
- package/resources/templates/default/admin/lib/tenant/otp/backup-codes.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/otp/email-otp-setup.tsx +133 -0
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +3 -1
- package/resources/templates/default/admin/lib/tenant/otp/otp-setup.tsx +6 -6
- package/resources/templates/default/admin/lib/tenant/security/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/passwordless-toggle.tsx +63 -0
- package/resources/templates/default/admin/lib/tenant/security/session-list.tsx +143 -0
- 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/admin/package.json +1 -0
- package/resources/templates/default/docker/object-storage/README.md +13 -0
- package/resources/templates/default/docker/object-storage/identities.json +13 -0
- package/resources/templates/default/docker-compose.yaml +29 -7
- 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 +45 -17
- package/src/commands/index.ts +1 -1
- package/src/lib/FileSystem.ts +2 -2
- package/src/lib/TemplateInstaller.ts +87 -69
- package/src/lib/version.ts +1 -1
- package/src/run.ts +11 -10
- package/tests/cases/unit/create-process.test.ts +66 -0
- package/tests/cases/unit/template-installer-cleanup.test.ts +150 -0
- package/tests/cases/unit/workspace-create.test.ts +81 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type FieldValue, SugaredRelativeSingleField, useField } from '@contember/interface'
|
|
2
|
+
import { Fragment, ReactNode } from 'react'
|
|
3
|
+
import { useEnumOptionsFormatter } from '../labels/index.js'
|
|
4
|
+
|
|
5
|
+
export type ListFieldProps<T> = {
|
|
6
|
+
field: SugaredRelativeSingleField['field']
|
|
7
|
+
render?: (value: T) => ReactNode
|
|
8
|
+
separator?: ReactNode
|
|
9
|
+
fallback?: ReactNode
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const ListField = (<T extends FieldValue = FieldValue>({ field, render, separator, fallback }: ListFieldProps<T>) => {
|
|
13
|
+
const value = useField<T[]>(field).value
|
|
14
|
+
if (!value || value.length === 0) {
|
|
15
|
+
return fallback ?? null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
{value.map((item, index) => (
|
|
21
|
+
<Fragment key={index}>
|
|
22
|
+
{render ? render(item) : <>{item}</>}
|
|
23
|
+
{index < value.length - 1 && separator}
|
|
24
|
+
</Fragment>
|
|
25
|
+
))}
|
|
26
|
+
</>
|
|
27
|
+
)
|
|
28
|
+
}) as <T extends FieldValue = FieldValue>(props: ListFieldProps<T>) => ReactNode
|
|
29
|
+
|
|
30
|
+
export type EnumListFieldProps = {
|
|
31
|
+
field: SugaredRelativeSingleField['field']
|
|
32
|
+
options?: Record<string, ReactNode>
|
|
33
|
+
decorate?: (value: ReactNode) => ReactNode
|
|
34
|
+
separator?: ReactNode
|
|
35
|
+
fallback?: ReactNode
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const EnumListField = ({ field, decorate, separator, fallback, options }: EnumListFieldProps) => {
|
|
39
|
+
const fieldAccessor = useField(field)
|
|
40
|
+
const enumOptions = useEnumOptionsFormatter()
|
|
41
|
+
if (!fieldAccessor.schema.enumName) {
|
|
42
|
+
throw new Error('Field is not an enum field')
|
|
43
|
+
}
|
|
44
|
+
const optionsResolved = options ?? enumOptions(fieldAccessor.schema.enumName)
|
|
45
|
+
return (
|
|
46
|
+
<ListField<string>
|
|
47
|
+
field={field}
|
|
48
|
+
separator={separator}
|
|
49
|
+
fallback={fallback}
|
|
50
|
+
render={value => {
|
|
51
|
+
const enumValue = optionsResolved[value]
|
|
52
|
+
return decorate ? decorate(enumValue) : enumValue
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
@@ -1,18 +1,48 @@
|
|
|
1
1
|
import { ReactNode } from 'react'
|
|
2
|
-
import { FormContainerUI, FormDescriptionUI, FormErrorUI, FormLabelUI, FormLabelWrapperUI } from '
|
|
3
|
-
import { useErrorFormatter } from '../errors'
|
|
2
|
+
import { FormContainerUI, FormDescriptionUI, FormErrorUI, FormLabelUI, FormLabelWrapperUI } from '~/lib'
|
|
3
|
+
import { useErrorFormatter } from '../errors/index.js'
|
|
4
4
|
import { Component, ErrorAccessor, useLabelMiddleware } from '@contember/interface'
|
|
5
5
|
import { FormError, FormFieldStateProvider, FormLabel, useFormFieldState } from '@contember/react-form'
|
|
6
|
-
import { FormFieldLabel } from './labels'
|
|
6
|
+
import { FormFieldLabel } from './labels.js'
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Props for the {@link FormContainer} component.
|
|
10
|
+
*/
|
|
8
11
|
export type FormContainerProps = {
|
|
12
|
+
/**
|
|
13
|
+
* The label for the form element.
|
|
14
|
+
*/
|
|
9
15
|
label?: ReactNode
|
|
16
|
+
/**
|
|
17
|
+
* The description text for the form element.
|
|
18
|
+
*/
|
|
10
19
|
description?: ReactNode
|
|
20
|
+
/**
|
|
21
|
+
* The child components or form elements to render within the container.
|
|
22
|
+
*/
|
|
11
23
|
children: ReactNode
|
|
24
|
+
/**
|
|
25
|
+
* The error message to display.
|
|
26
|
+
*/
|
|
12
27
|
errors?: ErrorAccessor.Error[] | ReactNode
|
|
28
|
+
/**
|
|
29
|
+
* Indicates whether the form element is required.
|
|
30
|
+
*/
|
|
13
31
|
required?: boolean
|
|
14
32
|
}
|
|
15
33
|
|
|
34
|
+
/**
|
|
35
|
+
* `FormContainer` is a layout component for form fields, providing consistent styling and handling
|
|
36
|
+
* of labels, descriptions, and error messages. It ensures accessibility and state management
|
|
37
|
+
* within form contexts.
|
|
38
|
+
*
|
|
39
|
+
* ## Example: Basic usage
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <FormContainer label="Email" description="Enter a valid email address" required errors={errors}>
|
|
42
|
+
* <FormInput field="email" />
|
|
43
|
+
* </FormContainer>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
16
46
|
export const FormContainer = Component(
|
|
17
47
|
({ children, description, label, required, errors }: FormContainerProps) => {
|
|
18
48
|
const errorsNode = Array.isArray(errors) ? undefined : errors
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from './container'
|
|
2
|
-
export * from './inputs'
|
|
3
|
-
export * from './select'
|
|
4
1
|
export * from './ui'
|
|
5
|
-
|
|
6
|
-
export * from './
|
|
2
|
+
|
|
3
|
+
export * from './container.js'
|
|
4
|
+
export * from './inputs.js'
|
|
5
|
+
export * from './select.js'
|
|
6
|
+
export * from './upload.js'
|
|
7
|
+
export * from './upload-repeaters.js'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentProps, ReactNode, useMemo } from 'react'
|
|
2
|
-
import { CheckboxInput, Input, RadioInput } from '
|
|
3
|
-
import { TextareaAutosize } from '
|
|
4
|
-
import { FormLabelUI } from '
|
|
2
|
+
import { CheckboxInput, Input, RadioInput } from '~/lib'
|
|
3
|
+
import { TextareaAutosize } from '~/lib'
|
|
4
|
+
import { FormLabelUI } from '~/lib'
|
|
5
5
|
import {
|
|
6
6
|
FormCheckbox,
|
|
7
7
|
FormCheckboxProps,
|
|
@@ -13,11 +13,14 @@ import {
|
|
|
13
13
|
FormRadioItemProps,
|
|
14
14
|
useFormFieldState,
|
|
15
15
|
} from '@contember/react-form'
|
|
16
|
-
import { FormContainer, FormContainerProps } from './container'
|
|
16
|
+
import { FormContainer, FormContainerProps } from './container.js'
|
|
17
17
|
import { Component, Field } from '@contember/interface'
|
|
18
|
-
import { useEnumOptionsFormatter } from '../labels'
|
|
19
|
-
import { FormFieldLabel } from './labels'
|
|
18
|
+
import { useEnumOptionsFormatter } from '../labels/index.js'
|
|
19
|
+
import { FormFieldLabel } from './labels.js'
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Props for the {@link InputField} component.
|
|
23
|
+
*/
|
|
21
24
|
export type InputFieldProps =
|
|
22
25
|
& Omit<FormInputProps, 'children'>
|
|
23
26
|
& Omit<FormContainerProps, 'children'>
|
|
@@ -26,6 +29,24 @@ export type InputFieldProps =
|
|
|
26
29
|
inputProps?: ComponentProps<typeof Input>
|
|
27
30
|
}
|
|
28
31
|
|
|
32
|
+
/**
|
|
33
|
+
* `InputField` is a form input component that integrates with {@link FormFieldScope},
|
|
34
|
+
* {@link FormContainer}, and {@link FormInput} to provide a structured and configurable input field.
|
|
35
|
+
*
|
|
36
|
+
* ## Example: Basic usage
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <InputField field="title" label="Article title" />
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* ## Example: With additional input properties
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <InputField
|
|
44
|
+
* field="title"
|
|
45
|
+
* label="Article title"
|
|
46
|
+
* inputProps={{ placeholder: 'Enter a title' }}
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
29
50
|
export const InputField = Component((
|
|
30
51
|
{ field, label, description, inputProps, isNonbearing, defaultValue, required, parseValue, formatValue }: InputFieldProps,
|
|
31
52
|
) => (
|
|
@@ -38,6 +59,9 @@ export const InputField = Component((
|
|
|
38
59
|
</FormFieldScope>
|
|
39
60
|
))
|
|
40
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Props for the {@link TextareaField} component.
|
|
64
|
+
*/
|
|
41
65
|
export type TextareaFieldProps =
|
|
42
66
|
& Omit<FormInputProps, 'children'>
|
|
43
67
|
& Omit<FormContainerProps, 'children'>
|
|
@@ -46,6 +70,30 @@ export type TextareaFieldProps =
|
|
|
46
70
|
inputProps?: ComponentProps<typeof TextareaAutosize>
|
|
47
71
|
}
|
|
48
72
|
|
|
73
|
+
/**
|
|
74
|
+
* `TextareaField` is a form textarea component that integrates with `FormFieldScope`,
|
|
75
|
+
* `FormContainer`, and `FormInput` to provide a structured and configurable multi-line input field.
|
|
76
|
+
*
|
|
77
|
+
* Must be used within a form context.
|
|
78
|
+
*
|
|
79
|
+
* ## Features
|
|
80
|
+
* - Supports field scoping for form state management
|
|
81
|
+
* - Includes a label and description for accessibility
|
|
82
|
+
* - Handles required validation
|
|
83
|
+
* - Supports automatic resizing with `TextareaAutosize`
|
|
84
|
+
* - Allows custom input properties via `inputProps`
|
|
85
|
+
*
|
|
86
|
+
* ## Example: Basic usage
|
|
87
|
+
* ```tsx
|
|
88
|
+
* <TextareaField
|
|
89
|
+
* field="bio"
|
|
90
|
+
* label="Biography"
|
|
91
|
+
* description="Tell us about yourself"
|
|
92
|
+
* required
|
|
93
|
+
* inputProps={{ placeholder: "Write something..." }}
|
|
94
|
+
* />
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
49
97
|
export const TextareaField = Component(({ field, label, description, inputProps, isNonbearing, defaultValue, required }: TextareaFieldProps) => (
|
|
50
98
|
<FormFieldScope field={field}>
|
|
51
99
|
<FormContainer description={description} label={label} required={required}>
|
|
@@ -64,6 +112,25 @@ export type CheckboxFieldProps =
|
|
|
64
112
|
inputProps?: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'>
|
|
65
113
|
}
|
|
66
114
|
|
|
115
|
+
/**
|
|
116
|
+
* CheckboxField is a component for boolean fields. Must be used within an Entity context.
|
|
117
|
+
*
|
|
118
|
+
* ## Requirements
|
|
119
|
+
* - Must be used within an Entity context (`<EntitySubTree />` or `<EntityListSubTree />`).
|
|
120
|
+
*
|
|
121
|
+
* ## Features:
|
|
122
|
+
* - Renders as a standard checkbox input
|
|
123
|
+
* - Label appears adjacent to the checkbox
|
|
124
|
+
* - Required state reflects field nullability (can be overridden)
|
|
125
|
+
*
|
|
126
|
+
* ## Example: Basic usage
|
|
127
|
+
* ```tsx
|
|
128
|
+
* <CheckboxField
|
|
129
|
+
* field="isPublished"
|
|
130
|
+
* label="Publish immediately"
|
|
131
|
+
* />
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
67
134
|
export const CheckboxField = Component(({ field, label, description, inputProps, isNonbearing, defaultValue, required }: CheckboxFieldProps) => (
|
|
68
135
|
<FormFieldScope field={field}>
|
|
69
136
|
<FormContainer description={description} label={false}>
|
|
@@ -89,6 +156,38 @@ export type RadioEnumFieldProps =
|
|
|
89
156
|
inputProps?: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'>
|
|
90
157
|
}
|
|
91
158
|
|
|
159
|
+
/**
|
|
160
|
+
* RadioEnumField is a component for enum fields with radio button selection. Must be used within an Entity context.
|
|
161
|
+
*
|
|
162
|
+
* ## Requirements
|
|
163
|
+
* - Must be used within an Entity context (`<EntitySubTree />` or `<EntityListSubTree />`).
|
|
164
|
+
*
|
|
165
|
+
* ## Features
|
|
166
|
+
* - Can auto-generate options from enum definitions
|
|
167
|
+
* - Supports horizontal or vertical layout
|
|
168
|
+
* - Options can be provided explicitly or derived from enum labels
|
|
169
|
+
*
|
|
170
|
+
* ## Example: Basic usage
|
|
171
|
+
* ```tsx
|
|
172
|
+
* <RadioEnumField
|
|
173
|
+
* field="status"
|
|
174
|
+
* label="Article Status"
|
|
175
|
+
* orientation="horizontal"
|
|
176
|
+
* options={[
|
|
177
|
+
* { value: 'draft', label: 'Draft' },
|
|
178
|
+
* { value: 'published', label: 'Published' }
|
|
179
|
+
* ]}
|
|
180
|
+
* />
|
|
181
|
+
* ```
|
|
182
|
+
*
|
|
183
|
+
* ## Example: Using enum auto-detection
|
|
184
|
+
* ```tsx
|
|
185
|
+
* <RadioEnumField
|
|
186
|
+
* field="category"
|
|
187
|
+
* label="Article Category"
|
|
188
|
+
* />
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
92
191
|
export const RadioEnumField = Component<RadioEnumFieldProps>(({ field, label, description, required, ...rest }) => {
|
|
93
192
|
return (
|
|
94
193
|
<FormFieldScope field={field}>
|
|
@@ -11,21 +11,66 @@ import {
|
|
|
11
11
|
SelectPopoverContent,
|
|
12
12
|
SortableMultiSelectInput,
|
|
13
13
|
SortableMultiSelectInputProps,
|
|
14
|
-
} from '../select'
|
|
14
|
+
} from '../select/index.js'
|
|
15
15
|
import * as React from 'react'
|
|
16
16
|
import { useCallback, useMemo } from 'react'
|
|
17
|
-
import { FormContainer, FormContainerProps } from './container'
|
|
17
|
+
import { FormContainer, FormContainerProps } from './container.js'
|
|
18
18
|
import { FormFieldScope, FormHasManyRelationScope, FormHasOneRelationScope, useFormFieldState } from '@contember/react-form'
|
|
19
19
|
import { Component, Field, RecursionTerminator, SugaredRelativeSingleField, useEntityBeforePersist, useField } from '@contember/interface'
|
|
20
|
-
import { Popover, PopoverTrigger } from '
|
|
20
|
+
import { Popover, PopoverTrigger } from '~/lib'
|
|
21
21
|
import { ChevronDownIcon, ChevronUpIcon } from 'lucide-react'
|
|
22
|
-
import { dict } from '
|
|
23
|
-
import { useEnumOptionsFormatter } from '../labels'
|
|
22
|
+
import { dict } from '~/lib'
|
|
23
|
+
import { useEnumOptionsFormatter } from '../labels/index.js'
|
|
24
24
|
|
|
25
25
|
export type SelectFieldProps =
|
|
26
26
|
& SelectInputProps
|
|
27
27
|
& Omit<FormContainerProps, 'children'>
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* `SelectField` is a component for single-entity relationship selection (hasOne). Must be used within an Entity context.
|
|
31
|
+
*
|
|
32
|
+
* ## Requirements
|
|
33
|
+
* - Must be used within an Entity context (`<EntitySubTree />` or `<EntityListSubTree />`).
|
|
34
|
+
*
|
|
35
|
+
* ## Features
|
|
36
|
+
* - Manages hasOne relationships through a dropdown interface.
|
|
37
|
+
* - Supports custom option rendering and creation of new entities.
|
|
38
|
+
* - Sorts options by a specified field.
|
|
39
|
+
* - Query-based option filtering.
|
|
40
|
+
*
|
|
41
|
+
* ## Example: Basic usage
|
|
42
|
+
* ```tsx
|
|
43
|
+
* <SelectField
|
|
44
|
+
* field="country"
|
|
45
|
+
* label="Home Country"
|
|
46
|
+
* >
|
|
47
|
+
* <Field field="name" />
|
|
48
|
+
* </SelectField>
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* ## Example: With sorting and form allowing creation of new entities
|
|
52
|
+
* ```tsx
|
|
53
|
+
* <SelectField
|
|
54
|
+
* field="author"
|
|
55
|
+
* label="Author"
|
|
56
|
+
* initialSorting={{ name: 'asc' }}
|
|
57
|
+
* createNewForm={<CountryForm />}
|
|
58
|
+
* >
|
|
59
|
+
* <Field field="name" />
|
|
60
|
+
* </SelectField>
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* ## Example: With query-based filtering
|
|
64
|
+
* ```tsx
|
|
65
|
+
* <SelectField
|
|
66
|
+
* field="author"
|
|
67
|
+
* label="Author"
|
|
68
|
+
* options="Author[archived != false]"
|
|
69
|
+
* >
|
|
70
|
+
* <Field field="name" />
|
|
71
|
+
* </SelectField>
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
29
74
|
export const SelectField = Component<SelectFieldProps>(
|
|
30
75
|
({ field, label, description, children, options, queryField, placeholder, createNewForm, errors, initialSorting, required }, env) => {
|
|
31
76
|
return (
|
|
@@ -54,6 +99,41 @@ export type MultiSelectFieldProps =
|
|
|
54
99
|
& MultiSelectInputProps
|
|
55
100
|
& Omit<FormContainerProps, 'children' | 'required'>
|
|
56
101
|
|
|
102
|
+
/**
|
|
103
|
+
* MultiSelectField component for managing multiple-entity (hasMany) relationships.
|
|
104
|
+
*
|
|
105
|
+
* ## Requirements
|
|
106
|
+
* - Must be used within an Entity context (`<EntitySubTree />` or `<EntityListSubTree />`)
|
|
107
|
+
*
|
|
108
|
+
* ## Features
|
|
109
|
+
* - Multiple entity selection with chip display
|
|
110
|
+
* - Supports custom option rendering and creation of new entities
|
|
111
|
+
* - Maintains selection order based on user interaction
|
|
112
|
+
* - Query-based option filtering with initial sorting
|
|
113
|
+
* - Integrated error state handling from parent form
|
|
114
|
+
*
|
|
115
|
+
* ## Example: Basic usage
|
|
116
|
+
* ```tsx
|
|
117
|
+
* <MultiSelectField
|
|
118
|
+
* field="categories"
|
|
119
|
+
* label="Article Categories"
|
|
120
|
+
* >
|
|
121
|
+
* <Field field="name" />
|
|
122
|
+
* </MultiSelectField>
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* ## Example: With creation form and sorting
|
|
126
|
+
* ```tsx
|
|
127
|
+
* <MultiSelectField
|
|
128
|
+
* field="tags"
|
|
129
|
+
* label="Article Tags"
|
|
130
|
+
* initialSorting={{ name: 'asc' }}
|
|
131
|
+
* createNewForm={<TagCreateForm />}
|
|
132
|
+
* >
|
|
133
|
+
* <Field field="name" />
|
|
134
|
+
* </MultiSelectField>
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
57
137
|
export const MultiSelectField = Component<MultiSelectFieldProps>(
|
|
58
138
|
({ field, label, description, children, options, queryField, placeholder, createNewForm, errors, initialSorting }) => {
|
|
59
139
|
return (
|
|
@@ -81,6 +161,32 @@ export type SortableMultiSelectFieldProps =
|
|
|
81
161
|
& SortableMultiSelectInputProps
|
|
82
162
|
& Omit<FormContainerProps, 'children' | 'required'>
|
|
83
163
|
|
|
164
|
+
/**
|
|
165
|
+
* SortableMultiSelectField component for ordered multi-entity relationships with drag-and-drop.
|
|
166
|
+
*
|
|
167
|
+
* ## Requirements
|
|
168
|
+
* - Must be used within an Entity context (`<EntitySubTree />` or `<EntityListSubTree />`)
|
|
169
|
+
* - Requires sort field configuration via `sortableBy` prop
|
|
170
|
+
*
|
|
171
|
+
* ## Features
|
|
172
|
+
* - Drag-and-drop reordering of selected items
|
|
173
|
+
* - Visual sorting indicators during drag operations
|
|
174
|
+
* - Customizable sort field storage
|
|
175
|
+
* - Connection point management for complex relationships
|
|
176
|
+
* - Inherits all MultiSelectField features
|
|
177
|
+
*
|
|
178
|
+
* ## Example: Basic usage
|
|
179
|
+
* ```tsx
|
|
180
|
+
* <SortableMultiSelectField
|
|
181
|
+
* field="chapterPages"
|
|
182
|
+
* label="Page Order"
|
|
183
|
+
* sortableBy="pageNumber"
|
|
184
|
+
* connectAt="bookChapter"
|
|
185
|
+
* >
|
|
186
|
+
* <Field field="content" />
|
|
187
|
+
* </SortableMultiSelectField>
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
84
190
|
export const SortableMultiSelectField = Component<SortableMultiSelectFieldProps>(
|
|
85
191
|
({ field, label, description, children, options, queryField, placeholder, sortableBy, connectAt, createNewForm, errors, initialSorting }) => {
|
|
86
192
|
return (
|
|
@@ -114,6 +220,57 @@ export type SelectEnumFieldProps =
|
|
|
114
220
|
required?: boolean
|
|
115
221
|
}
|
|
116
222
|
|
|
223
|
+
/**
|
|
224
|
+
* SelectEnumField component for enum value selection with auto-option detection.
|
|
225
|
+
*
|
|
226
|
+
* ## Requirements
|
|
227
|
+
* - Field must be an enum type when using auto-detection
|
|
228
|
+
* - Manual options must be provided if enum not detected
|
|
229
|
+
*
|
|
230
|
+
* ## Features
|
|
231
|
+
* - Auto-detects enum options from schema definition
|
|
232
|
+
* - Supports mixed value types (string, number, boolean, null)
|
|
233
|
+
* - Two option formats: object map or array of {value/label}
|
|
234
|
+
* - Required field validation with error feedback
|
|
235
|
+
* - Custom placeholder support
|
|
236
|
+
* - Pre-persist validation for required fields
|
|
237
|
+
*
|
|
238
|
+
* ## Example: Auto-detected enum usage
|
|
239
|
+
* ```tsx
|
|
240
|
+
* <SelectEnumField
|
|
241
|
+
* field="articleStatus"
|
|
242
|
+
* label="Publication Status"
|
|
243
|
+
* required
|
|
244
|
+
* />
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
247
|
+
* ## Example: Manual options with mixed types
|
|
248
|
+
* ```tsx
|
|
249
|
+
* <SelectEnumField
|
|
250
|
+
* field="notificationSettings"
|
|
251
|
+
* label="Alert Preferences"
|
|
252
|
+
* options={[
|
|
253
|
+
* { value: 'email', label: 'Email Notifications' },
|
|
254
|
+
* { value: 1, label: 'SMS Alerts' },
|
|
255
|
+
* { value: null, label: 'No Notifications' }
|
|
256
|
+
* ]}
|
|
257
|
+
* placeholder="Select preference..."
|
|
258
|
+
* />
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
261
|
+
* ## Example: Object-based options
|
|
262
|
+
* ```tsx
|
|
263
|
+
* <SelectEnumField
|
|
264
|
+
* field="userRole"
|
|
265
|
+
* label="Account Type"
|
|
266
|
+
* options={{
|
|
267
|
+
* admin: 'Administrator',
|
|
268
|
+
* user: 'Standard User',
|
|
269
|
+
* guest: 'Temporary Access'
|
|
270
|
+
* }}
|
|
271
|
+
* />
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
117
274
|
export const SelectEnumField = Component<SelectEnumFieldProps>(
|
|
118
275
|
({ field, label, description, options, placeholder, required }) => {
|
|
119
276
|
return (
|