@strapi/content-manager 0.0.0-experimental.c592deb623aed3f74ef7fdacfad9757ed59d34f7 → 0.0.0-experimental.cb74730ce5154c26404d4dccca14976a22319002
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/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
- package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-7-qB29e7.mjs → ComponentConfigurationPage-BgCLcjXO.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-7-qB29e7.mjs.map → ComponentConfigurationPage-BgCLcjXO.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-DP7AC0UU.js → ComponentConfigurationPage-DywpTZeV.js} +5 -6
- package/dist/_chunks/{ComponentConfigurationPage-DP7AC0UU.js.map → ComponentConfigurationPage-DywpTZeV.js.map} +1 -1
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
- package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
- package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
- package/dist/_chunks/{EditConfigurationPage-CI4XoymK.mjs → EditConfigurationPage-BNjOAHNS.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-CI4XoymK.mjs.map → EditConfigurationPage-BNjOAHNS.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-DITVliEI.js → EditConfigurationPage-CxRlP5if.js} +5 -6
- package/dist/_chunks/{EditConfigurationPage-DITVliEI.js.map → EditConfigurationPage-CxRlP5if.js.map} +1 -1
- package/dist/_chunks/{EditViewPage-CUS2EAhB.js → EditViewPage-BRewdTqE.js} +45 -10
- package/dist/_chunks/EditViewPage-BRewdTqE.js.map +1 -0
- package/dist/_chunks/{EditViewPage-Dzpno8xI.mjs → EditViewPage-CD_hqc1J.mjs} +45 -9
- package/dist/_chunks/EditViewPage-CD_hqc1J.mjs.map +1 -0
- package/dist/_chunks/{Field-B_jG_EV9.mjs → Field-BPkQ-3Ku.mjs} +102 -70
- package/dist/_chunks/Field-BPkQ-3Ku.mjs.map +1 -0
- package/dist/_chunks/{Field-CtUU1Fg8.js → Field-DwvmENVf.js} +103 -72
- package/dist/_chunks/Field-DwvmENVf.js.map +1 -0
- package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
- package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
- package/dist/_chunks/{Form-DTqO0ymI.js → Form-C_Gwv8P_.js} +6 -7
- package/dist/_chunks/Form-C_Gwv8P_.js.map +1 -0
- package/dist/_chunks/{Form-BXHao2mZ.mjs → Form-Czi0cf_2.mjs} +4 -4
- package/dist/_chunks/Form-Czi0cf_2.mjs.map +1 -0
- package/dist/_chunks/{History-C_uSGzO5.js → History-C1TKAig-.js} +42 -100
- package/dist/_chunks/History-C1TKAig-.js.map +1 -0
- package/dist/_chunks/{History-2Ah2CQ4T.mjs → History-CIQHyi4T.mjs} +43 -100
- package/dist/_chunks/History-CIQHyi4T.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-nyuP7OSy.js → ListConfigurationPage-D-NGRLYu.js} +7 -7
- package/dist/_chunks/ListConfigurationPage-D-NGRLYu.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BjSJlaoC.mjs → ListConfigurationPage-DcZsfyEL.mjs} +7 -6
- package/dist/_chunks/ListConfigurationPage-DcZsfyEL.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-B75x3nz2.mjs → ListViewPage-C10McTK1.mjs} +62 -39
- package/dist/_chunks/ListViewPage-C10McTK1.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-DHgHD8Xg.js → ListViewPage-xv5IQoZp.js} +63 -41
- package/dist/_chunks/ListViewPage-xv5IQoZp.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-DUacQSyF.mjs → NoContentTypePage-CPc0Cd3S.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DUacQSyF.mjs.map → NoContentTypePage-CPc0Cd3S.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-CDUKdZ7d.js → NoContentTypePage-Dzw5Yj5u.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-CDUKdZ7d.js.map → NoContentTypePage-Dzw5Yj5u.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-zwIZydDI.js → NoPermissionsPage-DAe5CDCC.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-zwIZydDI.js.map → NoPermissionsPage-DAe5CDCC.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-SFllMekk.mjs → NoPermissionsPage-wfPBh2_0.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-SFllMekk.mjs.map → NoPermissionsPage-wfPBh2_0.mjs.map} +1 -1
- package/dist/_chunks/Preview-B7LyGT_b.js +290 -0
- package/dist/_chunks/Preview-B7LyGT_b.js.map +1 -0
- package/dist/_chunks/Preview-BVFFm7uB.mjs +272 -0
- package/dist/_chunks/Preview-BVFFm7uB.mjs.map +1 -0
- package/dist/_chunks/{Relations-NFLaRNPr.js → Relations-BmYR1AjY.js} +68 -39
- package/dist/_chunks/Relations-BmYR1AjY.js.map +1 -0
- package/dist/_chunks/{Relations-D2NRW8fC.mjs → Relations-JPhWxk-s.mjs} +68 -38
- package/dist/_chunks/Relations-JPhWxk-s.mjs.map +1 -0
- package/dist/_chunks/{en-BlhnxQfj.js → en-BK8Xyl5I.js} +22 -10
- package/dist/_chunks/{en-BlhnxQfj.js.map → en-BK8Xyl5I.js.map} +1 -1
- package/dist/_chunks/{en-C8YBvRrK.mjs → en-Dtk_ot79.mjs} +22 -10
- package/dist/_chunks/{en-C8YBvRrK.mjs.map → en-Dtk_ot79.mjs.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
- package/dist/_chunks/{index-ovJRE1FM.js → index-C2Q_PLWj.js} +294 -167
- package/dist/_chunks/index-C2Q_PLWj.js.map +1 -0
- package/dist/_chunks/{index-C9HxCo5R.mjs → index-DLIkNVnQ.mjs} +297 -170
- package/dist/_chunks/index-DLIkNVnQ.mjs.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-UNWstw_s.js → layout-7AsWJzZJ.js} +5 -6
- package/dist/_chunks/{layout-UNWstw_s.js.map → layout-7AsWJzZJ.js.map} +1 -1
- package/dist/_chunks/{layout-DaUjDiWQ.mjs → layout-qE8qkNH_.mjs} +4 -4
- package/dist/_chunks/{layout-DaUjDiWQ.mjs.map → layout-qE8qkNH_.mjs.map} +1 -1
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-D8iFAeRu.mjs → relations-BjHH_1Am.mjs} +6 -7
- package/dist/_chunks/relations-BjHH_1Am.mjs.map +1 -0
- package/dist/_chunks/{relations-NN3coOG5.js → relations-EifVzf_2.js} +6 -7
- package/dist/_chunks/relations-EifVzf_2.js.map +1 -0
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -1
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -1
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
- package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
- package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +4 -4
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/constants.d.ts +1 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/documents.d.ts +0 -3
- package/dist/server/index.js +426 -190
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +426 -189
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +2 -3
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/preview/constants.d.ts +2 -0
- package/dist/server/src/preview/constants.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.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 +8 -8
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -4
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +12 -12
- package/dist/_chunks/EditViewPage-CUS2EAhB.js.map +0 -1
- package/dist/_chunks/EditViewPage-Dzpno8xI.mjs.map +0 -1
- package/dist/_chunks/Field-B_jG_EV9.mjs.map +0 -1
- package/dist/_chunks/Field-CtUU1Fg8.js.map +0 -1
- package/dist/_chunks/Form-BXHao2mZ.mjs.map +0 -1
- package/dist/_chunks/Form-DTqO0ymI.js.map +0 -1
- package/dist/_chunks/History-2Ah2CQ4T.mjs.map +0 -1
- package/dist/_chunks/History-C_uSGzO5.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-BjSJlaoC.mjs.map +0 -1
- package/dist/_chunks/ListConfigurationPage-nyuP7OSy.js.map +0 -1
- package/dist/_chunks/ListViewPage-B75x3nz2.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-DHgHD8Xg.js.map +0 -1
- package/dist/_chunks/Relations-D2NRW8fC.mjs.map +0 -1
- package/dist/_chunks/Relations-NFLaRNPr.js.map +0 -1
- package/dist/_chunks/index-C9HxCo5R.mjs.map +0 -1
- package/dist/_chunks/index-ovJRE1FM.js.map +0 -1
- package/dist/_chunks/relations-D8iFAeRu.mjs.map +0 -1
- package/dist/_chunks/relations-NN3coOG5.js.map +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"EditViewPage-BRewdTqE.js","sources":["../../admin/src/hooks/useOnce.ts","../../admin/src/pages/EditView/components/FormLayout.tsx","../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport * as React from 'react';\n\nexport const useOnce = (effect: React.EffectCallback) => React.useEffect(effect, emptyDeps);\n\nconst emptyDeps: React.DependencyList = [];\n","import { Box, Flex, Grid } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useDoc } from '../../../hooks/useDocument';\nimport { EditLayout } from '../../../hooks/useDocumentLayout';\n\nimport { InputRenderer } from './InputRenderer';\n\ninterface FormLayoutProps extends Pick<EditLayout, 'layout'> {}\n\nconst FormLayout = ({ layout }: FormLayoutProps) => {\n const { formatMessage } = useIntl();\n const { model } = useDoc();\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((panel, index) => {\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.content-types.${model}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n\n return (\n <Grid.Root key={field.name} gap={4}>\n <Grid.Item col={12} s={12} xs={12} direction=\"column\" alignItems=\"stretch\">\n <InputRenderer {...fieldWithTranslatedLabel} />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n key={index}\n hasRadius\n background=\"neutral0\"\n shadow=\"tableShadow\"\n paddingLeft={6}\n paddingRight={6}\n paddingTop={6}\n paddingBottom={6}\n borderColor=\"neutral150\"\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row, gridRowIndex) => (\n <Grid.Root key={gridRowIndex} gap={4}>\n {row.map(({ size, ...field }) => {\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.content-types.${model}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n return (\n <Grid.Item\n col={size}\n key={field.name}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <InputRenderer {...fieldWithTranslatedLabel} />\n </Grid.Item>\n );\n })}\n </Grid.Root>\n ))}\n </Flex>\n </Box>\n );\n })}\n </Flex>\n );\n};\n\nexport { FormLayout, FormLayoutProps };\n","import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDoc } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\nimport { transformDocument } from './utils/data';\nimport { createDefaultForm } from './utils/forms';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n } = useDoc();\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n /**\n * Here we prepare the form for editing, we need to:\n * - remove prohibited fields from the document (passwords | ADD YOURS WHEN THERES A NEW ONE)\n * - swap out count objects on relations for empty arrays\n * - set __temp_key__ on array objects for drag & drop\n *\n * We also prepare the form for new documents, so we need to:\n * - set default values on fields\n */\n const initialValues = React.useMemo(() => {\n if ((!document && !isCreatingDocument && !isSingleType) || !schema) {\n return undefined;\n }\n\n /**\n * Check that we have an ID so we know the\n * document has been created in some way.\n */\n const form = document?.id ? document : createDefaultForm(schema, components);\n\n return transformDocument(schema, components)(form);\n }, [document, isCreatingDocument, isSingleType, schema, components]);\n\n if (hasError) {\n return <Page.Error />;\n }\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n /**\n * We look to see what the mainField is from the configuration, if it's an id\n * we don't use it because it's a uuid format and not very user friendly.\n * Instead, we display the schema name for single-type documents\n * or \"Untitled\".\n */\n let documentTitle = 'Untitled';\n if (mainField !== 'id' && document?.[mainField]) {\n documentTitle = document[mainField];\n } else if (isSingleType && schema?.info.displayName) {\n documentTitle = schema.info.displayName;\n }\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{documentTitle}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n {({ resetForm }) => (\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={documentTitle}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <Blocker\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n onProceed={resetForm}\n />\n </>\n )}\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["React","useIntl","useDoc","jsx","Flex","index","Grid","InputRenderer","Box","useLocation","useQueryParams","useNotification","useDocumentRBAC","SINGLE_TYPES","useDocumentLayout","useLazyComponents","createDefaultForm","transformDocument","Page","status","createYupSchema","jsxs","Main","Form","Fragment","Header","Tabs","getTranslation","Panels","Blocker","styled","useParams","useRBAC","PERMISSIONS","permissions","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,UAAU,CAAC,WAAiCA,iBAAM,UAAU,QAAQ,SAAS;AAE1F,MAAM,YAAkC,CAAC;ACKzC,MAAM,aAAa,CAAC,EAAE,aAA8B;AAC5C,QAAA,EAAE,cAAc,IAAIC,kBAAQ;AAC5B,QAAA,EAAE,MAAM,IAAIC,aAAO;AAEzB,SACGC,2BAAAA,IAAAC,aAAAA,MAAA,EAAK,WAAU,UAAS,YAAW,WAAU,KAAK,GAChD,UAAO,OAAA,IAAI,CAAC,OAAOC,WAAU;AAC5B,QAAI,MAAM,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,UAAU,MAAM,SAAS,aAAa,CAAC,GAAG;AACpE,YAAA,CAAC,GAAG,IAAI;AACR,YAAA,CAAC,KAAK,IAAI;AAEhB,YAAM,2BAA2B;AAAA,QAC/B,GAAG;AAAA,QACH,OAAO,cAAc;AAAA,UACnB,IAAI,iCAAiC,KAAK,IAAI,MAAM,IAAI;AAAA,UACxD,gBAAgB,MAAM;AAAA,QACvB,CAAA;AAAA,MACH;AAGE,aAAAF,2BAAA,IAACG,aAAK,KAAA,MAAL,EAA2B,KAAK,GAC/B,UAAAH,2BAAAA,IAACG,aAAAA,KAAK,MAAL,EAAU,KAAK,IAAI,GAAG,IAAI,IAAI,IAAI,WAAU,UAAS,YAAW,WAC/D,UAAAH,2BAAA,IAACI,MAAe,uBAAA,EAAA,GAAG,yBAA0B,CAAA,EAAA,CAC/C,EAHc,GAAA,MAAM,IAItB;AAAA,IAAA;AAKF,WAAAJ,2BAAA;AAAA,MAACK,aAAA;AAAA,MAAA;AAAA,QAEC,WAAS;AAAA,QACT,YAAW;AAAA,QACX,QAAO;AAAA,QACP,aAAa;AAAA,QACb,cAAc;AAAA,QACd,YAAY;AAAA,QACZ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;;;"}
|
@@ -5,16 +5,25 @@ import { Flex, Grid, Box, Main, Tabs } from "@strapi/design-system";
|
|
5
5
|
import { useIntl } from "react-intl";
|
6
6
|
import { useLocation, useParams } from "react-router-dom";
|
7
7
|
import { styled } from "styled-components";
|
8
|
-
import { c as useDoc, f as useDocumentRBAC, h as useDocumentLayout, i as createYupSchema, j as Header, g as getTranslation, P as Panels, k as PERMISSIONS, l as DocumentRBAC, S as SINGLE_TYPES } from "./index-
|
9
|
-
import { M as MemoizedInputRenderer, u as useLazyComponents, c as createDefaultForm, t as transformDocument } from "./Field-
|
8
|
+
import { c as useDoc, f as useDocumentRBAC, h as useDocumentLayout, i as createYupSchema, j as Header, g as getTranslation, P as Panels, k as PERMISSIONS, l as DocumentRBAC, S as SINGLE_TYPES } from "./index-DLIkNVnQ.mjs";
|
9
|
+
import { M as MemoizedInputRenderer, u as useLazyComponents, c as createDefaultForm, t as transformDocument } from "./Field-BPkQ-3Ku.mjs";
|
10
10
|
const useOnce = (effect) => React.useEffect(effect, emptyDeps);
|
11
11
|
const emptyDeps = [];
|
12
12
|
const FormLayout = ({ layout }) => {
|
13
|
+
const { formatMessage } = useIntl();
|
14
|
+
const { model } = useDoc();
|
13
15
|
return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index) => {
|
14
16
|
if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
|
15
17
|
const [row] = panel;
|
16
18
|
const [field] = row;
|
17
|
-
|
19
|
+
const fieldWithTranslatedLabel = {
|
20
|
+
...field,
|
21
|
+
label: formatMessage({
|
22
|
+
id: `content-manager.content-types.${model}.${field.name}`,
|
23
|
+
defaultMessage: field.label
|
24
|
+
})
|
25
|
+
};
|
26
|
+
return /* @__PURE__ */ jsx(Grid.Root, { gap: 4, children: /* @__PURE__ */ jsx(Grid.Item, { col: 12, s: 12, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel }) }) }, field.name);
|
18
27
|
}
|
19
28
|
return /* @__PURE__ */ jsx(
|
20
29
|
Box,
|
@@ -28,6 +37,13 @@ const FormLayout = ({ layout }) => {
|
|
28
37
|
paddingBottom: 6,
|
29
38
|
borderColor: "neutral150",
|
30
39
|
children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: panel.map((row, gridRowIndex) => /* @__PURE__ */ jsx(Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
40
|
+
const fieldWithTranslatedLabel = {
|
41
|
+
...field,
|
42
|
+
label: formatMessage({
|
43
|
+
id: `content-manager.content-types.${model}.${field.name}`,
|
44
|
+
defaultMessage: field.label
|
45
|
+
})
|
46
|
+
};
|
31
47
|
return /* @__PURE__ */ jsx(
|
32
48
|
Grid.Item,
|
33
49
|
{
|
@@ -36,7 +52,7 @@ const FormLayout = ({ layout }) => {
|
|
36
52
|
xs: 12,
|
37
53
|
direction: "column",
|
38
54
|
alignItems: "stretch",
|
39
|
-
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...
|
55
|
+
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
|
40
56
|
},
|
41
57
|
field.name
|
42
58
|
);
|
@@ -112,16 +128,35 @@ const EditViewPage = () => {
|
|
112
128
|
setQuery({ status: status2 }, "push", true);
|
113
129
|
}
|
114
130
|
};
|
115
|
-
|
131
|
+
let documentTitle = "Untitled";
|
132
|
+
if (mainField !== "id" && document?.[mainField]) {
|
133
|
+
documentTitle = document[mainField];
|
134
|
+
} else if (isSingleType && schema?.info.displayName) {
|
135
|
+
documentTitle = schema.info.displayName;
|
136
|
+
}
|
137
|
+
const validateSync = (values, options) => {
|
138
|
+
const yupSchema = createYupSchema(schema?.attributes, components, {
|
139
|
+
status,
|
140
|
+
...options
|
141
|
+
});
|
142
|
+
return yupSchema.validateSync(values, { abortEarly: false });
|
143
|
+
};
|
116
144
|
return /* @__PURE__ */ jsxs(Main, { paddingLeft: 10, paddingRight: 10, children: [
|
117
|
-
/* @__PURE__ */ jsx(Page.Title, { children:
|
145
|
+
/* @__PURE__ */ jsx(Page.Title, { children: documentTitle }),
|
118
146
|
/* @__PURE__ */ jsx(
|
119
147
|
Form,
|
120
148
|
{
|
121
149
|
disabled: hasDraftAndPublished && status === "published",
|
122
150
|
initialValues,
|
123
151
|
method: isCreatingDocument ? "POST" : "PUT",
|
124
|
-
|
152
|
+
validate: (values, options) => {
|
153
|
+
const yupSchema = createYupSchema(schema?.attributes, components, {
|
154
|
+
status,
|
155
|
+
...options
|
156
|
+
});
|
157
|
+
return yupSchema.validate(values, { abortEarly: false });
|
158
|
+
},
|
159
|
+
initialErrors: location?.state?.forceValidation ? validateSync(initialValues, {}) : {},
|
125
160
|
children: ({ resetForm }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
126
161
|
/* @__PURE__ */ jsx(
|
127
162
|
Header,
|
@@ -213,6 +248,7 @@ const ProtectedEditViewPage = () => {
|
|
213
248
|
};
|
214
249
|
export {
|
215
250
|
EditViewPage,
|
216
|
-
ProtectedEditViewPage
|
251
|
+
ProtectedEditViewPage,
|
252
|
+
getDocumentStatus
|
217
253
|
};
|
218
|
-
//# sourceMappingURL=EditViewPage-
|
254
|
+
//# sourceMappingURL=EditViewPage-CD_hqc1J.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"EditViewPage-CD_hqc1J.mjs","sources":["../../admin/src/hooks/useOnce.ts","../../admin/src/pages/EditView/components/FormLayout.tsx","../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport * as React from 'react';\n\nexport const useOnce = (effect: React.EffectCallback) => React.useEffect(effect, emptyDeps);\n\nconst emptyDeps: React.DependencyList = [];\n","import { Box, Flex, Grid } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useDoc } from '../../../hooks/useDocument';\nimport { EditLayout } from '../../../hooks/useDocumentLayout';\n\nimport { InputRenderer } from './InputRenderer';\n\ninterface FormLayoutProps extends Pick<EditLayout, 'layout'> {}\n\nconst FormLayout = ({ layout }: FormLayoutProps) => {\n const { formatMessage } = useIntl();\n const { model } = useDoc();\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((panel, index) => {\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.content-types.${model}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n\n return (\n <Grid.Root key={field.name} gap={4}>\n <Grid.Item col={12} s={12} xs={12} direction=\"column\" alignItems=\"stretch\">\n <InputRenderer {...fieldWithTranslatedLabel} />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n key={index}\n hasRadius\n background=\"neutral0\"\n shadow=\"tableShadow\"\n paddingLeft={6}\n paddingRight={6}\n paddingTop={6}\n paddingBottom={6}\n borderColor=\"neutral150\"\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row, gridRowIndex) => (\n <Grid.Root key={gridRowIndex} gap={4}>\n {row.map(({ size, ...field }) => {\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.content-types.${model}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n return (\n <Grid.Item\n col={size}\n key={field.name}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <InputRenderer {...fieldWithTranslatedLabel} />\n </Grid.Item>\n );\n })}\n </Grid.Root>\n ))}\n </Flex>\n </Box>\n );\n })}\n </Flex>\n );\n};\n\nexport { FormLayout, FormLayoutProps };\n","import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDoc } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\nimport { transformDocument } from './utils/data';\nimport { createDefaultForm } from './utils/forms';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n } = useDoc();\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n /**\n * Here we prepare the form for editing, we need to:\n * - remove prohibited fields from the document (passwords | ADD YOURS WHEN THERES A NEW ONE)\n * - swap out count objects on relations for empty arrays\n * - set __temp_key__ on array objects for drag & drop\n *\n * We also prepare the form for new documents, so we need to:\n * - set default values on fields\n */\n const initialValues = React.useMemo(() => {\n if ((!document && !isCreatingDocument && !isSingleType) || !schema) {\n return undefined;\n }\n\n /**\n * Check that we have an ID so we know the\n * document has been created in some way.\n */\n const form = document?.id ? document : createDefaultForm(schema, components);\n\n return transformDocument(schema, components)(form);\n }, [document, isCreatingDocument, isSingleType, schema, components]);\n\n if (hasError) {\n return <Page.Error />;\n }\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n /**\n * We look to see what the mainField is from the configuration, if it's an id\n * we don't use it because it's a uuid format and not very user friendly.\n * Instead, we display the schema name for single-type documents\n * or \"Untitled\".\n */\n let documentTitle = 'Untitled';\n if (mainField !== 'id' && document?.[mainField]) {\n documentTitle = document[mainField];\n } else if (isSingleType && schema?.info.displayName) {\n documentTitle = schema.info.displayName;\n }\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{documentTitle}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n {({ resetForm }) => (\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={documentTitle}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <Blocker\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n onProceed={resetForm}\n />\n </>\n )}\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["InputRenderer","status","permissions"],"mappings":";;;;;;;;;AAGO,MAAM,UAAU,CAAC,WAAiC,MAAM,UAAU,QAAQ,SAAS;AAE1F,MAAM,YAAkC,CAAC;ACKzC,MAAM,aAAa,CAAC,EAAE,aAA8B;AAC5C,QAAA,EAAE,cAAc,IAAI,QAAQ;AAC5B,QAAA,EAAE,MAAM,IAAI,OAAO;AAEzB,SACG,oBAAA,MAAA,EAAK,WAAU,UAAS,YAAW,WAAU,KAAK,GAChD,UAAO,OAAA,IAAI,CAAC,OAAO,UAAU;AAC5B,QAAI,MAAM,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,UAAU,MAAM,SAAS,aAAa,CAAC,GAAG;AACpE,YAAA,CAAC,GAAG,IAAI;AACR,YAAA,CAAC,KAAK,IAAI;AAEhB,YAAM,2BAA2B;AAAA,QAC/B,GAAG;AAAA,QACH,OAAO,cAAc;AAAA,UACnB,IAAI,iCAAiC,KAAK,IAAI,MAAM,IAAI;AAAA,UACxD,gBAAgB,MAAM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PI
|
|
5
5
|
import { Box, SingleSelect, SingleSelectOption, Typography, Flex, BaseLink, Button, Popover, Field, Tooltip, IconButton, useComposedRefs, Portal, FocusTrap, Divider, VisuallyHidden, Grid as Grid$1, Accordion, TextButton, TextInput, IconButtonGroup, Menu, MenuItem } from "@strapi/design-system";
|
6
6
|
import pipe$1 from "lodash/fp/pipe";
|
7
7
|
import { useIntl } from "react-intl";
|
8
|
-
import { m as DOCUMENT_META_FIELDS, g as getTranslation, c as useDoc, e as contentManagerApi, n as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, o as useDocLayout } from "./index-
|
8
|
+
import { m as DOCUMENT_META_FIELDS, g as getTranslation, c as useDoc, e as contentManagerApi, n as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, S as SINGLE_TYPES, o as useDocLayout } from "./index-DLIkNVnQ.mjs";
|
9
9
|
import { generateNKeysBetween } from "fractional-indexing";
|
10
|
-
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-
|
11
|
-
import {
|
10
|
+
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-JPhWxk-s.mjs";
|
11
|
+
import { CodeBlock as CodeBlock$1, HeadingOne, HeadingTwo, HeadingThree, HeadingFour, HeadingFive, HeadingSix, Image as Image$1, NumberList, BulletList, Paragraph, Quotes, Link as Link$1, Drag, Collapse, Bold, Italic, Underline, StrikeThrough, Code, Expand, PlusCircle, Plus, Trash, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, More } from "@strapi/icons";
|
12
12
|
import { styled, css, keyframes } from "styled-components";
|
13
13
|
import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
|
14
14
|
import { getEmptyImage } from "react-dnd-html5-backend";
|
15
|
-
import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-
|
16
|
-
import { g as getIn } from "./objects-
|
15
|
+
import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DJ6jqvZN.mjs";
|
16
|
+
import { g as getIn } from "./objects-D6yBsdmx.mjs";
|
17
17
|
import { Editor as Editor$1, Transforms, Node, Element, Range, Path, Point, createEditor } from "slate";
|
18
18
|
import { withHistory } from "slate-history";
|
19
19
|
import { useFocused, useSelected, ReactEditor, Editable, useSlate, Slate, withReact } from "slate-react";
|
@@ -508,7 +508,7 @@ const CodeEditor = (props) => {
|
|
508
508
|
const codeBlocks = {
|
509
509
|
code: {
|
510
510
|
renderElement: (props) => /* @__PURE__ */ jsx(CodeEditor, { ...props }),
|
511
|
-
icon:
|
511
|
+
icon: CodeBlock$1,
|
512
512
|
label: {
|
513
513
|
id: "components.Blocks.blocks.code",
|
514
514
|
defaultMessage: "Code block"
|
@@ -697,8 +697,7 @@ const ImageDialog = () => {
|
|
697
697
|
const [isOpen, setIsOpen] = React.useState(true);
|
698
698
|
const { editor } = useBlocksEditorContext("ImageDialog");
|
699
699
|
const components = useStrapiApp("ImageDialog", (state) => state.components);
|
700
|
-
if (!components || !isOpen)
|
701
|
-
return null;
|
700
|
+
if (!components || !isOpen) return null;
|
702
701
|
const MediaLibraryDialog = components["media-library"];
|
703
702
|
const insertImages = (images) => {
|
704
703
|
Transforms.unwrapNodes(editor, {
|
@@ -707,14 +706,12 @@ const ImageDialog = () => {
|
|
707
706
|
});
|
708
707
|
const nodeEntryBeingReplaced = Editor$1.above(editor, {
|
709
708
|
match(node) {
|
710
|
-
if (Editor$1.isEditor(node))
|
711
|
-
return false;
|
709
|
+
if (Editor$1.isEditor(node)) return false;
|
712
710
|
const isInlineNode = ["text", "link"].includes(node.type);
|
713
711
|
return !isInlineNode;
|
714
712
|
}
|
715
713
|
});
|
716
|
-
if (!nodeEntryBeingReplaced)
|
717
|
-
return;
|
714
|
+
if (!nodeEntryBeingReplaced) return;
|
718
715
|
const [, pathToInsert] = nodeEntryBeingReplaced;
|
719
716
|
Transforms.removeNodes(editor);
|
720
717
|
const nodesToInsert = images.map((image) => {
|
@@ -892,8 +889,7 @@ const LinkContent = React.forwardRef(
|
|
892
889
|
ReactEditor.focus(editor);
|
893
890
|
};
|
894
891
|
React.useEffect(() => {
|
895
|
-
if (popoverOpen)
|
896
|
-
linkInputRef.current?.focus();
|
892
|
+
if (popoverOpen) linkInputRef.current?.focus();
|
897
893
|
}, [popoverOpen]);
|
898
894
|
const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
|
899
895
|
return /* @__PURE__ */ jsxs(Popover.Root, { open: popoverOpen, children: [
|
@@ -1048,8 +1044,7 @@ const isText$1 = (node) => {
|
|
1048
1044
|
return Node.isNode(node) && !Editor$1.isEditor(node) && node.type === "text";
|
1049
1045
|
};
|
1050
1046
|
const handleBackspaceKeyOnList = (editor, event) => {
|
1051
|
-
if (!editor.selection)
|
1052
|
-
return;
|
1047
|
+
if (!editor.selection) return;
|
1053
1048
|
const [currentListItem, currentListItemPath] = Editor$1.parent(editor, editor.selection.anchor);
|
1054
1049
|
const [currentList, currentListPath] = Editor$1.parent(editor, currentListItemPath);
|
1055
1050
|
const isListEmpty = currentList.children.length === 1 && isText$1(currentListItem.children[0]) && currentListItem.children[0].text === "";
|
@@ -1158,8 +1153,7 @@ const handleEnterKeyOnList = (editor) => {
|
|
1158
1153
|
};
|
1159
1154
|
const handleConvertToList = (editor, format) => {
|
1160
1155
|
const convertedPath = baseHandleConvert(editor, { type: "list-item" });
|
1161
|
-
if (!convertedPath)
|
1162
|
-
return;
|
1156
|
+
if (!convertedPath) return;
|
1163
1157
|
Transforms.wrapNodes(editor, { type: "list", format, children: [] }, { at: convertedPath });
|
1164
1158
|
};
|
1165
1159
|
const handleTabOnList = (editor) => {
|
@@ -1171,8 +1165,7 @@ const handleTabOnList = (editor) => {
|
|
1171
1165
|
}
|
1172
1166
|
const [currentListItem, currentListItemPath] = currentListItemEntry;
|
1173
1167
|
const [currentList] = Editor$1.parent(editor, currentListItemPath);
|
1174
|
-
if (currentListItem === currentList.children[0])
|
1175
|
-
return;
|
1168
|
+
if (currentListItem === currentList.children[0]) return;
|
1176
1169
|
const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);
|
1177
1170
|
const previousNode = currentList.children[currentListItemIndex - 1];
|
1178
1171
|
if (previousNode.type === "list") {
|
@@ -1539,8 +1532,7 @@ const isListNode = (node) => {
|
|
1539
1532
|
const ListButton = ({ block, format }) => {
|
1540
1533
|
const { editor, disabled, blocks } = useBlocksEditorContext("ListButton");
|
1541
1534
|
const isListActive = () => {
|
1542
|
-
if (!editor.selection)
|
1543
|
-
return false;
|
1535
|
+
if (!editor.selection) return false;
|
1544
1536
|
const currentListEntry = Editor$1.above(editor, {
|
1545
1537
|
match: (node) => !Editor$1.isEditor(node) && node.type === "list",
|
1546
1538
|
at: editor.selection.anchor
|
@@ -1614,8 +1606,7 @@ const LinkButton = ({ disabled }) => {
|
|
1614
1606
|
const { editor } = useBlocksEditorContext("LinkButton");
|
1615
1607
|
const isLinkActive = () => {
|
1616
1608
|
const { selection } = editor;
|
1617
|
-
if (!selection)
|
1618
|
-
return false;
|
1609
|
+
if (!selection) return false;
|
1619
1610
|
const [match] = Array.from(
|
1620
1611
|
Editor$1.nodes(editor, {
|
1621
1612
|
at: Editor$1.unhangRange(editor, selection),
|
@@ -1821,8 +1812,7 @@ const DragAndDropElement = ({
|
|
1821
1812
|
displayedValue: children
|
1822
1813
|
},
|
1823
1814
|
onDropItem(currentIndex, newIndex) {
|
1824
|
-
if (newIndex)
|
1825
|
-
handleMoveBlock(newIndex, currentIndex);
|
1815
|
+
if (newIndex) handleMoveBlock(newIndex, currentIndex);
|
1826
1816
|
}
|
1827
1817
|
});
|
1828
1818
|
const composedBoxRefs = useComposedRefs(blockRef, dropRef);
|
@@ -1966,8 +1956,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
1966
1956
|
[modifiers2]
|
1967
1957
|
);
|
1968
1958
|
const handleMoveBlocks = (editor2, event) => {
|
1969
|
-
if (!editor2.selection)
|
1970
|
-
return;
|
1959
|
+
if (!editor2.selection) return;
|
1971
1960
|
const start = Range.start(editor2.selection);
|
1972
1961
|
const currentIndex = [start.path[0]];
|
1973
1962
|
let newIndexPosition = 0;
|
@@ -2104,8 +2093,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
2104
2093
|
}
|
2105
2094
|
};
|
2106
2095
|
const handleScrollSelectionIntoView = () => {
|
2107
|
-
if (!editor.selection)
|
2108
|
-
return;
|
2096
|
+
if (!editor.selection) return;
|
2109
2097
|
const domRange = ReactEditor.toDOMRange(editor, editor.selection);
|
2110
2098
|
const domRect = domRange.getBoundingClientRect();
|
2111
2099
|
const blocksInput = blocksRef.current;
|
@@ -2299,8 +2287,7 @@ const InlineCode = styled.code`
|
|
2299
2287
|
`;
|
2300
2288
|
const baseCheckIsActive = (editor, name2) => {
|
2301
2289
|
const marks = Editor$1.marks(editor);
|
2302
|
-
if (!marks)
|
2303
|
-
return false;
|
2290
|
+
if (!marks) return false;
|
2304
2291
|
return Boolean(marks[name2]);
|
2305
2292
|
};
|
2306
2293
|
const baseHandleToggle = (editor, name2) => {
|
@@ -2624,7 +2611,7 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
|
|
2624
2611
|
Box,
|
2625
2612
|
{
|
2626
2613
|
tag: "button",
|
2627
|
-
background: "neutral100",
|
2614
|
+
background: disabled ? "neutral150" : "neutral100",
|
2628
2615
|
borderColor: field.error ? "danger600" : "neutral200",
|
2629
2616
|
hasRadius: true,
|
2630
2617
|
disabled,
|
@@ -2632,32 +2619,32 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
|
|
2632
2619
|
paddingTop: 9,
|
2633
2620
|
paddingBottom: 9,
|
2634
2621
|
type: "button",
|
2622
|
+
style: { cursor: disabled ? "not-allowed" : "pointer" },
|
2635
2623
|
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2636
|
-
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2637
|
-
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2638
|
-
|
2639
|
-
|
2640
|
-
|
2624
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsx(PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
|
2625
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2626
|
+
Typography,
|
2627
|
+
{
|
2628
|
+
textColor: disabled ? "neutral600" : "primary600",
|
2629
|
+
variant: "pi",
|
2630
|
+
fontWeight: "bold",
|
2631
|
+
children: formatMessage({
|
2632
|
+
id: getTranslation("components.empty-repeatable"),
|
2633
|
+
defaultMessage: "No entry yet. Click to add one."
|
2634
|
+
})
|
2635
|
+
}
|
2636
|
+
) })
|
2641
2637
|
] })
|
2642
2638
|
}
|
2643
2639
|
) });
|
2644
2640
|
};
|
2645
|
-
const CircleIcon = styled(PlusCircle)`
|
2646
|
-
width: 2.4rem;
|
2647
|
-
height: 2.4rem;
|
2648
|
-
> circle {
|
2649
|
-
fill: ${({ theme }) => theme.colors.primary200};
|
2650
|
-
}
|
2651
|
-
> path {
|
2652
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2653
|
-
}
|
2654
|
-
`;
|
2655
2641
|
const NonRepeatableComponent = ({
|
2656
2642
|
attribute,
|
2657
2643
|
name: name2,
|
2658
2644
|
children,
|
2659
2645
|
layout
|
2660
2646
|
}) => {
|
2647
|
+
const { formatMessage } = useIntl();
|
2661
2648
|
const { value } = useField(name2);
|
2662
2649
|
const level = useComponent("NonRepeatableComponent", (state) => state.level);
|
2663
2650
|
const isNested = level > 0;
|
@@ -2674,6 +2661,10 @@ const NonRepeatableComponent = ({
|
|
2674
2661
|
children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index) => {
|
2675
2662
|
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2676
2663
|
const completeFieldName = `${name2}.${field.name}`;
|
2664
|
+
const translatedLabel = formatMessage({
|
2665
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2666
|
+
defaultMessage: field.label
|
2667
|
+
});
|
2677
2668
|
return /* @__PURE__ */ jsx(
|
2678
2669
|
Grid$1.Item,
|
2679
2670
|
{
|
@@ -2682,7 +2673,7 @@ const NonRepeatableComponent = ({
|
|
2682
2673
|
xs: 12,
|
2683
2674
|
direction: "column",
|
2684
2675
|
alignItems: "stretch",
|
2685
|
-
children: children({ ...field, name: completeFieldName })
|
2676
|
+
children: children({ ...field, label: translatedLabel, name: completeFieldName })
|
2686
2677
|
},
|
2687
2678
|
completeFieldName
|
2688
2679
|
);
|
@@ -2704,13 +2695,34 @@ const RepeatableComponent = ({
|
|
2704
2695
|
const { search: searchString } = useLocation();
|
2705
2696
|
const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
|
2706
2697
|
const { components } = useDoc();
|
2707
|
-
const {
|
2698
|
+
const {
|
2699
|
+
value = [],
|
2700
|
+
error,
|
2701
|
+
rawError
|
2702
|
+
} = useField(name2);
|
2708
2703
|
const addFieldRow = useForm("RepeatableComponent", (state) => state.addFieldRow);
|
2709
2704
|
const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
|
2710
2705
|
const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
|
2711
2706
|
const { max = Infinity } = attribute;
|
2712
2707
|
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
2713
2708
|
const [liveText, setLiveText] = React.useState("");
|
2709
|
+
React.useEffect(() => {
|
2710
|
+
const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
|
2711
|
+
const hasNestedValue = value && Array.isArray(value) && value.length > 0;
|
2712
|
+
if (hasNestedErrors && hasNestedValue) {
|
2713
|
+
const errorOpenItems = rawError.map((_, idx) => {
|
2714
|
+
return value[idx] ? value[idx].__temp_key__ : null;
|
2715
|
+
}).filter((value2) => !!value2);
|
2716
|
+
if (errorOpenItems && errorOpenItems.length > 0) {
|
2717
|
+
setCollapseToOpen((collapseToOpen2) => {
|
2718
|
+
if (!errorOpenItems.includes(collapseToOpen2)) {
|
2719
|
+
return errorOpenItems[0];
|
2720
|
+
}
|
2721
|
+
return collapseToOpen2;
|
2722
|
+
});
|
2723
|
+
}
|
2724
|
+
}
|
2725
|
+
}, [rawError, value]);
|
2714
2726
|
const componentTmpKeyWithFocussedField = React.useMemo(() => {
|
2715
2727
|
if (search.has("field")) {
|
2716
2728
|
const fieldParam = search.get("field");
|
@@ -2863,6 +2875,10 @@ const RepeatableComponent = ({
|
|
2863
2875
|
children: layout.map((row, index2) => {
|
2864
2876
|
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2865
2877
|
const completeFieldName = `${nameWithIndex}.${field.name}`;
|
2878
|
+
const translatedLabel = formatMessage({
|
2879
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2880
|
+
defaultMessage: field.label
|
2881
|
+
});
|
2866
2882
|
return /* @__PURE__ */ jsx(
|
2867
2883
|
Grid$1.Item,
|
2868
2884
|
{
|
@@ -2871,7 +2887,11 @@ const RepeatableComponent = ({
|
|
2871
2887
|
xs: 12,
|
2872
2888
|
direction: "column",
|
2873
2889
|
alignItems: "stretch",
|
2874
|
-
children: children({
|
2890
|
+
children: children({
|
2891
|
+
...field,
|
2892
|
+
label: translatedLabel,
|
2893
|
+
name: completeFieldName
|
2894
|
+
})
|
2875
2895
|
},
|
2876
2896
|
completeFieldName
|
2877
2897
|
);
|
@@ -3715,8 +3735,7 @@ const Wrapper = styled.div`
|
|
3715
3735
|
`;
|
3716
3736
|
var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/;
|
3717
3737
|
function newlineAndIndentContinueMarkdownList(cm) {
|
3718
|
-
if (cm.getOption("disableInput"))
|
3719
|
-
return CodeMirror.Pass;
|
3738
|
+
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
3720
3739
|
var ranges = cm.listSelections(), replacements = [];
|
3721
3740
|
for (var i = 0; i < ranges.length; i++) {
|
3722
3741
|
var pos = ranges[i].head;
|
@@ -3750,8 +3769,7 @@ function newlineAndIndentContinueMarkdownList(cm) {
|
|
3750
3769
|
var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
|
3751
3770
|
var bullet = numbered ? parseInt(match[3], 10) + 1 + match[4] : match[2].replace("x", " ");
|
3752
3771
|
replacements[i] = "\n" + indent + bullet + after;
|
3753
|
-
if (numbered)
|
3754
|
-
incrementRemainingMarkdownListNumbers(cm, pos);
|
3772
|
+
if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
|
3755
3773
|
}
|
3756
3774
|
}
|
3757
3775
|
cm.replaceSelections(replacements);
|
@@ -3769,10 +3787,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
|
|
3769
3787
|
var newNumber = parseInt(startItem[3], 10) + lookAhead - skipCount;
|
3770
3788
|
var nextNumber = parseInt(nextItem[3], 10), itemNumber = nextNumber;
|
3771
3789
|
if (startIndent === nextIndent && !isNaN(nextNumber)) {
|
3772
|
-
if (newNumber === nextNumber)
|
3773
|
-
|
3774
|
-
if (newNumber > nextNumber)
|
3775
|
-
itemNumber = newNumber + 1;
|
3790
|
+
if (newNumber === nextNumber) itemNumber = nextNumber + 1;
|
3791
|
+
if (newNumber > nextNumber) itemNumber = newNumber + 1;
|
3776
3792
|
cm.replaceRange(
|
3777
3793
|
nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
|
3778
3794
|
{
|
@@ -3785,10 +3801,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
|
|
3785
3801
|
}
|
3786
3802
|
);
|
3787
3803
|
} else {
|
3788
|
-
if (startIndent.length > nextIndent.length)
|
3789
|
-
|
3790
|
-
if (startIndent.length < nextIndent.length && lookAhead === 1)
|
3791
|
-
return;
|
3804
|
+
if (startIndent.length > nextIndent.length) return;
|
3805
|
+
if (startIndent.length < nextIndent.length && lookAhead === 1) return;
|
3792
3806
|
skipCount += 1;
|
3793
3807
|
}
|
3794
3808
|
}
|
@@ -4925,15 +4939,19 @@ const Wysiwyg = React.forwardRef(
|
|
4925
4939
|
);
|
4926
4940
|
const MemoizedWysiwyg = React.memo(Wysiwyg);
|
4927
4941
|
const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
4928
|
-
const { id } = useDoc();
|
4942
|
+
const { id, document: document2, collectionType } = useDoc();
|
4929
4943
|
const isFormDisabled = useForm("InputRenderer", (state) => state.disabled);
|
4930
4944
|
const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
|
4931
4945
|
const canCreateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
|
4932
4946
|
const canReadFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
|
4933
4947
|
const canUpdateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
|
4934
4948
|
const canUserAction = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
|
4935
|
-
|
4936
|
-
|
4949
|
+
let idToCheck = id;
|
4950
|
+
if (collectionType === SINGLE_TYPES) {
|
4951
|
+
idToCheck = document2?.documentId;
|
4952
|
+
}
|
4953
|
+
const editableFields = idToCheck ? canUpdateFields : canCreateFields;
|
4954
|
+
const readableFields = idToCheck ? canReadFields : canCreateFields;
|
4937
4955
|
const canUserReadField = canUserAction(props.name, readableFields, props.type);
|
4938
4956
|
const canUserEditField = canUserAction(props.name, editableFields, props.type);
|
4939
4957
|
const fields = useStrapiApp("InputRenderer", (app) => app.fields);
|
@@ -5116,6 +5134,14 @@ const DynamicComponent = ({
|
|
5116
5134
|
React.useEffect(() => {
|
5117
5135
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
5118
5136
|
}, [dragPreviewRef, index]);
|
5137
|
+
const accordionValue = React.useId();
|
5138
|
+
const { value = [], rawError } = useField(`${name2}.${index}`);
|
5139
|
+
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
5140
|
+
React.useEffect(() => {
|
5141
|
+
if (rawError && value) {
|
5142
|
+
setCollapseToOpen(accordionValue);
|
5143
|
+
}
|
5144
|
+
}, [rawError, value, accordionValue]);
|
5119
5145
|
const composedBoxRefs = useComposedRefs(boxRef, dropRef);
|
5120
5146
|
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
5121
5147
|
/* @__PURE__ */ jsx(
|
@@ -5181,10 +5207,9 @@ const DynamicComponent = ({
|
|
5181
5207
|
] })
|
5182
5208
|
] });
|
5183
5209
|
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
5184
|
-
const accordionValue = React.useId();
|
5185
5210
|
return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
5186
5211
|
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
|
5187
|
-
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
|
5212
|
+
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
|
5188
5213
|
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
5189
5214
|
/* @__PURE__ */ jsx(
|
5190
5215
|
Accordion.Trigger,
|
@@ -5205,6 +5230,13 @@ const DynamicComponent = ({
|
|
5205
5230
|
alignItems: "stretch",
|
5206
5231
|
children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
5207
5232
|
const fieldName = `${name2}.${index}.${field.name}`;
|
5233
|
+
const fieldWithTranslatedLabel = {
|
5234
|
+
...field,
|
5235
|
+
label: formatMessage({
|
5236
|
+
id: `content-manager.components.${componentUid}.${field.name}`,
|
5237
|
+
defaultMessage: field.label
|
5238
|
+
})
|
5239
|
+
};
|
5208
5240
|
return /* @__PURE__ */ jsx(
|
5209
5241
|
Grid$1.Item,
|
5210
5242
|
{
|
@@ -5213,7 +5245,7 @@ const DynamicComponent = ({
|
|
5213
5245
|
xs: 12,
|
5214
5246
|
direction: "column",
|
5215
5247
|
alignItems: "stretch",
|
5216
|
-
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...
|
5248
|
+
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
|
5217
5249
|
},
|
5218
5250
|
fieldName
|
5219
5251
|
);
|
@@ -5528,4 +5560,4 @@ export {
|
|
5528
5560
|
transformDocument as t,
|
5529
5561
|
useLazyComponents as u
|
5530
5562
|
};
|
5531
|
-
//# sourceMappingURL=Field-
|
5563
|
+
//# sourceMappingURL=Field-BPkQ-3Ku.mjs.map
|