@strapi/content-manager 0.0.0-next.df5dd4b92e1b046c04ff00d00d76c88ea51b57d4 → 0.0.0-next.e1a19b9e52cdcb526515883c8289522a64c9871a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/components/ConfigurationForm/Fields.js +4 -1
- package/dist/admin/components/ConfigurationForm/Fields.js.map +1 -1
- package/dist/admin/components/ConfigurationForm/Fields.mjs +5 -2
- package/dist/admin/components/ConfigurationForm/Fields.mjs.map +1 -1
- package/dist/admin/components/ConfigurationForm/Form.js +1 -1
- package/dist/admin/components/ConfigurationForm/Form.js.map +1 -1
- package/dist/admin/components/ConfigurationForm/Form.mjs +3 -3
- package/dist/admin/components/ConfigurationForm/Form.mjs.map +1 -1
- package/dist/admin/components/DragPreviews/CardDragPreview.js +3 -1
- package/dist/admin/components/DragPreviews/CardDragPreview.js.map +1 -1
- package/dist/admin/components/DragPreviews/CardDragPreview.mjs +3 -1
- package/dist/admin/components/DragPreviews/CardDragPreview.mjs.map +1 -1
- package/dist/admin/components/DragPreviews/ComponentDragPreview.js +3 -1
- package/dist/admin/components/DragPreviews/ComponentDragPreview.js.map +1 -1
- package/dist/admin/components/DragPreviews/ComponentDragPreview.mjs +3 -1
- package/dist/admin/components/DragPreviews/ComponentDragPreview.mjs.map +1 -1
- package/dist/admin/components/DragPreviews/RelationDragPreview.js +3 -1
- package/dist/admin/components/DragPreviews/RelationDragPreview.js.map +1 -1
- package/dist/admin/components/DragPreviews/RelationDragPreview.mjs +3 -1
- package/dist/admin/components/DragPreviews/RelationDragPreview.mjs.map +1 -1
- package/dist/admin/components/LeftMenu.js +89 -49
- package/dist/admin/components/LeftMenu.js.map +1 -1
- package/dist/admin/components/LeftMenu.mjs +91 -51
- package/dist/admin/components/LeftMenu.mjs.map +1 -1
- package/dist/admin/components/Widgets.js +269 -9
- package/dist/admin/components/Widgets.js.map +1 -1
- package/dist/admin/components/Widgets.mjs +252 -12
- package/dist/admin/components/Widgets.mjs.map +1 -1
- package/dist/admin/history/components/VersionContent.js +24 -3
- package/dist/admin/history/components/VersionContent.js.map +1 -1
- package/dist/admin/history/components/VersionContent.mjs +25 -4
- package/dist/admin/history/components/VersionContent.mjs.map +1 -1
- package/dist/admin/history/components/VersionHeader.js +1 -0
- package/dist/admin/history/components/VersionHeader.js.map +1 -1
- package/dist/admin/history/components/VersionHeader.mjs +1 -0
- package/dist/admin/history/components/VersionHeader.mjs.map +1 -1
- package/dist/admin/history/components/VersionsList.js +1 -1
- package/dist/admin/history/components/VersionsList.js.map +1 -1
- package/dist/admin/history/components/VersionsList.mjs +1 -1
- package/dist/admin/history/components/VersionsList.mjs.map +1 -1
- package/dist/admin/history/pages/History.js +7 -7
- package/dist/admin/history/pages/History.js.map +1 -1
- package/dist/admin/history/pages/History.mjs +7 -7
- package/dist/admin/history/pages/History.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentActions.js +5 -5
- package/dist/admin/hooks/useDocumentActions.js.map +1 -1
- package/dist/admin/hooks/useDocumentActions.mjs +6 -6
- package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
- package/dist/admin/index.js +47 -8
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +47 -9
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/layout.js +28 -33
- package/dist/admin/layout.js.map +1 -1
- package/dist/admin/layout.mjs +29 -15
- package/dist/admin/layout.mjs.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.js +34 -20
- package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.mjs +36 -22
- package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/Blocker.js +18 -0
- package/dist/admin/pages/EditView/components/Blocker.js.map +1 -0
- package/dist/admin/pages/EditView/components/Blocker.mjs +16 -0
- package/dist/admin/pages/EditView/components/Blocker.mjs.map +1 -0
- package/dist/admin/pages/EditView/components/DocumentActions.js +74 -63
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +76 -65
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +12 -15
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +12 -15
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +54 -14
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +55 -15
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +12 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +13 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +15 -3
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +16 -4
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js +1 -2
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs +1 -2
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +20 -6
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +22 -8
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +158 -106
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +161 -109
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.js +86 -118
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.mjs +86 -118
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.js +40 -11
- package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.mjs +41 -11
- package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/Header.js +22 -7
- package/dist/admin/pages/EditView/components/Header.js.map +1 -1
- package/dist/admin/pages/EditView/components/Header.mjs +23 -8
- package/dist/admin/pages/EditView/components/Header.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +20 -7
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +20 -7
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/pages/EditView/utils/data.js +128 -0
- package/dist/admin/pages/EditView/utils/data.js.map +1 -1
- package/dist/admin/pages/EditView/utils/data.mjs +128 -1
- package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
- package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js +1 -0
- package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js.map +1 -1
- package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs +1 -0
- package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +221 -203
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +222 -204
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js +12 -2
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs +12 -2
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/Filters.js +3 -1
- package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
- package/dist/admin/pages/ListView/components/Filters.mjs +3 -1
- package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableActions.js +13 -3
- package/dist/admin/pages/ListView/components/TableActions.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableActions.mjs +13 -3
- package/dist/admin/pages/ListView/components/TableActions.mjs.map +1 -1
- package/dist/admin/preview/components/InputPopover.js +189 -0
- package/dist/admin/preview/components/InputPopover.js.map +1 -0
- package/dist/admin/preview/components/InputPopover.mjs +167 -0
- package/dist/admin/preview/components/InputPopover.mjs.map +1 -0
- package/dist/admin/preview/components/PreviewHeader.js +0 -1
- package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
- package/dist/admin/preview/components/PreviewHeader.mjs +0 -1
- package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.js +31 -4
- package/dist/admin/preview/components/PreviewSidePanel.js.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.mjs +32 -5
- package/dist/admin/preview/components/PreviewSidePanel.mjs.map +1 -1
- package/dist/admin/preview/hooks/usePreviewInputManager.js +77 -0
- package/dist/admin/preview/hooks/usePreviewInputManager.js.map +1 -0
- package/dist/admin/preview/hooks/usePreviewInputManager.mjs +56 -0
- package/dist/admin/preview/hooks/usePreviewInputManager.mjs.map +1 -0
- package/dist/admin/preview/pages/Preview.js +178 -74
- package/dist/admin/preview/pages/Preview.js.map +1 -1
- package/dist/admin/preview/pages/Preview.mjs +180 -76
- package/dist/admin/preview/pages/Preview.mjs.map +1 -1
- package/dist/admin/preview/utils/constants.js +56 -0
- package/dist/admin/preview/utils/constants.js.map +1 -0
- package/dist/admin/preview/utils/constants.mjs +52 -0
- package/dist/admin/preview/utils/constants.mjs.map +1 -0
- package/dist/admin/preview/utils/fieldUtils.js +107 -0
- package/dist/admin/preview/utils/fieldUtils.js.map +1 -0
- package/dist/admin/preview/utils/fieldUtils.mjs +102 -0
- package/dist/admin/preview/utils/fieldUtils.mjs.map +1 -0
- package/dist/admin/preview/utils/getSendMessage.js +22 -0
- package/dist/admin/preview/utils/getSendMessage.js.map +1 -0
- package/dist/admin/preview/utils/getSendMessage.mjs +20 -0
- package/dist/admin/preview/utils/getSendMessage.mjs.map +1 -0
- package/dist/admin/preview/utils/previewScript.js +534 -0
- package/dist/admin/preview/utils/previewScript.js.map +1 -0
- package/dist/admin/preview/utils/previewScript.mjs +532 -0
- package/dist/admin/preview/utils/previewScript.mjs.map +1 -0
- package/dist/admin/services/api.js +4 -1
- package/dist/admin/services/api.js.map +1 -1
- package/dist/admin/services/api.mjs +4 -1
- package/dist/admin/services/api.mjs.map +1 -1
- package/dist/admin/services/documents.js +42 -16
- package/dist/admin/services/documents.js.map +1 -1
- package/dist/admin/services/documents.mjs +42 -16
- package/dist/admin/services/documents.mjs.map +1 -1
- package/dist/admin/src/components/LeftMenu.d.ts +3 -1
- package/dist/admin/src/components/Widgets.d.ts +2 -1
- package/dist/admin/src/exports.d.ts +1 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocumentActions.d.ts +1 -0
- package/dist/admin/src/pages/EditView/components/Blocker.d.ts +5 -0
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +0 -3
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +1 -1
- package/dist/admin/src/pages/EditView/utils/data.d.ts +19 -1
- package/dist/admin/src/preview/components/InputPopover.d.ts +6 -0
- package/dist/admin/src/preview/hooks/usePreviewInputManager.d.ts +5 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +12 -0
- package/dist/admin/src/preview/services/preview.d.ts +1 -1
- package/dist/admin/src/preview/utils/constants.d.ts +55 -0
- package/dist/admin/src/preview/utils/fieldUtils.d.ts +22 -0
- package/dist/admin/src/preview/utils/getSendMessage.d.ts +11 -0
- package/dist/admin/src/preview/utils/previewScript.d.ts +24 -0
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +23 -17
- package/dist/admin/src/services/homepage.d.ts +1 -1
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/api.d.ts +1 -1
- package/dist/admin/src/utils/validation.d.ts +1 -0
- package/dist/admin/translations/en.json.js +12 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +12 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/translations/es.json.js +6 -2
- package/dist/admin/translations/es.json.js.map +1 -1
- package/dist/admin/translations/es.json.mjs +6 -2
- package/dist/admin/translations/es.json.mjs.map +1 -1
- package/dist/admin/translations/fr.json.js +11 -2
- package/dist/admin/translations/fr.json.js.map +1 -1
- package/dist/admin/translations/fr.json.mjs +11 -2
- package/dist/admin/translations/fr.json.mjs.map +1 -1
- package/dist/admin/utils/api.js +1 -1
- package/dist/admin/utils/api.js.map +1 -1
- package/dist/admin/utils/api.mjs +1 -1
- package/dist/admin/utils/api.mjs.map +1 -1
- package/dist/admin/utils/validation.js +18 -6
- package/dist/admin/utils/validation.js.map +1 -1
- package/dist/admin/utils/validation.mjs +18 -6
- package/dist/admin/utils/validation.mjs.map +1 -1
- package/dist/server/controllers/relations.js +8 -6
- package/dist/server/controllers/relations.js.map +1 -1
- package/dist/server/controllers/relations.mjs +8 -6
- package/dist/server/controllers/relations.mjs.map +1 -1
- package/dist/server/history/services/lifecycles.js +20 -19
- package/dist/server/history/services/lifecycles.js.map +1 -1
- package/dist/server/history/services/lifecycles.mjs +20 -19
- package/dist/server/history/services/lifecycles.mjs.map +1 -1
- package/dist/server/homepage/controllers/homepage.js +5 -0
- package/dist/server/homepage/controllers/homepage.js.map +1 -1
- package/dist/server/homepage/controllers/homepage.mjs +5 -0
- package/dist/server/homepage/controllers/homepage.mjs.map +1 -1
- package/dist/server/homepage/routes/homepage.js +11 -0
- package/dist/server/homepage/routes/homepage.js.map +1 -1
- package/dist/server/homepage/routes/homepage.mjs +11 -0
- package/dist/server/homepage/routes/homepage.mjs.map +1 -1
- package/dist/server/homepage/services/homepage.js +86 -46
- package/dist/server/homepage/services/homepage.js.map +1 -1
- package/dist/server/homepage/services/homepage.mjs +86 -46
- package/dist/server/homepage/services/homepage.mjs.map +1 -1
- package/dist/server/preview/services/preview-config.js +5 -1
- package/dist/server/preview/services/preview-config.js.map +1 -1
- package/dist/server/preview/services/preview-config.mjs +5 -1
- package/dist/server/preview/services/preview-config.mjs.map +1 -1
- package/dist/server/preview/services/preview.js +4 -0
- package/dist/server/preview/services/preview.js.map +1 -1
- package/dist/server/preview/services/preview.mjs +4 -0
- package/dist/server/preview/services/preview.mjs.map +1 -1
- package/dist/server/services/document-manager.js +3 -0
- package/dist/server/services/document-manager.js.map +1 -1
- package/dist/server/services/document-manager.mjs +3 -0
- package/dist/server/services/document-manager.mjs.map +1 -1
- package/dist/server/services/document-metadata.js +1 -1
- package/dist/server/services/document-metadata.js.map +1 -1
- package/dist/server/services/document-metadata.mjs +1 -1
- package/dist/server/services/document-metadata.mjs.map +1 -1
- package/dist/server/services/utils/populate.js +11 -0
- package/dist/server/services/utils/populate.js.map +1 -1
- package/dist/server/services/utils/populate.mjs +11 -0
- package/dist/server/services/utils/populate.mjs.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/homepage/controllers/homepage.d.ts +2 -1
- package/dist/server/src/homepage/controllers/homepage.d.ts.map +1 -1
- package/dist/server/src/homepage/index.d.ts +7 -0
- package/dist/server/src/homepage/index.d.ts.map +1 -1
- package/dist/server/src/homepage/routes/homepage.d.ts.map +1 -1
- package/dist/server/src/homepage/services/homepage.d.ts +4 -1
- package/dist/server/src/homepage/services/homepage.d.ts.map +1 -1
- package/dist/server/src/homepage/services/index.d.ts +7 -0
- package/dist/server/src/homepage/services/index.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +7 -0
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/preview/services/index.d.ts +1 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -1
- package/dist/server/src/preview/services/preview-config.d.ts +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -1
- package/dist/server/src/preview/services/preview.d.ts.map +1 -1
- package/dist/server/src/preview/utils.d.ts +1 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +7 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/dist/shared/contracts/collection-types.d.ts +0 -1
- package/dist/shared/contracts/collection-types.d.ts.map +1 -1
- package/dist/shared/contracts/homepage.d.ts +13 -0
- package/dist/shared/contracts/homepage.d.ts.map +1 -1
- package/package.json +7 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.mjs","sources":["../../../../../admin/src/pages/EditView/components/Header.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n DescriptionComponentRenderer,\n useForm,\n BackButton,\n useNotification,\n useStrapiApp,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Flex,\n SingleSelect,\n SingleSelectOption,\n Typography,\n IconButton,\n Dialog,\n} from '@strapi/design-system';\nimport { ListPlus, Pencil, Trash, WarningCircle } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { useMatch, useNavigate, useParams } from 'react-router-dom';\n\nimport { RelativeTime } from '../../../components/RelativeTime';\nimport {\n CREATED_AT_ATTRIBUTE_NAME,\n CREATED_BY_ATTRIBUTE_NAME,\n PUBLISHED_AT_ATTRIBUTE_NAME,\n PUBLISHED_BY_ATTRIBUTE_NAME,\n UPDATED_AT_ATTRIBUTE_NAME,\n UPDATED_BY_ATTRIBUTE_NAME,\n} from '../../../constants/attributes';\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { useDoc } from '../../../hooks/useDocument';\nimport { useDocumentActions } from '../../../hooks/useDocumentActions';\nimport { CLONE_PATH, LIST_PATH } from '../../../router';\nimport { getDisplayName } from '../../../utils/users';\n\nimport { DocumentActionsMenu } from './DocumentActions';\nimport { DocumentStatus } from './DocumentStatus';\n\nimport type { ContentManagerPlugin, DocumentActionComponent } from '../../../content-manager';\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\ninterface HeaderProps {\n isCreating?: boolean;\n status?: 'draft' | 'published' | 'modified';\n title?: string;\n}\n\nconst Header = ({ isCreating, status, title: documentTitle = 'Untitled' }: HeaderProps) => {\n const { formatMessage } = useIntl();\n const isCloning = useMatch(CLONE_PATH) !== null;\n const params = useParams<{ collectionType: string; slug: string }>();\n\n const title = isCreating\n ? formatMessage({\n id: 'content-manager.containers.edit.title.new',\n defaultMessage: 'Create an entry',\n })\n : documentTitle;\n\n return (\n <Flex direction=\"column\" alignItems=\"flex-start\" paddingTop={6} paddingBottom={4} gap={2}>\n <BackButton\n fallback={\n params.collectionType === SINGLE_TYPES\n ? undefined\n : `../${COLLECTION_TYPES}/${params.slug}`\n }\n />\n <Flex width=\"100%\" justifyContent=\"space-between\" gap=\"80px\" alignItems=\"flex-start\">\n <Typography variant=\"alpha\" tag=\"h1\">\n {title}\n </Typography>\n <HeaderToolbar />\n </Flex>\n {status ? (\n <Box marginTop={1}>\n <DocumentStatus status={isCloning ? 'draft' : status} />\n </Box>\n ) : null}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * HeaderToolbar\n * -----------------------------------------------------------------------------------------------*/\n\ninterface DialogOptions {\n type: 'dialog';\n title: string;\n content?: React.ReactNode;\n footer?: React.ReactNode;\n}\n\ninterface HeaderActionDescription {\n disabled?: boolean;\n label: string;\n icon?: React.ReactNode;\n type?: 'icon' | 'default';\n onClick?: (event: React.SyntheticEvent) => Promise<boolean | void> | boolean | void;\n dialog?: DialogOptions;\n options?: Array<{\n disabled?: boolean;\n label: string;\n startIcon?: React.ReactNode;\n textValue?: string;\n value: string;\n }>;\n onSelect?: (value: string) => void;\n value?: string;\n customizeContent?: (value: string) => React.ReactNode;\n}\n\n/**\n * @description Contains the document actions that have `position: header`, if there are\n * none we still render the menu because we render the information about the document there.\n */\nconst HeaderToolbar = () => {\n const { formatMessage } = useIntl();\n const isCloning = useMatch(CLONE_PATH) !== null;\n const [\n {\n query: { status = 'draft' },\n },\n ] = useQueryParams<{ status: 'draft' | 'published' }>();\n const { model, id, document, meta, collectionType } = useDoc();\n const plugins = useStrapiApp('HeaderToolbar', (state) => state.plugins);\n\n return (\n <Flex gap={2}>\n <DescriptionComponentRenderer\n props={{\n activeTab: status,\n model,\n documentId: id,\n document: isCloning ? undefined : document,\n meta: isCloning ? undefined : meta,\n collectionType,\n }}\n descriptions={(\n plugins['content-manager'].apis as ContentManagerPlugin['config']['apis']\n ).getHeaderActions()}\n >\n {(actions) => {\n if (actions.length > 0) {\n return <HeaderActions actions={actions} />;\n } else {\n return null;\n }\n }}\n </DescriptionComponentRenderer>\n <DescriptionComponentRenderer\n props={{\n activeTab: status,\n model,\n documentId: id,\n document: isCloning ? undefined : document,\n meta: isCloning ? undefined : meta,\n collectionType,\n }}\n descriptions={(\n plugins['content-manager'].apis as ContentManagerPlugin['config']['apis']\n ).getDocumentActions('header')}\n >\n {(actions) => {\n const headerActions = actions.filter((action) => {\n const positions = Array.isArray(action.position) ? action.position : [action.position];\n return positions.includes('header');\n });\n\n return (\n <DocumentActionsMenu\n actions={headerActions}\n label={formatMessage({\n id: 'content-manager.containers.edit.header.more-actions',\n defaultMessage: 'More actions',\n })}\n >\n <Information activeTab={status} />\n </DocumentActionsMenu>\n );\n }}\n </DescriptionComponentRenderer>\n </Flex>\n );\n};\n\ninterface InformationProps {\n activeTab: 'draft' | 'published';\n}\n\nconst Information = ({ activeTab }: InformationProps) => {\n const { formatMessage } = useIntl();\n const { document, meta } = useDoc();\n\n if (!document || !document.id) {\n return null;\n }\n\n /**\n * Because in the backend separate entries are made for draft and published\n * documents, the creator fields are different for each of them. For example,\n * you could make your draft in January and then publish it for the first time\n * in Feb. This would make the createdAt value for the published entry in Feb\n * but really we want to show the document as a whole. The draft entry will also\n * never have the publishedAt values.\n *\n * So, we decipher which document to show the creator for based on the activeTab.\n */\n\n const createAndUpdateDocument =\n activeTab === 'draft'\n ? document\n : meta?.availableStatus.find((status) => status.publishedAt === null);\n\n const publishDocument =\n activeTab === 'published'\n ? document\n : meta?.availableStatus.find((status) => status.publishedAt !== null);\n\n const creator = createAndUpdateDocument?.[CREATED_BY_ATTRIBUTE_NAME]\n ? getDisplayName(createAndUpdateDocument[CREATED_BY_ATTRIBUTE_NAME])\n : null;\n\n const updator = createAndUpdateDocument?.[UPDATED_BY_ATTRIBUTE_NAME]\n ? getDisplayName(createAndUpdateDocument[UPDATED_BY_ATTRIBUTE_NAME])\n : null;\n\n const information: Array<{ isDisplayed?: boolean; label: string; value: React.ReactNode }> = [\n {\n isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],\n label: formatMessage({\n id: 'content-manager.containers.edit.information.last-published.label',\n defaultMessage: 'Published',\n }),\n value: formatMessage(\n {\n id: 'content-manager.containers.edit.information.last-published.value',\n defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`,\n },\n {\n time: (\n <RelativeTime timestamp={new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME])} />\n ),\n isAnonymous: !publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME],\n author: publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME]\n ? getDisplayName(publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME])\n : null,\n }\n ),\n },\n {\n isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],\n label: formatMessage({\n id: 'content-manager.containers.edit.information.last-draft.label',\n defaultMessage: 'Updated',\n }),\n value: formatMessage(\n {\n id: 'content-manager.containers.edit.information.last-draft.value',\n defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`,\n },\n {\n time: (\n <RelativeTime\n timestamp={new Date(createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME])}\n />\n ),\n isAnonymous: !updator,\n author: updator,\n }\n ),\n },\n {\n isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],\n label: formatMessage({\n id: 'content-manager.containers.edit.information.document.label',\n defaultMessage: 'Created',\n }),\n value: formatMessage(\n {\n id: 'content-manager.containers.edit.information.document.value',\n defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`,\n },\n {\n time: (\n <RelativeTime\n timestamp={new Date(createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME])}\n />\n ),\n isAnonymous: !creator,\n author: creator,\n }\n ),\n },\n ].filter((info) => info.isDisplayed);\n\n return (\n <Flex\n borderWidth=\"1px 0 0 0\"\n borderStyle=\"solid\"\n borderColor=\"neutral150\"\n direction=\"column\"\n marginTop={2}\n tag=\"dl\"\n padding={5}\n gap={3}\n alignItems=\"flex-start\"\n /**\n * The menu content has a padding of 4px, but we want our divider (the border top applied) to\n * be flush with the menu content. So we need to adjust the margin & width to account for the padding.\n */\n marginLeft=\"-0.4rem\"\n marginRight=\"-0.4rem\"\n width=\"calc(100% + 8px)\"\n >\n {information.map((info) => (\n <Flex gap={1} direction=\"column\" alignItems=\"flex-start\" key={info.label}>\n <Typography tag=\"dt\" variant=\"pi\" fontWeight=\"bold\">\n {info.label}\n </Typography>\n <Typography tag=\"dd\" variant=\"pi\" textColor=\"neutral600\">\n {info.value}\n </Typography>\n </Flex>\n ))}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * HeaderActions\n * -----------------------------------------------------------------------------------------------*/\n\ninterface HeaderActionsProps {\n actions: Array<HeaderActionDescription & { id: string }>;\n}\n\nconst HeaderActions = ({ actions }: HeaderActionsProps) => {\n const [dialogId, setDialogId] = React.useState<string | null>(null);\n\n const handleClick =\n (action: HeaderActionDescription & { id: string }) => async (e: React.MouseEvent) => {\n if (!('options' in action)) {\n const { onClick = () => false, dialog, id } = action;\n\n const muteDialog = await onClick(e);\n\n if (dialog && !muteDialog) {\n e.preventDefault();\n setDialogId(id);\n }\n }\n };\n\n const handleClose = () => {\n setDialogId(null);\n };\n\n return (\n <Flex gap={1}>\n {actions.map((action) => {\n if (action.options) {\n return (\n <SingleSelect\n key={action.id}\n size=\"S\"\n // @ts-expect-error – the DS will handle numbers, but we're not allowing the API.\n onChange={action.onSelect}\n aria-label={action.label}\n {...action}\n >\n {action.options.map(({ label, ...option }) => (\n <SingleSelectOption key={option.value} {...option}>\n {label}\n </SingleSelectOption>\n ))}\n </SingleSelect>\n );\n } else {\n if (action.type === 'icon') {\n return (\n <React.Fragment key={action.id}>\n <IconButton\n disabled={action.disabled}\n label={action.label}\n size=\"S\"\n onClick={handleClick(action)}\n >\n {action.icon}\n </IconButton>\n {action.dialog ? (\n <HeaderActionDialog\n {...action.dialog}\n isOpen={dialogId === action.id}\n onClose={handleClose}\n />\n ) : null}\n </React.Fragment>\n );\n }\n }\n })}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * HeaderActionDialog\n * -----------------------------------------------------------------------------------------------*/\ninterface HeaderActionDialogProps {\n onClose: () => void;\n onCancel?: () => Promise<void>;\n title: string;\n content?: React.ReactNode | ((props: { onClose: () => void }) => React.ReactNode);\n isOpen: boolean;\n}\n\nconst HeaderActionDialog = ({\n onClose,\n onCancel,\n title,\n content: Content,\n isOpen,\n}: HeaderActionDialogProps) => {\n const handleClose = async () => {\n if (onCancel) {\n await onCancel();\n }\n\n onClose();\n };\n\n return (\n <Dialog.Root open={isOpen} onOpenChange={handleClose}>\n <Dialog.Content>\n <Dialog.Header>{title}</Dialog.Header>\n {typeof Content === 'function' ? <Content onClose={handleClose} /> : Content}\n </Dialog.Content>\n </Dialog.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DocumentActionComponents\n * -----------------------------------------------------------------------------------------------*/\n\nconst ConfigureTheViewAction: DocumentActionComponent = ({ collectionType, model }) => {\n const navigate = useNavigate();\n const { formatMessage } = useIntl();\n\n return {\n label: formatMessage({\n id: 'app.links.configure-view',\n defaultMessage: 'Configure the view',\n }),\n icon: <ListPlus />,\n onClick: () => {\n navigate(`../${collectionType}/${model}/configurations/edit`);\n },\n position: 'header',\n };\n};\n\nConfigureTheViewAction.type = 'configure-the-view';\nConfigureTheViewAction.position = 'header';\n\nconst EditTheModelAction: DocumentActionComponent = ({ model }) => {\n const navigate = useNavigate();\n const { formatMessage } = useIntl();\n\n return {\n label: formatMessage({\n id: 'content-manager.link-to-ctb',\n defaultMessage: 'Edit the model',\n }),\n icon: <Pencil />,\n onClick: () => {\n navigate(`/plugins/content-type-builder/content-types/${model}`);\n },\n position: 'header',\n };\n};\n\nEditTheModelAction.type = 'edit-the-model';\nEditTheModelAction.position = 'header';\n\nconst DeleteAction: DocumentActionComponent = ({ documentId, model, collectionType, document }) => {\n const navigate = useNavigate();\n const { formatMessage } = useIntl();\n const listViewPathMatch = useMatch(LIST_PATH);\n const canDelete = useDocumentRBAC('DeleteAction', (state) => state.canDelete);\n const { delete: deleteAction, isLoading } = useDocumentActions();\n const { toggleNotification } = useNotification();\n const setSubmitting = useForm('DeleteAction', (state) => state.setSubmitting);\n const isLocalized = document?.locale != null;\n\n return {\n disabled: !canDelete || !document,\n label: formatMessage(\n {\n id: 'content-manager.actions.delete.label',\n defaultMessage: 'Delete entry{isLocalized, select, true { (all locales)} other {}}',\n },\n { isLocalized }\n ),\n icon: <Trash />,\n dialog: {\n type: 'dialog',\n title: formatMessage({\n id: 'app.components.ConfirmDialog.title',\n defaultMessage: 'Confirmation',\n }),\n content: (\n <Flex direction=\"column\" gap={2}>\n <WarningCircle width=\"24px\" height=\"24px\" fill=\"danger600\" />\n <Typography tag=\"p\" variant=\"omega\" textAlign=\"center\">\n {formatMessage({\n id: 'content-manager.actions.delete.dialog.body',\n defaultMessage: 'Are you sure?',\n })}\n </Typography>\n </Flex>\n ),\n loading: isLoading,\n onConfirm: async () => {\n /**\n * If we have a match, we're in the list view\n * and therefore not in a form and shouldn't be\n * trying to set the submitting value.\n */\n if (!listViewPathMatch) {\n setSubmitting(true);\n }\n try {\n if (!documentId && collectionType !== SINGLE_TYPES) {\n console.error(\n \"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue.\"\n );\n\n toggleNotification({\n message: formatMessage({\n id: 'content-manager.actions.delete.error',\n defaultMessage: 'An error occurred while trying to delete the document.',\n }),\n type: 'danger',\n });\n\n return;\n }\n\n const res = await deleteAction({\n documentId,\n model,\n collectionType,\n params: {\n locale: '*',\n },\n });\n\n if (!('error' in res)) {\n navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });\n }\n } finally {\n if (!listViewPathMatch) {\n setSubmitting(false);\n }\n }\n },\n },\n variant: 'danger',\n position: ['header', 'table-row'],\n };\n};\n\nDeleteAction.type = 'delete';\nDeleteAction.position = ['header', 'table-row'];\n\nconst DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction];\n\nexport { Header, DEFAULT_HEADER_ACTIONS };\nexport type { HeaderProps, HeaderActionDescription };\n"],"names":["Header","isCreating","status","title","documentTitle","formatMessage","useIntl","isCloning","useMatch","CLONE_PATH","params","useParams","id","defaultMessage","_jsxs","Flex","direction","alignItems","paddingTop","paddingBottom","gap","_jsx","BackButton","fallback","collectionType","SINGLE_TYPES","undefined","COLLECTION_TYPES","slug","width","justifyContent","Typography","variant","tag","HeaderToolbar","Box","marginTop","DocumentStatus","query","useQueryParams","model","document","meta","useDoc","plugins","useStrapiApp","state","DescriptionComponentRenderer","props","activeTab","documentId","descriptions","apis","getHeaderActions","actions","length","HeaderActions","getDocumentActions","headerActions","filter","action","positions","Array","isArray","position","includes","DocumentActionsMenu","label","Information","createAndUpdateDocument","availableStatus","find","publishedAt","publishDocument","creator","CREATED_BY_ATTRIBUTE_NAME","getDisplayName","updator","UPDATED_BY_ATTRIBUTE_NAME","information","isDisplayed","PUBLISHED_AT_ATTRIBUTE_NAME","value","time","RelativeTime","timestamp","Date","isAnonymous","PUBLISHED_BY_ATTRIBUTE_NAME","author","UPDATED_AT_ATTRIBUTE_NAME","CREATED_AT_ATTRIBUTE_NAME","info","borderWidth","borderStyle","borderColor","padding","marginLeft","marginRight","map","fontWeight","textColor","dialogId","setDialogId","React","useState","handleClick","e","onClick","dialog","muteDialog","preventDefault","handleClose","options","SingleSelect","size","onChange","onSelect","aria-label","option","SingleSelectOption","type","Fragment","IconButton","disabled","icon","HeaderActionDialog","isOpen","onClose","onCancel","content","Content","Dialog","Root","open","onOpenChange","ConfigureTheViewAction","navigate","useNavigate","ListPlus","EditTheModelAction","Pencil","DeleteAction","listViewPathMatch","LIST_PATH","canDelete","useDocumentRBAC","delete","deleteAction","isLoading","useDocumentActions","toggleNotification","useNotification","setSubmitting","useForm","isLocalized","locale","Trash","WarningCircle","height","fill","textAlign","loading","onConfirm","console","error","message","res","pathname","replace","DEFAULT_HEADER_ACTIONS"],"mappings":";;;;;;;;;;;;;;;;;;AAsDMA,MAAAA,MAAAA,GAAS,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAAA,EAAOC,aAAgB,GAAA,UAAU,EAAe,GAAA;IACpF,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAC1B,MAAMC,SAAAA,GAAYC,SAASC,UAAgB,CAAA,KAAA,IAAA;AAC3C,IAAA,MAAMC,MAASC,GAAAA,SAAAA,EAAAA;IAEf,MAAMR,KAAAA,GAAQF,aACVI,aAAc,CAAA;QACZO,EAAI,EAAA,2CAAA;QACJC,cAAgB,EAAA;KAElBT,CAAAA,GAAAA,aAAAA;AAEJ,IAAA,qBACEU,IAACC,CAAAA,IAAAA,EAAAA;QAAKC,SAAU,EAAA,QAAA;QAASC,UAAW,EAAA,YAAA;QAAaC,UAAY,EAAA,CAAA;QAAGC,aAAe,EAAA,CAAA;QAAGC,GAAK,EAAA,CAAA;;0BACrFC,GAACC,CAAAA,UAAAA,EAAAA;AACCC,gBAAAA,QAAAA,EACEb,MAAOc,CAAAA,cAAc,KAAKC,YAAAA,GACtBC,YACA,CAAC,GAAG,EAAEC,gBAAAA,CAAiB,CAAC,EAAEjB,MAAOkB,CAAAA,IAAI,CAAC;;0BAG9Cd,IAACC,CAAAA,IAAAA,EAAAA;gBAAKc,KAAM,EAAA,MAAA;gBAAOC,cAAe,EAAA,eAAA;gBAAgBV,GAAI,EAAA,MAAA;gBAAOH,UAAW,EAAA,YAAA;;kCACtEI,GAACU,CAAAA,UAAAA,EAAAA;wBAAWC,OAAQ,EAAA,OAAA;wBAAQC,GAAI,EAAA,IAAA;AAC7B9B,wBAAAA,QAAAA,EAAAA;;kCAEHkB,GAAC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AAA;AAAK,yBAAA,CAAA;AAC1E;iBACQ,QAAA;AACR,oBAAA,IAAI,CAAC1B,iBAAmB,EAAA;wBACtBU,aAAc,CAAA,KAAA,CAAA;AAChB;AACF;AACF;AACF,SAAA;QACAzH,OAAS,EAAA,QAAA;QACTgC,QAAU,EAAA;AAAC,YAAA,QAAA;AAAU,YAAA;AAAY;AACnC,KAAA;AACF,CAAA;AAEA8E,YAAAA,CAAarB,IAAI,GAAG,QAAA;AACpBqB,YAAAA,CAAa9E,QAAQ,GAAG;AAAC,IAAA,QAAA;AAAU,IAAA;AAAY,CAAA;AAE/C,MAAM0G,sBAAyB,GAAA;AAAC9B,IAAAA,kBAAAA;AAAoBJ,IAAAA,sBAAAA;AAAwBM,IAAAA;AAAa;;;;"}
|
|
1
|
+
{"version":3,"file":"Header.mjs","sources":["../../../../../admin/src/pages/EditView/components/Header.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n DescriptionComponentRenderer,\n useForm,\n BackButton,\n useNotification,\n useStrapiApp,\n useQueryParams,\n useIsDesktop,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Flex,\n SingleSelect,\n SingleSelectOption,\n Typography,\n IconButton,\n Dialog,\n} from '@strapi/design-system';\nimport { ListPlus, Pencil, Trash, WarningCircle } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { useMatch, useNavigate, useParams } from 'react-router-dom';\n\nimport { RelativeTime } from '../../../components/RelativeTime';\nimport {\n CREATED_AT_ATTRIBUTE_NAME,\n CREATED_BY_ATTRIBUTE_NAME,\n PUBLISHED_AT_ATTRIBUTE_NAME,\n PUBLISHED_BY_ATTRIBUTE_NAME,\n UPDATED_AT_ATTRIBUTE_NAME,\n UPDATED_BY_ATTRIBUTE_NAME,\n} from '../../../constants/attributes';\nimport { COLLECTION_TYPES, SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { useDoc } from '../../../hooks/useDocument';\nimport { useDocumentActions } from '../../../hooks/useDocumentActions';\nimport { CLONE_PATH, LIST_PATH } from '../../../router';\nimport { getDisplayName } from '../../../utils/users';\n\nimport { DocumentActionsMenu } from './DocumentActions';\nimport { DocumentStatus } from './DocumentStatus';\n\nimport type { ContentManagerPlugin, DocumentActionComponent } from '../../../content-manager';\n\n/* -------------------------------------------------------------------------------------------------\n * Header\n * -----------------------------------------------------------------------------------------------*/\n\ninterface HeaderProps {\n isCreating?: boolean;\n status?: 'draft' | 'published' | 'modified';\n title?: string;\n}\n\nconst Header = ({ isCreating, status, title: documentTitle = 'Untitled' }: HeaderProps) => {\n const { formatMessage } = useIntl();\n const isCloning = useMatch(CLONE_PATH) !== null;\n const params = useParams<{ collectionType: string; slug: string }>();\n\n const title = isCreating\n ? formatMessage({\n id: 'content-manager.containers.edit.title.new',\n defaultMessage: 'Create an entry',\n })\n : documentTitle;\n\n return (\n <Flex\n direction=\"column\"\n alignItems=\"flex-start\"\n paddingTop={{\n initial: 4,\n large: 6,\n }}\n paddingBottom={{\n initial: 0,\n large: 4,\n }}\n gap={2}\n >\n <BackButton\n fallback={\n params.collectionType === SINGLE_TYPES\n ? undefined\n : `../${COLLECTION_TYPES}/${params.slug}`\n }\n />\n <Flex\n width=\"100%\"\n justifyContent=\"space-between\"\n gap={{\n initial: 2,\n medium: '8rem',\n }}\n alignItems=\"flex-start\"\n direction={{\n initial: 'column',\n medium: 'row',\n }}\n >\n <Typography variant=\"alpha\" tag=\"h1\">\n {title}\n </Typography>\n <HeaderToolbar />\n </Flex>\n {status ? (\n <Box marginTop={1}>\n <DocumentStatus status={isCloning ? 'draft' : status} />\n </Box>\n ) : null}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * HeaderToolbar\n * -----------------------------------------------------------------------------------------------*/\n\ninterface DialogOptions {\n type: 'dialog';\n title: string;\n content?: React.ReactNode;\n footer?: React.ReactNode;\n}\n\ninterface HeaderActionDescription {\n disabled?: boolean;\n label: string;\n icon?: React.ReactNode;\n type?: 'icon' | 'default';\n onClick?: (event: React.SyntheticEvent) => Promise<boolean | void> | boolean | void;\n dialog?: DialogOptions;\n options?: Array<{\n disabled?: boolean;\n label: string;\n startIcon?: React.ReactNode;\n textValue?: string;\n value: string;\n }>;\n onSelect?: (value: string) => void;\n value?: string;\n customizeContent?: (value: string) => React.ReactNode;\n}\n\n/**\n * @description Contains the document actions that have `position: header`, if there are\n * none we still render the menu because we render the information about the document there.\n */\nconst HeaderToolbar = () => {\n const { formatMessage } = useIntl();\n const isCloning = useMatch(CLONE_PATH) !== null;\n const [\n {\n query: { status = 'draft' },\n },\n ] = useQueryParams<{ status: 'draft' | 'published' }>();\n const { model, id, document, meta, collectionType } = useDoc();\n const plugins = useStrapiApp('HeaderToolbar', (state) => state.plugins);\n\n return (\n <Flex gap={2}>\n <DescriptionComponentRenderer\n props={{\n activeTab: status,\n model,\n documentId: id,\n document: isCloning ? undefined : document,\n meta: isCloning ? undefined : meta,\n collectionType,\n }}\n descriptions={(\n plugins['content-manager'].apis as ContentManagerPlugin['config']['apis']\n ).getHeaderActions()}\n >\n {(actions) => {\n if (actions.length > 0) {\n return <HeaderActions actions={actions} />;\n } else {\n return null;\n }\n }}\n </DescriptionComponentRenderer>\n <DescriptionComponentRenderer\n props={{\n activeTab: status,\n model,\n documentId: id,\n document: isCloning ? undefined : document,\n meta: isCloning ? undefined : meta,\n collectionType,\n }}\n descriptions={(\n plugins['content-manager'].apis as ContentManagerPlugin['config']['apis']\n ).getDocumentActions('header')}\n >\n {(actions) => {\n const headerActions = actions.filter((action) => {\n const positions = Array.isArray(action.position) ? action.position : [action.position];\n return positions.includes('header');\n });\n\n return (\n <DocumentActionsMenu\n actions={headerActions}\n label={formatMessage({\n id: 'content-manager.containers.edit.header.more-actions',\n defaultMessage: 'More actions',\n })}\n >\n <Information activeTab={status} />\n </DocumentActionsMenu>\n );\n }}\n </DescriptionComponentRenderer>\n </Flex>\n );\n};\n\ninterface InformationProps {\n activeTab: 'draft' | 'published';\n}\n\nconst Information = ({ activeTab }: InformationProps) => {\n const { formatMessage } = useIntl();\n const { document, meta } = useDoc();\n\n if (!document || !document.id) {\n return null;\n }\n\n /**\n * Because in the backend separate entries are made for draft and published\n * documents, the creator fields are different for each of them. For example,\n * you could make your draft in January and then publish it for the first time\n * in Feb. This would make the createdAt value for the published entry in Feb\n * but really we want to show the document as a whole. The draft entry will also\n * never have the publishedAt values.\n *\n * So, we decipher which document to show the creator for based on the activeTab.\n */\n\n const createAndUpdateDocument =\n activeTab === 'draft'\n ? document\n : meta?.availableStatus.find((status) => status.publishedAt === null);\n\n const publishDocument =\n activeTab === 'published'\n ? document\n : meta?.availableStatus.find((status) => status.publishedAt !== null);\n\n const creator = createAndUpdateDocument?.[CREATED_BY_ATTRIBUTE_NAME]\n ? getDisplayName(createAndUpdateDocument[CREATED_BY_ATTRIBUTE_NAME])\n : null;\n\n const updator = createAndUpdateDocument?.[UPDATED_BY_ATTRIBUTE_NAME]\n ? getDisplayName(createAndUpdateDocument[UPDATED_BY_ATTRIBUTE_NAME])\n : null;\n\n const information: Array<{ isDisplayed?: boolean; label: string; value: React.ReactNode }> = [\n {\n isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],\n label: formatMessage({\n id: 'content-manager.containers.edit.information.last-published.label',\n defaultMessage: 'Published',\n }),\n value: formatMessage(\n {\n id: 'content-manager.containers.edit.information.last-published.value',\n defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`,\n },\n {\n time: (\n <RelativeTime timestamp={new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME])} />\n ),\n isAnonymous: !publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME],\n author: publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME]\n ? getDisplayName(publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME])\n : null,\n }\n ),\n },\n {\n isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],\n label: formatMessage({\n id: 'content-manager.containers.edit.information.last-draft.label',\n defaultMessage: 'Updated',\n }),\n value: formatMessage(\n {\n id: 'content-manager.containers.edit.information.last-draft.value',\n defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`,\n },\n {\n time: (\n <RelativeTime\n timestamp={new Date(createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME])}\n />\n ),\n isAnonymous: !updator,\n author: updator,\n }\n ),\n },\n {\n isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],\n label: formatMessage({\n id: 'content-manager.containers.edit.information.document.label',\n defaultMessage: 'Created',\n }),\n value: formatMessage(\n {\n id: 'content-manager.containers.edit.information.document.value',\n defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`,\n },\n {\n time: (\n <RelativeTime\n timestamp={new Date(createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME])}\n />\n ),\n isAnonymous: !creator,\n author: creator,\n }\n ),\n },\n ].filter((info) => info.isDisplayed);\n\n return (\n <Flex\n borderWidth=\"1px 0 0 0\"\n borderStyle=\"solid\"\n borderColor=\"neutral150\"\n direction=\"column\"\n marginTop={2}\n tag=\"dl\"\n padding={5}\n gap={3}\n alignItems=\"flex-start\"\n /**\n * The menu content has a padding of 4px, but we want our divider (the border top applied) to\n * be flush with the menu content. So we need to adjust the margin & width to account for the padding.\n */\n marginLeft=\"-0.4rem\"\n marginRight=\"-0.4rem\"\n width=\"calc(100% + 8px)\"\n >\n {information.map((info) => (\n <Flex gap={1} direction=\"column\" alignItems=\"flex-start\" key={info.label}>\n <Typography tag=\"dt\" variant=\"pi\" fontWeight=\"bold\">\n {info.label}\n </Typography>\n <Typography tag=\"dd\" variant=\"pi\" textColor=\"neutral600\">\n {info.value}\n </Typography>\n </Flex>\n ))}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * HeaderActions\n * -----------------------------------------------------------------------------------------------*/\n\ninterface HeaderActionsProps {\n actions: Array<HeaderActionDescription & { id: string }>;\n}\n\nconst HeaderActions = ({ actions }: HeaderActionsProps) => {\n const [dialogId, setDialogId] = React.useState<string | null>(null);\n\n const handleClick =\n (action: HeaderActionDescription & { id: string }) => async (e: React.MouseEvent) => {\n if (!('options' in action)) {\n const { onClick = () => false, dialog, id } = action;\n\n const muteDialog = await onClick(e);\n\n if (dialog && !muteDialog) {\n e.preventDefault();\n setDialogId(id);\n }\n }\n };\n\n const handleClose = () => {\n setDialogId(null);\n };\n\n return (\n <Flex gap={1}>\n {actions.map((action) => {\n if (action.options) {\n return (\n <SingleSelect\n key={action.id}\n size=\"S\"\n // @ts-expect-error – the DS will handle numbers, but we're not allowing the API.\n onChange={action.onSelect}\n aria-label={action.label}\n {...action}\n >\n {action.options.map(({ label, ...option }) => (\n <SingleSelectOption key={option.value} {...option}>\n {label}\n </SingleSelectOption>\n ))}\n </SingleSelect>\n );\n } else {\n if (action.type === 'icon') {\n return (\n <React.Fragment key={action.id}>\n <IconButton\n disabled={action.disabled}\n label={action.label}\n size=\"S\"\n onClick={handleClick(action)}\n >\n {action.icon}\n </IconButton>\n {action.dialog ? (\n <HeaderActionDialog\n {...action.dialog}\n isOpen={dialogId === action.id}\n onClose={handleClose}\n />\n ) : null}\n </React.Fragment>\n );\n }\n }\n })}\n </Flex>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * HeaderActionDialog\n * -----------------------------------------------------------------------------------------------*/\ninterface HeaderActionDialogProps {\n onClose: () => void;\n onCancel?: () => Promise<void>;\n title: string;\n content?: React.ReactNode | ((props: { onClose: () => void }) => React.ReactNode);\n isOpen: boolean;\n}\n\nconst HeaderActionDialog = ({\n onClose,\n onCancel,\n title,\n content: Content,\n isOpen,\n}: HeaderActionDialogProps) => {\n const handleClose = async () => {\n if (onCancel) {\n await onCancel();\n }\n\n onClose();\n };\n\n return (\n <Dialog.Root open={isOpen} onOpenChange={handleClose}>\n <Dialog.Content>\n <Dialog.Header>{title}</Dialog.Header>\n {typeof Content === 'function' ? <Content onClose={handleClose} /> : Content}\n </Dialog.Content>\n </Dialog.Root>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * DocumentActionComponents\n * -----------------------------------------------------------------------------------------------*/\n\nconst ConfigureTheViewAction: DocumentActionComponent = ({ collectionType, model }) => {\n const navigate = useNavigate();\n const { formatMessage } = useIntl();\n const isDesktop = useIsDesktop();\n\n return isDesktop\n ? {\n label: formatMessage({\n id: 'app.links.configure-view',\n defaultMessage: 'Configure the view',\n }),\n icon: <ListPlus />,\n onClick: () => {\n navigate(`../${collectionType}/${model}/configurations/edit`);\n },\n position: 'header',\n }\n : null;\n};\n\nConfigureTheViewAction.type = 'configure-the-view';\nConfigureTheViewAction.position = 'header';\n\nconst EditTheModelAction: DocumentActionComponent = ({ model }) => {\n const navigate = useNavigate();\n const { formatMessage } = useIntl();\n const isDesktop = useIsDesktop();\n\n return isDesktop\n ? {\n label: formatMessage({\n id: 'content-manager.link-to-ctb',\n defaultMessage: 'Edit the model',\n }),\n icon: <Pencil />,\n onClick: () => {\n navigate(`/plugins/content-type-builder/content-types/${model}`);\n },\n position: 'header',\n }\n : null;\n};\n\nEditTheModelAction.type = 'edit-the-model';\nEditTheModelAction.position = 'header';\n\nconst DeleteAction: DocumentActionComponent = ({ documentId, model, collectionType, document }) => {\n const navigate = useNavigate();\n const { formatMessage } = useIntl();\n const listViewPathMatch = useMatch(LIST_PATH);\n const canDelete = useDocumentRBAC('DeleteAction', (state) => state.canDelete);\n const { delete: deleteAction, isLoading } = useDocumentActions();\n const { toggleNotification } = useNotification();\n const setSubmitting = useForm('DeleteAction', (state) => state.setSubmitting);\n const isLocalized = document?.locale != null;\n\n return {\n disabled: !canDelete || !document,\n label: formatMessage(\n {\n id: 'content-manager.actions.delete.label',\n defaultMessage: 'Delete entry{isLocalized, select, true { (all locales)} other {}}',\n },\n { isLocalized }\n ),\n icon: <Trash />,\n dialog: {\n type: 'dialog',\n title: formatMessage({\n id: 'app.components.ConfirmDialog.title',\n defaultMessage: 'Confirmation',\n }),\n content: (\n <Flex direction=\"column\" gap={2}>\n <WarningCircle width=\"24px\" height=\"24px\" fill=\"danger600\" />\n <Typography tag=\"p\" variant=\"omega\" textAlign=\"center\">\n {formatMessage({\n id: 'content-manager.actions.delete.dialog.body',\n defaultMessage: 'Are you sure?',\n })}\n </Typography>\n </Flex>\n ),\n loading: isLoading,\n onConfirm: async () => {\n /**\n * If we have a match, we're in the list view\n * and therefore not in a form and shouldn't be\n * trying to set the submitting value.\n */\n if (!listViewPathMatch) {\n setSubmitting(true);\n }\n try {\n if (!documentId && collectionType !== SINGLE_TYPES) {\n console.error(\n \"You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue.\"\n );\n\n toggleNotification({\n message: formatMessage({\n id: 'content-manager.actions.delete.error',\n defaultMessage: 'An error occurred while trying to delete the document.',\n }),\n type: 'danger',\n });\n\n return;\n }\n\n const res = await deleteAction({\n documentId,\n model,\n collectionType,\n params: {\n locale: '*',\n },\n });\n\n if (!('error' in res)) {\n navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });\n }\n } finally {\n if (!listViewPathMatch) {\n setSubmitting(false);\n }\n }\n },\n },\n variant: 'danger',\n position: ['header', 'table-row'],\n };\n};\n\nDeleteAction.type = 'delete';\nDeleteAction.position = ['header', 'table-row'];\n\nconst DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction];\n\nexport { Header, DEFAULT_HEADER_ACTIONS };\nexport type { HeaderProps, HeaderActionDescription };\n"],"names":["Header","isCreating","status","title","documentTitle","formatMessage","useIntl","isCloning","useMatch","CLONE_PATH","params","useParams","id","defaultMessage","_jsxs","Flex","direction","alignItems","paddingTop","initial","large","paddingBottom","gap","_jsx","BackButton","fallback","collectionType","SINGLE_TYPES","undefined","COLLECTION_TYPES","slug","width","justifyContent","medium","Typography","variant","tag","HeaderToolbar","Box","marginTop","DocumentStatus","query","useQueryParams","model","document","meta","useDoc","plugins","useStrapiApp","state","DescriptionComponentRenderer","props","activeTab","documentId","descriptions","apis","getHeaderActions","actions","length","HeaderActions","getDocumentActions","headerActions","filter","action","positions","Array","isArray","position","includes","DocumentActionsMenu","label","Information","createAndUpdateDocument","availableStatus","find","publishedAt","publishDocument","creator","CREATED_BY_ATTRIBUTE_NAME","getDisplayName","updator","UPDATED_BY_ATTRIBUTE_NAME","information","isDisplayed","PUBLISHED_AT_ATTRIBUTE_NAME","value","time","RelativeTime","timestamp","Date","isAnonymous","PUBLISHED_BY_ATTRIBUTE_NAME","author","UPDATED_AT_ATTRIBUTE_NAME","CREATED_AT_ATTRIBUTE_NAME","info","borderWidth","borderStyle","borderColor","padding","marginLeft","marginRight","map","fontWeight","textColor","dialogId","setDialogId","React","useState","handleClick","e","onClick","dialog","muteDialog","preventDefault","handleClose","options","SingleSelect","size","onChange","onSelect","aria-label","option","SingleSelectOption","type","Fragment","IconButton","disabled","icon","HeaderActionDialog","isOpen","onClose","onCancel","content","Content","Dialog","Root","open","onOpenChange","ConfigureTheViewAction","navigate","useNavigate","isDesktop","useIsDesktop","ListPlus","EditTheModelAction","Pencil","DeleteAction","listViewPathMatch","LIST_PATH","canDelete","useDocumentRBAC","delete","deleteAction","isLoading","useDocumentActions","toggleNotification","useNotification","setSubmitting","useForm","isLocalized","locale","Trash","WarningCircle","height","fill","textAlign","loading","onConfirm","console","error","message","res","pathname","replace","DEFAULT_HEADER_ACTIONS"],"mappings":";;;;;;;;;;;;;;;;;;AAuDMA,MAAAA,MAAAA,GAAS,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAEC,KAAAA,EAAOC,aAAgB,GAAA,UAAU,EAAe,GAAA;IACpF,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;IAC1B,MAAMC,SAAAA,GAAYC,SAASC,UAAgB,CAAA,KAAA,IAAA;AAC3C,IAAA,MAAMC,MAASC,GAAAA,SAAAA,EAAAA;IAEf,MAAMR,KAAAA,GAAQF,aACVI,aAAc,CAAA;QACZO,EAAI,EAAA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AAA;QACTgC,QAAU,EAAA;AAAC,YAAA,QAAA;AAAU,YAAA;AAAY;AACnC,KAAA;AACF,CAAA;AAEAgF,YAAAA,CAAavB,IAAI,GAAG,QAAA;AACpBuB,YAAAA,CAAahF,QAAQ,GAAG;AAAC,IAAA,QAAA;AAAU,IAAA;AAAY,CAAA;AAE/C,MAAM4G,sBAAyB,GAAA;AAAC9B,IAAAA,kBAAAA;AAAoBN,IAAAA,sBAAAA;AAAwBQ,IAAAA;AAAa;;;;"}
|
|
@@ -9,6 +9,8 @@ var DocumentRBAC = require('../../../features/DocumentRBAC.js');
|
|
|
9
9
|
var useDocumentContext = require('../../../hooks/useDocumentContext.js');
|
|
10
10
|
var useDocumentLayout = require('../../../hooks/useDocumentLayout.js');
|
|
11
11
|
var useLazyComponents = require('../../../hooks/useLazyComponents.js');
|
|
12
|
+
var InputPopover = require('../../../preview/components/InputPopover.js');
|
|
13
|
+
var usePreviewInputManager = require('../../../preview/hooks/usePreviewInputManager.js');
|
|
12
14
|
var BlocksInput = require('./FormInputs/BlocksInput/BlocksInput.js');
|
|
13
15
|
var Input = require('./FormInputs/Component/Input.js');
|
|
14
16
|
var Field = require('./FormInputs/DynamicZone/Field.js');
|
|
@@ -43,11 +45,13 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
43
45
|
* specifically to be used in the EditView of the content-manager this understands
|
|
44
46
|
* the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific
|
|
45
47
|
* components such as Blocks / Relations.
|
|
46
|
-
*/ const InputRenderer = ({ visible, hint: providedHint, document, ...
|
|
48
|
+
*/ const InputRenderer = ({ visible, hint: providedHint, document, ...inputProps })=>{
|
|
47
49
|
const { currentDocumentMeta } = useDocumentContext.useDocumentContext('DynamicComponent');
|
|
48
50
|
const { edit: { components } } = useDocumentLayout.useDocumentLayout(currentDocumentMeta.model);
|
|
49
51
|
const collectionType = document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';
|
|
50
52
|
const isInDynamicZone = Field.useDynamicZone('isInDynamicZone', (state)=>state.isInDynamicZone);
|
|
53
|
+
const isInPreviewPopover = InputPopover.useHasInputPopoverParent();
|
|
54
|
+
const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;
|
|
51
55
|
const isFormDisabled = strapiAdmin.useForm('InputRenderer', (state)=>state.disabled);
|
|
52
56
|
const canCreateFields = DocumentRBAC.useDocumentRBAC('InputRenderer', (rbac)=>rbac.canCreateFields);
|
|
53
57
|
const canReadFields = DocumentRBAC.useDocumentRBAC('InputRenderer', (rbac)=>rbac.canReadFields);
|
|
@@ -59,6 +63,12 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
59
63
|
}
|
|
60
64
|
const editableFields = idToCheck ? canUpdateFields : canCreateFields;
|
|
61
65
|
const readableFields = idToCheck ? canReadFields : canCreateFields;
|
|
66
|
+
// Everything preview related
|
|
67
|
+
const previewProps = usePreviewInputManager.usePreviewInputManager(inputProps.name, inputProps.attribute);
|
|
68
|
+
const props = {
|
|
69
|
+
...inputProps,
|
|
70
|
+
...previewProps
|
|
71
|
+
};
|
|
62
72
|
/**
|
|
63
73
|
* Component fields are always readable and editable,
|
|
64
74
|
* however the fields within them may not be.
|
|
@@ -76,29 +86,30 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
76
86
|
}
|
|
77
87
|
/**
|
|
78
88
|
* If the user can't read the field then we don't want to ever render it.
|
|
79
|
-
*/ if (!canUserReadField && !
|
|
89
|
+
*/ if (!canUserReadField && !shouldIgnorePermissions) {
|
|
80
90
|
return /*#__PURE__*/ jsxRuntime.jsx(NotAllowed.NotAllowedInput, {
|
|
81
91
|
hint: hint,
|
|
82
92
|
...props
|
|
83
93
|
});
|
|
84
94
|
}
|
|
85
|
-
const fieldIsDisabled = !canUserEditField && !
|
|
95
|
+
const fieldIsDisabled = !canUserEditField && !shouldIgnorePermissions || props.disabled || isFormDisabled;
|
|
86
96
|
/**
|
|
87
97
|
* Because a custom field has a unique prop but the type could be confused with either
|
|
88
98
|
* the useField hook or the type of the field we need to handle it separately and first.
|
|
89
99
|
*/ if (attributeHasCustomFieldProperty(props.attribute)) {
|
|
90
100
|
const CustomInput = lazyComponentStore[props.attribute.customField];
|
|
91
101
|
if (CustomInput) {
|
|
92
|
-
// @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
|
|
93
102
|
return /*#__PURE__*/ jsxRuntime.jsx(CustomInput, {
|
|
94
103
|
...props,
|
|
95
104
|
...field,
|
|
105
|
+
// @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
|
|
96
106
|
hint: hint,
|
|
97
107
|
disabled: fieldIsDisabled
|
|
98
108
|
});
|
|
99
109
|
}
|
|
100
110
|
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.InputRenderer, {
|
|
101
111
|
...props,
|
|
112
|
+
...previewProps,
|
|
102
113
|
hint: hint,
|
|
103
114
|
// @ts-expect-error – this workaround lets us display that the custom field is missing.
|
|
104
115
|
type: props.attribute.customField,
|
|
@@ -110,9 +121,9 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
110
121
|
*/ const addedInputTypes = Object.keys(fields);
|
|
111
122
|
if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
|
|
112
123
|
const CustomInput = fields[props.type];
|
|
113
|
-
// @ts-expect-error – TODO: fix this type error in the useLibrary hook.
|
|
114
124
|
return /*#__PURE__*/ jsxRuntime.jsx(CustomInput, {
|
|
115
125
|
...props,
|
|
126
|
+
// @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
|
|
116
127
|
hint: hint,
|
|
117
128
|
disabled: fieldIsDisabled
|
|
118
129
|
});
|
|
@@ -134,8 +145,8 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
134
145
|
hint: hint,
|
|
135
146
|
layout: components[props.attribute.component].layout,
|
|
136
147
|
disabled: fieldIsDisabled,
|
|
137
|
-
children: (
|
|
138
|
-
...
|
|
148
|
+
children: (componentInputProps)=>/*#__PURE__*/ jsxRuntime.jsx(InputRenderer, {
|
|
149
|
+
...componentInputProps
|
|
139
150
|
})
|
|
140
151
|
});
|
|
141
152
|
case 'dynamiczone':
|
|
@@ -169,6 +180,7 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
169
180
|
*/ case 'enumeration':
|
|
170
181
|
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.InputRenderer, {
|
|
171
182
|
...props,
|
|
183
|
+
...previewProps,
|
|
172
184
|
hint: hint,
|
|
173
185
|
options: props.attribute.enum.map((value)=>({
|
|
174
186
|
value
|
|
@@ -182,6 +194,7 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
|
182
194
|
const { unique: _unique, mainField: _mainField, ...restProps } = props;
|
|
183
195
|
return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.InputRenderer, {
|
|
184
196
|
...restProps,
|
|
197
|
+
...previewProps,
|
|
185
198
|
hint: hint,
|
|
186
199
|
// @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!
|
|
187
200
|
type: props.customField ? 'custom-field' : props.type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputRenderer.js","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst InputRenderer = ({ visible, hint: providedHint, document, ...props }: InputRendererProps) => {\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n return <CustomInput {...props} {...field} hint={hint} disabled={fieldIsDisabled} />;\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n return <CustomInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n return (\n <ComponentInput\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <InputRenderer {...inputProps} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return <DynamicZone {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'relation':\n return <RelationsInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'richtext':\n return <Wysiwyg {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'uid':\n return <UIDInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = !['biginteger', 'integer', 'number', 'dynamiczone', 'component'].includes(\n attribute.type\n )\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\nconst MemoizedInputRenderer = React.memo(InputRenderer);\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["InputRenderer","visible","hint","providedHint","document","props","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","canUserReadField","name","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","attribute","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","inputProps","DynamicZone","RelationsInput","Wysiwyg","UIDInput","options","enum","map","value","unique","_unique","mainField","_mainField","restProps","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","MemoizedInputRenderer","React","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA;;;;;;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admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\nimport { useHasInputPopoverParent } from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst InputRenderer = ({\n visible,\n hint: providedHint,\n document,\n ...inputProps\n}: InputRendererProps) => {\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n const isInPreviewPopover = useHasInputPopoverParent();\n const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n // Everything preview related\n const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);\n const props = { ...inputProps, ...previewProps };\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !shouldIgnorePermissions) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !shouldIgnorePermissions) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n {...field}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n return (\n <ComponentInput\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(componentInputProps) => <InputRenderer {...componentInputProps} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return <DynamicZone {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'relation':\n return <RelationsInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'richtext':\n return <Wysiwyg {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'uid':\n return <UIDInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n {...previewProps}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = !['biginteger', 'integer', 'number', 'dynamiczone', 'component'].includes(\n attribute.type\n )\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\nconst MemoizedInputRenderer = React.memo(InputRenderer);\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["InputRenderer","visible","hint","providedHint","document","inputProps","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","shouldIgnorePermissions","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","previewProps","usePreviewInputManager","name","attribute","props","canUserReadField","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","componentInputProps","DynamicZone","RelationsInput","Wysiwyg","UIDInput","options","enum","map","value","unique","_unique","mainField","_mainField","restProps","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","MemoizedInputRenderer","React","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;;;;;;AAOC,IACD,MAAMA,aAAAA,GAAgB,CAAC,EACrBC,OAAO,EACPC,IAAMC,EAAAA,YAAY,EAClBC,QAAQ,EACR,GAAGC,UACgB,EAAA,GAAA;AACnB,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,qCAAmB,CAAA,kBAAA,CAAA;IACnD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,mCAAkBJ,CAAAA,mBAAAA,CAAoBK,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJR,QAASS,CAAAA,MAAM,EAAEC,IAAAA,KAAS,mBAAmB,kBAAqB,GAAA,cAAA;A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A,OAAAA;QACLW,WAAa5F,EAAAA,IAAAA;QACb6F,IAAMT,EAAAA,KAAAA;AACNU,QAAAA,OAAAA,EAASJ,eACLX,aAAc,CAAA;YACZM,EAAI,EAAA,+CAAA;YACJC,cAAgB,EAAA;SAElB,CAAA,GAAA,IAAA;AACJS,QAAAA,EAAAA,gBAAI3C,cAAC2C,CAAAA,IAAAA,EAAAA,EAAAA;AACP,KAAA,CAAA;AAEJ;AAEA,MAAMZ,YAAY,CAAC/C,SAAAA,GAAAA;IACjB,IAAI,KAAA,IAASA,SAAa,IAAA,KAAA,IAASA,SAAW,EAAA;QAC5C,OAAO;YACL6C,OAAS,EAAA,CAACe,MAAOC,CAAAA,KAAK,CAACD,MAAAA,CAAO5D,SAAUqD,CAAAA,GAAG,CAAKO,CAAAA,GAAAA,MAAAA,CAAO5D,SAAUqD,CAAAA,GAAG,CAAIzC,GAAAA,SAAAA;YACxEkC,OAAS,EAAA,CAACc,MAAOC,CAAAA,KAAK,CAACD,MAAAA,CAAO5D,SAAUuD,CAAAA,GAAG,CAAKK,CAAAA,GAAAA,MAAAA,CAAO5D,SAAUuD,CAAAA,GAAG,CAAI3C,GAAAA;AAC1E,SAAA;AACF,KAAA,MAAO,IAAI,WAAA,IAAeZ,SAAa,IAAA,WAAA,IAAeA,SAAW,EAAA;QAC/D,OAAO;AAAE6C,YAAAA,OAAAA,EAAS7C,UAAU8D,SAAS;AAAEhB,YAAAA,OAAAA,EAAS9C,UAAU+D;AAAU,SAAA;KAC/D,MAAA;QACL,OAAO;YAAElB,OAASjC,EAAAA,SAAAA;YAAWkC,OAASlC,EAAAA;AAAU,SAAA;AAClD;AACF,CAAA;AAEMoD,MAAAA,qBAAAA,iBAAwBC,gBAAMC,CAAAA,IAAI,CAACxG,aAAAA;;;;;"}
|
|
@@ -7,6 +7,8 @@ import { useDocumentRBAC } from '../../../features/DocumentRBAC.mjs';
|
|
|
7
7
|
import { useDocumentContext } from '../../../hooks/useDocumentContext.mjs';
|
|
8
8
|
import { useDocumentLayout } from '../../../hooks/useDocumentLayout.mjs';
|
|
9
9
|
import { useLazyComponents } from '../../../hooks/useLazyComponents.mjs';
|
|
10
|
+
import { useHasInputPopoverParent } from '../../../preview/components/InputPopover.mjs';
|
|
11
|
+
import { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager.mjs';
|
|
10
12
|
import { BlocksInput as MemoizedBlocksInput } from './FormInputs/BlocksInput/BlocksInput.mjs';
|
|
11
13
|
import { ComponentInput as MemoizedComponentInput } from './FormInputs/Component/Input.mjs';
|
|
12
14
|
import { useDynamicZone, DynamicZone } from './FormInputs/DynamicZone/Field.mjs';
|
|
@@ -22,11 +24,13 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
22
24
|
* specifically to be used in the EditView of the content-manager this understands
|
|
23
25
|
* the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific
|
|
24
26
|
* components such as Blocks / Relations.
|
|
25
|
-
*/ const InputRenderer = ({ visible, hint: providedHint, document, ...
|
|
27
|
+
*/ const InputRenderer = ({ visible, hint: providedHint, document, ...inputProps })=>{
|
|
26
28
|
const { currentDocumentMeta } = useDocumentContext('DynamicComponent');
|
|
27
29
|
const { edit: { components } } = useDocumentLayout(currentDocumentMeta.model);
|
|
28
30
|
const collectionType = document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';
|
|
29
31
|
const isInDynamicZone = useDynamicZone('isInDynamicZone', (state)=>state.isInDynamicZone);
|
|
32
|
+
const isInPreviewPopover = useHasInputPopoverParent();
|
|
33
|
+
const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;
|
|
30
34
|
const isFormDisabled = useForm('InputRenderer', (state)=>state.disabled);
|
|
31
35
|
const canCreateFields = useDocumentRBAC('InputRenderer', (rbac)=>rbac.canCreateFields);
|
|
32
36
|
const canReadFields = useDocumentRBAC('InputRenderer', (rbac)=>rbac.canReadFields);
|
|
@@ -38,6 +42,12 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
38
42
|
}
|
|
39
43
|
const editableFields = idToCheck ? canUpdateFields : canCreateFields;
|
|
40
44
|
const readableFields = idToCheck ? canReadFields : canCreateFields;
|
|
45
|
+
// Everything preview related
|
|
46
|
+
const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);
|
|
47
|
+
const props = {
|
|
48
|
+
...inputProps,
|
|
49
|
+
...previewProps
|
|
50
|
+
};
|
|
41
51
|
/**
|
|
42
52
|
* Component fields are always readable and editable,
|
|
43
53
|
* however the fields within them may not be.
|
|
@@ -55,29 +65,30 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
55
65
|
}
|
|
56
66
|
/**
|
|
57
67
|
* If the user can't read the field then we don't want to ever render it.
|
|
58
|
-
*/ if (!canUserReadField && !
|
|
68
|
+
*/ if (!canUserReadField && !shouldIgnorePermissions) {
|
|
59
69
|
return /*#__PURE__*/ jsx(NotAllowedInput, {
|
|
60
70
|
hint: hint,
|
|
61
71
|
...props
|
|
62
72
|
});
|
|
63
73
|
}
|
|
64
|
-
const fieldIsDisabled = !canUserEditField && !
|
|
74
|
+
const fieldIsDisabled = !canUserEditField && !shouldIgnorePermissions || props.disabled || isFormDisabled;
|
|
65
75
|
/**
|
|
66
76
|
* Because a custom field has a unique prop but the type could be confused with either
|
|
67
77
|
* the useField hook or the type of the field we need to handle it separately and first.
|
|
68
78
|
*/ if (attributeHasCustomFieldProperty(props.attribute)) {
|
|
69
79
|
const CustomInput = lazyComponentStore[props.attribute.customField];
|
|
70
80
|
if (CustomInput) {
|
|
71
|
-
// @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
|
|
72
81
|
return /*#__PURE__*/ jsx(CustomInput, {
|
|
73
82
|
...props,
|
|
74
83
|
...field,
|
|
84
|
+
// @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
|
|
75
85
|
hint: hint,
|
|
76
86
|
disabled: fieldIsDisabled
|
|
77
87
|
});
|
|
78
88
|
}
|
|
79
89
|
return /*#__PURE__*/ jsx(InputRenderer$1, {
|
|
80
90
|
...props,
|
|
91
|
+
...previewProps,
|
|
81
92
|
hint: hint,
|
|
82
93
|
// @ts-expect-error – this workaround lets us display that the custom field is missing.
|
|
83
94
|
type: props.attribute.customField,
|
|
@@ -89,9 +100,9 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
89
100
|
*/ const addedInputTypes = Object.keys(fields);
|
|
90
101
|
if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
|
|
91
102
|
const CustomInput = fields[props.type];
|
|
92
|
-
// @ts-expect-error – TODO: fix this type error in the useLibrary hook.
|
|
93
103
|
return /*#__PURE__*/ jsx(CustomInput, {
|
|
94
104
|
...props,
|
|
105
|
+
// @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
|
|
95
106
|
hint: hint,
|
|
96
107
|
disabled: fieldIsDisabled
|
|
97
108
|
});
|
|
@@ -113,8 +124,8 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
113
124
|
hint: hint,
|
|
114
125
|
layout: components[props.attribute.component].layout,
|
|
115
126
|
disabled: fieldIsDisabled,
|
|
116
|
-
children: (
|
|
117
|
-
...
|
|
127
|
+
children: (componentInputProps)=>/*#__PURE__*/ jsx(InputRenderer, {
|
|
128
|
+
...componentInputProps
|
|
118
129
|
})
|
|
119
130
|
});
|
|
120
131
|
case 'dynamiczone':
|
|
@@ -148,6 +159,7 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
148
159
|
*/ case 'enumeration':
|
|
149
160
|
return /*#__PURE__*/ jsx(InputRenderer$1, {
|
|
150
161
|
...props,
|
|
162
|
+
...previewProps,
|
|
151
163
|
hint: hint,
|
|
152
164
|
options: props.attribute.enum.map((value)=>({
|
|
153
165
|
value
|
|
@@ -161,6 +173,7 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
161
173
|
const { unique: _unique, mainField: _mainField, ...restProps } = props;
|
|
162
174
|
return /*#__PURE__*/ jsx(InputRenderer$1, {
|
|
163
175
|
...restProps,
|
|
176
|
+
...previewProps,
|
|
164
177
|
hint: hint,
|
|
165
178
|
// @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!
|
|
166
179
|
type: props.customField ? 'custom-field' : props.type,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputRenderer.mjs","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst InputRenderer = ({ visible, hint: providedHint, document, ...props }: InputRendererProps) => {\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n return <CustomInput {...props} {...field} hint={hint} disabled={fieldIsDisabled} />;\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n return <CustomInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n return (\n <ComponentInput\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <InputRenderer {...inputProps} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return <DynamicZone {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'relation':\n return <RelationsInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'richtext':\n return <Wysiwyg {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'uid':\n return <UIDInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = !['biginteger', 'integer', 'number', 'dynamiczone', 'component'].includes(\n attribute.type\n )\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\nconst MemoizedInputRenderer = React.memo(InputRenderer);\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["InputRenderer","visible","hint","providedHint","document","props","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","canUserReadField","name","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","attribute","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","inputProps","DynamicZone","RelationsInput","Wysiwyg","UIDInput","options","enum","map","value","unique","_unique","mainField","_mainField","restProps","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","MemoizedInputRenderer","React","memo"],"mappings":";;;;;;;;;;;;;;;;;AAiCA;;;;;;;AAOC,IACD,MAAMA,aAAAA,GAAgB,CAAC,EAAEC,OAAO,EAAEC,IAAMC,EAAAA,YAAY,EAAEC,QAAQ,EAAE,GAAGC,KAA2B,EAAA,GAAA;AAC5F,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,kBAAmB,CAAA,kBAAA,CAAA;IACnD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,iBAAkBJ,CAAAA,mBAAAA,CAAoBK,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJR,QAASS,CAAAA,MAAM,EAAEC,IAAAA,KAAS,mBAAmB,kBAAqB,GAAA,cAAA;AAEpE,IAAA,MAAMC,kBAA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A,SAAW,EAAA;QAC5C,OAAO;YACLmC,OAAS,EAAA,CAACe,MAAOC,CAAAA,KAAK,CAACD,MAAAA,CAAOlD,SAAU2C,CAAAA,GAAG,CAAKO,CAAAA,GAAAA,MAAAA,CAAOlD,SAAU2C,CAAAA,GAAG,CAAIzC,GAAAA,SAAAA;YACxEkC,OAAS,EAAA,CAACc,MAAOC,CAAAA,KAAK,CAACD,MAAAA,CAAOlD,SAAU6C,CAAAA,GAAG,CAAKK,CAAAA,GAAAA,MAAAA,CAAOlD,SAAU6C,CAAAA,GAAG,CAAI3C,GAAAA;AAC1E,SAAA;AACF,KAAA,MAAO,IAAI,WAAA,IAAeF,SAAa,IAAA,WAAA,IAAeA,SAAW,EAAA;QAC/D,OAAO;AAAEmC,YAAAA,OAAAA,EAASnC,UAAUoD,SAAS;AAAEhB,YAAAA,OAAAA,EAASpC,UAAUqD;AAAU,SAAA;KAC/D,MAAA;QACL,OAAO;YAAElB,OAASjC,EAAAA,SAAAA;YAAWkC,OAASlC,EAAAA;AAAU,SAAA;AAClD;AACF,CAAA;AAEMoD,MAAAA,qBAAAA,iBAAwBC,KAAMC,CAAAA,IAAI,CAAClG,aAAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"InputRenderer.mjs","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\nimport { useHasInputPopoverParent } from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst InputRenderer = ({\n visible,\n hint: providedHint,\n document,\n ...inputProps\n}: InputRendererProps) => {\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n const isInPreviewPopover = useHasInputPopoverParent();\n const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n // Everything preview related\n const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);\n const props = { ...inputProps, ...previewProps };\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !shouldIgnorePermissions) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !shouldIgnorePermissions) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n {...field}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n return (\n <ComponentInput\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(componentInputProps) => <InputRenderer {...componentInputProps} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return <DynamicZone {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'relation':\n return <RelationsInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'richtext':\n return <Wysiwyg {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'uid':\n return <UIDInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n {...previewProps}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = !['biginteger', 'integer', 'number', 'dynamiczone', 'component'].includes(\n attribute.type\n )\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\nconst MemoizedInputRenderer = React.memo(InputRenderer);\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["InputRenderer","visible","hint","providedHint","document","inputProps","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","shouldIgnorePermissions","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","previewProps","usePreviewInputManager","name","attribute","props","canUserReadField","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","componentInputProps","DynamicZone","RelationsInput","Wysiwyg","UIDInput","options","enum","map","value","unique","_unique","mainField","_mainField","restProps","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","MemoizedInputRenderer","React","memo"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA;;;;;;;AAOC,IACD,MAAMA,aAAAA,GAAgB,CAAC,EACrBC,OAAO,EACPC,IAAMC,EAAAA,YAAY,EAClBC,QAAQ,EACR,GAAGC,UACgB,EAAA,GAAA;AACnB,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,kBAAmB,CAAA,kBAAA,CAAA;IACnD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,iBAAkBJ,CAAAA,mBAAAA,CAAoBK,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJR,QAASS,CAAAA,MAAM,EAAEC,IAAAA,KAAS,mBAAmB,kBAAqB,GAAA,cAAA;AAEpE,IAAA,MAAMC,kBAAkBC,cAAe,CAAA,iBAAA,EAAmB,CAACC,KAAAA,GAAUA,MAAMF,eAAe,CAAA;AAC1F,IAAA,MAAMG,kBAAqBC,GAAAA,wBAAAA,EAAAA;AAC3B,IAAA,MAAMC,0BAA0BL,eAAmBG,IAAAA,kBAAAA;AAEnD,IAAA,MAAMG,iBAAiBC,OAAQ,CAAA,eAAA,EAAiB,CAACL,KAAAA,GAAUA,MAAMM,QAAQ,CAAA;AACzE,IAAA,MAAMC,kBAAkBC,eAAgB,CAAA,eAAA,EAAiB,CAACC,IAAAA,GAASA,KAAKF,eAAe,CAAA;AACvF,IAAA,MAAMG,gBAAgBF,eAAgB,CAAA,eAAA,EAAiB,CAACC,IAAAA,GAASA,KA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