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

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 (253) 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-BPvzFjM7.mjs → ComponentConfigurationPage-BaJMOQyq.mjs} +4 -4
  7. package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs.map → ComponentConfigurationPage-BaJMOQyq.mjs.map} +1 -1
  8. package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js → ComponentConfigurationPage-N-CTtgQa.js} +4 -4
  9. package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js.map → ComponentConfigurationPage-N-CTtgQa.js.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-BHkjAbxH.js} +4 -4
  15. package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js.map → EditConfigurationPage-BHkjAbxH.js.map} +1 -1
  16. package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs → EditConfigurationPage-CKK-5LfX.mjs} +4 -4
  17. package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs.map → EditConfigurationPage-CKK-5LfX.mjs.map} +1 -1
  18. package/dist/_chunks/EditViewPage-B11aeMcf.mjs +254 -0
  19. package/dist/_chunks/EditViewPage-B11aeMcf.mjs.map +1 -0
  20. package/dist/_chunks/{EditViewPage-DvNpQkam.js → EditViewPage-QPUftxUd.js} +101 -52
  21. package/dist/_chunks/EditViewPage-QPUftxUd.js.map +1 -0
  22. package/dist/_chunks/{Field-6gvGdPBV.mjs → Field-Bj_RgtGo.mjs} +1077 -814
  23. package/dist/_chunks/Field-Bj_RgtGo.mjs.map +1 -0
  24. package/dist/_chunks/{Field-DmVKIAOo.js → Field-DUK83cfh.js} +1121 -859
  25. package/dist/_chunks/Field-DUK83cfh.js.map +1 -0
  26. package/dist/_chunks/{Form-CPZC9vWa.js → Form-DHmBRlHd.js} +66 -46
  27. package/dist/_chunks/Form-DHmBRlHd.js.map +1 -0
  28. package/dist/_chunks/{Form-DW6K1IH-.mjs → Form-DLMSoXV7.mjs} +66 -45
  29. package/dist/_chunks/Form-DLMSoXV7.mjs.map +1 -0
  30. package/dist/_chunks/{History-Dmr9fmUA.mjs → History-CfCSNlG9.mjs} +181 -144
  31. package/dist/_chunks/History-CfCSNlG9.mjs.map +1 -0
  32. package/dist/_chunks/{History-DeAPlvtv.js → History-Di3zm4HT.js} +181 -145
  33. package/dist/_chunks/History-Di3zm4HT.js.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-DhwvYcNv.mjs → ListConfigurationPage-0mtv_iqk.mjs} +67 -56
  35. package/dist/_chunks/ListConfigurationPage-0mtv_iqk.mjs.map +1 -0
  36. package/dist/_chunks/{ListConfigurationPage-DPCwW5Vr.js → ListConfigurationPage-Cq361KIt.js} +70 -60
  37. package/dist/_chunks/ListConfigurationPage-Cq361KIt.js.map +1 -0
  38. package/dist/_chunks/{ListViewPage-BtAwuYLE.mjs → ListViewPage-BxLVROX8.mjs} +175 -159
  39. package/dist/_chunks/ListViewPage-BxLVROX8.mjs.map +1 -0
  40. package/dist/_chunks/{ListViewPage-5ySZ-VUs.js → ListViewPage-DFDcG8gM.js} +178 -162
  41. package/dist/_chunks/ListViewPage-DFDcG8gM.js.map +1 -0
  42. package/dist/_chunks/{NoContentTypePage-DSPxnxxp.mjs → NoContentTypePage-BRfDd67_.mjs} +3 -3
  43. package/dist/_chunks/NoContentTypePage-BRfDd67_.mjs.map +1 -0
  44. package/dist/_chunks/{NoContentTypePage-DOC_yWOf.js → NoContentTypePage-BSyvnDZZ.js} +3 -3
  45. package/dist/_chunks/NoContentTypePage-BSyvnDZZ.js.map +1 -0
  46. package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs → NoPermissionsPage-CV9V8KWa.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs.map → NoPermissionsPage-CV9V8KWa.mjs.map} +1 -1
  48. package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js → NoPermissionsPage-DyLphsn_.js} +2 -2
  49. package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js.map → NoPermissionsPage-DyLphsn_.js.map} +1 -1
  50. package/dist/_chunks/Preview-C_B1nx3g.mjs +272 -0
  51. package/dist/_chunks/Preview-C_B1nx3g.mjs.map +1 -0
  52. package/dist/_chunks/Preview-D_3aO6Ly.js +291 -0
  53. package/dist/_chunks/Preview-D_3aO6Ly.js.map +1 -0
  54. package/dist/_chunks/{Relations-J8cscLlR.mjs → Relations-C6pwmDXh.mjs} +135 -89
  55. package/dist/_chunks/Relations-C6pwmDXh.mjs.map +1 -0
  56. package/dist/_chunks/{Relations-CgWtgnPe.js → Relations-Cne2AlrL.js} +138 -93
  57. package/dist/_chunks/Relations-Cne2AlrL.js.map +1 -0
  58. package/dist/_chunks/{en-MBPul9Su.mjs → en-DhFUjrNW.mjs} +37 -18
  59. package/dist/_chunks/{en-MBPul9Su.mjs.map → en-DhFUjrNW.mjs.map} +1 -1
  60. package/dist/_chunks/{en-C-V1_90f.js → en-Ic0kXjxB.js} +37 -18
  61. package/dist/_chunks/{en-C-V1_90f.js.map → en-Ic0kXjxB.js.map} +1 -1
  62. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  63. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  64. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  65. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  66. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  67. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  68. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  69. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  70. package/dist/_chunks/{index-CwRRo1V9.mjs → index-BpxR3En4.mjs} +1835 -824
  71. package/dist/_chunks/index-BpxR3En4.mjs.map +1 -0
  72. package/dist/_chunks/{index-C6AH2hEl.js → index-T-aWjbj2.js} +1788 -777
  73. package/dist/_chunks/index-T-aWjbj2.js.map +1 -0
  74. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  75. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  76. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  77. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  78. package/dist/_chunks/{layout-B_SXLhqf.js → layout-BEuNwv-F.js} +45 -29
  79. package/dist/_chunks/layout-BEuNwv-F.js.map +1 -0
  80. package/dist/_chunks/{layout-jIDzX0Fp.mjs → layout-DhMZ_lDx.mjs} +45 -27
  81. package/dist/_chunks/layout-DhMZ_lDx.mjs.map +1 -0
  82. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  83. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  84. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  85. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  86. package/dist/_chunks/{relations-CuvIgCqI.mjs → relations-BdnxoX6f.mjs} +6 -7
  87. package/dist/_chunks/relations-BdnxoX6f.mjs.map +1 -0
  88. package/dist/_chunks/{relations-iBMa_OFG.js → relations-kLcuobLk.js} +6 -7
  89. package/dist/_chunks/relations-kLcuobLk.js.map +1 -0
  90. package/dist/_chunks/useDebounce-CtcjDB3L.js +28 -0
  91. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  92. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  93. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  94. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -1
  95. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -1
  96. package/dist/admin/index.js +3 -1
  97. package/dist/admin/index.js.map +1 -1
  98. package/dist/admin/index.mjs +9 -7
  99. package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
  100. package/dist/admin/src/content-manager.d.ts +3 -3
  101. package/dist/admin/src/exports.d.ts +2 -1
  102. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  103. package/dist/admin/src/history/index.d.ts +3 -0
  104. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  105. package/dist/admin/src/hooks/useDocument.d.ts +37 -9
  106. package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
  107. package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
  108. package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
  109. package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
  110. package/dist/admin/src/index.d.ts +1 -0
  111. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  112. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +11 -4
  113. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  114. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
  115. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  116. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
  117. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
  118. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
  119. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +30 -18
  120. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
  121. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
  122. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +2 -2
  123. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  124. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +16 -53
  125. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  126. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
  127. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  128. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  129. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
  130. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  131. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  132. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  133. package/dist/admin/src/preview/constants.d.ts +1 -0
  134. package/dist/admin/src/preview/index.d.ts +4 -0
  135. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  136. package/dist/admin/src/preview/routes.d.ts +3 -0
  137. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  138. package/dist/admin/src/router.d.ts +1 -1
  139. package/dist/admin/src/services/api.d.ts +2 -3
  140. package/dist/admin/src/services/components.d.ts +2 -2
  141. package/dist/admin/src/services/contentTypes.d.ts +5 -5
  142. package/dist/admin/src/services/documents.d.ts +31 -20
  143. package/dist/admin/src/services/init.d.ts +2 -2
  144. package/dist/admin/src/services/relations.d.ts +3 -3
  145. package/dist/admin/src/services/uid.d.ts +3 -3
  146. package/dist/admin/src/utils/api.d.ts +4 -18
  147. package/dist/admin/src/utils/validation.d.ts +5 -7
  148. package/dist/server/index.js +852 -436
  149. package/dist/server/index.js.map +1 -1
  150. package/dist/server/index.mjs +859 -443
  151. package/dist/server/index.mjs.map +1 -1
  152. package/dist/server/src/bootstrap.d.ts.map +1 -1
  153. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  154. package/dist/server/src/controllers/index.d.ts.map +1 -1
  155. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  156. package/dist/server/src/controllers/single-types.d.ts.map +1 -1
  157. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  158. package/dist/server/src/controllers/utils/metadata.d.ts +22 -0
  159. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
  160. package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
  161. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
  162. package/dist/server/src/controllers/validation/index.d.ts +1 -1
  163. package/dist/server/src/history/services/history.d.ts.map +1 -1
  164. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  165. package/dist/server/src/history/services/utils.d.ts +4 -4
  166. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  167. package/dist/server/src/index.d.ts +21 -42
  168. package/dist/server/src/index.d.ts.map +1 -1
  169. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  170. package/dist/server/src/preview/constants.d.ts +2 -0
  171. package/dist/server/src/preview/constants.d.ts.map +1 -0
  172. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  173. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  174. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  175. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  176. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  177. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  178. package/dist/server/src/preview/index.d.ts +4 -0
  179. package/dist/server/src/preview/index.d.ts.map +1 -0
  180. package/dist/server/src/preview/routes/index.d.ts +8 -0
  181. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  182. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  183. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  184. package/dist/server/src/preview/services/index.d.ts +16 -0
  185. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  186. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  187. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  188. package/dist/server/src/preview/services/preview.d.ts +12 -0
  189. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  190. package/dist/server/src/preview/utils.d.ts +19 -0
  191. package/dist/server/src/preview/utils.d.ts.map +1 -0
  192. package/dist/server/src/register.d.ts.map +1 -1
  193. package/dist/server/src/routes/index.d.ts.map +1 -1
  194. package/dist/server/src/services/document-manager.d.ts +13 -12
  195. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  196. package/dist/server/src/services/document-metadata.d.ts +14 -35
  197. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  198. package/dist/server/src/services/index.d.ts +21 -42
  199. package/dist/server/src/services/index.d.ts.map +1 -1
  200. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  201. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  202. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  203. package/dist/server/src/services/utils/populate.d.ts +8 -1
  204. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  205. package/dist/server/src/utils/index.d.ts +2 -0
  206. package/dist/server/src/utils/index.d.ts.map +1 -1
  207. package/dist/shared/contracts/collection-types.d.ts +17 -7
  208. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  209. package/dist/shared/contracts/index.d.ts +1 -0
  210. package/dist/shared/contracts/index.d.ts.map +1 -1
  211. package/dist/shared/contracts/preview.d.ts +27 -0
  212. package/dist/shared/contracts/preview.d.ts.map +1 -0
  213. package/dist/shared/contracts/relations.d.ts +2 -2
  214. package/dist/shared/contracts/relations.d.ts.map +1 -1
  215. package/dist/shared/index.js +4 -0
  216. package/dist/shared/index.js.map +1 -1
  217. package/dist/shared/index.mjs +4 -0
  218. package/dist/shared/index.mjs.map +1 -1
  219. package/package.json +19 -20
  220. package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
  221. package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
  222. package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
  223. package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
  224. package/dist/_chunks/EditViewPage-DDS6H9HO.mjs +0 -203
  225. package/dist/_chunks/EditViewPage-DDS6H9HO.mjs.map +0 -1
  226. package/dist/_chunks/EditViewPage-DvNpQkam.js.map +0 -1
  227. package/dist/_chunks/Field-6gvGdPBV.mjs.map +0 -1
  228. package/dist/_chunks/Field-DmVKIAOo.js.map +0 -1
  229. package/dist/_chunks/Form-CPZC9vWa.js.map +0 -1
  230. package/dist/_chunks/Form-DW6K1IH-.mjs.map +0 -1
  231. package/dist/_chunks/History-DeAPlvtv.js.map +0 -1
  232. package/dist/_chunks/History-Dmr9fmUA.mjs.map +0 -1
  233. package/dist/_chunks/ListConfigurationPage-DPCwW5Vr.js.map +0 -1
  234. package/dist/_chunks/ListConfigurationPage-DhwvYcNv.mjs.map +0 -1
  235. package/dist/_chunks/ListViewPage-5ySZ-VUs.js.map +0 -1
  236. package/dist/_chunks/ListViewPage-BtAwuYLE.mjs.map +0 -1
  237. package/dist/_chunks/NoContentTypePage-DOC_yWOf.js.map +0 -1
  238. package/dist/_chunks/NoContentTypePage-DSPxnxxp.mjs.map +0 -1
  239. package/dist/_chunks/Relations-CgWtgnPe.js.map +0 -1
  240. package/dist/_chunks/Relations-J8cscLlR.mjs.map +0 -1
  241. package/dist/_chunks/index-C6AH2hEl.js.map +0 -1
  242. package/dist/_chunks/index-CwRRo1V9.mjs.map +0 -1
  243. package/dist/_chunks/layout-B_SXLhqf.js.map +0 -1
  244. package/dist/_chunks/layout-jIDzX0Fp.mjs.map +0 -1
  245. package/dist/_chunks/relations-CuvIgCqI.mjs.map +0 -1
  246. package/dist/_chunks/relations-iBMa_OFG.js.map +0 -1
  247. package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
  248. package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
  249. package/dist/_chunks/urls-DzZya_gm.js +0 -6
  250. package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
  251. package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
  252. package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
  253. package/strapi-server.js +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"objects-mKMAmfec.mjs","sources":["../../admin/src/utils/objects.ts"],"sourcesContent":["import clone from 'lodash/clone';\nimport toPath from 'lodash/toPath';\n\n/**\n * Deeply get a value from an object via its path.\n */\nexport function getIn(obj: any, key: string | string[], def?: any, pathStartIndex: number = 0) {\n const path = toPath(key);\n while (obj && pathStartIndex < path.length) {\n obj = obj[path[pathStartIndex++]];\n }\n\n // check if path is not in the end\n if (pathStartIndex !== path.length && !obj) {\n return def;\n }\n\n return obj === undefined ? def : obj;\n}\n\n/** @internal is the given object an Object? */\nexport const isObject = (obj: any): obj is object =>\n obj !== null && typeof obj === 'object' && !Array.isArray(obj);\n\n/** @internal is the given object an integer? */\nexport const isInteger = (obj: any): boolean => String(Math.floor(Number(obj))) === obj;\n\n/**\n * Deeply set a value from in object via its path. If the value at `path`\n * has changed, return a shallow copy of obj with `value` set at `path`.\n * If `value` has not changed, return the original `obj`.\n *\n * Existing objects / arrays along `path` are also shallow copied. Sibling\n * objects along path retain the same internal js reference. Since new\n * objects / arrays are only created along `path`, we can test if anything\n * changed in a nested structure by comparing the object's reference in\n * the old and new object, similar to how russian doll cache invalidation\n * works.\n *\n * In earlier versions of this function, which used cloneDeep, there were\n * issues whereby settings a nested value would mutate the parent\n * instead of creating a new object. `clone` avoids that bug making a\n * shallow copy of the objects along the update path\n * so no object is mutated in place.\n *\n * Before changing this function, please read through the following\n * discussions.\n *\n * @see https://github.com/developit/linkstate\n * @see https://github.com/jaredpalmer/formik/pull/123\n */\nexport function setIn(obj: any, path: string, value: any): any {\n const res: any = clone(obj); // this keeps inheritance when obj is a class\n let resVal: any = res;\n let i = 0;\n const pathArray = toPath(path);\n\n for (; i < pathArray.length - 1; i++) {\n const currentPath: string = pathArray[i];\n const currentObj: any = getIn(obj, pathArray.slice(0, i + 1));\n\n if (currentObj && (isObject(currentObj) || Array.isArray(currentObj))) {\n resVal = resVal[currentPath] = clone(currentObj);\n } else {\n const nextPath: string = pathArray[i + 1];\n resVal = resVal[currentPath] = isInteger(nextPath) && Number(nextPath) >= 0 ? [] : {};\n }\n }\n\n // Return original object if new value is the same as current\n if ((i === 0 ? obj : resVal)[pathArray[i]] === value) {\n return obj;\n }\n\n if (value === undefined) {\n delete resVal[pathArray[i]];\n } else {\n resVal[pathArray[i]] = value;\n }\n\n // If the path array has a single element, the loop did not run.\n // Deleting on `resVal` had no effect in this scenario, so we delete on the result instead.\n if (i === 0 && value === undefined) {\n delete res[pathArray[i]];\n }\n\n return res;\n}\n"],"names":[],"mappings":";;AAMO,SAAS,MAAM,KAA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AC3B,WAAA,IAAI,UAAU,CAAC,CAAC;AAAA,EACzB;AAEO,SAAA;AACT;"}
