@strapi/content-manager 0.0.0-next.7899d7020477ed75611335b08da36306d04789a2 → 0.0.0-next.79130900d1d112764eefaff6719704e0a3384e09

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.
Files changed (170) hide show
  1. package/dist/admin/components/LeftMenu.js +13 -15
  2. package/dist/admin/components/LeftMenu.js.map +1 -1
  3. package/dist/admin/components/LeftMenu.mjs +14 -16
  4. package/dist/admin/components/LeftMenu.mjs.map +1 -1
  5. package/dist/admin/components/Widgets.js +19 -12
  6. package/dist/admin/components/Widgets.js.map +1 -1
  7. package/dist/admin/components/Widgets.mjs +20 -13
  8. package/dist/admin/components/Widgets.mjs.map +1 -1
  9. package/dist/admin/hooks/useDocumentActions.js +0 -3
  10. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  11. package/dist/admin/hooks/useDocumentActions.mjs +1 -4
  12. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  13. package/dist/admin/index.js +43 -24
  14. package/dist/admin/index.js.map +1 -1
  15. package/dist/admin/index.mjs +44 -25
  16. package/dist/admin/index.mjs.map +1 -1
  17. package/dist/admin/layout.js +1 -27
  18. package/dist/admin/layout.js.map +1 -1
  19. package/dist/admin/layout.mjs +2 -9
  20. package/dist/admin/layout.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/EditViewPage.js +13 -20
  22. package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
  23. package/dist/admin/pages/EditView/EditViewPage.mjs +14 -21
  24. package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/Blocker.js +18 -0
  26. package/dist/admin/pages/EditView/components/Blocker.js.map +1 -0
  27. package/dist/admin/pages/EditView/components/Blocker.mjs +16 -0
  28. package/dist/admin/pages/EditView/components/Blocker.mjs.map +1 -0
  29. package/dist/admin/pages/EditView/components/DocumentActions.js +18 -3
  30. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  31. package/dist/admin/pages/EditView/components/DocumentActions.mjs +19 -4
  32. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +4 -1
  34. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +4 -1
  36. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  37. package/dist/admin/pages/EditView/components/InputRenderer.js +20 -7
  38. package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
  39. package/dist/admin/pages/EditView/components/InputRenderer.mjs +20 -7
  40. package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
  41. package/dist/admin/pages/EditView/utils/data.js +34 -9
  42. package/dist/admin/pages/EditView/utils/data.js.map +1 -1
  43. package/dist/admin/pages/EditView/utils/data.mjs +34 -9
  44. package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
  45. package/dist/admin/pages/ListView/ListViewPage.js +10 -10
  46. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  47. package/dist/admin/pages/ListView/ListViewPage.mjs +11 -11
  48. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  49. package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js +12 -2
  50. package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js.map +1 -1
  51. package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs +12 -2
  52. package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs.map +1 -1
  53. package/dist/admin/pages/ListView/components/Filters.js +3 -1
  54. package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
  55. package/dist/admin/pages/ListView/components/Filters.mjs +3 -1
  56. package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
  57. package/dist/admin/preview/components/InputPopover.js +189 -0
  58. package/dist/admin/preview/components/InputPopover.js.map +1 -0
  59. package/dist/admin/preview/components/InputPopover.mjs +167 -0
  60. package/dist/admin/preview/components/InputPopover.mjs.map +1 -0
  61. package/dist/admin/preview/components/PreviewHeader.js +0 -1
  62. package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
  63. package/dist/admin/preview/components/PreviewHeader.mjs +0 -1
  64. package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
  65. package/dist/admin/preview/components/PreviewSidePanel.js +31 -4
  66. package/dist/admin/preview/components/PreviewSidePanel.js.map +1 -1
  67. package/dist/admin/preview/components/PreviewSidePanel.mjs +32 -5
  68. package/dist/admin/preview/components/PreviewSidePanel.mjs.map +1 -1
  69. package/dist/admin/preview/hooks/usePreviewInputManager.js +77 -0
  70. package/dist/admin/preview/hooks/usePreviewInputManager.js.map +1 -0
  71. package/dist/admin/preview/hooks/usePreviewInputManager.mjs +56 -0
  72. package/dist/admin/preview/hooks/usePreviewInputManager.mjs.map +1 -0
  73. package/dist/admin/preview/pages/Preview.js +172 -68
  74. package/dist/admin/preview/pages/Preview.js.map +1 -1
  75. package/dist/admin/preview/pages/Preview.mjs +174 -70
  76. package/dist/admin/preview/pages/Preview.mjs.map +1 -1
  77. package/dist/admin/preview/utils/constants.js +56 -0
  78. package/dist/admin/preview/utils/constants.js.map +1 -0
  79. package/dist/admin/preview/utils/constants.mjs +52 -0
  80. package/dist/admin/preview/utils/constants.mjs.map +1 -0
  81. package/dist/admin/preview/utils/fieldUtils.js +107 -0
  82. package/dist/admin/preview/utils/fieldUtils.js.map +1 -0
  83. package/dist/admin/preview/utils/fieldUtils.mjs +102 -0
  84. package/dist/admin/preview/utils/fieldUtils.mjs.map +1 -0
  85. package/dist/admin/preview/utils/getSendMessage.js +22 -0
  86. package/dist/admin/preview/utils/getSendMessage.js.map +1 -0
  87. package/dist/admin/preview/utils/getSendMessage.mjs +20 -0
  88. package/dist/admin/preview/utils/getSendMessage.mjs.map +1 -0
  89. package/dist/admin/preview/utils/previewScript.js +534 -0
  90. package/dist/admin/preview/utils/previewScript.js.map +1 -0
  91. package/dist/admin/preview/utils/previewScript.mjs +532 -0
  92. package/dist/admin/preview/utils/previewScript.mjs.map +1 -0
  93. package/dist/admin/services/api.js +2 -1
  94. package/dist/admin/services/api.js.map +1 -1
  95. package/dist/admin/services/api.mjs +2 -1
  96. package/dist/admin/services/api.mjs.map +1 -1
  97. package/dist/admin/services/documents.js +22 -12
  98. package/dist/admin/services/documents.js.map +1 -1
  99. package/dist/admin/services/documents.mjs +22 -12
  100. package/dist/admin/services/documents.mjs.map +1 -1
  101. package/dist/admin/services/homepage.js +2 -11
  102. package/dist/admin/services/homepage.js.map +1 -1
  103. package/dist/admin/services/homepage.mjs +3 -11
  104. package/dist/admin/services/homepage.mjs.map +1 -1
  105. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  106. package/dist/admin/src/pages/EditView/components/Blocker.d.ts +5 -0
  107. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +1 -1
  108. package/dist/admin/src/preview/components/InputPopover.d.ts +6 -0
  109. package/dist/admin/src/preview/hooks/usePreviewInputManager.d.ts +5 -0
  110. package/dist/admin/src/preview/pages/Preview.d.ts +12 -0
  111. package/dist/admin/src/preview/services/preview.d.ts +1 -1
  112. package/dist/admin/src/preview/utils/constants.d.ts +55 -0
  113. package/dist/admin/src/preview/utils/fieldUtils.d.ts +22 -0
  114. package/dist/admin/src/preview/utils/getSendMessage.d.ts +11 -0
  115. package/dist/admin/src/preview/utils/previewScript.d.ts +24 -0
  116. package/dist/admin/src/services/api.d.ts +1 -1
  117. package/dist/admin/src/services/components.d.ts +2 -2
  118. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  119. package/dist/admin/src/services/documents.d.ts +16 -16
  120. package/dist/admin/src/services/homepage.d.ts +2 -6
  121. package/dist/admin/src/services/init.d.ts +1 -1
  122. package/dist/admin/src/services/relations.d.ts +2 -2
  123. package/dist/admin/src/services/uid.d.ts +3 -3
  124. package/dist/admin/src/utils/api.d.ts +1 -1
  125. package/dist/admin/translations/en.json.js +10 -0
  126. package/dist/admin/translations/en.json.js.map +1 -1
  127. package/dist/admin/translations/en.json.mjs +10 -0
  128. package/dist/admin/translations/en.json.mjs.map +1 -1
  129. package/dist/admin/translations/es.json.js +1 -0
  130. package/dist/admin/translations/es.json.js.map +1 -1
  131. package/dist/admin/translations/es.json.mjs +1 -0
  132. package/dist/admin/translations/es.json.mjs.map +1 -1
  133. package/dist/admin/translations/fr.json.js +1 -0
  134. package/dist/admin/translations/fr.json.js.map +1 -1
  135. package/dist/admin/translations/fr.json.mjs +1 -0
  136. package/dist/admin/translations/fr.json.mjs.map +1 -1
  137. package/dist/admin/utils/api.js +1 -1
  138. package/dist/admin/utils/api.js.map +1 -1
  139. package/dist/admin/utils/api.mjs +1 -1
  140. package/dist/admin/utils/api.mjs.map +1 -1
  141. package/dist/admin/utils/validation.js +2 -1
  142. package/dist/admin/utils/validation.js.map +1 -1
  143. package/dist/admin/utils/validation.mjs +2 -1
  144. package/dist/admin/utils/validation.mjs.map +1 -1
  145. package/dist/server/history/services/lifecycles.js +20 -19
  146. package/dist/server/history/services/lifecycles.js.map +1 -1
  147. package/dist/server/history/services/lifecycles.mjs +20 -19
  148. package/dist/server/history/services/lifecycles.mjs.map +1 -1
  149. package/dist/server/homepage/services/homepage.js +3 -3
  150. package/dist/server/homepage/services/homepage.js.map +1 -1
  151. package/dist/server/homepage/services/homepage.mjs +3 -3
  152. package/dist/server/homepage/services/homepage.mjs.map +1 -1
  153. package/dist/server/preview/services/preview-config.js +5 -1
  154. package/dist/server/preview/services/preview-config.js.map +1 -1
  155. package/dist/server/preview/services/preview-config.mjs +5 -1
  156. package/dist/server/preview/services/preview-config.mjs.map +1 -1
  157. package/dist/server/preview/services/preview.js +4 -0
  158. package/dist/server/preview/services/preview.js.map +1 -1
  159. package/dist/server/preview/services/preview.mjs +4 -0
  160. package/dist/server/preview/services/preview.mjs.map +1 -1
  161. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  162. package/dist/server/src/homepage/services/homepage.d.ts.map +1 -1
  163. package/dist/server/src/preview/services/index.d.ts +1 -0
  164. package/dist/server/src/preview/services/index.d.ts.map +1 -1
  165. package/dist/server/src/preview/services/preview-config.d.ts +1 -0
  166. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -1
  167. package/dist/server/src/preview/services/preview.d.ts.map +1 -1
  168. package/dist/server/src/preview/utils.d.ts +1 -0
  169. package/dist/server/src/preview/utils.d.ts.map +1 -1
  170. package/package.json +5 -6
