@webiny/app-headless-cms 6.6.0-alpha.0 → 6.6.0-alpha.2
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/ContentEntriesModule.js +3 -3
- package/ContentEntriesModule.js.map +1 -1
- package/HeadlessCMS.js +7 -2
- package/HeadlessCMS.js.map +1 -1
- package/admin/RoutesConfig.js +14 -1
- package/admin/RoutesConfig.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionMove.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionMove.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionPublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionPublish.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.d.ts +2 -2
- package/admin/components/ContentEntries/BulkActions/ActionUnpublish.js.map +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditorProvider.js +1 -0
- package/admin/components/ContentModelEditor/ContentModelEditorProvider.js.map +1 -1
- package/admin/components/ContentModelEditor/FieldsSidebar.js +12 -2
- package/admin/components/ContentModelEditor/FieldsSidebar.js.map +1 -1
- package/admin/components/ContentModelEditor/evaluateExpression.js +4 -0
- package/admin/components/ContentModelEditor/evaluateExpression.js.map +1 -1
- package/admin/components/Dialogs/PublishEntryConfirmDialog.d.ts +26 -1
- package/admin/components/Dialogs/PublishEntryConfirmDialog.js +4 -3
- package/admin/components/Dialogs/PublishEntryConfirmDialog.js.map +1 -1
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.d.ts +26 -1
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js +4 -3
- package/admin/components/Dialogs/UnpublishEntryConfirmDialog.js.map +1 -1
- package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js +3 -3
- package/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/PermissionsEditor.js.map +1 -1
- package/admin/components/FieldEditor/EditFieldDialog.d.ts +2 -2
- package/admin/components/FieldEditor/EditFieldDialog.js +5 -2
- package/admin/components/FieldEditor/EditFieldDialog.js.map +1 -1
- package/admin/components/FieldEditor/Field.js +1 -1
- package/admin/components/FieldEditor/Field.js.map +1 -1
- package/admin/components/FieldEditor/FieldEditor.js +2 -2
- package/admin/components/FieldEditor/FieldEditor.js.map +1 -1
- package/admin/components/FieldEditor/FieldEditorContext.d.ts +1 -1
- package/admin/components/FieldEditor/FieldEditorContext.js +6 -1
- package/admin/components/FieldEditor/FieldEditorContext.js.map +1 -1
- package/admin/components/LexicalCmsEditor/LexicalEditor.js +10 -6
- package/admin/components/LexicalCmsEditor/LexicalEditor.js.map +1 -1
- package/admin/components/LexicalCmsEditor/TypographyDropDown.js +3 -2
- package/admin/components/LexicalCmsEditor/TypographyDropDown.js.map +1 -1
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.d.ts +60 -2
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js +18 -5
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.js.map +1 -1
- package/admin/config/contentEntries/editor/NewEntryWizard.d.ts +8 -1
- package/admin/config/contentEntries/editor/NewEntryWizard.js +20 -5
- package/admin/config/contentEntries/editor/NewEntryWizard.js.map +1 -1
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.d.ts +38 -0
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js +23 -0
- package/admin/config/contentEntries/list/Browser/BreadcrumbRoot.js.map +1 -0
- package/admin/config/contentEntries/list/Browser/index.d.ts +21 -0
- package/admin/config/contentEntries/list/Browser/index.js +2 -0
- package/admin/config/contentEntries/list/Browser/index.js.map +1 -1
- package/admin/config/contentEntries/list/ContentEntryListConfig.d.ts +39 -0
- package/admin/config/contentEntries/list/ContentEntryListConfig.js +2 -1
- package/admin/config/contentEntries/list/ContentEntryListConfig.js.map +1 -1
- package/admin/graphql/contentModels.d.ts +1 -1
- package/admin/graphql/contentModels.js +2 -1
- package/admin/graphql/contentModels.js.map +1 -1
- package/admin/plugins/editor/formSettings/components/GeneralSettings.js +24 -1
- package/admin/plugins/editor/formSettings/components/GeneralSettings.js.map +1 -1
- package/exports/admin/cms/entry/editor.d.ts +1 -0
- package/exports/admin/cms/entry/editor.js +1 -0
- package/exports/admin/cms/entry/list.d.ts +2 -0
- package/exports/admin/cms/entry/list.js +2 -0
- package/exports/admin/cms.d.ts +2 -0
- package/exports/admin/cms.js +2 -0
- package/features/contentEntry/EntryGraphQLFields.js +1 -1
- package/features/contentEntry/EntryGraphQLFields.js.map +1 -1
- package/features/contentEntry/createEntry/CreateEntryRepository.d.ts +3 -1
- package/features/contentEntry/createEntry/CreateEntryRepository.js +10 -2
- package/features/contentEntry/createEntry/CreateEntryRepository.js.map +1 -1
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.d.ts +3 -1
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.js +12 -2
- package/features/contentEntry/deleteEntry/DeleteEntryRepository.js.map +1 -1
- package/features/contentEntry/refTypes.d.ts +7 -0
- package/features/contentEntry/refTypes.js.map +1 -1
- package/features/contentEntry/updateEntry/UpdateEntryRepository.d.ts +3 -1
- package/features/contentEntry/updateEntry/UpdateEntryRepository.js +10 -2
- package/features/contentEntry/updateEntry/UpdateEntryRepository.js.map +1 -1
- package/features/formModel/mappers/AssetFieldMapper.d.ts +12 -0
- package/features/formModel/mappers/AssetFieldMapper.js +13 -0
- package/features/formModel/mappers/AssetFieldMapper.js.map +1 -0
- package/features/formModel/mappers/index.js +2 -0
- package/features/formModel/mappers/index.js.map +1 -1
- package/features/model/updateModel/UpdateModelGateway.js +1 -0
- package/features/model/updateModel/UpdateModelGateway.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +24 -24
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +4 -0
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.d.ts +6 -0
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js +47 -0
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js.map +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +14 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.js +33 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.d.ts +2 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +27 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.d.ts +15 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.js +43 -0
- package/presentation/contentEntries/preview/PreviewComponentsContext.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewDecorator.d.ts +2 -0
- package/presentation/contentEntries/preview/PreviewDecorator.js +48 -0
- package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewPane.d.ts +9 -0
- package/presentation/contentEntries/preview/PreviewPane.js +181 -0
- package/presentation/contentEntries/preview/PreviewPane.js.map +1 -0
- package/presentation/contentEntries/preview/abstractions.d.ts +16 -0
- package/presentation/contentEntries/preview/abstractions.js +5 -0
- package/presentation/contentEntries/preview/abstractions.js.map +1 -0
- package/presentation/contentEntries/preview/feature.d.ts +3 -0
- package/presentation/contentEntries/preview/feature.js +17 -0
- package/presentation/contentEntries/preview/feature.js.map +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +5 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.js +29 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.d.ts +1 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.js +8 -0
- package/presentation/contentEntries/preview/useLivePreviewPresenter.js.map +1 -0
- package/presentation/contentEntries/trashBin/CmsTrashBin.d.ts +2 -2
- package/presentation/contentEntries/views/CmsAdvancedSearch.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.d.ts +13 -0
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js +54 -0
- package/presentation/contentEntries/views/ContentEntriesBreadcrumbs.js.map +1 -0
- package/presentation/contentEntries/views/ContentEntriesListLayout.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntriesListLayout.js +3 -2
- package/presentation/contentEntries/views/ContentEntriesListLayout.js.map +1 -1
- package/presentation/contentEntries/views/ContentEntryFormView.d.ts +2 -2
- package/presentation/contentEntries/views/ContentEntryFormView.js +5 -6
- package/presentation/contentEntries/views/ContentEntryFormView.js.map +1 -1
- package/presentation/contentEntries/views/RevisionDrawer.d.ts +2 -2
- package/presentation/contentEntries/views/RevisionsList.d.ts +2 -2
- package/presentation/contentEntries/views/SingleEntryLayout.d.ts +2 -2
- package/presentation/contentEntries/views/Table/Table.d.ts +2 -2
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/DeleteEntryMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/actions/PublishOnlyButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/RevisionSelector.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveAndPublishButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/SaveContentButton.d.ts +2 -2
- package/presentation/contentEntries/views/actions/ShowRevisionListMenuItem.d.ts +2 -2
- package/presentation/contentEntries/views/layout/ContentEntryForm.d.ts +12 -12
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.d.ts +10 -6
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.js +7 -2
- package/presentation/contentEntries/views/layout/ContentEntryFormContent.js.map +1 -1
- package/presentation/contentModels/components/CloneContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/ContentModels.d.ts +2 -2
- package/presentation/contentModels/components/ContentModelsDataList.d.ts +2 -2
- package/presentation/contentModels/components/NewContentModelDialog.d.ts +2 -2
- package/presentation/contentModels/components/fullDelete/types.js.map +1 -1
- package/presentation/fieldEditor/FieldEditorPresenter.js +1 -1
- package/presentation/fieldEditor/FieldEditorPresenter.js.map +1 -1
- package/presentation/fieldEditor/groups/ValidationsGroup.js +1 -1
- package/presentation/fieldEditor/groups/ValidationsGroup.js.map +1 -1
- package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js +3 -3
- package/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js +8 -0
- package/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js +8 -0
- package/presentation/fieldRenderers/ref/CmsRefDetailedSingleRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.d.ts +10 -0
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js +94 -0
- package/presentation/fieldRenderers/ref/components/EditEntryDrawer.js.map +1 -0
- package/presentation/fieldRenderers/ref/components/EntryCard.d.ts +2 -0
- package/presentation/fieldRenderers/ref/components/EntryCard.js +13 -3
- package/presentation/fieldRenderers/ref/components/EntryCard.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.d.ts +2 -2
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.d.ts +2 -1
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js +6 -0
- package/presentation/fieldRenderers/ref/detailed/RefDetailedPresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/detailed/abstractions.d.ts +2 -1
- package/presentation/fieldRenderers/ref/detailed/abstractions.js.map +1 -1
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.d.ts +13 -0
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js +25 -0
- package/presentation/fieldRenderers/ref/editEntry/EditEntryPresenter.js.map +1 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.d.ts +10 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.js +5 -0
- package/presentation/fieldRenderers/ref/editEntry/abstractions.js.map +1 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.d.ts +3 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.js +17 -0
- package/presentation/fieldRenderers/ref/editEntry/feature.js.map +1 -0
- package/presentation/fieldTypes/abstractions.d.ts +12 -0
- package/presentation/fieldTypes/abstractions.js.map +1 -1
- package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js +1 -1
- package/presentation/fieldTypes/renderers/common/SelectBoxRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js +6 -2
- package/presentation/fieldTypes/renderers/dynamicZone/DynamicZoneRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js +2 -0
- package/presentation/fieldTypes/renderers/object/ObjectAccordionRenderer.js.map +1 -1
- package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js +6 -0
- package/presentation/fieldTypes/renderers/object/ObjectsAccordionRenderer.js.map +1 -1
- package/presentation/fieldTypes/types/DynamicZoneFieldType.d.ts +3 -6
- package/presentation/fieldTypes/types/DynamicZoneFieldType.js +2 -12
- package/presentation/fieldTypes/types/DynamicZoneFieldType.js.map +1 -1
- package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js +25 -3
- package/presentation/fieldTypes/types/dynamicZone/TemplateDialog.js.map +1 -1
- package/presentation/importContentModels/ImportContentModelsDialog.d.ts +2 -2
- package/presentation/importContentModels/components/DataList.d.ts +2 -2
- package/presentation/importContentModels/components/FileUpload.d.ts +2 -2
- package/presentation/importContentModels/components/Model/DataListModels.d.ts +2 -2
- package/presentation/menus/ContentGroupsMenuItems.d.ts +2 -2
- package/presentation/modelGroup/ModelGroupPresenter.d.ts +3 -1
- package/presentation/modelGroup/ModelGroupPresenter.js +7 -9
- package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
- package/presentation/modelGroup/components/ContentModelGroups.d.ts +2 -2
- package/presentation/modelGroup/components/ContentModelGroupsDataList.d.ts +6 -2
- package/presentation/modelGroup/components/ContentModelGroupsForm.d.ts +8 -2
|
@@ -4,7 +4,7 @@ interface SingleEntryLayoutProps {
|
|
|
4
4
|
presenter: ISingleEntryPresenter;
|
|
5
5
|
modelName: string;
|
|
6
6
|
}
|
|
7
|
-
export declare const SingleEntryLayout: (({ presenter, modelName }: SingleEntryLayoutProps) => React.JSX.Element | null) & {
|
|
8
|
-
|
|
7
|
+
export declare const SingleEntryLayout: (({ presenter, modelName }: SingleEntryLayoutProps) => React.JSX.Element | null) & React.NamedExoticComponent<SingleEntryLayoutProps> & {
|
|
8
|
+
readonly type: ({ presenter, modelName }: SingleEntryLayoutProps) => React.JSX.Element | null;
|
|
9
9
|
};
|
|
10
10
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const CreateNewRevisionButton: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const CreateNewRevisionButton: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const DeleteEntryMenuItem: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const DeleteEntryMenuItem: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const PublishOnlyButton: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const PublishOnlyButton: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const RevisionSelector: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const RevisionSelector: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const SaveAndPublishButton: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const SaveAndPublishButton: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const SaveContentButton: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const SaveContentButton: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const ShowRevisionListMenuItem: (() => React.JSX.Element) & {
|
|
3
|
-
|
|
2
|
+
export declare const ShowRevisionListMenuItem: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element;
|
|
4
4
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
export declare const ContentEntryForm: (() => React.JSX.Element | null) & {
|
|
3
|
-
|
|
2
|
+
export declare const ContentEntryForm: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element | null;
|
|
4
4
|
} & {
|
|
5
|
-
original: (() => React.JSX.Element | null) & {
|
|
6
|
-
|
|
5
|
+
original: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
6
|
+
readonly type: () => React.JSX.Element | null;
|
|
7
7
|
};
|
|
8
8
|
originalName: string;
|
|
9
9
|
displayName: string;
|
|
10
10
|
} & {
|
|
11
|
-
original: (() => React.JSX.Element | null) & {
|
|
12
|
-
|
|
11
|
+
original: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
12
|
+
readonly type: () => React.JSX.Element | null;
|
|
13
13
|
} & {
|
|
14
|
-
original: (() => React.JSX.Element | null) & {
|
|
15
|
-
|
|
14
|
+
original: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
15
|
+
readonly type: () => React.JSX.Element | null;
|
|
16
16
|
};
|
|
17
17
|
originalName: string;
|
|
18
18
|
displayName: string;
|
|
@@ -20,11 +20,11 @@ export declare const ContentEntryForm: (() => React.JSX.Element | null) & {
|
|
|
20
20
|
originalName: string;
|
|
21
21
|
displayName: string;
|
|
22
22
|
} & {
|
|
23
|
-
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(() => React.JSX.Element | null) & {
|
|
24
|
-
|
|
23
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
24
|
+
readonly type: () => React.JSX.Element | null;
|
|
25
25
|
} & {
|
|
26
|
-
original: (() => React.JSX.Element | null) & {
|
|
27
|
-
|
|
26
|
+
original: (() => React.JSX.Element | null) & React.NamedExoticComponent<unknown> & {
|
|
27
|
+
readonly type: () => React.JSX.Element | null;
|
|
28
28
|
};
|
|
29
29
|
originalName: string;
|
|
30
30
|
displayName: string;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
interface ContentEntryFormContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
width?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const ContentEntryFormContent: (({ children, className, width, ...props }: ContentEntryFormContentProps) => React.JSX.Element) & {
|
|
6
|
+
original: ({ children, className, width, ...props }: ContentEntryFormContentProps) => React.JSX.Element;
|
|
4
7
|
originalName: string;
|
|
5
8
|
displayName: string;
|
|
6
9
|
} & {
|
|
7
|
-
original: (({ children, className, ...props }:
|
|
8
|
-
original: ({ children, className, ...props }:
|
|
10
|
+
original: (({ children, className, width, ...props }: ContentEntryFormContentProps) => React.JSX.Element) & {
|
|
11
|
+
original: ({ children, className, width, ...props }: ContentEntryFormContentProps) => React.JSX.Element;
|
|
9
12
|
originalName: string;
|
|
10
13
|
displayName: string;
|
|
11
14
|
};
|
|
12
15
|
originalName: string;
|
|
13
16
|
displayName: string;
|
|
14
17
|
} & {
|
|
15
|
-
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ children, className, ...props }:
|
|
16
|
-
original: ({ children, className, ...props }:
|
|
18
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<(({ children, className, width, ...props }: ContentEntryFormContentProps) => React.JSX.Element) & {
|
|
19
|
+
original: ({ children, className, width, ...props }: ContentEntryFormContentProps) => React.JSX.Element;
|
|
17
20
|
originalName: string;
|
|
18
21
|
displayName: string;
|
|
19
22
|
}>) => (props: unknown) => React.JSX.Element;
|
|
20
23
|
};
|
|
24
|
+
export {};
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { cn } from "@webiny/admin-ui";
|
|
3
3
|
import { makeDecoratable } from "@webiny/react-composition";
|
|
4
|
-
const ContentEntryFormContent = makeDecoratable("Content", ({ children, className, ...props })=>/*#__PURE__*/ react.createElement("div", {
|
|
4
|
+
const ContentEntryFormContent = makeDecoratable("Content", ({ children, className, width, ...props })=>/*#__PURE__*/ react.createElement("div", {
|
|
5
5
|
className: cn("flex justify-center pt-xl", className),
|
|
6
6
|
...props
|
|
7
|
-
},
|
|
7
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
8
|
+
className: "bg-neutral-base rounded-lg p-lg",
|
|
9
|
+
style: {
|
|
10
|
+
width
|
|
11
|
+
}
|
|
12
|
+
}, children)));
|
|
8
13
|
export { ContentEntryFormContent };
|
|
9
14
|
|
|
10
15
|
//# sourceMappingURL=ContentEntryFormContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentEntries/views/layout/ContentEntryFormContent.js","sources":["../../../../../src/presentation/contentEntries/views/layout/ContentEntryFormContent.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"@webiny/admin-ui\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\n\nexport const ContentEntryFormContent = makeDecoratable(\n \"Content\",\n ({ children, className, ...props }:
|
|
1
|
+
{"version":3,"file":"presentation/contentEntries/views/layout/ContentEntryFormContent.js","sources":["../../../../../src/presentation/contentEntries/views/layout/ContentEntryFormContent.tsx"],"sourcesContent":["import React from \"react\";\nimport { cn } from \"@webiny/admin-ui\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\n\ninterface ContentEntryFormContentProps extends React.HTMLAttributes<HTMLDivElement> {\n width?: string;\n}\n\nexport const ContentEntryFormContent = makeDecoratable(\n \"Content\",\n ({ children, className, width, ...props }: ContentEntryFormContentProps) => {\n return (\n <div className={cn(\"flex justify-center pt-xl\", className)} {...props}>\n <div className={\"bg-neutral-base rounded-lg p-lg\"} style={{ width }}>\n {children}\n </div>\n </div>\n );\n }\n);\n"],"names":["ContentEntryFormContent","makeDecoratable","children","className","width","props","cn"],"mappings":";;;AAQO,MAAMA,0BAA0BC,gBACnC,WACA,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGC,OAAqC,GAC5D,WAAP,GACI,oBAAC;QAAI,WAAWC,GAAG,6BAA6BH;QAAa,GAAGE,KAAK;qBACjE,oBAAC;QAAI,WAAW;QAAmC,OAAO;YAAED;QAAM;OAC7DF"}
|
|
@@ -5,7 +5,7 @@ interface CloneContentModelDialogProps {
|
|
|
5
5
|
contentModel: CmsModel;
|
|
6
6
|
closeModal: () => void;
|
|
7
7
|
}
|
|
8
|
-
export declare const CloneContentModelDialog: (({ onClose, contentModel, closeModal }: CloneContentModelDialogProps) => React.JSX.Element) & {
|
|
9
|
-
|
|
8
|
+
export declare const CloneContentModelDialog: (({ onClose, contentModel, closeModal }: CloneContentModelDialogProps) => React.JSX.Element) & React.NamedExoticComponent<CloneContentModelDialogProps> & {
|
|
9
|
+
readonly type: ({ onClose, contentModel, closeModal }: CloneContentModelDialogProps) => React.JSX.Element;
|
|
10
10
|
};
|
|
11
11
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
declare const ContentModels: (() => React.JSX.Element) & {
|
|
3
|
-
|
|
2
|
+
declare const ContentModels: (() => React.JSX.Element) & React.NamedExoticComponent<unknown> & {
|
|
3
|
+
readonly type: () => React.JSX.Element;
|
|
4
4
|
};
|
|
5
5
|
export default ContentModels;
|
|
@@ -6,7 +6,7 @@ interface ContentModelsDataListProps {
|
|
|
6
6
|
onClone: (contentModel: CmsModel) => void;
|
|
7
7
|
showImportModelModal: () => void;
|
|
8
8
|
}
|
|
9
|
-
declare const ContentModelsDataList: (({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => React.JSX.Element) & {
|
|
10
|
-
|
|
9
|
+
declare const ContentModelsDataList: (({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => React.JSX.Element) & React.NamedExoticComponent<ContentModelsDataListProps> & {
|
|
10
|
+
readonly type: ({ canCreate, onCreate, onClone, showImportModelModal }: ContentModelsDataListProps) => React.JSX.Element;
|
|
11
11
|
};
|
|
12
12
|
export default ContentModelsDataList;
|
|
@@ -4,7 +4,7 @@ export interface NewContentModelDialogProps {
|
|
|
4
4
|
open: boolean;
|
|
5
5
|
onClose: DialogProps["onClose"];
|
|
6
6
|
}
|
|
7
|
-
declare const NewContentModelDialog: (({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element) & {
|
|
8
|
-
|
|
7
|
+
declare const NewContentModelDialog: (({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element) & React.NamedExoticComponent<NewContentModelDialogProps> & {
|
|
8
|
+
readonly type: ({ open, onClose }: NewContentModelDialogProps) => React.JSX.Element;
|
|
9
9
|
};
|
|
10
10
|
export default NewContentModelDialog;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/contentModels/components/fullDelete/types.js","sources":["../../../../../src/presentation/contentModels/components/fullDelete/types.ts"],"sourcesContent":["import type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { IDeleteCmsModelTask } from \"~/admin/viewsGraphql.js\";\n\nexport enum FullyDeleteModelStateStatus {\n NONE = 0,\n UNDERSTOOD = 1,\n CONFIRMED = 2,\n PROCESSED = 3,\n ERROR = 999\n}\n\nexport interface IFullyDeleteModelState {\n status: FullyDeleteModelStateStatus;\n confirmation: string;\n model: CmsModel;\n error: CmsErrorResponse | null;\n task: IDeleteCmsModelTask | null;\n}\n"],"names":["FullyDeleteModelStateStatus"],"mappings":"AAGO,IAAKA,oCAA2BA,WAAAA,GAAAA,SAA3BA,2BAA2B
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/types.js","sources":["../../../../../src/presentation/contentModels/components/fullDelete/types.ts"],"sourcesContent":["import type { CmsErrorResponse, CmsModel } from \"~/types.js\";\nimport type { IDeleteCmsModelTask } from \"~/admin/viewsGraphql.js\";\n\nexport enum FullyDeleteModelStateStatus {\n NONE = 0,\n UNDERSTOOD = 1,\n CONFIRMED = 2,\n PROCESSED = 3,\n ERROR = 999\n}\n\nexport interface IFullyDeleteModelState {\n status: FullyDeleteModelStateStatus;\n confirmation: string;\n model: CmsModel;\n error: CmsErrorResponse | null;\n task: IDeleteCmsModelTask | null;\n}\n"],"names":["FullyDeleteModelStateStatus"],"mappings":"AAGO,IAAKA,oCAA2BA,WAAAA,GAAAA,SAA3BA,2BAA2B;sEAC5B;4EACM;2EACD;2EACA;uEACJ;WALAA"}
|
|
@@ -25,7 +25,7 @@ class FieldEditorPresenterImpl {
|
|
|
25
25
|
}
|
|
26
26
|
init(field, model) {
|
|
27
27
|
this.originalField = cloneDeep(field);
|
|
28
|
-
const fieldType = this.fieldTypes.find((ft)=>ft.type === field.type);
|
|
28
|
+
const fieldType = this.fieldTypes.find((ft)=>ft.matches?.(field)) ?? this.fieldTypes.find((ft)=>ft.type === field.type);
|
|
29
29
|
if (!fieldType) throw new Error(`Unknown field type: ${field.type}`);
|
|
30
30
|
this.context = {
|
|
31
31
|
field,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldEditor/FieldEditorPresenter.js","sources":["../../../src/presentation/fieldEditor/FieldEditorPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed } from \"mobx\";\nimport { FormModelFactory, FormModel } from \"@webiny/app-admin\";\nimport cloneDeep from \"lodash/cloneDeep.js\";\nimport {\n FieldEditorPresenter as PresenterAbstraction,\n CmsFieldEditorGroup,\n CmsFieldEditorGroupModifier\n} from \"./abstractions.js\";\nimport type {\n ICmsFieldEditorFormBuilder,\n ICmsFieldEditorContext,\n ICmsFieldEditorGroup,\n ICmsFieldEditorGroupModifier,\n IFieldEditorPresenter\n} from \"./abstractions.js\";\nimport { CmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport type { ICmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport type { CmsModel, CmsModelField } from \"~/types.js\";\n\ntype FieldsFactory = (\n fields: FormModelFactory.FieldBuilderRegistry\n) => Record<string, FormModelFactory.FieldBuilder>;\n\ntype LayoutFactory = (layout: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[];\n\ninterface CollectedGroup {\n group: ICmsFieldEditorGroup;\n fieldsFns: FieldsFactory[];\n layoutFns: LayoutFactory[];\n}\n\nclass FieldEditorPresenterImpl implements IFieldEditorPresenter {\n private form: FormModel.Interface | null = null;\n private context: ICmsFieldEditorContext | null = null;\n private originalField: CmsModelField | null = null;\n\n constructor(\n private factory: FormModelFactory.Interface,\n private groups: ICmsFieldEditorGroup[],\n private modifiers: ICmsFieldEditorGroupModifier[] | undefined,\n private fieldTypes: ICmsFieldType[]\n ) {\n makeAutoObservable(this, { vm: computed }, { autoBind: true });\n }\n\n get vm() {\n return {\n form: this.form ? this.form.vm : null\n };\n }\n\n init(field: CmsModelField, model: CmsModel) {\n this.originalField = cloneDeep(field);\n\n const fieldType = this.fieldTypes.find(ft => ft.type === field.type);\n if (!fieldType) {\n throw new Error(`Unknown field type: ${field.type}`);\n }\n\n this.context = { field, model, fieldType };\n this.form = this.buildForm(this.context);\n\n const data: Record<string, any> = {};\n for (const group of this.groups) {\n data[group.name] = group.mapToForm(field, this.context);\n }\n\n for (const mod of this.getApplicableModifiers(this.context)) {\n if (mod.mapToForm) {\n const modData = mod.mapToForm(field, this.context);\n data[mod.group] = { ...data[mod.group], ...modData };\n }\n }\n\n this.form.setData(data);\n }\n\n async submit(): Promise<CmsModelField | false> {\n if (!this.form || !this.context || !this.originalField) {\n return false;\n }\n\n const data = await this.form.submit<Record<string, any>>();\n if (!data) {\n return false;\n }\n\n const field = cloneDeep(this.originalField);\n\n for (const group of this.groups) {\n group.mapFromForm(data[group.name] ?? {}, field, this.context);\n }\n\n for (const mod of this.getApplicableModifiers(this.context)) {\n if (mod.mapFromForm) {\n mod.mapFromForm(data[mod.group] ?? {}, field, this.context);\n }\n }\n\n return field;\n }\n\n private buildForm(context: ICmsFieldEditorContext) {\n const collected = this.collectGroups(context);\n\n return this.factory.create({\n fields: registry => {\n const result: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const { group, fieldsFns } of collected) {\n result[group.name] = registry\n .object()\n .label(group.label)\n .renderer(\"passthrough\")\n .fields(childRegistry => {\n const merged: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const fn of fieldsFns) {\n Object.assign(merged, fn(childRegistry));\n }\n return merged;\n });\n }\n return result;\n },\n layout: layout => {\n const tabs = layout\n .tabs(\"field-settings\")\n .renderer(\"tabsHorizontal\", { spacing: \"lg\", size: \"md\", separator: true });\n for (const { group, layoutFns } of collected) {\n tabs.tab(group.name, tab => {\n tab.label(group.label);\n\n if (group.name === \"predefinedValues\") {\n tab.rules([\n {\n type: \"condition\",\n target: \"general.predefinedValuesEnabled\",\n operator: \"isFalsy\",\n value: null,\n action: \"disable\"\n }\n ]);\n }\n\n tab.layout(l => [\n l.object(group.name, inner => layoutFns.flatMap(fn => fn(inner)))\n ]);\n });\n }\n return [tabs];\n }\n });\n }\n\n private collectGroups(context: ICmsFieldEditorContext): CollectedGroup[] {\n return this.groups.map(group => {\n const fieldsFns: FieldsFactory[] = [];\n const layoutFns: LayoutFactory[] = [];\n\n const builder: ICmsFieldEditorFormBuilder = {\n fields(fn: FieldsFactory) {\n fieldsFns.push(fn);\n },\n layout(fn: LayoutFactory) {\n layoutFns.push(fn);\n }\n };\n\n group.buildForm(builder, context);\n\n for (const mod of this.getApplicableModifiers(context)) {\n if (mod.group !== group.name) {\n continue;\n }\n mod.modifyForm(builder, context);\n }\n\n return { group, fieldsFns, layoutFns };\n });\n }\n\n private getApplicableModifiers(\n context: ICmsFieldEditorContext\n ): ICmsFieldEditorGroupModifier[] {\n if (!this.modifiers) {\n return [];\n }\n return this.modifiers.filter(mod => {\n if (mod.shouldApply) {\n return mod.shouldApply(context);\n }\n return true;\n });\n }\n}\n\nexport const FieldEditorPresenterRegistration = PresenterAbstraction.createImplementation({\n implementation: FieldEditorPresenterImpl,\n dependencies: [\n FormModelFactory,\n [CmsFieldEditorGroup, { multiple: true }],\n [CmsFieldEditorGroupModifier, { multiple: true, optional: true }],\n [CmsFieldType, { multiple: true }]\n ]\n});\n"],"names":["FieldEditorPresenterImpl","factory","groups","modifiers","fieldTypes","makeAutoObservable","computed","field","model","cloneDeep","fieldType","ft","Error","data","group","mod","modData","context","collected","registry","result","fieldsFns","childRegistry","merged","fn","Object","layout","tabs","layoutFns","tab","l","inner","builder","FieldEditorPresenterRegistration","PresenterAbstraction","FormModelFactory","CmsFieldEditorGroup","CmsFieldEditorGroupModifier","CmsFieldType"],"mappings":";;;;;AA+BA,MAAMA;IAKF,YACYC,OAAmC,EACnCC,MAA8B,EAC9BC,SAAqD,EACrDC,UAA2B,CACrC;aAJUH,OAAO,GAAPA;aACAC,MAAM,GAANA;aACAC,SAAS,GAATA;aACAC,UAAU,GAAVA;aARJ,IAAI,GAA+B;aACnC,OAAO,GAAkC;aACzC,aAAa,GAAyB;QAQ1CC,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS,GAAG;YAAE,UAAU;QAAK;IAChE;IAEA,IAAI,KAAK;QACL,OAAO;YACH,MAAM,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG;QACrC;IACJ;IAEA,KAAKC,KAAoB,EAAEC,KAAe,EAAE;QACxC,IAAI,CAAC,aAAa,GAAGC,UAAUF;QAE/B,MAAMG,YAAY,IAAI,CAAC,UAAU,CAAC,IAAI,CAACC,CAAAA,KAAMA,GAAG,IAAI,KAAKJ,MAAM,IAAI;QACnE,IAAI,CAACG,WACD,MAAM,IAAIE,MAAM,CAAC,oBAAoB,EAAEL,MAAM,IAAI,EAAE;QAGvD,IAAI,CAAC,OAAO,GAAG;YAAEA;YAAOC;YAAOE;QAAU;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO;QAEvC,MAAMG,OAA4B,CAAC;QACnC,KAAK,MAAMC,SAAS,IAAI,CAAC,MAAM,CAC3BD,IAAI,CAACC,MAAM,IAAI,CAAC,GAAGA,MAAM,SAAS,CAACP,OAAO,IAAI,CAAC,OAAO;QAG1D,KAAK,MAAMQ,OAAO,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,EAC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H;gBAAOO;gBAAWO;YAAU;QACzC;IACJ;IAEQ,uBACJX,OAA+B,EACD;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EACf,OAAO,EAAE;QAEb,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAACF,CAAAA;YACzB,IAAIA,IAAI,WAAW,EACf,OAAOA,IAAI,WAAW,CAACE;YAE3B,OAAO;QACX;IACJ;AACJ;AAEO,MAAMgB,mCAAmCC,qBAAAA,oBAAyC,CAAC;IACtF,gBAAgBlC;IAChB,cAAc;QACVmC;QACA;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzC;YAACC;YAA6B;gBAAE,UAAU;gBAAM,UAAU;YAAK;SAAE;QACjE;YAACC;YAAc;gBAAE,UAAU;YAAK;SAAE;KACrC;AACL"}
|
|
1
|
+
{"version":3,"file":"presentation/fieldEditor/FieldEditorPresenter.js","sources":["../../../src/presentation/fieldEditor/FieldEditorPresenter.ts"],"sourcesContent":["import { makeAutoObservable, computed } from \"mobx\";\nimport { FormModelFactory, FormModel } from \"@webiny/app-admin\";\nimport cloneDeep from \"lodash/cloneDeep.js\";\nimport {\n FieldEditorPresenter as PresenterAbstraction,\n CmsFieldEditorGroup,\n CmsFieldEditorGroupModifier\n} from \"./abstractions.js\";\nimport type {\n ICmsFieldEditorFormBuilder,\n ICmsFieldEditorContext,\n ICmsFieldEditorGroup,\n ICmsFieldEditorGroupModifier,\n IFieldEditorPresenter\n} from \"./abstractions.js\";\nimport { CmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport type { ICmsFieldType } from \"~/presentation/fieldTypes/abstractions.js\";\nimport type { CmsModel, CmsModelField } from \"~/types.js\";\n\ntype FieldsFactory = (\n fields: FormModelFactory.FieldBuilderRegistry\n) => Record<string, FormModelFactory.FieldBuilder>;\n\ntype LayoutFactory = (layout: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[];\n\ninterface CollectedGroup {\n group: ICmsFieldEditorGroup;\n fieldsFns: FieldsFactory[];\n layoutFns: LayoutFactory[];\n}\n\nclass FieldEditorPresenterImpl implements IFieldEditorPresenter {\n private form: FormModel.Interface | null = null;\n private context: ICmsFieldEditorContext | null = null;\n private originalField: CmsModelField | null = null;\n\n constructor(\n private factory: FormModelFactory.Interface,\n private groups: ICmsFieldEditorGroup[],\n private modifiers: ICmsFieldEditorGroupModifier[] | undefined,\n private fieldTypes: ICmsFieldType[]\n ) {\n makeAutoObservable(this, { vm: computed }, { autoBind: true });\n }\n\n get vm() {\n return {\n form: this.form ? this.form.vm : null\n };\n }\n\n init(field: CmsModelField, model: CmsModel) {\n this.originalField = cloneDeep(field);\n\n const fieldType =\n this.fieldTypes.find(ft => ft.matches?.(field)) ??\n this.fieldTypes.find(ft => ft.type === field.type);\n if (!fieldType) {\n throw new Error(`Unknown field type: ${field.type}`);\n }\n\n this.context = { field, model, fieldType };\n this.form = this.buildForm(this.context);\n\n const data: Record<string, any> = {};\n for (const group of this.groups) {\n data[group.name] = group.mapToForm(field, this.context);\n }\n\n for (const mod of this.getApplicableModifiers(this.context)) {\n if (mod.mapToForm) {\n const modData = mod.mapToForm(field, this.context);\n data[mod.group] = { ...data[mod.group], ...modData };\n }\n }\n\n this.form.setData(data);\n }\n\n async submit(): Promise<CmsModelField | false> {\n if (!this.form || !this.context || !this.originalField) {\n return false;\n }\n\n const data = await this.form.submit<Record<string, any>>();\n if (!data) {\n return false;\n }\n\n const field = cloneDeep(this.originalField);\n\n for (const group of this.groups) {\n group.mapFromForm(data[group.name] ?? {}, field, this.context);\n }\n\n for (const mod of this.getApplicableModifiers(this.context)) {\n if (mod.mapFromForm) {\n mod.mapFromForm(data[mod.group] ?? {}, field, this.context);\n }\n }\n\n return field;\n }\n\n private buildForm(context: ICmsFieldEditorContext) {\n const collected = this.collectGroups(context);\n\n return this.factory.create({\n fields: registry => {\n const result: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const { group, fieldsFns } of collected) {\n result[group.name] = registry\n .object()\n .label(group.label)\n .renderer(\"passthrough\")\n .fields(childRegistry => {\n const merged: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const fn of fieldsFns) {\n Object.assign(merged, fn(childRegistry));\n }\n return merged;\n });\n }\n return result;\n },\n layout: layout => {\n const tabs = layout\n .tabs(\"field-settings\")\n .renderer(\"tabsHorizontal\", { spacing: \"lg\", size: \"md\", separator: true });\n for (const { group, layoutFns } of collected) {\n tabs.tab(group.name, tab => {\n tab.label(group.label);\n\n if (group.name === \"predefinedValues\") {\n tab.rules([\n {\n type: \"condition\",\n target: \"general.predefinedValuesEnabled\",\n operator: \"isFalsy\",\n value: null,\n action: \"disable\"\n }\n ]);\n }\n\n tab.layout(l => [\n l.object(group.name, inner => layoutFns.flatMap(fn => fn(inner)))\n ]);\n });\n }\n return [tabs];\n }\n });\n }\n\n private collectGroups(context: ICmsFieldEditorContext): CollectedGroup[] {\n return this.groups.map(group => {\n const fieldsFns: FieldsFactory[] = [];\n const layoutFns: LayoutFactory[] = [];\n\n const builder: ICmsFieldEditorFormBuilder = {\n fields(fn: FieldsFactory) {\n fieldsFns.push(fn);\n },\n layout(fn: LayoutFactory) {\n layoutFns.push(fn);\n }\n };\n\n group.buildForm(builder, context);\n\n for (const mod of this.getApplicableModifiers(context)) {\n if (mod.group !== group.name) {\n continue;\n }\n mod.modifyForm(builder, context);\n }\n\n return { group, fieldsFns, layoutFns };\n });\n }\n\n private getApplicableModifiers(\n context: ICmsFieldEditorContext\n ): ICmsFieldEditorGroupModifier[] {\n if (!this.modifiers) {\n return [];\n }\n return this.modifiers.filter(mod => {\n if (mod.shouldApply) {\n return mod.shouldApply(context);\n }\n return true;\n });\n }\n}\n\nexport const FieldEditorPresenterRegistration = PresenterAbstraction.createImplementation({\n implementation: FieldEditorPresenterImpl,\n dependencies: [\n FormModelFactory,\n [CmsFieldEditorGroup, { multiple: true }],\n [CmsFieldEditorGroupModifier, { multiple: true, optional: true }],\n [CmsFieldType, { multiple: true }]\n ]\n});\n"],"names":["FieldEditorPresenterImpl","factory","groups","modifiers","fieldTypes","makeAutoObservable","computed","field","model","cloneDeep","fieldType","ft","Error","data","group","mod","modData","context","collected","registry","result","fieldsFns","childRegistry","merged","fn","Object","layout","tabs","layoutFns","tab","l","inner","builder","FieldEditorPresenterRegistration","PresenterAbstraction","FormModelFactory","CmsFieldEditorGroup","CmsFieldEditorGroupModifier","CmsFieldType"],"mappings":";;;;;AA+BA,MAAMA;IAKF,YACYC,OAAmC,EACnCC,MAA8B,EAC9BC,SAAqD,EACrDC,UAA2B,CACrC;aAJUH,OAAO,GAAPA;aACAC,MAAM,GAANA;aACAC,SAAS,GAATA;aACAC,UAAU,GAAVA;aARJ,IAAI,GAA+B;aACnC,OAAO,GAAkC;aACzC,aAAa,GAAyB;QAQ1CC,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS,GAAG;YAAE,UAAU;QAAK;IAChE;IAEA,IAAI,KAAK;QACL,OAAO;YACH,MAAM,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG;QACrC;IACJ;IAEA,KAAKC,KAAoB,EAAEC,KAAe,EAAE;QACxC,IAAI,CAAC,aAAa,GAAGC,UAAUF;QAE/B,MAAMG,YACF,IAAI,CAAC,UAAU,CAAC,IAAI,CAACC,CAAAA,KAAMA,GAAG,OAAO,GAAGJ,WACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAACI,CAAAA,KAAMA,GAAG,IAAI,KAAKJ,MAAM,IAAI;QACrD,IAAI,CAACG,WACD,MAAM,IAAIE,MAAM,CAAC,oBAAoB,EAAEL,MAAM,IAAI,EAAE;QAGvD,IAAI,CAAC,OAAO,GAAG;YAAEA;YAAOC;YAAOE;QAAU;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO;QAEvC,MAAMG,OAA4B,CAAC;QACnC,KAAK,MAAMC,SAAS,IAAI,CAAC,MAAM,CAC3BD,IAAI,CAACC,MAAM,I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MF,OAAO,IAAI,CAAC,sBAAsB,CAACE,SAC1C,IAAIF,IAAI,KAAK,KAAKD,MAAM,IAAI,EAG5BC,IAAI,UAAU,CAACiB,SAASf;YAG5B,OAAO;gBAAEH;gBAAOO;gBAAWO;YAAU;QACzC;IACJ;IAEQ,uBACJX,OAA+B,EACD;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,EACf,OAAO,EAAE;QAEb,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAACF,CAAAA;YACzB,IAAIA,IAAI,WAAW,EACf,OAAOA,IAAI,WAAW,CAACE;YAE3B,OAAO;QACX;IACJ;AACJ;AAEO,MAAMgB,mCAAmCC,qBAAAA,oBAAyC,CAAC;IACtF,gBAAgBlC;IAChB,cAAc;QACVmC;QACA;YAACC;YAAqB;gBAAE,UAAU;YAAK;SAAE;QACzC;YAACC;YAA6B;gBAAE,UAAU;gBAAM,UAAU;YAAK;SAAE;QACjE;YAACC;YAAc;gBAAE,UAAU;YAAK;SAAE;KACrC;AACL"}
|
|
@@ -147,7 +147,7 @@ class ValidationsGroupImpl {
|
|
|
147
147
|
field.listValidation = this.flattenValidators(formData.listValidation || {});
|
|
148
148
|
}
|
|
149
149
|
flattenValidators(data) {
|
|
150
|
-
return Object.entries(data).filter(([
|
|
150
|
+
return Object.entries(data).filter(([, v])=>v && v.enabled).map(([name, v])=>({
|
|
151
151
|
name,
|
|
152
152
|
message: v.message,
|
|
153
153
|
settings: v.settings
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldEditor/groups/ValidationsGroup.js","sources":["../../../../src/presentation/fieldEditor/groups/ValidationsGroup.ts"],"sourcesContent":["import { CmsFieldEditorGroup } from \"../abstractions.js\";\nimport type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from \"../abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport type { CmsModelFieldValidatorsGroup } from \"~/presentation/fieldTypes/abstractions.js\";\nimport { CmsFieldValidator } from \"~/presentation/fieldValidators/abstractions.js\";\nimport type {\n ICmsFieldValidator,\n ICmsFieldValidatorFormBuilder\n} from \"~/presentation/fieldValidators/abstractions.js\";\nimport type { FormModelFactory, FormModel } from \"@webiny/app-admin\";\n\nfunction resolveValidatorNames(\n config:\n | string[]\n | CmsModelFieldValidatorsGroup\n | ((field: CmsModelField) => string[] | CmsModelFieldValidatorsGroup)\n | undefined,\n field: CmsModelField\n): string[] {\n if (!config) {\n return [];\n }\n if (typeof config === \"function\") {\n return resolveValidatorNames(config(field), field);\n }\n if (Array.isArray(config)) {\n return config;\n }\n return config.validators.map(v => (typeof v === \"string\" ? v : v.name));\n}\n\ninterface ValidatorBuildResult {\n fields: Record<string, FormModelFactory.FieldBuilder>;\n layouts: Map<\n string,\n {\n settingsLayoutFns: Array<\n (l: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[]\n >;\n hasSettings: boolean;\n }\n >;\n}\n\nclass ValidationsGroupImpl implements CmsFieldEditorGroup.Interface {\n name = \"validations\";\n label = \"Validations\";\n\n constructor(private allValidators: ICmsFieldValidator[]) {}\n\n buildForm(form: ICmsFieldEditorFormBuilder, context: ICmsFieldEditorContext) {\n const fieldValidatorNames = resolveValidatorNames(\n context.fieldType.validators,\n context.field\n );\n const DEFAULT_LIST_VALIDATORS = [\"minLength\", \"maxLength\"];\n const listValidatorNames =\n resolveValidatorNames(context.fieldType.listValidators, context.field).length > 0\n ? resolveValidatorNames(context.fieldType.listValidators, context.field)\n : DEFAULT_LIST_VALIDATORS;\n\n const fieldValidators = this.allValidators.filter(v =>\n fieldValidatorNames.includes(v.name)\n );\n const listValidators = this.allValidators.filter(v => listValidatorNames.includes(v.name));\n\n let fieldResult: ValidatorBuildResult | null = null;\n let listResult: ValidatorBuildResult | null = null;\n\n form.fields(fields => {\n const result: Record<string, FormModelFactory.FieldBuilder> = {};\n\n if (listValidators.length > 0) {\n listResult = this.buildValidatorFields(\n fields as FormModelFactory.FieldBuilderRegistry,\n listValidators,\n context\n );\n result.listValidation = fields\n .object()\n .renderer(\"passthrough\")\n .hiddenWhen(\n ({ form }: FormModel.CallbackParams) =>\n !form.field(\"general.list\").getValue()\n )\n .fields(() => listResult!.fields);\n }\n\n if (fieldValidators.length > 0) {\n fieldResult = this.buildValidatorFields(\n fields as FormModelFactory.FieldBuilderRegistry,\n fieldValidators,\n context\n );\n result.validation = fields\n .object()\n .renderer(\"passthrough\")\n .fields(() => fieldResult!.fields);\n }\n\n return result;\n });\n\n const listRule = {\n type: \"condition\",\n target: \"general.list\",\n operator: \"isFalsy\",\n value: null,\n action: \"hide\" as const\n };\n\n form.layout(layout => {\n const rows: FormModel.LayoutNodeBuilder[] = [];\n\n if (listValidators.length > 0 && listResult) {\n rows.push(\n layout\n .separator()\n .title(\"List validators\")\n .description(\"These validators are applied to the entire list of values.\")\n .rules([listRule])\n );\n rows.push(\n layout.object(\"listValidation\", inner =>\n this.buildValidatorLayouts(inner, listValidators, listResult!)\n )\n );\n }\n\n if (fieldValidators.length > 0 && fieldResult) {\n if (listValidators.length > 0) {\n rows.push(\n layout\n .separator()\n .title(\"Individual value validators\")\n .description(\"These validators are applied to each value in the list.\")\n .rules([listRule])\n );\n }\n rows.push(\n layout.object(\"validation\", inner =>\n this.buildValidatorLayouts(inner, fieldValidators, fieldResult!)\n )\n );\n }\n\n return rows;\n });\n }\n\n private buildValidatorLayouts(\n layout: FormModelFactory.LayoutBuilder,\n validators: ICmsFieldValidator[],\n result: ValidatorBuildResult\n ): FormModel.LayoutNodeBuilder[] {\n return validators.map(validator => {\n const meta = result.layouts.get(validator.name);\n return layout.object(validator.name, inner => {\n const rows: FormModel.LayoutNodeBuilder[] = [inner.row(\"message\")];\n if (meta && meta.hasSettings) {\n rows.push(\n inner.object(\"settings\", settingsLayout =>\n meta.settingsLayoutFns.flatMap(fn => fn(settingsLayout))\n )\n );\n }\n return rows;\n });\n });\n }\n\n private buildValidatorFields(\n fields: FormModelFactory.FieldBuilderRegistry,\n validators: ICmsFieldValidator[],\n context: ICmsFieldEditorContext\n ): ValidatorBuildResult {\n const resultFields: Record<string, FormModelFactory.FieldBuilder> = {};\n const layouts = new Map<\n string,\n {\n settingsLayoutFns: Array<\n (l: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[]\n >;\n hasSettings: boolean;\n }\n >();\n\n for (const validator of validators) {\n let messageDescription = \"This message will be displayed to the user.\";\n if (validator.variables && validator.variables.length > 0) {\n const vars = validator.variables.map(v => `{${v.name}}`).join(\", \");\n messageDescription += ` Available variables: ${vars}.`;\n }\n\n const notEnabled = ({ field }: FormModel.CallbackParams) =>\n !field.parent().field(\"enabled\").getValue();\n\n const childFields: Record<string, FormModelFactory.FieldBuilder> = {\n enabled: fields.boolean().label(\"Enabled\").defaultValue(false).hidden(),\n message: fields\n .text()\n .label(\"Message\")\n .description(messageDescription)\n .defaultValue(validator.defaultMessage)\n .hiddenWhen(notEnabled)\n };\n\n const settingsLayoutFns: Array<\n (l: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[]\n > = [];\n let hasSettings = false;\n\n if (validator.buildSettingsForm) {\n const settingsFieldsFns: Array<\n (\n f: FormModelFactory.FieldBuilderRegistry\n ) => Record<string, FormModelFactory.FieldBuilder>\n > = [];\n\n const builder: ICmsFieldValidatorFormBuilder = {\n message: childFields.message,\n fields: fn => {\n settingsFieldsFns.push(fn);\n },\n layout: fn => {\n settingsLayoutFns.push(fn);\n }\n };\n validator.buildSettingsForm(builder, { field: context.field });\n\n if (settingsFieldsFns.length > 0) {\n hasSettings = true;\n childFields.settings = fields\n .object()\n .renderer(\"passthrough\")\n .hiddenWhen(notEnabled)\n .fields((f: FormModelFactory.FieldBuilderRegistry) => {\n const merged: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const fn of settingsFieldsFns) {\n Object.assign(merged, fn(f));\n }\n return merged;\n });\n }\n }\n\n layouts.set(validator.name, { settingsLayoutFns, hasSettings });\n\n resultFields[validator.name] = fields\n .object()\n .label(validator.label)\n .description(validator.description)\n .renderer(\"cmsValidatorItem\")\n .fields(() => childFields);\n }\n\n return { fields: resultFields, layouts };\n }\n\n mapToForm(field: CmsModelField) {\n const validationMap: Record<string, Record<string, unknown>> = {};\n for (const v of field.validation || []) {\n const validator = v as {\n name: string;\n message?: string;\n settings?: Record<string, unknown>;\n };\n validationMap[validator.name] = {\n enabled: true,\n message: validator.message,\n settings: validator.settings || {}\n };\n }\n\n const listValidationMap: Record<string, Record<string, unknown>> = {};\n for (const v of field.listValidation || []) {\n listValidationMap[v.name] = {\n enabled: true,\n message: v.message,\n settings: v.settings || {}\n };\n }\n\n return {\n validation: validationMap,\n listValidation: listValidationMap\n };\n }\n\n mapFromForm(formData: Record<string, unknown>, field: CmsModelField) {\n field.validation = this.flattenValidators(\n (formData.validation || {}) as Record<string, any>\n );\n field.listValidation = this.flattenValidators(\n (formData.listValidation || {}) as Record<string, any>\n );\n }\n\n private flattenValidators(\n data: Record<\n string,\n {\n enabled?: boolean;\n message?: string;\n settings?: Record<string, unknown>;\n }\n >\n ) {\n return Object.entries(data)\n .filter(([_, v]) => v && v.enabled)\n .map(([name, v]) => ({\n name,\n message: v.message,\n settings: v.settings\n }));\n }\n}\n\nexport const ValidationsGroup = CmsFieldEditorGroup.createImplementation({\n implementation: ValidationsGroupImpl,\n dependencies: [[CmsFieldValidator, { multiple: true }]]\n});\n"],"names":["resolveValidatorNames","config","field","Array","v","ValidationsGroupImpl","allValidators","form","context","fieldValidatorNames","DEFAULT_LIST_VALIDATORS","listValidatorNames","fieldValidators","listValidators","fieldResult","listResult","fields","result","listRule","layout","rows","inner","validators","validator","meta","settingsLayout","fn","resultFields","layouts","Map","messageDescription","vars","notEnabled","childFields","settingsLayoutFns","hasSettings","settingsFieldsFns","builder","f","merged","Object","validationMap","listValidationMap","formData","data","_","name","ValidationsGroup","CmsFieldEditorGroup","CmsFieldValidator"],"mappings":";;AAWA,SAASA,sBACLC,MAIe,EACfC,KAAoB;IAEpB,IAAI,CAACD,QACD,O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KAAoB,EAAE;QACjEA,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CACpCyC,SAAS,UAAU,IAAI,CAAC;QAE7BzC,MAAM,cAAc,GAAG,IAAI,CAAC,iBAAiB,CACxCyC,SAAS,cAAc,IAAI,CAAC;IAErC;IAEQ,kBACJC,IAOC,EACH;QACE,OAAOJ,OAAO,OAAO,CAACI,MACjB,MAAM,CAAC,CAAC,CAACC,GAAGzC,EAAE,GAAKA,KAAKA,EAAE,OAAO,EACjC,GAAG,CAAC,CAAC,CAAC0C,MAAM1C,EAAE,GAAM;gBACjB0C;gBACA,SAAS1C,EAAE,OAAO;gBAClB,UAAUA,EAAE,QAAQ;YACxB;IACR;AACJ;AAEO,MAAM2C,mBAAmBC,oBAAoB,oBAAoB,CAAC;IACrE,gBAAgB3C;IAChB,cAAc;QAAC;YAAC4C;YAAmB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC3D"}
|
|
1
|
+
{"version":3,"file":"presentation/fieldEditor/groups/ValidationsGroup.js","sources":["../../../../src/presentation/fieldEditor/groups/ValidationsGroup.ts"],"sourcesContent":["import { CmsFieldEditorGroup } from \"../abstractions.js\";\nimport type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from \"../abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport type { CmsModelFieldValidatorsGroup } from \"~/presentation/fieldTypes/abstractions.js\";\nimport { CmsFieldValidator } from \"~/presentation/fieldValidators/abstractions.js\";\nimport type {\n ICmsFieldValidator,\n ICmsFieldValidatorFormBuilder\n} from \"~/presentation/fieldValidators/abstractions.js\";\nimport type { FormModelFactory, FormModel } from \"@webiny/app-admin\";\n\nfunction resolveValidatorNames(\n config:\n | string[]\n | CmsModelFieldValidatorsGroup\n | ((field: CmsModelField) => string[] | CmsModelFieldValidatorsGroup)\n | undefined,\n field: CmsModelField\n): string[] {\n if (!config) {\n return [];\n }\n if (typeof config === \"function\") {\n return resolveValidatorNames(config(field), field);\n }\n if (Array.isArray(config)) {\n return config;\n }\n return config.validators.map(v => (typeof v === \"string\" ? v : v.name));\n}\n\ninterface ValidatorBuildResult {\n fields: Record<string, FormModelFactory.FieldBuilder>;\n layouts: Map<\n string,\n {\n settingsLayoutFns: Array<\n (l: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[]\n >;\n hasSettings: boolean;\n }\n >;\n}\n\nclass ValidationsGroupImpl implements CmsFieldEditorGroup.Interface {\n name = \"validations\";\n label = \"Validations\";\n\n constructor(private allValidators: ICmsFieldValidator[]) {}\n\n buildForm(form: ICmsFieldEditorFormBuilder, context: ICmsFieldEditorContext) {\n const fieldValidatorNames = resolveValidatorNames(\n context.fieldType.validators,\n context.field\n );\n const DEFAULT_LIST_VALIDATORS = [\"minLength\", \"maxLength\"];\n const listValidatorNames =\n resolveValidatorNames(context.fieldType.listValidators, context.field).length > 0\n ? resolveValidatorNames(context.fieldType.listValidators, context.field)\n : DEFAULT_LIST_VALIDATORS;\n\n const fieldValidators = this.allValidators.filter(v =>\n fieldValidatorNames.includes(v.name)\n );\n const listValidators = this.allValidators.filter(v => listValidatorNames.includes(v.name));\n\n let fieldResult: ValidatorBuildResult | null = null;\n let listResult: ValidatorBuildResult | null = null;\n\n form.fields(fields => {\n const result: Record<string, FormModelFactory.FieldBuilder> = {};\n\n if (listValidators.length > 0) {\n listResult = this.buildValidatorFields(\n fields as FormModelFactory.FieldBuilderRegistry,\n listValidators,\n context\n );\n result.listValidation = fields\n .object()\n .renderer(\"passthrough\")\n .hiddenWhen(\n ({ form }: FormModel.CallbackParams) =>\n !form.field(\"general.list\").getValue()\n )\n .fields(() => listResult!.fields);\n }\n\n if (fieldValidators.length > 0) {\n fieldResult = this.buildValidatorFields(\n fields as FormModelFactory.FieldBuilderRegistry,\n fieldValidators,\n context\n );\n result.validation = fields\n .object()\n .renderer(\"passthrough\")\n .fields(() => fieldResult!.fields);\n }\n\n return result;\n });\n\n const listRule = {\n type: \"condition\",\n target: \"general.list\",\n operator: \"isFalsy\",\n value: null,\n action: \"hide\" as const\n };\n\n form.layout(layout => {\n const rows: FormModel.LayoutNodeBuilder[] = [];\n\n if (listValidators.length > 0 && listResult) {\n rows.push(\n layout\n .separator()\n .title(\"List validators\")\n .description(\"These validators are applied to the entire list of values.\")\n .rules([listRule])\n );\n rows.push(\n layout.object(\"listValidation\", inner =>\n this.buildValidatorLayouts(inner, listValidators, listResult!)\n )\n );\n }\n\n if (fieldValidators.length > 0 && fieldResult) {\n if (listValidators.length > 0) {\n rows.push(\n layout\n .separator()\n .title(\"Individual value validators\")\n .description(\"These validators are applied to each value in the list.\")\n .rules([listRule])\n );\n }\n rows.push(\n layout.object(\"validation\", inner =>\n this.buildValidatorLayouts(inner, fieldValidators, fieldResult!)\n )\n );\n }\n\n return rows;\n });\n }\n\n private buildValidatorLayouts(\n layout: FormModelFactory.LayoutBuilder,\n validators: ICmsFieldValidator[],\n result: ValidatorBuildResult\n ): FormModel.LayoutNodeBuilder[] {\n return validators.map(validator => {\n const meta = result.layouts.get(validator.name);\n return layout.object(validator.name, inner => {\n const rows: FormModel.LayoutNodeBuilder[] = [inner.row(\"message\")];\n if (meta && meta.hasSettings) {\n rows.push(\n inner.object(\"settings\", settingsLayout =>\n meta.settingsLayoutFns.flatMap(fn => fn(settingsLayout))\n )\n );\n }\n return rows;\n });\n });\n }\n\n private buildValidatorFields(\n fields: FormModelFactory.FieldBuilderRegistry,\n validators: ICmsFieldValidator[],\n context: ICmsFieldEditorContext\n ): ValidatorBuildResult {\n const resultFields: Record<string, FormModelFactory.FieldBuilder> = {};\n const layouts = new Map<\n string,\n {\n settingsLayoutFns: Array<\n (l: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[]\n >;\n hasSettings: boolean;\n }\n >();\n\n for (const validator of validators) {\n let messageDescription = \"This message will be displayed to the user.\";\n if (validator.variables && validator.variables.length > 0) {\n const vars = validator.variables.map(v => `{${v.name}}`).join(\", \");\n messageDescription += ` Available variables: ${vars}.`;\n }\n\n const notEnabled = ({ field }: FormModel.CallbackParams) =>\n !field.parent().field(\"enabled\").getValue();\n\n const childFields: Record<string, FormModelFactory.FieldBuilder> = {\n enabled: fields.boolean().label(\"Enabled\").defaultValue(false).hidden(),\n message: fields\n .text()\n .label(\"Message\")\n .description(messageDescription)\n .defaultValue(validator.defaultMessage)\n .hiddenWhen(notEnabled)\n };\n\n const settingsLayoutFns: Array<\n (l: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[]\n > = [];\n let hasSettings = false;\n\n if (validator.buildSettingsForm) {\n const settingsFieldsFns: Array<\n (\n f: FormModelFactory.FieldBuilderRegistry\n ) => Record<string, FormModelFactory.FieldBuilder>\n > = [];\n\n const builder: ICmsFieldValidatorFormBuilder = {\n message: childFields.message,\n fields: fn => {\n settingsFieldsFns.push(fn);\n },\n layout: fn => {\n settingsLayoutFns.push(fn);\n }\n };\n validator.buildSettingsForm(builder, { field: context.field });\n\n if (settingsFieldsFns.length > 0) {\n hasSettings = true;\n childFields.settings = fields\n .object()\n .renderer(\"passthrough\")\n .hiddenWhen(notEnabled)\n .fields((f: FormModelFactory.FieldBuilderRegistry) => {\n const merged: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const fn of settingsFieldsFns) {\n Object.assign(merged, fn(f));\n }\n return merged;\n });\n }\n }\n\n layouts.set(validator.name, { settingsLayoutFns, hasSettings });\n\n resultFields[validator.name] = fields\n .object()\n .label(validator.label)\n .description(validator.description)\n .renderer(\"cmsValidatorItem\")\n .fields(() => childFields);\n }\n\n return { fields: resultFields, layouts };\n }\n\n mapToForm(field: CmsModelField) {\n const validationMap: Record<string, Record<string, unknown>> = {};\n for (const v of field.validation || []) {\n const validator = v as {\n name: string;\n message?: string;\n settings?: Record<string, unknown>;\n };\n validationMap[validator.name] = {\n enabled: true,\n message: validator.message,\n settings: validator.settings || {}\n };\n }\n\n const listValidationMap: Record<string, Record<string, unknown>> = {};\n for (const v of field.listValidation || []) {\n listValidationMap[v.name] = {\n enabled: true,\n message: v.message,\n settings: v.settings || {}\n };\n }\n\n return {\n validation: validationMap,\n listValidation: listValidationMap\n };\n }\n\n mapFromForm(formData: Record<string, unknown>, field: CmsModelField) {\n field.validation = this.flattenValidators(\n (formData.validation || {}) as Record<string, any>\n );\n field.listValidation = this.flattenValidators(\n (formData.listValidation || {}) as Record<string, any>\n );\n }\n\n private flattenValidators(\n data: Record<\n string,\n {\n enabled?: boolean;\n message?: string;\n settings?: Record<string, unknown>;\n }\n >\n ) {\n return Object.entries(data)\n .filter(([, v]) => v && v.enabled)\n .map(([name, v]) => ({\n name,\n message: v.message,\n settings: v.settings\n }));\n }\n}\n\nexport const ValidationsGroup = CmsFieldEditorGroup.createImplementation({\n implementation: ValidationsGroupImpl,\n dependencies: [[CmsFieldValidator, { multiple: true }]]\n});\n"],"names":["resolveValidatorNames","config","field","Array","v","ValidationsGroupImpl","allValidators","form","context","fieldValidatorNames","DEFAULT_LIST_VALIDATORS","listValidatorNames","fieldValidators","listValidators","fieldResult","listResult","fields","result","listRule","layout","rows","inner","validators","validator","meta","settingsLayout","fn","resultFields","layouts","Map","messageDescription","vars","notEnabled","childFields","settingsLayoutFns","hasSettings","settingsFieldsFns","builder","f","merged","Object","validationMap","listValidationMap","formData","data","name","ValidationsGroup","CmsFieldEditorGroup","CmsFieldValidator"],"mappings":";;AAWA,SAASA,sBACLC,MAIe,EACfC,KAAoB;IAEpB,IAAI,CAACD,QACD,OAAO,EAAE;IAEb,IAAI,AAAkB,cAAlB,OAAOA,QACP,OAAOD,sBAAsBC,OAAOC,QAAQA;IAEhD,IAAIC,MAAM,OAAO,CAACF,SACd,OAAOA;IAEX,OAAOA,OAAO,UAAU,CAAC,GAAG,CAACG,CAAAA,IAAM,AAAa,YAAb,OAAOA,IAAiBA,IAAIA,EAAE,IAAI;AACzE;AAeA,MAAMC;IAIF,YAAoBC,aAAmC,CAAE;aAArCA,aAAa,GAAbA;aAHpB,IAAI,GAAG;aACP,KAAK,GAAG;IAEkD;IAE1D,UAAUC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BACjByC;gBACA,SAASzC,EAAE,OAAO;gBAClB,UAAUA,EAAE,QAAQ;YACxB;IACR;AACJ;AAEO,MAAM0C,mBAAmBC,oBAAoB,oBAAoB,CAAC;IACrE,gBAAgB1C;IAChB,cAAc;QAAC;YAAC2C;YAAmB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC3D"}
|
|
@@ -2,7 +2,7 @@ import react, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import { useFeature } from "@webiny/app";
|
|
4
4
|
import { createObjectFieldRenderer } from "@webiny/app-admin/features/formModel/createFieldRenderer.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useFeatureFlags } from "@webiny/app-admin";
|
|
6
6
|
import { Grid } from "@webiny/admin-ui";
|
|
7
7
|
import { UsersTeamsMultiAutocomplete } from "@webiny/app-aco";
|
|
8
8
|
import { ListFolderPermissionsTargetsFeature } from "../../../features/listFolderPermissionsTargets/feature.js";
|
|
@@ -12,7 +12,7 @@ const CmsAccessControlRulesRenderer = createObjectFieldRenderer(({ field })=>/*#
|
|
|
12
12
|
field: field
|
|
13
13
|
}));
|
|
14
14
|
const AccessControlRules = observer(({ field })=>{
|
|
15
|
-
const
|
|
15
|
+
const featureFlags = useFeatureFlags();
|
|
16
16
|
const { useCase } = useFeature(ListFolderPermissionsTargetsFeature);
|
|
17
17
|
const rules = Array.isArray(field.value) ? field.value : [];
|
|
18
18
|
const [targetsList, setTargetsList] = useState([]);
|
|
@@ -50,7 +50,7 @@ const AccessControlRules = observer(({ field })=>{
|
|
|
50
50
|
rules,
|
|
51
51
|
field
|
|
52
52
|
]);
|
|
53
|
-
if (!
|
|
53
|
+
if (!featureFlags.isEnabled("advancedAccessControlLayer.hcmsFieldPermissions")) return /*#__PURE__*/ react.createElement(Grid, null, /*#__PURE__*/ react.createElement(Grid.Column, {
|
|
54
54
|
span: 12
|
|
55
55
|
}, /*#__PURE__*/ react.createElement(CannotUsePermissions, null)));
|
|
56
56
|
const selectedValues = useMemo(()=>rules.map((rule)=>String(rule.value)), [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js","sources":["../../../../src/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { createObjectFieldRenderer } from \"@webiny/app-admin/features/formModel/createFieldRenderer.js\";\nimport type { IObjectFieldVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.js","sources":["../../../../src/presentation/fieldEditor/renderers/CmsAccessControlRulesRenderer.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { useFeature } from \"@webiny/app\";\nimport { createObjectFieldRenderer } from \"@webiny/app-admin/features/formModel/createFieldRenderer.js\";\nimport type { IObjectFieldVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { useFeatureFlags } from \"@webiny/app-admin\";\nimport { Grid } from \"@webiny/admin-ui\";\nimport { UsersTeamsMultiAutocomplete } from \"@webiny/app-aco\";\nimport type { FolderLevelPermissionsTarget } from \"@webiny/app-aco\";\nimport { ListFolderPermissionsTargetsFeature } from \"~/features/listFolderPermissionsTargets/feature.js\";\nimport type { FieldRule } from \"~/types.js\";\nimport { FieldPermissionsSelection } from \"~/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/FieldPermissionsSelection.js\";\nimport { CannotUsePermissions } from \"~/admin/components/FieldEditor/EditFieldDialog/PermissionsEditor/CannotUsePermissions.js\";\n\nexport const CmsAccessControlRulesRenderer = createObjectFieldRenderer(({ field }) => {\n return <AccessControlRules field={field} />;\n});\n\ninterface AccessControlRulesProps {\n field: IObjectFieldVM;\n}\n\nconst AccessControlRules = observer(({ field }: AccessControlRulesProps) => {\n const featureFlags = useFeatureFlags();\n const { useCase } = useFeature(ListFolderPermissionsTargetsFeature);\n const rules: FieldRule[] = Array.isArray(field.value) ? (field.value as FieldRule[]) : [];\n\n const [targetsList, setTargetsList] = useState<FolderLevelPermissionsTarget[]>([]);\n\n useEffect(() => {\n useCase.execute().then(setTargetsList).catch(console.error);\n }, []);\n\n const addPermission = useCallback(\n (value: string[]) => {\n const selectedUserOrTeam = value[value.length - 1];\n if (!selectedUserOrTeam) {\n return;\n }\n const newRule: FieldRule = {\n type: \"accessControl\",\n target: \"identity\",\n operator: \"matches\",\n value: selectedUserOrTeam,\n action: \"disable\"\n };\n field.onChange([...rules, newRule]);\n },\n [rules, field]\n );\n\n const updatePermission = useCallback(\n ({ rule: updatedRule }: { rule: FieldRule }) => {\n const updated = rules.map(rule =>\n rule.value === updatedRule.value ? updatedRule : rule\n );\n field.onChange(updated);\n },\n [rules, field]\n );\n\n const removePermission = useCallback(\n ({ rule: removedRule }: { rule: FieldRule }) => {\n field.onChange(rules.filter(rule => rule.value !== removedRule.value));\n },\n [rules, field]\n );\n\n if (!featureFlags.isEnabled(\"advancedAccessControlLayer.hcmsFieldPermissions\")) {\n return (\n <Grid>\n <Grid.Column span={12}>\n <CannotUsePermissions />\n </Grid.Column>\n </Grid>\n );\n }\n\n const selectedValues = useMemo(\n () => rules.map(rule => String(rule.value) as `admin:${string}` | `team:${string}`),\n [rules]\n );\n\n return (\n <Grid>\n <Grid.Column span={12}>\n <UsersTeamsMultiAutocomplete\n options={targetsList}\n value={selectedValues}\n onChange={addPermission}\n />\n </Grid.Column>\n <Grid.Column span={12}>\n <FieldPermissionsSelection\n rules={rules}\n targetsList={targetsList}\n onRemoveAccess={removePermission}\n onUpdatePermission={updatePermission}\n />\n </Grid.Column>\n </Grid>\n );\n});\n"],"names":["CmsAccessControlRulesRenderer","createObjectFieldRenderer","field","AccessControlRules","observer","featureFlags","useFeatureFlags","useCase","useFeature","ListFolderPermissionsTargetsFeature","rules","Array","targetsList","setTargetsList","useState","useEffect","console","addPermission","useCallback","value","selectedUserOrTeam","newRule","updatePermission","updatedRule","updated","rule","removePermission","removedRule","Grid","CannotUsePermissions","selectedValues","useMemo","String","UsersTeamsMultiAutocomplete","FieldPermissionsSelection"],"mappings":";;;;;;;;;;AAcO,MAAMA,gCAAgCC,0BAA0B,CAAC,EAAEC,KAAK,EAAE,GACtE,WAAP,GAAO,oBAACC,oBAAkBA;QAAC,OAAOD;;AAOtC,MAAMC,qBAAqBC,SAAS,CAAC,EAAEF,KAAK,EAA2B;IACnE,MAAMG,eAAeC;IACrB,MAAM,EAAEC,OAAO,EAAE,GAAGC,WAAWC;IAC/B,MAAMC,QAAqBC,MAAM,OAAO,CAACT,MAAM,KAAK,IAAKA,MAAM,KAAK,GAAmB,EAAE;IAEzF,MAAM,CAACU,aAAaC,eAAe,GAAGC,SAAyC,EAAE;IAEjFC,UAAU;QACNR,QAAQ,OAAO,GAAG,IAAI,CAACM,gBAAgB,KAAK,CAACG,QAAQ,KAAK;IAC9D,GAAG,EAAE;IAEL,MAAMC,gBAAgBC,YAClB,CAACC;QACG,MAAMC,qBAAqBD,KAAK,CAACA,MAAM,MAAM,GAAG,EAAE;QAClD,IAAI,CAACC,oBACD;QAEJ,MAAMC,UAAqB;YACvB,MAAM;YACN,QAAQ;YACR,UAAU;YACV,OAAOD;YACP,QAAQ;QACZ;QACAlB,MAAM,QAAQ,CAAC;eAAIQ;YAAOW;SAAQ;IACtC,GACA;QAACX;QAAOR;KAAM;IAGlB,MAAMoB,mBAAmBJ,YACrB,CAAC,EAAE,MAAMK,WAAW,EAAuB;QACvC,MAAMC,UAAUd,MAAM,GAAG,CAACe,CAAAA,OACtBA,KAAK,KAAK,KAAKF,YAAY,KAAK,GAAGA,cAAcE;QAErDvB,MAAM,QAAQ,CAACsB;IACnB,GACA;QAACd;QAAOR;KAAM;IAGlB,MAAMwB,mBAAmBR,YACrB,CAAC,EAAE,MAAMS,WAAW,EAAuB;QACvCzB,MAAM,QAAQ,CAACQ,MAAM,MAAM,CAACe,CAAAA,OAAQA,KAAK,KAAK,KAAKE,YAAY,KAAK;IACxE,GACA;QAACjB;QAAOR;KAAM;IAGlB,IAAI,CAACG,aAAa,SAAS,CAAC,oDACxB,OAAO,WAAP,GACI,oBAACuB,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACC,sBAAoBA;IAMrC,MAAMC,iBAAiBC,QACnB,IAAMrB,MAAM,GAAG,CAACe,CAAAA,OAAQO,OAAOP,KAAK,KAAK,IACzC;QAACf;KAAM;IAGX,OAAO,WAAP,GACI,oBAACkB,MAAIA,MAAAA,WAAAA,GACD,oBAACA,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACK,6BAA2BA;QACxB,SAASrB;QACT,OAAOkB;QACP,UAAUb;uBAGlB,oBAACW,KAAK,MAAM;QAAC,MAAM;qBACf,oBAACM,2BAAyBA;QACtB,OAAOxB;QACP,aAAaE;QACb,gBAAgBc;QAChB,oBAAoBJ;;AAKxC"}
|
|
@@ -9,6 +9,7 @@ import { EntryList } from "./components/EntryList.js";
|
|
|
9
9
|
import { RefFieldOptions } from "./components/RefFieldOptions.js";
|
|
10
10
|
import { ReferencesDialog } from "./components/ReferencesDialog.js";
|
|
11
11
|
import { NewEntryDrawer } from "./components/NewEntryDrawer.js";
|
|
12
|
+
import { EditEntryDrawer } from "./components/EditEntryDrawer.js";
|
|
12
13
|
import { parseIdentifier } from "@webiny/utils";
|
|
13
14
|
const CmsRefDetailedMultipleRenderer = createFieldRenderer(({ field })=>{
|
|
14
15
|
const parentContainer = useContainer();
|
|
@@ -27,6 +28,7 @@ const RefDetailedMultipleInner = observer(({ field })=>{
|
|
|
27
28
|
const { presenter } = useFeature(RefDetailedPresenterFeature);
|
|
28
29
|
const [selectDialogModel, setSelectDialogModel] = useState(null);
|
|
29
30
|
const [newEntryModelId, setNewEntryModelId] = useState(null);
|
|
31
|
+
const [editEntry, setEditEntry] = useState(null);
|
|
30
32
|
const settings = field.rendererSettings;
|
|
31
33
|
const modelIds = (settings.models || []).map((m)=>m.modelId);
|
|
32
34
|
const values = Array.isArray(field.value) ? field.value : [];
|
|
@@ -131,6 +133,7 @@ const RefDetailedMultipleInner = observer(({ field })=>{
|
|
|
131
133
|
index: index,
|
|
132
134
|
entry: entry,
|
|
133
135
|
onRemove: onRemove,
|
|
136
|
+
onEdit: setEditEntry,
|
|
134
137
|
onMoveUp: isFirst ? void 0 : onMoveUp,
|
|
135
138
|
onMoveDown: isLast ? void 0 : onMoveDown
|
|
136
139
|
});
|
|
@@ -161,6 +164,11 @@ const RefDetailedMultipleInner = observer(({ field })=>{
|
|
|
161
164
|
]) : null);
|
|
162
165
|
setNewEntryModelId(null);
|
|
163
166
|
}
|
|
167
|
+
}), editEntry && /*#__PURE__*/ react.createElement(EditEntryDrawer, {
|
|
168
|
+
modelId: editEntry.model.modelId,
|
|
169
|
+
entryId: editEntry.id,
|
|
170
|
+
onClose: ()=>setEditEntry(null),
|
|
171
|
+
onSaved: (patch)=>presenter.patchEntry(patch)
|
|
164
172
|
}));
|
|
165
173
|
});
|
|
166
174
|
export { CmsRefDetailedMultipleRenderer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js","sources":["../../../../src/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { createFieldRenderer } from \"@webiny/app-admin/features/formModel/createFieldRenderer.js\";\nimport type { IFieldVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { DiContainerProvider, useContainer, useFeature } from \"@webiny/app\";\nimport { FormComponentErrorMessage, FormComponentLabel } from \"@webiny/admin-ui\";\nimport type { CmsModel } from \"~/types.js\";\nimport type { CmsReferenceEntry, CmsReferenceValue } from \"~/features/contentEntry/refTypes.js\";\nimport type { RefFieldRendererSettings } from \"./types.js\";\nimport { RefDetailedPresenterFeature } from \"./detailed/feature.js\";\nimport { EntryCard } from \"./components/EntryCard.js\";\nimport { EntryList } from \"./components/EntryList.js\";\nimport { RefFieldOptions } from \"./components/RefFieldOptions.js\";\nimport { ReferencesDialog } from \"./components/ReferencesDialog.js\";\nimport { NewEntryDrawer } from \"./components/NewEntryDrawer.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\ndeclare module \"@webiny/app-admin/features/formModel/abstractions.js\" {\n interface IFieldRendererRegistry {\n refDetailedMultiple: { fieldType: \"ref\"; settings: RefFieldRendererSettings };\n }\n}\n\nexport const CmsRefDetailedMultipleRenderer = createFieldRenderer<\"refDetailedMultiple\">(\n ({ field }) => {\n const parentContainer = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = parentContainer.createChildContainer();\n RefDetailedPresenterFeature.register(child);\n return child;\n }, []);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <RefDetailedMultipleInner field={field} />\n </DiContainerProvider>\n );\n }\n);\n\ninterface InnerFieldProps {\n field: IFieldVM & { rendererSettings: RefFieldRendererSettings };\n}\n\nconst RefDetailedMultipleInner = observer(({ field }: InnerFieldProps) => {\n const { presenter } = useFeature(RefDetailedPresenterFeature);\n\n const [selectDialogModel, setSelectDialogModel] = useState<CmsModel | null>(null);\n const [newEntryModelId, setNewEntryModelId] = useState<string | null>(null);\n\n const settings = field.rendererSettings;\n const modelIds = (settings.models || []).map(m => m.modelId);\n\n const values: CmsReferenceValue[] = Array.isArray(field.value) ? field.value : [];\n\n useEffect(() => {\n presenter.init({ modelIds, multiSelect: true });\n if (values.length > 0) {\n presenter.resolveValues(values);\n }\n }, []);\n\n const onRemove = useCallback(\n (id: string) => {\n const { id: entryId } = parseIdentifier(id);\n const newValues = values.filter(v => {\n const { id: vEntryId } = parseIdentifier(v.id);\n return vEntryId !== entryId;\n });\n field.onChange(newValues.length > 0 ? newValues : null);\n },\n [values]\n );\n\n const onMoveUp = useCallback(\n (index: number, toTop?: boolean) => {\n if (values.length === 0) {\n return;\n }\n const newValues = [...values];\n if (toTop) {\n const [item] = newValues.splice(index, 1);\n newValues.unshift(item);\n } else {\n const temp = newValues[index - 1];\n newValues[index - 1] = newValues[index];\n newValues[index] = temp;\n }\n field.onChange(newValues);\n },\n [values]\n );\n\n const onMoveDown = useCallback(\n (index: number, toBottom?: boolean) => {\n if (values.length === 0) {\n return;\n }\n const newValues = [...values];\n if (toBottom) {\n const [item] = newValues.splice(index, 1);\n newValues.push(item);\n } else {\n const temp = newValues[index + 1];\n newValues[index + 1] = newValues[index];\n newValues[index] = temp;\n }\n field.onChange(newValues);\n },\n [values]\n );\n\n const onNewRecord = useCallback((modelId: string) => {\n setNewEntryModelId(modelId);\n }, []);\n\n const onExistingRecord = useCallback(\n (modelId: string) => {\n const model = presenter.vm.models.find(m => m.modelId === modelId);\n if (model) {\n setSelectDialogModel(model);\n }\n },\n [presenter.vm.models]\n );\n\n const onDialogSave = useCallback(\n (selectedValues: CmsReferenceValue[], entries: CmsReferenceEntry[]) => {\n presenter.addEntries(entries);\n field.onChange(selectedValues.length > 0 ? selectedValues : null);\n },\n []\n );\n\n const { validation } = field;\n const invalid = validation.isValid === false;\n const disabled = field.disabled;\n\n const entryMap = new Map(presenter.vm.entries.map(e => [e.entryId, e]));\n const orderedEntries = values\n .map(v => {\n const entryId = v.id.split(\"#\")[0];\n return entryMap.get(entryId);\n })\n .filter((e): e is CmsReferenceEntry => e != null);\n\n return (\n <div className={\"@container\"}>\n <div className={\"flex items-center justify-between\"}>\n <FormComponentLabel\n text={field.label}\n hint={field.help}\n invalid={invalid}\n disabled={disabled}\n />\n </div>\n <div className={\"webiny_ref-field-container\"}>\n <EntryList entries={orderedEntries} loadMore={() => presenter.loadMore()}>\n {(entry, index) => {\n const isFirst = index === 0;\n const isLast = index >= values.length - 1;\n const model = presenter.vm.models.find(\n m => m.modelId === entry.model.modelId\n );\n if (!model) {\n return null;\n }\n return (\n <EntryCard\n disabled={disabled}\n model={model}\n placement=\"multiRef\"\n index={index}\n entry={entry}\n onRemove={onRemove}\n onMoveUp={!isFirst ? onMoveUp : undefined}\n onMoveDown={!isLast ? onMoveDown : undefined}\n />\n );\n }}\n </EntryList>\n </div>\n <FormComponentErrorMessage\n text={validation.message}\n invalid={invalid}\n disabled={disabled}\n />\n {values.length > 0 && <div className=\"mb-md\" />}\n {!disabled && (\n <RefFieldOptions\n models={presenter.vm.models}\n onNewRecord={onNewRecord}\n onLinkExistingRecord={onExistingRecord}\n />\n )}\n {selectDialogModel && (\n <ReferencesDialog\n model={selectDialogModel}\n values={values}\n multiple={true}\n onSave={onDialogSave}\n onClose={() => setSelectDialogModel(null)}\n />\n )}\n {newEntryModelId && (\n <NewEntryDrawer\n modelId={newEntryModelId}\n onClose={() => setNewEntryModelId(null)}\n onChange={ref => {\n field.onChange(\n values.concat([ref]).length > 0 ? values.concat([ref]) : null\n );\n setNewEntryModelId(null);\n }}\n />\n )}\n </div>\n );\n});\n"],"names":["CmsRefDetailedMultipleRenderer","createFieldRenderer","field","parentContainer","useContainer","scopedContainer","useMemo","child","RefDetailedPresenterFeature","DiContainerProvider","RefDetailedMultipleInner","observer","presenter","useFeature","selectDialogModel","setSelectDialogModel","useState","newEntryModelId","setNewEntryModelId","settings","modelIds","m","values","Array","useEffect","onRemove","useCallback","id","entryId","parseIdentifier","newValues","v","vEntryId","onMoveUp","index","toTop","item","temp","onMoveDown","toBottom","onNewRecord","modelId","onExistingRecord","model","onDialogSave","selectedValues","entries","validation","invalid","disabled","entryMap","Map","e","orderedEntries","FormComponentLabel","EntryList","entry","isFirst","isLast","EntryCard","undefined","FormComponentErrorMessage","RefFieldOptions","ReferencesDialog","NewEntryDrawer","ref"],"mappings":";;;;;;;;;;;;AAuBO,MAAMA,iCAAiCC,oBAC1C,CAAC,EAAEC,KAAK,EAAE;IACN,MAAMC,kBAAkBC;IAExB,M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,GAAK,oBAAC;QAAI,WAAU;QACpC,CAAC2B,YAAY,WAAZA,GACE,oBAACa,iBAAeA;QACZ,QAAQlD,UAAU,EAAE,CAAC,MAAM;QAC3B,aAAa4B;QACb,sBAAsBE;QAG7B5B,qBAAqB,WAArBA,GACG,oBAACiD,kBAAgBA;QACb,OAAOjD;QACP,QAAQQ;QACR,UAAU;QACV,QAAQsB;QACR,SAAS,IAAM7B,qBAAqB;QAG3CE,mBAAmB,WAAnBA,GACG,oBAAC+C,gBAAcA;QACX,SAAS/C;QACT,SAAS,IAAMC,mBAAmB;QAClC,UAAU+C,CAAAA;YACN/D,MAAM,QAAQ,CACVoB,OAAO,MAAM,CAAC;gBAAC2C;aAAI,EAAE,MAAM,GAAG,IAAI3C,OAAO,MAAM,CAAC;gBAAC2C;aAAI,IAAI;YAE7D/C,mBAAmB;QACvB;;AAKpB"}
|
|
1
|
+
{"version":3,"file":"presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.js","sources":["../../../../src/presentation/fieldRenderers/ref/CmsRefDetailedMultipleRenderer.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { createFieldRenderer } from \"@webiny/app-admin/features/formModel/createFieldRenderer.js\";\nimport type { IFieldVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { DiContainerProvider, useContainer, useFeature } from \"@webiny/app\";\nimport { FormComponentErrorMessage, FormComponentLabel } from \"@webiny/admin-ui\";\nimport type { CmsModel } from \"~/types.js\";\nimport type { CmsReferenceEntry, CmsReferenceValue } from \"~/features/contentEntry/refTypes.js\";\nimport type { RefFieldRendererSettings } from \"./types.js\";\nimport { RefDetailedPresenterFeature } from \"./detailed/feature.js\";\nimport { EntryCard } from \"./components/EntryCard.js\";\nimport { EntryList } from \"./components/EntryList.js\";\nimport { RefFieldOptions } from \"./components/RefFieldOptions.js\";\nimport { ReferencesDialog } from \"./components/ReferencesDialog.js\";\nimport { NewEntryDrawer } from \"./components/NewEntryDrawer.js\";\nimport { EditEntryDrawer } from \"./components/EditEntryDrawer.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\ndeclare module \"@webiny/app-admin/features/formModel/abstractions.js\" {\n interface IFieldRendererRegistry {\n refDetailedMultiple: { fieldType: \"ref\"; settings: RefFieldRendererSettings };\n }\n}\n\nexport const CmsRefDetailedMultipleRenderer = createFieldRenderer<\"refDetailedMultiple\">(\n ({ field }) => {\n const parentContainer = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = parentContainer.createChildContainer();\n RefDetailedPresenterFeature.register(child);\n return child;\n }, []);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <RefDetailedMultipleInner field={field} />\n </DiContainerProvider>\n );\n }\n);\n\ninterface InnerFieldProps {\n field: IFieldVM & { rendererSettings: RefFieldRendererSettings };\n}\n\nconst RefDetailedMultipleInner = observer(({ field }: InnerFieldProps) => {\n const { presenter } = useFeature(RefDetailedPresenterFeature);\n\n const [selectDialogModel, setSelectDialogModel] = useState<CmsModel | null>(null);\n const [newEntryModelId, setNewEntryModelId] = useState<string | null>(null);\n const [editEntry, setEditEntry] = useState<CmsReferenceEntry | null>(null);\n\n const settings = field.rendererSettings;\n const modelIds = (settings.models || []).map(m => m.modelId);\n\n const values: CmsReferenceValue[] = Array.isArray(field.value) ? field.value : [];\n\n useEffect(() => {\n presenter.init({ modelIds, multiSelect: true });\n if (values.length > 0) {\n presenter.resolveValues(values);\n }\n }, []);\n\n const onRemove = useCallback(\n (id: string) => {\n const { id: entryId } = parseIdentifier(id);\n const newValues = values.filter(v => {\n const { id: vEntryId } = parseIdentifier(v.id);\n return vEntryId !== entryId;\n });\n field.onChange(newValues.length > 0 ? newValues : null);\n },\n [values]\n );\n\n const onMoveUp = useCallback(\n (index: number, toTop?: boolean) => {\n if (values.length === 0) {\n return;\n }\n const newValues = [...values];\n if (toTop) {\n const [item] = newValues.splice(index, 1);\n newValues.unshift(item);\n } else {\n const temp = newValues[index - 1];\n newValues[index - 1] = newValues[index];\n newValues[index] = temp;\n }\n field.onChange(newValues);\n },\n [values]\n );\n\n const onMoveDown = useCallback(\n (index: number, toBottom?: boolean) => {\n if (values.length === 0) {\n return;\n }\n const newValues = [...values];\n if (toBottom) {\n const [item] = newValues.splice(index, 1);\n newValues.push(item);\n } else {\n const temp = newValues[index + 1];\n newValues[index + 1] = newValues[index];\n newValues[index] = temp;\n }\n field.onChange(newValues);\n },\n [values]\n );\n\n const onNewRecord = useCallback((modelId: string) => {\n setNewEntryModelId(modelId);\n }, []);\n\n const onExistingRecord = useCallback(\n (modelId: string) => {\n const model = presenter.vm.models.find(m => m.modelId === modelId);\n if (model) {\n setSelectDialogModel(model);\n }\n },\n [presenter.vm.models]\n );\n\n const onDialogSave = useCallback(\n (selectedValues: CmsReferenceValue[], entries: CmsReferenceEntry[]) => {\n presenter.addEntries(entries);\n field.onChange(selectedValues.length > 0 ? selectedValues : null);\n },\n []\n );\n\n const { validation } = field;\n const invalid = validation.isValid === false;\n const disabled = field.disabled;\n\n const entryMap = new Map(presenter.vm.entries.map(e => [e.entryId, e]));\n const orderedEntries = values\n .map(v => {\n const entryId = v.id.split(\"#\")[0];\n return entryMap.get(entryId);\n })\n .filter((e): e is CmsReferenceEntry => e != null);\n\n return (\n <div className={\"@container\"}>\n <div className={\"flex items-center justify-between\"}>\n <FormComponentLabel\n text={field.label}\n hint={field.help}\n invalid={invalid}\n disabled={disabled}\n />\n </div>\n <div className={\"webiny_ref-field-container\"}>\n <EntryList entries={orderedEntries} loadMore={() => presenter.loadMore()}>\n {(entry, index) => {\n const isFirst = index === 0;\n const isLast = index >= values.length - 1;\n const model = presenter.vm.models.find(\n m => m.modelId === entry.model.modelId\n );\n if (!model) {\n return null;\n }\n return (\n <EntryCard\n disabled={disabled}\n model={model}\n placement=\"multiRef\"\n index={index}\n entry={entry}\n onRemove={onRemove}\n onEdit={setEditEntry}\n onMoveUp={!isFirst ? onMoveUp : undefined}\n onMoveDown={!isLast ? onMoveDown : undefined}\n />\n );\n }}\n </EntryList>\n </div>\n <FormComponentErrorMessage\n text={validation.message}\n invalid={invalid}\n disabled={disabled}\n />\n {values.length > 0 && <div className=\"mb-md\" />}\n {!disabled && (\n <RefFieldOptions\n models={presenter.vm.models}\n onNewRecord={onNewRecord}\n onLinkExistingRecord={onExistingRecord}\n />\n )}\n {selectDialogModel && (\n <ReferencesDialog\n model={selectDialogModel}\n values={values}\n multiple={true}\n onSave={onDialogSave}\n onClose={() => setSelectDialogModel(null)}\n />\n )}\n {newEntryModelId && (\n <NewEntryDrawer\n modelId={newEntryModelId}\n onClose={() => setNewEntryModelId(null)}\n onChange={ref => {\n field.onChange(\n values.concat([ref]).length > 0 ? values.concat([ref]) : null\n );\n setNewEntryModelId(null);\n }}\n />\n )}\n {editEntry && (\n <EditEntryDrawer\n modelId={editEntry.model.modelId}\n entryId={editEntry.id}\n onClose={() => setEditEntry(null)}\n onSaved={patch => presenter.patchEntry(patch)}\n />\n )}\n </div>\n );\n});\n"],"names":["CmsRefDetailedMultipleRenderer","createFieldRenderer","field","parentContainer","useContainer","scopedContainer","useMemo","child","RefDetailedPresenterFeature","DiContainerProvider","RefDetailedMultipleInner","observer","presenter","useFeature","selectDialogModel","setSelectDialogModel","useState","newEntryModelId","setNewEntryModelId","editEntry","setEditEntry","settings","modelIds","m","values","Array","useEffect","onRemove","useCallback","id","entryId","parseIdentifier","newValues","v","vEntryId","onMoveUp","index","toTop","item","temp","onMoveDown","toBottom","onNewRecord","modelId","onExistingRecord","model","onDialogSave","selectedValues","entries","validation","invalid","disabled","entryMap","Map","e","orderedEntries","FormComponentLabel","EntryList","entry","isFirst","isLast","EntryCard","undefined","FormComponentErrorMessage","RefFieldOptions","ReferencesDialog","NewEntryDrawer","ref","EditEntryDrawer","patch"],"mappings":";;;;;;;;;;;;;AAwBO,MAAMA,iCAAiCC,oBAC1C,CAAC,EAAEC,KAAK,EAAE;IACN,MAAMC,kBAAkBC;IAExB,MAAMC,kBAA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