1
+ {"version":3,"file":"objects-D6yBsdmx.mjs","sources":["../../admin/src/utils/objects.ts"],"sourcesContent":["import clone from 'lodash/clone';\nimport toPath from 'lodash/toPath';\n\n/**\n * Deeply get a value from an object via its path.\n */\nexport function getIn(obj: any, key: string | string[], def?: any, pathStartIndex: number = 0) {\n const path = toPath(key);\n while (obj && pathStartIndex < path.length) {\n obj = obj[path[pathStartIndex++]];\n }\n\n // check if path is not in the end\n if (pathStartIndex !== path.length && !obj) {\n return def;\n }\n\n return obj === undefined ? def : obj;\n}\n\n/** @internal is the given object an Object? */\nexport const isObject = (obj: any): obj is object =>\n obj !== null && typeof obj === 'object' && !Array.isArray(obj);\n\n/** @internal is the given object an integer? */\nexport const isInteger = (obj: any): boolean => String(Math.floor(Number(obj))) === obj;\n\n/**\n * Deeply set a value from in object via its path. If the value at `path`\n * has changed, return a shallow copy of obj with `value` set at `path`.\n * If `value` has not changed, return the original `obj`.\n *\n * Existing objects / arrays along `path` are also shallow copied. Sibling\n * objects along path retain the same internal js reference. Since new\n * objects / arrays are only created along `path`, we can test if anything\n * changed in a nested structure by comparing the object's reference in\n * the old and new object, similar to how russian doll cache invalidation\n * works.\n *\n * In earlier versions of this function, which used cloneDeep, there were\n * issues whereby settings a nested value would mutate the parent\n * instead of creating a new object. `clone` avoids that bug making a\n * shallow copy of the objects along the update path\n * so no object is mutated in place.\n *\n * Before changing this function, please read through the following\n * discussions.\n *\n * @see https://github.com/developit/linkstate\n * @see https://github.com/jaredpalmer/formik/pull/123\n */\nexport function setIn(obj: any, path: string, value: any): any {\n const res: any = clone(obj); // this keeps inheritance when obj is a class\n let resVal: any = res;\n let i = 0;\n const pathArray = toPath(path);\n\n for (; i < pathArray.length - 1; i++) {\n const currentPath: string = pathArray[i];\n const currentObj: any = getIn(obj, pathArray.slice(0, i + 1));\n\n if (currentObj && (isObject(currentObj) || Array.isArray(currentObj))) {\n resVal = resVal[currentPath] = clone(currentObj);\n } else {\n const nextPath: string = pathArray[i + 1];\n resVal = resVal[currentPath] = isInteger(nextPath) && Number(nextPath) >= 0 ? [] : {};\n }\n }\n\n // Return original object if new value is the same as current\n if ((i === 0 ? obj : resVal)[pathArray[i]] === value) {\n return obj;\n }\n\n if (value === undefined) {\n delete resVal[pathArray[i]];\n } else {\n resVal[pathArray[i]] = value;\n }\n\n // If the path array has a single element, the loop did not run.\n // Deleting on `resVal` had no effect in this scenario, so we delete on the result instead.\n if (i === 0 && value === undefined) {\n delete res[pathArray[i]];\n }\n\n return res;\n}\n"],"names":[],"mappings":";;AAMO,SAAS,MAAM,KAAU,KAAwB,KAAW,iBAAyB,GAAG;AACvF,QAAA,OAAO,OAAO,GAAG;AAChB,SAAA,OAAO,iBAAiB,KAAK,QAAQ;AACpC,UAAA,IAAI,KAAK,gBAAgB,CAAC;AAAA,EAClC;AAGA,MAAI,mBAAmB,KAAK,UAAU,CAAC,KAAK;AACnC,WAAA;AAAA,EACT;AAEO,SAAA,QAAQ,SAAY,MAAM;AACnC;AAGa,MAAA,WAAW,CAAC,QACvB,QAAQ,QAAQ,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,GAAG;AAGlD,MAAA,YAAY,CAAC,QAAsB,OAAO,KAAK,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM;AA0BpE,SAAA,MAAM,KAAU,MAAc,OAAiB;AACvD,QAAA,MAAW,MAAM,GAAG;AAC1B,MAAI,SAAc;AAClB,MAAI,IAAI;AACF,QAAA,YAAY,OAAO,IAAI;AAE7B,SAAO,IAAI,UAAU,SAAS,GAAG,KAAK;AAC9B,UAAA,cAAsB,UAAU,CAAC;AACjC,UAAA,aAAkB,MAAM,KAAK,UAAU,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5D,QAAI,eAAe,SAAS,UAAU,KAAK,MAAM,QAAQ,UAAU,IAAI;AACrE,eAAS,OAAO,WAAW,IAAI,MAAM,UAAU;AAAA,IAAA,OAC1C;AACC,YAAA,WAAmB,UAAU,IAAI,CAAC;AACxC,eAAS,OAAO,WAAW,IAAI,UAAU,QAAQ,KAAK,OAAO,QAAQ,KAAK,IAAI,CAAA,IAAK,CAAA;AAAA,IACrF;AAAA,EACF;AAGK,OAAA,MAAM,IAAI,MAAM,QAAQ,UAAU,CAAC,CAAC,MAAM,OAAO;AAC7C,WAAA;AAAA,EACT;AAEyB;AAChB,WAAA,OAAO,UAAU,CAAC,CAAC;AAAA,EAG5B;AAII,MAAA,MAAM,KAAK,UAAU,QAAW;AAC3B,WAAA,IAAI,UAAU,CAAC,CAAC;AAAA,EACzB;AAEO,SAAA;AACT;"}
@@ -1,5 +1,5 @@
1
1
  import { generateNKeysBetween } from "fractional-indexing";