@@ -1 +1 @@
1
- {"version":3,"file":"Relations.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/Relations.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n type InputProps,\n useField,\n useForm,\n useNotification,\n useFocusInputField,\n useRBAC,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Combobox,\n ComboboxOption,\n Flex,\n IconButton,\n TextButton,\n Typography,\n VisuallyHidden,\n useComposedRefs,\n Link,\n Field,\n FlexComponent,\n BoxComponent,\n Loader,\n EmptyStateLayout,\n} from '@strapi/design-system';\nimport { Cross, Drag, ArrowClockwise, Link as LinkIcon, Plus, WarningCircle } from '@strapi/icons';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport pipe from 'lodash/fp/pipe';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { FixedSizeList, ListChildComponentProps } from 'react-window';\nimport { styled } from 'styled-components';\n\nimport { RelationDragPreviewProps } from '../../../../../components/DragPreviews/RelationDragPreview';\nimport { COLLECTION_TYPES } from '../../../../../constants/collections';\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { PERMISSIONS } from '../../../../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../../../../features/DocumentRBAC';\nimport { useDebounce } from '../../../../../hooks/useDebounce';\nimport { useDocument } from '../../../../../hooks/useDocument';\nimport { type DocumentMeta, useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { type EditFieldLayout } from '../../../../../hooks/useDocumentLayout';\nimport {\n DROP_SENSITIVITY,\n UseDragAndDropOptions,\n useDragAndDrop,\n} from '../../../../../hooks/useDragAndDrop';\nimport {\n useGetRelationsQuery,\n useLazySearchRelationsQuery,\n RelationResult,\n} from '../../../../../services/relations';\nimport { type MainField } from '../../../../../utils/attributes';\nimport { getRelationLabel } from '../../../../../utils/relations';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { DocumentStatus } from '../../DocumentStatus';\nimport { useComponent } from '../ComponentContext';\nimport { RelationModalRenderer, getCollectionType } from '../Relations/RelationModal';\n\nimport type { FindAvailable } from '../../../../../../../shared/contracts/relations';\nimport type { Schema } from '@strapi/types';\n\n/**\n * Remove a relation, whether it's been already saved or not.\n * It's used both in RelationsList, where the \"remove relation\" button is, and in the input,\n * because we sometimes need to remove a previous relation when selecting a new one.\n */\nfunction useHandleDisconnect(fieldName: string, consumerName: string) {\n const field = useField(fieldName);\n const removeFieldRow = useForm(consumerName, (state) => state.removeFieldRow);\n const addFieldRow = useForm(consumerName, (state) => state.addFieldRow);\n\n const handleDisconnect: ListItemProps['data']['handleDisconnect'] = (relation) => {\n if (field.value && field.value.connect) {\n /**\n * A relation will exist in the `connect` array _if_ it has\n * been added without saving. In this case, we just remove it\n * from the connect array\n */\n const indexOfRelationInConnectArray = field.value.connect.findIndex(\n (rel: NonNullable<RelationsFormValue['connect']>[number]) => rel.id === relation.id\n );\n\n if (indexOfRelationInConnectArray >= 0) {\n removeFieldRow(`${fieldName}.connect`, indexOfRelationInConnectArray);\n return;\n }\n }\n\n addFieldRow(`${fieldName}.disconnect`, {\n id: relation.id,\n apiData: {\n id: relation.id,\n documentId: relation.documentId,\n locale: relation.locale,\n },\n });\n };\n\n return handleDisconnect;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsField\n * -----------------------------------------------------------------------------------------------*/\n\nconst RELATIONS_TO_DISPLAY = 5;\nconst ONE_WAY_RELATIONS = ['oneWay', 'oneToOne', 'manyToOne', 'oneToManyMorph', 'oneToOneMorph'];\n\ntype RelationPosition =\n | (Pick<RelationResult, 'status' | 'locale'> & {\n before: string;\n end?: never;\n })\n | { end: boolean; before?: never; status?: never; locale?: never };\n\ninterface Relation extends Pick<RelationResult, 'documentId' | 'id' | 'locale' | 'status'> {\n href: string;\n label: string;\n position?: RelationPosition;\n __temp_key__: string;\n apiData?: {\n documentId: RelationResult['documentId'];\n id: RelationResult['id'];\n locale?: RelationResult['locale'];\n position: RelationPosition;\n // Added this property to prevent call useDocument with a not temporary relation (one already saved in the database)\n isTemporary?: boolean;\n };\n}\n\ninterface RelationsFieldProps\n extends Omit<Extract<EditFieldLayout, { type: 'relation' }>, 'size' | 'hint'>,\n Pick<InputProps, 'hint'> {}\n\nexport interface RelationsFormValue {\n connect?: Relation[];\n disconnect?: Pick<Relation, 'id'>[];\n}\n\n/**\n * TODO: we get a rather ugly flash when we remove a single relation from the list leaving\n * no other relations when we press save. The initial relation re-renders, probably because\n * of the lag in the Form cleaning it's \"disconnect\" array, whilst our data has not been invalidated.\n *\n * Could we invalidate relation data on the document actions? Should we?\n */\n\n/**\n * @internal\n * @description The relations field holds a lot of domain logic for handling relations which is rather complicated\n * At present we do not expose this to plugin developers, however, they are able to overwrite it themselves should\n * they wish to do so.\n */\nconst RelationsField = React.forwardRef<HTMLDivElement, RelationsFieldProps>(\n ({ disabled, label, ...props }, ref) => {\n const { currentDocument, currentDocumentMeta } = useDocumentContext('RelationsField');\n\n const [currentPage, setCurrentPage] = React.useState(1);\n\n // Use the documentId from the actual document, not the params (meta)\n const documentId = currentDocument.document?.documentId;\n\n const { formatMessage } = useIntl();\n\n const isMorph = props.attribute.relation.toLowerCase().includes('morph');\n const isDisabled = isMorph || disabled;\n\n const { componentId, componentUID } = useComponent('RelationsField', ({ uid, id }) => ({\n componentId: id,\n componentUID: uid,\n }));\n\n const isSubmitting = useForm('RelationsList', (state) => state.isSubmitting);\n\n React.useEffect(() => {\n setCurrentPage(1);\n }, [isSubmitting]);\n\n const component = componentUID && currentDocument.components[componentUID];\n /**\n * We'll always have a documentId in a created entry, so we look for a componentId first.\n * Same with `uid` and `documentModel`.\n * The componentId is empty when adding a new component in a repeatable. Let it be null to skip isRelatedToCurrentDocument\n */\n const model = component ? component.uid : currentDocumentMeta.model;\n const id = component ? componentId?.toString() : documentId;\n\n /**\n * The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.\n * Where the above example would a nested field within two components, however\n * we only require the field on the component not the complete path since we query\n * individual components. Therefore we split the string and take the last item.\n */\n const [targetField] = props.name.split('.').slice(-1);\n\n const schemaAttributes = component\n ? (component.attributes ?? {})\n : (currentDocument.schema?.attributes ?? {});\n\n /**\n * Confirm the target field is related to the current document.\n * Since relations can exist in a modal on top of the root document,\n * we need to ensure we are fetching relations for the correct document (root document vs related document),\n */\n const isRelatedToCurrentDocument =\n Object.values(schemaAttributes).filter(\n (attribute) =>\n attribute.type === 'relation' &&\n 'target' in attribute &&\n 'target' in props.attribute &&\n attribute.target === props.attribute.target\n ).length > 0;\n\n const { data, isLoading, isFetching } = useGetRelationsQuery(\n {\n model,\n targetField,\n // below we don't run the query if there is no id.\n id,\n params: {\n ...currentDocumentMeta.params,\n pageSize: RELATIONS_TO_DISPLAY,\n page: currentPage,\n },\n },\n {\n refetchOnMountOrArgChange: true,\n skip: !id || !isRelatedToCurrentDocument,\n selectFromResult: (result) => {\n return {\n ...result,\n data: {\n ...result.data,\n results: result.data?.results ? result.data.results : [],\n },\n };\n },\n }\n );\n\n const handleLoadMore = () => {\n setCurrentPage((prev) => prev + 1);\n };\n\n const field = useField(props.name);\n\n const isFetchingMoreRelations = isLoading || isFetching;\n\n const realServerRelationsCount =\n 'pagination' in data && data.pagination ? data.pagination.total : 0;\n\n /**\n * Items that are already connected, but reordered would be in\n * this list, so to get an accurate figure, we remove them.\n */\n const relationsConnected =\n (field.value?.connect ?? []).filter(\n (rel: Relation) => data.results.findIndex((relation) => relation.id === rel.id) === -1\n ).length ?? 0;\n const relationsDisconnected = field.value?.disconnect?.length ?? 0;\n\n const relationsCount = realServerRelationsCount + relationsConnected - relationsDisconnected;\n\n /**\n * This is it, the source of truth for reordering in conjunction with partial loading & updating\n * of relations. Relations on load are given __temp_key__ when fetched, because we don't want to\n * create brand new keys everytime the data updates, just keep adding them onto the newly loaded ones.\n */\n const relations = React.useMemo(() => {\n const ctx = {\n field: field.value,\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n href: `../${COLLECTION_TYPES}/${props.attribute.targetModel}`,\n mainField: props.mainField,\n };\n\n /**\n * Tidy up our data.\n */\n const transformations = pipe(\n removeConnected(ctx),\n removeDisconnected(ctx),\n addLabelAndHref(ctx)\n );\n\n const transformedRels = transformations([...data.results]);\n\n /**\n * THIS IS CRUCIAL. If you don't sort by the __temp_key__ which comes from fractional indexing\n * then the list will be in the wrong order.\n */\n return [...transformedRels, ...(field.value?.connect ?? [])].sort((a, b) => {\n if (a.__temp_key__ < b.__temp_key__) return -1;\n if (a.__temp_key__ > b.__temp_key__) return 1;\n return 0;\n });\n }, [\n data.results,\n field.value,\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n props.attribute.targetModel,\n props.mainField,\n ]);\n\n const handleDisconnect = useHandleDisconnect(props.name, 'RelationsField');\n\n const handleConnect: RelationsInputProps['onChange'] = (relation) => {\n const [lastItemInList] = relations.slice(-1);\n const item = {\n id: relation.id,\n apiData: {\n id: relation.id,\n documentId: relation.documentId,\n locale: relation.locale,\n isTemporary: true,\n },\n status: relation.status,\n /**\n * If there's a last item, that's the first key we use to generate out next one.\n */\n __temp_key__: generateNKeysBetween(lastItemInList?.__temp_key__ ?? null, null, 1)[0],\n // Fallback to `id` if there is no `mainField` value, which will overwrite the above `id` property with the exact same data.\n [props.mainField?.name ?? 'documentId']: relation[props.mainField?.name ?? 'documentId'],\n label: getRelationLabel(relation, props.mainField),\n // @ts-expect-error – targetModel does exist on the attribute, but it's not typed.\n href: `../${COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`,\n };\n\n if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {\n // Remove any existing relation so they can be replaced with the new one\n field.value?.connect?.forEach(handleDisconnect);\n relations.forEach(handleDisconnect);\n\n field.onChange(`${props.name}.connect`, [item]);\n } else {\n field.onChange(`${props.name}.connect`, [...(field.value?.connect ?? []), item]);\n }\n };\n\n return (\n <Flex\n ref={ref}\n direction=\"column\"\n gap={3}\n justifyContent=\"space-between\"\n alignItems=\"stretch\"\n wrap=\"wrap\"\n >\n <StyledFlex direction=\"column\" alignItems=\"start\" gap={2} width=\"100%\">\n <RelationsInput\n disabled={isDisabled}\n // NOTE: we should not default to using the documentId if the component is being created (componentUID is undefined)\n id={componentUID && component ? (componentId ? `${componentId}` : '') : documentId}\n label={`${label} ${relationsCount > 0 ? `(${relationsCount})` : ''}`}\n model={model}\n onChange={handleConnect}\n isRelatedToCurrentDocument={isRelatedToCurrentDocument}\n {...props}\n />\n {'pagination' in data &&\n data.pagination &&\n data.pagination.pageCount > data.pagination.page ? (\n <TextButton\n disabled={isFetchingMoreRelations}\n onClick={handleLoadMore}\n loading={isFetchingMoreRelations}\n startIcon={<ArrowClockwise />}\n // prevent the label from line-wrapping\n shrink={0}\n >\n {formatMessage({\n id: getTranslation('relation.loadMore'),\n defaultMessage: 'Load More',\n })}\n </TextButton>\n ) : null}\n </StyledFlex>\n <RelationsList\n data={relations}\n serverData={data.results}\n disabled={isDisabled}\n name={props.name}\n isLoading={isFetchingMoreRelations}\n relationType={props.attribute.relation}\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n targetModel={props.attribute.targetModel}\n mainField={props.mainField}\n />\n </Flex>\n );\n }\n);\n\n/**\n * TODO: this can be removed once we stop shipping Inputs with\n * labels wrapped round in DS@2.\n */\nconst StyledFlex = styled<FlexComponent>(Flex)`\n & > div {\n width: 100%;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Relation Transformations\n * -----------------------------------------------------------------------------------------------*/\n\ninterface TransformationContext extends Pick<RelationsFieldProps, 'mainField'> {\n field?: RelationsFormValue;\n href: string;\n}\n\n/**\n * If it's in the connected array, it can get out of our data array,\n * we'll be putting it back in later and sorting it anyway.\n */\nconst removeConnected =\n ({ field }: TransformationContext) =>\n (relations: RelationResult[]) => {\n return relations.filter((relation) => {\n const connectedRelations = field?.connect ?? [];\n\n return connectedRelations.findIndex((rel) => rel.id === relation.id) === -1;\n });\n };\n\n/**\n * @description Removes relations that are in the `disconnect` array of the field\n */\nconst removeDisconnected =\n ({ field }: TransformationContext) =>\n (relations: RelationResult[]): RelationResult[] =>\n relations.filter((relation) => {\n const disconnectedRelations = field?.disconnect ?? [];\n\n return disconnectedRelations.findIndex((rel) => rel.id === relation.id) === -1;\n });\n\n/**\n * @description Adds a label and href to the relation object we use this to render\n * a better UI where we can link to the relation and display a human-readable label.\n */\nconst addLabelAndHref =\n ({ mainField, href }: TransformationContext) =>\n (relations: RelationResult[]): Relation[] =>\n relations.map((relation) => {\n return {\n ...relation,\n // Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.\n [mainField?.name ?? 'documentId']: relation[mainField?.name ?? 'documentId'],\n label: getRelationLabel(relation, mainField),\n href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`,\n };\n });\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsInput\n * -----------------------------------------------------------------------------------------------*/\ninterface RelationsInputProps extends Omit<RelationsFieldProps, 'type'> {\n id?: string;\n model: string;\n isRelatedToCurrentDocument: boolean;\n onChange: (\n relation: Pick<RelationResult, 'documentId' | 'id' | 'locale' | 'status'> & {\n [key: string]: any;\n }\n ) => void;\n}\n\n/**\n * @description Contains all the logic for the combobox that can search\n * for relations and then add them to the field's connect array.\n */\nconst RelationsInput = ({\n hint,\n id,\n model,\n label,\n labelAction,\n name,\n mainField,\n placeholder,\n required,\n unique: _unique,\n 'aria-label': _ariaLabel,\n onChange,\n isRelatedToCurrentDocument,\n ...props\n}: RelationsInputProps) => {\n const [searchParams, setSearchParams] = React.useState({\n _q: '',\n page: 1,\n });\n const { toggleNotification } = useNotification();\n const { currentDocumentMeta } = useDocumentContext('RelationsInput');\n const { formatMessage } = useIntl();\n\n const field = useField<RelationsFormValue>(name);\n\n const searchParamsDebounced = useDebounce(searchParams, 300);\n const [searchForTrigger, { data, isLoading }] = useLazySearchRelationsQuery();\n\n /**\n * Because we're using a lazy query, we need to trigger the search\n * when the component mounts and when the search params change.\n * We also need to trigger the search when the field value changes\n * so that we can filter out the relations that are already connected.\n */\n React.useEffect(() => {\n /**\n * The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.\n * Where the above example would a nested field within two components, however\n * we only require the field on the component not the complete path since we query\n * individual components. Therefore we split the string and take the last item.\n */\n const [targetField] = name.split('.').slice(-1);\n\n // Return early if there is no relation to the document\n if (!isRelatedToCurrentDocument) return;\n\n searchForTrigger({\n model,\n targetField,\n params: {\n ...currentDocumentMeta.params,\n id: id ?? '',\n pageSize: 10,\n idsToInclude: field.value?.disconnect?.map((rel) => rel.id.toString()) ?? [],\n idsToOmit: field.value?.connect?.map((rel) => rel.id.toString()) ?? [],\n ...searchParamsDebounced,\n },\n });\n }, [\n field.value?.connect,\n field.value?.disconnect,\n id,\n model,\n name,\n searchForTrigger,\n searchParamsDebounced,\n isRelatedToCurrentDocument,\n currentDocumentMeta.params,\n ]);\n\n const hasNextPage = data?.pagination ? data.pagination.page < data.pagination.pageCount : false;\n\n const options = data?.results ?? [];\n\n const handleChange = (relationId?: string) => {\n if (!relationId) {\n return;\n }\n\n const relation = options.find((opt) => opt.id.toString() === relationId);\n\n if (!relation) {\n // This is very unlikely to happen, but it ensures we don't have any data for.\n console.error(\n \"You've tried to add a relation with an id that does not exist in the options you can see, this is likely a bug with Strapi. Please open an issue.\"\n );\n\n toggleNotification({\n message: formatMessage({\n id: getTranslation('relation.error-adding-relation'),\n defaultMessage: 'An error occurred while trying to add the relation.',\n }),\n type: 'danger',\n });\n\n return;\n }\n\n /**\n * You need to give this relation a correct _temp_key_ but\n * this component doesn't know about those ones, you can't rely\n * on the connect array because that doesn't hold items that haven't\n * moved. So use a callback to fill in the gaps when connecting.\n *\n */\n onChange(relation);\n };\n\n const relation = {\n collectionType: COLLECTION_TYPES,\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n model: props.attribute.targetModel,\n documentId: '',\n params: currentDocumentMeta.params,\n } as DocumentMeta;\n\n const {\n permissions = [],\n isLoading: isLoadingPermissions,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: relation.model,\n }))\n );\n\n if (error) {\n return (\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <EmptyStateLayout\n icon={<WarningCircle width=\"16rem\" />}\n content={formatMessage({\n id: 'anErrorOccurred',\n defaultMessage: 'Whoops! Something went wrong. Please, try again.',\n })}\n />\n </Flex>\n );\n }\n\n return (\n <Field.Root error={field.error} hint={hint} name={name} required={required}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <DocumentRBAC permissions={permissions} model={relation.model}>\n <RelationModalWithContext\n relation={relation}\n name={name}\n placeholder={placeholder}\n hasNextPage={hasNextPage}\n isLoadingPermissions={isLoadingPermissions}\n isLoadingSearchRelations={isLoading}\n handleChange={handleChange}\n setSearchParams={setSearchParams}\n data={data}\n mainField={mainField}\n fieldValue={field.value}\n {...props}\n />\n </DocumentRBAC>\n <Field.Error />\n <Field.Hint />\n </Field.Root>\n );\n};\n\ninterface RelationModalWithContextProps\n extends Omit<RelationsInputProps, 'onChange' | 'label' | 'model' | 'isRelatedToCurrentDocument'> {\n relation: DocumentMeta;\n hasNextPage: boolean;\n isLoadingSearchRelations: boolean;\n isLoadingPermissions: boolean;\n handleChange: (relationId?: string) => void;\n data?: FindAvailable.Response;\n fieldValue?: RelationsFormValue;\n setSearchParams: React.Dispatch<\n React.SetStateAction<{\n _q: string;\n page: number;\n }>\n >;\n}\n\nconst RelationModalWithContext = ({\n relation,\n name,\n placeholder,\n hasNextPage,\n isLoadingSearchRelations,\n isLoadingPermissions,\n handleChange,\n mainField,\n setSearchParams,\n fieldValue,\n data,\n ...props\n}: RelationModalWithContextProps) => {\n const [textValue, setTextValue] = React.useState<string | undefined>('');\n const { formatMessage } = useIntl();\n const canCreate = useDocumentRBAC('RelationModalWrapper', (state) => state.canCreate);\n const fieldRef = useFocusInputField<HTMLInputElement>(name);\n const { componentUID } = useComponent('RelationsField', ({ uid }) => ({\n componentUID: uid,\n }));\n\n const handleLoadMore = () => {\n if (!data || !data.pagination) {\n return;\n } else if (data.pagination.page < data.pagination.pageCount) {\n setSearchParams((s) => ({ ...s, page: s.page + 1 }));\n }\n };\n\n const options = data?.results ?? [];\n\n React.useLayoutEffect(() => {\n setTextValue('');\n }, [fieldValue]);\n\n const handleSearch = async (search: string) => {\n setSearchParams((s) => ({ ...s, _q: search, page: 1 }));\n };\n return (\n <RelationModalRenderer>\n {({ dispatch }) => (\n <Combobox\n ref={fieldRef}\n creatable=\"visible\"\n creatableDisabled={!canCreate}\n createMessage={() =>\n formatMessage({\n id: getTranslation('relation.create'),\n defaultMessage: 'Create a relation',\n })\n }\n onCreateOption={() => {\n if (canCreate) {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: {\n document: relation,\n shouldBypassConfirmation: false,\n fieldToConnect: name,\n fieldToConnectUID: componentUID,\n },\n });\n }\n }}\n creatableStartIcon={<Plus fill=\"neutral500\" />}\n name={name}\n autocomplete=\"list\"\n placeholder={\n placeholder ||\n formatMessage({\n id: getTranslation('relation.add'),\n defaultMessage: 'Add relation',\n })\n }\n hasMoreItems={hasNextPage}\n loading={isLoadingSearchRelations || isLoadingPermissions}\n onOpenChange={() => {\n handleSearch(textValue ?? '');\n }}\n noOptionsMessage={() =>\n formatMessage({\n id: getTranslation('relation.notAvailable'),\n defaultMessage: 'No relations available',\n })\n }\n loadingMessage={formatMessage({\n id: getTranslation('relation.isLoading'),\n defaultMessage: 'Relations are loading',\n })}\n onLoadMore={handleLoadMore}\n textValue={textValue}\n onChange={handleChange}\n onTextValueChange={(text) => {\n setTextValue(text);\n }}\n onInputChange={(event) => {\n handleSearch(event.currentTarget.value);\n }}\n {...props}\n >\n {options?.map((opt) => {\n const textValue = getRelationLabel(opt, mainField);\n\n return (\n <ComboboxOption key={opt.id} value={opt.id.toString()} textValue={textValue}>\n <Flex gap={2} justifyContent=\"space-between\">\n <Flex gap={2}>\n <LinkIcon fill=\"neutral500\" />\n <Typography ellipsis>{textValue}</Typography>\n </Flex>\n {opt.status ? <DocumentStatus status={opt.status} /> : null}\n </Flex>\n </ComboboxOption>\n );\n })}\n </Combobox>\n )}\n </RelationModalRenderer>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsList\n * -----------------------------------------------------------------------------------------------*/\nconst RELATION_ITEM_HEIGHT = 50;\nconst RELATION_GUTTER = 4;\n\ninterface RelationsListProps extends Pick<RelationsFieldProps, 'disabled' | 'name'> {\n data: Relation[];\n isLoading?: boolean;\n relationType: Schema.Attribute.RelationKind.Any;\n /**\n * The existing relations connected on the server. We need these to diff against.\n */\n serverData: RelationResult[];\n targetModel: string;\n mainField?: MainField;\n}\n\nconst RelationsList = ({\n data,\n serverData,\n disabled,\n name,\n isLoading,\n relationType,\n targetModel,\n mainField,\n}: RelationsListProps) => {\n const ariaDescriptionId = React.useId();\n const { formatMessage } = useIntl();\n const listRef = React.useRef<FixedSizeList>(null);\n const outerListRef = React.useRef<HTMLUListElement>(null);\n const [overflow, setOverflow] = React.useState<'top' | 'bottom' | 'top-bottom'>();\n const [liveText, setLiveText] = React.useState('');\n const field = useField(name);\n\n React.useEffect(() => {\n if (data.length <= RELATIONS_TO_DISPLAY) {\n return setOverflow(undefined);\n }\n\n const handleNativeScroll = (e: Event) => {\n const el = e.target as HTMLUListElement;\n const parentScrollContainerHeight = (el.parentNode as HTMLDivElement).scrollHeight;\n const maxScrollBottom = el.scrollHeight - el.scrollTop;\n\n if (el.scrollTop === 0) {\n return setOverflow('bottom');\n }\n\n if (maxScrollBottom === parentScrollContainerHeight) {\n return setOverflow('top');\n }\n\n return setOverflow('top-bottom');\n };\n\n const outerListRefCurrent = outerListRef?.current;\n\n if (!isLoading && data.length > 0 && outerListRefCurrent) {\n outerListRef.current.addEventListener('scroll', handleNativeScroll);\n }\n\n return () => {\n if (outerListRefCurrent) {\n outerListRefCurrent.removeEventListener('scroll', handleNativeScroll);\n }\n };\n }, [isLoading, data.length]);\n\n const getItemPos = (index: number) => `${index + 1} of ${data.length}`;\n\n const handleMoveItem: UseDragAndDropOptions['onMoveItem'] = (newIndex, oldIndex) => {\n const item = data[oldIndex];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.reorder'),\n defaultMessage: '{item}, moved. New position in list: {position}.',\n },\n {\n item: item.label ?? item.documentId,\n position: getItemPos(newIndex),\n }\n )\n );\n\n /**\n * Splicing mutates the array, so we need to create a new array\n */\n const newData = [...data];\n const currentRow = data[oldIndex];\n\n const startKey =\n oldIndex > newIndex ? newData[newIndex - 1]?.__temp_key__ : newData[newIndex]?.__temp_key__;\n const endKey =\n oldIndex > newIndex ? newData[newIndex]?.__temp_key__ : newData[newIndex + 1]?.__temp_key__;\n\n /**\n * We're moving the relation between two other relations, so\n * we need to generate a new key that keeps the order\n */\n const [newKey] = generateNKeysBetween(startKey, endKey, 1);\n\n newData.splice(oldIndex, 1);\n newData.splice(newIndex, 0, { ...currentRow, __temp_key__: newKey });\n\n /**\n * Now we diff against the server to understand what's different so we\n * can keep the connect array nice and tidy. It also needs reversing because\n * we reverse the relations from the server in the first place.\n */\n const connectedRelations = newData\n .reduce<Relation[]>((acc, relation, currentIndex, array) => {\n const relationOnServer = serverData.find((oldRelation) => oldRelation.id === relation.id);\n\n const relationInFront = array[currentIndex + 1];\n\n if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {\n const position = relationInFront\n ? {\n before: relationInFront.documentId,\n locale: relationInFront.locale,\n status:\n 'publishedAt' in relationInFront && relationInFront.publishedAt\n ? ('published' as Relation['status'])\n : ('draft' as Relation['status']),\n }\n : { end: true };\n\n const relationWithPosition: Relation = {\n ...relation,\n ...{\n apiData: {\n id: relation.id,\n documentId: relation.documentId ?? relation.apiData?.documentId ?? '',\n locale: relation.locale || relation.apiData?.locale,\n isTemporary: relation.apiData?.isTemporary,\n position,\n },\n },\n };\n\n return [...acc, relationWithPosition];\n }\n\n return acc;\n }, [])\n .toReversed();\n\n field.onChange(`${name}.connect`, connectedRelations);\n };\n\n const handleGrabItem: UseDragAndDropOptions['onGrabItem'] = (index) => {\n const item = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.grab-item'),\n defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`,\n },\n {\n item: item.label ?? item.documentId,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleDropItem: UseDragAndDropOptions['onDropItem'] = (index) => {\n const { href: _href, label, ...item } = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.drop-item'),\n defaultMessage: `{item}, dropped. Final position in list: {position}.`,\n },\n {\n item: label ?? item.documentId,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleCancel: UseDragAndDropOptions['onCancel'] = (index) => {\n const item = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.cancel-item'),\n defaultMessage: '{item}, dropped. Re-order cancelled.',\n },\n {\n item: item.label ?? item.documentId,\n }\n )\n );\n };\n\n const handleDisconnect = useHandleDisconnect(name, 'RelationsList');\n\n /**\n * These relation types will only ever have one item\n * in their list, so you can't reorder a single item!\n */\n const canReorder = !ONE_WAY_RELATIONS.includes(relationType);\n\n const dynamicListHeight =\n data.length > RELATIONS_TO_DISPLAY\n ? Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER) +\n RELATION_ITEM_HEIGHT / 2\n : Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER);\n\n return (\n <ShadowBox $overflowDirection={overflow}>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('dnd.instructions'),\n defaultMessage: `Press spacebar to grab and re-order`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n {/* @ts-expect-error – width is expected, but we've not needed to pass it before. */}\n <FixedSizeList\n height={dynamicListHeight}\n ref={listRef}\n outerRef={outerListRef}\n itemCount={data.length}\n itemSize={RELATION_ITEM_HEIGHT + RELATION_GUTTER}\n itemData={{\n ariaDescribedBy: ariaDescriptionId,\n canDrag: canReorder,\n disabled,\n handleCancel,\n handleDropItem,\n handleGrabItem,\n handleMoveItem,\n name,\n handleDisconnect,\n relations: data,\n targetModel,\n mainField,\n }}\n itemKey={(index) => data[index].id}\n innerElementType=\"ol\"\n >\n {ListItem}\n </FixedSizeList>\n </ShadowBox>\n );\n};\n\nconst ShadowBox = styled<BoxComponent>(Box)<{\n $overflowDirection?: 'top-bottom' | 'top' | 'bottom';\n}>`\n position: relative;\n overflow: hidden;\n flex: 1;\n\n &:before,\n &:after {\n position: absolute;\n width: 100%;\n height: 4px;\n z-index: 1;\n }\n\n &:before {\n /* TODO: as for DS Table component we would need this to be handled by the DS theme */\n content: '';\n background: linear-gradient(rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);\n top: 0;\n opacity: ${({ $overflowDirection }) =>\n $overflowDirection === 'top-bottom' || $overflowDirection === 'top' ? 1 : 0};\n transition: opacity 0.2s ease-in-out;\n }\n\n &:after {\n /* TODO: as for DS Table component we would need this to be handled by the DS theme */\n content: '';\n background: linear-gradient(0deg, rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);\n bottom: 0;\n opacity: ${({ $overflowDirection }) =>\n $overflowDirection === 'top-bottom' || $overflowDirection === 'bottom' ? 1 : 0};\n transition: opacity 0.2s ease-in-out;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * ListItem\n * -----------------------------------------------------------------------------------------------*/\n\ninterface ListItemProps extends Pick<ListChildComponentProps, 'style' | 'index'> {\n data: {\n ariaDescribedBy: string;\n canDrag?: boolean;\n disabled?: boolean;\n handleCancel: UseDragAndDropOptions['onCancel'];\n handleDropItem: UseDragAndDropOptions['onDropItem'];\n handleGrabItem: UseDragAndDropOptions['onGrabItem'];\n handleMoveItem: UseDragAndDropOptions['onMoveItem'];\n handleDisconnect: (relation: Relation) => void;\n name: string;\n relations: Relation[];\n targetModel: string;\n mainField?: MainField;\n };\n}\n\nconst ListItem = ({ data, index, style }: ListItemProps) => {\n const {\n ariaDescribedBy,\n canDrag = false,\n disabled = false,\n handleCancel,\n handleDisconnect,\n handleDropItem,\n handleGrabItem,\n handleMoveItem,\n name,\n relations,\n targetModel,\n mainField,\n } = data;\n const { currentDocumentMeta } = useDocumentContext('RelationsField');\n\n const { formatMessage } = useIntl();\n\n const {\n href,\n id,\n label: originalLabel,\n status: originalStatus,\n documentId,\n apiData,\n locale,\n } = relations[index];\n\n /**\n * The code above attempts to retrieve the updated value of a relation that has not yet been saved.\n * This is necessary when a relation modal is opened, and the mainField or its status is updated.\n * These changes need to be reflected in the initial relation field.\n */\n const collectionType = getCollectionType(href)!;\n const isTemporary = apiData?.isTemporary ?? false;\n const { document } = useDocument(\n {\n collectionType,\n model: targetModel,\n documentId: documentId ?? apiData?.documentId,\n params: currentDocumentMeta.params,\n },\n { skip: !isTemporary }\n );\n const label = isTemporary && document ? getRelationLabel(document, mainField) : originalLabel;\n const status = isTemporary && document ? document?.status : originalStatus;\n\n const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop<number, Omit<RelationDragPreviewProps, 'width'>, HTMLDivElement>(\n canDrag && !disabled,\n {\n type: `${ItemTypes.RELATION}_${name}`,\n index,\n item: {\n displayedValue: label,\n status,\n id: id,\n index,\n },\n onMoveItem: handleMoveItem,\n onDropItem: handleDropItem,\n onGrabItem: handleGrabItem,\n onCancel: handleCancel,\n dropSensitivity: DROP_SENSITIVITY.REGULAR,\n }\n );\n\n const composedRefs = useComposedRefs<HTMLDivElement>(relationRef, dragRef);\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage());\n }, [dragPreviewRef]);\n\n const safeDocumentId = documentId ?? apiData?.documentId;\n const safeLocale = locale ?? apiData?.locale ?? null;\n const documentMeta = React.useMemo(\n () =>\n ({\n documentId: safeDocumentId,\n model: targetModel,\n collectionType: getCollectionType(href)!,\n params: {\n locale: safeLocale,\n },\n }) as DocumentMeta,\n [safeDocumentId, href, safeLocale, targetModel]\n );\n\n return (\n <Box\n style={style}\n tag=\"li\"\n ref={dropRef}\n aria-describedby={ariaDescribedBy}\n cursor={canDrag ? 'all-scroll' : 'default'}\n >\n {isDragging ? (\n <RelationItemPlaceholder />\n ) : (\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={canDrag ? 2 : 4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background={disabled ? 'neutral150' : 'neutral0'}\n justifyContent=\"space-between\"\n ref={composedRefs}\n data-handler-id={handlerId}\n >\n <FlexWrapper gap={1}>\n {canDrag ? (\n <IconButton\n tag=\"div\"\n role=\"button\"\n tabIndex={0}\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.RelationInput.icon-button-aria-label'),\n defaultMessage: 'Drag',\n })}\n variant=\"ghost\"\n onKeyDown={handleKeyDown}\n disabled={disabled}\n >\n <Drag />\n </IconButton>\n ) : null}\n <Flex width=\"100%\" minWidth={0} gap={4} justifyContent=\"space-between\">\n <Box flex={1} minWidth={0} paddingTop={1} paddingBottom={1}>\n <RelationModalRenderer relation={documentMeta}>{label}</RelationModalRenderer>\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <Box paddingLeft={4}>\n <IconButton\n onClick={() => handleDisconnect(relations[index])}\n disabled={disabled}\n label={formatMessage({\n id: getTranslation('relation.disconnect'),\n defaultMessage: 'Remove',\n })}\n variant=\"ghost\"\n size=\"S\"\n >\n <Cross />\n </IconButton>\n </Box>\n </Flex>\n )}\n </Box>\n );\n};\n\nconst FlexWrapper = styled<FlexComponent>(Flex)`\n width: 100%;\n /* Used to prevent endAction to be pushed out of container */\n min-width: 0;\n\n & > div[role='button'] {\n cursor: all-scroll;\n }\n`;\n\nconst DisconnectButton = styled.button`\n svg path {\n fill: ${({ theme, disabled }) =>\n disabled ? theme.colors.neutral600 : theme.colors.neutral500};\n }\n\n &:hover svg path,\n &:focus svg path {\n fill: ${({ theme, disabled }) => !disabled && theme.colors.neutral600};\n }\n`;\n\nconst LinkEllipsis = styled(Link)`\n display: block;\n\n & > span {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: block;\n }\n`;\n\nconst RelationItemPlaceholder = () => (\n <Box\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderStyle=\"dashed\"\n borderColor=\"primary600\"\n borderWidth=\"1px\"\n background=\"primary100\"\n height={`calc(100% - ${RELATION_GUTTER}px)`}\n />\n);\n\nconst MemoizedRelationsField = React.memo(RelationsField);\n\nexport { MemoizedRelationsField as RelationsInput, FlexWrapper, DisconnectButton, LinkEllipsis };\nexport type { RelationsFieldProps };\n"],"names":["useHandleDisconnect","fieldName","consumerName","field","useField","removeFieldRow","useForm","state","addFieldRow","handleDisconnect","relation","value","connect","indexOfRelationInConnectArray","findIndex","rel","id","apiData","documentId","locale","RELATIONS_TO_DISPLAY","ONE_WAY_RELATIONS","RelationsField","React","forwardRef","disabled","label","props","ref","currentDocument","currentDocumentMeta","useDocumentContext","currentPage","setCurrentPage","useState","document","formatMessage","useIntl","isMorph","attribute","toLowerCase","includes","isDisabled","componentId","componentUID","useComponent","uid","isSubmitting","useEffect","component","components","model","toString","targetField","name","split","slice","schemaAttributes","attributes","schema","isRelatedToCurrentDocument","Object","values","filter","type","target","length","data","isLoading","isFetching","useGetRelationsQuery","params","pageSize","page","refetchOnMountOrArgChange","skip","selectFromResult","result","results","handleLoadMore","prev","isFetchingMoreRelations","realServerRelationsCount","pagination","total","relationsConnected","relationsDisconnected","disconnect","relationsCount","relations","useMemo","ctx","href","COLLECTION_TYPES","targetModel","mainField","transformations","pipe","removeConnected","removeDisconnected","addLabelAndHref","transformedRels","sort","a","b","__temp_key__","handleConnect","lastItemInList","item","isTemporary","status","generateNKeysBetween","getRelationLabel","forEach","onChange","_jsxs","Flex","direction","gap","justifyContent","alignItems","wrap","StyledFlex","width","_jsx","RelationsInput","pageCount","TextButton","onClick","loading","startIcon","ArrowClockwise","shrink","getTranslation","defaultMessage","RelationsList","serverData","relationType","styled","connectedRelations","disconnectedRelations","map","hint","labelAction","placeholder","required","unique","_unique","_ariaLabel","searchParams","setSearchParams","_q","toggleNotification","useNotification","searchParamsDebounced","useDebounce","searchForTrigger","useLazySearchRelationsQuery","idsToInclude","idsToOmit","hasNextPage","options","handleChange","relationId","find","opt","console","error","message","collectionType","permissions","isLoadingPermissions","useRBAC","PERMISSIONS","action","subject","height","EmptyStateLayout","icon","WarningCircle","content","Field","Root","Label","DocumentRBAC","RelationModalWithContext","isLoadingSearchRelations","fieldValue","Error","Hint","textValue","setTextValue","canCreate","useDocumentRBAC","fieldRef","useFocusInputField","s","useLayoutEffect","handleSearch","search","RelationModalRenderer","dispatch","Combobox","creatable","creatableDisabled","createMessage","onCreateOption","payload","shouldBypassConfirmation","fieldToConnect","fieldToConnectUID","creatableStartIcon","Plus","fill","autocomplete","hasMoreItems","onOpenChange","noOptionsMessage","loadingMessage","onLoadMore","onTextValueChange","text","onInputChange","event","currentTarget","ComboboxOption","LinkIcon","Typography","ellipsis","DocumentStatus","RELATION_ITEM_HEIGHT","RELATION_GUTTER","ariaDescriptionId","useId","listRef","useRef","outerListRef","overflow","setOverflow","liveText","setLiveText","undefined","handleNativeScroll","e","el","parentScrollContainerHeight","parentNode","scrollHeight","maxScrollBottom","scrollTop","outerListRefCurrent","current","addEventListener","removeEventListener","getItemPos","index","handleMoveItem","newIndex","oldIndex","position","newData","currentRow","startKey","endKey","newKey","splice","reduce","acc","currentIndex","array","relationOnServer","oldRelation","relationInFront","before","publishedAt","end","relationWithPosition","toReversed","handleGrabItem","handleDropItem","_href","handleCancel","canReorder","dynamicListHeight","Math","min","ShadowBox","$overflowDirection","VisuallyHidden","aria-live","FixedSizeList","outerRef","itemCount","itemSize","itemData","ariaDescribedBy","canDrag","itemKey","innerElementType","ListItem","Box","style","originalLabel","originalStatus","getCollectionType","useDocument","handlerId","isDragging","handleKeyDown","relationRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","ItemTypes","RELATION","displayedValue","onMoveItem","onDropItem","onGrabItem","onCancel","dropSensitivity","DROP_SENSITIVITY","REGULAR","composedRefs","useComposedRefs","getEmptyImage","safeDocumentId","safeLocale","documentMeta","tag","aria-describedby","cursor","RelationItemPlaceholder","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","data-handler-id","FlexWrapper","IconButton","role","tabIndex","withTooltip","variant","onKeyDown","Drag","minWidth","flex","size","Cross","DisconnectButton","button","theme","colors","neutral600","neutral500","LinkEllipsis","Link","borderStyle","borderWidth","MemoizedRelationsField","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA;;;;AAIC,IACD,SAASA,mBAAAA,CAAoBC,SAAiB,EAAEC,YAAoB,EAAA;AAClE,IAAA,MAAMC,QAAQC,QAASH,CAAAA,SAAAA,CAAAA;AACvB,IAAA,MAAMI,iBAAiBC,OAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMF,cAAc,CAAA;AAC5E,IAAA,MAAMG,cAAcF,OAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMC,WAAW,CAAA;AAEtE,IAAA,MAAMC,mBAA8D,CAACC,QAAAA,GAAAA;A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,CAAA;QACfC,WAAa,EAAA,CAAA;QACbC,YAAc,EAAA,CAAA;QACdC,SAAS,EAAA,IAAA;QACTwB,WAAY,EAAA,QAAA;QACZvB,WAAY,EAAA,YAAA;QACZwB,WAAY,EAAA,KAAA;QACZvB,UAAW,EAAA,YAAA;AACXpK,QAAAA,MAAAA,EAAQ,CAAC,YAAY,EAAEuD,eAAAA,CAAgB,GAAG;;AAIxCqI,MAAAA,sBAAAA,iBAAyBrV,KAAMsV,CAAAA,IAAI,CAACvV,cAAAA;;;;"}
1
+ {"version":3,"file":"Relations.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Relations/Relations.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n type InputProps,\n useField,\n useForm,\n useNotification,\n useFocusInputField,\n useRBAC,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Combobox,\n ComboboxOption,\n Flex,\n IconButton,\n TextButton,\n Typography,\n VisuallyHidden,\n useComposedRefs,\n Link,\n Field,\n FlexComponent,\n BoxComponent,\n Loader,\n EmptyStateLayout,\n} from '@strapi/design-system';\nimport { Cross, Drag, ArrowClockwise, Link as LinkIcon, Plus, WarningCircle } from '@strapi/icons';\nimport { generateNKeysBetween } from 'fractional-indexing';\nimport pipe from 'lodash/fp/pipe';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { FixedSizeList, ListChildComponentProps } from 'react-window';\nimport { styled } from 'styled-components';\n\nimport { RelationDragPreviewProps } from '../../../../../components/DragPreviews/RelationDragPreview';\nimport { COLLECTION_TYPES } from '../../../../../constants/collections';\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { PERMISSIONS } from '../../../../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../../../../features/DocumentRBAC';\nimport { useDebounce } from '../../../../../hooks/useDebounce';\nimport { useDocument } from '../../../../../hooks/useDocument';\nimport { type DocumentMeta, useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { type EditFieldLayout } from '../../../../../hooks/useDocumentLayout';\nimport {\n DROP_SENSITIVITY,\n UseDragAndDropOptions,\n useDragAndDrop,\n} from '../../../../../hooks/useDragAndDrop';\nimport {\n useGetRelationsQuery,\n useLazySearchRelationsQuery,\n RelationResult,\n} from '../../../../../services/relations';\nimport { type MainField } from '../../../../../utils/attributes';\nimport { getRelationLabel } from '../../../../../utils/relations';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { DocumentStatus } from '../../DocumentStatus';\nimport { useComponent } from '../ComponentContext';\nimport { RelationModalRenderer, getCollectionType } from '../Relations/RelationModal';\n\nimport type { FindAvailable } from '../../../../../../../shared/contracts/relations';\nimport type { Schema } from '@strapi/types';\n\n/**\n * Remove a relation, whether it's been already saved or not.\n * It's used both in RelationsList, where the \"remove relation\" button is, and in the input,\n * because we sometimes need to remove a previous relation when selecting a new one.\n */\nfunction useHandleDisconnect(fieldName: string, consumerName: string) {\n const field = useField(fieldName);\n const removeFieldRow = useForm(consumerName, (state) => state.removeFieldRow);\n const addFieldRow = useForm(consumerName, (state) => state.addFieldRow);\n\n const handleDisconnect: ListItemProps['data']['handleDisconnect'] = (relation) => {\n if (field.value && field.value.connect) {\n /**\n * A relation will exist in the `connect` array _if_ it has\n * been added without saving. In this case, we just remove it\n * from the connect array\n */\n const indexOfRelationInConnectArray = field.value.connect.findIndex(\n (rel: NonNullable<RelationsFormValue['connect']>[number]) => rel.id === relation.id\n );\n\n if (indexOfRelationInConnectArray >= 0) {\n removeFieldRow(`${fieldName}.connect`, indexOfRelationInConnectArray);\n return;\n }\n }\n\n addFieldRow(`${fieldName}.disconnect`, {\n id: relation.id,\n apiData: {\n id: relation.id,\n documentId: relation.documentId,\n locale: relation.locale,\n },\n });\n };\n\n return handleDisconnect;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsField\n * -----------------------------------------------------------------------------------------------*/\n\nconst RELATIONS_TO_DISPLAY = 5;\nconst ONE_WAY_RELATIONS = ['oneWay', 'oneToOne', 'manyToOne', 'oneToManyMorph', 'oneToOneMorph'];\n\ntype RelationPosition =\n | (Pick<RelationResult, 'status' | 'locale'> & {\n before: string;\n end?: never;\n })\n | { end: boolean; before?: never; status?: never; locale?: never };\n\ninterface Relation extends Pick<RelationResult, 'documentId' | 'id' | 'locale' | 'status'> {\n href: string;\n label: string;\n position?: RelationPosition;\n __temp_key__: string;\n apiData?: {\n documentId: RelationResult['documentId'];\n id: RelationResult['id'];\n locale?: RelationResult['locale'];\n position: RelationPosition;\n // Added this property to prevent call useDocument with a not temporary relation (one already saved in the database)\n isTemporary?: boolean;\n };\n}\n\ninterface RelationsFieldProps\n extends Omit<Extract<EditFieldLayout, { type: 'relation' }>, 'size' | 'hint'>,\n Pick<InputProps, 'hint'> {}\n\nexport interface RelationsFormValue {\n connect?: Relation[];\n disconnect?: Pick<Relation, 'id'>[];\n}\n\n/**\n * TODO: we get a rather ugly flash when we remove a single relation from the list leaving\n * no other relations when we press save. The initial relation re-renders, probably because\n * of the lag in the Form cleaning it's \"disconnect\" array, whilst our data has not been invalidated.\n *\n * Could we invalidate relation data on the document actions? Should we?\n */\n\n/**\n * @internal\n * @description The relations field holds a lot of domain logic for handling relations which is rather complicated\n * At present we do not expose this to plugin developers, however, they are able to overwrite it themselves should\n * they wish to do so.\n */\nconst RelationsField = React.forwardRef<HTMLDivElement, RelationsFieldProps>(\n ({ disabled, label, ...props }, ref) => {\n const { currentDocument, currentDocumentMeta } = useDocumentContext('RelationsField');\n\n const [currentPage, setCurrentPage] = React.useState(1);\n\n // Use the documentId from the actual document, not the params (meta)\n const documentId = currentDocument.document?.documentId;\n\n const { formatMessage } = useIntl();\n\n const isMorph = props.attribute.relation.toLowerCase().includes('morph');\n const isDisabled = isMorph || disabled;\n\n const { componentId, componentUID } = useComponent('RelationsField', ({ uid, id }) => ({\n componentId: id,\n componentUID: uid,\n }));\n\n const isSubmitting = useForm('RelationsList', (state) => state.isSubmitting);\n\n React.useEffect(() => {\n setCurrentPage(1);\n }, [isSubmitting]);\n\n const component = componentUID && currentDocument.components[componentUID];\n /**\n * We'll always have a documentId in a created entry, so we look for a componentId first.\n * Same with `uid` and `documentModel`.\n * The componentId is empty when adding a new component in a repeatable. Let it be null to skip isRelatedToCurrentDocument\n */\n const model = component ? component.uid : currentDocumentMeta.model;\n const id = component ? componentId?.toString() : documentId;\n\n /**\n * The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.\n * Where the above example would a nested field within two components, however\n * we only require the field on the component not the complete path since we query\n * individual components. Therefore we split the string and take the last item.\n */\n const [targetField] = props.name.split('.').slice(-1);\n\n const schemaAttributes = component\n ? (component.attributes ?? {})\n : (currentDocument.schema?.attributes ?? {});\n\n /**\n * Confirm the target field is related to the current document.\n * Since relations can exist in a modal on top of the root document,\n * we need to ensure we are fetching relations for the correct document (root document vs related document),\n */\n const isRelatedToCurrentDocument =\n Object.values(schemaAttributes).filter(\n (attribute) =>\n attribute.type === 'relation' &&\n 'target' in attribute &&\n 'target' in props.attribute &&\n attribute.target === props.attribute.target\n ).length > 0;\n\n const { data, isLoading, isFetching } = useGetRelationsQuery(\n {\n model,\n targetField,\n // below we don't run the query if there is no id.\n id,\n params: {\n ...currentDocumentMeta.params,\n pageSize: RELATIONS_TO_DISPLAY,\n page: currentPage,\n },\n },\n {\n refetchOnMountOrArgChange: true,\n skip: !id || !isRelatedToCurrentDocument,\n selectFromResult: (result) => {\n return {\n ...result,\n data: {\n ...result.data,\n results: result.data?.results ? result.data.results : [],\n },\n };\n },\n }\n );\n\n const handleLoadMore = () => {\n setCurrentPage((prev) => prev + 1);\n };\n\n const field = useField(props.name);\n\n const isFetchingMoreRelations = isLoading || isFetching;\n\n const realServerRelationsCount =\n 'pagination' in data && data.pagination ? data.pagination.total : 0;\n\n /**\n * Items that are already connected, but reordered would be in\n * this list, so to get an accurate figure, we remove them.\n */\n const relationsConnected =\n (field.value?.connect ?? []).filter(\n (rel: Relation) => data.results.findIndex((relation) => relation.id === rel.id) === -1\n ).length ?? 0;\n const relationsDisconnected = field.value?.disconnect?.length ?? 0;\n\n const relationsCount = realServerRelationsCount + relationsConnected - relationsDisconnected;\n\n /**\n * This is it, the source of truth for reordering in conjunction with partial loading & updating\n * of relations. Relations on load are given __temp_key__ when fetched, because we don't want to\n * create brand new keys everytime the data updates, just keep adding them onto the newly loaded ones.\n */\n const relations = React.useMemo(() => {\n const ctx = {\n field: field.value,\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n href: `../${COLLECTION_TYPES}/${props.attribute.targetModel}`,\n mainField: props.mainField,\n };\n\n /**\n * Tidy up our data.\n */\n const transformations = pipe(\n removeConnected(ctx),\n removeDisconnected(ctx),\n addLabelAndHref(ctx)\n );\n\n const transformedRels = transformations([...data.results]);\n\n /**\n * THIS IS CRUCIAL. If you don't sort by the __temp_key__ which comes from fractional indexing\n * then the list will be in the wrong order.\n */\n return [...transformedRels, ...(field.value?.connect ?? [])].sort((a, b) => {\n if (a.__temp_key__ < b.__temp_key__) return -1;\n if (a.__temp_key__ > b.__temp_key__) return 1;\n return 0;\n });\n }, [\n data.results,\n field.value,\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n props.attribute.targetModel,\n props.mainField,\n ]);\n\n const handleDisconnect = useHandleDisconnect(props.name, 'RelationsField');\n\n const handleConnect: RelationsInputProps['onChange'] = (relation) => {\n const [lastItemInList] = relations.slice(-1);\n const item = {\n id: relation.id,\n apiData: {\n id: relation.id,\n documentId: relation.documentId,\n locale: relation.locale,\n isTemporary: true,\n },\n status: relation.status,\n /**\n * If there's a last item, that's the first key we use to generate out next one.\n */\n __temp_key__: generateNKeysBetween(lastItemInList?.__temp_key__ ?? null, null, 1)[0],\n // Fallback to `id` if there is no `mainField` value, which will overwrite the above `id` property with the exact same data.\n [props.mainField?.name ?? 'documentId']: relation[props.mainField?.name ?? 'documentId'],\n label: getRelationLabel(relation, props.mainField),\n // @ts-expect-error – targetModel does exist on the attribute, but it's not typed.\n href: `../${COLLECTION_TYPES}/${props.attribute.targetModel}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`,\n };\n\n if (ONE_WAY_RELATIONS.includes(props.attribute.relation)) {\n // Remove any existing relation so they can be replaced with the new one\n field.value?.connect?.forEach(handleDisconnect);\n relations.forEach(handleDisconnect);\n\n field.onChange(`${props.name}.connect`, [item]);\n } else {\n field.onChange(`${props.name}.connect`, [...(field.value?.connect ?? []), item]);\n }\n };\n\n return (\n <Flex\n ref={ref}\n direction=\"column\"\n gap={3}\n justifyContent=\"space-between\"\n alignItems=\"stretch\"\n wrap=\"wrap\"\n >\n <StyledFlex direction=\"column\" alignItems=\"start\" gap={2} width=\"100%\">\n <RelationsInput\n disabled={isDisabled}\n // NOTE: we should not default to using the documentId if the component is being created (componentUID is undefined)\n id={componentUID && component ? (componentId ? `${componentId}` : '') : documentId}\n label={`${label} ${relationsCount > 0 ? `(${relationsCount})` : ''}`}\n model={model}\n onChange={handleConnect}\n isRelatedToCurrentDocument={isRelatedToCurrentDocument}\n {...props}\n />\n {'pagination' in data &&\n data.pagination &&\n data.pagination.pageCount > data.pagination.page ? (\n <TextButton\n disabled={isFetchingMoreRelations}\n onClick={handleLoadMore}\n loading={isFetchingMoreRelations}\n startIcon={<ArrowClockwise />}\n // prevent the label from line-wrapping\n shrink={0}\n >\n {formatMessage({\n id: getTranslation('relation.loadMore'),\n defaultMessage: 'Load More',\n })}\n </TextButton>\n ) : null}\n </StyledFlex>\n <RelationsList\n data={relations}\n serverData={data.results}\n disabled={isDisabled}\n name={props.name}\n isLoading={isFetchingMoreRelations}\n relationType={props.attribute.relation}\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n targetModel={props.attribute.targetModel}\n mainField={props.mainField}\n />\n </Flex>\n );\n }\n);\n\n/**\n * TODO: this can be removed once we stop shipping Inputs with\n * labels wrapped round in DS@2.\n */\nconst StyledFlex = styled<FlexComponent>(Flex)`\n & > div {\n width: 100%;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Relation Transformations\n * -----------------------------------------------------------------------------------------------*/\n\ninterface TransformationContext extends Pick<RelationsFieldProps, 'mainField'> {\n field?: RelationsFormValue;\n href: string;\n}\n\n/**\n * If it's in the connected array, it can get out of our data array,\n * we'll be putting it back in later and sorting it anyway.\n */\nconst removeConnected =\n ({ field }: TransformationContext) =>\n (relations: RelationResult[]) => {\n return relations.filter((relation) => {\n const connectedRelations = field?.connect ?? [];\n\n return connectedRelations.findIndex((rel) => rel.id === relation.id) === -1;\n });\n };\n\n/**\n * @description Removes relations that are in the `disconnect` array of the field\n */\nconst removeDisconnected =\n ({ field }: TransformationContext) =>\n (relations: RelationResult[]): RelationResult[] =>\n relations.filter((relation) => {\n const disconnectedRelations = field?.disconnect ?? [];\n\n return disconnectedRelations.findIndex((rel) => rel.id === relation.id) === -1;\n });\n\n/**\n * @description Adds a label and href to the relation object we use this to render\n * a better UI where we can link to the relation and display a human-readable label.\n */\nconst addLabelAndHref =\n ({ mainField, href }: TransformationContext) =>\n (relations: RelationResult[]): Relation[] =>\n relations.map((relation) => {\n return {\n ...relation,\n // Fallback to `id` if there is no `mainField` value, which will overwrite the above `documentId` property with the exact same data.\n [mainField?.name ?? 'documentId']: relation[mainField?.name ?? 'documentId'],\n label: getRelationLabel(relation, mainField),\n href: `${href}/${relation.documentId}?${relation.locale ? `plugins[i18n][locale]=${relation.locale}` : ''}`,\n };\n });\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsInput\n * -----------------------------------------------------------------------------------------------*/\ninterface RelationsInputProps extends Omit<RelationsFieldProps, 'type'> {\n id?: string;\n model: string;\n isRelatedToCurrentDocument: boolean;\n onChange: (\n relation: Pick<RelationResult, 'documentId' | 'id' | 'locale' | 'status'> & {\n [key: string]: any;\n }\n ) => void;\n}\n\n/**\n * @description Contains all the logic for the combobox that can search\n * for relations and then add them to the field's connect array.\n */\nconst RelationsInput = ({\n hint,\n id,\n model,\n label,\n labelAction,\n name,\n mainField,\n placeholder,\n required,\n unique: _unique,\n 'aria-label': _ariaLabel,\n onChange,\n isRelatedToCurrentDocument,\n ...props\n}: RelationsInputProps) => {\n const [searchParams, setSearchParams] = React.useState({\n _q: '',\n page: 1,\n });\n const { toggleNotification } = useNotification();\n const { currentDocumentMeta } = useDocumentContext('RelationsInput');\n const { formatMessage } = useIntl();\n\n const field = useField<RelationsFormValue>(name);\n\n const searchParamsDebounced = useDebounce(searchParams, 300);\n const [searchForTrigger, { data, isLoading }] = useLazySearchRelationsQuery();\n\n /**\n * Because we're using a lazy query, we need to trigger the search\n * when the component mounts and when the search params change.\n * We also need to trigger the search when the field value changes\n * so that we can filter out the relations that are already connected.\n */\n React.useEffect(() => {\n /**\n * The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.\n * Where the above example would a nested field within two components, however\n * we only require the field on the component not the complete path since we query\n * individual components. Therefore we split the string and take the last item.\n */\n const [targetField] = name.split('.').slice(-1);\n\n // Return early if there is no relation to the document\n if (!isRelatedToCurrentDocument) return;\n\n searchForTrigger({\n model,\n targetField,\n params: {\n ...currentDocumentMeta.params,\n id: id ?? '',\n pageSize: 10,\n idsToInclude: field.value?.disconnect?.map((rel) => rel.id.toString()) ?? [],\n idsToOmit: field.value?.connect?.map((rel) => rel.id.toString()) ?? [],\n ...searchParamsDebounced,\n },\n });\n }, [\n field.value?.connect,\n field.value?.disconnect,\n id,\n model,\n name,\n searchForTrigger,\n searchParamsDebounced,\n isRelatedToCurrentDocument,\n currentDocumentMeta.params,\n ]);\n\n const hasNextPage = data?.pagination ? data.pagination.page < data.pagination.pageCount : false;\n\n const options = data?.results ?? [];\n\n const handleChange = (relationId?: string) => {\n if (!relationId) {\n return;\n }\n\n const relation = options.find((opt) => opt.id.toString() === relationId);\n\n if (!relation) {\n // This is very unlikely to happen, but it ensures we don't have any data for.\n console.error(\n \"You've tried to add a relation with an id that does not exist in the options you can see, this is likely a bug with Strapi. Please open an issue.\"\n );\n\n toggleNotification({\n message: formatMessage({\n id: getTranslation('relation.error-adding-relation'),\n defaultMessage: 'An error occurred while trying to add the relation.',\n }),\n type: 'danger',\n });\n\n return;\n }\n\n /**\n * You need to give this relation a correct _temp_key_ but\n * this component doesn't know about those ones, you can't rely\n * on the connect array because that doesn't hold items that haven't\n * moved. So use a callback to fill in the gaps when connecting.\n *\n */\n onChange(relation);\n };\n\n const relation = {\n collectionType: COLLECTION_TYPES,\n // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.\n model: props.attribute.targetModel,\n documentId: '',\n params: currentDocumentMeta.params,\n } as DocumentMeta;\n\n const {\n permissions = [],\n isLoading: isLoadingPermissions,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: relation.model,\n }))\n );\n\n if (error) {\n return (\n <Flex alignItems=\"center\" height=\"100%\" justifyContent=\"center\">\n <EmptyStateLayout\n icon={<WarningCircle width=\"16rem\" />}\n content={formatMessage({\n id: 'anErrorOccurred',\n defaultMessage: 'Whoops! Something went wrong. Please, try again.',\n })}\n />\n </Flex>\n );\n }\n\n return (\n <Field.Root error={field.error} hint={hint} name={name} required={required}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <DocumentRBAC permissions={permissions} model={relation.model}>\n <RelationModalWithContext\n relation={relation}\n name={name}\n placeholder={placeholder}\n hasNextPage={hasNextPage}\n isLoadingPermissions={isLoadingPermissions}\n isLoadingSearchRelations={isLoading}\n handleChange={handleChange}\n setSearchParams={setSearchParams}\n data={data}\n mainField={mainField}\n fieldValue={field.value}\n {...props}\n />\n </DocumentRBAC>\n <Field.Error />\n <Field.Hint />\n </Field.Root>\n );\n};\n\ninterface RelationModalWithContextProps\n extends Omit<RelationsInputProps, 'onChange' | 'label' | 'model' | 'isRelatedToCurrentDocument'> {\n relation: DocumentMeta;\n hasNextPage: boolean;\n isLoadingSearchRelations: boolean;\n isLoadingPermissions: boolean;\n handleChange: (relationId?: string) => void;\n data?: FindAvailable.Response;\n fieldValue?: RelationsFormValue;\n setSearchParams: React.Dispatch<\n React.SetStateAction<{\n _q: string;\n page: number;\n }>\n >;\n}\n\nconst RelationModalWithContext = ({\n relation,\n name,\n placeholder,\n hasNextPage,\n isLoadingSearchRelations,\n isLoadingPermissions,\n handleChange,\n mainField,\n setSearchParams,\n fieldValue,\n data,\n ...props\n}: RelationModalWithContextProps) => {\n const [textValue, setTextValue] = React.useState<string | undefined>('');\n const { formatMessage } = useIntl();\n const canCreate = useDocumentRBAC('RelationModalWrapper', (state) => state.canCreate);\n const fieldRef = useFocusInputField<HTMLInputElement>(name);\n const { componentUID } = useComponent('RelationsField', ({ uid }) => ({\n componentUID: uid,\n }));\n\n const handleLoadMore = () => {\n if (!data || !data.pagination) {\n return;\n } else if (data.pagination.page < data.pagination.pageCount) {\n setSearchParams((s) => ({ ...s, page: s.page + 1 }));\n }\n };\n\n const options = data?.results ?? [];\n\n React.useLayoutEffect(() => {\n setTextValue('');\n }, [fieldValue]);\n\n const handleSearch = async (search: string) => {\n setSearchParams((s) => ({ ...s, _q: search, page: 1 }));\n };\n return (\n <RelationModalRenderer>\n {({ dispatch }) => (\n <Combobox\n ref={fieldRef}\n creatable=\"visible\"\n creatableDisabled={!canCreate}\n createMessage={() =>\n formatMessage({\n id: getTranslation('relation.create'),\n defaultMessage: 'Create a relation',\n })\n }\n onCreateOption={() => {\n if (canCreate) {\n dispatch({\n type: 'GO_TO_RELATION',\n payload: {\n document: relation,\n shouldBypassConfirmation: false,\n fieldToConnect: name,\n fieldToConnectUID: componentUID,\n },\n });\n }\n }}\n creatableStartIcon={<Plus fill=\"neutral500\" />}\n name={name}\n autocomplete={{ type: 'list', filter: 'contains' }}\n placeholder={\n placeholder ||\n formatMessage({\n id: getTranslation('relation.add'),\n defaultMessage: 'Add relation',\n })\n }\n hasMoreItems={hasNextPage}\n loading={isLoadingSearchRelations || isLoadingPermissions}\n onOpenChange={() => {\n handleSearch(textValue ?? '');\n }}\n noOptionsMessage={() =>\n formatMessage({\n id: getTranslation('relation.notAvailable'),\n defaultMessage: 'No relations available',\n })\n }\n loadingMessage={formatMessage({\n id: getTranslation('relation.isLoading'),\n defaultMessage: 'Relations are loading',\n })}\n onLoadMore={handleLoadMore}\n textValue={textValue}\n onChange={handleChange}\n onTextValueChange={(text) => {\n setTextValue(text);\n }}\n onInputChange={(event) => {\n handleSearch(event.currentTarget.value);\n }}\n {...props}\n >\n {options?.map((opt) => {\n const textValue = getRelationLabel(opt, mainField);\n\n return (\n <ComboboxOption key={opt.id} value={opt.id.toString()} textValue={textValue}>\n <Flex gap={2} justifyContent=\"space-between\">\n <Flex gap={2}>\n <LinkIcon fill=\"neutral500\" />\n <Typography ellipsis>{textValue}</Typography>\n </Flex>\n {opt.status ? <DocumentStatus status={opt.status} /> : null}\n </Flex>\n </ComboboxOption>\n );\n })}\n </Combobox>\n )}\n </RelationModalRenderer>\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * RelationsList\n * -----------------------------------------------------------------------------------------------*/\nconst RELATION_ITEM_HEIGHT = 50;\nconst RELATION_GUTTER = 4;\n\ninterface RelationsListProps extends Pick<RelationsFieldProps, 'disabled' | 'name'> {\n data: Relation[];\n isLoading?: boolean;\n relationType: Schema.Attribute.RelationKind.Any;\n /**\n * The existing relations connected on the server. We need these to diff against.\n */\n serverData: RelationResult[];\n targetModel: string;\n mainField?: MainField;\n}\n\nconst RelationsList = ({\n data,\n serverData,\n disabled,\n name,\n isLoading,\n relationType,\n targetModel,\n mainField,\n}: RelationsListProps) => {\n const ariaDescriptionId = React.useId();\n const { formatMessage } = useIntl();\n const listRef = React.useRef<FixedSizeList>(null);\n const outerListRef = React.useRef<HTMLUListElement>(null);\n const [overflow, setOverflow] = React.useState<'top' | 'bottom' | 'top-bottom'>();\n const [liveText, setLiveText] = React.useState('');\n const field = useField(name);\n\n React.useEffect(() => {\n if (data.length <= RELATIONS_TO_DISPLAY) {\n return setOverflow(undefined);\n }\n\n const handleNativeScroll = (e: Event) => {\n const el = e.target as HTMLUListElement;\n const parentScrollContainerHeight = (el.parentNode as HTMLDivElement).scrollHeight;\n const maxScrollBottom = el.scrollHeight - el.scrollTop;\n\n if (el.scrollTop === 0) {\n return setOverflow('bottom');\n }\n\n if (maxScrollBottom === parentScrollContainerHeight) {\n return setOverflow('top');\n }\n\n return setOverflow('top-bottom');\n };\n\n const outerListRefCurrent = outerListRef?.current;\n\n if (!isLoading && data.length > 0 && outerListRefCurrent) {\n outerListRef.current.addEventListener('scroll', handleNativeScroll);\n }\n\n return () => {\n if (outerListRefCurrent) {\n outerListRefCurrent.removeEventListener('scroll', handleNativeScroll);\n }\n };\n }, [isLoading, data.length]);\n\n const getItemPos = (index: number) => `${index + 1} of ${data.length}`;\n\n const handleMoveItem: UseDragAndDropOptions['onMoveItem'] = (newIndex, oldIndex) => {\n const item = data[oldIndex];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.reorder'),\n defaultMessage: '{item}, moved. New position in list: {position}.',\n },\n {\n item: item.label ?? item.documentId,\n position: getItemPos(newIndex),\n }\n )\n );\n\n /**\n * Splicing mutates the array, so we need to create a new array\n */\n const newData = [...data];\n const currentRow = data[oldIndex];\n\n const startKey =\n oldIndex > newIndex ? newData[newIndex - 1]?.__temp_key__ : newData[newIndex]?.__temp_key__;\n const endKey =\n oldIndex > newIndex ? newData[newIndex]?.__temp_key__ : newData[newIndex + 1]?.__temp_key__;\n\n /**\n * We're moving the relation between two other relations, so\n * we need to generate a new key that keeps the order\n */\n const [newKey] = generateNKeysBetween(startKey, endKey, 1);\n\n newData.splice(oldIndex, 1);\n newData.splice(newIndex, 0, { ...currentRow, __temp_key__: newKey });\n\n /**\n * Now we diff against the server to understand what's different so we\n * can keep the connect array nice and tidy. It also needs reversing because\n * we reverse the relations from the server in the first place.\n */\n const connectedRelations = newData\n .reduce<Relation[]>((acc, relation, currentIndex, array) => {\n const relationOnServer = serverData.find((oldRelation) => oldRelation.id === relation.id);\n\n const relationInFront = array[currentIndex + 1];\n\n if (!relationOnServer || relationOnServer.__temp_key__ !== relation.__temp_key__) {\n const position = relationInFront\n ? {\n before: relationInFront.documentId,\n locale: relationInFront.locale,\n status:\n 'publishedAt' in relationInFront && relationInFront.publishedAt\n ? ('published' as Relation['status'])\n : ('draft' as Relation['status']),\n }\n : { end: true };\n\n const relationWithPosition: Relation = {\n ...relation,\n ...{\n apiData: {\n id: relation.id,\n documentId: relation.documentId ?? relation.apiData?.documentId ?? '',\n locale: relation.locale || relation.apiData?.locale,\n isTemporary: relation.apiData?.isTemporary,\n position,\n },\n },\n };\n\n return [...acc, relationWithPosition];\n }\n\n return acc;\n }, [])\n .toReversed();\n\n field.onChange(`${name}.connect`, connectedRelations);\n };\n\n const handleGrabItem: UseDragAndDropOptions['onGrabItem'] = (index) => {\n const item = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.grab-item'),\n defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`,\n },\n {\n item: item.label ?? item.documentId,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleDropItem: UseDragAndDropOptions['onDropItem'] = (index) => {\n const { href: _href, label, ...item } = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.drop-item'),\n defaultMessage: `{item}, dropped. Final position in list: {position}.`,\n },\n {\n item: label ?? item.documentId,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleCancel: UseDragAndDropOptions['onCancel'] = (index) => {\n const item = data[index];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.cancel-item'),\n defaultMessage: '{item}, dropped. Re-order cancelled.',\n },\n {\n item: item.label ?? item.documentId,\n }\n )\n );\n };\n\n const handleDisconnect = useHandleDisconnect(name, 'RelationsList');\n\n /**\n * These relation types will only ever have one item\n * in their list, so you can't reorder a single item!\n */\n const canReorder = !ONE_WAY_RELATIONS.includes(relationType);\n\n const dynamicListHeight =\n data.length > RELATIONS_TO_DISPLAY\n ? Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER) +\n RELATION_ITEM_HEIGHT / 2\n : Math.min(data.length, RELATIONS_TO_DISPLAY) * (RELATION_ITEM_HEIGHT + RELATION_GUTTER);\n\n return (\n <ShadowBox $overflowDirection={overflow}>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('dnd.instructions'),\n defaultMessage: `Press spacebar to grab and re-order`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n {/* @ts-expect-error – width is expected, but we've not needed to pass it before. */}\n <FixedSizeList\n height={dynamicListHeight}\n ref={listRef}\n outerRef={outerListRef}\n itemCount={data.length}\n itemSize={RELATION_ITEM_HEIGHT + RELATION_GUTTER}\n itemData={{\n ariaDescribedBy: ariaDescriptionId,\n canDrag: canReorder,\n disabled,\n handleCancel,\n handleDropItem,\n handleGrabItem,\n handleMoveItem,\n name,\n handleDisconnect,\n relations: data,\n targetModel,\n mainField,\n }}\n itemKey={(index) => data[index].id}\n innerElementType=\"ol\"\n >\n {ListItem}\n </FixedSizeList>\n </ShadowBox>\n );\n};\n\nconst ShadowBox = styled<BoxComponent>(Box)<{\n $overflowDirection?: 'top-bottom' | 'top' | 'bottom';\n}>`\n position: relative;\n overflow: hidden;\n flex: 1;\n\n &:before,\n &:after {\n position: absolute;\n width: 100%;\n height: 4px;\n z-index: 1;\n }\n\n &:before {\n /* TODO: as for DS Table component we would need this to be handled by the DS theme */\n content: '';\n background: linear-gradient(rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);\n top: 0;\n opacity: ${({ $overflowDirection }) =>\n $overflowDirection === 'top-bottom' || $overflowDirection === 'top' ? 1 : 0};\n transition: opacity 0.2s ease-in-out;\n }\n\n &:after {\n /* TODO: as for DS Table component we would need this to be handled by the DS theme */\n content: '';\n background: linear-gradient(0deg, rgba(3, 3, 5, 0.2) 0%, rgba(0, 0, 0, 0) 100%);\n bottom: 0;\n opacity: ${({ $overflowDirection }) =>\n $overflowDirection === 'top-bottom' || $overflowDirection === 'bottom' ? 1 : 0};\n transition: opacity 0.2s ease-in-out;\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * ListItem\n * -----------------------------------------------------------------------------------------------*/\n\ninterface ListItemProps extends Pick<ListChildComponentProps, 'style' | 'index'> {\n data: {\n ariaDescribedBy: string;\n canDrag?: boolean;\n disabled?: boolean;\n handleCancel: UseDragAndDropOptions['onCancel'];\n handleDropItem: UseDragAndDropOptions['onDropItem'];\n handleGrabItem: UseDragAndDropOptions['onGrabItem'];\n handleMoveItem: UseDragAndDropOptions['onMoveItem'];\n handleDisconnect: (relation: Relation) => void;\n name: string;\n relations: Relation[];\n targetModel: string;\n mainField?: MainField;\n };\n}\n\nconst ListItem = ({ data, index, style }: ListItemProps) => {\n const {\n ariaDescribedBy,\n canDrag = false,\n disabled = false,\n handleCancel,\n handleDisconnect,\n handleDropItem,\n handleGrabItem,\n handleMoveItem,\n name,\n relations,\n targetModel,\n mainField,\n } = data;\n const { currentDocumentMeta } = useDocumentContext('RelationsField');\n\n const { formatMessage } = useIntl();\n\n const {\n href,\n id,\n label: originalLabel,\n status: originalStatus,\n documentId,\n apiData,\n locale,\n } = relations[index];\n\n /**\n * The code above attempts to retrieve the updated value of a relation that has not yet been saved.\n * This is necessary when a relation modal is opened, and the mainField or its status is updated.\n * These changes need to be reflected in the initial relation field.\n */\n const collectionType = getCollectionType(href)!;\n const isTemporary = apiData?.isTemporary ?? false;\n const { document } = useDocument(\n {\n collectionType,\n model: targetModel,\n documentId: documentId ?? apiData?.documentId,\n params: currentDocumentMeta.params,\n },\n { skip: !isTemporary }\n );\n const label = isTemporary && document ? getRelationLabel(document, mainField) : originalLabel;\n const status = isTemporary && document ? document?.status : originalStatus;\n\n const [{ handlerId, isDragging, handleKeyDown }, relationRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop<number, Omit<RelationDragPreviewProps, 'width'>, HTMLDivElement>(\n canDrag && !disabled,\n {\n type: `${ItemTypes.RELATION}_${name}`,\n index,\n item: {\n displayedValue: label,\n status,\n id: id,\n index,\n },\n onMoveItem: handleMoveItem,\n onDropItem: handleDropItem,\n onGrabItem: handleGrabItem,\n onCancel: handleCancel,\n dropSensitivity: DROP_SENSITIVITY.REGULAR,\n }\n );\n\n const composedRefs = useComposedRefs<HTMLDivElement>(relationRef, dragRef);\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage());\n }, [dragPreviewRef]);\n\n const safeDocumentId = documentId ?? apiData?.documentId;\n const safeLocale = locale ?? apiData?.locale ?? null;\n const documentMeta = React.useMemo(\n () =>\n ({\n documentId: safeDocumentId,\n model: targetModel,\n collectionType: getCollectionType(href)!,\n params: {\n locale: safeLocale,\n },\n }) as DocumentMeta,\n [safeDocumentId, href, safeLocale, targetModel]\n );\n\n return (\n <Box\n style={style}\n tag=\"li\"\n ref={dropRef}\n aria-describedby={ariaDescribedBy}\n cursor={canDrag ? 'all-scroll' : 'default'}\n >\n {isDragging ? (\n <RelationItemPlaceholder />\n ) : (\n <Flex\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={canDrag ? 2 : 4}\n paddingRight={4}\n hasRadius\n borderColor=\"neutral200\"\n background={disabled ? 'neutral150' : 'neutral0'}\n justifyContent=\"space-between\"\n ref={composedRefs}\n data-handler-id={handlerId}\n >\n <FlexWrapper gap={1}>\n {canDrag ? (\n <IconButton\n tag=\"div\"\n role=\"button\"\n tabIndex={0}\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.RelationInput.icon-button-aria-label'),\n defaultMessage: 'Drag',\n })}\n variant=\"ghost\"\n onKeyDown={handleKeyDown}\n disabled={disabled}\n >\n <Drag />\n </IconButton>\n ) : null}\n <Flex width=\"100%\" minWidth={0} gap={4} justifyContent=\"space-between\">\n <Box flex={1} minWidth={0} paddingTop={1} paddingBottom={1}>\n <RelationModalRenderer relation={documentMeta}>{label}</RelationModalRenderer>\n </Box>\n {status ? <DocumentStatus status={status} /> : null}\n </Flex>\n </FlexWrapper>\n <Box paddingLeft={4}>\n <IconButton\n onClick={() => handleDisconnect(relations[index])}\n disabled={disabled}\n label={formatMessage({\n id: getTranslation('relation.disconnect'),\n defaultMessage: 'Remove',\n })}\n variant=\"ghost\"\n size=\"S\"\n >\n <Cross />\n </IconButton>\n </Box>\n </Flex>\n )}\n </Box>\n );\n};\n\nconst FlexWrapper = styled<FlexComponent>(Flex)`\n width: 100%;\n /* Used to prevent endAction to be pushed out of container */\n min-width: 0;\n\n & > div[role='button'] {\n cursor: all-scroll;\n }\n`;\n\nconst DisconnectButton = styled.button`\n svg path {\n fill: ${({ theme, disabled }) =>\n disabled ? theme.colors.neutral600 : theme.colors.neutral500};\n }\n\n &:hover svg path,\n &:focus svg path {\n fill: ${({ theme, disabled }) => !disabled && theme.colors.neutral600};\n }\n`;\n\nconst LinkEllipsis = styled(Link)`\n display: block;\n\n & > span {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n display: block;\n }\n`;\n\nconst RelationItemPlaceholder = () => (\n <Box\n paddingTop={2}\n paddingBottom={2}\n paddingLeft={4}\n paddingRight={4}\n hasRadius\n borderStyle=\"dashed\"\n borderColor=\"primary600\"\n borderWidth=\"1px\"\n background=\"primary100\"\n height={`calc(100% - ${RELATION_GUTTER}px)`}\n />\n);\n\nconst MemoizedRelationsField = React.memo(RelationsField);\n\nexport { MemoizedRelationsField as RelationsInput, FlexWrapper, DisconnectButton, LinkEllipsis };\nexport type { RelationsFieldProps };\n"],"names":["useHandleDisconnect","fieldName","consumerName","field","useField","removeFieldRow","useForm","state","addFieldRow","handleDisconnect","relation","value","connect","indexOfRelationInConnectArray","findIndex","rel","id","apiData","documentId","locale","RELATIONS_TO_DISPLAY","ONE_WAY_RELATIONS","RelationsField","React","forwardRef","disabled","label","props","ref","currentDocument","currentDocumentMeta","useDocumentContext","currentPage","setCurrentPage","useState","document","formatMessage","useIntl","isMorph","attribute","toLowerCase","includes","isDisabled","componentId","componentUID","useComponent","uid","isSubmitting","useEffect","component","components","model","toString","targetField","name","split","slice","schemaAttributes","attributes","schema","isRelatedToCurrentDocument","Object","values","filter","type","target","length","data","isLoading","isFetching","useGetRelationsQuery","params","pageSize","page","refetchOnMountOrArgChange","skip","selectFromResult","result","results","handleLoadMore","prev","isFetchingMoreRelations","realServerRelationsCount","pagination","total","relationsConnected","relationsDisconnected","disconnect","relationsCount","relations","useMemo","ctx","href","COLLECTION_TYPES","targetModel","mainField","transformations","pipe","removeConnected","removeDisconnected","addLabelAndHref","transformedRels","sort","a","b","__temp_key__","handleConnect","lastItemInList","item","isTemporary","status","generateNKeysBetween","getRelationLabel","forEach","onChange","_jsxs","Flex","direction","gap","justifyContent","alignItems","wrap","StyledFlex","width","_jsx","RelationsInput","pageCount","TextButton","onClick","loading","startIcon","ArrowClockwise","shrink","getTranslation","defaultMessage","RelationsList","serverData","relationType","styled","connectedRelations","disconnectedRelations","map","hint","labelAction","placeholder","required","unique","_unique","_ariaLabel","searchParams","setSearchParams","_q","toggleNotification","useNotification","searchParamsDebounced","useDebounce","searchForTrigger","useLazySearchRelationsQuery","idsToInclude","idsToOmit","hasNextPage","options","handleChange","relationId","find","opt","console","error","message","collectionType","permissions","isLoadingPermissions","useRBAC","PERMISSIONS","action","subject","height","EmptyStateLayout","icon","WarningCircle","content","Field","Root","Label","DocumentRBAC","RelationModalWithContext","isLoadingSearchRelations","fieldValue","Error","Hint","textValue","setTextValue","canCreate","useDocumentRBAC","fieldRef","useFocusInputField","s","useLayoutEffect","handleSearch","search","RelationModalRenderer","dispatch","Combobox","creatable","creatableDisabled","createMessage","onCreateOption","payload","shouldBypassConfirmation","fieldToConnect","fieldToConnectUID","creatableStartIcon","Plus","fill","autocomplete","hasMoreItems","onOpenChange","noOptionsMessage","loadingMessage","onLoadMore","onTextValueChange","text","onInputChange","event","currentTarget","ComboboxOption","LinkIcon","Typography","ellipsis","DocumentStatus","RELATION_ITEM_HEIGHT","RELATION_GUTTER","ariaDescriptionId","useId","listRef","useRef","outerListRef","overflow","setOverflow","liveText","setLiveText","undefined","handleNativeScroll","e","el","parentScrollContainerHeight","parentNode","scrollHeight","maxScrollBottom","scrollTop","outerListRefCurrent","current","addEventListener","removeEventListener","getItemPos","index","handleMoveItem","newIndex","oldIndex","position","newData","currentRow","startKey","endKey","newKey","splice","reduce","acc","currentIndex","array","relationOnServer","oldRelation","relationInFront","before","publishedAt","end","relationWithPosition","toReversed","handleGrabItem","handleDropItem","_href","handleCancel","canReorder","dynamicListHeight","Math","min","ShadowBox","$overflowDirection","VisuallyHidden","aria-live","FixedSizeList","outerRef","itemCount","itemSize","itemData","ariaDescribedBy","canDrag","itemKey","innerElementType","ListItem","Box","style","originalLabel","originalStatus","getCollectionType","useDocument","handlerId","isDragging","handleKeyDown","relationRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","ItemTypes","RELATION","displayedValue","onMoveItem","onDropItem","onGrabItem","onCancel","dropSensitivity","DROP_SENSITIVITY","REGULAR","composedRefs","useComposedRefs","getEmptyImage","safeDocumentId","safeLocale","documentMeta","tag","aria-describedby","cursor","RelationItemPlaceholder","paddingTop","paddingBottom","paddingLeft","paddingRight","hasRadius","borderColor","background","data-handler-id","FlexWrapper","IconButton","role","tabIndex","withTooltip","variant","onKeyDown","Drag","minWidth","flex","size","Cross","DisconnectButton","button","theme","colors","neutral600","neutral500","LinkEllipsis","Link","borderStyle","borderWidth","MemoizedRelationsField","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA;;;;AAIC,IACD,SAASA,mBAAAA,CAAoBC,SAAiB,EAAEC,YAAoB,EAAA;AAClE,IAAA,MAAMC,QAAQC,QAASH,CAAAA,SAAAA,CAAAA;AACvB,IAAA,MAAMI,iBAAiBC,OAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMF,cAAc,CAAA;AAC5E,IAAA,MAAMG,cAAcF,OAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMC,WAAW,CAAA;AAEtE,IAAA,MAA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AA,GAA0B,kBAC9BjN,GAACgL,CAAAA,GAAAA,EAAAA;QACCkC,UAAY,EAAA,CAAA;QACZC,aAAe,EAAA,CAAA;QACfC,WAAa,EAAA,CAAA;QACbC,YAAc,EAAA,CAAA;QACdC,SAAS,EAAA,IAAA;QACTwB,WAAY,EAAA,QAAA;QACZvB,WAAY,EAAA,YAAA;QACZwB,WAAY,EAAA,KAAA;QACZvB,UAAW,EAAA,YAAA;AACXpK,QAAAA,MAAAA,EAAQ,CAAC,YAAY,EAAEuD,eAAAA,CAAgB,GAAG;;AAIxCqI,MAAAA,sBAAAA,iBAAyBrV,KAAMsV,CAAAA,IAAI,CAACvV,cAAAA;;;;"}
@@ -9,6 +9,8 @@ var DocumentRBAC = require('../../../features/DocumentRBAC.js');
9
9
  var useDocumentContext = require('../../../hooks/useDocumentContext.js');
