@strapi/content-manager 0.0.0-next.e21fe90bf2ab9906267ea6e6ca620bdcc729906c → 0.0.0-next.e3eb76a86aff89979cc9098aec129d2ffa600c56

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 (248) hide show
  1. package/dist/admin/components/ConfigurationForm/Fields.js +300 -204
  2. package/dist/admin/components/ConfigurationForm/Fields.js.map +1 -1
  3. package/dist/admin/components/ConfigurationForm/Fields.mjs +304 -209
  4. package/dist/admin/components/ConfigurationForm/Fields.mjs.map +1 -1
  5. package/dist/admin/components/LeftMenu.js +34 -30
  6. package/dist/admin/components/LeftMenu.js.map +1 -1
  7. package/dist/admin/components/LeftMenu.mjs +36 -32
  8. package/dist/admin/components/LeftMenu.mjs.map +1 -1
  9. package/dist/admin/history/components/VersionHeader.js +6 -0
  10. package/dist/admin/history/components/VersionHeader.js.map +1 -1
  11. package/dist/admin/history/components/VersionHeader.mjs +7 -1
  12. package/dist/admin/history/components/VersionHeader.mjs.map +1 -1
  13. package/dist/admin/hooks/useDocumentActions.js +12 -4
  14. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  15. package/dist/admin/hooks/useDocumentActions.mjs +12 -4
  16. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  17. package/dist/admin/hooks/useDocumentContext.js.map +1 -1
  18. package/dist/admin/hooks/useDocumentContext.mjs.map +1 -1
  19. package/dist/admin/index.js +1 -3
  20. package/dist/admin/index.js.map +1 -1
  21. package/dist/admin/pages/EditView/EditViewPage.js +81 -74
  22. package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
  23. package/dist/admin/pages/EditView/EditViewPage.mjs +82 -75
  24. package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/DocumentActions.js +235 -71
  26. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  27. package/dist/admin/pages/EditView/components/DocumentActions.mjs +238 -74
  28. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +12 -15
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +12 -15
  32. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +61 -26
  34. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +63 -28
  36. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +21 -35
  38. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +21 -35
  40. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js +46 -95
  42. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs +48 -78
  44. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs.map +1 -1
  45. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +2 -0
  46. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
  47. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +2 -0
  48. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
  49. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +2 -2
  50. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
  51. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +3 -3
  52. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
  53. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +128 -55
  54. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  55. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +128 -55
  56. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  57. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +120 -32
  58. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  59. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +124 -36
  60. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  61. package/dist/admin/pages/EditView/components/FormInputs/UID.js +4 -2
  62. package/dist/admin/pages/EditView/components/FormInputs/UID.js.map +1 -1
  63. package/dist/admin/pages/EditView/components/FormInputs/UID.mjs +4 -2
  64. package/dist/admin/pages/EditView/components/FormInputs/UID.mjs.map +1 -1
  65. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js +1 -1
  66. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js.map +1 -1
  67. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs +1 -1
  68. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs.map +1 -1
  69. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.js +50 -97
  70. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.js.map +1 -1
  71. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.mjs +51 -79
  72. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.mjs.map +1 -1
  73. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.js +86 -118
  74. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.js.map +1 -1
  75. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.mjs +86 -118
  76. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.mjs.map +1 -1
  77. package/dist/admin/pages/EditView/components/FormLayout.js +20 -24
  78. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  79. package/dist/admin/pages/EditView/components/FormLayout.mjs +20 -24
  80. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  81. package/dist/admin/pages/ListView/ListViewPage.js +77 -0
  82. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  83. package/dist/admin/pages/ListView/ListViewPage.mjs +78 -1
  84. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  85. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.js +2 -1
  86. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.js.map +1 -1
  87. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.mjs +2 -1
  88. package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.mjs.map +1 -1
  89. package/dist/admin/pages/ListView/components/Filters.js +1 -0
  90. package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
  91. package/dist/admin/pages/ListView/components/Filters.mjs +1 -0
  92. package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
  93. package/dist/admin/pages/ListView/components/TableActions.js +13 -3
  94. package/dist/admin/pages/ListView/components/TableActions.js.map +1 -1
  95. package/dist/admin/pages/ListView/components/TableActions.mjs +13 -3
  96. package/dist/admin/pages/ListView/components/TableActions.mjs.map +1 -1
  97. package/dist/admin/preview/components/PreviewHeader.js +1 -1
  98. package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
  99. package/dist/admin/preview/components/PreviewHeader.mjs +1 -1
  100. package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
  101. package/dist/admin/services/documents.js +2 -2
  102. package/dist/admin/services/documents.js.map +1 -1
  103. package/dist/admin/services/documents.mjs +2 -2
  104. package/dist/admin/services/documents.mjs.map +1 -1
  105. package/dist/admin/services/homepage.js +9 -5
  106. package/dist/admin/services/homepage.js.map +1 -1
  107. package/dist/admin/services/homepage.mjs +9 -5
  108. package/dist/admin/services/homepage.mjs.map +1 -1
  109. package/dist/admin/src/components/ConfigurationForm/Fields.d.ts +6 -4
  110. package/dist/admin/src/hooks/useDocumentActions.d.ts +1 -0
  111. package/dist/admin/src/hooks/useDocumentContext.d.ts +1 -1
  112. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.d.ts +2 -2
  113. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +26 -5
  114. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +1 -0
  115. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +7 -8
  116. package/dist/admin/src/services/documents.d.ts +7 -1
  117. package/dist/admin/translations/en.json.js +3 -1
  118. package/dist/admin/translations/en.json.js.map +1 -1
  119. package/dist/admin/translations/en.json.mjs +3 -1
  120. package/dist/admin/translations/en.json.mjs.map +1 -1
  121. package/dist/admin/translations/ru.json.js +235 -226
  122. package/dist/admin/translations/ru.json.js.map +1 -1
  123. package/dist/admin/translations/ru.json.mjs +230 -226
  124. package/dist/admin/translations/ru.json.mjs.map +1 -1
  125. package/dist/admin/utils/validation.js +1 -1
  126. package/dist/admin/utils/validation.js.map +1 -1
  127. package/dist/admin/utils/validation.mjs +1 -1
  128. package/dist/admin/utils/validation.mjs.map +1 -1
  129. package/dist/server/controllers/content-types.js +11 -1
  130. package/dist/server/controllers/content-types.js.map +1 -1
  131. package/dist/server/controllers/content-types.mjs +11 -1
  132. package/dist/server/controllers/content-types.mjs.map +1 -1
  133. package/dist/server/controllers/index.js +3 -1
  134. package/dist/server/controllers/index.js.map +1 -1
  135. package/dist/server/controllers/index.mjs +3 -1
  136. package/dist/server/controllers/index.mjs.map +1 -1
  137. package/dist/server/controllers/validation/index.js +14 -2
  138. package/dist/server/controllers/validation/index.js.map +1 -1
  139. package/dist/server/controllers/validation/index.mjs +14 -2
  140. package/dist/server/controllers/validation/index.mjs.map +1 -1
  141. package/dist/server/history/services/lifecycles.js +3 -0
  142. package/dist/server/history/services/lifecycles.js.map +1 -1
  143. package/dist/server/history/services/lifecycles.mjs +3 -0
  144. package/dist/server/history/services/lifecycles.mjs.map +1 -1
  145. package/dist/server/homepage/controllers/homepage.js +57 -0
  146. package/dist/server/homepage/controllers/homepage.js.map +1 -0
  147. package/dist/server/homepage/controllers/homepage.mjs +36 -0
  148. package/dist/server/homepage/controllers/homepage.mjs.map +1 -0
  149. package/dist/server/homepage/controllers/index.js +10 -0
  150. package/dist/server/homepage/controllers/index.js.map +1 -0
  151. package/dist/server/homepage/controllers/index.mjs +8 -0
  152. package/dist/server/homepage/controllers/index.mjs.map +1 -0
  153. package/dist/server/homepage/index.js +14 -0
  154. package/dist/server/homepage/index.js.map +1 -0
  155. package/dist/server/homepage/index.mjs +12 -0
  156. package/dist/server/homepage/index.mjs.map +1 -0
  157. package/dist/server/homepage/routes/homepage.js +25 -0
  158. package/dist/server/homepage/routes/homepage.js.map +1 -0
  159. package/dist/server/homepage/routes/homepage.mjs +23 -0
  160. package/dist/server/homepage/routes/homepage.mjs.map +1 -0
  161. package/dist/server/homepage/routes/index.js +13 -0
  162. package/dist/server/homepage/routes/index.js.map +1 -0
  163. package/dist/server/homepage/routes/index.mjs +11 -0
  164. package/dist/server/homepage/routes/index.mjs.map +1 -0
  165. package/dist/server/homepage/services/homepage.js +157 -0
  166. package/dist/server/homepage/services/homepage.js.map +1 -0
  167. package/dist/server/homepage/services/homepage.mjs +155 -0
  168. package/dist/server/homepage/services/homepage.mjs.map +1 -0
  169. package/dist/server/homepage/services/index.js +10 -0
  170. package/dist/server/homepage/services/index.js.map +1 -0
  171. package/dist/server/homepage/services/index.mjs +8 -0
  172. package/dist/server/homepage/services/index.mjs.map +1 -0
  173. package/dist/server/preview/services/preview.js +0 -1
  174. package/dist/server/preview/services/preview.js.map +1 -1
  175. package/dist/server/preview/services/preview.mjs +0 -1
  176. package/dist/server/preview/services/preview.mjs.map +1 -1
  177. package/dist/server/routes/index.js +3 -1
  178. package/dist/server/routes/index.js.map +1 -1
  179. package/dist/server/routes/index.mjs +3 -1
  180. package/dist/server/routes/index.mjs.map +1 -1
  181. package/dist/server/services/data-mapper.js +4 -1
  182. package/dist/server/services/data-mapper.js.map +1 -1
  183. package/dist/server/services/data-mapper.mjs +4 -1
  184. package/dist/server/services/data-mapper.mjs.map +1 -1
  185. package/dist/server/services/document-manager.js +8 -1
  186. package/dist/server/services/document-manager.js.map +1 -1
  187. package/dist/server/services/document-manager.mjs +8 -1
  188. package/dist/server/services/document-manager.mjs.map +1 -1
  189. package/dist/server/services/document-metadata.js +3 -1
  190. package/dist/server/services/document-metadata.js.map +1 -1
  191. package/dist/server/services/document-metadata.mjs +3 -1
  192. package/dist/server/services/document-metadata.mjs.map +1 -1
  193. package/dist/server/services/index.js +3 -1
  194. package/dist/server/services/index.js.map +1 -1
  195. package/dist/server/services/index.mjs +3 -1
  196. package/dist/server/services/index.mjs.map +1 -1
  197. package/dist/server/services/utils/configuration/attributes.js +1 -1
  198. package/dist/server/services/utils/configuration/attributes.js.map +1 -1
  199. package/dist/server/services/utils/configuration/attributes.mjs +1 -1
  200. package/dist/server/services/utils/configuration/attributes.mjs.map +1 -1
  201. package/dist/server/services/utils/configuration/layouts.js +1 -1
  202. package/dist/server/services/utils/configuration/layouts.js.map +1 -1
  203. package/dist/server/services/utils/configuration/layouts.mjs +1 -1
  204. package/dist/server/services/utils/configuration/layouts.mjs.map +1 -1
  205. package/dist/server/services/utils/configuration/metadatas.js +8 -0
  206. package/dist/server/services/utils/configuration/metadatas.js.map +1 -1
  207. package/dist/server/services/utils/configuration/metadatas.mjs +8 -0
  208. package/dist/server/services/utils/configuration/metadatas.mjs.map +1 -1
  209. package/dist/server/services/utils/populate.js +11 -0
  210. package/dist/server/services/utils/populate.js.map +1 -1
  211. package/dist/server/services/utils/populate.mjs +11 -0
  212. package/dist/server/services/utils/populate.mjs.map +1 -1
  213. package/dist/server/src/controllers/content-types.d.ts.map +1 -1
  214. package/dist/server/src/controllers/index.d.ts.map +1 -1
  215. package/dist/server/src/controllers/validation/index.d.ts +6 -1
  216. package/dist/server/src/controllers/validation/index.d.ts.map +1 -1
  217. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  218. package/dist/server/src/homepage/controllers/homepage.d.ts +7 -0
  219. package/dist/server/src/homepage/controllers/homepage.d.ts.map +1 -0
  220. package/dist/server/src/homepage/controllers/index.d.ts +2 -0
  221. package/dist/server/src/homepage/controllers/index.d.ts.map +1 -0
  222. package/dist/server/src/homepage/index.d.ts +16 -0
  223. package/dist/server/src/homepage/index.d.ts.map +1 -0
  224. package/dist/server/src/homepage/routes/homepage.d.ts +4 -0
  225. package/dist/server/src/homepage/routes/homepage.d.ts.map +1 -0
  226. package/dist/server/src/homepage/routes/index.d.ts +8 -0
  227. package/dist/server/src/homepage/routes/index.d.ts.map +1 -0
  228. package/dist/server/src/{services → homepage/services}/homepage.d.ts +1 -1
  229. package/dist/server/src/homepage/services/homepage.d.ts.map +1 -0
  230. package/dist/server/src/homepage/services/index.d.ts +9 -0
  231. package/dist/server/src/homepage/services/index.d.ts.map +1 -0
  232. package/dist/server/src/index.d.ts +8 -0
  233. package/dist/server/src/index.d.ts.map +1 -1
  234. package/dist/server/src/preview/services/preview.d.ts.map +1 -1
  235. package/dist/server/src/routes/index.d.ts +1 -0
  236. package/dist/server/src/routes/index.d.ts.map +1 -1
  237. package/dist/server/src/services/data-mapper.d.ts +1 -0
  238. package/dist/server/src/services/data-mapper.d.ts.map +1 -1
  239. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  240. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  241. package/dist/server/src/services/index.d.ts +7 -0
  242. package/dist/server/src/services/index.d.ts.map +1 -1
  243. package/dist/server/src/services/utils/configuration/metadatas.d.ts.map +1 -1
  244. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  245. package/dist/shared/contracts/collection-types.d.ts +0 -1
  246. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  247. package/package.json +11 -8
  248. package/dist/server/src/services/homepage.d.ts.map +0 -1