2
- import { d as contentManagerApi } from "./index-CwRRo1V9.mjs";
2
+ import { e as contentManagerApi } from "./index-BpxR3En4.mjs";
3
3
  const relationsApi = contentManagerApi.injectEndpoints({
4
4
  endpoints: (build) => ({
5
5
  getRelations: build.query({
@@ -26,11 +26,10 @@ const relationsApi = contentManagerApi.injectEndpoints({
26
26
  merge: (currentCache, newItems) => {
27
27
  if (currentCache.pagination && newItems.pagination) {
28
28
  if (currentCache.pagination.page < newItems.pagination.page) {
29
- const existingIds = currentCache.results.map((item) => item.documentId);
30
- const uniqueNewItems = newItems.results.filter(
31
- (item) => !existingIds.includes(item.documentId)
32
- );
33
- currentCache.results.push(...prepareTempKeys(uniqueNewItems, currentCache.results));
29
+ currentCache.results = [
30
+ ...prepareTempKeys(newItems.results, currentCache.results),
31
+ ...currentCache.results
32
+ ];
34
33
  currentCache.pagination = newItems.pagination;
35
34
  } else if (newItems.pagination.page === 1) {
36
35
  currentCache.results = prepareTempKeys(newItems.results);
@@ -132,4 +131,4 @@ export {
132
131
  getRelationLabel as g,
133
132
  useGetRelationsQuery as u
134
133
  };
135
- //# sourceMappingURL=relations-CuvIgCqI.mjs.map
134
+ //# sourceMappingURL=relations-BdnxoX6f.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relations-BdnxoX6f.mjs","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 * Push new items at the beginning as latest items are shown first\n */\n currentCache.results = [\n ...prepareTempKeys(newItems.results, currentCache.results),\n ...currentCache.results,\n ];\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 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":[],"mappings":";;AAkCA,MAAM,eAAe,kBAAkB,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,QA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,SAAO,UAAU,IAAI,CAAC,OAAO,WAAW;AAAA,IACtC,GAAG;AAAA,IACH,cAAc,KAAK,KAAK;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,6 +1,6 @@
1
1
  "use strict";
2
2
  const fractionalIndexing = require("fractional-indexing");
3
- const index = require("./index-C6AH2hEl.js");
3
+ const index = require("./index-T-aWjbj2.js");
4
4
  const relationsApi = index.contentManagerApi.injectEndpoints({
5
5
  endpoints: (build) => ({
6
6
  getRelations: build.query({
@@ -27,11 +27,10 @@ const relationsApi = index.contentManagerApi.injectEndpoints({
27
27
  merge: (currentCache, newItems) => {
28
28
  if (currentCache.pagination && newItems.pagination) {
29
29
  if (currentCache.pagination.page < newItems.pagination.page) {
30
- const existingIds = currentCache.results.map((item) => item.documentId);
31
- const uniqueNewItems = newItems.results.filter(
32
- (item) => !existingIds.includes(item.documentId)
33
- );
34
- currentCache.results.push(...prepareTempKeys(uniqueNewItems, currentCache.results));
30
+ currentCache.results = [
31
+ ...prepareTempKeys(newItems.results, currentCache.results),
32
+ ...currentCache.results
33
+ ];
35
34
  currentCache.pagination = newItems.pagination;
36
35
  } else if (newItems.pagination.page === 1) {
37
36
  currentCache.results = prepareTempKeys(newItems.results);
@@ -131,4 +130,4 @@ const getRelationLabel = (relation, mainField) => {
131
130
  exports.getRelationLabel = getRelationLabel;
132
131
  exports.useGetRelationsQuery = useGetRelationsQuery;
133
132
  exports.useLazySearchRelationsQuery = useLazySearchRelationsQuery;
134
- //# sourceMappingURL=relations-iBMa_OFG.js.map
133
+ //# sourceMappingURL=relations-kLcuobLk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relations-kLcuobLk.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 * Push new items at the beginning as latest items are shown first\n */\n currentCache.results = [\n ...prepareTempKeys(newItems.results, currentCache.results),\n ...currentCache.results,\n ];\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 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,QA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AM,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;;;;"}
@@ -0,0 +1,28 @@
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
+ function useDebounce(value, delay) {
14
+ const [debouncedValue, setDebouncedValue] = React.useState(value);
15
+ React.useEffect(() => {
16
+ const handler = setTimeout(() => {
17
+ setDebouncedValue(value);
18
+ }, delay);
19
+ return () => {
20
+ clearTimeout(handler);
21
+ };
22
+ }, [value, delay]);
23
+ return debouncedValue;
24
+ }
25
+ exports.prefixFileUrlWithBackendUrl = prefixFileUrlWithBackendUrl;
26
+ exports.useDebounce = useDebounce;
27
+ exports.usePrev = usePrev;
28
+ //# sourceMappingURL=useDebounce-CtcjDB3L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebounce-CtcjDB3L.js","sources":["../../admin/src/utils/urls.ts","../../admin/src/hooks/usePrev.ts","../../admin/src/hooks/useDebounce.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","import { useEffect, useState } from 'react';\n\nexport function useDebounce<TValue>(value: TValue, delay: number): TValue {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\n}\n"],"names":["useRef","useEffect","useState"],"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;ACRgB,SAAA,YAAoB,OAAe,OAAuB;AACxE,QAAM,CAAC,gBAAgB,iBAAiB,IAAIC,eAAS,KAAK;AAE1DD,QAAAA,UAAU,MAAM;AACR,UAAA,UAAU,WAAW,MAAM;AAC/B,wBAAkB,KAAK;AAAA,OACtB,KAAK;AAER,WAAO,MAAM;AACX,mBAAa,OAAO;AAAA,IAAA;AAAA,EACtB,GACC,CAAC,OAAO,KAAK,CAAC;AAEV,SAAA;AACT;;;;"}
@@ -0,0 +1,29 @@
1
+ import { useRef, useEffect, useState } 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
+ function useDebounce(value, delay) {
13
+ const [debouncedValue, setDebouncedValue] = useState(value);
14
+ useEffect(() => {
15
+ const handler = setTimeout(() => {
16
+ setDebouncedValue(value);
17
+ }, delay);
18
+ return () => {
19
+ clearTimeout(handler);
20
+ };
21
+ }, [value, delay]);
22
+ return debouncedValue;
23
+ }
24
+ export {
25
+ useDebounce as a,
26
+ prefixFileUrlWithBackendUrl as p,
27
+ usePrev as u
28
+ };
29
+ //# sourceMappingURL=useDebounce-DmuSJIF3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebounce-DmuSJIF3.mjs","sources":["../../admin/src/utils/urls.ts","../../admin/src/hooks/usePrev.ts","../../admin/src/hooks/useDebounce.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","import { useEffect, useState } from 'react';\n\nexport function useDebounce<TValue>(value: TValue, delay: number): TValue {\n const [debouncedValue, setDebouncedValue] = useState(value);\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value);\n }, delay);\n\n return () => {\n clearTimeout(handler);\n };\n }, [value, delay]);\n\n return debouncedValue;\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;ACRgB,SAAA,YAAoB,OAAe,OAAuB;AACxE,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,KAAK;AAE1D,YAAU,MAAM;AACR,UAAA,UAAU,WAAW,MAAM;AAC/B,wBAAkB,KAAK;AAAA,OACtB,KAAK;AAER,WAAO,MAAM;AACX,mBAAa,OAAO;AAAA,IAAA;AAAA,EACtB,GACC,CAAC,OAAO,KAAK,CAAC;AAEV,SAAA;AACT;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDragAndDrop-DdHgKsqq.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,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uB,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-DdHgKsqq.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 = <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;AA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;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,MA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AA,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;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AAA,IACL,EAAE,WAAW,YAAY,eAAe,kBAAkB,QAAQ,UAAU;AAAA,IAC5E;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;;;;;"}
@@ -1,9 +1,11 @@
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-T-aWjbj2.js");
4
4
  require("@strapi/icons");
5
5
  exports.DocumentRBAC = index.DocumentRBAC;
6
+ exports.buildValidParams = index.buildValidParams;
6
7
  exports.default = index.index;
8
+ exports.unstable_useContentManagerContext = index.useContentManagerContext;
7
9
  exports.unstable_useDocument = index.useDocument;
8
10
  exports.unstable_useDocumentActions = index.useDocumentActions;
9
11
  exports.unstable_useDocumentLayout = index.useDocumentLayout;
@@ -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,13 @@
1
- import { k, J, G, K, f, e } from "../_chunks/index-CwRRo1V9.mjs";
1
+ import { l, d, L, M, J, N, h, f } from "../_chunks/index-BpxR3En4.mjs";
2
2
  import "@strapi/icons";
3
3
  export {
4
- k as DocumentRBAC,
5
- J as default,
6
- G as unstable_useDocument,
7
- K as unstable_useDocumentActions,
8
- f as unstable_useDocumentLayout,
9
- e as useDocumentRBAC
4
+ l as DocumentRBAC,
5
+ d as buildValidParams,
6
+ L as default,
7
+ M as unstable_useContentManagerContext,
8
+ J as unstable_useDocument,
9
+ N as unstable_useDocumentActions,
10
+ h as unstable_useDocumentLayout,
11
+ f as useDocumentRBAC
10
12
  };
11
13
  //# 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,7 +3,8 @@
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 { useDocument as unstable_useDocument } from './hooks/useDocument';
6
+ export { buildValidParams } from './utils/api';
7
+ export { useDocument as unstable_useDocument, useContentManagerContext as unstable_useContentManagerContext, } from './hooks/useDocument';
7
8
  export { useDocumentActions as unstable_useDocumentActions } from './hooks/useDocumentActions';
8
9
  export { useDocumentLayout as unstable_useDocumentLayout } from './hooks/useDocumentLayout';
9
10
  export type { EditFieldLayout, EditLayout, ListFieldLayout, ListLayout, } 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" | "UidAvailability", 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" | "UidAvailability", 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,9 @@ 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
+ schemas?: Schema[];
35
+ validate: (document: Document) => null | FormErrors;
36
+ hasError?: boolean;
36
37
  };
37
38
  /**
38
39
  * @alpha
@@ -72,19 +73,46 @@ declare const useDoc: () => {
72
73
  * by their uid.
73
74
  */
74
75
  components: ComponentsDictionary;
75
- document?: import("@strapi/types/dist/modules/documents").AnyDocument | undefined;
76
+ document?: Modules.Documents.AnyDocument | undefined;
76
77
  meta?: import("../../../shared/contracts/collection-types").DocumentMetadata | undefined;
77
78
  isLoading: boolean;
78
79
  /**
79
80
  * This is the schema of the content type, it is not the same as the layout.
80
81
  */
81
82
  schema?: ContentType | undefined;
82
- validate: (document: Document) => null | Record<string, MessageDescriptor & {
83
- values?: Record<string, PrimitiveType>;
84
- }>;
83
+ schemas?: ContentType[] | undefined;
84
+ validate: (document: Document) => null | FormErrors;
85
+ hasError?: boolean | undefined;
85
86
  collectionType: string;
86
87
  model: string;
87
88
  id: string | undefined;
88
89
  };
89
- export { useDocument, useDoc };
90
+ /**
91
+ * @public
92
+ * @experimental
93
+ * Content manager context hooks for plugin development.
94
+ * Make sure to use this hook inside the content manager.
95
+ */
96
+ declare const useContentManagerContext: () => {
97
+ error: import("@reduxjs/toolkit").SerializedError | import("../utils/api").BaseQueryError | undefined;
98
+ isLoading: boolean;
99
+ model: string;
100
+ collectionType: string;
101
+ id: string | undefined;
102
+ slug: string;
103
+ isCreatingEntry: boolean;
104
+ isSingleType: boolean;
105
+ hasDraftAndPublish: boolean;
106
+ components: ComponentsDictionary;
107
+ contentType: ContentType | undefined;
108
+ contentTypes: ContentType[] | undefined;
109
+ form: import("@strapi/admin/strapi-admin").FormContextValue<import("@strapi/admin/strapi-admin").FormValues>;
110
+ layout: {
111
+ error?: import("@reduxjs/toolkit").SerializedError | import("../utils/api").BaseQueryError | undefined;
112
+ isLoading: boolean;
113
+ edit: import("./useDocumentLayout").EditLayout;
114
+ list: import("./useDocumentLayout").ListLayout;
115
+ };
116
+ };
117
+ export { useDocument, useDoc, useContentManagerContext };
90
118
  export type { UseDocument, UseDocumentArgs, Document, Schema, ComponentsDictionary };
@@ -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