10
10
  var useDocumentLayout = require('../../../hooks/useDocumentLayout.js');
11
11
  var useLazyComponents = require('../../../hooks/useLazyComponents.js');
12
+ var InputPopover = require('../../../preview/components/InputPopover.js');
13
+ var usePreviewInputManager = require('../../../preview/hooks/usePreviewInputManager.js');
12
14
  var BlocksInput = require('./FormInputs/BlocksInput/BlocksInput.js');
13
15
  var Input = require('./FormInputs/Component/Input.js');
14
16
  var Field = require('./FormInputs/DynamicZone/Field.js');
@@ -43,11 +45,13 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
43
45
  * specifically to be used in the EditView of the content-manager this understands
44
46
  * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific
45
47
  * components such as Blocks / Relations.
46
- */ const InputRenderer = ({ visible, hint: providedHint, document, ...props })=>{
48
+ */ const InputRenderer = ({ visible, hint: providedHint, document, ...inputProps })=>{
47
49
  const { currentDocumentMeta } = useDocumentContext.useDocumentContext('DynamicComponent');
48
50
  const { edit: { components } } = useDocumentLayout.useDocumentLayout(currentDocumentMeta.model);
49
51
  const collectionType = document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';
50
52
  const isInDynamicZone = Field.useDynamicZone('isInDynamicZone', (state)=>state.isInDynamicZone);
53
+ const isInPreviewPopover = InputPopover.useHasInputPopoverParent();
54
+ const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;
51
55
  const isFormDisabled = strapiAdmin.useForm('InputRenderer', (state)=>state.disabled);
52
56
  const canCreateFields = DocumentRBAC.useDocumentRBAC('InputRenderer', (rbac)=>rbac.canCreateFields);
53
57
  const canReadFields = DocumentRBAC.useDocumentRBAC('InputRenderer', (rbac)=>rbac.canReadFields);
@@ -59,6 +63,12 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
59
63
  }
60
64
  const editableFields = idToCheck ? canUpdateFields : canCreateFields;
61
65
  const readableFields = idToCheck ? canReadFields : canCreateFields;
66
+ // Everything preview related
67
+ const previewProps = usePreviewInputManager.usePreviewInputManager(inputProps.name, inputProps.attribute);
68
+ const props = {
69
+ ...inputProps,
70
+ ...previewProps
71
+ };
62
72
  /**
63
73
  * Component fields are always readable and editable,
64
74
  * however the fields within them may not be.
@@ -76,29 +86,30 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
76
86
  }
77
87
  /**
78
88
  * If the user can't read the field then we don't want to ever render it.
79
- */ if (!canUserReadField && !isInDynamicZone) {
89
+ */ if (!canUserReadField && !shouldIgnorePermissions) {
80
90
  return /*#__PURE__*/ jsxRuntime.jsx(NotAllowed.NotAllowedInput, {
81
91
  hint: hint,
82
92
  ...props
83
93
  });
84
94
  }
85
- const fieldIsDisabled = !canUserEditField && !isInDynamicZone || props.disabled || isFormDisabled;
95
+ const fieldIsDisabled = !canUserEditField && !shouldIgnorePermissions || props.disabled || isFormDisabled;
86
96
  /**
87
97
  * Because a custom field has a unique prop but the type could be confused with either
88
98
  * the useField hook or the type of the field we need to handle it separately and first.
89
99
  */ if (attributeHasCustomFieldProperty(props.attribute)) {
90
100
  const CustomInput = lazyComponentStore[props.attribute.customField];
91
101
  if (CustomInput) {
92
- // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
93
102
  return /*#__PURE__*/ jsxRuntime.jsx(CustomInput, {
94
103
  ...props,
95
104
  ...field,
105
+ // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
96
106
  hint: hint,
97
107
  disabled: fieldIsDisabled
98
108
  });
99
109
  }
100
110
  return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.InputRenderer, {
101
111
  ...props,
112
+ ...previewProps,
102
113
  hint: hint,
103
114
  // @ts-expect-error – this workaround lets us display that the custom field is missing.
104
115
  type: props.attribute.customField,
@@ -110,9 +121,9 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
110
121
  */ const addedInputTypes = Object.keys(fields);
111
122
  if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
112
123
  const CustomInput = fields[props.type];
113
- // @ts-expect-error – TODO: fix this type error in the useLibrary hook.
114
124
  return /*#__PURE__*/ jsxRuntime.jsx(CustomInput, {
115
125
  ...props,
126
+ // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.
116
127
  hint: hint,
117
128
  disabled: fieldIsDisabled
118
129
  });
@@ -134,8 +145,8 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
134
145
  hint: hint,
135
146
  layout: components[props.attribute.component].layout,
136
147
  disabled: fieldIsDisabled,
137
- children: (inputProps)=>/*#__PURE__*/ jsxRuntime.jsx(InputRenderer, {
138
- ...inputProps
148
+ children: (componentInputProps)=>/*#__PURE__*/ jsxRuntime.jsx(InputRenderer, {
149
+ ...componentInputProps
139
150
  })
140
151
  });
141
152
  case 'dynamiczone':
@@ -169,6 +180,7 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
169
180
  */ case 'enumeration':
170
181
  return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.InputRenderer, {
171
182
  ...props,
183
+ ...previewProps,
172
184
  hint: hint,
173
185
  options: props.attribute.enum.map((value)=>({
174
186
  value
@@ -182,6 +194,7 @@ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
182
194
  const { unique: _unique, mainField: _mainField, ...restProps } = props;
183
195
  return /*#__PURE__*/ jsxRuntime.jsx(strapiAdmin.InputRenderer, {
184
196
  ...restProps,
197
+ ...previewProps,
185
198
  hint: hint,
186
199
  // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!
187
200
  type: props.customField ? 'custom-field' : props.type,
@@ -1 +1 @@
1
- {"version":3,"file":"InputRenderer.js","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst InputRenderer = ({ visible, hint: providedHint, document, ...props }: InputRendererProps) => {\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !isInDynamicZone) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !isInDynamicZone) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n return <CustomInput {...props} {...field} hint={hint} disabled={fieldIsDisabled} />;\n }\n\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n // @ts-expect-error – TODO: fix this type error in the useLibrary hook.\n return <CustomInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n return (\n <ComponentInput\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(inputProps) => <InputRenderer {...inputProps} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return <DynamicZone {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'relation':\n return <RelationsInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'richtext':\n return <Wysiwyg {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'uid':\n return <UIDInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = !['biginteger', 'integer', 'number', 'dynamiczone', 'component'].includes(\n attribute.type\n )\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\nconst MemoizedInputRenderer = React.memo(InputRenderer);\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["InputRenderer","visible","hint","providedHint","document","props","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","canUserReadField","name","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","attribute","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","inputProps","DynamicZone","RelationsInput","Wysiwyg","UIDInput","options","enum","map","value","unique","_unique","mainField","_mainField","restProps","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","MemoizedInputRenderer","React","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA;;;;;;;AAOC,IACD,MAAMA,aAAAA,GAAgB,CAAC,EAAEC,OAAO,EAAEC,IAAMC,EAAAA,YAAY,EAAEC,QAAQ,EAAE,GAAGC,KAA2B,EAAA,GAAA;AAC5F,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,qCAAmB,CAAA,kBAAA,CAAA;IACnD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,mCAAkBJ,CAAAA,mBAAAA,CAAoBK,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJR,QAASS,CAAAA,MAAM,EAAEC,IAAAA,KAAS,mBAAmB,kBAAqB,GAAA,cAAA;AAEpE,IAAA,MAAMC,kBAAkBC,oBAAe,CAAA,iBAAA,EAAmB,CAACC,KAAAA,GAAUA,MAAMF,eAAe,CAAA;AAE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,CAAAA,KAAK,CAACD,MAAAA,CAAOlD,SAAU2C,CAAAA,GAAG,CAAKO,CAAAA,GAAAA,MAAAA,CAAOlD,SAAU2C,CAAAA,GAAG,CAAIzC,GAAAA,SAAAA;YACxEkC,OAAS,EAAA,CAACc,MAAOC,CAAAA,KAAK,CAACD,MAAAA,CAAOlD,SAAU6C,CAAAA,GAAG,CAAKK,CAAAA,GAAAA,MAAAA,CAAOlD,SAAU6C,CAAAA,GAAG,CAAI3C,GAAAA;AAC1E,SAAA;AACF,KAAA,MAAO,IAAI,WAAA,IAAeF,SAAa,IAAA,WAAA,IAAeA,SAAW,EAAA;QAC/D,OAAO;AAAEmC,YAAAA,OAAAA,EAASnC,UAAUoD,SAAS;AAAEhB,YAAAA,OAAAA,EAASpC,UAAUqD;AAAU,SAAA;KAC/D,MAAA;QACL,OAAO;YAAElB,OAASjC,EAAAA,SAAAA;YAAWkC,OAASlC,EAAAA;AAAU,SAAA;AAClD;AACF,CAAA;AAEMoD,MAAAA,qBAAAA,iBAAwBC,gBAAMC,CAAAA,IAAI,CAAClG,aAAAA;;;;;"}
1
+ {"version":3,"file":"InputRenderer.js","sources":["../../../../../admin/src/pages/EditView/components/InputRenderer.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useStrapiApp,\n useForm,\n InputRenderer as FormInputRenderer,\n useField,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\n\nimport { SINGLE_TYPES } from '../../../constants/collections';\nimport { useDocumentRBAC } from '../../../features/DocumentRBAC';\nimport { type UseDocument } from '../../../hooks/useDocument';\nimport { useDocumentContext } from '../../../hooks/useDocumentContext';\nimport { useDocumentLayout } from '../../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../../hooks/useLazyComponents';\nimport { useHasInputPopoverParent } from '../../../preview/components/InputPopover';\nimport { usePreviewInputManager } from '../../../preview/hooks/usePreviewInputManager';\n\nimport { BlocksInput } from './FormInputs/BlocksInput/BlocksInput';\nimport { ComponentInput } from './FormInputs/Component/Input';\nimport { DynamicZone, useDynamicZone } from './FormInputs/DynamicZone/Field';\nimport { NotAllowedInput } from './FormInputs/NotAllowed';\nimport { RelationsInput } from './FormInputs/Relations/Relations';\nimport { UIDInput } from './FormInputs/UID';\nimport { Wysiwyg } from './FormInputs/Wysiwyg/Field';\n\nimport type { EditFieldLayout } from '../../../hooks/useDocumentLayout';\nimport type { Schema } from '@strapi/types';\nimport type { DistributiveOmit } from 'react-redux';\n\ntype InputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {\n document: ReturnType<UseDocument>;\n};\n\n/**\n * @internal\n *\n * @description An abstraction around the regular form input renderer designed\n * specifically to be used in the EditView of the content-manager this understands\n * the complete EditFieldLayout and will handle RBAC conditions and rendering CM specific\n * components such as Blocks / Relations.\n */\nconst InputRenderer = ({\n visible,\n hint: providedHint,\n document,\n ...inputProps\n}: InputRendererProps) => {\n const { currentDocumentMeta } = useDocumentContext('DynamicComponent');\n const {\n edit: { components },\n } = useDocumentLayout(currentDocumentMeta.model);\n\n const collectionType =\n document.schema?.kind === 'collectionType' ? 'collection-types' : 'single-types';\n\n const isInDynamicZone = useDynamicZone('isInDynamicZone', (state) => state.isInDynamicZone);\n const isInPreviewPopover = useHasInputPopoverParent();\n const shouldIgnorePermissions = isInDynamicZone || isInPreviewPopover;\n\n const isFormDisabled = useForm('InputRenderer', (state) => state.disabled);\n const canCreateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canCreateFields);\n const canReadFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canReadFields);\n const canUpdateFields = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUpdateFields);\n const canUserAction = useDocumentRBAC('InputRenderer', (rbac) => rbac.canUserAction);\n\n let idToCheck = document.document?.documentId;\n if (collectionType === SINGLE_TYPES) {\n idToCheck = document?.document?.documentId;\n }\n\n const editableFields = idToCheck ? canUpdateFields : canCreateFields;\n const readableFields = idToCheck ? canReadFields : canCreateFields;\n\n // Everything preview related\n const previewProps = usePreviewInputManager(inputProps.name, inputProps.attribute);\n const props = { ...inputProps, ...previewProps };\n\n /**\n * Component fields are always readable and editable,\n * however the fields within them may not be.\n */\n const canUserReadField = canUserAction(props.name, readableFields, props.type);\n const canUserEditField = canUserAction(props.name, editableFields, props.type);\n\n const fields = useStrapiApp('InputRenderer', (app) => app.fields);\n const { lazyComponentStore } = useLazyComponents(\n attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : undefined\n );\n\n const hint = useFieldHint(providedHint, props.attribute);\n\n // We pass field in case of Custom Fields to keep backward compatibility\n const field = useField(props.name);\n\n if (!visible) {\n return null;\n }\n\n /**\n * If the user can't read the field then we don't want to ever render it.\n */\n if (!canUserReadField && !shouldIgnorePermissions) {\n return <NotAllowedInput hint={hint} {...props} />;\n }\n\n const fieldIsDisabled =\n (!canUserEditField && !shouldIgnorePermissions) || props.disabled || isFormDisabled;\n\n /**\n * Because a custom field has a unique prop but the type could be confused with either\n * the useField hook or the type of the field we need to handle it separately and first.\n */\n if (attributeHasCustomFieldProperty(props.attribute)) {\n const CustomInput = lazyComponentStore[props.attribute.customField];\n\n if (CustomInput) {\n return (\n <CustomInput\n {...props}\n {...field}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n return (\n <FormInputRenderer\n {...props}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – this workaround lets us display that the custom field is missing.\n type={props.attribute.customField}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * This is where we handle ONLY the fields from the `useLibrary` hook.\n */\n const addedInputTypes = Object.keys(fields);\n if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {\n const CustomInput = fields[props.type];\n return (\n <CustomInput\n {...props}\n // @ts-expect-error – TODO: fix this type error in the useLazyComponents hook.\n hint={hint}\n disabled={fieldIsDisabled}\n />\n );\n }\n\n /**\n * These include the content-manager specific fields, failing that we fall back\n * to the more generic form input renderer.\n */\n switch (props.type) {\n case 'blocks':\n return <BlocksInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'component':\n return (\n <ComponentInput\n {...props}\n hint={hint}\n layout={components[props.attribute.component].layout}\n disabled={fieldIsDisabled}\n >\n {(componentInputProps) => <InputRenderer {...componentInputProps} />}\n </ComponentInput>\n );\n case 'dynamiczone':\n return <DynamicZone {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'relation':\n return <RelationsInput {...props} hint={hint} disabled={fieldIsDisabled} />;\n case 'richtext':\n return <Wysiwyg {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n case 'uid':\n return <UIDInput {...props} hint={hint} type={props.type} disabled={fieldIsDisabled} />;\n /**\n * Enumerations are a special case because they require options.\n */\n case 'enumeration':\n return (\n <FormInputRenderer\n {...props}\n {...previewProps}\n hint={hint}\n options={props.attribute.enum.map((value) => ({ value }))}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n default:\n // These props are not needed for the generic form input renderer.\n const { unique: _unique, mainField: _mainField, ...restProps } = props;\n return (\n <FormInputRenderer\n {...restProps}\n {...previewProps}\n hint={hint}\n // @ts-expect-error – Temp workaround so we don't forget custom-fields don't work!\n type={props.customField ? 'custom-field' : props.type}\n disabled={fieldIsDisabled}\n />\n );\n }\n};\n\nconst attributeHasCustomFieldProperty = (\n attribute: Schema.Attribute.AnyAttribute\n): attribute is Schema.Attribute.AnyAttribute & Schema.Attribute.CustomField<string> =>\n 'customField' in attribute && typeof attribute.customField === 'string';\n\nconst useFieldHint = (\n hint: React.ReactNode = undefined,\n attribute: Schema.Attribute.AnyAttribute\n) => {\n const { formatMessage } = useIntl();\n\n const { maximum, minimum } = getMinMax(attribute);\n\n if (!maximum && !minimum) {\n return hint;\n }\n\n const units = !['biginteger', 'integer', 'number', 'dynamiczone', 'component'].includes(\n attribute.type\n )\n ? formatMessage(\n {\n id: 'content-manager.form.Input.hint.character.unit',\n defaultMessage: '{maxValue, plural, one { character} other { characters}}',\n },\n {\n maxValue: Math.max(minimum || 0, maximum || 0),\n }\n )\n : null;\n\n const hasMinAndMax = typeof minimum === 'number' && typeof maximum === 'number';\n\n return formatMessage(\n {\n id: 'content-manager.form.Input.hint.text',\n defaultMessage:\n '{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}',\n },\n {\n min: minimum,\n max: maximum,\n description: hint,\n unit: units,\n divider: hasMinAndMax\n ? formatMessage({\n id: 'content-manager.form.Input.hint.minMaxDivider',\n defaultMessage: ' / ',\n })\n : null,\n br: <br />,\n }\n );\n};\n\nconst getMinMax = (attribute: Schema.Attribute.AnyAttribute) => {\n if ('min' in attribute || 'max' in attribute) {\n return {\n maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : undefined,\n minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : undefined,\n };\n } else if ('maxLength' in attribute || 'minLength' in attribute) {\n return { maximum: attribute.maxLength, minimum: attribute.minLength };\n } else {\n return { maximum: undefined, minimum: undefined };\n }\n};\n\nconst MemoizedInputRenderer = React.memo(InputRenderer);\n\nexport type { InputRendererProps };\nexport { MemoizedInputRenderer as InputRenderer, useFieldHint };\n"],"names":["InputRenderer","visible","hint","providedHint","document","inputProps","currentDocumentMeta","useDocumentContext","edit","components","useDocumentLayout","model","collectionType","schema","kind","isInDynamicZone","useDynamicZone","state","isInPreviewPopover","useHasInputPopoverParent","shouldIgnorePermissions","isFormDisabled","useForm","disabled","canCreateFields","useDocumentRBAC","rbac","canReadFields","canUpdateFields","canUserAction","idToCheck","documentId","SINGLE_TYPES","editableFields","readableFields","previewProps","usePreviewInputManager","name","attribute","props","canUserReadField","type","canUserEditField","fields","useStrapiApp","app","lazyComponentStore","useLazyComponents","attributeHasCustomFieldProperty","customField","undefined","useFieldHint","field","useField","_jsx","NotAllowedInput","fieldIsDisabled","CustomInput","FormInputRenderer","addedInputTypes","Object","keys","includes","BlocksInput","ComponentInput","layout","component","componentInputProps","DynamicZone","RelationsInput","Wysiwyg","UIDInput","options","enum","map","value","unique","_unique","mainField","_mainField","restProps","formatMessage","useIntl","maximum","minimum","getMinMax","units","id","defaultMessage","maxValue","Math","max","hasMinAndMax","min","description","unit","divider","br","Number","isNaN","maxLength","minLength","MemoizedInputRenderer","React","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;;;;;;AAOC,IACD,MAAMA,aAAAA,GAAgB,CAAC,EACrBC,OAAO,EACPC,IAAMC,EAAAA,YAAY,EAClBC,QAAQ,EACR,GAAGC,UACgB,EAAA,GAAA;AACnB,IAAA,MAAM,EAAEC,mBAAmB,EAAE,GAAGC,qCAAmB,CAAA,kBAAA,CAAA;IACnD,MAAM,EACJC,MAAM,EAAEC,UAAU,EAAE,EACrB,GAAGC,mCAAkBJ,CAAAA,mBAAAA,CAAoBK,KAAK,CAAA;AAE/C,IAAA,MAAMC,iBACJR,QAASS,CAAAA,MAAM,EAAEC,IAAAA,KAAS,mBAAmB,kBAAqB,GAAA,cAAA;AAEpE,IAAA,MAAMC,kBAAkBC,oBAAe,CAAA,iBAAA,EAAmB,CAACC,KAAAA,GAAUA,MAAMF,eAAe,CAAA;AAC1F,IAAA,MAAMG,kBAAqBC,GAAAA,qCAAAA,EAAAA;AAC3B,IAAA,MAAMC,0BAA0BL,eAAmBG,IAAAA,kBAAAA;AAEnD,IAAA,MAAMG,iBAAiBC,mBAAQ,CAAA,eAAA,EAAiB,CAACL,KAAAA,GAAUA,MAAMM,QAAQ,CAAA;AACzE,IAAA,MAAMC,kBAAkBC,4BAAgB,CAAA,eAAA,EAAiB,CAACC,IAAAA,GAASA,KAAKF,eAAe,CAAA;AACvF,IAAA,MAAMG,gBAAgBF,4BAAgB,CAAA,eAAA,EAAiB,CAACC,IAAAA,GAASA,KAAKC,aAAa,CAAA;AACnF,IAAA,MAAMC,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