@strapi/content-manager 5.59.0 → 5.61.0
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/constants/customOrder.js +14 -0
- package/dist/admin/constants/customOrder.js.map +1 -0
- package/dist/admin/constants/customOrder.mjs +10 -0
- package/dist/admin/constants/customOrder.mjs.map +1 -0
- package/dist/admin/history/components/VersionInputRenderer.js +2 -1
- package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs +2 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
- package/dist/admin/hooks/useDocument.js +22 -11
- package/dist/admin/hooks/useDocument.js.map +1 -1
- package/dist/admin/hooks/useDocument.mjs +22 -11
- package/dist/admin/hooks/useDocument.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentLayout.js.map +1 -1
- package/dist/admin/hooks/useDocumentLayout.mjs.map +1 -1
- package/dist/admin/hooks/useHasBeenNearViewport.js +70 -0
- package/dist/admin/hooks/useHasBeenNearViewport.js.map +1 -0
- package/dist/admin/hooks/useHasBeenNearViewport.mjs +46 -0
- package/dist/admin/hooks/useHasBeenNearViewport.mjs.map +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js +102 -32
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs +104 -35
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js +20 -17
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs +20 -17
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +15 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +17 -3
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.js +21 -0
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.mjs +22 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +2 -0
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +2 -0
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +4 -7
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +4 -7
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +46 -10
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +47 -11
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.js +201 -50
- package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormLayout.mjs +202 -52
- package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +3 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +3 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/Settings.js +31 -2
- package/dist/admin/pages/ListConfiguration/components/Settings.js.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/Settings.mjs +31 -2
- package/dist/admin/pages/ListConfiguration/components/Settings.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +196 -132
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +196 -132
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/CustomOrder.js +571 -0
- package/dist/admin/pages/ListView/components/CustomOrder.js.map +1 -0
- package/dist/admin/pages/ListView/components/CustomOrder.mjs +546 -0
- package/dist/admin/pages/ListView/components/CustomOrder.mjs.map +1 -0
- package/dist/admin/pages/ListView/components/TableActions.js +4 -1
- package/dist/admin/pages/ListView/components/TableActions.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableActions.mjs +4 -1
- package/dist/admin/pages/ListView/components/TableActions.mjs.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.js +2 -1
- package/dist/admin/preview/components/PreviewSidePanel.js.map +1 -1
- package/dist/admin/preview/components/PreviewSidePanel.mjs +2 -1
- package/dist/admin/preview/components/PreviewSidePanel.mjs.map +1 -1
- package/dist/admin/preview/utils/getPreviewUrlStatus.js +17 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.js.map +1 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.mjs +15 -0
- package/dist/admin/preview/utils/getPreviewUrlStatus.mjs.map +1 -0
- package/dist/admin/services/documents.js +22 -1
- package/dist/admin/services/documents.js.map +1 -1
- package/dist/admin/services/documents.mjs +21 -2
- package/dist/admin/services/documents.mjs.map +1 -1
- package/dist/admin/src/constants/customOrder.d.ts +8 -0
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/history/components/VersionInputRenderer.d.ts +3 -1
- package/dist/admin/src/hooks/useDocument.d.ts +4 -0
- package/dist/admin/src/hooks/useDocumentLayout.d.ts +6 -2
- package/dist/admin/src/hooks/useHasBeenNearViewport.d.ts +13 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.d.ts +13 -1
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +11 -1
- package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -0
- package/dist/admin/src/pages/ListView/components/CustomOrder.d.ts +72 -0
- package/dist/admin/src/preview/utils/getPreviewUrlStatus.d.ts +6 -0
- package/dist/admin/src/services/documents.d.ts +10 -2
- package/dist/admin/translations/en.json.js +9 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +9 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/server/audit-logs.js +36 -0
- package/dist/server/audit-logs.js.map +1 -0
- package/dist/server/audit-logs.mjs +33 -0
- package/dist/server/audit-logs.mjs.map +1 -0
- package/dist/server/bootstrap.js +8 -0
- package/dist/server/bootstrap.js.map +1 -1
- package/dist/server/bootstrap.mjs +8 -0
- package/dist/server/bootstrap.mjs.map +1 -1
- package/dist/server/controllers/collection-types.js +8 -0
- package/dist/server/controllers/collection-types.js.map +1 -1
- package/dist/server/controllers/collection-types.mjs +8 -0
- package/dist/server/controllers/collection-types.mjs.map +1 -1
- package/dist/server/controllers/content-types.js +15 -0
- package/dist/server/controllers/content-types.js.map +1 -1
- package/dist/server/controllers/content-types.mjs +16 -1
- package/dist/server/controllers/content-types.mjs.map +1 -1
- package/dist/server/controllers/index.js +3 -1
- package/dist/server/controllers/index.js.map +1 -1
- package/dist/server/controllers/index.mjs +2 -0
- package/dist/server/controllers/index.mjs.map +1 -1
- package/dist/server/controllers/relations.js +53 -17
- package/dist/server/controllers/relations.js.map +1 -1
- package/dist/server/controllers/relations.mjs +54 -18
- package/dist/server/controllers/relations.mjs.map +1 -1
- package/dist/server/controllers/single-types.js +10 -1
- package/dist/server/controllers/single-types.js.map +1 -1
- package/dist/server/controllers/single-types.mjs +10 -1
- package/dist/server/controllers/single-types.mjs.map +1 -1
- package/dist/server/controllers/validation/model-configuration.js +2 -1
- package/dist/server/controllers/validation/model-configuration.js.map +1 -1
- package/dist/server/controllers/validation/model-configuration.mjs +2 -1
- package/dist/server/controllers/validation/model-configuration.mjs.map +1 -1
- package/dist/server/custom-order/constants.js +21 -0
- package/dist/server/custom-order/constants.js.map +1 -0
- package/dist/server/custom-order/constants.mjs +17 -0
- package/dist/server/custom-order/constants.mjs.map +1 -0
- package/dist/server/custom-order/controllers/custom-order.js +77 -0
- package/dist/server/custom-order/controllers/custom-order.js.map +1 -0
- package/dist/server/custom-order/controllers/custom-order.mjs +75 -0
- package/dist/server/custom-order/controllers/custom-order.mjs.map +1 -0
- package/dist/server/custom-order/controllers/index.js +10 -0
- package/dist/server/custom-order/controllers/index.js.map +1 -0
- package/dist/server/custom-order/controllers/index.mjs +8 -0
- package/dist/server/custom-order/controllers/index.mjs.map +1 -0
- package/dist/server/custom-order/index.js +71 -0
- package/dist/server/custom-order/index.js.map +1 -0
- package/dist/server/custom-order/index.mjs +69 -0
- package/dist/server/custom-order/index.mjs.map +1 -0
- package/dist/server/custom-order/routes/custom-order.js +38 -0
- package/dist/server/custom-order/routes/custom-order.js.map +1 -0
- package/dist/server/custom-order/routes/custom-order.mjs +36 -0
- package/dist/server/custom-order/routes/custom-order.mjs.map +1 -0
- package/dist/server/custom-order/routes/index.js +13 -0
- package/dist/server/custom-order/routes/index.js.map +1 -0
- package/dist/server/custom-order/routes/index.mjs +11 -0
- package/dist/server/custom-order/routes/index.mjs.map +1 -0
- package/dist/server/custom-order/services/custom-order.js +286 -0
- package/dist/server/custom-order/services/custom-order.js.map +1 -0
- package/dist/server/custom-order/services/custom-order.mjs +284 -0
- package/dist/server/custom-order/services/custom-order.mjs.map +1 -0
- package/dist/server/custom-order/services/document-middleware.js +83 -0
- package/dist/server/custom-order/services/document-middleware.js.map +1 -0
- package/dist/server/custom-order/services/document-middleware.mjs +81 -0
- package/dist/server/custom-order/services/document-middleware.mjs.map +1 -0
- package/dist/server/custom-order/services/index.js +10 -0
- package/dist/server/custom-order/services/index.js.map +1 -0
- package/dist/server/custom-order/services/index.mjs +8 -0
- package/dist/server/custom-order/services/index.mjs.map +1 -0
- package/dist/server/custom-order/services/utils.js +152 -0
- package/dist/server/custom-order/services/utils.js.map +1 -0
- package/dist/server/custom-order/services/utils.mjs +148 -0
- package/dist/server/custom-order/services/utils.mjs.map +1 -0
- package/dist/server/custom-order/utils.js +13 -0
- package/dist/server/custom-order/utils.js.map +1 -0
- package/dist/server/custom-order/utils.mjs +10 -0
- package/dist/server/custom-order/utils.mjs.map +1 -0
- package/dist/server/history/constants.js +2 -1
- package/dist/server/history/constants.js.map +1 -1
- package/dist/server/history/constants.mjs +2 -1
- package/dist/server/history/constants.mjs.map +1 -1
- package/dist/server/history/controllers/history-version.js +6 -2
- package/dist/server/history/controllers/history-version.js.map +1 -1
- package/dist/server/history/controllers/history-version.mjs +6 -2
- package/dist/server/history/controllers/history-version.mjs.map +1 -1
- package/dist/server/history/services/history.js +24 -7
- package/dist/server/history/services/history.js.map +1 -1
- package/dist/server/history/services/history.mjs +25 -8
- package/dist/server/history/services/history.mjs.map +1 -1
- package/dist/server/history/services/lifecycles.js +2 -16
- package/dist/server/history/services/lifecycles.js.map +1 -1
- package/dist/server/history/services/lifecycles.mjs +2 -16
- package/dist/server/history/services/lifecycles.mjs.map +1 -1
- package/dist/server/mcp/schemas/filters-schema.js +10 -2
- package/dist/server/mcp/schemas/filters-schema.js.map +1 -1
- package/dist/server/mcp/schemas/filters-schema.mjs +10 -2
- package/dist/server/mcp/schemas/filters-schema.mjs.map +1 -1
- package/dist/server/preview/controllers/validation/preview.js +1 -1
- package/dist/server/preview/controllers/validation/preview.js.map +1 -1
- package/dist/server/preview/controllers/validation/preview.mjs +2 -2
- package/dist/server/preview/controllers/validation/preview.mjs.map +1 -1
- package/dist/server/register.js +4 -0
- package/dist/server/register.js.map +1 -1
- package/dist/server/register.mjs +4 -0
- package/dist/server/register.mjs.map +1 -1
- package/dist/server/routes/index.js +3 -1
- package/dist/server/routes/index.js.map +1 -1
- package/dist/server/routes/index.mjs +2 -0
- package/dist/server/routes/index.mjs.map +1 -1
- package/dist/server/services/content-types.js +2 -2
- package/dist/server/services/content-types.js.map +1 -1
- package/dist/server/services/content-types.mjs +2 -2
- package/dist/server/services/content-types.mjs.map +1 -1
- package/dist/server/services/document-manager.js +13 -0
- package/dist/server/services/document-manager.js.map +1 -1
- package/dist/server/services/document-manager.mjs +14 -1
- 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/index.js +3 -1
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/index.mjs +2 -0
- package/dist/server/services/index.mjs.map +1 -1
- package/dist/server/services/utils/configuration/settings.js +2 -1
- package/dist/server/services/utils/configuration/settings.js.map +1 -1
- package/dist/server/services/utils/configuration/settings.mjs +2 -1
- package/dist/server/services/utils/configuration/settings.mjs.map +1 -1
- package/dist/server/src/audit-logs.d.ts +40 -0
- package/dist/server/src/audit-logs.d.ts.map +1 -0
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/content-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts +21 -3
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts +19 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/single-types.d.ts +1 -1
- package/dist/server/src/controllers/single-types.d.ts.map +1 -1
- package/dist/server/src/custom-order/constants.d.ts +18 -0
- package/dist/server/src/custom-order/constants.d.ts.map +1 -0
- package/dist/server/src/custom-order/controllers/custom-order.d.ts +8 -0
- package/dist/server/src/custom-order/controllers/custom-order.d.ts.map +1 -0
- package/dist/server/src/custom-order/controllers/index.d.ts +3 -0
- package/dist/server/src/custom-order/controllers/index.d.ts.map +1 -0
- package/dist/server/src/custom-order/index.d.ts +8 -0
- package/dist/server/src/custom-order/index.d.ts.map +1 -0
- package/dist/server/src/custom-order/routes/custom-order.d.ts +4 -0
- package/dist/server/src/custom-order/routes/custom-order.d.ts.map +1 -0
- package/dist/server/src/custom-order/routes/index.d.ts +10 -0
- package/dist/server/src/custom-order/routes/index.d.ts.map +1 -0
- package/dist/server/src/custom-order/services/custom-order.d.ts +43 -0
- package/dist/server/src/custom-order/services/custom-order.d.ts.map +1 -0
- package/dist/server/src/custom-order/services/document-middleware.d.ts +16 -0
- package/dist/server/src/custom-order/services/document-middleware.d.ts.map +1 -0
- package/dist/server/src/custom-order/services/index.d.ts +24 -0
- package/dist/server/src/custom-order/services/index.d.ts.map +1 -0
- package/dist/server/src/custom-order/services/utils.d.ts +34 -0
- package/dist/server/src/custom-order/services/utils.d.ts.map +1 -0
- package/dist/server/src/custom-order/utils.d.ts +6 -0
- package/dist/server/src/custom-order/utils.d.ts.map +1 -0
- package/dist/server/src/history/constants.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.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/index.d.ts +22 -6
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/mcp/schemas/filters-schema.d.ts.map +1 -1
- 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/content-types.d.ts +1 -3
- package/dist/server/src/services/content-types.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +1 -3
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -1
- package/dist/shared/contracts/content-types.d.ts +5 -0
- package/dist/shared/contracts/content-types.d.ts.map +1 -1
- package/dist/shared/contracts/custom-order.d.ts +33 -0
- package/dist/shared/contracts/custom-order.d.ts.map +1 -0
- package/dist/shared/contracts/custom-order.js +3 -0
- package/dist/shared/contracts/custom-order.js.map +1 -0
- package/dist/shared/contracts/custom-order.mjs +2 -0
- package/dist/shared/contracts/custom-order.mjs.map +1 -0
- package/dist/shared/contracts/history-versions.d.ts +0 -1
- package/dist/shared/contracts/history-versions.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/index.js +2 -0
- package/dist/shared/contracts/index.js.map +1 -1
- package/dist/shared/contracts/index.mjs +2 -0
- package/dist/shared/contracts/index.mjs.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLayout.mjs","sources":["../../../../../admin/src/pages/EditView/components/FormLayout.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, BoxProps, Flex, Grid } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { EditLayout } from '../../../hooks/useDocumentLayout';\n\nimport { InputRenderer } from './InputRenderer';\n\nimport type { UseDocument } from '../../../hooks/useDocument';\n\nexport const ResponsiveGridRoot = styled(Grid.Root)`\n container-type: inline-size;\n`;\n\nexport const ResponsiveGridItem =\n /**\n * TODO:\n * JSDOM cannot handle container queries.\n * This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error\n * for failing to parse the stylesheet.\n */\n process.env.NODE_ENV !== 'test'\n ? styled(Grid.Item)<{ col: number }>`\n grid-column: span 12;\n ${({ theme }) => theme.breakpoints.medium} {\n ${({ col }) => col && `grid-column: span ${col};`}\n }\n `\n : styled(Grid.Item)<{ col: number }>`\n grid-column: span 12;\n `;\n\nconst panelStyles = {\n padding: {\n initial: 4,\n medium: 6,\n },\n borderColor: 'neutral150',\n background: 'neutral0',\n hasRadius: true,\n shadow: 'tableShadow',\n} satisfies BoxProps;\n\ninterface FormLayoutProps extends Pick<EditLayout, 'layout'> {\n hasBackground?: boolean;\n document: ReturnType<UseDocument>;\n}\n\nconst FormLayout = React.memo(({ layout, document, hasBackground = true }: FormLayoutProps) => {\n const { formatMessage } = useIntl();\n const modelUid = document.schema?.uid;\n\n const getLabel = (name: string, label: string) => {\n return formatMessage({\n id: `content-manager.content-types.${modelUid}.${name}`,\n defaultMessage: label,\n });\n };\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((panel) => {\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\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\n {...field}\n label={getLabel(field.name, field.label)}\n document={document}\n />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n key={panel.flatMap((row) => row.map((field) => field.name)).join('.')}\n {...(hasBackground && panelStyles)}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row) => {\n return (\n <ResponsiveGridRoot\n key={row.map((field) => field.name).join('.')}\n gap={{ initial: 6, medium: 4 }}\n >\n {row.map(({ size, ...field }) => {\n return (\n <ResponsiveGridItem\n col={size}\n key={field.name}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <InputRenderer\n {...field}\n label={getLabel(field.name, field.label)}\n document={document}\n />\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n );\n })}\n </Flex>\n </Box>\n );\n })}\n </Flex>\n );\n});\n\nFormLayout.displayName = 'FormLayout';\n\nexport { FormLayout, FormLayoutProps };\n"],"names":["ResponsiveGridRoot","styled","Grid","Root","ResponsiveGridItem","process","env","NODE_ENV","Item","theme","breakpoints","medium","col","panelStyles","padding","initial","borderColor","background","hasRadius","shadow","FormLayout","React","memo","layout","document","hasBackground","formatMessage","useIntl","modelUid","schema","uid","getLabel","name","label","id","defaultMessage","_jsx","Flex","direction","alignItems","gap","map","panel","some","row","field","type","s","xs","InputRenderer","Box","size","join","flatMap","displayName"],"mappings":";;;;;;;MAYaA,kBAAAA,GAAqBC,MAAAA,CAAOC,IAAAA,CAAKC,IAAI,CAAC;;AAEnD;MAEaC,kBAAAA;;;;;MAOXC,OAAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,SACrBN,MAAAA,CAAOC,IAAAA,CAAKM,IAAI,CAAkB;;QAEhC,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,WAAW,CAACC,MAAM,CAAC;AACxC,UAAA,EAAE,CAAC,EAAEC,GAAG,EAAE,GAAKA,GAAAA,IAAO,CAAC,kBAAkB,EAAEA,GAAAA,CAAI,CAAC,CAAC;;AAErD,MAAA,CAAC,GACDX,MAAAA,CAAOC,IAA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A,GAAGJ,KAAK;AACTZ,wCAAAA,KAAAA,EAAOF,QAAAA,CAASc,KAAAA,CAAMb,IAAI,EAAEa,MAAMZ,KAAK,CAAA;wCACvCT,QAAAA,EAAUA;;AATPqB,iCAAAA,EAAAA,KAAAA,CAAMb,IAAI,CAAA;AAarB,4BAAA,CAAA;2BApBKY,GAAAA,CAAIH,GAAG,CAAC,CAACI,KAAAA,GAAUA,MAAMb,IAAI,CAAA,CAAEoB,IAAI,CAAC,GAAA,CAAA,CAAA;AAuB/C,oBAAA,CAAA;;AA9BGV,aAAAA,EAAAA,KAAAA,CAAMW,OAAO,CAAC,CAACT,GAAAA,GAAQA,GAAAA,CAAIH,GAAG,CAAC,CAACI,KAAAA,GAAUA,KAAAA,CAAMb,IAAI,CAAA,CAAA,CAAGoB,IAAI,CAAC,GAAA,CAAA,CAAA;AAkCvE,QAAA,CAAA;;AAGN,CAAA;AAEAhC,UAAAA,CAAWkC,WAAW,GAAG,YAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"FormLayout.mjs","sources":["../../../../../admin/src/pages/EditView/components/FormLayout.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useForm } from '@strapi/admin/strapi-admin';\nimport { Box, BoxProps, Flex, Grid } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { styled } from 'styled-components';\n\nimport { EditLayout } from '../../../hooks/useDocumentLayout';\nimport { NEAR_VIEWPORT_MARGIN, getScrollParent } from '../../../hooks/useHasBeenNearViewport';\n\nimport { InputRenderer } from './InputRenderer';\n\nimport type { UseDocument } from '../../../hooks/useDocument';\n\n/* -------------------------------------------------------------------------------------------------\n * LazyFormRow\n * -----------------------------------------------------------------------------------------------*/\n\ntype LayoutField = EditLayout['layout'][number][number][number];\n\n/**\n * Rough rendered heights, only used to size placeholders so the scrollbar stays sensible.\n */\nconst ESTIMATED_HEIGHT: Partial<Record<LayoutField['type'], number>> = {\n richtext: 320,\n blocks: 320,\n json: 240,\n component: 240,\n dynamiczone: 160,\n relation: 120,\n media: 160,\n text: 120,\n};\nconst DEFAULT_ESTIMATED_HEIGHT = 80;\n\n/* -------------------------------------------------------------------------------------------------\n * Idle mount queue\n * -----------------------------------------------------------------------------------------------*/\n\ntype ScheduleMount = (mount: () => void) => () => void;\n\ninterface IdleMountQueue {\n schedule: ScheduleMount;\n dispose: () => void;\n}\n\nconst requestIdle = (callback: () => void): number =>\n typeof window.requestIdleCallback === 'function'\n ? window.requestIdleCallback(callback, { timeout: 2000 })\n : window.setTimeout(callback, 16);\n\nconst cancelIdle = (handle: number) =>\n typeof window.cancelIdleCallback === 'function'\n ? window.cancelIdleCallback(handle)\n : window.clearTimeout(handle);\n\n/**\n * Mounts the rows that weren't needed for the first paint, one per idle period, in the order\n * they were scheduled (top to bottom). Rows are then already rendered when the user scrolls to\n * them, and the browser search finds every field.\n */\nconst createIdleMountQueue = (): IdleMountQueue => {\n let queue: Array<() => void> = [];\n let handle: number | null = null;\n\n const flush = () => {\n handle = null;\n queue.shift()?.();\n\n if (queue.length > 0) {\n handle = requestIdle(flush);\n }\n };\n\n return {\n schedule: (mount) => {\n queue.push(mount);\n\n if (handle === null) {\n handle = requestIdle(flush);\n }\n\n return () => {\n queue = queue.filter((scheduled) => scheduled !== mount);\n };\n },\n dispose: () => {\n queue = [];\n\n if (handle !== null) {\n cancelIdle(handle);\n handle = null;\n }\n },\n };\n};\n\nconst IdleMountContext = React.createContext<ScheduleMount | null>(null);\n\nconst useIdleMountQueue = () => {\n const [queue] = React.useState(createIdleMountQueue);\n\n React.useEffect(() => queue.dispose, [queue]);\n\n return queue.schedule;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * LazyFormRow\n * -----------------------------------------------------------------------------------------------*/\n\ntype Components = ReturnType<UseDocument>['components'];\ntype Attribute = LayoutField['attribute'];\n\n/**\n * Some inputs set a value when they mount: a required UID fetches its default value, and custom\n * fields may set a default. Their rows are mounted with the page, as they always were, so that\n * saving right after the page loads doesn't miss those values. Non-repeatable components are\n * expanded by default, so the inputs they contain count too.\n */\nconst hasMountSideEffects = (attribute: Attribute, components: Components, depth = 0): boolean => {\n if ((attribute.type === 'uid' && attribute.required) || 'customField' in attribute) {\n return true;\n }\n\n if (attribute.type === 'component' && !attribute.repeatable && depth < 10) {\n return Object.values(components[attribute.component]?.attributes ?? {}).some((nested) =>\n hasMountSideEffects(nested as Attribute, components, depth + 1)\n );\n }\n\n return false;\n};\n\ninterface LazyFormRowProps {\n fields: Pick<LayoutField, 'name' | 'type'>[];\n mountImmediately?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * Mounts its children once they get close to the viewport, or in the background when the\n * browser is idle, then keeps them mounted. Rendering every field of a large content type\n * upfront is what makes the edit view slow: the cost of the first render should depend on\n * the screen, not on the size of the model.\n */\nconst LazyFormRow = ({ fields, mountImmediately = false, children }: LazyFormRowProps) => {\n const scheduleMount = React.useContext(IdleMountContext);\n const placeholderRef = React.useRef<HTMLDivElement>(null);\n const [isVisible, setIsVisible] = React.useState(\n () => mountImmediately || typeof IntersectionObserver === 'undefined'\n );\n\n // A field in error has to be mounted so the error is displayed and can receive the focus.\n const hasError = useForm('LazyFormRow', (state) =>\n fields.some(({ name }) => name in state.errors)\n );\n\n // Once mounted for an error, the row stays mounted when the errors are cleared (every\n // validation starts by clearing them), so its state (e.g. open blocks) is preserved.\n React.useEffect(() => {\n if (hasError) {\n setIsVisible(true);\n }\n }, [hasError]);\n\n const shouldMount = isVisible || hasError;\n\n React.useEffect(() => {\n const placeholder = placeholderRef.current;\n\n if (shouldMount || !placeholder) {\n return;\n }\n\n const observer = new IntersectionObserver(\n (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n setIsVisible(true);\n }\n },\n { root: getScrollParent(placeholder), rootMargin: NEAR_VIEWPORT_MARGIN }\n );\n\n observer.observe(placeholder);\n\n // Low priority: user input interrupts the render of a row mounted in the background.\n const cancelIdleMount = scheduleMount?.(() =>\n React.startTransition(() => {\n setIsVisible(true);\n })\n );\n\n return () => {\n observer.disconnect();\n cancelIdleMount?.();\n };\n }, [shouldMount, scheduleMount]);\n\n if (shouldMount) {\n return <>{children}</>;\n }\n\n const height = Math.max(\n ...fields.map(({ type }) => ESTIMATED_HEIGHT[type] ?? DEFAULT_ESTIMATED_HEIGHT)\n );\n\n return <div ref={placeholderRef} style={{ height }} aria-hidden />;\n};\n\nexport const ResponsiveGridRoot = styled(Grid.Root)`\n container-type: inline-size;\n`;\n\nexport const ResponsiveGridItem =\n /**\n * TODO:\n * JSDOM cannot handle container queries.\n * This is a temporary workaround so that tests do not fail in the CI when jestdom throws an error\n * for failing to parse the stylesheet.\n */\n process.env.NODE_ENV !== 'test'\n ? styled(Grid.Item)<{ col: number }>`\n grid-column: span 12;\n ${({ theme }) => theme.breakpoints.medium} {\n ${({ col }) => col && `grid-column: span ${col};`}\n }\n `\n : styled(Grid.Item)<{ col: number }>`\n grid-column: span 12;\n `;\n\nconst panelStyles = {\n padding: {\n initial: 4,\n medium: 6,\n },\n borderColor: 'neutral150',\n background: 'neutral0',\n hasRadius: true,\n shadow: 'tableShadow',\n} satisfies BoxProps;\n\ninterface FormLayoutProps extends Pick<EditLayout, 'layout'> {\n hasBackground?: boolean;\n document: ReturnType<UseDocument>;\n}\n\nconst FormLayout = React.memo(({ layout, document, hasBackground = true }: FormLayoutProps) => {\n const { formatMessage } = useIntl();\n const scheduleMount = useIdleMountQueue();\n const modelUid = document.schema?.uid;\n\n const getLabel = (name: string, label: string) => {\n return formatMessage({\n id: `content-manager.content-types.${modelUid}.${name}`,\n defaultMessage: label,\n });\n };\n\n return (\n <IdleMountContext.Provider value={scheduleMount}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((panel) => {\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n return (\n <LazyFormRow\n key={field.name}\n fields={[field]}\n mountImmediately={hasMountSideEffects(field.attribute, document.components)}\n >\n <Grid.Root gap={4}>\n <Grid.Item col={12} s={12} xs={12} direction=\"column\" alignItems=\"stretch\">\n <InputRenderer\n {...field}\n label={getLabel(field.name, field.label)}\n document={document}\n />\n </Grid.Item>\n </Grid.Root>\n </LazyFormRow>\n );\n }\n\n return (\n <Box\n key={panel.flatMap((row) => row.map((field) => field.name)).join('.')}\n {...(hasBackground && panelStyles)}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row) => {\n return (\n <LazyFormRow\n key={row.map((field) => field.name).join('.')}\n fields={row}\n mountImmediately={row.some((field) =>\n hasMountSideEffects(field.attribute, document.components)\n )}\n >\n <ResponsiveGridRoot gap={{ initial: 6, medium: 4 }}>\n {row.map(({ size, ...field }) => {\n return (\n <ResponsiveGridItem\n col={size}\n key={field.name}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <InputRenderer\n {...field}\n size={size}\n label={getLabel(field.name, field.label)}\n document={document}\n />\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n </LazyFormRow>\n );\n })}\n </Flex>\n </Box>\n );\n })}\n </Flex>\n </IdleMountContext.Provider>\n );\n});\n\nFormLayout.displayName = 'FormLayout';\n\nexport { FormLayout, FormLayoutProps, hasMountSideEffects };\n"],"names":["ESTIMATED_HEIGHT","richtext","blocks","json","component","dynamiczone","relation","media","text","DEFAULT_ESTIMATED_HEIGHT","requestIdle","callback","window","requestIdleCallback","timeout","setTimeout","cancelIdle","handle","cancelIdleCallback","clearTimeout","createIdleMountQueue","queue","flush","shift","length","schedule","mount","push","filter","scheduled","dispose","IdleMountContext","React","createContext","useIdleMountQueue","useState","useEffect","hasMountSideEffects","attribute","components","depth","type","required","repeatable","Object","values","attributes","some","nested","LazyFormRow","fields","mountImmediately","children","scheduleMount","useContext","placeholderRef","useRef","isVisible","setIsVisible","IntersectionObserver","hasError","useForm","state","name","errors","shouldMount","placeholder","current","observer","entries","entry","isIntersecting","root","getScrollParent","rootMargin","NEAR_VIEWPORT_MARGIN","observe","cancelIdleMount","startTransition","disconnect","_jsx","_Fragment","height","Math","max","map","div","ref","style","aria-hidden","ResponsiveGridRoot","styled","Grid","Root","ResponsiveGridItem","process","env","NODE_ENV","Item","theme","breakpoints","medium","col","panelStyles","padding","initial","borderColor","background","hasRadius","shadow","FormLayout","memo","layout","document","hasBackground","formatMessage","useIntl","modelUid","schema","uid","getLabel","label","id","defaultMessage","Provider","value","Flex","direction","alignItems","gap","panel","row","field","s","xs","InputRenderer","Box","size","join","flatMap","displayName"],"mappings":";;;;;;;;;AAoBA;;AAEC,IACD,MAAMA,gBAAAA,GAAiE;IACrEC,QAAAA,EAAU,GAAA;IACVC,MAAAA,EAAQ,GAAA;IACRC,IAAAA,EAAM,GAAA;IACNC,SAAAA,EAAW,GAAA;IACXC,WAAAA,EAAa,GAAA;IACbC,QAAAA,EAAU,GAAA;IACVC,KAAAA,EAAO,GAAA;IACPC,IAAAA,EAAM;AACR,CAAA;AACA,MAAMC,wBAAAA,GAA2B,EAAA;AAajC,MAAMC,WAAAA,GAAc,CAACC,QAAAA,GACnB,OAAOC,MAAAA,CAAOC,mBAAmB,KAAK,UAAA,GAClCD,MAAAA,CAAOC,mBAAmB,CAACF,QAAAA,EAAU;QAAEG,OAAAA,EAAS;KAAK,CAAA,GACrDF,MAAAA,CAAOG,UAAU,CAACJ,QAAAA,EAAU,EAAA,CAAA;AAElC,MAAMK,UAAAA,GAAa,CAACC,MAAAA,GAClB,OAAOL,OAAOM,kBAAkB,KAAK,UAAA,GACjCN,MAAAA,CAAOM,kBAAkB,CAACD,MAAAA,CAAAA,GAC1BL,MAAAA,CAAOO,YAAY,CAACF,MAAAA,CAAAA;AAE1B;;;;AAIC,IACD,MAAMG,oBAAAA,GAAuB,IAAA;AAC3B,IAAA,IAAIC,QAA2B,EAAE;AACjC,IAAA,IAAIJ,MAAAA,GAAwB,IAAA;AAE5B,IAAA,MAAMK,KAAAA,GAAQ,IAAA;QACZL,MAAAA,GAAS,IAAA;AACTI,QAAAA,KAAAA,CAAME,KAAK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,IAAI,EAAEqE,MAAMX,KAAK,CAAA;gDACvCR,QAAAA,EAAUA;;AAVPmB,yCAAAA,EAAAA,KAAAA,CAAMrE,IAAI,CAAA;AAcrB,oCAAA,CAAA;;+BAzBGoE,GAAAA,CAAI9C,GAAG,CAAC,CAAC+C,KAAAA,GAAUA,MAAMrE,IAAI,CAAA,CAAE2E,IAAI,CAAC,GAAA,CAAA,CAAA;AA6B/C,wBAAA,CAAA;;AApCGR,iBAAAA,EAAAA,KAAAA,CAAMS,OAAO,CAAC,CAACR,GAAAA,GAAQA,GAAAA,CAAI9C,GAAG,CAAC,CAAC+C,KAAAA,GAAUA,KAAAA,CAAMrE,IAAI,CAAA,CAAA,CAAG2E,IAAI,CAAC,GAAA,CAAA,CAAA;AAwCvE,YAAA,CAAA;;;AAIR,CAAA;AAEA5B,UAAAA,CAAW8B,WAAW,GAAG,YAAA;;;;"}
|
|
@@ -48,7 +48,8 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
48
48
|
* specifically to be used in the EditView of the content-manager this understands
|
|
49
49
|
* the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific
|
|
50
50
|
* components such as Blocks / Relations.
|
|
51
|
-
*/ const BaseInputRenderer = ({ visible, hint: providedHint, document: providedDocument,
|
|
51
|
+
*/ const BaseInputRenderer = ({ visible, hint: providedHint, document: providedDocument, // Not spread with the rest: design-system inputs have a `size` prop of their own.
|
|
52
|
+
size: layoutSize, ...inputProps })=>{
|
|
52
53
|
const { currentDocument, currentDocumentMeta } = useDocumentContext.useDocumentContext('DynamicComponent');
|
|
53
54
|
// Most edit-view fields can read the document from context, which avoids threading a
|
|
54
55
|
// frequently-changing `document` prop through nested component/DZ trees and reduces churn.
|
|
@@ -139,6 +140,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
139
140
|
...props,
|
|
140
141
|
// @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
|
|
141
142
|
hint: hint,
|
|
143
|
+
layoutSize: layoutSize,
|
|
142
144
|
disabled: fieldIsDisabled
|
|
143
145
|
}, `input-${props.name}-${localeKey}`);
|
|
144
146
|
}
|
|
@@ -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 createRulesEngine,\n type JsonLogicCondition,\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 {\n useHasInputPopoverParent,\n usePreviewPopoverBlockIndex,\n} from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\nimport {\n getConditionDependencyPaths,\n getConditionDependencySubscriptionValue,\n} from '../../../utils/conditionalFields';\nimport { getDirectParent } from '../utils/data';\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 BaseInputRenderer = ({\n visible,\n hint: providedHint,\n document: providedDocument,\n ...inputProps\n}: InputRendererProps) => {\n const { currentDocument, currentDocumentMeta } = useDocumentContext('DynamicComponent');\n // Most edit-view fields can read the document from context, which avoids threading a\n // frequently-changing `document` prop through nested component/DZ trees and reduces churn.\n // Keep `providedDocument` as an explicit override for callers outside that default flow.\n const document = providedDocument ?? currentDocument;\n const localeKey = document?.document?.locale || 'default';\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 blockIndex = usePreviewPopoverBlockIndex();\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 const renderComponentInput = React.useCallback(\n (componentInputProps: InputRendererProps) => (\n <MemoizedInputRenderer\n key={`input-${componentInputProps.name}-${localeKey}`}\n {...componentInputProps}\n />\n ),\n [localeKey]\n );\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 key={`input-${props.name}-${localeKey}`}\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 key={`input-${props.name}-${localeKey}`}\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 (\n <BlocksInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n autoFocus={isInPreviewPopover && blockIndex == null}\n livePreviewSync={isInPreviewPopover}\n blockIndex={blockIndex}\n />\n );\n case 'component':\n // Preview focus/blur handlers are not used for data-structure roots (component/dynamic zone).\n // Dropping them avoids unstable function props cascading through memoized component trees.\n const { onBlur: _onComponentBlur, onFocus: _onComponentFocus, ...componentProps } = props;\n\n return (\n <ComponentInput\n key={`input-${props.name}-${localeKey}`}\n {...componentProps}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {renderComponentInput}\n </ComponentInput>\n );\n case 'dynamiczone':\n // Same rationale as `component` above: keep data-structure root props stable.\n const { onBlur: _onDzBlur, onFocus: _onDzFocus, ...dynamicZoneProps } = props;\n\n return (\n <DynamicZone\n key={`input-${props.name}-${localeKey}`}\n {...dynamicZoneProps}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'relation':\n return (\n <RelationsInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n // These props are not needed for the generic form input renderer.\n const { unique: _uniqueUID, ...restUIDProps } = props;\n return (\n <UIDInput\n key={`input-${props.name}-${localeKey}`}\n {...restUIDProps}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\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 key={`input-${props.name}-${localeKey}`}\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\n// Reuse one rules engine instance instead of recreating it for every field render.\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n condition,\n ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n // Extract only the field paths the visibility rule depends on so unrelated form changes\n // do not force this conditional field to re-render.\n const conditionDependencyPaths = React.useMemo(\n () => getConditionDependencyPaths(condition),\n [condition]\n );\n const getValues = useForm(\n 'ConditionalInputRenderer',\n (state) => (state as typeof state & { getValues: () => unknown }).getValues\n );\n const conditionSubscriptionValue = useForm('ConditionalInputRenderer', (state) => {\n // Subscribe to a small, comparable snapshot of the parent scope instead of all form values.\n return getConditionDependencySubscriptionValue(\n getDirectParent(state.values, props.name),\n conditionDependencyPaths\n );\n });\n\n // When dependencies are known, read the latest parent scope lazily via getValues() so the\n // rule still evaluates against fresh data without subscribing to every form change.\n const targetValues =\n conditionDependencyPaths === null\n ? conditionSubscriptionValue\n : getDirectParent(getValues(), props.name);\n\n const isVisible = rulesEngine.evaluate(condition, targetValues);\n\n if (!isVisible) {\n return null;\n }\n\n return <BaseInputRenderer {...props} />;\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 = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\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\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n const condition = props.attribute.conditions?.visible;\n if (condition) {\n return <ConditionAwareInputRenderer {...props} condition={condition} />;\n }\n\n return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","providedDocument","inputProps","currentDocument","currentDocumentMeta","useDocumentContext","localeKey","locale","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","blockIndex","usePreviewPopoverBlockIndex","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","renderComponentInput","React","useCallback","componentInputProps","_jsx","MemoizedInputRenderer","field","useField","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","autoFocus","livePreviewSync","onBlur","_onComponentBlur","onFocus","_onComponentFocus","componentProps","ComponentInput","layout","component","_onDzBlur","_onDzFocus","dynamicZoneProps","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","conditionDependencyPaths","useMemo","getConditionDependencyPaths","getValues","conditionSubscriptionValue","getConditionDependencySubscriptionValue","getDirectParent","values","targetValues","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAAA,EAAMC,YAAY,EAClBC,QAAAA,EAAUC,gBAAgB,EAC1B,GAAGC,UAAAA,EACgB,GAAA;AACnB,IAAA,MAAM,EAAEC,eAAe,EAAEC,mBAAmB,EAAE,GAAG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OAAAA,EAAS,CAACc,MAAAA,CAAOC,KAAK,CAACD,MAAAA,CAAO3F,SAAAA,CAAUsF,GAAG,CAAA,CAAA,GAAKK,MAAAA,CAAO3F,SAAAA,CAAUsF,GAAG,CAAA,GAAI1E;AAC1E,SAAA;AACF,IAAA,CAAA,MAAO,IAAI,WAAA,IAAeZ,SAAAA,IAAa,WAAA,IAAeA,SAAAA,EAAW;QAC/D,OAAO;AAAE4E,YAAAA,OAAAA,EAAS5E,UAAU6F,SAAS;AAAEhB,YAAAA,OAAAA,EAAS7E,UAAU8F;AAAU,SAAA;IACtE,CAAA,MAAO;QACL,OAAO;YAAElB,OAAAA,EAAShE,SAAAA;YAAWiE,OAAAA,EAASjE;AAAU,SAAA;AAClD,IAAA;AACF,CAAA;AAEA;;;;;;;AAOC,IACD,MAAMO,qBAAAA,iBAAwBJ,gBAAAA,CAAMgF,IAAI,CAAC,CAAC9F,KAAAA,GAAAA;AACxC,IAAA,MAAM6D,SAAAA,GAAY7D,KAAAA,CAAMD,SAAS,CAACgG,UAAU,EAAE3I,OAAAA;AAC9C,IAAA,IAAIyG,SAAAA,EAAW;AACb,QAAA,qBAAO5C,cAAA,CAAC2C,2BAAAA,EAAAA;AAA6B,YAAA,GAAG5D,KAAK;YAAE6D,SAAAA,EAAWA;;AAC5D,IAAA;AAEA,IAAA,qBAAO5C,cAAA,CAAC9D,iBAAAA,EAAAA;AAAmB,QAAA,GAAG6C;;AAChC,CAAA;;;;;"}
|
|
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 createRulesEngine,\n type JsonLogicCondition,\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 {\n useHasInputPopoverParent,\n usePreviewPopoverBlockIndex,\n} from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\nimport {\n getConditionDependencyPaths,\n getConditionDependencySubscriptionValue,\n} from '../../../utils/conditionalFields';\nimport { getDirectParent } from '../utils/data';\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 /** The field's width in the edit layout, out of 12. */\n size?: number;\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 BaseInputRenderer = ({\n visible,\n hint: providedHint,\n document: providedDocument,\n // Not spread with the rest: design-system inputs have a `size` prop of their own.\n size: layoutSize,\n ...inputProps\n}: InputRendererProps) => {\n const { currentDocument, currentDocumentMeta } = useDocumentContext('DynamicComponent');\n // Most edit-view fields can read the document from context, which avoids threading a\n // frequently-changing `document` prop through nested component/DZ trees and reduces churn.\n // Keep `providedDocument` as an explicit override for callers outside that default flow.\n const document = providedDocument ?? currentDocument;\n const localeKey = document?.document?.locale || 'default';\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 blockIndex = usePreviewPopoverBlockIndex();\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 const renderComponentInput = React.useCallback(\n (componentInputProps: InputRendererProps) => (\n <MemoizedInputRenderer\n key={`input-${componentInputProps.name}-${localeKey}`}\n {...componentInputProps}\n />\n ),\n [localeKey]\n );\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 key={`input-${props.name}-${localeKey}`}\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 key={`input-${props.name}-${localeKey}`}\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n layoutSize={layoutSize}\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 (\n <BlocksInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n autoFocus={isInPreviewPopover && blockIndex == null}\n livePreviewSync={isInPreviewPopover}\n blockIndex={blockIndex}\n />\n );\n case 'component':\n // Preview focus/blur handlers are not used for data-structure roots (component/dynamic zone).\n // Dropping them avoids unstable function props cascading through memoized component trees.\n const { onBlur: _onComponentBlur, onFocus: _onComponentFocus, ...componentProps } = props;\n\n return (\n <ComponentInput\n key={`input-${props.name}-${localeKey}`}\n {...componentProps}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {renderComponentInput}\n </ComponentInput>\n );\n case 'dynamiczone':\n // Same rationale as `component` above: keep data-structure root props stable.\n const { onBlur: _onDzBlur, onFocus: _onDzFocus, ...dynamicZoneProps } = props;\n\n return (\n <DynamicZone\n key={`input-${props.name}-${localeKey}`}\n {...dynamicZoneProps}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'relation':\n return (\n <RelationsInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n // These props are not needed for the generic form input renderer.\n const { unique: _uniqueUID, ...restUIDProps } = props;\n return (\n <UIDInput\n key={`input-${props.name}-${localeKey}`}\n {...restUIDProps}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\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 key={`input-${props.name}-${localeKey}`}\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\n// Reuse one rules engine instance instead of recreating it for every field render.\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n condition,\n ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n // Extract only the field paths the visibility rule depends on so unrelated form changes\n // do not force this conditional field to re-render.\n const conditionDependencyPaths = React.useMemo(\n () => getConditionDependencyPaths(condition),\n [condition]\n );\n const getValues = useForm(\n 'ConditionalInputRenderer',\n (state) => (state as typeof state & { getValues: () => unknown }).getValues\n );\n const conditionSubscriptionValue = useForm('ConditionalInputRenderer', (state) => {\n // Subscribe to a small, comparable snapshot of the parent scope instead of all form values.\n return getConditionDependencySubscriptionValue(\n getDirectParent(state.values, props.name),\n conditionDependencyPaths\n );\n });\n\n // When dependencies are known, read the latest parent scope lazily via getValues() so the\n // rule still evaluates against fresh data without subscribing to every form change.\n const targetValues =\n conditionDependencyPaths === null\n ? conditionSubscriptionValue\n : getDirectParent(getValues(), props.name);\n\n const isVisible = rulesEngine.evaluate(condition, targetValues);\n\n if (!isVisible) {\n return null;\n }\n\n return <BaseInputRenderer {...props} />;\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 = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\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\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n const condition = props.attribute.conditions?.visible;\n if (condition) {\n return <ConditionAwareInputRenderer {...props} condition={condition} />;\n }\n\n return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","providedDocument","size","layoutSize","inputProps","currentDocument","currentDocumentMeta","useDocumentContext","localeKey","locale","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","blockIndex","usePreviewPopoverBlockIndex","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","renderComponentInput","React","useCallback","componentInputProps","_jsx","MemoizedInputRenderer","field","useField","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","autoFocus","livePreviewSync","onBlur","_onComponentBlur","onFocus","_onComponentFocus","componentProps","ComponentInput","layout","component","_onDzBlur","_onDzFocus","dynamicZoneProps","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","conditionDependencyPaths","useMemo","getConditionDependencyPaths","getValues","conditionSubscriptionValue","getConditionDependencySubscriptionValue","getDirectParent","values","targetValues","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAAA,EAAMC,YAAY,EAClBC,QAAAA,EAAUC,gBAAgB;AAE1BC,IAAAA,EAAMC,UAAU,EAChB,GAAGC,UAAAA,EACgB,GAAA;AACnB,IAAA,MAAM,EAAEC,eAAe,EAAEC,mBAAmB,EAAE,GAAGC,qCAAAA,CAAmB,kBAAA,CAAA;;;;AAIpE,IAAA,MAAMP,WAAWC,gBAAAA,IAAoBI,eAAAA;IACrC,MAAMG,SAAAA,GAAYR,QAAAA,EAAUA,QAAAA,EAAUS,MAAAA,IAAU,SAAA;IAChD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,mCAAAA,CAAkBN,mBAAAA,CAAoBO,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJd,QAAA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,YAAAA,OAAAA,EAAS5E,UAAU6F,SAAS;AAAEhB,YAAAA,OAAAA,EAAS7E,UAAU8F;AAAU,SAAA;IACtE,CAAA,MAAO;QACL,OAAO;YAAElB,OAAAA,EAAShE,SAAAA;YAAWiE,OAAAA,EAASjE;AAAU,SAAA;AAClD,IAAA;AACF,CAAA;AAEA;;;;;;;AAOC,IACD,MAAMO,qBAAAA,iBAAwBJ,gBAAAA,CAAMgF,IAAI,CAAC,CAAC9F,KAAAA,GAAAA;AACxC,IAAA,MAAM6D,SAAAA,GAAY7D,KAAAA,CAAMD,SAAS,CAACgG,UAAU,EAAE7I,OAAAA;AAC9C,IAAA,IAAI2G,SAAAA,EAAW;AACb,QAAA,qBAAO5C,cAAA,CAAC2C,2BAAAA,EAAAA;AAA6B,YAAA,GAAG5D,KAAK;YAAE6D,SAAAA,EAAWA;;AAC5D,IAAA;AAEA,IAAA,qBAAO5C,cAAA,CAAChE,iBAAAA,EAAAA;AAAmB,QAAA,GAAG+C;;AAChC,CAAA;;;;;"}
|
|
@@ -26,7 +26,8 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
26
26
|
* specifically to be used in the EditView of the content-manager this understands
|
|
27
27
|
* the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific
|
|
28
28
|
* components such as Blocks / Relations.
|
|
29
|
-
*/ const BaseInputRenderer = ({ visible, hint: providedHint, document: providedDocument,
|
|
29
|
+
*/ const BaseInputRenderer = ({ visible, hint: providedHint, document: providedDocument, // Not spread with the rest: design-system inputs have a `size` prop of their own.
|
|
30
|
+
size: layoutSize, ...inputProps })=>{
|
|
30
31
|
const { currentDocument, currentDocumentMeta } = useDocumentContext('DynamicComponent');
|
|
31
32
|
// Most edit-view fields can read the document from context, which avoids threading a
|
|
32
33
|
// frequently-changing `document` prop through nested component/DZ trees and reduces churn.
|
|
@@ -117,6 +118,7 @@ import { Wysiwyg as MemoizedWysiwyg } from './FormInputs/Wysiwyg/Field.mjs';
|
|
|
117
118
|
...props,
|
|
118
119
|
// @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
|
|
119
120
|
hint: hint,
|
|
121
|
+
layoutSize: layoutSize,
|
|
120
122
|
disabled: fieldIsDisabled
|
|
121
123
|
}, `input-${props.name}-${localeKey}`);
|
|
122
124
|
}
|
|
@@ -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 createRulesEngine,\n type JsonLogicCondition,\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 {\n useHasInputPopoverParent,\n usePreviewPopoverBlockIndex,\n} from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\nimport {\n getConditionDependencyPaths,\n getConditionDependencySubscriptionValue,\n} from '../../../utils/conditionalFields';\nimport { getDirectParent } from '../utils/data';\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 BaseInputRenderer = ({\n visible,\n hint: providedHint,\n document: providedDocument,\n ...inputProps\n}: InputRendererProps) => {\n const { currentDocument, currentDocumentMeta } = useDocumentContext('DynamicComponent');\n // Most edit-view fields can read the document from context, which avoids threading a\n // frequently-changing `document` prop through nested component/DZ trees and reduces churn.\n // Keep `providedDocument` as an explicit override for callers outside that default flow.\n const document = providedDocument ?? currentDocument;\n const localeKey = document?.document?.locale || 'default';\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 blockIndex = usePreviewPopoverBlockIndex();\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 const renderComponentInput = React.useCallback(\n (componentInputProps: InputRendererProps) => (\n <MemoizedInputRenderer\n key={`input-${componentInputProps.name}-${localeKey}`}\n {...componentInputProps}\n />\n ),\n [localeKey]\n );\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 key={`input-${props.name}-${localeKey}`}\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 key={`input-${props.name}-${localeKey}`}\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 (\n <BlocksInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n autoFocus={isInPreviewPopover && blockIndex == null}\n livePreviewSync={isInPreviewPopover}\n blockIndex={blockIndex}\n />\n );\n case 'component':\n // Preview focus/blur handlers are not used for data-structure roots (component/dynamic zone).\n // Dropping them avoids unstable function props cascading through memoized component trees.\n const { onBlur: _onComponentBlur, onFocus: _onComponentFocus, ...componentProps } = props;\n\n return (\n <ComponentInput\n key={`input-${props.name}-${localeKey}`}\n {...componentProps}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {renderComponentInput}\n </ComponentInput>\n );\n case 'dynamiczone':\n // Same rationale as `component` above: keep data-structure root props stable.\n const { onBlur: _onDzBlur, onFocus: _onDzFocus, ...dynamicZoneProps } = props;\n\n return (\n <DynamicZone\n key={`input-${props.name}-${localeKey}`}\n {...dynamicZoneProps}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'relation':\n return (\n <RelationsInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n // These props are not needed for the generic form input renderer.\n const { unique: _uniqueUID, ...restUIDProps } = props;\n return (\n <UIDInput\n key={`input-${props.name}-${localeKey}`}\n {...restUIDProps}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\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 key={`input-${props.name}-${localeKey}`}\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\n// Reuse one rules engine instance instead of recreating it for every field render.\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n condition,\n ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n // Extract only the field paths the visibility rule depends on so unrelated form changes\n // do not force this conditional field to re-render.\n const conditionDependencyPaths = React.useMemo(\n () => getConditionDependencyPaths(condition),\n [condition]\n );\n const getValues = useForm(\n 'ConditionalInputRenderer',\n (state) => (state as typeof state & { getValues: () => unknown }).getValues\n );\n const conditionSubscriptionValue = useForm('ConditionalInputRenderer', (state) => {\n // Subscribe to a small, comparable snapshot of the parent scope instead of all form values.\n return getConditionDependencySubscriptionValue(\n getDirectParent(state.values, props.name),\n conditionDependencyPaths\n );\n });\n\n // When dependencies are known, read the latest parent scope lazily via getValues() so the\n // rule still evaluates against fresh data without subscribing to every form change.\n const targetValues =\n conditionDependencyPaths === null\n ? conditionSubscriptionValue\n : getDirectParent(getValues(), props.name);\n\n const isVisible = rulesEngine.evaluate(condition, targetValues);\n\n if (!isVisible) {\n return null;\n }\n\n return <BaseInputRenderer {...props} />;\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 = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\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\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n const condition = props.attribute.conditions?.visible;\n if (condition) {\n return <ConditionAwareInputRenderer {...props} condition={condition} />;\n }\n\n return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","providedDocument","inputProps","currentDocument","currentDocumentMeta","useDocumentContext","localeKey","locale","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","blockIndex","usePreviewPopoverBlockIndex","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","renderComponentInput","React","useCallback","componentInputProps","_jsx","MemoizedInputRenderer","field","useField","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","autoFocus","livePreviewSync","onBlur","_onComponentBlur","onFocus","_onComponentFocus","componentProps","ComponentInput","layout","component","_onDzBlur","_onDzFocus","dynamicZoneProps","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","conditionDependencyPaths","useMemo","getConditionDependencyPaths","getValues","conditionSubscriptionValue","getConditionDependencySubscriptionValue","getDirectParent","values","targetValues","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAAA,EAAMC,YAAY,EAClBC,QAAAA,EAAUC,gBAA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KO,MAAAA,CAAO3F,SAAAA,CAAUoF,GAAG,CAAA,GAAIxE,SAAAA;YACxEiE,OAAAA,EAAS,CAACc,MAAAA,CAAOC,KAAK,CAACD,MAAAA,CAAO3F,SAAAA,CAAUsF,GAAG,CAAA,CAAA,GAAKK,MAAAA,CAAO3F,SAAAA,CAAUsF,GAAG,CAAA,GAAI1E;AAC1E,SAAA;AACF,IAAA,CAAA,MAAO,IAAI,WAAA,IAAeZ,SAAAA,IAAa,WAAA,IAAeA,SAAAA,EAAW;QAC/D,OAAO;AAAE4E,YAAAA,OAAAA,EAAS5E,UAAU6F,SAAS;AAAEhB,YAAAA,OAAAA,EAAS7E,UAAU8F;AAAU,SAAA;IACtE,CAAA,MAAO;QACL,OAAO;YAAElB,OAAAA,EAAShE,SAAAA;YAAWiE,OAAAA,EAASjE;AAAU,SAAA;AAClD,IAAA;AACF,CAAA;AAEA;;;;;;;AAOC,IACD,MAAMO,qBAAAA,iBAAwBJ,KAAAA,CAAMgF,IAAI,CAAC,CAAC9F,KAAAA,GAAAA;AACxC,IAAA,MAAM6D,SAAAA,GAAY7D,KAAAA,CAAMD,SAAS,CAACgG,UAAU,EAAE3I,OAAAA;AAC9C,IAAA,IAAIyG,SAAAA,EAAW;AACb,QAAA,qBAAO5C,GAAA,CAAC2C,2BAAAA,EAAAA;AAA6B,YAAA,GAAG5D,KAAK;YAAE6D,SAAAA,EAAWA;;AAC5D,IAAA;AAEA,IAAA,qBAAO5C,GAAA,CAAC9D,iBAAAA,EAAAA;AAAmB,QAAA,GAAG6C;;AAChC,CAAA;;;;"}
|
|
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 createRulesEngine,\n type JsonLogicCondition,\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 {\n useHasInputPopoverParent,\n usePreviewPopoverBlockIndex,\n} from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\nimport {\n getConditionDependencyPaths,\n getConditionDependencySubscriptionValue,\n} from '../../../utils/conditionalFields';\nimport { getDirectParent } from '../utils/data';\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 /** The field's width in the edit layout, out of 12. */\n size?: number;\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 BaseInputRenderer = ({\n visible,\n hint: providedHint,\n document: providedDocument,\n // Not spread with the rest: design-system inputs have a `size` prop of their own.\n size: layoutSize,\n ...inputProps\n}: InputRendererProps) => {\n const { currentDocument, currentDocumentMeta } = useDocumentContext('DynamicComponent');\n // Most edit-view fields can read the document from context, which avoids threading a\n // frequently-changing `document` prop through nested component/DZ trees and reduces churn.\n // Keep `providedDocument` as an explicit override for callers outside that default flow.\n const document = providedDocument ?? currentDocument;\n const localeKey = document?.document?.locale || 'default';\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 blockIndex = usePreviewPopoverBlockIndex();\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 const renderComponentInput = React.useCallback(\n (componentInputProps: InputRendererProps) => (\n <MemoizedInputRenderer\n key={`input-${componentInputProps.name}-${localeKey}`}\n {...componentInputProps}\n />\n ),\n [localeKey]\n );\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 key={`input-${props.name}-${localeKey}`}\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 key={`input-${props.name}-${localeKey}`}\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n layoutSize={layoutSize}\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 (\n <BlocksInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n autoFocus={isInPreviewPopover && blockIndex == null}\n livePreviewSync={isInPreviewPopover}\n blockIndex={blockIndex}\n />\n );\n case 'component':\n // Preview focus/blur handlers are not used for data-structure roots (component/dynamic zone).\n // Dropping them avoids unstable function props cascading through memoized component trees.\n const { onBlur: _onComponentBlur, onFocus: _onComponentFocus, ...componentProps } = props;\n\n return (\n <ComponentInput\n key={`input-${props.name}-${localeKey}`}\n {...componentProps}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {renderComponentInput}\n </ComponentInput>\n );\n case 'dynamiczone':\n // Same rationale as `component` above: keep data-structure root props stable.\n const { onBlur: _onDzBlur, onFocus: _onDzFocus, ...dynamicZoneProps } = props;\n\n return (\n <DynamicZone\n key={`input-${props.name}-${localeKey}`}\n {...dynamicZoneProps}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'relation':\n return (\n <RelationsInput\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n case 'richtext':\n return (\n <Wysiwyg\n key={`input-${props.name}-${localeKey}`}\n {...props}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n case 'uid':\n // These props are not needed for the generic form input renderer.\n const { unique: _uniqueUID, ...restUIDProps } = props;\n return (\n <UIDInput\n key={`input-${props.name}-${localeKey}`}\n {...restUIDProps}\n hint={hint}\n type={props.type}\n disabled={fieldIsDisabled}\n />\n );\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n key={`input-${props.name}-${localeKey}`}\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 key={`input-${props.name}-${localeKey}`}\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\n// Reuse one rules engine instance instead of recreating it for every field render.\nconst rulesEngine = createRulesEngine();\n\n/**\n * A wrapper around BaseInputRenderer that conditionally renders it depending on the attribute's condition.\n */\nconst ConditionAwareInputRenderer = ({\n condition,\n ...props\n}: InputRendererProps & { condition: JsonLogicCondition }) => {\n // Extract only the field paths the visibility rule depends on so unrelated form changes\n // do not force this conditional field to re-render.\n const conditionDependencyPaths = React.useMemo(\n () => getConditionDependencyPaths(condition),\n [condition]\n );\n const getValues = useForm(\n 'ConditionalInputRenderer',\n (state) => (state as typeof state & { getValues: () => unknown }).getValues\n );\n const conditionSubscriptionValue = useForm('ConditionalInputRenderer', (state) => {\n // Subscribe to a small, comparable snapshot of the parent scope instead of all form values.\n return getConditionDependencySubscriptionValue(\n getDirectParent(state.values, props.name),\n conditionDependencyPaths\n );\n });\n\n // When dependencies are known, read the latest parent scope lazily via getValues() so the\n // rule still evaluates against fresh data without subscribing to every form change.\n const targetValues =\n conditionDependencyPaths === null\n ? conditionSubscriptionValue\n : getDirectParent(getValues(), props.name);\n\n const isVisible = rulesEngine.evaluate(condition, targetValues);\n\n if (!isVisible) {\n return null;\n }\n\n return <BaseInputRenderer {...props} />;\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 = ['string', 'uid', 'richtext', 'email', 'password', 'text'].includes(attribute.type)\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\n/**\n * Conditionally routes the exported InputRender component towards ConditionalInputRenderer\n * (when there's a JSON logic condition on the attribute, or BaseInputRenderer otherwise.\n * We do this because rendering a conditional field requires access to the values of\n * other form fields, which causes many re-renders and performance issues on complex content\n * types. By splitting the component into two, we isolate the performance issue to\n * conditional fields only, not all edit view fields.\n */\nconst MemoizedInputRenderer = React.memo((props: InputRendererProps) => {\n const condition = props.attribute.conditions?.visible;\n if (condition) {\n return <ConditionAwareInputRenderer {...props} condition={condition} />;\n }\n\n return <BaseInputRenderer {...props} />;\n});\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["BaseInputRenderer","visible","hint","providedHint","document","providedDocument","size","layoutSize","inputProps","currentDocument","currentDocumentMeta","useDocumentContext","localeKey","locale","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","blockIndex","usePreviewPopoverBlockIndex","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","renderComponentInput","React","useCallback","componentInputProps","_jsx","MemoizedInputRenderer","field","useField","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","autoFocus","livePreviewSync","onBlur","_onComponentBlur","onFocus","_onComponentFocus","componentProps","ComponentInput","layout","component","_onDzBlur","_onDzFocus","dynamicZoneProps","DynamicZone","RelationsInput","Wysiwyg","unique","_uniqueUID","restUIDProps","UIDInput","options","enum","map","value","_unique","mainField","_mainField","restProps","rulesEngine","createRulesEngine","ConditionAwareInputRenderer","condition","conditionDependencyPaths","useMemo","getConditionDependencyPaths","getValues","conditionSubscriptionValue","getConditionDependencySubscriptionValue","getDirectParent","values","targetValues","isVisible","evaluate","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","memo","conditions"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+CA;;;;;;;AAOC,IACD,MAAMA,iBAAAA,GAAoB,CAAC,EACzBC,OAAO,EACPC,IAAAA,EAAMC,YAAY,EAClBC,QAAAA,EAAUC,gBAAgB;AAE1BC,IAAAA,EAAMC,UAAU,EAChB,GAAGC,UAAAA,EACgB,GAAA;AACnB,IAAA,MAAM,EAAEC,eAAe,EAAEC,mBAAmB,EAAE,GAAGC,kBAAAA,CAAmB,kBAAA,CAAA;;;;AAIpE,IAAA,MAAMP,WAAWC,gBAAAA,IAAoBI,eAAAA;IACrC,MAAMG,SAAAA,GAAYR,QAAAA,EAAUA,QAAAA,EAAUS,MAAAA,IAAU,SAAA;IAChD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,iBAAAA,CAAkBN,mBAAAA,CAAoBO,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QAC/D,OAAO;AAAE4E,YAAAA,OAAAA,EAAS5E,UAAU6F,SAAS;AAAEhB,YAAAA,OAAAA,EAAS7E,UAAU8F;AAAU,SAAA;IACtE,CAAA,MAAO;QACL,OAAO;YAAElB,OAAAA,EAAShE,SAAAA;YAAWiE,OAAAA,EAASjE;AAAU,SAAA;AAClD,IAAA;AACF,CAAA;AAEA;;;;;;;AAOC,IACD,MAAMO,qBAAAA,iBAAwBJ,KAAAA,CAAMgF,IAAI,CAAC,CAAC9F,KAAAA,GAAAA;AACxC,IAAA,MAAM6D,SAAAA,GAAY7D,KAAAA,CAAMD,SAAS,CAACgG,UAAU,EAAE7I,OAAAA;AAC9C,IAAA,IAAI2G,SAAAA,EAAW;AACb,QAAA,qBAAO5C,GAAA,CAAC2C,2BAAAA,EAAAA;AAA6B,YAAA,GAAG5D,KAAK;YAAE6D,SAAAA,EAAWA;;AAC5D,IAAA;AAEA,IAAA,qBAAO5C,GAAA,CAAChE,iBAAAA,EAAAA;AAAmB,QAAA,GAAG+C;;AAChC,CAAA;;;;"}
|
|
@@ -5,6 +5,8 @@ var React = require('react');
|
|
|
5
5
|
var strapiAdmin = require('@strapi/admin/strapi-admin');
|
|
6
6
|
var designSystem = require('@strapi/design-system');
|
|
7
7
|
var reactIntl = require('react-intl');
|
|
8
|
+
var collections = require('../../../constants/collections.js');
|
|
9
|
+
var customOrder = require('../../../constants/customOrder.js');
|
|
8
10
|
var useDocument = require('../../../hooks/useDocument.js');
|
|
9
11
|
var translations = require('../../../utils/translations.js');
|
|
10
12
|
|
|
@@ -42,8 +44,10 @@ const Settings = ()=>{
|
|
|
42
44
|
const formatter = designSystem.useCollator(locale, {
|
|
43
45
|
sensitivity: 'base'
|
|
44
46
|
});
|
|
45
|
-
const { schema } = useDocument.useDoc();
|
|
47
|
+
const { schema, collectionType } = useDocument.useDoc();
|
|
46
48
|
const layout = strapiAdmin.useForm('Settings', (state)=>state.values.layout ?? []);
|
|
49
|
+
const hasCustomOrder = strapiAdmin.useForm('Settings', (state)=>state.values.settings.customOrder);
|
|
50
|
+
const canUseCustomOrder = collectionType === collections.COLLECTION_TYPES && customOrder.isCustomOrderFeatureEnabled();
|
|
47
51
|
const currentSortBy = strapiAdmin.useForm('Settings', (state)=>state.values.settings.defaultSortBy);
|
|
48
52
|
const onChange = strapiAdmin.useForm('Settings', (state)=>state.onChange);
|
|
49
53
|
const sortOptions = React__namespace.useMemo(()=>Object.values(layout).reduce((acc, field)=>{
|
|
@@ -69,10 +73,17 @@ const Settings = ()=>{
|
|
|
69
73
|
onChange,
|
|
70
74
|
sortOptionsSorted
|
|
71
75
|
]);
|
|
72
|
-
const formLayout = React__namespace.useMemo(()=>
|
|
76
|
+
const formLayout = React__namespace.useMemo(()=>[
|
|
77
|
+
...SETTINGS_FORM_LAYOUT,
|
|
78
|
+
...canUseCustomOrder ? [
|
|
79
|
+
CUSTOM_ORDER_FORM_LAYOUT
|
|
80
|
+
] : []
|
|
81
|
+
].map((row)=>row.map((field)=>{
|
|
73
82
|
if (field.type === 'enumeration') {
|
|
74
83
|
return {
|
|
75
84
|
...field,
|
|
85
|
+
// The custom order takes over the default sort of the list
|
|
86
|
+
disabled: canUseCustomOrder && hasCustomOrder && isDefaultSortField(field.name),
|
|
76
87
|
hint: field.hint ? formatMessage(field.hint) : undefined,
|
|
77
88
|
label: formatMessage(field.label),
|
|
78
89
|
options: field.name === 'settings.defaultSortBy' ? sortOptionsSorted : field.options
|
|
@@ -85,7 +96,9 @@ const Settings = ()=>{
|
|
|
85
96
|
};
|
|
86
97
|
}
|
|
87
98
|
})), [
|
|
99
|
+
canUseCustomOrder,
|
|
88
100
|
formatMessage,
|
|
101
|
+
hasCustomOrder,
|
|
89
102
|
sortOptionsSorted
|
|
90
103
|
]);
|
|
91
104
|
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
|
|
@@ -197,6 +210,22 @@ const SETTINGS_FORM_LAYOUT = [
|
|
|
197
210
|
}
|
|
198
211
|
]
|
|
199
212
|
];
|
|
213
|
+
const CUSTOM_ORDER_FORM_LAYOUT = [
|
|
214
|
+
{
|
|
215
|
+
hint: {
|
|
216
|
+
id: translations.getTranslation('form.Input.customOrder.hint'),
|
|
217
|
+
defaultMessage: 'Arrange entries by hand in the list view. New entries are added on top. The Content API returns entries in this order when no sort is requested.'
|
|
218
|
+
},
|
|
219
|
+
label: {
|
|
220
|
+
id: translations.getTranslation('form.Input.customOrder'),
|
|
221
|
+
defaultMessage: 'Enable custom order'
|
|
222
|
+
},
|
|
223
|
+
name: 'settings.customOrder',
|
|
224
|
+
size: 6,
|
|
225
|
+
type: 'boolean'
|
|
226
|
+
}
|
|
227
|
+
];
|
|
228
|
+
const isDefaultSortField = (name)=>name === 'settings.defaultSortBy' || name === 'settings.defaultSortOrder';
|
|
200
229
|
|
|
201
230
|
exports.Settings = Settings;
|
|
202
231
|
//# sourceMappingURL=Settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.js","sources":["../../../../../admin/src/pages/ListConfiguration/components/Settings.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useForm, InputRenderer, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Flex, Grid, Typography, useCollator } from '@strapi/design-system';\nimport { type MessageDescriptor, useIntl } from 'react-intl';\n\nimport { useDoc } from '../../../hooks/useDocument';\nimport { type EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport { getTranslation } from '../../../utils/translations';\nimport { type FormData } from '../ListConfigurationPage';\n\nimport type { DistributiveOmit } from 'react-redux';\n\nexport type InputPropsWithMessageDescriptors = DistributiveOmit<\n InputProps,\n 'hint' | 'label' | 'placeholder'\n> & {\n hint?: MessageDescriptor;\n label: MessageDescriptor;\n placeholder?: MessageDescriptor;\n};\n\n/**\n * @internal\n * @description Form inputs are always displayed in a grid, so we need\n * to use the size property to determine how many columns the input should\n * take up.\n */\nexport type FormLayoutInputProps = InputPropsWithMessageDescriptors & { size: number };\n\nconst EXCLUDED_SORT_ATTRIBUTE_TYPES = new Set([\n 'media',\n 'richtext',\n 'dynamiczone',\n 'relation',\n 'component',\n 'json',\n 'blocks',\n]);\n\ninterface SortOption {\n value: string;\n label: string;\n}\n\nconst Settings = () => {\n const { formatMessage, locale } = useIntl();\n const formatter = useCollator(locale, {\n sensitivity: 'base',\n });\n const { schema } = useDoc();\n\n const layout = useForm<FormData['layout']>(\n 'Settings',\n (state) => (state.values as FormData).layout ?? []\n );\n const currentSortBy = useForm<FormData['settings']['defaultSortBy']>(\n 'Settings',\n (state) => (state.values as FormData).settings.defaultSortBy\n );\n const onChange = useForm('Settings', (state) => state.onChange);\n\n const sortOptions = React.useMemo(\n () =>\n Object.values(layout).reduce<SortOption[]>((acc, field) => {\n if (schema && !EXCLUDED_SORT_ATTRIBUTE_TYPES.has(schema.attributes[field.name].type)) {\n acc.push({\n value: field.name,\n label: typeof field.label !== 'string' ? formatMessage(field.label) : field.label,\n });\n }\n\n return acc;\n }, []),\n [formatMessage, layout, schema]\n );\n\n const sortOptionsSorted = sortOptions.sort((a, b) => formatter.compare(a.label, b.label));\n\n React.useEffect(() => {\n if (sortOptionsSorted.findIndex((opt) => opt.value === currentSortBy) === -1) {\n onChange('settings.defaultSortBy', sortOptionsSorted[0]?.value);\n }\n }, [currentSortBy, onChange, sortOptionsSorted]);\n\n const formLayout = React.useMemo(\n () =>\n SETTINGS_FORM_LAYOUT.map((row) =>\n row.map((field) => {\n if (field.type === 'enumeration') {\n return {\n ...field,\n hint: field.hint ? formatMessage(field.hint) : undefined,\n label: formatMessage(field.label),\n options: field.name === 'settings.defaultSortBy' ? sortOptionsSorted : field.options,\n };\n } else {\n return {\n ...field,\n hint: field.hint ? formatMessage(field.hint) : undefined,\n label: formatMessage(field.label),\n };\n }\n })\n ) as [top: EditFieldLayout[], bottom: EditFieldLayout[]],\n [formatMessage, sortOptionsSorted]\n );\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Typography variant=\"delta\" tag=\"h2\">\n {formatMessage({\n id: getTranslation('containers.SettingPage.settings'),\n defaultMessage: 'Settings',\n })}\n </Typography>\n <Grid.Root key=\"bottom\" gap={4}>\n {formLayout.map((row) =>\n row.map(({ size, ...field }) => (\n <Grid.Item key={field.name} xs={12} col={size} direction=\"column\" alignItems=\"stretch\">\n {/* @ts-expect-error – issue with EnumerationProps conflicting with InputProps */}\n <InputRenderer {...field} />\n </Grid.Item>\n ))\n )}\n </Grid.Root>\n </Flex>\n );\n};\n\nconst SETTINGS_FORM_LAYOUT: FormLayoutInputProps[][] = [\n [\n {\n label: {\n id: getTranslation('form.Input.search'),\n defaultMessage: 'Enable search',\n },\n name: 'settings.searchable',\n size: 4,\n type: 'boolean' as const,\n },\n {\n label: {\n id: getTranslation('form.Input.filters'),\n defaultMessage: 'Enable filters',\n },\n name: 'settings.filterable',\n size: 4,\n type: 'boolean' as const,\n },\n {\n label: {\n id: getTranslation('form.Input.bulkActions'),\n defaultMessage: 'Enable bulk actions',\n },\n name: 'settings.bulkable',\n size: 4,\n type: 'boolean' as const,\n },\n ],\n [\n {\n hint: {\n id: getTranslation('form.Input.pageEntries.inputDescription'),\n defaultMessage: 'Note: You can override this value in the Collection Type settings page.',\n },\n label: {\n id: getTranslation('form.Input.pageEntries'),\n defaultMessage: 'Entries per page',\n },\n name: 'settings.pageSize',\n options: ['10', '20', '50', '100'].map((value) => ({ value, label: value })),\n size: 6,\n type: 'enumeration' as const,\n },\n {\n label: {\n id: getTranslation('form.Input.defaultSort'),\n defaultMessage: 'Default sort attribute',\n },\n name: 'settings.defaultSortBy',\n options: [],\n size: 3,\n type: 'enumeration' as const,\n },\n {\n label: {\n id: getTranslation('form.Input.sort.order'),\n defaultMessage: 'Default sort order',\n },\n name: 'settings.defaultSortOrder',\n options: ['ASC', 'DESC'].map((value) => ({ value, label: value })),\n size: 3,\n type: 'enumeration' as const,\n },\n ],\n];\n\nexport { Settings };\n"],"names":["EXCLUDED_SORT_ATTRIBUTE_TYPES","Set","Settings","formatMessage","locale","useIntl","formatter","useCollator","sensitivity","schema","useDoc","layout","useForm","state","values","currentSortBy","settings","defaultSortBy","onChange","sortOptions","React","useMemo","Object","reduce","acc","field","has","attributes","name","type","push","value","label","sortOptionsSorted","sort","a","b","compare","useEffect","findIndex","opt","formLayout","SETTINGS_FORM_LAYOUT","map","row","hint","undefined","options","_jsxs","Flex","direction","alignItems","gap","_jsx","Typography","variant","tag","id","getTranslation","defaultMessage","Grid","Root","size","Item","xs","col","InputRenderer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAMA,6BAAAA,GAAgC,IAAIC,GAAAA,CAAI;AAC5C,IAAA,OAAA;AACA,IAAA,UAAA;AACA,IAAA,aAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD,CAAA,CAAA;AAOD,MAAMC,QAAAA,GAAW,IAAA;AACf,IAAA,MAAM,EAAEC,aAAa,EAAEC,MAAM,EAAE,GAAGC,iBAAAA,EAAAA;IAClC,MAAMC,SAAAA,GAAYC,yBAAYH,MAAAA,EAAQ;QACpCI,WAAAA,EAAa;AACf,KAAA,CAAA;IACA,MAAM,EAAEC,MAAM,EAAE,GAAGC,kBAAAA,EAAAA;IAEnB,MAAMC,MAAAA,GAASC,mBAAAA,CACb,UAAA,EACA,CAACC,KAAAA,GAAU,KAACA,CAAMC,MAAM,CAAcH,MAAM,IAAI,EAAE,CAAA;IAEpD,MAAMI,aAAAA,GAAgBH,mBAAAA,CACpB,UAAA,EACA,CAACC,KAAAA,GAAU,KAACA,CAAMC,MAAM,CAAcE,QAAQ,CAACC,aAAa,CAAA;AAE9D,IAAA,MAAMC,WAAWN,mBAAAA,CAAQ,UAAA,EAAY,CAACC,KAAAA,GAAUA,MAAMK,QAAQ,CAAA;AAE9D,IAAA,MAAMC,WAAAA,GAAcC,gBAAAA,CAAMC,OAAO,CAC/B,IACEC,MAAAA,CAAOR,MAAM,CAACH,MAAAA,CAAAA,CAAQY,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ACA3B,KAAAA,EAAO;AACLyB,gBAAAA,EAAAA,EAAIC,2BAAAA,CAAe,wBAAA,CAAA;gBACnBC,cAAAA,EAAgB;AAClB,aAAA;YACA/B,IAAAA,EAAM,mBAAA;YACNmB,OAAAA,EAAS;AAAC,gBAAA,IAAA;AAAM,gBAAA,IAAA;AAAM,gBAAA,IAAA;AAAM,gBAAA;AAAM,aAAA,CAACJ,GAAG,CAAC,CAACZ,KAAAA,IAAW;AAAEA,oBAAAA,KAAAA;oBAAOC,KAAAA,EAAOD;iBAAM,CAAA,CAAA;YACzE+B,IAAAA,EAAM,CAAA;YACNjC,IAAAA,EAAM;AACR,SAAA;AACA,QAAA;YACEG,KAAAA,EAAO;AACLyB,gBAAAA,EAAAA,EAAIC,2BAAAA,CAAe,wBAAA,CAAA;gBACnBC,cAAAA,EAAgB;AAClB,aAAA;YACA/B,IAAAA,EAAM,wBAAA;AACNmB,YAAAA,OAAAA,EAAS,EAAE;YACXe,IAAAA,EAAM,CAAA;YACNjC,IAAAA,EAAM;AACR,SAAA;AACA,QAAA;YACEG,KAAAA,EAAO;AACLyB,gBAAAA,EAAAA,EAAIC,2BAAAA,CAAe,uBAAA,CAAA;gBACnBC,cAAAA,EAAgB;AAClB,aAAA;YACA/B,IAAAA,EAAM,2BAAA;YACNmB,OAAAA,EAAS;AAAC,gBAAA,KAAA;AAAO,gBAAA;AAAO,aAAA,CAACJ,GAAG,CAAC,CAACZ,KAAAA,IAAW;AAAEA,oBAAAA,KAAAA;oBAAOC,KAAAA,EAAOD;iBAAM,CAAA,CAAA;YAC/D+B,IAAAA,EAAM,CAAA;YACNjC,IAAAA,EAAM;AACR;AACD;AACF,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"Settings.js","sources":["../../../../../admin/src/pages/ListConfiguration/components/Settings.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useForm, InputRenderer, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Flex, Grid, Typography, useCollator } from '@strapi/design-system';\nimport { type MessageDescriptor, useIntl } from 'react-intl';\n\nimport { COLLECTION_TYPES } from '../../../constants/collections';\nimport { isCustomOrderFeatureEnabled } from '../../../constants/customOrder';\nimport { useDoc } from '../../../hooks/useDocument';\nimport { type EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport { getTranslation } from '../../../utils/translations';\nimport { type FormData } from '../ListConfigurationPage';\n\nimport type { DistributiveOmit } from 'react-redux';\n\nexport type InputPropsWithMessageDescriptors = DistributiveOmit<\n InputProps,\n 'hint' | 'label' | 'placeholder'\n> & {\n hint?: MessageDescriptor;\n label: MessageDescriptor;\n placeholder?: MessageDescriptor;\n};\n\n/**\n * @internal\n * @description Form inputs are always displayed in a grid, so we need\n * to use the size property to determine how many columns the input should\n * take up.\n */\nexport type FormLayoutInputProps = InputPropsWithMessageDescriptors & { size: number };\n\nconst EXCLUDED_SORT_ATTRIBUTE_TYPES = new Set([\n 'media',\n 'richtext',\n 'dynamiczone',\n 'relation',\n 'component',\n 'json',\n 'blocks',\n]);\n\ninterface SortOption {\n value: string;\n label: string;\n}\n\nconst Settings = () => {\n const { formatMessage, locale } = useIntl();\n const formatter = useCollator(locale, {\n sensitivity: 'base',\n });\n const { schema, collectionType } = useDoc();\n\n const layout = useForm<FormData['layout']>(\n 'Settings',\n (state) => (state.values as FormData).layout ?? []\n );\n const hasCustomOrder = useForm<FormData['settings']['customOrder']>(\n 'Settings',\n (state) => (state.values as FormData).settings.customOrder\n );\n const canUseCustomOrder = collectionType === COLLECTION_TYPES && isCustomOrderFeatureEnabled();\n const currentSortBy = useForm<FormData['settings']['defaultSortBy']>(\n 'Settings',\n (state) => (state.values as FormData).settings.defaultSortBy\n );\n const onChange = useForm('Settings', (state) => state.onChange);\n\n const sortOptions = React.useMemo(\n () =>\n Object.values(layout).reduce<SortOption[]>((acc, field) => {\n if (schema && !EXCLUDED_SORT_ATTRIBUTE_TYPES.has(schema.attributes[field.name].type)) {\n acc.push({\n value: field.name,\n label: typeof field.label !== 'string' ? formatMessage(field.label) : field.label,\n });\n }\n\n return acc;\n }, []),\n [formatMessage, layout, schema]\n );\n\n const sortOptionsSorted = sortOptions.sort((a, b) => formatter.compare(a.label, b.label));\n\n React.useEffect(() => {\n if (sortOptionsSorted.findIndex((opt) => opt.value === currentSortBy) === -1) {\n onChange('settings.defaultSortBy', sortOptionsSorted[0]?.value);\n }\n }, [currentSortBy, onChange, sortOptionsSorted]);\n\n const formLayout = React.useMemo(\n () =>\n [...SETTINGS_FORM_LAYOUT, ...(canUseCustomOrder ? [CUSTOM_ORDER_FORM_LAYOUT] : [])].map(\n (row) =>\n row.map((field) => {\n if (field.type === 'enumeration') {\n return {\n ...field,\n // The custom order takes over the default sort of the list\n disabled: canUseCustomOrder && hasCustomOrder && isDefaultSortField(field.name),\n hint: field.hint ? formatMessage(field.hint) : undefined,\n label: formatMessage(field.label),\n options:\n field.name === 'settings.defaultSortBy' ? sortOptionsSorted : field.options,\n };\n } else {\n return {\n ...field,\n hint: field.hint ? formatMessage(field.hint) : undefined,\n label: formatMessage(field.label),\n };\n }\n })\n ) as EditFieldLayout[][],\n [canUseCustomOrder, formatMessage, hasCustomOrder, sortOptionsSorted]\n );\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={4}>\n <Typography variant=\"delta\" tag=\"h2\">\n {formatMessage({\n id: getTranslation('containers.SettingPage.settings'),\n defaultMessage: 'Settings',\n })}\n </Typography>\n <Grid.Root key=\"bottom\" gap={4}>\n {formLayout.map((row) =>\n row.map(({ size, ...field }) => (\n <Grid.Item key={field.name} xs={12} col={size} direction=\"column\" alignItems=\"stretch\">\n {/* @ts-expect-error – issue with EnumerationProps conflicting with InputProps */}\n <InputRenderer {...field} />\n </Grid.Item>\n ))\n )}\n </Grid.Root>\n </Flex>\n );\n};\n\nconst SETTINGS_FORM_LAYOUT: FormLayoutInputProps[][] = [\n [\n {\n label: {\n id: getTranslation('form.Input.search'),\n defaultMessage: 'Enable search',\n },\n name: 'settings.searchable',\n size: 4,\n type: 'boolean' as const,\n },\n {\n label: {\n id: getTranslation('form.Input.filters'),\n defaultMessage: 'Enable filters',\n },\n name: 'settings.filterable',\n size: 4,\n type: 'boolean' as const,\n },\n {\n label: {\n id: getTranslation('form.Input.bulkActions'),\n defaultMessage: 'Enable bulk actions',\n },\n name: 'settings.bulkable',\n size: 4,\n type: 'boolean' as const,\n },\n ],\n [\n {\n hint: {\n id: getTranslation('form.Input.pageEntries.inputDescription'),\n defaultMessage: 'Note: You can override this value in the Collection Type settings page.',\n },\n label: {\n id: getTranslation('form.Input.pageEntries'),\n defaultMessage: 'Entries per page',\n },\n name: 'settings.pageSize',\n options: ['10', '20', '50', '100'].map((value) => ({ value, label: value })),\n size: 6,\n type: 'enumeration' as const,\n },\n {\n label: {\n id: getTranslation('form.Input.defaultSort'),\n defaultMessage: 'Default sort attribute',\n },\n name: 'settings.defaultSortBy',\n options: [],\n size: 3,\n type: 'enumeration' as const,\n },\n {\n label: {\n id: getTranslation('form.Input.sort.order'),\n defaultMessage: 'Default sort order',\n },\n name: 'settings.defaultSortOrder',\n options: ['ASC', 'DESC'].map((value) => ({ value, label: value })),\n size: 3,\n type: 'enumeration' as const,\n },\n ],\n];\n\nconst CUSTOM_ORDER_FORM_LAYOUT: FormLayoutInputProps[] = [\n {\n hint: {\n id: getTranslation('form.Input.customOrder.hint'),\n defaultMessage:\n 'Arrange entries by hand in the list view. New entries are added on top. The Content API returns entries in this order when no sort is requested.',\n },\n label: {\n id: getTranslation('form.Input.customOrder'),\n defaultMessage: 'Enable custom order',\n },\n name: 'settings.customOrder',\n size: 6,\n type: 'boolean' as const,\n },\n];\n\nconst isDefaultSortField = (name: string) =>\n name === 'settings.defaultSortBy' || name === 'settings.defaultSortOrder';\n\nexport { Settings };\n"],"names":["EXCLUDED_SORT_ATTRIBUTE_TYPES","Set","Settings","formatMessage","locale","useIntl","formatter","useCollator","sensitivity","schema","collectionType","useDoc","layout","useForm","state","values","hasCustomOrder","settings","customOrder","canUseCustomOrder","COLLECTION_TYPES","isCustomOrderFeatureEnabled","currentSortBy","defaultSortBy","onChange","sortOptions","React","useMemo","Object","reduce","acc","field","has","attributes","name","type","push","value","label","sortOptionsSorted","sort","a","b","compare","useEffect","findIndex","opt","formLayout","SETTINGS_FORM_LAYOUT","CUSTOM_ORDER_FORM_LAYOUT","map","row","disabled","isDefaultSortField","hint","undefined","options","_jsxs","Flex","direction","alignItems","gap","_jsx","Typography","variant","tag","id","getTranslation","defaultMessage","Grid","Root","size","Item","xs","col","InputRenderer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAMA,6BAAAA,GAAgC,IAAIC,GAAAA,CAAI;AAC5C,IAAA,OAAA;AACA,IAAA,UAAA;AACA,IAAA,aAAA;AACA,IAAA,UAAA;AACA,IAAA,WAAA;AACA,IAAA,MAAA;AACA,IAAA;AACD,CAAA,CAAA;AAOD,MAAMC,QAAAA,GAAW,IAAA;AACf,IAAA,MAAM,EAAEC,aAAa,EAAEC,MAAM,EAAE,GAAGC,iBAAAA,EAAAA;IAClC,MAAMC,SAAAA,GAAYC,yBAAYH,MAAAA,EAAQ;QACpCI,WAAAA,EAAa;AACf,KAAA,CAAA;AACA,IAAA,MAAM,EAAEC,MAAM,EAAEC,cAAc,EAAE,GAAGC,kBAAAA,EAAAA;IAEnC,MAAMC,MAAAA,GAASC,mBAAAA,CACb,UAAA,EACA,CAACC,KAAAA,GAAU,KAACA,CAAMC,MAAM,CAAcH,MAAM,IAAI,EAAE,CAAA;IAEpD,MAAMI,cAAAA,GAAiBH,mBAAAA,CACrB,UAAA,EACA,CAACC,KAAAA,GAAU,KAACA,CAAMC,MAAM,CAAcE,QAAQ,CAACC,WAAW,CAAA;IAE5D,MAAMC,iBAAAA,GAAoBT,mBAAmBU,4BAAAA,IAAoBC,uCAAAA,EAAAA;IACjE,MAAMC,aAAAA,GAAgBT,mBAAAA,CACpB,UAAA,EACA,CAACC,KAAAA,GAAU,KAACA,CAAMC,MAAM,CAAcE,QA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