@@ -13,6 +13,8 @@ var reactWindow = require('react-window');
13
13
  var styledComponents = require('styled-components');
14
14
  var collections = require('../../../../../constants/collections.js');
15
15
  var dragAndDrop = require('../../../../../constants/dragAndDrop.js');
16
+ var plugin = require('../../../../../constants/plugin.js');
17
+ var DocumentRBAC = require('../../../../../features/DocumentRBAC.js');
16
18
  var useDebounce = require('../../../../../hooks/useDebounce.js');
17
19
  var useDocument = require('../../../../../hooks/useDocument.js');
18
20
  var useDocumentContext = require('../../../../../hooks/useDocumentContext.js');
@@ -117,8 +119,9 @@ const ONE_WAY_RELATIONS = [
117
119
  /**
118
120
  * We'll always have a documentId in a created entry, so we look for a componentId first.
119
121
  * Same with `uid` and `documentModel`.
122
+ * The componentId is empty when adding a new component in a repeatable. Let it be null to skip isRelatedToCurrentDocument
120
123
  */ const model = component ? component.uid : currentDocumentMeta.model;
121
- const id = component && componentId ? componentId.toString() : documentId;
124
+ const id = component ? componentId?.toString() : documentId;
122
125
  /**
123
126
  * The `name` prop is a complete path to the field, e.g. `field1.field2.field3`.
124
127
  * Where the above example would a nested field within two components, however
@@ -327,7 +330,6 @@ const ONE_WAY_RELATIONS = [
327
330
  * @description Contains all the logic for the combobox that can search
328
331
  * for relations and then add them to the field's connect array.
329
332
  */ const RelationsInput = ({ hint, id, model, label, labelAction, name, mainField, placeholder, required, unique: _unique, 'aria-label': _ariaLabel, onChange, isRelatedToCurrentDocument, ...props })=>{
330
- const [textValue, setTextValue] = React__namespace.useState('');
331
333
  const [searchParams, setSearchParams] = React__namespace.useState({
332
334
  _q: '',
333
335
  page: 1
@@ -335,7 +337,6 @@ const ONE_WAY_RELATIONS = [
335
337
  const { toggleNotification } = strapiAdmin.useNotification();
336
338
  const { currentDocumentMeta } = useDocumentContext.useDocumentContext('RelationsInput');
337
339
  const { formatMessage } = reactIntl.useIntl();
338
- const fieldRef = strapiAdmin.useFocusInputField(name);
339
340
  const field = strapiAdmin.useField(name);
340
341
  const searchParamsDebounced = useDebounce.useDebounce(searchParams, 300);
341
342
  const [searchForTrigger, { data, isLoading }] = relations.useLazySearchRelationsQuery();
@@ -376,13 +377,6 @@ const ONE_WAY_RELATIONS = [
376
377
  isRelatedToCurrentDocument,
377
378
  currentDocumentMeta.params
378
379
  ]);
379
- const handleSearch = async (search)=>{
380
- setSearchParams((s)=>({
381
- ...s,
382
- _q: search,
383
- page: 1
384
- }));
385
- };
386
380
  const hasNextPage = data?.pagination ? data.pagination.page < data.pagination.pageCount : false;
387
381
  const options = data?.results ?? [];
388
382
  const handleChange = (relationId)=>{
@@ -410,6 +404,74 @@ const ONE_WAY_RELATIONS = [
410
404
  *
411
405
  */ onChange(relation);
412
406
  };
407
+ const relation = {
408
+ collectionType: collections.COLLECTION_TYPES,
409
+ // @ts-expect-error – targetModel does exist on the attribute. But it's not typed.
410
+ model: props.attribute.targetModel,
411
+ documentId: '',
412
+ params: currentDocumentMeta.params
413
+ };
414
+ const { permissions = [], isLoading: isLoadingPermissions, error } = strapiAdmin.useRBAC(plugin.PERMISSIONS.map((action)=>({
415
+ action,
416
+ subject: relation.model
417
+ })));
418
+ if (error) {
419
+ return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
420
+ alignItems: "center",
421
+ height: "100%",
422
+ justifyContent: "center",
423
+ children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.EmptyStateLayout, {
424
+ icon: /*#__PURE__*/ jsxRuntime.jsx(Icons.WarningCircle, {
425
+ width: "16rem"
426
+ }),
427
+ content: formatMessage({
428
+ id: 'anErrorOccurred',
429
+ defaultMessage: 'Whoops! Something went wrong. Please, try again.'
430
+ })
431
+ })
432
+ });
433
+ }
434
+ return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
435
+ error: field.error,
436
+ hint: hint,
437
+ name: name,
438
+ required: required,
439
+ children: [
440
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
441
+ action: labelAction,
442
+ children: label
443
+ }),
444
+ /*#__PURE__*/ jsxRuntime.jsx(DocumentRBAC.DocumentRBAC, {
445
+ permissions: permissions,
446
+ model: relation.model,
447
+ children: /*#__PURE__*/ jsxRuntime.jsx(RelationModalWithContext, {
448
+ relation: relation,
449
+ name: name,
450
+ placeholder: placeholder,
451
+ hasNextPage: hasNextPage,
452
+ isLoadingPermissions: isLoadingPermissions,
453
+ isLoadingSearchRelations: isLoading,
454
+ handleChange: handleChange,
455
+ setSearchParams: setSearchParams,
456
+ data: data,
457
+ mainField: mainField,
458
+ fieldValue: field.value,
459
+ ...props
460
+ })
461
+ }),
462
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {}),
463
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Hint, {})
464
+ ]
465
+ });
466
+ };
467
+ const RelationModalWithContext = ({ relation, name, placeholder, hasNextPage, isLoadingSearchRelations, isLoadingPermissions, handleChange, mainField, setSearchParams, fieldValue, data, ...props })=>{
468
+ const [textValue, setTextValue] = React__namespace.useState('');
469
+ const { formatMessage } = reactIntl.useIntl();
470
+ const canCreate = DocumentRBAC.useDocumentRBAC('RelationModalWrapper', (state)=>state.canCreate);
471
+ const fieldRef = strapiAdmin.useFocusInputField(name);
472
+ const { componentUID } = ComponentContext.useComponent('RelationsField', ({ uid })=>({
473
+ componentUID: uid
474
+ }));
413
475
  const handleLoadMore = ()=>{
414
476
  if (!data || !data.pagination) {
415
477
  return;
@@ -420,23 +482,44 @@ const ONE_WAY_RELATIONS = [
420
482
  }));
421
483
  }
