@strapi/content-manager 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.f31889311d753b5f7d95198ae84d8fce1d156cd6

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 (175) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/{CardDragPreview-DSVYodBX.js → CardDragPreview-C0QyJgRA.js} +10 -14
  3. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
  4. package/dist/_chunks/{CardDragPreview-ikSG4M46.mjs → CardDragPreview-DOxamsuj.mjs} +7 -9
  5. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
  6. package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js → ComponentConfigurationPage-BNxtMIfV.js} +3 -3
  7. package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js.map → ComponentConfigurationPage-BNxtMIfV.js.map} +1 -1
  8. package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs → ComponentConfigurationPage-BWOQWCv2.mjs} +3 -3
  9. package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs.map → ComponentConfigurationPage-BWOQWCv2.mjs.map} +1 -1
  10. package/dist/_chunks/{ComponentIcon-BBQsYCVn.js → ComponentIcon-BXdiCGQp.js} +8 -2
  11. package/dist/_chunks/ComponentIcon-BXdiCGQp.js.map +1 -0
  12. package/dist/_chunks/{ComponentIcon-BOFnK76n.mjs → ComponentIcon-u4bIXTFY.mjs} +9 -3
  13. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
  14. package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js → EditConfigurationPage-D340bYlT.js} +3 -3
  15. package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js.map → EditConfigurationPage-D340bYlT.js.map} +1 -1
  16. package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs → EditConfigurationPage-GTp-Ucnw.mjs} +3 -3
  17. package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs.map → EditConfigurationPage-GTp-Ucnw.mjs.map} +1 -1
  18. package/dist/_chunks/{EditViewPage-DDS6H9HO.mjs → EditViewPage-BVMS5hT-.mjs} +47 -47
  19. package/dist/_chunks/EditViewPage-BVMS5hT-.mjs.map +1 -0
  20. package/dist/_chunks/{EditViewPage-DvNpQkam.js → EditViewPage-CXkmnAvI.js} +46 -48
  21. package/dist/_chunks/EditViewPage-CXkmnAvI.js.map +1 -0
  22. package/dist/_chunks/{Field-DmVKIAOo.js → Field-Ibi32diw.js} +953 -782
  23. package/dist/_chunks/Field-Ibi32diw.js.map +1 -0
  24. package/dist/_chunks/{Field-6gvGdPBV.mjs → Field-nNgv5bpd.mjs} +901 -729
  25. package/dist/_chunks/Field-nNgv5bpd.mjs.map +1 -0
  26. package/dist/_chunks/{Form-CPZC9vWa.js → Form-Dhnh34ym.js} +39 -38
  27. package/dist/_chunks/Form-Dhnh34ym.js.map +1 -0
  28. package/dist/_chunks/{Form-DW6K1IH-.mjs → Form-DodJsI2A.mjs} +39 -37
  29. package/dist/_chunks/Form-DodJsI2A.mjs.map +1 -0
  30. package/dist/_chunks/{History-DeAPlvtv.js → History-C9auUkDi.js} +149 -56
  31. package/dist/_chunks/History-C9auUkDi.js.map +1 -0
  32. package/dist/_chunks/{History-Dmr9fmUA.mjs → History-CKCSQXz_.mjs} +148 -54
  33. package/dist/_chunks/History-CKCSQXz_.mjs.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-DPCwW5Vr.js → ListConfigurationPage-Bg4rWUjX.js} +58 -59
  35. package/dist/_chunks/ListConfigurationPage-Bg4rWUjX.js.map +1 -0
  36. package/dist/_chunks/{ListConfigurationPage-DhwvYcNv.mjs → ListConfigurationPage-CKEC4ttG.mjs} +54 -54
  37. package/dist/_chunks/ListConfigurationPage-CKEC4ttG.mjs.map +1 -0
  38. package/dist/_chunks/{ListViewPage-BtAwuYLE.mjs → ListViewPage-B7_WJUjG.mjs} +93 -104
  39. package/dist/_chunks/ListViewPage-B7_WJUjG.mjs.map +1 -0
  40. package/dist/_chunks/{ListViewPage-5ySZ-VUs.js → ListViewPage-C2gIeYHG.js} +98 -109
  41. package/dist/_chunks/ListViewPage-C2gIeYHG.js.map +1 -0
  42. package/dist/_chunks/{NoContentTypePage-DSPxnxxp.mjs → NoContentTypePage-Ckem6Ll6.mjs} +3 -3
  43. package/dist/_chunks/NoContentTypePage-Ckem6Ll6.mjs.map +1 -0
  44. package/dist/_chunks/{NoContentTypePage-DOC_yWOf.js → NoContentTypePage-DqgdUfyn.js} +3 -3
  45. package/dist/_chunks/NoContentTypePage-DqgdUfyn.js.map +1 -0
  46. package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs → NoPermissionsPage-BO-GEjA4.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs.map → NoPermissionsPage-BO-GEjA4.mjs.map} +1 -1
  48. package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js → NoPermissionsPage-CF29Q-sW.js} +2 -2
  49. package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js.map → NoPermissionsPage-CF29Q-sW.js.map} +1 -1
  50. package/dist/_chunks/{Relations-CgWtgnPe.js → Relations-C0uC9J4f.js} +70 -61
  51. package/dist/_chunks/Relations-C0uC9J4f.js.map +1 -0
  52. package/dist/_chunks/{Relations-J8cscLlR.mjs → Relations-DItV5eow.mjs} +66 -56
  53. package/dist/_chunks/Relations-DItV5eow.mjs.map +1 -0
  54. package/dist/_chunks/{en-MBPul9Su.mjs → en-BrCTWlZv.mjs} +11 -4
  55. package/dist/_chunks/{en-MBPul9Su.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
  56. package/dist/_chunks/{en-C-V1_90f.js → en-uOUIxfcQ.js} +11 -4
  57. package/dist/_chunks/{en-C-V1_90f.js.map → en-uOUIxfcQ.js.map} +1 -1
  58. package/dist/_chunks/{index-C6AH2hEl.js → index-Dd0nXyJF.js} +1649 -905
  59. package/dist/_chunks/index-Dd0nXyJF.js.map +1 -0
  60. package/dist/_chunks/{index-CwRRo1V9.mjs → index-DrNe6ctw.mjs} +1671 -926
  61. package/dist/_chunks/index-DrNe6ctw.mjs.map +1 -0
  62. package/dist/_chunks/{layout-jIDzX0Fp.mjs → layout-B3ez7kvr.mjs} +43 -26
  63. package/dist/_chunks/layout-B3ez7kvr.mjs.map +1 -0
  64. package/dist/_chunks/{layout-B_SXLhqf.js → layout-CLLtt_5O.js} +43 -28
  65. package/dist/_chunks/layout-CLLtt_5O.js.map +1 -0
  66. package/dist/_chunks/{relations-CuvIgCqI.mjs → relations-B0hlsUU_.mjs} +2 -2
  67. package/dist/_chunks/{relations-CuvIgCqI.mjs.map → relations-B0hlsUU_.mjs.map} +1 -1
  68. package/dist/_chunks/{relations-iBMa_OFG.js → relations-bRxcNv1q.js} +2 -2
  69. package/dist/_chunks/{relations-iBMa_OFG.js.map → relations-bRxcNv1q.js.map} +1 -1
  70. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -1
  71. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -1
  72. package/dist/_chunks/usePrev-B9w_-eYc.js +15 -0
  73. package/dist/_chunks/usePrev-B9w_-eYc.js.map +1 -0
  74. package/dist/_chunks/usePrev-DH6iah0A.mjs +16 -0
  75. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -0
  76. package/dist/admin/index.js +2 -1
  77. package/dist/admin/index.js.map +1 -1
  78. package/dist/admin/index.mjs +5 -4
  79. package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
  80. package/dist/admin/src/content-manager.d.ts +3 -3
  81. package/dist/admin/src/exports.d.ts +1 -0
  82. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  83. package/dist/admin/src/history/index.d.ts +3 -0
  84. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  85. package/dist/admin/src/hooks/useDocument.d.ts +5 -8
  86. package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
  87. package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
  88. package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
  89. package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
  90. package/dist/admin/src/index.d.ts +1 -0
  91. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +11 -4
  92. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
  93. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  94. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
  95. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
  96. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
  97. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +30 -18
  98. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
  99. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
  100. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +2 -2
  101. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +59 -52
  102. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
  103. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  104. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  105. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
  106. package/dist/admin/src/services/api.d.ts +2 -3
  107. package/dist/admin/src/services/components.d.ts +2 -2
  108. package/dist/admin/src/services/contentTypes.d.ts +5 -5
  109. package/dist/admin/src/services/documents.d.ts +29 -17
  110. package/dist/admin/src/services/init.d.ts +2 -2
  111. package/dist/admin/src/services/relations.d.ts +3 -3
  112. package/dist/admin/src/services/uid.d.ts +3 -3
  113. package/dist/admin/src/utils/api.d.ts +4 -18
  114. package/dist/admin/src/utils/validation.d.ts +1 -6
  115. package/dist/server/index.js +392 -261
  116. package/dist/server/index.js.map +1 -1
  117. package/dist/server/index.mjs +400 -269
  118. package/dist/server/index.mjs.map +1 -1
  119. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  120. package/dist/server/src/controllers/single-types.d.ts.map +1 -1
  121. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  122. package/dist/server/src/controllers/utils/metadata.d.ts +8 -0
  123. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
  124. package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
  125. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
  126. package/dist/server/src/controllers/validation/index.d.ts +1 -1
  127. package/dist/server/src/history/services/history.d.ts.map +1 -1
  128. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  129. package/dist/server/src/history/services/utils.d.ts +1 -1
  130. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  131. package/dist/server/src/index.d.ts +18 -39
  132. package/dist/server/src/index.d.ts.map +1 -1
  133. package/dist/server/src/services/document-manager.d.ts +13 -12
  134. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  135. package/dist/server/src/services/document-metadata.d.ts +8 -29
  136. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  137. package/dist/server/src/services/index.d.ts +18 -39
  138. package/dist/server/src/services/index.d.ts.map +1 -1
  139. package/dist/server/src/services/utils/populate.d.ts +8 -1
  140. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  141. package/dist/shared/contracts/collection-types.d.ts +14 -6
  142. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  143. package/dist/shared/contracts/relations.d.ts +2 -2
  144. package/dist/shared/contracts/relations.d.ts.map +1 -1
  145. package/package.json +13 -14
  146. package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
  147. package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
  148. package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
  149. package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
  150. package/dist/_chunks/EditViewPage-DDS6H9HO.mjs.map +0 -1
  151. package/dist/_chunks/EditViewPage-DvNpQkam.js.map +0 -1
  152. package/dist/_chunks/Field-6gvGdPBV.mjs.map +0 -1
  153. package/dist/_chunks/Field-DmVKIAOo.js.map +0 -1
  154. package/dist/_chunks/Form-CPZC9vWa.js.map +0 -1
  155. package/dist/_chunks/Form-DW6K1IH-.mjs.map +0 -1
  156. package/dist/_chunks/History-DeAPlvtv.js.map +0 -1
  157. package/dist/_chunks/History-Dmr9fmUA.mjs.map +0 -1
  158. package/dist/_chunks/ListConfigurationPage-DPCwW5Vr.js.map +0 -1
  159. package/dist/_chunks/ListConfigurationPage-DhwvYcNv.mjs.map +0 -1
  160. package/dist/_chunks/ListViewPage-5ySZ-VUs.js.map +0 -1
  161. package/dist/_chunks/ListViewPage-BtAwuYLE.mjs.map +0 -1
  162. package/dist/_chunks/NoContentTypePage-DOC_yWOf.js.map +0 -1
  163. package/dist/_chunks/NoContentTypePage-DSPxnxxp.mjs.map +0 -1
  164. package/dist/_chunks/Relations-CgWtgnPe.js.map +0 -1
  165. package/dist/_chunks/Relations-J8cscLlR.mjs.map +0 -1
  166. package/dist/_chunks/index-C6AH2hEl.js.map +0 -1
  167. package/dist/_chunks/index-CwRRo1V9.mjs.map +0 -1
  168. package/dist/_chunks/layout-B_SXLhqf.js.map +0 -1
  169. package/dist/_chunks/layout-jIDzX0Fp.mjs.map +0 -1
  170. package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
  171. package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
  172. package/dist/_chunks/urls-DzZya_gm.js +0 -6
  173. package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
  174. package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
  175. package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"relations-iBMa_OFG.js","sources":["../../admin/src/services/relations.ts","../../admin/src/utils/relations.ts"],"sourcesContent":["import { generateNKeysBetween } from 'fractional-indexing';\n\nimport {\n RelationResult as RelResult,\n FindAvailable,\n FindExisting,\n} from '../../../shared/contracts/relations';\n\nimport { contentManagerApi } from './api';\n\nimport type { Modules } from '@strapi/types';\nimport type { errors } from '@strapi/utils';\n\ninterface RelationResult extends RelResult {\n __temp_key__: string;\n}\n\ntype GetRelationsResponse =\n | {\n results: Array<RelationResult>;\n pagination: {\n page: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['page']>;\n pageSize: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['pageSize']>;\n pageCount: number;\n total: number;\n } | null;\n error?: never;\n }\n | {\n results?: never;\n pagination?: never;\n error: errors.ApplicationError | errors.YupValidationError;\n };\n\nconst relationsApi = contentManagerApi.injectEndpoints({\n endpoints: (build) => ({\n getRelations: build.query<\n GetRelationsResponse,\n FindExisting.Params & {\n params?: FindExisting.Request['query'];\n }\n >({\n query: ({ model, id, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${id}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n id: queryArgs.id,\n targetField: queryArgs.targetField,\n locale: queryArgs.params?.locale,\n status: queryArgs.params?.status,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...prepareTempKeys(uniqueNewItems, currentCache.results));\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = prepareTempKeys(newItems.results);\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindExisting.Response) => {\n if ('results' in response && response.results) {\n return {\n ...response,\n results: prepareTempKeys(response.results.toReversed()),\n };\n } else {\n return response;\n }\n },\n providesTags: ['Relations'],\n }),\n searchRelations: build.query<\n FindAvailable.Response,\n FindAvailable.Params & {\n params?: FindAvailable.Request['query'];\n }\n >({\n query: ({ model, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n targetField: queryArgs.targetField,\n _q: queryArgs.params?._q,\n idsToOmit: queryArgs.params?.idsToOmit,\n idsToInclude: queryArgs.params?.idsToInclude,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...uniqueNewItems);\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = newItems.results;\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindAvailable.Response) => {\n if (response.results) {\n return {\n ...response,\n results: response.results,\n };\n } else {\n return response;\n }\n },\n }),\n }),\n});\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each relation item. This gives us\n * a stable identifier regardless of it's ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {\n const [firstItem] = existingRelations.slice(0);\n\n const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);\n\n return relations.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n};\n\nconst { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;\n\nexport { useGetRelationsQuery, useLazySearchRelationsQuery };\nexport type { RelationResult };\n","import type { MainField } from './attributes';\nimport type { RelationResult } from '../../../shared/contracts/relations';\n\n/**\n * @internal\n * @description Get the label of a relation, the contract has [key: string]: unknown,\n * so we need to check if the mainFieldKey is defined and if the relation has a value\n * under that property. If it does, we then verify it's type of string and return it.\n *\n * We fallback to the documentId.\n */\nconst getRelationLabel = (relation: RelationResult, mainField?: MainField): string => {\n const label = mainField && relation[mainField.name] ? relation[mainField.name] : null;\n\n if (typeof label === 'string') {\n return label;\n }\n\n return relation.documentId;\n};\n\nexport { getRelationLabel };\n"],"names":["contentManagerApi","generateNKeysBetween","index"],"mappings":";;;AAkCA,MAAM,eAAeA,wBAAkB,gBAAgB;AAAA,EACrD,WAAW,CAAC,WAAW;AAAA,IACrB,cAAc,MAAM,MAKlB;AAAA,MACA,OAAO,CAAC,EAAE,OAAO,IAAI,aAAa,aAAa;AACtC,eAAA;AAAA,UACL,KAAK,8BAA8B,KAAK,IAAI,EAAE,IAAI,WAAW;AAAA,UAC7D,QAAQ;AAAA,UACR,QAAQ;AAAA,YACN;AAAA,UACF;AAAA,QAAA;AAAA,MAEJ;AAAA,MACA,oBAAoB,CAAC,SAA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AAS,SAAS;AAAA,UAAA;AAAA,QACpB,OACK;AACE,iBAAA;AAAA,QACT;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAEL,CAAC;AAOD,MAAM,kBAAkB,CAAC,WAAwB,oBAAsC,OAAO;AAC5F,QAAM,CAAC,SAAS,IAAI,kBAAkB,MAAM,CAAC;AAE7C,QAAM,OAAOC,mBAAqB,qBAAA,MAAM,WAAW,gBAAgB,MAAM,UAAU,MAAM;AAEzF,SAAO,UAAU,IAAI,CAAC,OAAOC,YAAW;AAAA,IACtC,GAAG;AAAA,IACH,cAAc,KAAKA,MAAK;AAAA,EACxB,EAAA;AACJ;AAEM,MAAA,EAAE,sBAAsB,gCAAgC;ACvLxD,MAAA,mBAAmB,CAAC,UAA0B,cAAkC;AAC9E,QAAA,QAAQ,aAAa,SAAS,UAAU,IAAI,IAAI,SAAS,UAAU,IAAI,IAAI;AAE7E,MAAA,OAAO,UAAU,UAAU;AACtB,WAAA;AAAA,EACT;AAEA,SAAO,SAAS;AAClB;;;;"}
