@webiny/app-headless-cms 6.6.0-alpha.1 → 6.6.0-alpha.11
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 +20 -3
- package/ContentEntriesModule.js.map +1 -1
- package/admin/RoutesConfig.js +5 -1
- package/admin/RoutesConfig.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js +2 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.js.map +1 -1
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.d.ts +1 -0
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js +125 -0
- package/admin/components/ContentEntries/BulkActions/ActionDelete.test.js.map +1 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.d.ts +2 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.js +85 -0
- package/admin/components/ContentEntries/Filters/RefFieldRenderer.js.map +1 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.d.ts +2 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js +34 -0
- package/admin/components/ContentEntries/Table/Actions/DuplicateEntry.js.map +1 -0
- package/admin/components/ContentEntries/Table/Actions/index.d.ts +1 -0
- package/admin/components/ContentEntries/Table/Actions/index.js +1 -0
- package/admin/components/ContentEntries/Table/Cells/CellLive.js +9 -2
- package/admin/components/ContentEntries/Table/Cells/CellLive.js.map +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js +1 -1
- package/admin/components/ContentModelEditor/ContentModelEditor.js.map +1 -1
- package/admin/components/ContentModelEditor/evaluateExpression.d.ts +1 -1
- package/admin/components/ContentModelEditor/evaluateExpression.js +6 -0
- package/admin/components/ContentModelEditor/evaluateExpression.js.map +1 -1
- package/admin/components/ContentModelEditor/operatorOptions.js +12 -0
- package/admin/components/ContentModelEditor/operatorOptions.js.map +1 -1
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.d.ts +2 -0
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js +22 -0
- package/admin/components/Dialogs/DuplicateEntryConfirmDialog.js.map +1 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.d.ts +2 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.js +33 -0
- package/admin/components/Dialogs/EditRevisionNoteDialog.js.map +1 -0
- package/admin/components/FieldEditor/Field.js +4 -4
- package/admin/components/FieldEditor/Field.js.map +1 -1
- package/admin/components/ModelFieldProvider/ModelFieldContext.d.ts +1 -0
- package/admin/config/contentEntries/editor/ContentEntryEditorConfig.d.ts +1 -1
- package/admin/graphql/contentModels.d.ts +2 -2
- package/admin/graphql/contentModels.js +1 -0
- package/admin/graphql/contentModels.js.map +1 -1
- package/admin/hooks/usePermission.js +6 -34
- package/admin/hooks/usePermission.js.map +1 -1
- package/admin/plugins/editor/defaultBar/Name/Name.d.ts +0 -5
- package/admin/plugins/editor/defaultBar/Name/Name.js +0 -2
- package/admin/plugins/editor/defaultBar/Name/Name.js.map +1 -1
- package/admin/plugins/editor/formSettings/components/GeneralSettings.js +0 -16
- package/admin/plugins/editor/formSettings/components/GeneralSettings.js.map +1 -1
- package/domain/permissions/checkCmsPermission.d.ts +14 -0
- package/domain/permissions/checkCmsPermission.js +20 -0
- package/domain/permissions/checkCmsPermission.js.map +1 -0
- package/domain/permissions/hasAccessForModel.d.ts +11 -0
- package/domain/permissions/hasAccessForModel.js +20 -0
- package/domain/permissions/hasAccessForModel.js.map +1 -0
- package/domain/permissions/isModelAllowed.d.ts +2 -0
- package/domain/permissions/isModelAllowed.js +11 -0
- package/domain/permissions/isModelAllowed.js.map +1 -0
- package/features/contentEntry/CmsEntryError.d.ts +10 -0
- package/features/contentEntry/CmsEntryError.js +11 -0
- package/features/contentEntry/CmsEntryError.js.map +1 -0
- package/features/contentEntry/bulkAction/BulkActionGateway.js +6 -1
- package/features/contentEntry/bulkAction/BulkActionGateway.js.map +1 -1
- package/features/contentEntry/bulkAction/BulkActionGateway.test.d.ts +1 -0
- package/features/contentEntry/bulkAction/BulkActionGateway.test.js +134 -0
- package/features/contentEntry/bulkAction/BulkActionGateway.test.js.map +1 -0
- package/features/contentEntry/createEntry/CreateEntryGateway.d.ts +0 -1
- package/features/contentEntry/createEntry/CreateEntryGateway.js +3 -10
- package/features/contentEntry/createEntry/CreateEntryGateway.js.map +1 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.d.ts +3 -1
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js +8 -3
- package/features/contentEntry/createRevisionFrom/CreateRevisionFromGateway.js.map +1 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.js +6 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.js.map +1 -1
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.d.ts +1 -0
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js +116 -0
- package/features/contentEntry/deleteEntry/DeleteEntryGateway.test.js.map +1 -0
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js +6 -1
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.js.map +1 -1
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.d.ts +1 -0
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js +112 -0
- package/features/contentEntry/deleteEntryRevision/DeleteEntryRevisionGateway.test.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.d.ts +14 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js +43 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryGateway.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.d.ts +15 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js +34 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryRepository.js.map +1 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.d.ts +11 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js +18 -0
- package/features/contentEntry/duplicateEntry/DuplicateEntryUseCase.js.map +1 -0
- package/features/contentEntry/duplicateEntry/abstractions.d.ts +26 -0
- package/features/contentEntry/duplicateEntry/abstractions.js +7 -0
- package/features/contentEntry/duplicateEntry/abstractions.js.map +1 -0
- package/features/contentEntry/duplicateEntry/feature.d.ts +3 -0
- package/features/contentEntry/duplicateEntry/feature.js +21 -0
- package/features/contentEntry/duplicateEntry/feature.js.map +1 -0
- package/features/contentEntry/entryValueGateways.test.d.ts +1 -0
- package/features/contentEntry/entryValueGateways.test.js +106 -0
- package/features/contentEntry/entryValueGateways.test.js.map +1 -0
- package/features/contentEntry/feature.js +4 -2
- package/features/contentEntry/feature.js.map +1 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js +6 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.js.map +1 -1
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.d.ts +1 -0
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js +130 -0
- package/features/contentEntry/permanentlyDeleteEntry/PermanentlyDeleteEntryGateway.test.js.map +1 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.d.ts +18 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.js +58 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.js.map +1 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.d.ts +1 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.js +173 -0
- package/features/contentEntry/referenceTitles/ReferenceTitles.test.js.map +1 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.d.ts +22 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js +40 -0
- package/features/contentEntry/referenceTitles/RememberTitlesDecorators.js.map +1 -0
- package/features/contentEntry/referenceTitles/abstractions.d.ts +16 -0
- package/features/contentEntry/referenceTitles/abstractions.js +5 -0
- package/features/contentEntry/referenceTitles/abstractions.js.map +1 -0
- package/features/contentEntry/referenceTitles/feature.d.ts +3 -0
- package/features/contentEntry/referenceTitles/feature.js +20 -0
- package/features/contentEntry/referenceTitles/feature.js.map +1 -0
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.d.ts +0 -1
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js +3 -10
- package/features/contentEntry/singletonEntry/UpdateSingletonEntryGateway.js.map +1 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.d.ts +0 -1
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js +3 -10
- package/features/contentEntry/updateEntry/UpdateEntryGateway.js.map +1 -1
- package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js +7 -2
- package/features/contentEntry/valueTransformers/DynamicZoneValueTransformer.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.d.ts +9 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js +8 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.js.map +1 -1
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.d.ts +1 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js +113 -0
- package/features/contentEntry/valueTransformers/EntryDataPreparer.test.js.map +1 -0
- package/features/contentEntry/valueTransformers/ObjectValueTransformer.js +16 -2
- package/features/contentEntry/valueTransformers/ObjectValueTransformer.js.map +1 -1
- package/features/contentEntry/valueTransformers/entryValueFixtures.d.ts +146 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js +171 -0
- package/features/contentEntry/valueTransformers/entryValueFixtures.js.map +1 -0
- package/features/formModel/CmsFormModelBuilder.d.ts +9 -1
- package/features/formModel/CmsFormModelBuilder.js +26 -15
- package/features/formModel/CmsFormModelBuilder.js.map +1 -1
- package/features/formModel/CmsFormModelBuilder.test.d.ts +1 -0
- package/features/formModel/CmsFormModelBuilder.test.js +465 -0
- package/features/formModel/CmsFormModelBuilder.test.js.map +1 -0
- package/features/formModel/CmsLayoutMapper.d.ts +8 -1
- package/features/formModel/CmsLayoutMapper.js +27 -5
- package/features/formModel/CmsLayoutMapper.js.map +1 -1
- package/features/formModel/CmsRefFieldValueFormatter.d.ts +12 -0
- package/features/formModel/CmsRefFieldValueFormatter.js +29 -0
- package/features/formModel/CmsRefFieldValueFormatter.js.map +1 -0
- package/features/formModel/CmsValidationMapper.d.ts +9 -0
- package/features/formModel/CmsValidationMapper.js +25 -19
- package/features/formModel/CmsValidationMapper.js.map +1 -1
- package/features/formModel/feature.js +2 -2
- package/features/formModel/feature.js.map +1 -1
- package/features/formModel/mappers/DateTimeFieldMapper.js +3 -0
- package/features/formModel/mappers/DateTimeFieldMapper.js.map +1 -1
- package/features/formModel/mappers/DynamicZoneFieldMapper.js +8 -2
- package/features/formModel/mappers/DynamicZoneFieldMapper.js.map +1 -1
- package/features/formModel/mappers/ObjectFieldMapper.js +12 -5
- package/features/formModel/mappers/ObjectFieldMapper.js.map +1 -1
- package/features/formModel/mappers/applyFieldProps.js +2 -1
- package/features/formModel/mappers/applyFieldProps.js.map +1 -1
- package/features/formModel/mappers/applyFieldProps.test.d.ts +1 -0
- package/features/formModel/mappers/applyFieldProps.test.js +59 -0
- package/features/formModel/mappers/applyFieldProps.test.js.map +1 -0
- package/features/model/deleteModel/DeleteModelGateway.js +6 -1
- package/features/model/deleteModel/DeleteModelGateway.js.map +1 -1
- package/features/model/deleteModel/DeleteModelGateway.test.d.ts +1 -0
- package/features/model/deleteModel/DeleteModelGateway.test.js +71 -0
- package/features/model/deleteModel/DeleteModelGateway.test.js.map +1 -0
- package/features/model/exportModels/ExportModelsGateway.d.ts +1 -1
- package/features/model/exportModels/ExportModelsGateway.js.map +1 -1
- package/features/model/exportModels/ExportModelsUseCase.js +7 -1
- package/features/model/exportModels/ExportModelsUseCase.js.map +1 -1
- package/features/model/exportModels/abstractions.d.ts +8 -2
- package/features/model/exportModels/abstractions.js.map +1 -1
- package/package.json +30 -28
- package/presentation/cloneContentModel/CloneContentModelPresenter.d.ts +1 -0
- package/presentation/cloneContentModel/CloneContentModelPresenter.js +8 -6
- package/presentation/cloneContentModel/CloneContentModelPresenter.js.map +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.d.ts +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js +6 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.js.map +1 -1
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.d.ts +1 -0
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js +124 -0
- package/presentation/contentEntries/bulkActions/BulkDeletePresenter.test.js.map +1 -0
- package/presentation/contentEntries/bulkActions/abstractions.d.ts +1 -1
- package/presentation/contentEntries/bulkActions/abstractions.js.map +1 -1
- package/presentation/contentEntries/form/ContentEntryFormPresenter.d.ts +2 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.d.ts +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js +107 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.deleteEntry.test.js.map +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.js +47 -30
- package/presentation/contentEntries/form/ContentEntryFormPresenter.js.map +1 -1
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js +244 -0
- package/presentation/contentEntries/form/ContentEntryFormPresenter.test.js.map +1 -0
- package/presentation/contentEntries/form/abstractions.d.ts +1 -0
- package/presentation/contentEntries/form/abstractions.js.map +1 -1
- package/presentation/contentEntries/form/getFieldBuilders.test.js +4 -2
- package/presentation/contentEntries/form/getFieldBuilders.test.js.map +1 -1
- package/presentation/contentEntries/form/toFormErrors.d.ts +7 -0
- package/presentation/contentEntries/form/toFormErrors.js +49 -0
- package/presentation/contentEntries/form/toFormErrors.js.map +1 -0
- package/presentation/contentEntries/form/toFormErrors.test.d.ts +1 -0
- package/presentation/contentEntries/form/toFormErrors.test.js +175 -0
- package/presentation/contentEntries/form/toFormErrors.test.js.map +1 -0
- package/presentation/contentEntries/list/ContentEntriesDataSource.d.ts +5 -0
- package/presentation/contentEntries/list/ContentEntriesDataSource.js +16 -4
- package/presentation/contentEntries/list/ContentEntriesDataSource.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.d.ts +6 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js +27 -2
- package/presentation/contentEntries/list/ContentEntriesPresenter.js.map +1 -1
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js +130 -5
- package/presentation/contentEntries/list/ContentEntriesPresenter.test.js.map +1 -1
- package/presentation/contentEntries/list/abstractions.d.ts +12 -0
- package/presentation/contentEntries/list/abstractions.js.map +1 -1
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.d.ts +3 -2
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js +2 -2
- package/presentation/contentEntries/preview/ComponentDiscoveryIframe.js.map +1 -1
- package/presentation/contentEntries/preview/LivePreviewPresenter.d.ts +12 -1
- package/presentation/contentEntries/preview/LivePreviewPresenter.js +48 -5
- package/presentation/contentEntries/preview/LivePreviewPresenter.js.map +1 -1
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.js +81 -0
- package/presentation/contentEntries/preview/LivePreviewPresenter.test.js.map +1 -0
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js +8 -5
- package/presentation/contentEntries/preview/ModelEditorComponentDiscovery.js.map +1 -1
- package/presentation/contentEntries/preview/PreviewDecorator.js +30 -10
- package/presentation/contentEntries/preview/PreviewDecorator.js.map +1 -1
- package/presentation/contentEntries/preview/PreviewDomainStatus.d.ts +10 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.js +19 -0
- package/presentation/contentEntries/preview/PreviewDomainStatus.js.map +1 -0
- package/presentation/contentEntries/preview/PreviewPane.d.ts +12 -3
- package/presentation/contentEntries/preview/PreviewPane.js +82 -46
- package/presentation/contentEntries/preview/PreviewPane.js.map +1 -1
- package/presentation/contentEntries/preview/abstractions.d.ts +8 -0
- package/presentation/contentEntries/preview/abstractions.js.map +1 -1
- package/presentation/contentEntries/preview/resolvePreviewUrl.d.ts +23 -2
- package/presentation/contentEntries/preview/resolvePreviewUrl.js +62 -10
- package/presentation/contentEntries/preview/resolvePreviewUrl.js.map +1 -1
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.d.ts +1 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.js +127 -0
- package/presentation/contentEntries/preview/resolvePreviewUrl.test.js.map +1 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.d.ts +21 -2
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js +143 -6
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.js.map +1 -1
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js +384 -0
- package/presentation/contentEntries/revisionsList/RevisionsListPresenter.test.js.map +1 -0
- package/presentation/contentEntries/revisionsList/abstractions.d.ts +16 -0
- package/presentation/contentEntries/revisionsList/abstractions.js.map +1 -1
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js +9 -4
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.js.map +1 -1
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.d.ts +1 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js +122 -0
- package/presentation/contentEntries/singleEntry/SingleEntryPresenter.test.js.map +1 -0
- package/presentation/contentEntries/views/ContentEntriesListLayout.js +1 -0
- package/presentation/contentEntries/views/ContentEntriesListLayout.js.map +1 -1
- package/presentation/contentEntries/views/ContentEntriesView.js +2 -0
- package/presentation/contentEntries/views/ContentEntriesView.js.map +1 -1
- package/presentation/contentEntries/views/ContentEntryFormView.js +4 -1
- package/presentation/contentEntries/views/ContentEntryFormView.js.map +1 -1
- package/presentation/contentEntries/views/OlderRevisionAlert.d.ts +4 -0
- package/presentation/contentEntries/views/OlderRevisionAlert.js +43 -0
- package/presentation/contentEntries/views/OlderRevisionAlert.js.map +1 -0
- package/presentation/contentEntries/views/RevisionDrawer.js +4 -0
- package/presentation/contentEntries/views/RevisionDrawer.js.map +1 -1
- package/presentation/contentEntries/views/RevisionListItem.d.ts +3 -3
- package/presentation/contentEntries/views/RevisionListItem.js +82 -14
- package/presentation/contentEntries/views/RevisionListItem.js.map +1 -1
- package/presentation/contentEntries/views/RevisionsList.js +3 -3
- package/presentation/contentEntries/views/RevisionsList.js.map +1 -1
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js +11 -0
- package/presentation/contentEntries/views/actions/CreateNewRevisionButton.js.map +1 -1
- package/presentation/contentModels/ContentModelsPresenter.d.ts +5 -5
- package/presentation/contentModels/ContentModelsPresenter.js +1 -1
- package/presentation/contentModels/ContentModelsPresenter.js.map +1 -1
- package/presentation/contentModels/abstractions.d.ts +7 -2
- package/presentation/contentModels/abstractions.js.map +1 -1
- package/presentation/contentModels/components/ContentModelsDataList.js +6 -5
- package/presentation/contentModels/components/ContentModelsDataList.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js +8 -3
- package/presentation/contentModels/components/fullDelete/FullyDeleteModelDialog.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/dialog/Content.js +7 -2
- package/presentation/contentModels/components/fullDelete/dialog/Content.js.map +1 -1
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.d.ts +1 -0
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.js +54 -0
- package/presentation/contentModels/components/fullDelete/dialog/Content.test.js.map +1 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.d.ts +25 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js +9 -0
- package/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js.map +1 -0
- package/presentation/fieldEditor/groups/AppearanceGroup.js +12 -0
- package/presentation/fieldEditor/groups/AppearanceGroup.js.map +1 -1
- package/presentation/fieldEditor/groups/GeneralGroup.d.ts +5 -5
- package/presentation/fieldEditor/groups/GeneralGroup.js +5 -1
- package/presentation/fieldEditor/groups/GeneralGroup.js.map +1 -1
- package/presentation/fieldEditor/groups/GeneralGroup.test.d.ts +1 -0
- package/presentation/fieldEditor/groups/GeneralGroup.test.js +68 -0
- package/presentation/fieldEditor/groups/GeneralGroup.test.js.map +1 -0
- package/presentation/fieldEditor/groups/ValidationsGroup.d.ts +2 -0
- package/presentation/fieldEditor/groups/ValidationsGroup.js +20 -6
- package/presentation/fieldEditor/groups/ValidationsGroup.js.map +1 -1
- package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js +2 -2
- package/presentation/fieldEditor/renderers/CmsValidatorsRenderer.js.map +1 -1
- package/presentation/fieldRenderers/feature.js +2 -1
- package/presentation/fieldRenderers/feature.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js +1 -0
- package/presentation/fieldRenderers/ref/CmsRefInputRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js +1 -0
- package/presentation/fieldRenderers/ref/CmsRefInputsRenderer.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.d.ts +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js +8 -2
- package/presentation/fieldRenderers/ref/autocomplete/BaseAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.d.ts +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js +185 -0
- package/presentation/fieldRenderers/ref/autocomplete/RefAutocompletePresenters.test.js.map +1 -0
- package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/multi/RefMultiAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js +1 -1
- package/presentation/fieldRenderers/ref/autocomplete/single/RefSingleAutocompletePresenter.js.map +1 -1
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js +3 -2
- package/presentation/fieldRenderers/ref/components/RefFieldOptions.js.map +1 -1
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.d.ts +15 -0
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js +19 -0
- package/presentation/fieldTypes/renderers/dateTime/BirthdayInputRenderer.js.map +1 -0
- package/presentation/fieldTypes/renderers/index.d.ts +1 -0
- package/presentation/fieldTypes/renderers/index.js +1 -0
- package/presentation/fieldValidators/abstractions.d.ts +7 -0
- package/presentation/fieldValidators/abstractions.js.map +1 -1
- package/presentation/fieldValidators/validators/DateGteValidator.d.ts +6 -0
- package/presentation/fieldValidators/validators/DateGteValidator.js +17 -25
- package/presentation/fieldValidators/validators/DateGteValidator.js.map +1 -1
- package/presentation/fieldValidators/validators/DateLteValidator.d.ts +6 -0
- package/presentation/fieldValidators/validators/DateLteValidator.js +17 -25
- package/presentation/fieldValidators/validators/DateLteValidator.js.map +1 -1
- package/presentation/fieldValidators/validators/dateLimitSettings.d.ts +20 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.js +124 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.js.map +1 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.d.ts +1 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.js +111 -0
- package/presentation/fieldValidators/validators/dateLimitSettings.test.js.map +1 -0
- package/presentation/importContentModels/ImportContentModelsPresenter.js +1 -1
- package/presentation/importContentModels/ImportContentModelsPresenter.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModelItem.js +3 -3
- package/presentation/importContentModels/components/Model/DataListModelItem.js.map +1 -1
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js +2 -2
- package/presentation/importContentModels/components/Model/DataListModelItemInfo.js.map +1 -1
- package/presentation/modelGroup/ModelGroupPresenter.js +1 -2
- package/presentation/modelGroup/ModelGroupPresenter.js.map +1 -1
- package/presentation/newContentModel/NewContentModelPresenter.d.ts +1 -0
- package/presentation/newContentModel/NewContentModelPresenter.js +8 -6
- package/presentation/newContentModel/NewContentModelPresenter.js.map +1 -1
- package/utils/normalizeIcon.d.ts +4 -0
- package/utils/normalizeIcon.js +9 -6
- package/utils/normalizeIcon.js.map +1 -1
- package/features/formModel/CmsAccessControlRuleEvaluator.d.ts +0 -9
- package/features/formModel/CmsAccessControlRuleEvaluator.js +0 -16
- package/features/formModel/CmsAccessControlRuleEvaluator.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import { AdminUiProvider } from "@webiny/admin-ui";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import { FullyDeleteModelStateStatus } from "../types.js";
|
|
6
|
+
import { Content } from "./Content.js";
|
|
7
|
+
vi.mock("@webiny/admin-ui", async (importOriginal)=>{
|
|
8
|
+
const actual = await importOriginal();
|
|
9
|
+
return {
|
|
10
|
+
...actual,
|
|
11
|
+
Alert: (props)=>/*#__PURE__*/ react.createElement("div", {
|
|
12
|
+
role: "alert"
|
|
13
|
+
}, props.children)
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
const model = {
|
|
17
|
+
modelId: "article",
|
|
18
|
+
name: "Article"
|
|
19
|
+
};
|
|
20
|
+
describe("Content of the fully delete model dialog", ()=>{
|
|
21
|
+
it("shows only the error after the server refused the delete", ()=>{
|
|
22
|
+
const view = render(/*#__PURE__*/ react.createElement(AdminUiProvider, null, /*#__PURE__*/ react.createElement(Content, {
|
|
23
|
+
model: model,
|
|
24
|
+
confirmation: "delete article",
|
|
25
|
+
setConfirmation: ()=>void 0,
|
|
26
|
+
error: {
|
|
27
|
+
message: "The model is used by a workflow.",
|
|
28
|
+
code: "X",
|
|
29
|
+
data: {}
|
|
30
|
+
},
|
|
31
|
+
status: FullyDeleteModelStateStatus.ERROR
|
|
32
|
+
})));
|
|
33
|
+
expect(view.getByText("The model is used by a workflow.")).toBeTruthy();
|
|
34
|
+
expect(view.queryByText(/Are you sure/)).toBeNull();
|
|
35
|
+
expect(view.queryAllByTestId("cms-delete-content-model-input")).toHaveLength(0);
|
|
36
|
+
});
|
|
37
|
+
it("keeps the confirmation input with a wrong confirmation text", ()=>{
|
|
38
|
+
const view = render(/*#__PURE__*/ react.createElement(AdminUiProvider, null, /*#__PURE__*/ react.createElement(Content, {
|
|
39
|
+
model: model,
|
|
40
|
+
confirmation: "nope",
|
|
41
|
+
setConfirmation: ()=>void 0,
|
|
42
|
+
error: {
|
|
43
|
+
message: "Confirmation value is not correct.",
|
|
44
|
+
code: "CONFIRMATION_ERROR",
|
|
45
|
+
data: {}
|
|
46
|
+
},
|
|
47
|
+
status: FullyDeleteModelStateStatus.UNDERSTOOD
|
|
48
|
+
})));
|
|
49
|
+
expect(view.getByText("Confirmation value is not correct.")).toBeTruthy();
|
|
50
|
+
expect(view.getAllByTestId("cms-delete-content-model-input").length).toBeGreaterThan(0);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=Content.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/dialog/Content.test.js","sources":["../../../../../../src/presentation/contentModels/components/fullDelete/dialog/Content.test.tsx"],"sourcesContent":["/**\n * @vitest-environment jsdom\n */\nimport React from \"react\";\nimport { render } from \"@testing-library/react\";\nimport { AdminUiProvider } from \"@webiny/admin-ui\";\nimport { describe } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { it } from \"vitest\";\nimport { vi } from \"vitest\";\nimport type { CmsModel } from \"~/types.js\";\nimport { FullyDeleteModelStateStatus } from \"../types.js\";\nimport { Content } from \"./Content.js\";\n\ninterface FakeAlertProps {\n children?: React.ReactNode;\n}\n\n// The real Alert renders svg icons, which this package's tests do not load.\nvi.mock(\"@webiny/admin-ui\", async importOriginal => {\n const actual = await importOriginal<typeof import(\"@webiny/admin-ui\")>();\n return {\n ...actual,\n Alert: (props: FakeAlertProps) => <div role={\"alert\"}>{props.children}</div>\n };\n});\n\nconst model = { modelId: \"article\", name: \"Article\" } as CmsModel;\n\ndescribe(\"Content of the fully delete model dialog\", () => {\n it(\"shows only the error after the server refused the delete\", () => {\n const view = render(\n <AdminUiProvider>\n <Content\n model={model}\n confirmation={\"delete article\"}\n setConfirmation={() => undefined}\n error={{ message: \"The model is used by a workflow.\", code: \"X\", data: {} }}\n status={FullyDeleteModelStateStatus.ERROR}\n />\n </AdminUiProvider>\n );\n\n expect(view.getByText(\"The model is used by a workflow.\")).toBeTruthy();\n expect(view.queryByText(/Are you sure/)).toBeNull();\n expect(view.queryAllByTestId(\"cms-delete-content-model-input\")).toHaveLength(0);\n });\n\n it(\"keeps the confirmation input with a wrong confirmation text\", () => {\n const view = render(\n <AdminUiProvider>\n <Content\n model={model}\n confirmation={\"nope\"}\n setConfirmation={() => undefined}\n error={{\n message: \"Confirmation value is not correct.\",\n code: \"CONFIRMATION_ERROR\",\n data: {}\n }}\n status={FullyDeleteModelStateStatus.UNDERSTOOD}\n />\n </AdminUiProvider>\n );\n\n expect(view.getByText(\"Confirmation value is not correct.\")).toBeTruthy();\n expect(view.getAllByTestId(\"cms-delete-content-model-input\").length).toBeGreaterThan(0);\n });\n});\n"],"names":["vi","importOriginal","actual","props","model","describe","it","view","render","AdminUiProvider","Content","undefined","FullyDeleteModelStateStatus","expect"],"mappings":";;;;;;AAmBAA,GAAG,IAAI,CAAC,oBAAoB,OAAMC;IAC9B,MAAMC,SAAS,MAAMD;IACrB,OAAO;QACH,GAAGC,MAAM;QACT,OAAO,CAACC,QAAAA,WAAAA,GAA0B,oBAAC;gBAAI,MAAM;eAAUA,MAAM,QAAQ;IACzE;AACJ;AAEA,MAAMC,QAAQ;IAAE,SAAS;IAAW,MAAM;AAAU;AAEpDC,SAAS,4CAA4C;IACjDC,GAAG,4DAA4D;QAC3D,MAAMC,OAAOC,OAAO,WAADA,GACf,oBAACC,iBAAeA,MAAAA,WAAAA,GACZ,oBAACC,SAAOA;YACJ,OAAON;YACP,cAAc;YACd,iBAAiB,IAAMO;YACvB,OAAO;gBAAE,SAAS;gBAAoC,MAAM;gBAAK,MAAM,CAAC;YAAE;YAC1E,QAAQC,4BAA4B,KAAK;;QAKrDC,OAAON,KAAK,SAAS,CAAC,qCAAqC,UAAU;QACrEM,OAAON,KAAK,WAAW,CAAC,iBAAiB,QAAQ;QACjDM,OAAON,KAAK,gBAAgB,CAAC,mCAAmC,YAAY,CAAC;IACjF;IAEAD,GAAG,+DAA+D;QAC9D,MAAMC,OAAOC,OAAO,WAADA,GACf,oBAACC,iBAAeA,MAAAA,WAAAA,GACZ,oBAACC,SAAOA;YACJ,OAAON;YACP,cAAc;YACd,iBAAiB,IAAMO;YACvB,OAAO;gBACH,SAAS;gBACT,MAAM;gBACN,MAAM,CAAC;YACX;YACA,QAAQC,4BAA4B,UAAU;;QAK1DC,OAAON,KAAK,SAAS,CAAC,uCAAuC,UAAU;QACvEM,OAAON,KAAK,cAAc,CAAC,kCAAkC,MAAM,EAAE,eAAe,CAAC;IACzF;AACJ"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { CmsErrorResponse, CmsModel } from "../../../../../types.js";
|
|
3
|
+
export interface FullyDeleteModelErrorProps {
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
error: CmsErrorResponse;
|
|
6
|
+
}
|
|
7
|
+
export declare const FullyDeleteModelError: ((props: FullyDeleteModelErrorProps) => React.JSX.Element) & {
|
|
8
|
+
original: (props: FullyDeleteModelErrorProps) => React.JSX.Element;
|
|
9
|
+
originalName: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
} & {
|
|
12
|
+
original: ((props: FullyDeleteModelErrorProps) => React.JSX.Element) & {
|
|
13
|
+
original: (props: FullyDeleteModelErrorProps) => React.JSX.Element;
|
|
14
|
+
originalName: string;
|
|
15
|
+
displayName: string;
|
|
16
|
+
};
|
|
17
|
+
originalName: string;
|
|
18
|
+
displayName: string;
|
|
19
|
+
} & {
|
|
20
|
+
createDecorator: (decorator: import("@webiny/react-composition").ComponentDecorator<((props: FullyDeleteModelErrorProps) => React.JSX.Element) & {
|
|
21
|
+
original: (props: FullyDeleteModelErrorProps) => React.JSX.Element;
|
|
22
|
+
originalName: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
}>) => (props: unknown) => React.JSX.Element;
|
|
25
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { makeDecoratable } from "@webiny/react-composition";
|
|
3
|
+
import { Alert } from "@webiny/admin-ui";
|
|
4
|
+
const FullyDeleteModelError = makeDecoratable("FullyDeleteModelError", (props)=>/*#__PURE__*/ react.createElement(Alert, {
|
|
5
|
+
type: "danger"
|
|
6
|
+
}, props.error.message));
|
|
7
|
+
export { FullyDeleteModelError };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=FullyDeleteModelError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.js","sources":["../../../../../../src/presentation/contentModels/components/fullDelete/dialog/FullyDeleteModelError.tsx"],"sourcesContent":["import React from \"react\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { Alert } from \"@webiny/admin-ui\";\nimport type { CmsErrorResponse, CmsModel } from \"~/types.js\";\n\nexport interface FullyDeleteModelErrorProps {\n model: CmsModel;\n error: CmsErrorResponse;\n}\n\n/*\n * The error a refused model delete ends with. Decoratable, so a package that blocks the delete\n * (for example a workflow bound to the model) can explain its own refusal.\n */\nexport const FullyDeleteModelError = makeDecoratable(\n \"FullyDeleteModelError\",\n (props: FullyDeleteModelErrorProps) => {\n return <Alert type={\"danger\"}>{props.error.message}</Alert>;\n }\n);\n"],"names":["FullyDeleteModelError","makeDecoratable","props","Alert"],"mappings":";;;AAcO,MAAMA,wBAAwBC,gBACjC,yBACA,CAACC,QACU,WAAP,GAAO,oBAACC,OAAKA;QAAC,MAAM;OAAWD,MAAM,KAAK,CAAC,OAAO"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { CmsFieldEditorGroup } from "../abstractions.js";
|
|
2
2
|
import { CmsFieldRenderer } from "../../fieldRenderers/abstractions.js";
|
|
3
|
+
const getOptionalValue = (form, path)=>{
|
|
4
|
+
try {
|
|
5
|
+
return form.field(path).getValue();
|
|
6
|
+
} catch {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
3
10
|
class AppearanceGroupImpl {
|
|
4
11
|
constructor(allRenderers){
|
|
5
12
|
this.allRenderers = allRenderers;
|
|
@@ -13,9 +20,14 @@ class AppearanceGroupImpl {
|
|
|
13
20
|
name: fields.text().options(({ form })=>{
|
|
14
21
|
const list = Boolean(form.field("general.list").getValue());
|
|
15
22
|
const predefined = Boolean(form.field("general.predefinedValuesEnabled").getValue());
|
|
23
|
+
const settingsType = getOptionalValue(form, "general.settingsType");
|
|
16
24
|
const liveField = {
|
|
17
25
|
...context.field,
|
|
18
26
|
list,
|
|
27
|
+
settings: "string" == typeof settingsType ? {
|
|
28
|
+
...context.field.settings,
|
|
29
|
+
type: settingsType
|
|
30
|
+
} : context.field.settings,
|
|
19
31
|
predefinedValues: {
|
|
20
32
|
values: context.field.predefinedValues?.values ?? [],
|
|
21
33
|
enabled: predefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldEditor/groups/AppearanceGroup.js","sources":["../../../../src/presentation/fieldEditor/groups/AppearanceGroup.ts"],"sourcesContent":["import { CmsFieldEditorGroup } from \"../abstractions.js\";\nimport type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from \"../abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { CmsFieldRenderer } from \"~/presentation/fieldRenderers/abstractions.js\";\nimport type {\n ICmsFieldRenderer,\n ICmsFieldRendererFormBuilder\n} from \"~/presentation/fieldRenderers/abstractions.js\";\nimport type { FormModelFactory, FormModel } from \"@webiny/app-admin\";\n\ndeclare module \"@webiny/app-admin/features/formModel/abstractions.js\" {\n interface IFieldRendererRegistry {\n cmsAppearance: { fieldType: \"object\"; settings: undefined };\n }\n}\n\ninterface RendererSettingsBuild {\n rendererName: string;\n fieldsFns: Array<\n (f: FormModelFactory.FieldBuilderRegistry) => Record<string, FormModelFactory.FieldBuilder>\n >;\n layoutFns: Array<(l: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[]>;\n}\n\nclass AppearanceGroupImpl implements CmsFieldEditorGroup.Interface {\n name = \"appearance\";\n label = \"Appearance\";\n\n constructor(private allRenderers: ICmsFieldRenderer[]) {}\n\n buildForm(form: ICmsFieldEditorFormBuilder, context: ICmsFieldEditorContext) {\n const settingsBuilds = this.collectRendererSettings(this.allRenderers);\n\n form.fields(fields => {\n const rendererChildren: Record<string, FormModelFactory.FieldBuilder> = {\n name: fields.text().options(({ form }) => {\n const list = Boolean(form.field(\"general.list\").getValue());\n const predefined = Boolean(\n form.field(\"general.predefinedValuesEnabled\").getValue()\n );\n const liveField = {\n ...context.field,\n list,\n predefinedValues: {\n values: context.field.predefinedValues?.values ?? [],\n enabled: predefined\n }\n };\n\n return this.allRenderers\n .filter(r => r.canUse({ field: liveField, model: context.model }))\n .map(r => ({ label: r.name, value: r.rendererName }));\n })\n };\n\n for (const build of settingsBuilds) {\n const notSelected = ({ field }: FormModel.CallbackParams) =>\n field.parent().field(\"name\").getValue() !== build.rendererName;\n\n rendererChildren[`settings__${build.rendererName}`] = fields\n .object()\n .renderer(\"passthrough\")\n .hiddenWhen(notSelected)\n .fields((f: FormModelFactory.FieldBuilderRegistry) => {\n const merged: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const fn of build.fieldsFns) {\n Object.assign(merged, fn(f));\n }\n return merged;\n });\n }\n\n return {\n renderer: fields\n .object()\n .renderer(\"cmsAppearance\")\n .fields(() => rendererChildren)\n };\n });\n\n form.layout(layout => {\n const innerLayout = (inner: FormModelFactory.LayoutBuilder) => {\n const nodes: FormModel.LayoutNodeBuilder[] = [inner.row(\"name\")];\n for (const build of settingsBuilds) {\n nodes.push(\n inner.object(`settings__${build.rendererName}`, settingsInner =>\n build.layoutFns.flatMap(fn => fn(settingsInner))\n )\n );\n }\n return nodes;\n };\n\n return [layout.object(\"renderer\", innerLayout)];\n });\n }\n\n mapToForm(field: CmsModelField) {\n const renderer = typeof field.renderer === \"object\" ? field.renderer : null;\n const rendererName = renderer ? renderer.name : \"\";\n const settings = renderer ? (renderer.settings ?? {}) : {};\n\n const result: Record<string, unknown> = {\n name: rendererName\n };\n\n for (const r of this.allRenderers) {\n if (r.buildSettingsForm) {\n result[`settings__${r.rendererName}`] =\n r.rendererName === rendererName ? settings : {};\n }\n }\n\n return { renderer: result };\n }\n\n mapFromForm(formData: Record<string, any>, field: CmsModelField) {\n const rendererName = formData.renderer?.name || \"\";\n const settingsKey = `settings__${rendererName}`;\n const settings = formData.renderer?.[settingsKey] ?? {};\n\n field.renderer = {\n name: rendererName,\n settings\n };\n }\n\n private collectRendererSettings(renderers: ICmsFieldRenderer[]): RendererSettingsBuild[] {\n const builds: RendererSettingsBuild[] = [];\n\n for (const renderer of renderers) {\n if (!renderer.buildSettingsForm) {\n continue;\n }\n\n const fieldsFns: RendererSettingsBuild[\"fieldsFns\"] = [];\n const layoutFns: RendererSettingsBuild[\"layoutFns\"] = [];\n\n const builder: ICmsFieldRendererFormBuilder = {\n fields: fn => {\n fieldsFns.push(fn);\n },\n layout: fn => {\n layoutFns.push(fn);\n }\n };\n\n renderer.buildSettingsForm(builder);\n\n if (fieldsFns.length > 0) {\n builds.push({ rendererName: renderer.rendererName, fieldsFns, layoutFns });\n }\n }\n\n return builds;\n }\n}\n\nexport const AppearanceGroup = CmsFieldEditorGroup.createImplementation({\n implementation: AppearanceGroupImpl,\n dependencies: [[CmsFieldRenderer, { multiple: true }]]\n});\n"],"names":["AppearanceGroupImpl","allRenderers","form","context","settingsBuilds","fields","rendererChildren","list","Boolean","predefined","liveField","r","build","notSelected","field","f","merged","fn","Object","layout","innerLayout","inner","nodes","settingsInner","renderer","rendererName","settings","result","formData","settingsKey","renderers","builds","fieldsFns","layoutFns","builder","AppearanceGroup","CmsFieldEditorGroup","CmsFieldRenderer"],"mappings":";;AAwBA,MAAMA;IAIF,YAAoBC,YAAiC,CAAE;aAAnCA,YAAY,GAAZA;aAHpB,IAAI,GAAG;aACP,KAAK,GAAG;IAEgD;IAExD,UAAUC,IAAgC,EAAEC,OAA+B,EAAE;QACzE,MAAMC,iBAAiB,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,YAAY;QAErEF,KAAK,MAAM,CAACG,CAAAA;YACR,MAAMC,mBAAkE;gBACpE,MAAMD,OAAO,IAAI,GAAG,OAAO,CAAC,CAAC,EAAEH,IAAI,EAAE;oBACjC,MAAMK,OAAOC,QAAQN,KAAK,KAAK,CAAC,gBAAgB,QAAQ;oBACxD,MAAMO,aAAaD,QACfN,KAAK,KAAK,CAAC,mCAAmC,QAAQ;oBAE1D,MAAMQ,YAAY;wBACd,GAAGP,QAAQ,KAAK;wBAChBI;wBACA,kBAAkB;4BACd,QAAQJ,QAAQ,KAAK,CAAC,gBAAgB,EAAE,UAAU,EAAE;4BACpD,SAASM;wBACb;oBACJ;oBAEA,OAAO,IAAI,CAAC,YAAY,CACnB,MAAM,CAACE,CAAAA,IAAKA,EAAE,MAAM,CAAC;4BAAE,OAAOD;4BAAW,OAAOP,QAAQ,KAAK;wBAAC,IAC9D,GAAG,CAACQ,CAAAA,IAAM;4BAAE,OAAOA,EAAE,IAAI;4BAAE,OAAOA,EAAE,YAAY;wBAAC;g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E,iBAAiB,EACnBgB,MAAM,CAAC,CAAC,UAAU,EAAEhB,EAAE,YAAY,EAAE,CAAC,GACjCA,EAAE,YAAY,KAAKc,eAAeC,WAAW,CAAC;QAI1D,OAAO;YAAE,UAAUC;QAAO;IAC9B;IAEA,YAAYC,QAA6B,EAAEd,KAAoB,EAAE;QAC7D,MAAMW,eAAeG,SAAS,QAAQ,EAAE,QAAQ;QAChD,MAAMC,cAAc,CAAC,UAAU,EAAEJ,cAAc;QAC/C,MAAMC,WAAWE,SAAS,QAAQ,EAAE,CAACC,YAAY,IAAI,CAAC;QAEtDf,MAAM,QAAQ,GAAG;YACb,MAAMW;YACNC;QACJ;IACJ;IAEQ,wBAAwBI,SAA8B,EAA2B;QACrF,MAAMC,SAAkC,EAAE;QAE1C,KAAK,MAAMP,YAAYM,UAAW;YAC9B,IAAI,CAACN,SAAS,iBAAiB,EAC3B;YAGJ,MAAMQ,YAAgD,EAAE;YACxD,MAAMC,YAAgD,EAAE;YAExD,MAAMC,UAAwC;gBAC1C,QAAQjB,CAAAA;oBACJe,UAAU,IAAI,CAACf;gBACnB;gBACA,QAAQA,CAAAA;oBACJgB,UAAU,IAAI,CAAChB;gBACnB;YACJ;YAEAO,SAAS,iBAAiB,CAACU;YAE3B,IAAIF,UAAU,MAAM,GAAG,GACnBD,OAAO,IAAI,CAAC;gBAAE,cAAcP,SAAS,YAAY;gBAAEQ;gBAAWC;YAAU;QAEhF;QAEA,OAAOF;IACX;AACJ;AAEO,MAAMI,kBAAkBC,oBAAoB,oBAAoB,CAAC;IACpE,gBAAgBpC;IAChB,cAAc;QAAC;YAACqC;YAAkB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC1D"}
|
|
1
|
+
{"version":3,"file":"presentation/fieldEditor/groups/AppearanceGroup.js","sources":["../../../../src/presentation/fieldEditor/groups/AppearanceGroup.ts"],"sourcesContent":["import { CmsFieldEditorGroup } from \"../abstractions.js\";\nimport type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from \"../abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\nimport { CmsFieldRenderer } from \"~/presentation/fieldRenderers/abstractions.js\";\nimport type {\n ICmsFieldRenderer,\n ICmsFieldRendererFormBuilder\n} from \"~/presentation/fieldRenderers/abstractions.js\";\nimport type { FormModelFactory, FormModel } from \"@webiny/app-admin\";\n\ndeclare module \"@webiny/app-admin/features/formModel/abstractions.js\" {\n interface IFieldRendererRegistry {\n cmsAppearance: { fieldType: \"object\"; settings: undefined };\n }\n}\n\n/**\n * Only some field types add the field (date/time adds `general.settingsType`, the Format\n * dropdown), and `form.field()` throws for a path the form doesn't have.\n */\nconst getOptionalValue = (form: FormModel.Interface, path: string): unknown => {\n try {\n return form.field(path).getValue();\n } catch {\n return undefined;\n }\n};\n\ninterface RendererSettingsBuild {\n rendererName: string;\n fieldsFns: Array<\n (f: FormModelFactory.FieldBuilderRegistry) => Record<string, FormModelFactory.FieldBuilder>\n >;\n layoutFns: Array<(l: FormModelFactory.LayoutBuilder) => FormModel.LayoutNodeBuilder[]>;\n}\n\nclass AppearanceGroupImpl implements CmsFieldEditorGroup.Interface {\n name = \"appearance\";\n label = \"Appearance\";\n\n constructor(private allRenderers: ICmsFieldRenderer[]) {}\n\n buildForm(form: ICmsFieldEditorFormBuilder, context: ICmsFieldEditorContext) {\n const settingsBuilds = this.collectRendererSettings(this.allRenderers);\n\n form.fields(fields => {\n const rendererChildren: Record<string, FormModelFactory.FieldBuilder> = {\n name: fields.text().options(({ form }) => {\n const list = Boolean(form.field(\"general.list\").getValue());\n const predefined = Boolean(\n form.field(\"general.predefinedValuesEnabled\").getValue()\n );\n const settingsType = getOptionalValue(form, \"general.settingsType\");\n const liveField = {\n ...context.field,\n list,\n settings:\n typeof settingsType === \"string\"\n ? { ...context.field.settings, type: settingsType }\n : context.field.settings,\n predefinedValues: {\n values: context.field.predefinedValues?.values ?? [],\n enabled: predefined\n }\n };\n\n return this.allRenderers\n .filter(r => r.canUse({ field: liveField, model: context.model }))\n .map(r => ({ label: r.name, value: r.rendererName }));\n })\n };\n\n for (const build of settingsBuilds) {\n const notSelected = ({ field }: FormModel.CallbackParams) =>\n field.parent().field(\"name\").getValue() !== build.rendererName;\n\n rendererChildren[`settings__${build.rendererName}`] = fields\n .object()\n .renderer(\"passthrough\")\n .hiddenWhen(notSelected)\n .fields((f: FormModelFactory.FieldBuilderRegistry) => {\n const merged: Record<string, FormModelFactory.FieldBuilder> = {};\n for (const fn of build.fieldsFns) {\n Object.assign(merged, fn(f));\n }\n return merged;\n });\n }\n\n return {\n renderer: fields\n .object()\n .renderer(\"cmsAppearance\")\n .fields(() => rendererChildren)\n };\n });\n\n form.layout(layout => {\n const innerLayout = (inner: FormModelFactory.LayoutBuilder) => {\n const nodes: FormModel.LayoutNodeBuilder[] = [inner.row(\"name\")];\n for (const build of settingsBuilds) {\n nodes.push(\n inner.object(`settings__${build.rendererName}`, settingsInner =>\n build.layoutFns.flatMap(fn => fn(settingsInner))\n )\n );\n }\n return nodes;\n };\n\n return [layout.object(\"renderer\", innerLayout)];\n });\n }\n\n mapToForm(field: CmsModelField) {\n const renderer = typeof field.renderer === \"object\" ? field.renderer : null;\n const rendererName = renderer ? renderer.name : \"\";\n const settings = renderer ? (renderer.settings ?? {}) : {};\n\n const result: Record<string, unknown> = {\n name: rendererName\n };\n\n for (const r of this.allRenderers) {\n if (r.buildSettingsForm) {\n result[`settings__${r.rendererName}`] =\n r.rendererName === rendererName ? settings : {};\n }\n }\n\n return { renderer: result };\n }\n\n mapFromForm(formData: Record<string, any>, field: CmsModelField) {\n const rendererName = formData.renderer?.name || \"\";\n const settingsKey = `settings__${rendererName}`;\n const settings = formData.renderer?.[settingsKey] ?? {};\n\n field.renderer = {\n name: rendererName,\n settings\n };\n }\n\n private collectRendererSettings(renderers: ICmsFieldRenderer[]): RendererSettingsBuild[] {\n const builds: RendererSettingsBuild[] = [];\n\n for (const renderer of renderers) {\n if (!renderer.buildSettingsForm) {\n continue;\n }\n\n const fieldsFns: RendererSettingsBuild[\"fieldsFns\"] = [];\n const layoutFns: RendererSettingsBuild[\"layoutFns\"] = [];\n\n const builder: ICmsFieldRendererFormBuilder = {\n fields: fn => {\n fieldsFns.push(fn);\n },\n layout: fn => {\n layoutFns.push(fn);\n }\n };\n\n renderer.buildSettingsForm(builder);\n\n if (fieldsFns.length > 0) {\n builds.push({ rendererName: renderer.rendererName, fieldsFns, layoutFns });\n }\n }\n\n return builds;\n }\n}\n\nexport const AppearanceGroup = CmsFieldEditorGroup.createImplementation({\n implementation: AppearanceGroupImpl,\n dependencies: [[CmsFieldRenderer, { multiple: true }]]\n});\n"],"names":["getOptionalValue","form","path","AppearanceGroupImpl","allRenderers","context","settingsBuilds","fields","rendererChildren","list","Boolean","predefined","settingsType","liveField","r","build","notSelected","field","f","merged","fn","Object","layout","innerLayout","inner","nodes","settingsInner","renderer","rendererName","settings","result","formData","settingsKey","renderers","builds","fieldsFns","layoutFns","builder","AppearanceGroup","CmsFieldEditorGroup","CmsFieldRenderer"],"mappings":";;AAoBA,MAAMA,mBAAmB,CAACC,MAA2BC;IACjD,IAAI;QACA,OAAOD,KAAK,KAAK,CAACC,MAAM,QAAQ;IACpC,EAAE,OAAM;QACJ;IACJ;AACJ;AAUA,MAAMC;IAIF,YAAoBC,YAAiC,CAAE;aAAnCA,YAAY,GAAZA;aAHpB,IAAI,GAAG;aACP,KAAK,GAAG;IAEgD;IAExD,UAAUH,IAAgC,EAAEI,OAA+B,EAAE;QACzE,MAAMC,iBAAiB,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,YAAY;QAErEL,KAAK,MAAM,CAACM,CAAAA;YACR,MAAMC,mBAAkE;gBACpE,MAAMD,OAAO,IAAI,GAAG,OAAO,CAAC,CAAC,EAAEN,IAAI,EAAE;oBACjC,MAAMQ,OAAOC,QAAQT,KAAK,KAAK,CAAC,gBAAgB,QAAQ;oBACxD,MAAMU,aAAaD,QACfT,KAAK,KAAK,CAAC,mCAAmC,QAAQ;oBAE1D,M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A,QAAQA,CAAAA;oBACJgB,UAAU,IAAI,CAAChB;gBACnB;YACJ;YAEAO,SAAS,iBAAiB,CAACU;YAE3B,IAAIF,UAAU,MAAM,GAAG,GACnBD,OAAO,IAAI,CAAC;gBAAE,cAAcP,SAAS,YAAY;gBAAEQ;gBAAWC;YAAU;QAEhF;QAEA,OAAOF;IACX;AACJ;AAEO,MAAMI,kBAAkBC,oBAAoB,oBAAoB,CAAC;IACpE,gBAAgBpC;IAChB,cAAc;QAAC;YAACqC;YAAkB;gBAAE,UAAU;YAAK;SAAE;KAAC;AAC1D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CmsFieldEditorGroup } from "../abstractions.js";
|
|
2
2
|
import type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from "../abstractions.js";
|
|
3
3
|
import type { CmsModelField } from "../../../types.js";
|
|
4
|
-
declare class GeneralGroupImpl implements CmsFieldEditorGroup.Interface {
|
|
4
|
+
export declare class GeneralGroupImpl implements CmsFieldEditorGroup.Interface {
|
|
5
5
|
name: string;
|
|
6
6
|
label: string;
|
|
7
7
|
buildForm(form: ICmsFieldEditorFormBuilder, context: ICmsFieldEditorContext): void;
|
|
@@ -10,9 +10,10 @@ declare class GeneralGroupImpl implements CmsFieldEditorGroup.Interface {
|
|
|
10
10
|
fieldId: string;
|
|
11
11
|
list: boolean;
|
|
12
12
|
predefinedValuesEnabled: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
description: string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
15
|
+
note: string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
|
+
help: string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
17
|
tags: string[];
|
|
17
18
|
};
|
|
18
19
|
mapFromForm(formData: Record<string, any>, field: CmsModelField): void;
|
|
@@ -20,4 +21,3 @@ declare class GeneralGroupImpl implements CmsFieldEditorGroup.Interface {
|
|
|
20
21
|
export declare const GeneralGroup: typeof GeneralGroupImpl & {
|
|
21
22
|
__abstraction: import("@webiny/di").Abstraction<import("../abstractions.js").ICmsFieldEditorGroup>;
|
|
22
23
|
};
|
|
23
|
-
export {};
|
|
@@ -18,6 +18,7 @@ class GeneralGroupImpl {
|
|
|
18
18
|
fieldId: fieldIdBuilder,
|
|
19
19
|
list: fields.boolean().label(fieldType.listLabel || "Use as a list").disabled(!fieldType.allowList),
|
|
20
20
|
predefinedValuesEnabled: fields.boolean().label("Use predefined values").disabled(!fieldType.allowPredefinedValues),
|
|
21
|
+
disabled: fields.boolean().label("Disabled").description("Shows the value but doesn't let editors change it. Only useful when something else writes it, such as your code or an integration calling the API."),
|
|
21
22
|
description: fields.text().label("Description").description("This text will be shown below the label (optional)"),
|
|
22
23
|
note: fields.text().label("Note").description("This text will be shown below the input (optional)"),
|
|
23
24
|
help: fields.text().label("Help").renderer("textarea").description("This text will be shown in a tooltip (optional)"),
|
|
@@ -27,6 +28,7 @@ class GeneralGroupImpl {
|
|
|
27
28
|
form.layout((layout)=>[
|
|
28
29
|
layout.row("label", "fieldId"),
|
|
29
30
|
layout.row("list", "predefinedValuesEnabled"),
|
|
31
|
+
layout.row("disabled"),
|
|
30
32
|
layout.row("description"),
|
|
31
33
|
layout.row("note"),
|
|
32
34
|
layout.row("help"),
|
|
@@ -39,6 +41,7 @@ class GeneralGroupImpl {
|
|
|
39
41
|
fieldId: field.fieldId ?? "",
|
|
40
42
|
list: field.list ?? false,
|
|
41
43
|
predefinedValuesEnabled: field.predefinedValues?.enabled ?? false,
|
|
44
|
+
disabled: field.disabled ?? false,
|
|
42
45
|
description: field.description ?? "",
|
|
43
46
|
note: field.note ?? "",
|
|
44
47
|
help: field.help ?? "",
|
|
@@ -54,6 +57,7 @@ class GeneralGroupImpl {
|
|
|
54
57
|
values: []
|
|
55
58
|
};
|
|
56
59
|
field.predefinedValues.enabled = formData.predefinedValuesEnabled;
|
|
60
|
+
field.disabled = formData.disabled;
|
|
57
61
|
field.description = formData.description;
|
|
58
62
|
field.note = formData.note;
|
|
59
63
|
field.help = formData.help;
|
|
@@ -68,6 +72,6 @@ const GeneralGroup = CmsFieldEditorGroup.createImplementation({
|
|
|
68
72
|
implementation: GeneralGroupImpl,
|
|
69
73
|
dependencies: []
|
|
70
74
|
});
|
|
71
|
-
export { GeneralGroup };
|
|
75
|
+
export { GeneralGroup, GeneralGroupImpl };
|
|
72
76
|
|
|
73
77
|
//# sourceMappingURL=GeneralGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldEditor/groups/GeneralGroup.js","sources":["../../../../src/presentation/fieldEditor/groups/GeneralGroup.ts"],"sourcesContent":["import zod from \"zod\";\nimport camelCase from \"lodash/camelCase.js\";\nimport { CmsFieldEditorGroup } from \"../abstractions.js\";\nimport type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from \"../abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\n\nconst fieldIdSchema = zod\n .string()\n .max(100)\n .regex(/^!?[a-zA-Z]/, { message: \"Must not start with a number.\" })\n .regex(/^(^[a-zA-Z0-9]+)$/, { message: \"Must be alphanumeric string.\" });\n\
|
|
1
|
+
{"version":3,"file":"presentation/fieldEditor/groups/GeneralGroup.js","sources":["../../../../src/presentation/fieldEditor/groups/GeneralGroup.ts"],"sourcesContent":["import zod from \"zod\";\nimport camelCase from \"lodash/camelCase.js\";\nimport { CmsFieldEditorGroup } from \"../abstractions.js\";\nimport type { ICmsFieldEditorFormBuilder, ICmsFieldEditorContext } from \"../abstractions.js\";\nimport type { CmsModelField } from \"~/types.js\";\n\nconst fieldIdSchema = zod\n .string()\n .max(100)\n .regex(/^!?[a-zA-Z]/, { message: \"Must not start with a number.\" })\n .regex(/^(^[a-zA-Z0-9]+)$/, { message: \"Must be alphanumeric string.\" });\n\nexport class GeneralGroupImpl implements CmsFieldEditorGroup.Interface {\n name = \"general\";\n label = \"General\";\n\n buildForm(form: ICmsFieldEditorFormBuilder, context: ICmsFieldEditorContext) {\n const { fieldType, field } = context;\n const isNewField = !field.id;\n\n form.fields(fields => {\n const fieldIdBuilder = fields\n .text()\n .label(\"Field ID\")\n .required()\n .schema(fieldIdSchema)\n .beforeChange(value => String(value).trim());\n\n if (isNewField) {\n fieldIdBuilder.computedUntilDirty(({ form }) => {\n return camelCase(String(form.field(\"general.label\").getValue() || \"\"));\n });\n }\n\n return {\n label: fields.text().label(\"Label\").required().autoFocus(),\n fieldId: fieldIdBuilder,\n list: fields\n .boolean()\n .label(fieldType.listLabel || \"Use as a list\")\n .disabled(!fieldType.allowList),\n predefinedValuesEnabled: fields\n .boolean()\n .label(\"Use predefined values\")\n .disabled(!fieldType.allowPredefinedValues),\n disabled: fields\n .boolean()\n .label(\"Disabled\")\n .description(\n \"Shows the value but doesn't let editors change it. Only useful when something else writes it, such as your code or an integration calling the API.\"\n ),\n description: fields\n .text()\n .label(\"Description\")\n .description(\"This text will be shown below the label (optional)\"),\n note: fields\n .text()\n .label(\"Note\")\n .description(\"This text will be shown below the input (optional)\"),\n help: fields\n .text()\n .label(\"Help\")\n .renderer(\"textarea\")\n .description(\"This text will be shown in a tooltip (optional)\"),\n tags: fields\n .text()\n .label(\"Tags\")\n .renderer(\"tags\")\n .list()\n .description(\n \"Field tags are useful for developers and are not visible in the UI (optional)\"\n )\n };\n });\n\n form.layout(layout => [\n layout.row(\"label\", \"fieldId\"),\n layout.row(\"list\", \"predefinedValuesEnabled\"),\n layout.row(\"disabled\"),\n layout.row(\"description\"),\n layout.row(\"note\"),\n layout.row(\"help\"),\n layout.row(\"tags\")\n ]);\n }\n\n mapToForm(field: CmsModelField) {\n return {\n label: field.label ?? \"\",\n fieldId: field.fieldId ?? \"\",\n list: field.list ?? false,\n predefinedValuesEnabled: field.predefinedValues?.enabled ?? false,\n disabled: field.disabled ?? false,\n description: field.description ?? \"\",\n note: field.note ?? \"\",\n help: field.help ?? \"\",\n tags: field.tags ?? []\n };\n }\n\n mapFromForm(formData: Record<string, any>, field: CmsModelField) {\n field.label = formData.label;\n field.fieldId = formData.fieldId;\n field.list = formData.list;\n if (!field.predefinedValues) {\n field.predefinedValues = { enabled: false, values: [] };\n }\n field.predefinedValues.enabled = formData.predefinedValuesEnabled;\n field.disabled = formData.disabled;\n field.description = formData.description;\n field.note = formData.note;\n field.help = formData.help;\n field.tags = formData.tags;\n }\n}\n\nexport const GeneralGroup = CmsFieldEditorGroup.createImplementation({\n implementation: GeneralGroupImpl,\n dependencies: []\n});\n"],"names":["fieldIdSchema","zod","GeneralGroupImpl","form","context","fieldType","field","isNewField","fields","fieldIdBuilder","value","String","camelCase","layout","formData","GeneralGroup","CmsFieldEditorGroup"],"mappings":";;;AAMA,MAAMA,gBAAgBC,IAAAA,MACX,GACN,GAAG,CAAC,KACJ,KAAK,CAAC,eAAe;IAAE,SAAS;AAAgC,GAChE,KAAK,CAAC,qBAAqB;IAAE,SAAS;AAA+B;AAEnE,MAAMC;IAIT,UAAUC,IAAgC,EAAEC,OAA+B,EAAE;QACzE,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGF;QAC7B,MAAMG,aAAa,CAACD,MAAM,EAAE;QAE5BH,KAAK,MAAM,CAACK,CAAAA;YACR,MAAMC,iBAAiBD,OAClB,IAAI,GACJ,KA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,yBAAyBA,MAAM,gBAAgB,EAAE,WAAW;YAC5D,UAAUA,MAAM,QAAQ,IAAI;YAC5B,aAAaA,MAAM,WAAW,IAAI;YAClC,MAAMA,MAAM,IAAI,IAAI;YACpB,MAAMA,MAAM,IAAI,IAAI;YACpB,MAAMA,MAAM,IAAI,IAAI,EAAE;QAC1B;IACJ;IAEA,YAAYQ,QAA6B,EAAER,KAAoB,EAAE;QAC7DA,MAAM,KAAK,GAAGQ,SAAS,KAAK;QAC5BR,MAAM,OAAO,GAAGQ,SAAS,OAAO;QAChCR,MAAM,IAAI,GAAGQ,SAAS,IAAI;QAC1B,IAAI,CAACR,MAAM,gBAAgB,EACvBA,MAAM,gBAAgB,GAAG;YAAE,SAAS;YAAO,QAAQ,EAAE;QAAC;QAE1DA,MAAM,gBAAgB,CAAC,OAAO,GAAGQ,SAAS,uBAAuB;QACjER,MAAM,QAAQ,GAAGQ,SAAS,QAAQ;QAClCR,MAAM,WAAW,GAAGQ,SAAS,WAAW;QACxCR,MAAM,IAAI,GAAGQ,SAAS,IAAI;QAC1BR,MAAM,IAAI,GAAGQ,SAAS,IAAI;QAC1BR,MAAM,IAAI,GAAGQ,SAAS,IAAI;IAC9B;;aApGA,IAAI,GAAG;aACP,KAAK,GAAG;;AAoGZ;AAEO,MAAMC,eAAeC,oBAAoB,oBAAoB,CAAC;IACjE,gBAAgBd;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { GeneralGroupImpl } from "./GeneralGroup.js";
|
|
3
|
+
const createGroup = ()=>new GeneralGroupImpl();
|
|
4
|
+
const createField = (overrides = {})=>({
|
|
5
|
+
id: "externalId",
|
|
6
|
+
fieldId: "externalId",
|
|
7
|
+
storageId: "text@externalId",
|
|
8
|
+
type: "text",
|
|
9
|
+
label: "External ID",
|
|
10
|
+
renderer: {
|
|
11
|
+
name: "text-input"
|
|
12
|
+
},
|
|
13
|
+
validation: [],
|
|
14
|
+
listValidation: [],
|
|
15
|
+
...overrides
|
|
16
|
+
});
|
|
17
|
+
const formData = (disabled)=>({
|
|
18
|
+
label: "External ID",
|
|
19
|
+
fieldId: "externalId",
|
|
20
|
+
list: false,
|
|
21
|
+
predefinedValuesEnabled: false,
|
|
22
|
+
disabled,
|
|
23
|
+
description: "",
|
|
24
|
+
note: "",
|
|
25
|
+
help: "",
|
|
26
|
+
tags: []
|
|
27
|
+
});
|
|
28
|
+
describe("GeneralGroup disabled flag", ()=>{
|
|
29
|
+
it("reads the flag off the field", ()=>{
|
|
30
|
+
const group = createGroup();
|
|
31
|
+
expect(group.mapToForm(createField({
|
|
32
|
+
disabled: true
|
|
33
|
+
})).disabled).toBe(true);
|
|
34
|
+
expect(group.mapToForm(createField({
|
|
35
|
+
disabled: false
|
|
36
|
+
})).disabled).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
it("defaults to false for a field that predates the flag", ()=>{
|
|
39
|
+
const group = createGroup();
|
|
40
|
+
expect(group.mapToForm(createField()).disabled).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
it("writes the flag back to the field", ()=>{
|
|
43
|
+
const group = createGroup();
|
|
44
|
+
const enabled = createField();
|
|
45
|
+
createGroup().mapFromForm(formData(true), enabled);
|
|
46
|
+
expect(enabled.disabled).toBe(true);
|
|
47
|
+
const cleared = createField({
|
|
48
|
+
disabled: true
|
|
49
|
+
});
|
|
50
|
+
group.mapFromForm(formData(false), cleared);
|
|
51
|
+
expect(cleared.disabled).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
it("round-trips without changing the value", ()=>{
|
|
54
|
+
const group = createGroup();
|
|
55
|
+
const field = createField({
|
|
56
|
+
disabled: true
|
|
57
|
+
});
|
|
58
|
+
group.mapFromForm({
|
|
59
|
+
...formData(group.mapToForm(field).disabled)
|
|
60
|
+
}, field);
|
|
61
|
+
group.mapFromForm({
|
|
62
|
+
...formData(group.mapToForm(field).disabled)
|
|
63
|
+
}, field);
|
|
64
|
+
expect(field.disabled).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=GeneralGroup.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation/fieldEditor/groups/GeneralGroup.test.js","sources":["../../../../src/presentation/fieldEditor/groups/GeneralGroup.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { GeneralGroupImpl } from \"./GeneralGroup.js\";\nimport type { CmsModelField } from \"~/types.js\";\n\nconst createGroup = () => new GeneralGroupImpl();\n\nconst createField = (overrides: Partial<CmsModelField> = {}): CmsModelField =>\n ({\n id: \"externalId\",\n fieldId: \"externalId\",\n storageId: \"text@externalId\",\n type: \"text\",\n label: \"External ID\",\n renderer: { name: \"text-input\" },\n validation: [],\n listValidation: [],\n ...overrides\n }) as CmsModelField;\n\nconst formData = (disabled: boolean) => ({\n label: \"External ID\",\n fieldId: \"externalId\",\n list: false,\n predefinedValuesEnabled: false,\n disabled,\n description: \"\",\n note: \"\",\n help: \"\",\n tags: []\n});\n\ndescribe(\"GeneralGroup disabled flag\", () => {\n it(\"reads the flag off the field\", () => {\n const group = createGroup();\n\n expect(group.mapToForm(createField({ disabled: true })).disabled).toBe(true);\n expect(group.mapToForm(createField({ disabled: false })).disabled).toBe(false);\n });\n\n it(\"defaults to false for a field that predates the flag\", () => {\n const group = createGroup();\n\n expect(group.mapToForm(createField()).disabled).toBe(false);\n });\n\n it(\"writes the flag back to the field\", () => {\n const group = createGroup();\n\n const enabled = createField();\n createGroup().mapFromForm(formData(true), enabled);\n expect(enabled.disabled).toBe(true);\n\n const cleared = createField({ disabled: true });\n group.mapFromForm(formData(false), cleared);\n expect(cleared.disabled).toBe(false);\n });\n\n it(\"round-trips without changing the value\", () => {\n const group = createGroup();\n const field = createField({ disabled: true });\n\n group.mapFromForm({ ...formData(group.mapToForm(field).disabled) }, field);\n group.mapFromForm({ ...formData(group.mapToForm(field).disabled) }, field);\n\n expect(field.disabled).toBe(true);\n });\n});\n"],"names":["createGroup","GeneralGroupImpl","createField","overrides","formData","disabled","describe","it","group","expect","enabled","cleared","field"],"mappings":";;AAIA,MAAMA,cAAc,IAAM,IAAIC;AAE9B,MAAMC,cAAc,CAACC,YAAoC,CAAC,CAAC,GACtD;QACG,IAAI;QACJ,SAAS;QACT,WAAW;QACX,MAAM;QACN,OAAO;QACP,UAAU;YAAE,MAAM;QAAa;QAC/B,YAAY,EAAE;QACd,gBAAgB,EAAE;QAClB,GAAGA,SAAS;IAChB;AAEJ,MAAMC,WAAW,CAACC,WAAuB;QACrC,OAAO;QACP,SAAS;QACT,MAAM;QACN,yBAAyB;QACzBA;QACA,aAAa;QACb,MAAM;QACN,MAAM;QACN,MAAM,EAAE;IACZ;AAEAC,SAAS,8BAA8B;IACnCC,GAAG,gCAAgC;QAC/B,MAAMC,QAAQR;QAEdS,OAAOD,MAAM,SAAS,CAACN,YAAY;YAAE,UAAU;QAAK,IAAI,QAAQ,EAAE,IAAI,CAAC;QACvEO,OAAOD,MAAM,SAAS,CAACN,YAAY;YAAE,UAAU;QAAM,IAAI,QAAQ,EAAE,IAAI,CAAC;IAC5E;IAEAK,GAAG,wDAAwD;QACvD,MAAMC,QAAQR;QAEdS,OAAOD,MAAM,SAAS,CAACN,eAAe,QAAQ,EAAE,IAAI,CAAC;IACzD;IAEAK,GAAG,qCAAqC;QACpC,MAAMC,QAAQR;QAEd,MAAMU,UAAUR;QAChBF,cAAc,WAAW,CAACI,SAAS,OAAOM;QAC1CD,OAAOC,QAAQ,QAAQ,EAAE,IAAI,CAAC;QAE9B,MAAMC,UAAUT,YAAY;YAAE,UAAU;QAAK;QAC7CM,MAAM,WAAW,CAACJ,SAAS,QAAQO;QACnCF,OAAOE,QAAQ,QAAQ,EAAE,IAAI,CAAC;IAClC;IAEAJ,GAAG,0CAA0C;QACzC,MAAMC,QAAQR;QACd,MAAMY,QAAQV,YAAY;YAAE,UAAU;QAAK;QAE3CM,MAAM,WAAW,CAAC;YAAE,GAAGJ,SAASI,MAAM,SAAS,CAACI,OAAO,QAAQ,CAAC;QAAC,GAAGA;QACpEJ,MAAM,WAAW,CAAC;YAAE,GAAGJ,SAASI,MAAM,SAAS,CAACI,OAAO,QAAQ,CAAC;QAAC,GAAGA;QAEpEH,OAAOG,MAAM,QAAQ,EAAE,IAAI,CAAC;IAChC;AACJ"}
|
|
@@ -16,6 +16,8 @@ declare class ValidationsGroupImpl implements CmsFieldEditorGroup.Interface {
|
|
|
16
16
|
};
|
|
17
17
|
mapFromForm(formData: Record<string, unknown>, field: CmsModelField): void;
|
|
18
18
|
private flattenValidators;
|
|
19
|
+
private settingsToForm;
|
|
20
|
+
private settingsFromForm;
|
|
19
21
|
}
|
|
20
22
|
export declare const ValidationsGroup: typeof ValidationsGroupImpl & {
|
|
21
23
|
__abstraction: import("@webiny/di").Abstraction<import("../abstractions.js").ICmsFieldEditorGroup>;
|
|
@@ -128,14 +128,14 @@ class ValidationsGroupImpl {
|
|
|
128
128
|
validationMap[validator.name] = {
|
|
129
129
|
enabled: true,
|
|
130
130
|
message: validator.message,
|
|
131
|
-
settings: validator.settings || {}
|
|
131
|
+
settings: this.settingsToForm(validator.name, validator.settings || {}, field)
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
const listValidationMap = {};
|
|
135
135
|
for (const v of field.listValidation || [])listValidationMap[v.name] = {
|
|
136
136
|
enabled: true,
|
|
137
137
|
message: v.message,
|
|
138
|
-
settings: v.settings || {}
|
|
138
|
+
settings: this.settingsToForm(v.name, v.settings || {}, field)
|
|
139
139
|
};
|
|
140
140
|
return {
|
|
141
141
|
validation: validationMap,
|
|
@@ -143,16 +143,30 @@ class ValidationsGroupImpl {
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
mapFromForm(formData, field) {
|
|
146
|
-
field.validation = this.flattenValidators(formData.validation || {});
|
|
147
|
-
field.listValidation = this.flattenValidators(formData.listValidation || {});
|
|
146
|
+
field.validation = this.flattenValidators(formData.validation || {}, field);
|
|
147
|
+
field.listValidation = this.flattenValidators(formData.listValidation || {}, field);
|
|
148
148
|
}
|
|
149
|
-
flattenValidators(data) {
|
|
149
|
+
flattenValidators(data, field) {
|
|
150
150
|
return Object.entries(data).filter(([, v])=>v && v.enabled).map(([name, v])=>({
|
|
151
151
|
name,
|
|
152
152
|
message: v.message,
|
|
153
|
-
settings: v.settings
|
|
153
|
+
settings: this.settingsFromForm(name, v.settings, field)
|
|
154
154
|
}));
|
|
155
155
|
}
|
|
156
|
+
settingsToForm(name, settings, field) {
|
|
157
|
+
const validator = this.allValidators.find((v)=>v.name === name);
|
|
158
|
+
if (!validator?.mapSettingsToForm) return settings;
|
|
159
|
+
return validator.mapSettingsToForm(settings, {
|
|
160
|
+
field
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
settingsFromForm(name, settings, field) {
|
|
164
|
+
const validator = this.allValidators.find((v)=>v.name === name);
|
|
165
|
+
if (!settings || !validator?.mapSettingsFromForm) return settings;
|
|
166
|
+
return validator.mapSettingsFromForm(settings, {
|
|
167
|
+
field
|
|
168
|
+
});
|
|
169
|
+
}
|
|
156
170
|
}
|
|
157
171
|
const ValidationsGroup = CmsFieldEditorGroup.createImplementation({
|
|
158
172
|
implementation: ValidationsGroupImpl,
|
|
@@ -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,OAAO,EAAE;IAEb,IAAI,AAAkB,cAAlB,OAAOA,QACP,OAAOD,sBAA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pCyC,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,GAAGxC,EAAE,GAAKA,KAAKA,EAAE,OAAO,EAChC,GAAG,CAAC,CAAC,CAACyC,MAAMzC,EAAE,GAAM;gBACjByC;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"}
|
|
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: this.settingsToForm(validator.name, validator.settings || {}, field)\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: this.settingsToForm(v.name, v.settings || {}, field)\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 field\n );\n field.listValidation = this.flattenValidators(\n (formData.listValidation || {}) as Record<string, any>,\n field\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 field: CmsModelField\n ) {\n return Object.entries(data)\n .filter(([, v]) => v && v.enabled)\n .map(([name, v]) => ({\n name,\n message: v.message,\n settings: this.settingsFromForm(name, v.settings, field)\n }));\n }\n\n private settingsToForm(\n name: string,\n settings: Record<string, unknown>,\n field: CmsModelField\n ): Record<string, unknown> {\n const validator = this.allValidators.find(v => v.name === name);\n if (!validator?.mapSettingsToForm) {\n return settings;\n }\n return validator.mapSettingsToForm(settings, { field });\n }\n\n private settingsFromForm(\n name: string,\n settings: Record<string, unknown> | undefined,\n field: CmsModelField\n ): Record<string, unknown> | undefined {\n const validator = this.allValidators.find(v => v.name === name);\n if (!settings || !validator?.mapSettingsFromForm) {\n return settings;\n }\n return validator.mapSettingsFromForm(settings, { field });\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","settings","ValidationsGroup","CmsFieldEditorGroup","CmsFieldValidator"],"mappings":";;AAWA,SAASA,sBACLC,MAIe,EACfC,KAAoB;IAEpB,IAAI,CAACD,QACD,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UAAU;YAAK;SAAE;KAAC;AAC3D"}
|
|
@@ -2,7 +2,7 @@ import react from "react";
|
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import { createObjectFieldRenderer } from "@webiny/app-admin/features/formModel/createFieldRenderer.js";
|
|
4
4
|
import { LayoutNodeRenderer } from "@webiny/app-admin/features/formModel/FormView.js";
|
|
5
|
-
import { Accordion,
|
|
5
|
+
import { Accordion, SwitchPrimitive } from "@webiny/admin-ui";
|
|
6
6
|
const CmsValidatorItemRenderer = createObjectFieldRenderer(({ field })=>/*#__PURE__*/ react.createElement(ValidatorItem, {
|
|
7
7
|
field: field
|
|
8
8
|
}));
|
|
@@ -20,7 +20,7 @@ const ValidatorItem = observer(({ field })=>{
|
|
|
20
20
|
open: isEnabled,
|
|
21
21
|
title: field.label,
|
|
22
22
|
description: field.description,
|
|
23
|
-
actions: /*#__PURE__*/ react.createElement(
|
|
23
|
+
actions: /*#__PURE__*/ react.createElement(SwitchPrimitive, {
|
|
24
24
|
label: "Enabled",
|
|
25
25
|
checked: isEnabled,
|
|
26
26
|
onChange: toggleEnabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation/fieldEditor/renderers/CmsValidatorsRenderer.js","sources":["../../../../src/presentation/fieldEditor/renderers/CmsValidatorsRenderer.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { createObjectFieldRenderer } from \"@webiny/app-admin/features/formModel/createFieldRenderer.js\";\nimport { LayoutNodeRenderer } from \"@webiny/app-admin/features/formModel/FormView.js\";\nimport type { IObjectFieldVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { Accordion,
|
|
1
|
+
{"version":3,"file":"presentation/fieldEditor/renderers/CmsValidatorsRenderer.js","sources":["../../../../src/presentation/fieldEditor/renderers/CmsValidatorsRenderer.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { createObjectFieldRenderer } from \"@webiny/app-admin/features/formModel/createFieldRenderer.js\";\nimport { LayoutNodeRenderer } from \"@webiny/app-admin/features/formModel/FormView.js\";\nimport type { IObjectFieldVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\nimport { Accordion, SwitchPrimitive } from \"@webiny/admin-ui\";\n\ndeclare module \"@webiny/app-admin/features/formModel/abstractions.js\" {\n interface IFieldRendererRegistry {\n cmsValidatorItem: { fieldType: \"object\"; settings: undefined };\n }\n}\n\nexport const CmsValidatorItemRenderer = createObjectFieldRenderer(({ field }) => {\n return <ValidatorItem field={field} />;\n});\n\ninterface ValidatorItemProps {\n field: IObjectFieldVM;\n}\n\nconst ValidatorItem = observer(({ field }: ValidatorItemProps) => {\n const value = field.value as Record<string, unknown> | null;\n const isEnabled = Boolean(value && value.enabled);\n\n const toggleEnabled = (checked: boolean) => {\n field.onChange({ ...value, enabled: checked });\n };\n\n return (\n <Accordion.Item\n interactive={false}\n open={isEnabled}\n title={field.label}\n description={field.description}\n actions={\n // The primitive keeps the label inline: in an accordion header the switch is\n // an action next to the title, not a form field with a label above it.\n <SwitchPrimitive label=\"Enabled\" checked={isEnabled} onChange={toggleEnabled} />\n }\n >\n {isEnabled ? (\n <div className={\"flex flex-col gap-md p-md\"}>\n {field.layout.map((node, index) => (\n <LayoutNodeRenderer key={index} node={node} />\n ))}\n </div>\n ) : null}\n </Accordion.Item>\n );\n});\n"],"names":["CmsValidatorItemRenderer","createObjectFieldRenderer","field","ValidatorItem","observer","value","isEnabled","Boolean","toggleEnabled","checked","Accordion","SwitchPrimitive","node","index","LayoutNodeRenderer"],"mappings":";;;;;AAaO,MAAMA,2BAA2BC,0BAA0B,CAAC,EAAEC,KAAK,EAAE,GACjE,WAAP,GAAO,oBAACC,eAAaA;QAAC,OAAOD;;AAOjC,MAAMC,gBAAgBC,SAAS,CAAC,EAAEF,KAAK,EAAsB;IACzD,MAAMG,QAAQH,MAAM,KAAK;IACzB,MAAMI,YAAYC,QAAQF,SAASA,MAAM,OAAO;IAEhD,MAAMG,gBAAgB,CAACC;QACnBP,MAAM,QAAQ,CAAC;YAAE,GAAGG,KAAK;YAAE,SAASI;QAAQ;IAChD;IAEA,OAAO,WAAP,GACI,oBAACC,UAAU,IAAI;QACX,aAAa;QACb,MAAMJ;QACN,OAAOJ,MAAM,KAAK;QAClB,aAAaA,MAAM,WAAW;QAC9B,S,cAGI,oBAACS,iBAAeA;YAAC,OAAM;YAAU,SAASL;YAAW,UAAUE;;OAGlEF,YAAY,WAAZA,GACG,oBAAC;QAAI,WAAW;OACXJ,MAAM,MAAM,CAAC,GAAG,CAAC,CAACU,MAAMC,QAAAA,WAAAA,GACrB,oBAACC,oBAAkBA;YAAC,KAAKD;YAAO,MAAMD;eAG9C;AAGhB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
-
import { BooleanSwitchRenderer, CheckboxesRenderer, DateTimeInputRenderer, DateTimeInputsRenderer, DynamicZoneRenderer, HiddenRenderer, LexicalTextInputRenderer, LexicalTextInputsRenderer, LongTextRenderer, LongTextsRenderer, NumberInputRenderer, NumberInputsRenderer, ObjectAccordionMultipleRenderer, ObjectAccordionRenderer, ObjectsAccordionRenderer, PassthroughRenderer, RadioButtonsRenderer, RefDetailedMultipleRenderer, RefDetailedSingleRenderer, RefInputRenderer, RefInputsRenderer, RefSimpleMultipleRenderer, RefSimpleSingleRenderer, SelectBoxRenderer, TagsRenderer, TextInputRenderer, TextInputsRenderer } from "../fieldTypes/renderers/index.js";
|
|
2
|
+
import { BirthdayInputRenderer, BooleanSwitchRenderer, CheckboxesRenderer, DateTimeInputRenderer, DateTimeInputsRenderer, DynamicZoneRenderer, HiddenRenderer, LexicalTextInputRenderer, LexicalTextInputsRenderer, LongTextRenderer, LongTextsRenderer, NumberInputRenderer, NumberInputsRenderer, ObjectAccordionMultipleRenderer, ObjectAccordionRenderer, ObjectsAccordionRenderer, PassthroughRenderer, RadioButtonsRenderer, RefDetailedMultipleRenderer, RefDetailedSingleRenderer, RefInputRenderer, RefInputsRenderer, RefSimpleMultipleRenderer, RefSimpleSingleRenderer, SelectBoxRenderer, TagsRenderer, TextInputRenderer, TextInputsRenderer } from "../fieldTypes/renderers/index.js";
|
|
3
3
|
const CmsFieldRendererFeature = createFeature({
|
|
4
4
|
name: "CmsFieldRenderers",
|
|
5
5
|
register (container) {
|
|
@@ -13,6 +13,7 @@ const CmsFieldRendererFeature = createFeature({
|
|
|
13
13
|
container.register(BooleanSwitchRenderer);
|
|
14
14
|
container.register(DateTimeInputRenderer);
|
|
15
15
|
container.register(DateTimeInputsRenderer);
|
|
16
|
+
container.register(BirthdayInputRenderer);
|
|
16
17
|
container.register(SelectBoxRenderer);
|
|
17
18
|
container.register(RadioButtonsRenderer);
|
|
18
19
|
container.register(CheckboxesRenderer);
|