422
484
  };
485
+ const options = data?.results ?? [];
423
486
  React__namespace.useLayoutEffect(()=>{
424
487
  setTextValue('');
425
488
  }, [
426
- field.value
489
+ fieldValue
427
490
  ]);
428
- return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Field.Root, {
429
- error: field.error,
430
- hint: hint,
431
- name: name,
432
- required: required,
433
- children: [
434
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
435
- action: labelAction,
436
- children: label
437
- }),
438
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Combobox, {
491
+ const handleSearch = async (search)=>{
492
+ setSearchParams((s)=>({
493
+ ...s,
494
+ _q: search,
495
+ page: 1
496
+ }));
497
+ };
498
+ return /*#__PURE__*/ jsxRuntime.jsx(RelationModal.RelationModalRenderer, {
499
+ children: ({ dispatch })=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Combobox, {
439
500
  ref: fieldRef,
501
+ creatable: "visible",
502
+ creatableDisabled: !canCreate,
503
+ createMessage: ()=>formatMessage({
504
+ id: translations.getTranslation('relation.create'),
505
+ defaultMessage: 'Create a relation'
506
+ }),
507
+ onCreateOption: ()=>{
508
+ if (canCreate) {
509
+ dispatch({
510
+ type: 'GO_TO_RELATION',
511
+ payload: {
512
+ document: relation,
513
+ shouldBypassConfirmation: false,
514
+ fieldToConnect: name,
515
+ fieldToConnectUID: componentUID
516
+ }
517
+ });
518
+ }
519
+ },
520
+ creatableStartIcon: /*#__PURE__*/ jsxRuntime.jsx(Icons.Plus, {
521
+ fill: "neutral500"
522
+ }),
440
523
  name: name,
441
524
  autocomplete: "list",
442
525
  placeholder: placeholder || formatMessage({
@@ -444,7 +527,7 @@ const ONE_WAY_RELATIONS = [
444
527
  defaultMessage: 'Add relation'
445
528
  }),
446
529
  hasMoreItems: hasNextPage,
447
- loading: isLoading,
530
+ loading: isLoadingSearchRelations || isLoadingPermissions,
448
531
  onOpenChange: ()=>{
449
532
  handleSearch(textValue ?? '');
450
533
  },
@@ -466,7 +549,7 @@ const ONE_WAY_RELATIONS = [
466
549
  handleSearch(event.currentTarget.value);
467
550
  },
468
551
  ...props,
469
- children: options.map((opt)=>{
552
+ children: options?.map((opt)=>{
470
553
  const textValue = relations$1.getRelationLabel(opt, mainField);
471
554
  return /*#__PURE__*/ jsxRuntime.jsx(designSystem.ComboboxOption, {
472
555
  value: opt.id.toString(),
@@ -475,9 +558,17 @@ const ONE_WAY_RELATIONS = [
475
558
  gap: 2,
476
559
  justifyContent: "space-between",
477
560
  children: [
478
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
479
- ellipsis: true,
480
- children: textValue
561
+ /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
562
+ gap: 2,
563
+ children: [
564
+ /*#__PURE__*/ jsxRuntime.jsx(Icons.Link, {
565
+ fill: "neutral500"
566
+ }),
567
+ /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
568
+ ellipsis: true,
569
+ children: textValue
570
+ })
571
+ ]
481
572
  }),
482
573
  opt.status ? /*#__PURE__*/ jsxRuntime.jsx(DocumentStatus.DocumentStatus, {
483
574
  status: opt.status
@@ -486,10 +577,7 @@ const ONE_WAY_RELATIONS = [
486
577
  })
487
578
  }, opt.id);
488
579
  })
489
- }),
490
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Error, {}),
491
- /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Hint, {})
492
- ]
580
+ })
493
581
  });