1
+ {"version":3,"file":"relations-bRxcNv1q.js","sources":["../../admin/src/services/relations.ts","../../admin/src/utils/relations.ts"],"sourcesContent":["import { generateNKeysBetween } from 'fractional-indexing';\n\nimport {\n RelationResult as RelResult,\n FindAvailable,\n FindExisting,\n} from '../../../shared/contracts/relations';\n\nimport { contentManagerApi } from './api';\n\nimport type { Modules } from '@strapi/types';\nimport type { errors } from '@strapi/utils';\n\ninterface RelationResult extends RelResult {\n __temp_key__: string;\n}\n\ntype GetRelationsResponse =\n | {\n results: Array<RelationResult>;\n pagination: {\n page: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['page']>;\n pageSize: NonNullable<Modules.EntityService.Params.Pagination.PageNotation['pageSize']>;\n pageCount: number;\n total: number;\n } | null;\n error?: never;\n }\n | {\n results?: never;\n pagination?: never;\n error: errors.ApplicationError | errors.YupValidationError;\n };\n\nconst relationsApi = contentManagerApi.injectEndpoints({\n endpoints: (build) => ({\n getRelations: build.query<\n GetRelationsResponse,\n FindExisting.Params & {\n params?: FindExisting.Request['query'];\n }\n >({\n query: ({ model, id, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${id}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n id: queryArgs.id,\n targetField: queryArgs.targetField,\n locale: queryArgs.params?.locale,\n status: queryArgs.params?.status,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...prepareTempKeys(uniqueNewItems, currentCache.results));\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = prepareTempKeys(newItems.results);\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindExisting.Response) => {\n if ('results' in response && response.results) {\n return {\n ...response,\n results: prepareTempKeys(response.results.toReversed()),\n };\n } else {\n return response;\n }\n },\n providesTags: ['Relations'],\n }),\n searchRelations: build.query<\n FindAvailable.Response,\n FindAvailable.Params & {\n params?: FindAvailable.Request['query'];\n }\n >({\n query: ({ model, targetField, params }) => {\n return {\n url: `/content-manager/relations/${model}/${targetField}`,\n method: 'GET',\n config: {\n params,\n },\n };\n },\n serializeQueryArgs: (args) => {\n const { endpointName, queryArgs } = args;\n return {\n endpointName,\n model: queryArgs.model,\n targetField: queryArgs.targetField,\n _q: queryArgs.params?._q,\n idsToOmit: queryArgs.params?.idsToOmit,\n idsToInclude: queryArgs.params?.idsToInclude,\n };\n },\n merge: (currentCache, newItems) => {\n if (currentCache.pagination && newItems.pagination) {\n if (currentCache.pagination.page < newItems.pagination.page) {\n /**\n * Relations will always have unique IDs, so we can therefore assume\n * that we only need to push the new items to the cache.\n */\n const existingIds = currentCache.results.map((item) => item.documentId);\n const uniqueNewItems = newItems.results.filter(\n (item) => !existingIds.includes(item.documentId)\n );\n currentCache.results.push(...uniqueNewItems);\n currentCache.pagination = newItems.pagination;\n } else if (newItems.pagination.page === 1) {\n /**\n * We're resetting the relations\n */\n currentCache.results = newItems.results;\n currentCache.pagination = newItems.pagination;\n }\n }\n },\n forceRefetch({ currentArg, previousArg }) {\n if (!currentArg?.params && !previousArg?.params) {\n return false;\n }\n\n return (\n currentArg?.params?.page !== previousArg?.params?.page ||\n currentArg?.params?.pageSize !== previousArg?.params?.pageSize\n );\n },\n transformResponse: (response: FindAvailable.Response) => {\n if (response.results) {\n return {\n ...response,\n results: response.results,\n };\n } else {\n return response;\n }\n },\n }),\n }),\n});\n\n/**\n * @internal\n * @description Adds a `__temp_key__` to each relation item. This gives us\n * a stable identifier regardless of it's ids etc. that we can then use for drag and drop.\n */\nconst prepareTempKeys = (relations: RelResult[], existingRelations: RelationResult[] = []) => {\n const [firstItem] = existingRelations.slice(0);\n\n const keys = generateNKeysBetween(null, firstItem?.__temp_key__ ?? null, relations.length);\n\n return relations.map((datum, index) => ({\n ...datum,\n __temp_key__: keys[index],\n }));\n};\n\nconst { useGetRelationsQuery, useLazySearchRelationsQuery } = relationsApi;\n\nexport { useGetRelationsQuery, useLazySearchRelationsQuery };\nexport type { RelationResult };\n","import type { MainField } from './attributes';\nimport type { RelationResult } from '../../../shared/contracts/relations';\n\n/**\n * @internal\n * @description Get the label of a relation, the contract has [key: string]: unknown,\n * so we need to check if the mainFieldKey is defined and if the relation has a value\n * under that property. If it does, we then verify it's type of string and return it.\n *\n * We fallback to the documentId.\n */\nconst getRelationLabel = (relation: RelationResult, mainField?: MainField): string => {\n const label = mainField && relation[mainField.name] ? relation[mainField.name] : null;\n\n if (typeof label === 'string') {\n return label;\n }\n\n return relation.documentId;\n};\n\nexport { getRelationLabel };\n"],"names":["contentManagerApi","generateNKeysBetween","index"],"mappings":";;;AAkCA,MAAM,eAAeA,wBAAkB,gBAAgB;AAAA,EACrD,WAAW,CAAC,WAAW;AAAA,IACrB,cAAc,MAAM,MAKlB;AAAA,MACA,OAAO,CAAC,EAAE,OAAO,IAAI,aAAa,aAAa;AACtC,eAAA;AAAA,UACL,KAAK,8BAA8B,KAAK,IAAI,EAAE,IAAI,WAAW;AAAA,UAC7D,QAAQ;AAAA,UACR,QAAQ;AAAA,YACN;AAAA,UACF;AAAA,QAAA;AAAA,MAEJ;AAAA,MACA,oBAAoB,CAAC,SAAS;AACtB,cAAA,EAAE,cAAc,UAAc,IAAA;AAC7B,eAAA;AAAA,UACL;AAAA,UACA,OAAO,UAAU;AAAA,UACjB,IAAI,UAAU;AAAA,UACd,aAAa,UAAU;AAAA,UACvB,QAAQ,UAAU,QAAQ;AAAA,UAC1B,QAAQ,UAAU,QAAQ;AAAA,QAAA;AAAA,MAE9B;AAAA,MACA,OAAO,CAAC,cAAc,aAAa;AAC7B,YAAA,aAAa,cAAc,SAAS,YAAY;AAClD,cAAI,aAAa,WAAW,OAAO,SAAS,WAAW,MAAM;AAK3D,kBAAM,cAAc,aAAa,QAAQ,IAAI,CAAC,SAAS,KAAK,UAAU;AAChE,kBAAA,iBAAiB,SAAS,QAAQ;AAAA,cACtC,CAAC,SAAS,CAAC,YAAY,SAAS,KAAK,UAAU;AAAA,YAAA;AAEjD,yBAAa,QAAQ,KAAK,GAAG,gBAAgB,gBAAgB,aAAa,OAAO,CAAC;AAClF,yBAAa,aAAa,SAAS;AAAA,UAC1B,WAAA,SAAS,WAAW,SAAS,GAAG;AAI5B,yBAAA,UAAU,gBAAgB,SAAS,OAAO;AACvD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qq.mjs","sources":["../../admin/src/constants/dragAndDrop.ts","../../admin/src/hooks/useKeyboardDragAndDrop.ts","../../admin/src/hooks/useDragAndDrop.ts"],"sourcesContent":["export const ItemTypes = {\n COMPONENT: 'component',\n EDIT_FIELD: 'editField',\n FIELD: 'field',\n DYNAMIC_ZONE: 'dynamicZone',\n RELATION: 'relation',\n BLOCKS: 'blocks',\n} as const;\n","import * as React from 'react';\n\nexport type UseKeyboardDragAndDropCallbacks<TIndex extends number | Array<number> = number> = {\n onCancel?: (index: TIndex) => void;\n onDropItem?: (currentIndex: TIndex, newIndex?: TIndex) => void;\n onGrabItem?: (index: TIndex) => void;\n onMoveItem?: (newIndex: TIndex, currentIndex: TIndex) => void;\n};\n\n/**\n * Utility hook designed to implement keyboard accessibile drag and drop by\n * returning an onKeyDown handler to be passed to the drag icon button.\n *\n * @internal - You should use `useDragAndDrop` instead.\n */\nexport const useKeyboardDragAndDrop = <TIndex extends number | Array<number> = number>(\n active: boolean,\n index: TIndex,\n { onCancel, onDropItem, onGrabItem, onMoveItem }: UseKeyboardDragAndDropCallbacks<TIndex>\n) => {\n const [isSelected, setIsSelected] = React.useState(false);\n\n const handleMove = (movement: 'UP' | 'DOWN') => {\n if (!isSelected) {\n return;\n }\n if (typeof index === 'number' && onMoveItem) {\n if (movement === 'UP') {\n onMoveItem((index - 1) as TIndex, index);\n } else if (movement === 'DOWN') {\n onMoveItem((index + 1) as TIndex, index);\n }\n }\n };\n\n const handleDragClick = () => {\n if (isSelected) {\n if (onDropItem) {\n onDropItem(index);\n }\n setIsSelected(false);\n } else {\n if (onGrabItem) {\n onGrabItem(index);\n }\n setIsSelected(true);\n }\n };\n\n const handleCancel = () => {\n if (isSelected) {\n setIsSelected(false);\n\n if (onCancel) {\n onCancel(index);\n }\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLButtonElement> = (e) => {\n if (!active) {\n return;\n }\n\n if (e.key === 'Tab' && !isSelected) {\n return;\n }\n\n e.preventDefault();\n\n switch (e.key) {\n case ' ':\n case 'Enter':\n handleDragClick();\n break;\n\n case 'Escape':\n handleCancel();\n break;\n\n case 'ArrowDown':\n case 'ArrowRight':\n handleMove('DOWN');\n break;\n\n case 'ArrowUp':\n case 'ArrowLeft':\n handleMove('UP');\n break;\n\n default:\n }\n };\n\n return handleKeyDown;\n};\n","import * as React from 'react';\n\nimport {\n useDrag,\n useDrop,\n type HandlerManager,\n type ConnectDragSource,\n type ConnectDropTarget,\n type ConnectDragPreview,\n type DragSourceMonitor,\n} from 'react-dnd';\n\nimport {\n useKeyboardDragAndDrop,\n type UseKeyboardDragAndDropCallbacks,\n} from './useKeyboardDragAndDrop';\n\nimport type { Data } from '@strapi/types';\n\nconst DIRECTIONS = {\n UPWARD: 'upward',\n DOWNWARD: 'downward',\n} as const;\n\nconst DROP_SENSITIVITY = {\n REGULAR: 'regular',\n IMMEDIATE: 'immediate',\n} as const;\n\ninterface UseDragAndDropOptions<\n TIndex extends number | Array<number> = number,\n TItem extends { index: TIndex } = { index: TIndex },\n> extends UseKeyboardDragAndDropCallbacks<TIndex> {\n type?: string;\n index: TIndex;\n item?: TItem;\n onStart?: () => void;\n onEnd?: () => void;\n dropSensitivity?: (typeof DROP_SENSITIVITY)[keyof typeof DROP_SENSITIVITY];\n}\n\ntype Identifier = ReturnType<HandlerManager['getHandlerId']>;\n\ntype UseDragAndDropReturn<Element extends HTMLElement = HTMLElement> = [\n props: {\n handlerId: Identifier;\n isDragging: boolean;\n handleKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>) => void;\n isOverDropTarget: boolean;\n direction: (typeof DIRECTIONS)[keyof typeof DIRECTIONS] | null;\n },\n objectRef: React.RefObject<Element>,\n dropRef: ConnectDropTarget,\n dragRef: ConnectDragSource,\n dragPreviewRef: ConnectDragPreview,\n];\n\ntype DropCollectedProps = {\n handlerId: Identifier;\n isOver: boolean;\n};\n\n/**\n * A utility hook abstracting the general drag and drop hooks from react-dnd.\n * Centralising the same behaviours and by default offering keyboard support.\n */\nconst useDragAndDrop = <\n TIndex extends number | Array<number>,\n TItem extends { index: TIndex; id?: Data.ID; [key: string]: unknown } = {\n index: TIndex;\n [key: string]: unknown;\n },\n Element extends HTMLElement = HTMLElement,\n>(\n active: boolean,\n {\n type = 'STRAPI_DND',\n index,\n item,\n onStart,\n onEnd,\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n dropSensitivity = DROP_SENSITIVITY.REGULAR,\n }: UseDragAndDropOptions<TIndex, TItem>\n): UseDragAndDropReturn<Element> => {\n const objectRef = React.useRef<Element>(null);\n\n const [{ handlerId, isOver }, dropRef] = useDrop<TItem, void, DropCollectedProps>({\n accept: type,\n collect(monitor) {\n return {\n handlerId: monitor.getHandlerId(),\n isOver: monitor.isOver({ shallow: true }),\n };\n },\n drop(item) {\n const draggedIndex = item.index;\n const newIndex = index;\n\n if (isOver && onDropItem) {\n onDropItem(draggedIndex, newIndex);\n }\n },\n hover(item, monitor) {\n if (!objectRef.current || !onMoveItem) {\n return;\n }\n\n const dragIndex = item.index;\n const newIndex = index;\n\n const hoverBoundingRect = objectRef.current?.getBoundingClientRect();\n const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (!clientOffset) return;\n\n const hoverClientY = clientOffset && clientOffset.y - hoverBoundingRect.top;\n if (typeof dragIndex === 'number' && typeof newIndex === 'number') {\n if (dragIndex === newIndex) {\n // Don't replace items with themselves\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (dragIndex < newIndex && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (dragIndex > newIndex && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n\n // Time to actually perform the action\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n } else {\n // Using numbers as indices doesn't work for nested list items with path like [1, 1, 0]\n if (Array.isArray(dragIndex) && Array.isArray(newIndex)) {\n // Indices comparison to find item position in nested list\n const minLength = Math.min(dragIndex.length, newIndex.length);\n let areEqual = true;\n let isLessThan = false;\n let isGreaterThan = false;\n\n for (let i = 0; i < minLength; i++) {\n if (dragIndex[i] < newIndex[i]) {\n isLessThan = true;\n areEqual = false;\n break;\n } else if (dragIndex[i] > newIndex[i]) {\n isGreaterThan = true;\n areEqual = false;\n break;\n }\n }\n\n // Don't replace items with themselves\n if (areEqual && dragIndex.length === newIndex.length) {\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (isLessThan && !isGreaterThan && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (isGreaterThan && !isLessThan && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n }\n\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n }\n },\n });\n\n const getDragDirection = (monitor: DragSourceMonitor<TItem, void>) => {\n if (\n monitor &&\n monitor.isDragging() &&\n !monitor.didDrop() &&\n monitor.getInitialClientOffset() &&\n monitor.getClientOffset()\n ) {\n const deltaY = monitor.getInitialClientOffset()!.y - monitor.getClientOffset()!.y;\n\n if (deltaY > 0) return DIRECTIONS.UPWARD;\n\n if (deltaY < 0) return DIRECTIONS.DOWNWARD;\n\n return null;\n }\n\n return null;\n };\n\n const [{ isDragging, direction }, dragRef, dragPreviewRef] = useDrag({\n type,\n item() {\n if (onStart) {\n onStart();\n }\n\n /**\n * This will be attached and it helps define the preview sizes\n * when a component is flexy e.g. Relations\n */\n const { width } = objectRef.current?.getBoundingClientRect() ?? {};\n\n return { index, width, ...item };\n },\n end() {\n if (onEnd) {\n onEnd();\n }\n },\n canDrag: active,\n /**\n * This is useful when the item is in a virtualized list.\n * However, if we don't have an ID then we want the libraries\n * defaults to take care of this.\n */\n isDragging: item?.id\n ? (monitor) => {\n return item.id === monitor.getItem().id;\n }\n : undefined,\n collect: (monitor) => ({\n isDragging: monitor.isDragging(),\n initialOffset: monitor.getInitialClientOffset(),\n currentOffset: monitor.getClientOffset(),\n direction: getDragDirection(monitor),\n }),\n });\n\n const handleKeyDown = useKeyboardDragAndDrop(active, index, {\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n });\n\n return [\n { handlerId, isDragging, handleKeyDown, isOverDropTarget: isOver, direction },\n objectRef,\n dropRef,\n dragRef,\n dragPreviewRef,\n ];\n};\n\nexport {\n useDragAndDrop,\n UseDragAndDropReturn,\n UseDragAndDropOptions,\n DIRECTIONS,\n DROP_SENSITIVITY,\n};\n"],"names":["item"],"mappings":";;AAAO,MAAM,YAAY;AAAA,EACvB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,cAAc;AAAA,EACd,UAAU;AAAA,EACV,QAAQ;AACV;ACQa,MAAA,yBAAyB,CACpC,QACA,OACA,EAAE,UAAU,YAAY,YAAY,iBACjC;AACH,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,KAAK;AAElD,QAAA,aAAa,CAAC,aAA4B;AAC9C,QAAI,CAAC,YAAY;AACf;AAAA,IACF;AACI,QAAA,OAAO,UAAU,YAAY,YAAY;AAC3C,UAAI,aAAa,MAAM;AACT,mBAAA,QAAQ,GAAc,KAAK;AAAA,MAAA,WAC9B,aAAa,QAAQ;AAClB,mBAAA,QAAQ,GAAc,KAAK;AAAA,MACzC;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,kBAAkB,MAAM;AAC5B,QAAI,YAAY;AACd,UAAI,YAAY;AACd,mBAAW,KAAK;AAAA,MAClB;AACA,oBAAc,KAAK;AAAA,IAAA,OACd;AACL,UAAI,YAAY;AACd,mBAAW,KAAK;AAAA,MAClB;AACA,oBAAc,IAAI;AAAA,IACpB;AAAA,EAAA;AAGF,QAAM,eAAe,MAAM;AACzB,QAAI,YAAY;AACd,oBAAc,KAAK;AAEnB,UAAI,UAAU;AACZ,iBAAS,KAAK;AAAA,MAChB;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,gBAA+D,CAAC,MAAM;AAC1E,QAAI,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ardDragAndDrop.ts","../../admin/src/hooks/useDragAndDrop.ts"],"sourcesContent":["export const ItemTypes = {\n COMPONENT: 'component',\n EDIT_FIELD: 'editField',\n FIELD: 'field',\n DYNAMIC_ZONE: 'dynamicZone',\n RELATION: 'relation',\n BLOCKS: 'blocks',\n} as const;\n","import * as React from 'react';\n\nexport type UseKeyboardDragAndDropCallbacks<TIndex extends number | Array<number> = number> = {\n onCancel?: (index: TIndex) => void;\n onDropItem?: (currentIndex: TIndex, newIndex?: TIndex) => void;\n onGrabItem?: (index: TIndex) => void;\n onMoveItem?: (newIndex: TIndex, currentIndex: TIndex) => void;\n};\n\n/**\n * Utility hook designed to implement keyboard accessibile drag and drop by\n * returning an onKeyDown handler to be passed to the drag icon button.\n *\n * @internal - You should use `useDragAndDrop` instead.\n */\nexport const useKeyboardDragAndDrop = <TIndex extends number | Array<number> = number>(\n active: boolean,\n index: TIndex,\n { onCancel, onDropItem, onGrabItem, onMoveItem }: UseKeyboardDragAndDropCallbacks<TIndex>\n) => {\n const [isSelected, setIsSelected] = React.useState(false);\n\n const handleMove = (movement: 'UP' | 'DOWN') => {\n if (!isSelected) {\n return;\n }\n if (typeof index === 'number' && onMoveItem) {\n if (movement === 'UP') {\n onMoveItem((index - 1) as TIndex, index);\n } else if (movement === 'DOWN') {\n onMoveItem((index + 1) as TIndex, index);\n }\n }\n };\n\n const handleDragClick = () => {\n if (isSelected) {\n if (onDropItem) {\n onDropItem(index);\n }\n setIsSelected(false);\n } else {\n if (onGrabItem) {\n onGrabItem(index);\n }\n setIsSelected(true);\n }\n };\n\n const handleCancel = () => {\n if (isSelected) {\n setIsSelected(false);\n\n if (onCancel) {\n onCancel(index);\n }\n }\n };\n\n const handleKeyDown = <E extends Element>(e: React.KeyboardEvent<E>) => {\n if (!active) {\n return;\n }\n\n if (e.key === 'Tab' && !isSelected) {\n return;\n }\n\n e.preventDefault();\n\n switch (e.key) {\n case ' ':\n case 'Enter':\n handleDragClick();\n break;\n\n case 'Escape':\n handleCancel();\n break;\n\n case 'ArrowDown':\n case 'ArrowRight':\n handleMove('DOWN');\n break;\n\n case 'ArrowUp':\n case 'ArrowLeft':\n handleMove('UP');\n break;\n\n default:\n }\n };\n\n return handleKeyDown;\n};\n","import * as React from 'react';\n\nimport {\n useDrag,\n useDrop,\n type HandlerManager,\n type ConnectDragSource,\n type ConnectDropTarget,\n type ConnectDragPreview,\n type DragSourceMonitor,\n} from 'react-dnd';\n\nimport {\n useKeyboardDragAndDrop,\n type UseKeyboardDragAndDropCallbacks,\n} from './useKeyboardDragAndDrop';\n\nimport type { Data } from '@strapi/types';\n\nconst DIRECTIONS = {\n UPWARD: 'upward',\n DOWNWARD: 'downward',\n} as const;\n\nconst DROP_SENSITIVITY = {\n REGULAR: 'regular',\n IMMEDIATE: 'immediate',\n} as const;\n\ninterface UseDragAndDropOptions<\n TIndex extends number | Array<number> = number,\n TItem extends { index: TIndex } = { index: TIndex },\n> extends UseKeyboardDragAndDropCallbacks<TIndex> {\n type?: string;\n index: TIndex;\n item?: TItem;\n onStart?: () => void;\n onEnd?: () => void;\n dropSensitivity?: (typeof DROP_SENSITIVITY)[keyof typeof DROP_SENSITIVITY];\n}\n\ntype Identifier = ReturnType<HandlerManager['getHandlerId']>;\n\ntype UseDragAndDropReturn<E extends Element = HTMLElement> = [\n props: {\n handlerId: Identifier;\n isDragging: boolean;\n handleKeyDown: <E extends Element>(event: React.KeyboardEvent<E>) => void;\n isOverDropTarget: boolean;\n direction: (typeof DIRECTIONS)[keyof typeof DIRECTIONS] | null;\n },\n objectRef: React.RefObject<E>,\n dropRef: ConnectDropTarget,\n dragRef: ConnectDragSource,\n dragPreviewRef: ConnectDragPreview,\n];\n\ntype DropCollectedProps = {\n handlerId: Identifier;\n isOver: boolean;\n};\n\n/**\n * A utility hook abstracting the general drag and drop hooks from react-dnd.\n * Centralising the same behaviours and by default offering keyboard support.\n */\nconst useDragAndDrop = <\n TIndex extends number | Array<number>,\n TItem extends { index: TIndex; id?: Data.ID; [key: string]: unknown } = {\n index: TIndex;\n [key: string]: unknown;\n },\n E extends Element = HTMLElement,\n>(\n active: boolean,\n {\n type = 'STRAPI_DND',\n index,\n item,\n onStart,\n onEnd,\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n dropSensitivity = DROP_SENSITIVITY.REGULAR,\n }: UseDragAndDropOptions<TIndex, TItem>\n): UseDragAndDropReturn<E> => {\n const objectRef = React.useRef<E>(null);\n\n const [{ handlerId, isOver }, dropRef] = useDrop<TItem, void, DropCollectedProps>({\n accept: type,\n collect(monitor) {\n return {\n handlerId: monitor.getHandlerId(),\n isOver: monitor.isOver({ shallow: true }),\n };\n },\n drop(item) {\n const draggedIndex = item.index;\n const newIndex = index;\n\n if (isOver && onDropItem) {\n onDropItem(draggedIndex, newIndex);\n }\n },\n hover(item, monitor) {\n if (!objectRef.current || !onMoveItem) {\n return;\n }\n\n const dragIndex = item.index;\n const newIndex = index;\n\n const hoverBoundingRect = objectRef.current?.getBoundingClientRect();\n const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (!clientOffset) return;\n\n const hoverClientY = clientOffset && clientOffset.y - hoverBoundingRect.top;\n if (typeof dragIndex === 'number' && typeof newIndex === 'number') {\n if (dragIndex === newIndex) {\n // Don't replace items with themselves\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (dragIndex < newIndex && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (dragIndex > newIndex && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n\n // Time to actually perform the action\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n } else {\n // Using numbers as indices doesn't work for nested list items with path like [1, 1, 0]\n if (Array.isArray(dragIndex) && Array.isArray(newIndex)) {\n // Indices comparison to find item position in nested list\n const minLength = Math.min(dragIndex.length, newIndex.length);\n let areEqual = true;\n let isLessThan = false;\n let isGreaterThan = false;\n\n for (let i = 0; i < minLength; i++) {\n if (dragIndex[i] < newIndex[i]) {\n isLessThan = true;\n areEqual = false;\n break;\n } else if (dragIndex[i] > newIndex[i]) {\n isGreaterThan = true;\n areEqual = false;\n break;\n }\n }\n\n // Don't replace items with themselves\n if (areEqual && dragIndex.length === newIndex.length) {\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (isLessThan && !isGreaterThan && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (isGreaterThan && !isLessThan && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n }\n\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n }\n },\n });\n\n const getDragDirection = (monitor: DragSourceMonitor<TItem, void>) => {\n if (\n monitor &&\n monitor.isDragging() &&\n !monitor.didDrop() &&\n monitor.getInitialClientOffset() &&\n monitor.getClientOffset()\n ) {\n const deltaY = monitor.getInitialClientOffset()!.y - monitor.getClientOffset()!.y;\n\n if (deltaY > 0) return DIRECTIONS.UPWARD;\n\n if (deltaY < 0) return DIRECTIONS.DOWNWARD;\n\n return null;\n }\n\n return null;\n };\n\n const [{ isDragging, direction }, dragRef, dragPreviewRef] = useDrag({\n type,\n item() {\n if (onStart) {\n onStart();\n }\n\n /**\n * This will be attached and it helps define the preview sizes\n * when a component is flexy e.g. Relations\n */\n const { width } = objectRef.current?.getBoundingClientRect() ?? {};\n\n return { index, width, ...item };\n },\n end() {\n if (onEnd) {\n onEnd();\n }\n },\n canDrag: active,\n /**\n * This is useful when the item is in a virtualized list.\n * However, if we don't have an ID then we want the libraries\n * defaults to take care of this.\n */\n isDragging: item?.id\n ? (monitor) => {\n return item.id === monitor.getItem().id;\n }\n : undefined,\n collect: (monitor) => ({\n isDragging: monitor.isDragging(),\n initialOffset: monitor.getInitialClientOffset(),\n currentOffset: monitor.getClientOffset(),\n direction: getDragDirection(monitor),\n }),\n });\n\n const handleKeyDown = useKeyboardDragAndDrop(active, index, {\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n });\n\n return [\n { handlerId, isDragging, handleKeyDown, isOverDropTarget: isOver, direction },\n objectRef,\n dropRef,\n dragRef,\n dragPreviewRef,\n ];\n};\n\nexport {\n useDragAndDrop,\n UseDragAndDropReturn,\n UseDragAndDropOptions,\n DIRECTIONS,\n DROP_SENSITIVITY,\n};\n"],"names":["item"],"mappings":";;AAAO,MAAM,YAAY;AAAA,EACvB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,cAAc;AAAA,EACd,UAAU;AAAA,EACV,QAAQ;AACV;ACQa,MAAA,yBAAyB,CACpC,QACA,OACA,EAAE,UAAU,YAAY,YAAY,iBACjC;AACH,QAAM,CAAC,YAAY,aAAa,IAAI,MAAM,SAAS,KAAK;AAElD,QAAA,aAAa,CAAC,aAA4B;AAC9C,QAAI,CAAC,YAAY;AACf;AAAA,IACF;AACI,QAAA,OAAO,UAAU,YAAY,YAAY;AAC3C,UAAI,aAAa,MAAM;AACT,mBAAA,QAAQ,GAAc,KAAK;AAAA,MAAA,WAC9B,aAAa,QAAQ;AAClB,mBAAA,QAAQ,GAAc,KAAK;AAAA,MACzC;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,kBAAkB,MAAM;AAC5B,QAAI,YAAY;AACd,UAAI,YAAY;AACd,mBAAW,KAAK;AAAA,MAClB;AACA,oBAAc,KAAK;AAAA,IAAA,OACd;AACL,UAAI,YAAY;AACd,mBAAW,KAAK;AAAA,MAClB;AACA,oBAAc,IAAI;AAAA,IACpB;AAAA,EAAA;AAGF,QAAM,eAAe,MAAM;AACzB,QAAI,YAAY;AACd,oBAAc,KAAK;AAEnB,UAAI,UAAU;AACZ,iBAAS,KAAK;AAAA,MAChB;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,gBAAgB,CAAoB,MAA8B;AACtE,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,QAAI,EAAE,QAAQ,SAAS,CAAC,YAAY;AAClC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AAQ,mBACR;AACA,YAAM,SAAS,QAAQ,yBAA0B,IAAI,QAAQ,gBAAmB,EAAA;AAEhF,UAAI,SAAS;AAAG,eAAO,WAAW;AAElC,UAAI,SAAS;AAAG,eAAO,WAAW;AAE3B,aAAA;AAAA,IACT;AAEO,WAAA;AAAA,EAAA;AAGH,QAAA,CAAC,EAAE,YAAY,UAAA,GAAa,SAAS,cAAc,IAAI,QAAQ;AAAA,IACnE;AAAA,IACA,OAAO;AACL,UAAI,SAAS;AACH;MACV;AAMA,YAAM,EAAE,MAAM,IAAI,UAAU,SAAS,2BAA2B;AAEhE,aAAO,EAAE,OAAO,OAAO,GAAG,KAAK;AAAA,IACjC;AAAA,IACA,MAAM;AACJ,UAAI,OAAO;AACH;MACR;AAAA,IACF;AAAA,IACA,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMT,YAAY,MAAM,KACd,CAAC,YAAY;AACX,aAAO,KAAK,OAAO,QAAQ,QAAA,EAAU;AAAA,IAEvC,IAAA;AAAA,IACJ,SAAS,CAAC,aAAa;AAAA,MACrB,YAAY,QAAQ,WAAW;AAAA,MAC/B,eAAe,QAAQ,uBAAuB;AAAA,MAC9C,eAAe,QAAQ,gBAAgB;AAAA,MACvC,WAAW,iBAAiB,OAAO;AAAA,IAAA;AAAA,EACrC,CACD;AAEK,QAAA,gBAAgB,uBAAuB,QAAQ,OAAO;AAAA,IAC1D;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAEM,SAAA;AAAA,IACL,EAAE,WAAW,YAAY,eAAe,kBAAkB,QAAQ,UAAU;AAAA,IAC5E;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDragAndDrop-J0TUUbR6.js","sources":["../../admin/src/constants/dragAndDrop.ts","../../admin/src/hooks/useKeyboardDragAndDrop.ts","../../admin/src/hooks/useDragAndDrop.ts"],"sourcesContent":["export const ItemTypes = {\n COMPONENT: 'component',\n EDIT_FIELD: 'editField',\n FIELD: 'field',\n DYNAMIC_ZONE: 'dynamicZone',\n RELATION: 'relation',\n BLOCKS: 'blocks',\n} as const;\n","import * as React from 'react';\n\nexport type UseKeyboardDragAndDropCallbacks<TIndex extends number | Array<number> = number> = {\n onCancel?: (index: TIndex) => void;\n onDropItem?: (currentIndex: TIndex, newIndex?: TIndex) => void;\n onGrabItem?: (index: TIndex) => void;\n onMoveItem?: (newIndex: TIndex, currentIndex: TIndex) => void;\n};\n\n/**\n * Utility hook designed to implement keyboard accessibile drag and drop by\n * returning an onKeyDown handler to be passed to the drag icon button.\n *\n * @internal - You should use `useDragAndDrop` instead.\n */\nexport const useKeyboardDragAndDrop = <TIndex extends number | Array<number> = number>(\n active: boolean,\n index: TIndex,\n { onCancel, onDropItem, onGrabItem, onMoveItem }: UseKeyboardDragAndDropCallbacks<TIndex>\n) => {\n const [isSelected, setIsSelected] = React.useState(false);\n\n const handleMove = (movement: 'UP' | 'DOWN') => {\n if (!isSelected) {\n return;\n }\n if (typeof index === 'number' && onMoveItem) {\n if (movement === 'UP') {\n onMoveItem((index - 1) as TIndex, index);\n } else if (movement === 'DOWN') {\n onMoveItem((index + 1) as TIndex, index);\n }\n }\n };\n\n const handleDragClick = () => {\n if (isSelected) {\n if (onDropItem) {\n onDropItem(index);\n }\n setIsSelected(false);\n } else {\n if (onGrabItem) {\n onGrabItem(index);\n }\n setIsSelected(true);\n }\n };\n\n const handleCancel = () => {\n if (isSelected) {\n setIsSelected(false);\n\n if (onCancel) {\n onCancel(index);\n }\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLButtonElement> = (e) => {\n if (!active) {\n return;\n }\n\n if (e.key === 'Tab' && !isSelected) {\n return;\n }\n\n e.preventDefault();\n\n switch (e.key) {\n case ' ':\n case 'Enter':\n handleDragClick();\n break;\n\n case 'Escape':\n handleCancel();\n break;\n\n case 'ArrowDown':\n case 'ArrowRight':\n handleMove('DOWN');\n break;\n\n case 'ArrowUp':\n case 'ArrowLeft':\n handleMove('UP');\n break;\n\n default:\n }\n };\n\n return handleKeyDown;\n};\n","import * as React from 'react';\n\nimport {\n useDrag,\n useDrop,\n type HandlerManager,\n type ConnectDragSource,\n type ConnectDropTarget,\n type ConnectDragPreview,\n type DragSourceMonitor,\n} from 'react-dnd';\n\nimport {\n useKeyboardDragAndDrop,\n type UseKeyboardDragAndDropCallbacks,\n} from './useKeyboardDragAndDrop';\n\nimport type { Data } from '@strapi/types';\n\nconst DIRECTIONS = {\n UPWARD: 'upward',\n DOWNWARD: 'downward',\n} as const;\n\nconst DROP_SENSITIVITY = {\n REGULAR: 'regular',\n IMMEDIATE: 'immediate',\n} as const;\n\ninterface UseDragAndDropOptions<\n TIndex extends number | Array<number> = number,\n TItem extends { index: TIndex } = { index: TIndex },\n> extends UseKeyboardDragAndDropCallbacks<TIndex> {\n type?: string;\n index: TIndex;\n item?: TItem;\n onStart?: () => void;\n onEnd?: () => void;\n dropSensitivity?: (typeof DROP_SENSITIVITY)[keyof typeof DROP_SENSITIVITY];\n}\n\ntype Identifier = ReturnType<HandlerManager['getHandlerId']>;\n\ntype UseDragAndDropReturn<Element extends HTMLElement = HTMLElement> = [\n props: {\n handlerId: Identifier;\n isDragging: boolean;\n handleKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>) => void;\n isOverDropTarget: boolean;\n direction: (typeof DIRECTIONS)[keyof typeof DIRECTIONS] | null;\n },\n objectRef: React.RefObject<Element>,\n dropRef: ConnectDropTarget,\n dragRef: ConnectDragSource,\n dragPreviewRef: ConnectDragPreview,\n];\n\ntype DropCollectedProps = {\n handlerId: Identifier;\n isOver: boolean;\n};\n\n/**\n * A utility hook abstracting the general drag and drop hooks from react-dnd.\n * Centralising the same behaviours and by default offering keyboard support.\n */\nconst useDragAndDrop = <\n TIndex extends number | Array<number>,\n TItem extends { index: TIndex; id?: Data.ID; [key: string]: unknown } = {\n index: TIndex;\n [key: string]: unknown;\n },\n Element extends HTMLElement = HTMLElement,\n>(\n active: boolean,\n {\n type = 'STRAPI_DND',\n index,\n item,\n onStart,\n onEnd,\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n dropSensitivity = DROP_SENSITIVITY.REGULAR,\n }: UseDragAndDropOptions<TIndex, TItem>\n): UseDragAndDropReturn<Element> => {\n const objectRef = React.useRef<Element>(null);\n\n const [{ handlerId, isOver }, dropRef] = useDrop<TItem, void, DropCollectedProps>({\n accept: type,\n collect(monitor) {\n return {\n handlerId: monitor.getHandlerId(),\n isOver: monitor.isOver({ shallow: true }),\n };\n },\n drop(item) {\n const draggedIndex = item.index;\n const newIndex = index;\n\n if (isOver && onDropItem) {\n onDropItem(draggedIndex, newIndex);\n }\n },\n hover(item, monitor) {\n if (!objectRef.current || !onMoveItem) {\n return;\n }\n\n const dragIndex = item.index;\n const newIndex = index;\n\n const hoverBoundingRect = objectRef.current?.getBoundingClientRect();\n const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (!clientOffset) return;\n\n const hoverClientY = clientOffset && clientOffset.y - hoverBoundingRect.top;\n if (typeof dragIndex === 'number' && typeof newIndex === 'number') {\n if (dragIndex === newIndex) {\n // Don't replace items with themselves\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (dragIndex < newIndex && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (dragIndex > newIndex && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n\n // Time to actually perform the action\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n } else {\n // Using numbers as indices doesn't work for nested list items with path like [1, 1, 0]\n if (Array.isArray(dragIndex) && Array.isArray(newIndex)) {\n // Indices comparison to find item position in nested list\n const minLength = Math.min(dragIndex.length, newIndex.length);\n let areEqual = true;\n let isLessThan = false;\n let isGreaterThan = false;\n\n for (let i = 0; i < minLength; i++) {\n if (dragIndex[i] < newIndex[i]) {\n isLessThan = true;\n areEqual = false;\n break;\n } else if (dragIndex[i] > newIndex[i]) {\n isGreaterThan = true;\n areEqual = false;\n break;\n }\n }\n\n // Don't replace items with themselves\n if (areEqual && dragIndex.length === newIndex.length) {\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (isLessThan && !isGreaterThan && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (isGreaterThan && !isLessThan && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n }\n\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n }\n },\n });\n\n const getDragDirection = (monitor: DragSourceMonitor<TItem, void>) => {\n if (\n monitor &&\n monitor.isDragging() &&\n !monitor.didDrop() &&\n monitor.getInitialClientOffset() &&\n monitor.getClientOffset()\n ) {\n const deltaY = monitor.getInitialClientOffset()!.y - monitor.getClientOffset()!.y;\n\n if (deltaY > 0) return DIRECTIONS.UPWARD;\n\n if (deltaY < 0) return DIRECTIONS.DOWNWARD;\n\n return null;\n }\n\n return null;\n };\n\n const [{ isDragging, direction }, dragRef, dragPreviewRef] = useDrag({\n type,\n item() {\n if (onStart) {\n onStart();\n }\n\n /**\n * This will be attached and it helps define the preview sizes\n * when a component is flexy e.g. Relations\n */\n const { width } = objectRef.current?.getBoundingClientRect() ?? {};\n\n return { index, width, ...item };\n },\n end() {\n if (onEnd) {\n onEnd();\n }\n },\n canDrag: active,\n /**\n * This is useful when the item is in a virtualized list.\n * However, if we don't have an ID then we want the libraries\n * defaults to take care of this.\n */\n isDragging: item?.id\n ? (monitor) => {\n return item.id === monitor.getItem().id;\n }\n : undefined,\n collect: (monitor) => ({\n isDragging: monitor.isDragging(),\n initialOffset: monitor.getInitialClientOffset(),\n currentOffset: monitor.getClientOffset(),\n direction: getDragDirection(monitor),\n }),\n });\n\n const handleKeyDown = useKeyboardDragAndDrop(active, index, {\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n });\n\n return [\n { handlerId, isDragging, handleKeyDown, isOverDropTarget: isOver, direction },\n objectRef,\n dropRef,\n dragRef,\n dragPreviewRef,\n ];\n};\n\nexport {\n useDragAndDrop,\n UseDragAndDropReturn,\n UseDragAndDropOptions,\n DIRECTIONS,\n DROP_SENSITIVITY,\n};\n"],"names":["React","useDrop","item","useDrag"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;AAAA,EACvB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,cAAc;AAAA,EACd,UAAU;AAAA,EACV,QAAQ;AACV;ACQa,MAAA,yBAAyB,CACpC,QACA,OACA,EAAE,UAAU,YAAY,YAAY,iBACjC;AACH,QAAM,CAAC,YAAY,aAAa,IAAIA,iBAAM,SAAS,KAAK;AAElD,QAAA,aAAa,CAAC,aAA4B;AAC9C,QAAI,CAAC,YAAY;AACf;AAAA,IACF;AACI,QAAA,OAAO,UAAU,YAAY,YAAY;AAC3C,UAAI,aAAa,MAAM;AACT,mBAAA,QAAQ,GAAc,KAAK;AAAA,MAAA,WAC9B,aAAa,QAAQ;AAClB,mBAAA,QAAQ,GAAc,KAAK;AAAA,MACzC;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,kBAAkB,MAAM;AAC5B,QAAI,YAAY;AACd,UAAI,YAAY;AACd,mBAAW,KAAK;AAAA,MAClB;AACA,oBAAc,KAAK;AAAA,IAAA,OACd;AACL,UAAI,YAAY;AACd,mBAAW,KAAK;AAAA,MAClB;AACA,oBAAc,IAAI;AAAA,IACpB;AAAA,EAAA;AAGF,QAAM,eAAe,MAAM;AACzB,QAAI,YAAY;AACd,oBAAc,KAAK;AAEnB,UAAI,UAAU;AACZ,iBAAS,KAAK;AAAA,MAChB;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,gBAA+D,CAAC,MAAM;AAC1E,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,QAAI,EAAE,QAAQ,SAAS,CAAC,YAAY;AAClC;AAAA,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ACR,QAAQ,mBACR;AACA,YAAM,SAAS,QAAQ,yBAA0B,IAAI,QAAQ,gBAAmB,EAAA;AAEhF,UAAI,SAAS;AAAG,eAAO,WAAW;AAElC,UAAI,SAAS;AAAG,eAAO,WAAW;AAE3B,aAAA;AAAA,IACT;AAEO,WAAA;AAAA,EAAA;AAGH,QAAA,CAAC,EAAE,YAAY,UAAA,GAAa,SAAS,cAAc,IAAIC,iBAAQ;AAAA,IACnE;AAAA,IACA,OAAO;AACL,UAAI,SAAS;AACH;MACV;AAMA,YAAM,EAAE,MAAM,IAAI,UAAU,SAAS,2BAA2B;AAEhE,aAAO,EAAE,OAAO,OAAO,GAAG,KAAK;AAAA,IACjC;AAAA,IACA,MAAM;AACJ,UAAI,OAAO;AACH;MACR;AAAA,IACF;AAAA,IACA,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMT,YAAY,MAAM,KACd,CAAC,YAAY;AACX,aAAO,KAAK,OAAO,QAAQ,QAAA,EAAU;AAAA,IAEvC,IAAA;AAAA,IACJ,SAAS,CAAC,aAAa;AAAA,MACrB,YAAY,QAAQ,WAAW;AAAA,MAC/B,eAAe,QAAQ,uBAAuB;AAAA,MAC9C,eAAe,QAAQ,gBAAgB;AAAA,MACvC,WAAW,iBAAiB,OAAO;AAAA,IAAA;AAAA,EACrC,CACD;AAEK,QAAA,gBAAgB,uBAAuB,QAAQ,OAAO;AAAA,IAC1D;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAEM,SAAA;AAAA,IACL,EAAE,WAAW,YAAY,eAAe,kBAAkB,QAAQ,UAAU;AAAA,IAC5E;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;;;;"}
1
+ {"version":3,"file":"useDragAndDrop-J0TUUbR6.js","sources":["../../admin/src/constants/dragAndDrop.ts","../../admin/src/hooks/useKeyboardDragAndDrop.ts","../../admin/src/hooks/useDragAndDrop.ts"],"sourcesContent":["export const ItemTypes = {\n COMPONENT: 'component',\n EDIT_FIELD: 'editField',\n FIELD: 'field',\n DYNAMIC_ZONE: 'dynamicZone',\n RELATION: 'relation',\n BLOCKS: 'blocks',\n} as const;\n","import * as React from 'react';\n\nexport type UseKeyboardDragAndDropCallbacks<TIndex extends number | Array<number> = number> = {\n onCancel?: (index: TIndex) => void;\n onDropItem?: (currentIndex: TIndex, newIndex?: TIndex) => void;\n onGrabItem?: (index: TIndex) => void;\n onMoveItem?: (newIndex: TIndex, currentIndex: TIndex) => void;\n};\n\n/**\n * Utility hook designed to implement keyboard accessibile drag and drop by\n * returning an onKeyDown handler to be passed to the drag icon button.\n *\n * @internal - You should use `useDragAndDrop` instead.\n */\nexport const useKeyboardDragAndDrop = <TIndex extends number | Array<number> = number>(\n active: boolean,\n index: TIndex,\n { onCancel, onDropItem, onGrabItem, onMoveItem }: UseKeyboardDragAndDropCallbacks<TIndex>\n) => {\n const [isSelected, setIsSelected] = React.useState(false);\n\n const handleMove = (movement: 'UP' | 'DOWN') => {\n if (!isSelected) {\n return;\n }\n if (typeof index === 'number' && onMoveItem) {\n if (movement === 'UP') {\n onMoveItem((index - 1) as TIndex, index);\n } else if (movement === 'DOWN') {\n onMoveItem((index + 1) as TIndex, index);\n }\n }\n };\n\n const handleDragClick = () => {\n if (isSelected) {\n if (onDropItem) {\n onDropItem(index);\n }\n setIsSelected(false);\n } else {\n if (onGrabItem) {\n onGrabItem(index);\n }\n setIsSelected(true);\n }\n };\n\n const handleCancel = () => {\n if (isSelected) {\n setIsSelected(false);\n\n if (onCancel) {\n onCancel(index);\n }\n }\n };\n\n const handleKeyDown = <E extends Element>(e: React.KeyboardEvent<E>) => {\n if (!active) {\n return;\n }\n\n if (e.key === 'Tab' && !isSelected) {\n return;\n }\n\n e.preventDefault();\n\n switch (e.key) {\n case ' ':\n case 'Enter':\n handleDragClick();\n break;\n\n case 'Escape':\n handleCancel();\n break;\n\n case 'ArrowDown':\n case 'ArrowRight':\n handleMove('DOWN');\n break;\n\n case 'ArrowUp':\n case 'ArrowLeft':\n handleMove('UP');\n break;\n\n default:\n }\n };\n\n return handleKeyDown;\n};\n","import * as React from 'react';\n\nimport {\n useDrag,\n useDrop,\n type HandlerManager,\n type ConnectDragSource,\n type ConnectDropTarget,\n type ConnectDragPreview,\n type DragSourceMonitor,\n} from 'react-dnd';\n\nimport {\n useKeyboardDragAndDrop,\n type UseKeyboardDragAndDropCallbacks,\n} from './useKeyboardDragAndDrop';\n\nimport type { Data } from '@strapi/types';\n\nconst DIRECTIONS = {\n UPWARD: 'upward',\n DOWNWARD: 'downward',\n} as const;\n\nconst DROP_SENSITIVITY = {\n REGULAR: 'regular',\n IMMEDIATE: 'immediate',\n} as const;\n\ninterface UseDragAndDropOptions<\n TIndex extends number | Array<number> = number,\n TItem extends { index: TIndex } = { index: TIndex },\n> extends UseKeyboardDragAndDropCallbacks<TIndex> {\n type?: string;\n index: TIndex;\n item?: TItem;\n onStart?: () => void;\n onEnd?: () => void;\n dropSensitivity?: (typeof DROP_SENSITIVITY)[keyof typeof DROP_SENSITIVITY];\n}\n\ntype Identifier = ReturnType<HandlerManager['getHandlerId']>;\n\ntype UseDragAndDropReturn<E extends Element = HTMLElement> = [\n props: {\n handlerId: Identifier;\n isDragging: boolean;\n handleKeyDown: <E extends Element>(event: React.KeyboardEvent<E>) => void;\n isOverDropTarget: boolean;\n direction: (typeof DIRECTIONS)[keyof typeof DIRECTIONS] | null;\n },\n objectRef: React.RefObject<E>,\n dropRef: ConnectDropTarget,\n dragRef: ConnectDragSource,\n dragPreviewRef: ConnectDragPreview,\n];\n\ntype DropCollectedProps = {\n handlerId: Identifier;\n isOver: boolean;\n};\n\n/**\n * A utility hook abstracting the general drag and drop hooks from react-dnd.\n * Centralising the same behaviours and by default offering keyboard support.\n */\nconst useDragAndDrop = <\n TIndex extends number | Array<number>,\n TItem extends { index: TIndex; id?: Data.ID; [key: string]: unknown } = {\n index: TIndex;\n [key: string]: unknown;\n },\n E extends Element = HTMLElement,\n>(\n active: boolean,\n {\n type = 'STRAPI_DND',\n index,\n item,\n onStart,\n onEnd,\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n dropSensitivity = DROP_SENSITIVITY.REGULAR,\n }: UseDragAndDropOptions<TIndex, TItem>\n): UseDragAndDropReturn<E> => {\n const objectRef = React.useRef<E>(null);\n\n const [{ handlerId, isOver }, dropRef] = useDrop<TItem, void, DropCollectedProps>({\n accept: type,\n collect(monitor) {\n return {\n handlerId: monitor.getHandlerId(),\n isOver: monitor.isOver({ shallow: true }),\n };\n },\n drop(item) {\n const draggedIndex = item.index;\n const newIndex = index;\n\n if (isOver && onDropItem) {\n onDropItem(draggedIndex, newIndex);\n }\n },\n hover(item, monitor) {\n if (!objectRef.current || !onMoveItem) {\n return;\n }\n\n const dragIndex = item.index;\n const newIndex = index;\n\n const hoverBoundingRect = objectRef.current?.getBoundingClientRect();\n const hoverMiddleY = (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;\n const clientOffset = monitor.getClientOffset();\n if (!clientOffset) return;\n\n const hoverClientY = clientOffset && clientOffset.y - hoverBoundingRect.top;\n if (typeof dragIndex === 'number' && typeof newIndex === 'number') {\n if (dragIndex === newIndex) {\n // Don't replace items with themselves\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (dragIndex < newIndex && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (dragIndex > newIndex && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n\n // Time to actually perform the action\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n } else {\n // Using numbers as indices doesn't work for nested list items with path like [1, 1, 0]\n if (Array.isArray(dragIndex) && Array.isArray(newIndex)) {\n // Indices comparison to find item position in nested list\n const minLength = Math.min(dragIndex.length, newIndex.length);\n let areEqual = true;\n let isLessThan = false;\n let isGreaterThan = false;\n\n for (let i = 0; i < minLength; i++) {\n if (dragIndex[i] < newIndex[i]) {\n isLessThan = true;\n areEqual = false;\n break;\n } else if (dragIndex[i] > newIndex[i]) {\n isGreaterThan = true;\n areEqual = false;\n break;\n }\n }\n\n // Don't replace items with themselves\n if (areEqual && dragIndex.length === newIndex.length) {\n return;\n }\n\n if (dropSensitivity === DROP_SENSITIVITY.REGULAR) {\n // Dragging downwards\n if (isLessThan && !isGreaterThan && hoverClientY < hoverMiddleY) {\n return;\n }\n\n // Dragging upwards\n if (isGreaterThan && !isLessThan && hoverClientY > hoverMiddleY) {\n return;\n }\n }\n }\n\n onMoveItem(newIndex, dragIndex);\n item.index = newIndex;\n }\n },\n });\n\n const getDragDirection = (monitor: DragSourceMonitor<TItem, void>) => {\n if (\n monitor &&\n monitor.isDragging() &&\n !monitor.didDrop() &&\n monitor.getInitialClientOffset() &&\n monitor.getClientOffset()\n ) {\n const deltaY = monitor.getInitialClientOffset()!.y - monitor.getClientOffset()!.y;\n\n if (deltaY > 0) return DIRECTIONS.UPWARD;\n\n if (deltaY < 0) return DIRECTIONS.DOWNWARD;\n\n return null;\n }\n\n return null;\n };\n\n const [{ isDragging, direction }, dragRef, dragPreviewRef] = useDrag({\n type,\n item() {\n if (onStart) {\n onStart();\n }\n\n /**\n * This will be attached and it helps define the preview sizes\n * when a component is flexy e.g. Relations\n */\n const { width } = objectRef.current?.getBoundingClientRect() ?? {};\n\n return { index, width, ...item };\n },\n end() {\n if (onEnd) {\n onEnd();\n }\n },\n canDrag: active,\n /**\n * This is useful when the item is in a virtualized list.\n * However, if we don't have an ID then we want the libraries\n * defaults to take care of this.\n */\n isDragging: item?.id\n ? (monitor) => {\n return item.id === monitor.getItem().id;\n }\n : undefined,\n collect: (monitor) => ({\n isDragging: monitor.isDragging(),\n initialOffset: monitor.getInitialClientOffset(),\n currentOffset: monitor.getClientOffset(),\n direction: getDragDirection(monitor),\n }),\n });\n\n const handleKeyDown = useKeyboardDragAndDrop(active, index, {\n onGrabItem,\n onDropItem,\n onCancel,\n onMoveItem,\n });\n\n return [\n { handlerId, isDragging, handleKeyDown, isOverDropTarget: isOver, direction },\n objectRef,\n dropRef,\n dragRef,\n dragPreviewRef,\n ];\n};\n\nexport {\n useDragAndDrop,\n UseDragAndDropReturn,\n UseDragAndDropOptions,\n DIRECTIONS,\n DROP_SENSITIVITY,\n};\n"],"names":["React","useDrop","item","useDrag"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;AAAA,EACvB,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,cAAc;AAAA,EACd,UAAU;AAAA,EACV,QAAQ;AACV;ACQa,MAAA,yBAAyB,CACpC,QACA,OACA,EAAE,UAAU,YAAY,YAAY,iBACjC;AACH,QAAM,CAAC,YAAY,aAAa,IAAIA,iBAAM,SAAS,KAAK;AAElD,QAAA,aAAa,CAAC,aAA4B;AAC9C,QAAI,CAAC,YAAY;AACf;AAAA,IACF;AACI,QAAA,OAAO,UAAU,YAAY,YAAY;AAC3C,UAAI,aAAa,MAAM;AACT,mBAAA,QAAQ,GAAc,KAAK;AAAA,MAAA,WAC9B,aAAa,QAAQ;AAClB,mBAAA,QAAQ,GAAc,KAAK;AAAA,MACzC;AAAA,IACF;AAAA,EAAA;AAGF,QAAM,kBAAkB,MAAM;AAC5B,QAAI,YAAY;AACd,UAAI,YAAY;AACd,mBAAW,KAAK;AAAA,MAClB;AACA,oBAAc,KAAK;AAAA,IAAA,OACd;AACL,UAAI,YAAY;AACd,mBAAW,KAAK;AAAA,MAClB;AACA,oBAAc,IAAI;AAAA,IACpB;AAAA,EAAA;AAGF,QAAM,eAAe,MAAM;AACzB,QAAI,YAAY;AACd,oBAAc,KAAK;AAEnB,UAAI,UAAU;AACZ,iBAAS,KAAK;AAAA,MAChB;AAAA,IACF;AAAA,EAAA;AAGI,QAAA,gBAAgB,CAAoB,MAA8B;AACtE,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,QAAI,EAAE,QAAQ,SAAS,CAAC,YAAY;AAClC;AAAA,IACF;AAEA,MAAE,eAA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YAAM,SAAS,QAAQ,yBAA0B,IAAI,QAAQ,gBAAmB,EAAA;AAEhF,UAAI,SAAS;AAAG,eAAO,WAAW;AAElC,UAAI,SAAS;AAAG,eAAO,WAAW;AAE3B,aAAA;AAAA,IACT;AAEO,WAAA;AAAA,EAAA;AAGH,QAAA,CAAC,EAAE,YAAY,UAAA,GAAa,SAAS,cAAc,IAAIC,iBAAQ;AAAA,IACnE;AAAA,IACA,OAAO;AACL,UAAI,SAAS;AACH;MACV;AAMA,YAAM,EAAE,MAAM,IAAI,UAAU,SAAS,2BAA2B;AAEhE,aAAO,EAAE,OAAO,OAAO,GAAG,KAAK;AAAA,IACjC;AAAA,IACA,MAAM;AACJ,UAAI,OAAO;AACH;MACR;AAAA,IACF;AAAA,IACA,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMT,YAAY,MAAM,KACd,CAAC,YAAY;AACX,aAAO,KAAK,OAAO,QAAQ,QAAA,EAAU;AAAA,IAEvC,IAAA;AAAA,IACJ,SAAS,CAAC,aAAa;AAAA,MACrB,YAAY,QAAQ,WAAW;AAAA,MAC/B,eAAe,QAAQ,uBAAuB;AAAA,MAC9C,eAAe,QAAQ,gBAAgB;AAAA,MACvC,WAAW,iBAAiB,OAAO;AAAA,IAAA;AAAA,EACrC,CACD;AAEK,QAAA,gBAAgB,uBAAuB,QAAQ,OAAO;AAAA,IAC1D;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACD;AAEM,SAAA;AAAA,IACL,EAAE,WAAW,YAAY,eAAe,kBAAkB,QAAQ,UAAU;AAAA,IAC5E;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;;;;"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ const React = require("react");
3
+ const prefixFileUrlWithBackendUrl = (fileURL) => {
4
+ return !!fileURL && fileURL.startsWith("/") ? `${window.strapi.backendURL}${fileURL}` : fileURL;
5
+ };
6
+ const usePrev = (value) => {
7
+ const ref = React.useRef();
8
+ React.useEffect(() => {
9
+ ref.current = value;
10
+ }, [value]);
11
+ return ref.current;
12
+ };
13
+ exports.prefixFileUrlWithBackendUrl = prefixFileUrlWithBackendUrl;
14
+ exports.usePrev = usePrev;
15
+ //# sourceMappingURL=usePrev-B9w_-eYc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrev-B9w_-eYc.js","sources":["../../admin/src/utils/urls.ts","../../admin/src/hooks/usePrev.ts"],"sourcesContent":["const prefixFileUrlWithBackendUrl = (fileURL?: string): string | undefined => {\n return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;\n};\n\nexport { prefixFileUrlWithBackendUrl };\n","import { useEffect, useRef } from 'react';\n\nexport const usePrev = <T>(value: T): T | undefined => {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n};\n"],"names":["useRef","useEffect"],"mappings":";;AAAM,MAAA,8BAA8B,CAAC,YAAyC;AAC5E,SAAO,CAAC,CAAC,WAAW,QAAQ,WAAW,GAAG,IAAI,GAAG,OAAO,OAAO,UAAU,GAAG,OAAO,KAAK;AAC1F;ACAa,MAAA,UAAU,CAAI,UAA4B;AACrD,QAAM,MAAMA,MAAAA;AAEZC,QAAAA,UAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAAA,GACb,CAAC,KAAK,CAAC;AAEV,SAAO,IAAI;AACb;;;"}
@@ -0,0 +1,16 @@
1
+ import { useRef, useEffect } from "react";
2
+ const prefixFileUrlWithBackendUrl = (fileURL) => {
3
+ return !!fileURL && fileURL.startsWith("/") ? `${window.strapi.backendURL}${fileURL}` : fileURL;
4
+ };
5
+ const usePrev = (value) => {
6
+ const ref = useRef();
7
+ useEffect(() => {
8
+ ref.current = value;
9
+ }, [value]);
10
+ return ref.current;
11
+ };
12
+ export {
13
+ prefixFileUrlWithBackendUrl as p,
14
+ usePrev as u
15
+ };
16
+ //# sourceMappingURL=usePrev-DH6iah0A.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePrev-DH6iah0A.mjs","sources":["../../admin/src/utils/urls.ts","../../admin/src/hooks/usePrev.ts"],"sourcesContent":["const prefixFileUrlWithBackendUrl = (fileURL?: string): string | undefined => {\n return !!fileURL && fileURL.startsWith('/') ? `${window.strapi.backendURL}${fileURL}` : fileURL;\n};\n\nexport { prefixFileUrlWithBackendUrl };\n","import { useEffect, useRef } from 'react';\n\nexport const usePrev = <T>(value: T): T | undefined => {\n const ref = useRef<T>();\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n};\n"],"names":[],"mappings":";AAAM,MAAA,8BAA8B,CAAC,YAAyC;AAC5E,SAAO,CAAC,CAAC,WAAW,QAAQ,WAAW,GAAG,IAAI,GAAG,OAAO,OAAO,UAAU,GAAG,OAAO,KAAK;AAC1F;ACAa,MAAA,UAAU,CAAI,UAA4B;AACrD,QAAM,MAAM;AAEZ,YAAU,MAAM;AACd,QAAI,UAAU;AAAA,EAAA,GACb,CAAC,KAAK,CAAC;AAEV,SAAO,IAAI;AACb;"}
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("../_chunks/index-C6AH2hEl.js");
3
+ const index = require("../_chunks/index-Dd0nXyJF.js");
4
4
  require("@strapi/icons");
5
5
  exports.DocumentRBAC = index.DocumentRBAC;
6
+ exports.buildValidParams = index.buildValidParams;
6
7
  exports.default = index.index;
7
8
  exports.unstable_useDocument = index.useDocument;
8
9
  exports.unstable_useDocumentActions = index.useDocumentActions;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1,11 +1,12 @@
1
- import { k, J, G, K, f, e } from "../_chunks/index-CwRRo1V9.mjs";
1
+ import { l, d, J, G, K, h, f } from "../_chunks/index-DrNe6ctw.mjs";
2
2
  import "@strapi/icons";
3
3
  export {
4
- k as DocumentRBAC,
4
+ l as DocumentRBAC,
5
+ d as buildValidParams,
5
6
  J as default,
6
7
  G as unstable_useDocument,
7
8
  K as unstable_useDocumentActions,
8
- f as unstable_useDocumentLayout,
9
- e as useDocumentRBAC
9
+ h as unstable_useDocumentLayout,
10
+ f as useDocumentRBAC
10
11
  };
11
12
  //# sourceMappingURL=index.mjs.map
@@ -1,8 +1,11 @@
1
+ import * as React from 'react';
2
+ import { FlexProps } from '@strapi/design-system';
1
3
  import type { Struct } from '@strapi/types';
2
- interface ComponentIconProps {
4
+ interface ComponentIconProps extends FlexProps {
3
5
  showBackground?: boolean;
4
6
  icon?: Struct.ContentTypeSchemaInfo['icon'];
5
7
  }
6
- declare const ComponentIcon: ({ showBackground, icon }: ComponentIconProps) => import("react/jsx-runtime").JSX.Element;
7
- export { ComponentIcon };
8
+ declare const ComponentIcon: ({ showBackground, icon, ...props }: ComponentIconProps) => import("react/jsx-runtime").JSX.Element;
9
+ declare const COMPONENT_ICONS: Record<string, React.ComponentType<any>>;
10
+ export { ComponentIcon, COMPONENT_ICONS };
8
11
  export type { ComponentIconProps };
@@ -39,9 +39,9 @@ interface ListViewContext {
39
39
  */
40
40
  collectionType: string;
41
41
  /**
42
- * TODO: add comment
42
+ * The current selected documents in the table
43
43
  */
44
- documentIds: string[];
44
+ documents: Document[];
45
45
  /**
46
46
  * The current content-type's model.
47
47
  */
@@ -68,7 +68,7 @@ interface HeaderActionComponent extends DescriptionComponent<HeaderActionProps,
68
68
  interface BulkActionComponentProps extends ListViewContext {
69
69
  }
70
70
  interface BulkActionComponent extends DescriptionComponent<BulkActionComponentProps, BulkActionDescription> {
71
- actionType?: 'delete' | 'publish' | 'unpublish';
71
+ type?: 'delete' | 'publish' | 'unpublish';
72
72
  }
73
73
  declare class ContentManagerPlugin {
74
74
  /**
@@ -3,6 +3,7 @@
3
3
  * When we move the CM plugin back to its package, we won't need this
4
4
  * but should still export the same things.
5
5
  */
6
+ export { buildValidParams } from './utils/api';
6
7
  export { useDocument as unstable_useDocument } from './hooks/useDocument';
7
8
  export { useDocumentActions as unstable_useDocumentActions } from './hooks/useDocumentActions';
8
9
  export { useDocumentLayout as unstable_useDocumentLayout } from './hooks/useDocumentLayout';
@@ -14,6 +14,6 @@ type VersionInputRendererProps = DistributiveOmit<EditFieldLayout, 'size'> & {
14
14
  * to be used on the History page in the content-manager. It understands how to render specific
15
15
  * inputs within the context of a history version (i.e. relations, media, ignored RBAC, etc...)
16
16
  */
17
- declare const VersionInputRenderer: ({ visible, hint: providedHint, shouldIgnoreRBAC, ...props }: VersionInputRendererProps) => import("react/jsx-runtime").JSX.Element | null;
17
+ declare const VersionInputRenderer: ({ visible, hint: providedHint, shouldIgnoreRBAC, labelAction, ...props }: VersionInputRendererProps) => import("react/jsx-runtime").JSX.Element | null;
18
18
  export type { VersionInputRendererProps };
19
19
  export { VersionInputRenderer };
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from '@strapi/types';
2
+ declare const historyAdmin: Partial<Plugin.Config.AdminInput>;
3
+ export { historyAdmin };
@@ -8,5 +8,5 @@ declare const useGetHistoryVersionsQuery: import("@reduxjs/toolkit/dist/query/re
8
8
  contentType: import("@strapi/types/dist/uid").ContentType;
9
9
  documentId?: Data.ID | undefined;
10
10
  locale?: string | undefined;
11
- } & Partial<Pick<import("../../../../shared/contracts/history-versions").Pagination, "page" | "pageSize">>, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("../../utils/api").QueryArguments, unknown, import("../../utils/api").BaseQueryError>, "ComponentConfiguration" | "ContentTypesConfiguration" | "ContentTypeSettings" | "Document" | "InitialData" | "HistoryVersion" | "Relations", GetHistoryVersions.Response, "contentManagerApi">>, useRestoreVersionMutation: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseMutation<import("@reduxjs/toolkit/query").MutationDefinition<RestoreVersion, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("../../utils/api").QueryArguments, unknown, import("../../utils/api").BaseQueryError>, "ComponentConfiguration" | "ContentTypesConfiguration" | "ContentTypeSettings" | "Document" | "InitialData" | "HistoryVersion" | "Relations", RestoreHistoryVersion.Response, "contentManagerApi">>;
11
+ } & Partial<Pick<import("../../../../shared/contracts/history-versions").Pagination, "page" | "pageSize">>, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "ComponentConfiguration" | "ContentTypesConfiguration" | "ContentTypeSettings" | "Document" | "InitialData" | "HistoryVersion" | "Relations", GetHistoryVersions.Response, "adminApi">>, useRestoreVersionMutation: import("@reduxjs/toolkit/dist/query/react/buildHooks").UseMutation<import("@reduxjs/toolkit/query").MutationDefinition<RestoreVersion, import("@reduxjs/toolkit/query").BaseQueryFn<string | import("@strapi/admin/strapi-admin").QueryArguments, unknown, import("@strapi/admin/strapi-admin").BaseQueryError, {}, {}>, "ComponentConfiguration" | "ContentTypesConfiguration" | "ContentTypeSettings" | "Document" | "InitialData" | "HistoryVersion" | "Relations", RestoreHistoryVersion.Response, "adminApi">>;
12
12
  export { useGetHistoryVersionsQuery, useRestoreVersionMutation };
@@ -3,11 +3,12 @@
3
3
  * this sounds expensive but actually, it's really not. Because we have redux-toolkit-query
4
4
  * being a cache layer so if nothing invalidates the cache, we don't fetch again.
5
5
  */
6
+ import { FormErrors } from '@strapi/admin/strapi-admin';
7
+ import { Modules } from '@strapi/types';
6
8
  import { useGetDocumentQuery } from '../services/documents';
7
9
  import { ComponentsDictionary } from './useContentTypeSchema';
8
10
  import type { FindOne } from '../../../shared/contracts/collection-types';
9
11
  import type { ContentType } from '../../../shared/contracts/content-types';
10
- import type { MessageDescriptor, PrimitiveType } from 'react-intl';
11
12
  interface UseDocumentArgs {
12
13
  collectionType: string;
13
14
  model: string;
@@ -30,9 +31,7 @@ type UseDocument = (args: UseDocumentArgs, opts?: UseDocumentOpts) => {
30
31
  * This is the schema of the content type, it is not the same as the layout.
31
32
  */
32
33
  schema?: Schema;
33
- validate: (document: Document) => null | Record<string, MessageDescriptor & {
34
- values?: Record<string, PrimitiveType>;
35
- }>;
34
+ validate: (document: Document) => null | FormErrors;
36
35
  };
37
36
  /**
38
37
  * @alpha
@@ -72,16 +71,14 @@ declare const useDoc: () => {
72
71
  * by their uid.
73
72
  */
74
73
  components: ComponentsDictionary;
75
- document?: import("@strapi/types/dist/modules/documents").AnyDocument | undefined;
74
+ document?: Modules.Documents.AnyDocument | undefined;
76
75
  meta?: import("../../../shared/contracts/collection-types").DocumentMetadata | undefined;
77
76
  isLoading: boolean;
78
77
  /**
79
78
  * This is the schema of the content type, it is not the same as the layout.
80
79
  */
81
80
  schema?: ContentType | undefined;
82
- validate: (document: Document) => null | Record<string, MessageDescriptor & {
83
- values?: Record<string, PrimitiveType>;
84
- }>;
81
+ validate: (document: Document) => null | FormErrors;
85
82
  collectionType: string;
86
83
  model: string;
87
84
  id: string | undefined;
@@ -2,12 +2,18 @@ import { SerializedError } from '@reduxjs/toolkit';
2
2
  import { type TrackingEvent } from '@strapi/admin/strapi-admin';
3
3
  import { BaseQueryError } from '../utils/api';
4
4
  import type { Document } from './useDocument';
5
- import type { AutoClone, Clone, Create, Delete, Discard, FindOne, Publish, Update, Unpublish } from '../../../shared/contracts/collection-types';
5
+ import type { AutoClone, Clone, Create, Delete, BulkDelete, Discard, FindOne, Publish, BulkPublish, Update, Unpublish, BulkUnpublish } from '../../../shared/contracts/collection-types';
6
6
  type OperationResponse<TResponse extends {
7
7
  data: any;
8
- meta: any;
8
+ meta?: any;
9
9
  error?: any;
10
- }> = Pick<TResponse, 'data' | 'meta'> | {
10
+ }> = Pick<TResponse, 'data'> | Pick<TResponse, 'data' | 'meta'> | {
11
+ error: BaseQueryError | SerializedError;
12
+ };
13
+ type BulkOperationResponse<TResponse extends {
14
+ data: any;
15
+ error?: any;
16
+ }> = Pick<TResponse, 'data'> | {
11
17
  error: BaseQueryError | SerializedError;
12
18
  };
13
19
  type UseDocumentActions = () => {
@@ -41,6 +47,11 @@ type UseDocumentActions = () => {
41
47
  }, trackerProperty?: Extract<TrackingEvent, {
42
48
  name: 'willDeleteEntry' | 'didDeleteEntry' | 'didNotDeleteEntry';
43
49
  }>['properties']) => Promise<OperationResponse<Delete.Response>>;
50
+ deleteMany: (args: {
51
+ model: string;
52
+ documentIds: string[];
53
+ params?: object;
54
+ }) => Promise<BulkOperationResponse<BulkDelete.Response>>;
44
55
  discard: (args: {
45
56
  collectionType: string;
46
57
  model: string;
@@ -59,6 +70,11 @@ type UseDocumentActions = () => {
59
70
  documentId?: string;
60
71
  params?: object;
61
72
  }, document: Partial<Document>) => Promise<OperationResponse<Publish.Response>>;
73
+ publishMany: (args: {
74
+ model: string;
75
+ documentIds: string[];
76
+ params?: object;
77
+ }) => Promise<BulkOperationResponse<BulkPublish.Response>>;
62
78
  update: (args: {
63
79
  collectionType: string;
64
80
  model: string;
@@ -73,6 +89,11 @@ type UseDocumentActions = () => {
73
89
  documentId?: string;
74
90
  params?: object;
75
91
  }, discardDraft?: boolean) => Promise<OperationResponse<Unpublish.Response>>;
92
+ unpublishMany: (args: {
93
+ model: string;
94
+ documentIds: string[];
95
+ params?: object;
96
+ }) => Promise<BulkOperationResponse<BulkUnpublish.Response>>;
76
97
  };
77
98
  /**
78
99
  * @alpha
@@ -93,7 +93,7 @@ declare const DEFAULT_SETTINGS: {
93
93
  * const { model } = useParams<{ model: string }>();
94
94
  * const { edit: { schema: layout } } = useDocumentLayout(model);
95
95
  *
96
- * return layout.map(panel => panel.map(row => row.map(field => <Field {...field} />)))
96
+ * return layout.map(panel => panel.map(row => row.map(field => <Field.Root {...field} />)))
97
97
  * ```
98
98
  *
99
99
  */
@@ -103,7 +103,7 @@ declare const useDocumentLayout: UseDocumentLayout;
103
103
  * content-manager because it won't work as intended.
104
104
  */
105
105
  declare const useDocLayout: () => {
106
- error?: BaseQueryError | SerializedError | undefined;
106
+ error?: SerializedError | BaseQueryError | undefined;
107
107
  isLoading: boolean;
108
108
  /**
109
109
  * This is the layout for the edit view,
@@ -23,15 +23,15 @@ interface UseDragAndDropOptions<TIndex extends number | Array<number> = number,
23
23
  dropSensitivity?: (typeof DROP_SENSITIVITY)[keyof typeof DROP_SENSITIVITY];
24
24
  }
25
25
  type Identifier = ReturnType<HandlerManager['getHandlerId']>;
26
- type UseDragAndDropReturn<Element extends HTMLElement = HTMLElement> = [
26
+ type UseDragAndDropReturn<E extends Element = HTMLElement> = [
27
27
  props: {
28
28
  handlerId: Identifier;
29
29
  isDragging: boolean;
30
- handleKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>) => void;
30
+ handleKeyDown: <E extends Element>(event: React.KeyboardEvent<E>) => void;
31
31
  isOverDropTarget: boolean;
32
32
  direction: (typeof DIRECTIONS)[keyof typeof DIRECTIONS] | null;
33
33
  },
34
- objectRef: React.RefObject<Element>,
34
+ objectRef: React.RefObject<E>,
35
35
  dropRef: ConnectDropTarget,
36
36
  dragRef: ConnectDragSource,
37
37
  dragPreviewRef: ConnectDragPreview
@@ -47,5 +47,5 @@ declare const useDragAndDrop: <TIndex extends number | number[], TItem extends {
47
47
  } = {
48
48
  [key: string]: unknown;
49
49
  index: TIndex;
50
- }, Element extends HTMLElement = HTMLElement>(active: boolean, { type, index, item, onStart, onEnd, onGrabItem, onDropItem, onCancel, onMoveItem, dropSensitivity, }: UseDragAndDropOptions<TIndex, TItem>) => UseDragAndDropReturn<Element>;
50
+ }, E extends Element = HTMLElement>(active: boolean, { type, index, item, onStart, onEnd, onGrabItem, onDropItem, onCancel, onMoveItem, dropSensitivity, }: UseDragAndDropOptions<TIndex, TItem>) => UseDragAndDropReturn<E>;
51
51
  export { useDragAndDrop, UseDragAndDropReturn, UseDragAndDropOptions, DIRECTIONS, DROP_SENSITIVITY, };
@@ -11,4 +11,4 @@ export type UseKeyboardDragAndDropCallbacks<TIndex extends number | Array<number
11
11
  *
12
12
  * @internal - You should use `useDragAndDrop` instead.
13
13
  */
14
- export declare const useKeyboardDragAndDrop: <TIndex extends number | number[] = number>(active: boolean, index: TIndex, { onCancel, onDropItem, onGrabItem, onMoveItem }: UseKeyboardDragAndDropCallbacks<TIndex>) => React.KeyboardEventHandler<HTMLButtonElement>;
14
+ export declare const useKeyboardDragAndDrop: <TIndex extends number | number[] = number>(active: boolean, index: TIndex, { onCancel, onDropItem, onGrabItem, onMoveItem }: UseKeyboardDragAndDropCallbacks<TIndex>) => <E extends Element>(e: React.KeyboardEvent<E>) => void;
@@ -1,5 +1,6 @@
1
1
  declare const _default: {
2
2
  register(app: any): void;
3
+ bootstrap(app: any): void;
3
4
  registerTrads({ locales }: {
4
5
  locales: string[];
5
6
  }): Promise<({
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { NotificationConfig } from '@strapi/admin/strapi-admin';
3
+ import { ButtonProps } from '@strapi/design-system';
3
4
  import type { DocumentActionComponent } from '../../../content-manager';
4
5
  type DocumentActionPosition = 'panel' | 'header' | 'table-row';
5
6
  interface DocumentActionDescription {
@@ -19,12 +20,13 @@ interface DocumentActionDescription {
19
20
  /**
20
21
  * @default 'secondary'
21
22
  */
22
- variant?: 'default' | 'secondary' | 'danger' | 'success';
23
+ variant?: ButtonProps['variant'];
23
24
  }
24
25
  interface DialogOptions {
25
26
  type: 'dialog';
26
27
  title: string;
27
28
  content?: React.ReactNode;
29
+ variant?: ButtonProps['variant'];
28
30
  onConfirm?: () => void | Promise<void>;
29
31
  onCancel?: () => void | Promise<void>;
30
32
  }
@@ -44,8 +46,10 @@ interface NotificationOptions {
44
46
  interface ModalOptions {
45
47
  type: 'modal';
46
48
  title: string;
47
- content: React.ReactNode;
48
- footer: React.ComponentType<{
49
+ content: React.ComponentType<{
50
+ onClose: () => void;
51
+ }> | React.ReactNode;
52
+ footer?: React.ComponentType<{
49
53
  onClose: () => void;
50
54
  }> | React.ReactNode;
51
55
  onClose?: () => void;
@@ -57,6 +61,9 @@ interface DocumentActionsProps {
57
61
  actions: Action[];
58
62
  }
59
63
  declare const DocumentActions: ({ actions }: DocumentActionsProps) => import("react/jsx-runtime").JSX.Element | null;
64
+ interface DocumentActionButtonProps extends Action {
65
+ }
66
+ declare const DocumentActionButton: (action: DocumentActionButtonProps) => import("react/jsx-runtime").JSX.Element;
60
67
  interface DocumentActionsMenuProps {
61
68
  actions: Action[];
62
69
  children?: React.ReactNode;
@@ -65,5 +72,5 @@ interface DocumentActionsMenuProps {
65
72
  }
66
73
  declare const DocumentActionsMenu: ({ actions, children, label, variant, }: DocumentActionsMenuProps) => import("react/jsx-runtime").JSX.Element;
67
74
  declare const DEFAULT_ACTIONS: DocumentActionComponent[];
68
- export { DocumentActions, DocumentActionsMenu, DEFAULT_ACTIONS };
75
+ export { DocumentActions, DocumentActionsMenu, DocumentActionButton, DEFAULT_ACTIONS };
69
76
  export type { DocumentActionDescription, DialogOptions, NotificationOptions, ModalOptions };
@@ -5,7 +5,7 @@ interface BlocksInputProps extends Omit<InputProps, 'type'> {
5
5
  labelAction?: React.ReactNode;
6
6
  type: Schema.Attribute.Blocks['type'];
7
7
  }
8
- declare const BlocksInput: React.ForwardRefExoticComponent<BlocksInputProps & React.RefAttributes<{
8
+ declare const MemoizedBlocksInput: React.MemoExoticComponent<React.ForwardRefExoticComponent<BlocksInputProps & React.RefAttributes<{
9
9
  focus: () => void;
10
- }>>;
11
- export { BlocksInput };
10
+ }>>>;
11
+ export { MemoizedBlocksInput as BlocksInput };
@@ -0,0 +1,4 @@
1
+ export declare const codeLanguages: {
2
+ value: string;
3
+ label: string;
4
+ }[];
@@ -13,6 +13,6 @@ interface ComponentInputProps extends Omit<Extract<EditFieldLayout, {
13
13
  */
14
14
  layout: EditFieldLayout[][];
15
15
  }
16
- declare const ComponentInput: ({ label, required, name, attribute, disabled, labelAction, ...props }: ComponentInputProps) => import("react/jsx-runtime").JSX.Element;
17
- export { ComponentInput };
16
+ declare const MemoizedComponentInput: React.MemoExoticComponent<({ label, required, name, attribute, disabled, labelAction, ...props }: ComponentInputProps) => import("react/jsx-runtime").JSX.Element>;
17
+ export { MemoizedComponentInput as ComponentInput };
18
18
  export type { ComponentInputProps };
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { AccordionVariant } from '@strapi/design-system';
2
+ import { Accordion } from '@strapi/design-system';
3
3
  interface ComponentCategoryProps {
4
4
  category: string;
5
5
  components?: Array<{
@@ -7,11 +7,9 @@ interface ComponentCategoryProps {
7
7
  displayName: string;
8
8
  icon?: string;
9
9
  }>;
10
- isOpen?: boolean;
11
10
  onAddComponent: (componentUid: string) => React.MouseEventHandler<HTMLButtonElement> & React.MouseEventHandler<HTMLDivElement>;
12
- onToggle: (category: string) => void;
13
- variant?: AccordionVariant;
11
+ variant?: Accordion.Variant;
14
12
  }
15
- declare const ComponentCategory: ({ category, components, variant, isOpen, onAddComponent, onToggle, }: ComponentCategoryProps) => import("react/jsx-runtime").JSX.Element;
13
+ declare const ComponentCategory: ({ category, components, variant, onAddComponent, }: ComponentCategoryProps) => import("react/jsx-runtime").JSX.Element;
16
14
  export { ComponentCategory };
17
15
  export type { ComponentCategoryProps };