@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
|
@@ -4,16 +4,16 @@ import { dataAttribute } from '@contember/utilities'
|
|
|
4
4
|
import { FilterIcon, RefreshCcwIcon, SettingsIcon } from 'lucide-react'
|
|
5
5
|
import * as React from 'react'
|
|
6
6
|
import { ReactNode } from 'react'
|
|
7
|
-
import { dict } from '
|
|
8
|
-
import { Button } from '
|
|
9
|
-
import { Popover, PopoverContent, PopoverTrigger } from '
|
|
10
|
-
import { DataGridToolbarVisibleElements } from './elements'
|
|
11
|
-
import { DataGridAutoExport } from './export'
|
|
12
|
-
import { DataGridQueryFilter } from './filters'
|
|
13
|
-
import { DataGridShowFiltersContext } from './filters/mobile'
|
|
14
|
-
import { DataGridLayoutSwitcher } from './layout-switcher'
|
|
15
|
-
import { DataGridPerPageSelector } from './pagination'
|
|
16
|
-
import { DataGridToolbarUI } from './ui'
|
|
7
|
+
import { dict } from '~/lib'
|
|
8
|
+
import { Button } from '~/lib'
|
|
9
|
+
import { Popover, PopoverContent, PopoverTrigger } from '~/lib'
|
|
10
|
+
import { DataGridToolbarVisibleElements } from './elements.js'
|
|
11
|
+
import { DataGridAutoExport } from './export.js'
|
|
12
|
+
import { DataGridQueryFilter } from './filters/index.js'
|
|
13
|
+
import { DataGridShowFiltersContext } from './filters/mobile.js'
|
|
14
|
+
import { DataGridLayoutSwitcher } from './layout-switcher.js'
|
|
15
|
+
import { DataGridPerPageSelector } from './pagination.js'
|
|
16
|
+
import { DataGridToolbarUI } from './ui.js'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Props for the {@link DataGridToolbar} component.
|
|
@@ -26,18 +26,14 @@ export interface DataGridToolbarProps {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
* It
|
|
31
|
-
* - filters (with default DataGridQueryFilter, which can be replaced by custom filters in children)
|
|
32
|
-
* - settings (layout switcher, visible elements, per page selector)
|
|
33
|
-
* - export button
|
|
34
|
-
* - reload button
|
|
29
|
+
* `DataGridToolbar` provides a toolbar for `DataGrid` with default UI components.
|
|
30
|
+
* It includes filtering, layout settings, export functionality, and a reload button.
|
|
35
31
|
*
|
|
36
|
-
* ## Example
|
|
32
|
+
* ## Example: Basic usage with custom filters
|
|
37
33
|
* ```tsx
|
|
38
34
|
* <DataGridToolbar>
|
|
39
|
-
*
|
|
40
|
-
*
|
|
35
|
+
* <DataGridQueryFilter />
|
|
36
|
+
* <DataGridTextFilter field="name" label="Name" />
|
|
41
37
|
* </DataGridToolbar>
|
|
42
38
|
* ```
|
|
43
39
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CheckSquareIcon, FilterIcon, FilterXIcon, PlusIcon, SquareIcon, XIcon } from 'lucide-react'
|
|
2
2
|
import { forwardRef, ReactEventHandler, ReactNode, useCallback } from 'react'
|
|
3
|
-
import { dict } from '
|
|
4
|
-
import { Button } from '
|
|
5
|
-
import { cn, uic } from '
|
|
3
|
+
import { dict } from '~/lib'
|
|
4
|
+
import { Button } from '~/lib'
|
|
5
|
+
import { cn, uic } from '~/lib'
|
|
6
6
|
|
|
7
7
|
export const DataGridTooltipLabel = uic('span', {
|
|
8
8
|
baseClass: 'cursor-pointer border-dashed border-b border-b-gray-400 hover:border-gray-800',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './login-panel'
|
|
2
|
-
export * from './todo'
|
|
1
|
+
export * from './login-panel.js'
|
|
2
|
+
export * from './todo.js'
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { Button } from '
|
|
1
|
+
import { Button } from '~/lib'
|
|
2
2
|
import { useSessionTokenWithMeta, useSetSessionToken } from '@contember/react-client'
|
|
3
3
|
import { CreateSessionTokenForm, useCreateSessionTokenForm } from '@contember/react-client-tenant'
|
|
4
|
-
import { Loader } from '
|
|
5
|
-
import { TenantFormError, TenantFormField } from '
|
|
4
|
+
import { Loader } from '~/lib'
|
|
5
|
+
import { TenantFormError, TenantFormField } from '~/lib/tenant'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* `LoginWithEmail` component handles user authentication using email.
|
|
9
|
+
* It integrates with session token management to facilitate authentication.
|
|
10
|
+
*
|
|
11
|
+
* ## Example: Basic Usage
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <LoginWithEmail />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
7
16
|
export const LoginWithEmail = () => {
|
|
8
17
|
const sessionToken = useSessionTokenWithMeta()
|
|
9
18
|
const setSessionToken = useSetSessionToken()
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Props for the {@link Todo} component.
|
|
5
|
+
*/
|
|
3
6
|
export interface CommentProps extends PropsWithChildren {
|
|
4
7
|
}
|
|
5
8
|
|
|
9
|
+
/**
|
|
10
|
+
* `Todo` is a development-only helper component for marking TODOs in the UI.
|
|
11
|
+
* It displays a highlighted message when in development mode (`import.meta.env.DEV`).
|
|
12
|
+
*
|
|
13
|
+
* ## Example: Basic Usage
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <Todo>Implement authentication logic</Todo>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
6
18
|
export const Todo = ({ children }: CommentProps) => {
|
|
7
19
|
if (!import.meta.env.DEV) return null
|
|
8
20
|
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { TextFilterArtifactsMatchMode } from '@contember/react-dataview'
|
|
2
|
-
import { InviteErrorCodes } from './tenant/hooks/useInvite'
|
|
3
2
|
import { UploaderErrorType } from '@contember/react-uploader'
|
|
4
|
-
import { ChangeMyPasswordFormErrorCode, CreateApiKeyFormErrorCode } from '@contember/interface'
|
|
5
|
-
import {
|
|
6
|
-
InviteFormErrorCode,
|
|
7
|
-
LoginFormErrorCode,
|
|
8
|
-
OtpConfirmFormErrorCode,
|
|
9
|
-
OtpPrepareFormErrorCode,
|
|
10
|
-
PasswordlessSignInFormErrorCode,
|
|
11
|
-
PasswordlessSignInInitFormErrorCode,
|
|
12
|
-
PasswordResetFormErrorCode,
|
|
13
|
-
PasswordResetRequestFormErrorCode,
|
|
14
|
-
UpdateProjectMemberFormErrorCode,
|
|
15
|
-
} from '@contember/react-identity'
|
|
16
|
-
import { ActivatePasswordlessOtpErrorCode, WeakPasswordReason } from '@contember/graphql-client-tenant'
|
|
17
3
|
|
|
18
4
|
export const dict = {
|
|
19
5
|
deleteEntityDialog: {
|
|
@@ -99,16 +85,6 @@ export const dict = {
|
|
|
99
85
|
false: 'No',
|
|
100
86
|
},
|
|
101
87
|
logout: 'Log out',
|
|
102
|
-
inviteErrors: {
|
|
103
|
-
ALREADY_MEMBER: 'This user is already a member of the project',
|
|
104
|
-
INVALID_EMAIL_FORMAT: 'Invalid email format',
|
|
105
|
-
INVALID_MEMBERSHIP: 'Invalid membership',
|
|
106
|
-
PROJECT_NOT_FOUND: 'Project not found',
|
|
107
|
-
ROLE_NOT_FOUND: 'Role not found',
|
|
108
|
-
VARIABLE_EMPTY: 'Variable is empty',
|
|
109
|
-
VARIABLE_NOT_FOUND: 'Variable not found',
|
|
110
|
-
fallback: 'Failed to invite user',
|
|
111
|
-
} satisfies Record<InviteErrorCodes | 'fallback', string>,
|
|
112
88
|
uploader: {
|
|
113
89
|
uploadErrors: {
|
|
114
90
|
httpError: 'HTTP error',
|
|
@@ -134,243 +110,6 @@ export const dict = {
|
|
|
134
110
|
snooze: 'Snooze',
|
|
135
111
|
refreshNow: 'Refresh now',
|
|
136
112
|
},
|
|
137
|
-
tenant: {
|
|
138
|
-
memberList: {
|
|
139
|
-
failedToLoadData: 'Failed to load data',
|
|
140
|
-
noResults: 'No results',
|
|
141
|
-
previous: 'Previous',
|
|
142
|
-
next: 'Next',
|
|
143
|
-
roles: 'Roles',
|
|
144
|
-
action: 'Action',
|
|
145
|
-
},
|
|
146
|
-
apiKeyList: {
|
|
147
|
-
deleted: 'API key deleted',
|
|
148
|
-
deleteFailed: 'Failed to delete API key',
|
|
149
|
-
unnamed: 'Unnamed API key',
|
|
150
|
-
noResults: 'No API keys',
|
|
151
|
-
description: 'Description',
|
|
152
|
-
role: 'Role',
|
|
153
|
-
action: 'Action',
|
|
154
|
-
deleteConfirmation: 'Are you sure you want to delete this API key?',
|
|
155
|
-
deleteCancelAction: 'Cancel',
|
|
156
|
-
deleteConfirmAction: 'Delete',
|
|
157
|
-
},
|
|
158
|
-
createApiKey: {
|
|
159
|
-
description: 'Description',
|
|
160
|
-
roles: 'Roles',
|
|
161
|
-
submit: 'Create API key',
|
|
162
|
-
errorMessages: {
|
|
163
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
164
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
165
|
-
'INVALID_MEMBERSHIP': 'Invalid membership',
|
|
166
|
-
'PROJECT_NOT_FOUND': 'Project not found',
|
|
167
|
-
'ROLE_NOT_FOUND': 'Role not found',
|
|
168
|
-
'VARIABLE_EMPTY': 'Variable empty',
|
|
169
|
-
'VARIABLE_NOT_FOUND': 'Variable not found',
|
|
170
|
-
} satisfies Record<CreateApiKeyFormErrorCode, string>,
|
|
171
|
-
},
|
|
172
|
-
invite: {
|
|
173
|
-
email: 'Email',
|
|
174
|
-
name: 'Name',
|
|
175
|
-
roles: 'Roles',
|
|
176
|
-
submit: 'Invite',
|
|
177
|
-
addRole: 'Add new role',
|
|
178
|
-
errorMessages: {
|
|
179
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
180
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
181
|
-
'ALREADY_MEMBER': 'This person is already a member',
|
|
182
|
-
'INVALID_EMAIL_FORMAT': 'Invalid email format',
|
|
183
|
-
'INVALID_MEMBERSHIP': 'Invalid membership',
|
|
184
|
-
'PROJECT_NOT_FOUND': 'Project not found',
|
|
185
|
-
'ROLE_NOT_FOUND': 'Role not found',
|
|
186
|
-
'VARIABLE_EMPTY': 'Variable empty',
|
|
187
|
-
'VARIABLE_NOT_FOUND': 'Variable not found',
|
|
188
|
-
} satisfies Record<InviteFormErrorCode, string>,
|
|
189
|
-
},
|
|
190
|
-
changePassword: {
|
|
191
|
-
currentPassword: 'Current password',
|
|
192
|
-
newPassword: 'New password',
|
|
193
|
-
confirmPassword: 'Confirm password',
|
|
194
|
-
submit: 'Change password',
|
|
195
|
-
errorMessages: {
|
|
196
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
197
|
-
'INVALID_VALUE': 'Invalid value',
|
|
198
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
199
|
-
'PASSWORD_MISMATCH': 'Passwords do not match',
|
|
200
|
-
'TOO_WEAK': 'Password is too weak',
|
|
201
|
-
'NO_PASSWORD_SET': 'Your account has no password set',
|
|
202
|
-
'INVALID_PASSWORD': 'Invalid password',
|
|
203
|
-
'NOT_A_PERSON': 'Invalid user',
|
|
204
|
-
} satisfies Record<ChangeMyPasswordFormErrorCode, string>,
|
|
205
|
-
},
|
|
206
|
-
login: {
|
|
207
|
-
email: 'Email',
|
|
208
|
-
password: 'Password',
|
|
209
|
-
otpToken: '2FA OTP token',
|
|
210
|
-
forgotPassword: 'Forgot password?',
|
|
211
|
-
login: 'Login',
|
|
212
|
-
errorMessages: {
|
|
213
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
214
|
-
'INVALID_VALUE': 'Invalid value',
|
|
215
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
216
|
-
'INVALID_PASSWORD': 'Invalid password',
|
|
217
|
-
'INVALID_OTP_TOKEN': 'Invalid OTP token',
|
|
218
|
-
'NO_PASSWORD_SET': 'No password set',
|
|
219
|
-
'PERSON_DISABLED': 'Person disabled',
|
|
220
|
-
'UNKNOWN_EMAIL': 'Unknown email',
|
|
221
|
-
'INVALID_CREDENTIALS': 'Invalid credentials',
|
|
222
|
-
'RATE_LIMIT_EXCEEDED': 'Too many failed attempts, please try again later',
|
|
223
|
-
'OTP_REQUIRED': undefined,
|
|
224
|
-
} satisfies Record<LoginFormErrorCode, string | undefined>,
|
|
225
|
-
idpInitError: 'Failed to initialize IdP login:',
|
|
226
|
-
idpResponseError: 'Failed to process IdP response:',
|
|
227
|
-
title: 'Login',
|
|
228
|
-
description: 'Enter your email below to login to your account',
|
|
229
|
-
backToLogin: 'Back to login',
|
|
230
|
-
},
|
|
231
|
-
personList: {
|
|
232
|
-
email: 'Email',
|
|
233
|
-
name: 'Name',
|
|
234
|
-
deleted: 'Member deleted',
|
|
235
|
-
deleteFailed: 'Failed to delete member',
|
|
236
|
-
noEmail: 'User has no email',
|
|
237
|
-
noName: 'User has no name',
|
|
238
|
-
role: 'Role',
|
|
239
|
-
action: 'Action',
|
|
240
|
-
noResults: 'No members',
|
|
241
|
-
deleteConfirmation: 'Are you sure you want to delete this member?',
|
|
242
|
-
deleteCancelAction: 'Cancel',
|
|
243
|
-
deleteConfirmAction: 'Delete',
|
|
244
|
-
},
|
|
245
|
-
memberDelete: {
|
|
246
|
-
cancel: 'Cancel',
|
|
247
|
-
confirm: 'Confirm',
|
|
248
|
-
},
|
|
249
|
-
otpSetup: {
|
|
250
|
-
prepareContinue: 'Continue',
|
|
251
|
-
otpConfirmFormErrorMessages: {
|
|
252
|
-
UNKNOWN_ERROR: 'Something went wrong. Please try again later',
|
|
253
|
-
INVALID_OTP_TOKEN: 'Invalid OTP token',
|
|
254
|
-
FIELD_REQUIRED: 'This field is required',
|
|
255
|
-
NOT_PREPARED: 'OTP setup was not initialized',
|
|
256
|
-
} satisfies Record<OtpConfirmFormErrorCode, string>,
|
|
257
|
-
otpPrepareFormErrorMessages: {
|
|
258
|
-
UNKNOWN_ERROR: 'Something went wrong. Please try again later',
|
|
259
|
-
} satisfies Record<OtpPrepareFormErrorCode, string>,
|
|
260
|
-
alreadyHaveOtp: 'You already have two-factor authentication active. By clicking "Continue", the old one will no longer work.',
|
|
261
|
-
nowScanQrCode: 'Now scan the following QR code in your application:',
|
|
262
|
-
writeDownCode: 'After registering to your application, write down a code from the application.',
|
|
263
|
-
twoFactorEnabled: 'Two factor authentication is ENABLED.',
|
|
264
|
-
disableTwoFactor: 'Disable two-factor authentication',
|
|
265
|
-
disableTwoFactorConfirm: 'Are you sure you want to disable two-factor authentication?',
|
|
266
|
-
cancel: 'Cancel',
|
|
267
|
-
disable: 'Disable',
|
|
268
|
-
disabledSuccess: 'Two-factor authentication was disabled.',
|
|
269
|
-
setupAgain: 'Setup again',
|
|
270
|
-
description:
|
|
271
|
-
'2-Step Verification provides stronger security for your account by requiring a second step of verification when you sign in. In addition to your password, you’ll also need a code generated by an application on your phone.',
|
|
272
|
-
setupTwoFactor: 'Setup two-factor authentication',
|
|
273
|
-
enabledSuccess: 'Two-factor authentication was enabled.',
|
|
274
|
-
otpToken: 'OTP token',
|
|
275
|
-
label: 'Label',
|
|
276
|
-
confirm: 'Confirm',
|
|
277
|
-
},
|
|
278
|
-
|
|
279
|
-
passwordReset: {
|
|
280
|
-
token: 'Reset code',
|
|
281
|
-
password: 'Password',
|
|
282
|
-
passwordConfirmation: 'Confirm password',
|
|
283
|
-
submit: 'Reset password',
|
|
284
|
-
errorMessages: {
|
|
285
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
286
|
-
'INVALID_VALUE': 'Invalid value',
|
|
287
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
288
|
-
'PASSWORD_MISMATCH': 'Passwords do not match',
|
|
289
|
-
'PASSWORD_TOO_WEAK': 'Password is too weak',
|
|
290
|
-
'TOKEN_EXPIRED': 'Token expired',
|
|
291
|
-
'TOKEN_NOT_FOUND': 'Token not found',
|
|
292
|
-
'TOKEN_USED': 'Token already used',
|
|
293
|
-
'TOKEN_INVALID': 'Invalid token',
|
|
294
|
-
} satisfies Record<PasswordResetFormErrorCode, string>,
|
|
295
|
-
title: 'Reset password',
|
|
296
|
-
description: 'Enter new password below',
|
|
297
|
-
success: 'Password has been reset',
|
|
298
|
-
},
|
|
299
|
-
passwordResetRequest: {
|
|
300
|
-
email: 'E-mail',
|
|
301
|
-
submit: 'Request reset code',
|
|
302
|
-
errorMessages: {
|
|
303
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
304
|
-
'INVALID_VALUE': 'Invalid value',
|
|
305
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
306
|
-
'PERSON_NOT_FOUND': 'Unknown email',
|
|
307
|
-
} satisfies Record<PasswordResetRequestFormErrorCode, string>,
|
|
308
|
-
title: 'Reset password',
|
|
309
|
-
description: 'Enter your email below to reset your password',
|
|
310
|
-
success: 'Password reset link has been sent',
|
|
311
|
-
checkMail: 'Please check your mailbox for instructions on how to reset your password.',
|
|
312
|
-
entryCode: 'Or enter the reset code directly.',
|
|
313
|
-
},
|
|
314
|
-
passwordlessSignInInit: {
|
|
315
|
-
email: 'E-mail',
|
|
316
|
-
submit: 'Send magic link',
|
|
317
|
-
errorMessages: {
|
|
318
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
319
|
-
'INVALID_VALUE': 'Invalid value',
|
|
320
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
321
|
-
'PERSON_NOT_FOUND': 'Unknown email',
|
|
322
|
-
'PASSWORDLESS_DISABLED': 'Passwordless sign-in is not available',
|
|
323
|
-
} satisfies Record<PasswordlessSignInInitFormErrorCode, string>,
|
|
324
|
-
title: 'Sign in',
|
|
325
|
-
description: 'Enter your email below to sign in to your account',
|
|
326
|
-
success: 'Magic link has been sent',
|
|
327
|
-
checkMail: 'Please check your mailbox for instructions on how to sign in.',
|
|
328
|
-
entryCode: 'Or enter the reset code directly.',
|
|
329
|
-
},
|
|
330
|
-
passwordlessSignIn: {
|
|
331
|
-
token: 'Verification code',
|
|
332
|
-
otpToken: '2FA OTP token',
|
|
333
|
-
submit: 'Sign in',
|
|
334
|
-
errorMessages: {
|
|
335
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
336
|
-
'INVALID_VALUE': 'Invalid value',
|
|
337
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
338
|
-
'INVALID_OTP_TOKEN': 'Invalid OTP token',
|
|
339
|
-
'OTP_REQUIRED': undefined,
|
|
340
|
-
'PERSON_DISABLED': 'Person disabled',
|
|
341
|
-
'TOKEN_EXPIRED': 'Token expired',
|
|
342
|
-
'TOKEN_NOT_FOUND': 'Token not found',
|
|
343
|
-
'TOKEN_USED': 'Token already used',
|
|
344
|
-
'TOKEN_INVALID': 'Invalid token',
|
|
345
|
-
} satisfies Record<PasswordlessSignInFormErrorCode, string | undefined>,
|
|
346
|
-
title: 'Sign in',
|
|
347
|
-
},
|
|
348
|
-
otpActivation: {
|
|
349
|
-
errorMessages: {
|
|
350
|
-
'TOKEN_INVALID': 'This token is not valid. Please try again.',
|
|
351
|
-
'TOKEN_USED': 'Token already used',
|
|
352
|
-
'TOKEN_NOT_FOUND': 'Token not found',
|
|
353
|
-
'TOKEN_EXPIRED': 'Token expired',
|
|
354
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
355
|
-
} satisfies Record<ActivatePasswordlessOtpErrorCode | 'UNKNOWN_ERROR', string>,
|
|
356
|
-
},
|
|
357
|
-
|
|
358
|
-
updateProjectMember: {
|
|
359
|
-
updateSuccess: 'Roles updated',
|
|
360
|
-
roles: 'Roles',
|
|
361
|
-
submit: 'Update role',
|
|
362
|
-
errorMessages: {
|
|
363
|
-
'FIELD_REQUIRED': 'This field is required',
|
|
364
|
-
'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
|
|
365
|
-
'INVALID_MEMBERSHIP': 'Invalid membership',
|
|
366
|
-
'PROJECT_NOT_FOUND': 'Project not found',
|
|
367
|
-
'ROLE_NOT_FOUND': 'Role not found',
|
|
368
|
-
'VARIABLE_EMPTY': 'Variable empty',
|
|
369
|
-
'VARIABLE_NOT_FOUND': 'Variable not found',
|
|
370
|
-
'NOT_MEMBER': 'Not a member',
|
|
371
|
-
} satisfies Record<UpdateProjectMemberFormErrorCode, string>,
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
113
|
}
|
|
375
114
|
export const dictFormat = (value: string, replacements: Record<string, string>) => {
|
|
376
115
|
return value.replace(/\${([^}]+)}/g, (_, key) => replacements[key] || '')
|
|
@@ -17,20 +17,68 @@ import {
|
|
|
17
17
|
import { DataView, DataViewEachRow, DataViewLoaderState, DataViewSortingDirections, useDataViewEntityListAccessor } from '@contember/react-dataview'
|
|
18
18
|
import { ReactNode, useMemo } from 'react'
|
|
19
19
|
import { CheckIcon } from 'lucide-react'
|
|
20
|
-
import { Loader } from '
|
|
21
|
-
import { Popover, PopoverContent, PopoverTrigger } from '
|
|
22
|
-
import { Button } from '
|
|
23
|
-
import { DimensionLabelUI, DimensionLabelWrapperUI } from '
|
|
20
|
+
import { Loader } from '~/lib'
|
|
21
|
+
import { Popover, PopoverContent, PopoverTrigger } from '~/lib'
|
|
22
|
+
import { Button } from '~/lib'
|
|
23
|
+
import { DimensionLabelUI, DimensionLabelWrapperUI } from '~/lib'
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Props for the {@link DimensionsSwitcher} component.
|
|
27
|
+
*/
|
|
25
28
|
export type DimensionsSwitcherProps = {
|
|
29
|
+
/**
|
|
30
|
+
* Entity list for dimension options.
|
|
31
|
+
*/
|
|
26
32
|
options: SugaredQualifiedEntityList['entities']
|
|
33
|
+
/**
|
|
34
|
+
* Specifies initial sorting of the options (e.g., `{ label: 'desc' }`).
|
|
35
|
+
*/
|
|
27
36
|
orderBy?: DataViewSortingDirections
|
|
37
|
+
/**
|
|
38
|
+
* The name of the dimension to switch.
|
|
39
|
+
*/
|
|
28
40
|
dimension: string
|
|
41
|
+
/**
|
|
42
|
+
* Child components or fields to render within the dimension selector.
|
|
43
|
+
*/
|
|
29
44
|
children: ReactNode
|
|
45
|
+
/**
|
|
46
|
+
* Field containing unique dimension identifiers.
|
|
47
|
+
*/
|
|
30
48
|
slugField: SugaredRelativeSingleField['field']
|
|
49
|
+
/**
|
|
50
|
+
* Enables multi-selection mode.
|
|
51
|
+
*/
|
|
31
52
|
isMulti?: boolean
|
|
32
53
|
}
|
|
33
54
|
|
|
55
|
+
/**
|
|
56
|
+
* `DimensionsSwitcher` is a UI component for switching between different dimensions of data.
|
|
57
|
+
*
|
|
58
|
+
* ## Example: Basic usage
|
|
59
|
+
* ```tsx
|
|
60
|
+
* <DimensionsSwitcher
|
|
61
|
+
* dimension="locale"
|
|
62
|
+
* slugField="code"
|
|
63
|
+
* options="DimensionsLocale"
|
|
64
|
+
* >
|
|
65
|
+
* <Field field="label" />
|
|
66
|
+
* </DimensionsSwitcher>
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* ## Example: With initial sorting and multi-selection
|
|
70
|
+
* ```tsx
|
|
71
|
+
* <DimensionsSwitcher
|
|
72
|
+
* dimension="locale"
|
|
73
|
+
* slugField="code"
|
|
74
|
+
* options="DimensionsLocale"
|
|
75
|
+
* orderBy={{ label: 'desc' }}
|
|
76
|
+
* isMulti
|
|
77
|
+
* >
|
|
78
|
+
* <Field field="label" />
|
|
79
|
+
* </DimensionsSwitcher>
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
34
82
|
export const DimensionsSwitcher = Component(({ options, dimension, children, slugField, orderBy, isMulti }: DimensionsSwitcherProps) => (
|
|
35
83
|
<DataView entities={options} initialSorting={orderBy}>
|
|
36
84
|
<DataViewLoaderState initial refreshing>
|
|
@@ -122,14 +170,47 @@ export type RenderLabelProps = {
|
|
|
122
170
|
dimensionValue: string | null
|
|
123
171
|
}
|
|
124
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Props for the {@link SideDimensions} component.
|
|
175
|
+
*/
|
|
125
176
|
export type SideDimensionsProps = {
|
|
177
|
+
/**
|
|
178
|
+
* The name of the dimension to render.
|
|
179
|
+
*/
|
|
126
180
|
dimension: string
|
|
181
|
+
/**
|
|
182
|
+
* The name of the dimension variable to expose in the context.
|
|
183
|
+
*/
|
|
127
184
|
as: string
|
|
185
|
+
/**
|
|
186
|
+
* The field to traverse via `HasOne` relationship.
|
|
187
|
+
*/
|
|
128
188
|
field: SugaredRelativeSingleEntity['field']
|
|
189
|
+
/**
|
|
190
|
+
* Child components or fields to render within the dimension selector.
|
|
191
|
+
*/
|
|
129
192
|
children: ReactNode
|
|
193
|
+
/**
|
|
194
|
+
* Optional custom label renderer. Receives the label and the current dimension value.
|
|
195
|
+
*/
|
|
130
196
|
renderLabel?: ({ label, dimensionValue }: RenderLabelProps) => ReactNode
|
|
131
197
|
}
|
|
132
198
|
|
|
199
|
+
/**
|
|
200
|
+
* `SideDimensions` is a layout component that renders content for a specific dimension
|
|
201
|
+
* within a flexible side panel. It wraps its content inside a `DimensionRenderer` and `HasOne` field relationship.
|
|
202
|
+
*
|
|
203
|
+
* ## Example: Basic Usage
|
|
204
|
+
* ```tsx
|
|
205
|
+
* <SideDimensions
|
|
206
|
+
* dimension="locale"
|
|
207
|
+
* as="currentLocale"
|
|
208
|
+
* field="locales(locale.code = $currentLocale)"
|
|
209
|
+
* >
|
|
210
|
+
* <InputField field="title" />
|
|
211
|
+
* </SideDimensions>
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
133
214
|
export const SideDimensions = Component<SideDimensionsProps>(({ dimension, children, as, field, renderLabel }) => (
|
|
134
215
|
<div className="flex mt-4 gap-4">
|
|
135
216
|
<DimensionRenderer dimension={dimension} as={as}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dimensions'
|
|
1
|
+
export * from './dimensions.js'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReactNode, useCallback, useMemo } from 'react'
|
|
2
|
-
import { EditorCanvas } from './common/editor-canvas'
|
|
3
|
-
import { EditorEditableCanvas } from './common/editor-editable-canvas'
|
|
2
|
+
import { EditorCanvas } from './common/editor-canvas.js'
|
|
3
|
+
import { EditorEditableCanvas } from './common/editor-editable-canvas.js'
|
|
4
4
|
import { BlockEditor, BlockEditorProps, withReferences } from '@contember/react-slate-editor'
|
|
5
5
|
import { Component, SugaredRelativeEntityList, SugaredRelativeSingleField } from '@contember/interface'
|
|
6
6
|
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'
|
|
7
7
|
import { useSlate, useSlateStatic } from 'slate-react'
|
|
8
|
-
import { blockEditorPlugins } from './plugins'
|
|
8
|
+
import { blockEditorPlugins } from './plugins.js'
|
|
9
9
|
import {
|
|
10
10
|
closestCenter,
|
|
11
11
|
DndContext,
|
|
@@ -22,11 +22,80 @@ import { Transforms } from 'slate'
|
|
|
22
22
|
export type BlockEditorFieldProps =
|
|
23
23
|
& BlockEditorProps
|
|
24
24
|
& {
|
|
25
|
+
/** Field for storing related entities */
|
|
25
26
|
referencesField: SugaredRelativeEntityList['field']
|
|
27
|
+
/** Field for entity type discrimination */
|
|
26
28
|
referenceDiscriminationField: SugaredRelativeSingleField['field']
|
|
29
|
+
/** Editor placeholder text */
|
|
27
30
|
placeholder?: string
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
/**
|
|
34
|
+
* BlockEditorField component - Rich text editor with drag-and-drop block management
|
|
35
|
+
*
|
|
36
|
+
* ## Purpose
|
|
37
|
+
* Provides a structured content editing experience with sortable blocks and reference management
|
|
38
|
+
*
|
|
39
|
+
* ## Features
|
|
40
|
+
* - Drag-and-drop block reordering
|
|
41
|
+
* - Reference entity integration
|
|
42
|
+
* - Slate.js editor core
|
|
43
|
+
* - Plugin system extensibility
|
|
44
|
+
* - Collision detection and measuring strategies
|
|
45
|
+
*
|
|
46
|
+
* ## Example: Basic usage
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <BlockEditorField
|
|
49
|
+
* field="data"
|
|
50
|
+
* referencesField="references"
|
|
51
|
+
* referenceDiscriminationField="type"
|
|
52
|
+
* >
|
|
53
|
+
* <EditorBlockToolbar>
|
|
54
|
+
* <EditorReferenceTrigger referenceType="image">
|
|
55
|
+
* <BlockButton><ImageIcon /> Image</BlockButton>
|
|
56
|
+
* </EditorReferenceTrigger>
|
|
57
|
+
* </EditorBlockToolbar>
|
|
58
|
+
*
|
|
59
|
+
* <EditorBlock name="image" label="Image">
|
|
60
|
+
* <ImageField baseField="image" urlField="url" />
|
|
61
|
+
* </EditorBlock>
|
|
62
|
+
* </BlockEditorField>
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* ## Example with custom plugins and toolbars (inline and block)
|
|
66
|
+
* ```tsx
|
|
67
|
+
* <BlockEditorField
|
|
68
|
+
* field="data"
|
|
69
|
+
* referencesField="references"
|
|
70
|
+
* referenceDiscriminationField="type"
|
|
71
|
+
* plugins={[
|
|
72
|
+
* editor => {
|
|
73
|
+
* editor.registerElement({
|
|
74
|
+
* type: 'link',
|
|
75
|
+
* isInline: true,
|
|
76
|
+
* render: LinkElement,
|
|
77
|
+
* })
|
|
78
|
+
* },
|
|
79
|
+
* ]}
|
|
80
|
+
* >
|
|
81
|
+
* <EditorBlockToolbar>
|
|
82
|
+
* <EditorReferenceTrigger referenceType="image">
|
|
83
|
+
* <BlockButton>
|
|
84
|
+
* <ImageIcon /> Image
|
|
85
|
+
* </BlockButton>
|
|
86
|
+
* </EditorReferenceTrigger>
|
|
87
|
+
* </EditorBlockToolbar>
|
|
88
|
+
*
|
|
89
|
+
* <EditorBlock name="quote" label="Quote">
|
|
90
|
+
* <EditorBlockContent />
|
|
91
|
+
* </EditorBlock>
|
|
92
|
+
*
|
|
93
|
+
* <EditorBlock name="image" label="Image">
|
|
94
|
+
* <ImageField baseField="image" urlField="url" />
|
|
95
|
+
* </EditorBlock>
|
|
96
|
+
* </BlockEditorField>
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
30
99
|
export const BlockEditorField = Component<BlockEditorFieldProps>(({ placeholder, children, ...props }) => {
|
|
31
100
|
return (
|
|
32
101
|
<BlockEditor
|