494
582
  };
495
583
  /* -------------------------------------------------------------------------------------------------
@@ -806,7 +894,7 @@ const ListItem = ({ data, index, style })=>{
806
894
  minWidth: 0,
807
895
  paddingTop: 1,
808
896
  paddingBottom: 1,
809
- children: /*#__PURE__*/ jsxRuntime.jsx(RelationModal.RelationModal, {
897
+ children: /*#__PURE__*/ jsxRuntime.jsx(RelationModal.RelationModalRenderer, {
810
898
  relation: documentMeta,
811
899
  children: label
812
900
  })
@@ -1 +1 @@
1
- {"version":3,"file":"Relations.js","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} 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} from '@strapi/design-system';\nimport { Cross, Drag, ArrowClockwise } 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 { 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 { RelationModal, getCollectionType } from '../Relations/RelationModal';\n\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 */\n const model = component ? component.uid : currentDocumentMeta.model;\n const id = component && componentId ? 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\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 [textValue, setTextValue] = React.useState<string | undefined>('');\n const [searchParams, setSearchParams] = React.useState({\n _q: '',\n page: 1,\n });\n const { toggleNotification } = useNotification();\n const { currentDocumentMeta } = useDocumentContext('RelationsInput');\n\n const { formatMessage } = useIntl();\n const fieldRef = useFocusInputField<HTMLInputElement>(name);\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 handleSearch = async (search: string) => {\n setSearchParams((s) => ({ ...s, _q: search, page: 1 }));\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 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 React.useLayoutEffect(() => {\n setTextValue('');\n }, [field.value]);\n\n return (\n <Field.Root error={field.error} hint={hint} name={name} required={required}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <Combobox\n ref={fieldRef}\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={isLoading}\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 <Typography ellipsis>{textValue}</Typography>\n {opt.status ? <DocumentStatus status={opt.status} /> : null}\n </Flex>\n </ComboboxOption>\n );\n })}\n </Combobox>\n <Field.Error />\n <Field.Hint />\n </Field.Root>\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 <RelationModal relation={documentMeta}>{label}</RelationModal>\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","textValue","setTextValue","searchParams","setSearchParams","_q","toggleNotification","useNotification","fieldRef","useFocusInputField","searchParamsDebounced","useDebounce","searchForTrigger","useLazySearchRelationsQuery","idsToInclude","idsToOmit","handleSearch","search","s","hasNextPage","options","handleChange","relationId","find","opt","console","error","message","useLayoutEffect","Field","Root","Label","action","Combobox","autocomplete","hasMoreItems","onOpenChange","noOptionsMessage","loadingMessage","onLoadMore","onTextValueChange","text","onInputChange","event","currentTarget","ComboboxOption","Typography","ellipsis","DocumentStatus","Error","Hint","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","height","outerRef","itemCount","itemSize","itemData","ariaDescribedBy","canDrag","itemKey","innerElementType","ListItem","Box","style","originalLabel","originalStatus","collectionType","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","RelationModal","size","Cross","DisconnectButton","button","theme","colors","neutral600","neutral500","LinkEllipsis","Link","borderStyle","borderWidth","MemoizedRelationsField","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA;;;;AAIC,IACD,SAASA,mBAAAA,CAAoBC,SAAiB,EAAEC,YAAoB,EAAA;AAClE,IAAA,MAAMC,QAAQC,oBAASH,CAAAA,SAAAA,CAAAA;AACvB,IAAA,MAAMI,iBAAiBC,mBAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMF,cAAc,CAAA;AAC5E,IAAA,MAAMG,cAAcF,mBAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMC,WAA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AA,CAAgB,GAAG;;AAIxCwI,MAAAA,sBAAAA,iBAAyBzT,gBAAM0T,CAAAA,IAAI,CAAC3T,cAAAA;;;;;;;"}
1
+ {"version":3,"file":"Relations.js","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,oBAASH,CAAAA,SAAAA,CAAAA;AACvB,IAAA,MAAMI,iBAAiBC,mBAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMF,cAAc,CAAA;AAC5E,IAAA,MAAMG,cAAcF,mBAAQJ,CAAAA,YAAAA,EAAc,CAACK,KAAAA,GAAUA,MAAMC,WAAW,CAAA;AAEtE,IAAA,MAAMC,mBAA8D,CAACC,QAAAA,GAAAA;AACnE,QAAA,IAAIP,MAAMQ,KAAK,IAAIR,MAAMQ,KAAK,CAACC,OAAO,EAAE;AACtC;;;;AAIC,UACD,MAAMC,6BAAAA,GAAgCV,KAAMQ,CAAAA,KAAK,CAACC,OAAO,CAACE,SAAS,CACjE,CAACC,GAA4DA,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