@strapi/content-manager 0.0.0-experimental.0faf8967355707d2684ecb8579b03979ad5df042

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 (511) hide show
  1. package/LICENSE +37 -0
  2. package/README.md +9 -0
  3. package/dist/_chunks/CardDragPreview-C0QyJgRA.js +69 -0
  4. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
  5. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs +70 -0
  6. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
  7. package/dist/_chunks/ComponentConfigurationPage-BX0PmIl_.js +255 -0
  8. package/dist/_chunks/ComponentConfigurationPage-BX0PmIl_.js.map +1 -0
  9. package/dist/_chunks/ComponentConfigurationPage-D1l2o3w3.mjs +236 -0
  10. package/dist/_chunks/ComponentConfigurationPage-D1l2o3w3.mjs.map +1 -0
  11. package/dist/_chunks/ComponentIcon-BXdiCGQp.js +176 -0
  12. package/dist/_chunks/ComponentIcon-BXdiCGQp.js.map +1 -0
  13. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs +157 -0
  14. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
  15. package/dist/_chunks/EditConfigurationPage-Sed22MMc.js +151 -0
  16. package/dist/_chunks/EditConfigurationPage-Sed22MMc.js.map +1 -0
  17. package/dist/_chunks/EditConfigurationPage-uDsDO3-f.mjs +132 -0
  18. package/dist/_chunks/EditConfigurationPage-uDsDO3-f.mjs.map +1 -0
  19. package/dist/_chunks/EditViewPage-Bg7aQ3vS.mjs +224 -0
  20. package/dist/_chunks/EditViewPage-Bg7aQ3vS.mjs.map +1 -0
  21. package/dist/_chunks/EditViewPage-CcWIJyJa.js +243 -0
  22. package/dist/_chunks/EditViewPage-CcWIJyJa.js.map +1 -0
  23. package/dist/_chunks/Field-BnTZJ0fG.js +5591 -0
  24. package/dist/_chunks/Field-BnTZJ0fG.js.map +1 -0
  25. package/dist/_chunks/Field-Cf1nzyOi.mjs +5559 -0
  26. package/dist/_chunks/Field-Cf1nzyOi.mjs.map +1 -0
  27. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs +50 -0
  28. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -0
  29. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js +49 -0
  30. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -0
  31. package/dist/_chunks/Form-BH04zZdW.js +779 -0
  32. package/dist/_chunks/Form-BH04zZdW.js.map +1 -0
  33. package/dist/_chunks/Form-CXe7dOCt.mjs +758 -0
  34. package/dist/_chunks/Form-CXe7dOCt.mjs.map +1 -0
  35. package/dist/_chunks/History-CAM3gN3h.js +1053 -0
  36. package/dist/_chunks/History-CAM3gN3h.js.map +1 -0
  37. package/dist/_chunks/History-Cg_rjVg_.mjs +1032 -0
  38. package/dist/_chunks/History-Cg_rjVg_.mjs.map +1 -0
  39. package/dist/_chunks/ListConfigurationPage-51n8mFbZ.mjs +632 -0
  40. package/dist/_chunks/ListConfigurationPage-51n8mFbZ.mjs.map +1 -0
  41. package/dist/_chunks/ListConfigurationPage-DMBKzujx.js +652 -0
  42. package/dist/_chunks/ListConfigurationPage-DMBKzujx.js.map +1 -0
  43. package/dist/_chunks/ListViewPage-DFzs-3jf.js +852 -0
  44. package/dist/_chunks/ListViewPage-DFzs-3jf.js.map +1 -0
  45. package/dist/_chunks/ListViewPage-RzuT8-b2.mjs +828 -0
  46. package/dist/_chunks/ListViewPage-RzuT8-b2.mjs.map +1 -0
  47. package/dist/_chunks/NoContentTypePage-BNfF_UU1.js +51 -0
  48. package/dist/_chunks/NoContentTypePage-BNfF_UU1.js.map +1 -0
  49. package/dist/_chunks/NoContentTypePage-CldwfMNH.mjs +51 -0
  50. package/dist/_chunks/NoContentTypePage-CldwfMNH.mjs.map +1 -0
  51. package/dist/_chunks/NoPermissionsPage-DhRIJOX9.mjs +23 -0
  52. package/dist/_chunks/NoPermissionsPage-DhRIJOX9.mjs.map +1 -0
  53. package/dist/_chunks/NoPermissionsPage-DwcEM1UU.js +23 -0
  54. package/dist/_chunks/NoPermissionsPage-DwcEM1UU.js.map +1 -0
  55. package/dist/_chunks/Relations-D3LEWajT.mjs +703 -0
  56. package/dist/_chunks/Relations-D3LEWajT.mjs.map +1 -0
  57. package/dist/_chunks/Relations-DnFXuS0x.js +723 -0
  58. package/dist/_chunks/Relations-DnFXuS0x.js.map +1 -0
  59. package/dist/_chunks/ar-BUUWXIYu.js +226 -0
  60. package/dist/_chunks/ar-BUUWXIYu.js.map +1 -0
  61. package/dist/_chunks/ar-CCEVvqGG.mjs +226 -0
  62. package/dist/_chunks/ar-CCEVvqGG.mjs.map +1 -0
  63. package/dist/_chunks/ca-5U32ON2v.mjs +201 -0
  64. package/dist/_chunks/ca-5U32ON2v.mjs.map +1 -0
  65. package/dist/_chunks/ca-Cmk45QO6.js +201 -0
  66. package/dist/_chunks/ca-Cmk45QO6.js.map +1 -0
  67. package/dist/_chunks/cs-CM2aBUar.mjs +125 -0
  68. package/dist/_chunks/cs-CM2aBUar.mjs.map +1 -0
  69. package/dist/_chunks/cs-CkJy6B2v.js +125 -0
  70. package/dist/_chunks/cs-CkJy6B2v.js.map +1 -0
  71. package/dist/_chunks/de-C72KDNOl.mjs +199 -0
  72. package/dist/_chunks/de-C72KDNOl.mjs.map +1 -0
  73. package/dist/_chunks/de-CCEmbAah.js +199 -0
  74. package/dist/_chunks/de-CCEmbAah.js.map +1 -0
  75. package/dist/_chunks/en-Bm0D0IWz.js +293 -0
  76. package/dist/_chunks/en-Bm0D0IWz.js.map +1 -0
  77. package/dist/_chunks/en-DKV44jRb.mjs +293 -0
  78. package/dist/_chunks/en-DKV44jRb.mjs.map +1 -0
  79. package/dist/_chunks/es-CeXiYflN.mjs +196 -0
  80. package/dist/_chunks/es-CeXiYflN.mjs.map +1 -0
  81. package/dist/_chunks/es-EUonQTon.js +196 -0
  82. package/dist/_chunks/es-EUonQTon.js.map +1 -0
  83. package/dist/_chunks/eu-CdALomew.mjs +202 -0
  84. package/dist/_chunks/eu-CdALomew.mjs.map +1 -0
  85. package/dist/_chunks/eu-VDH-3ovk.js +202 -0
  86. package/dist/_chunks/eu-VDH-3ovk.js.map +1 -0
  87. package/dist/_chunks/fr-B7kGGg3E.js +206 -0
  88. package/dist/_chunks/fr-B7kGGg3E.js.map +1 -0
  89. package/dist/_chunks/fr-CD9VFbPM.mjs +206 -0
  90. package/dist/_chunks/fr-CD9VFbPM.mjs.map +1 -0
  91. package/dist/_chunks/gu-BRmF601H.js +200 -0
  92. package/dist/_chunks/gu-BRmF601H.js.map +1 -0
  93. package/dist/_chunks/gu-CNpaMDpH.mjs +200 -0
  94. package/dist/_chunks/gu-CNpaMDpH.mjs.map +1 -0
  95. package/dist/_chunks/hi-CCJBptSq.js +200 -0
  96. package/dist/_chunks/hi-CCJBptSq.js.map +1 -0
  97. package/dist/_chunks/hi-Dwvd04m3.mjs +200 -0
  98. package/dist/_chunks/hi-Dwvd04m3.mjs.map +1 -0
  99. package/dist/_chunks/hooks-BAaaKPS_.js +7 -0
  100. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -0
  101. package/dist/_chunks/hooks-E5u1mcgM.mjs +8 -0
  102. package/dist/_chunks/hooks-E5u1mcgM.mjs.map +1 -0
  103. package/dist/_chunks/hu-CeYvaaO0.mjs +202 -0
  104. package/dist/_chunks/hu-CeYvaaO0.mjs.map +1 -0
  105. package/dist/_chunks/hu-sNV_yLYy.js +202 -0
  106. package/dist/_chunks/hu-sNV_yLYy.js.map +1 -0
  107. package/dist/_chunks/id-B5Ser98A.js +160 -0
  108. package/dist/_chunks/id-B5Ser98A.js.map +1 -0
  109. package/dist/_chunks/id-BtwA9WJT.mjs +160 -0
  110. package/dist/_chunks/id-BtwA9WJT.mjs.map +1 -0
  111. package/dist/_chunks/index-CtuQXm7x.mjs +4080 -0
  112. package/dist/_chunks/index-CtuQXm7x.mjs.map +1 -0
  113. package/dist/_chunks/index-DhdyY1Y8.js +4099 -0
  114. package/dist/_chunks/index-DhdyY1Y8.js.map +1 -0
  115. package/dist/_chunks/it-BrVPqaf1.mjs +162 -0
  116. package/dist/_chunks/it-BrVPqaf1.mjs.map +1 -0
  117. package/dist/_chunks/it-DkBIs7vD.js +162 -0
  118. package/dist/_chunks/it-DkBIs7vD.js.map +1 -0
  119. package/dist/_chunks/ja-CcFe8diO.js +196 -0
  120. package/dist/_chunks/ja-CcFe8diO.js.map +1 -0
  121. package/dist/_chunks/ja-CtsUxOvk.mjs +196 -0
  122. package/dist/_chunks/ja-CtsUxOvk.mjs.map +1 -0
  123. package/dist/_chunks/ko-HVQRlfUI.mjs +195 -0
  124. package/dist/_chunks/ko-HVQRlfUI.mjs.map +1 -0
  125. package/dist/_chunks/ko-woFZPmLk.js +195 -0
  126. package/dist/_chunks/ko-woFZPmLk.js.map +1 -0
  127. package/dist/_chunks/layout-BQCvMBx_.mjs +471 -0
  128. package/dist/_chunks/layout-BQCvMBx_.mjs.map +1 -0
  129. package/dist/_chunks/layout-DeADP3ln.js +489 -0
  130. package/dist/_chunks/layout-DeADP3ln.js.map +1 -0
  131. package/dist/_chunks/ml-BihZwQit.mjs +200 -0
  132. package/dist/_chunks/ml-BihZwQit.mjs.map +1 -0
  133. package/dist/_chunks/ml-C2W8N8k1.js +200 -0
  134. package/dist/_chunks/ml-C2W8N8k1.js.map +1 -0
  135. package/dist/_chunks/ms-BuFotyP_.js +144 -0
  136. package/dist/_chunks/ms-BuFotyP_.js.map +1 -0
  137. package/dist/_chunks/ms-m_WjyWx7.mjs +144 -0
  138. package/dist/_chunks/ms-m_WjyWx7.mjs.map +1 -0
  139. package/dist/_chunks/nl-D4R9gHx5.mjs +202 -0
  140. package/dist/_chunks/nl-D4R9gHx5.mjs.map +1 -0
  141. package/dist/_chunks/nl-bbEOHChV.js +202 -0
  142. package/dist/_chunks/nl-bbEOHChV.js.map +1 -0
  143. package/dist/_chunks/objects-gigeqt7s.js +49 -0
  144. package/dist/_chunks/objects-gigeqt7s.js.map +1 -0
  145. package/dist/_chunks/objects-mKMAmfec.mjs +47 -0
  146. package/dist/_chunks/objects-mKMAmfec.mjs.map +1 -0
  147. package/dist/_chunks/pl-sbx9mSt_.mjs +199 -0
  148. package/dist/_chunks/pl-sbx9mSt_.mjs.map +1 -0
  149. package/dist/_chunks/pl-uzwG-hk7.js +199 -0
  150. package/dist/_chunks/pl-uzwG-hk7.js.map +1 -0
  151. package/dist/_chunks/pt-BR-BiOz37D9.js +201 -0
  152. package/dist/_chunks/pt-BR-BiOz37D9.js.map +1 -0
  153. package/dist/_chunks/pt-BR-C71iDxnh.mjs +201 -0
  154. package/dist/_chunks/pt-BR-C71iDxnh.mjs.map +1 -0
  155. package/dist/_chunks/pt-BsaFvS8-.mjs +95 -0
  156. package/dist/_chunks/pt-BsaFvS8-.mjs.map +1 -0
  157. package/dist/_chunks/pt-CeXQuq50.js +95 -0
  158. package/dist/_chunks/pt-CeXQuq50.js.map +1 -0
  159. package/dist/_chunks/relations-BVo_S6No.js +134 -0
  160. package/dist/_chunks/relations-BVo_S6No.js.map +1 -0
  161. package/dist/_chunks/relations-tS4X2RK8.mjs +135 -0
  162. package/dist/_chunks/relations-tS4X2RK8.mjs.map +1 -0
  163. package/dist/_chunks/ru-BE6A4Exp.mjs +231 -0
  164. package/dist/_chunks/ru-BE6A4Exp.mjs.map +1 -0
  165. package/dist/_chunks/ru-BT3ybNny.js +231 -0
  166. package/dist/_chunks/ru-BT3ybNny.js.map +1 -0
  167. package/dist/_chunks/sa-CcvkYInH.js +200 -0
  168. package/dist/_chunks/sa-CcvkYInH.js.map +1 -0
  169. package/dist/_chunks/sa-Dag0k-Z8.mjs +200 -0
  170. package/dist/_chunks/sa-Dag0k-Z8.mjs.map +1 -0
  171. package/dist/_chunks/sk-BFg-R8qJ.mjs +202 -0
  172. package/dist/_chunks/sk-BFg-R8qJ.mjs.map +1 -0
  173. package/dist/_chunks/sk-CvY09Xjv.js +202 -0
  174. package/dist/_chunks/sk-CvY09Xjv.js.map +1 -0
  175. package/dist/_chunks/sv-CUnfWGsh.mjs +202 -0
  176. package/dist/_chunks/sv-CUnfWGsh.mjs.map +1 -0
  177. package/dist/_chunks/sv-MYDuzgvT.js +202 -0
  178. package/dist/_chunks/sv-MYDuzgvT.js.map +1 -0
  179. package/dist/_chunks/th-BqbI8lIT.mjs +148 -0
  180. package/dist/_chunks/th-BqbI8lIT.mjs.map +1 -0
  181. package/dist/_chunks/th-D9_GfAjc.js +148 -0
  182. package/dist/_chunks/th-D9_GfAjc.js.map +1 -0
  183. package/dist/_chunks/tr-CgeK3wJM.mjs +199 -0
  184. package/dist/_chunks/tr-CgeK3wJM.mjs.map +1 -0
  185. package/dist/_chunks/tr-D9UH-O_R.js +199 -0
  186. package/dist/_chunks/tr-D9UH-O_R.js.map +1 -0
  187. package/dist/_chunks/uk-C8EiqJY7.js +144 -0
  188. package/dist/_chunks/uk-C8EiqJY7.js.map +1 -0
  189. package/dist/_chunks/uk-CR-zDhAY.mjs +144 -0
  190. package/dist/_chunks/uk-CR-zDhAY.mjs.map +1 -0
  191. package/dist/_chunks/useDebounce-CtcjDB3L.js +28 -0
  192. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  193. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  194. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  195. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs +231 -0
  196. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -0
  197. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js +249 -0
  198. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -0
  199. package/dist/_chunks/vi-CJlYDheJ.js +111 -0
  200. package/dist/_chunks/vi-CJlYDheJ.js.map +1 -0
  201. package/dist/_chunks/vi-DUXIk_fw.mjs +111 -0
  202. package/dist/_chunks/vi-DUXIk_fw.mjs.map +1 -0
  203. package/dist/_chunks/zh-BWZspA60.mjs +209 -0
  204. package/dist/_chunks/zh-BWZspA60.mjs.map +1 -0
  205. package/dist/_chunks/zh-CQQfszqR.js +209 -0
  206. package/dist/_chunks/zh-CQQfszqR.js.map +1 -0
  207. package/dist/_chunks/zh-Hans-9kOncHGw.js +952 -0
  208. package/dist/_chunks/zh-Hans-9kOncHGw.js.map +1 -0
  209. package/dist/_chunks/zh-Hans-BPQcRIyH.mjs +952 -0
  210. package/dist/_chunks/zh-Hans-BPQcRIyH.mjs.map +1 -0
  211. package/dist/admin/index.js +13 -0
  212. package/dist/admin/index.js.map +1 -0
  213. package/dist/admin/index.mjs +13 -0
  214. package/dist/admin/index.mjs.map +1 -0
  215. package/dist/admin/src/components/ComponentIcon.d.ts +11 -0
  216. package/dist/admin/src/components/ConfigurationForm/EditFieldForm.d.ts +9 -0
  217. package/dist/admin/src/components/ConfigurationForm/Fields.d.ts +21 -0
  218. package/dist/admin/src/components/ConfigurationForm/Form.d.ts +32 -0
  219. package/dist/admin/src/components/DragLayer.d.ts +13 -0
  220. package/dist/admin/src/components/DragPreviews/CardDragPreview.d.ts +7 -0
  221. package/dist/admin/src/components/DragPreviews/ComponentDragPreview.d.ts +6 -0
  222. package/dist/admin/src/components/DragPreviews/RelationDragPreview.d.ts +11 -0
  223. package/dist/admin/src/components/FieldTypeIcon.d.ts +9 -0
  224. package/dist/admin/src/components/InjectionZone.d.ts +45 -0
  225. package/dist/admin/src/components/LeftMenu.d.ts +2 -0
  226. package/dist/admin/src/components/RelativeTime.d.ts +28 -0
  227. package/dist/admin/src/constants/attributes.d.ts +14 -0
  228. package/dist/admin/src/constants/collections.d.ts +3 -0
  229. package/dist/admin/src/constants/dragAndDrop.d.ts +8 -0
  230. package/dist/admin/src/constants/hooks.d.ts +26 -0
  231. package/dist/admin/src/constants/plugin.d.ts +3 -0
  232. package/dist/admin/src/content-manager.d.ts +133 -0
  233. package/dist/admin/src/exports.d.ts +12 -0
  234. package/dist/admin/src/features/DocumentRBAC.d.ts +36 -0
  235. package/dist/admin/src/history/components/HistoryAction.d.ts +3 -0
  236. package/dist/admin/src/history/components/VersionContent.d.ts +17 -0
  237. package/dist/admin/src/history/components/VersionHeader.d.ts +5 -0
  238. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +19 -0
  239. package/dist/admin/src/history/components/VersionsList.d.ts +2 -0
  240. package/dist/admin/src/history/index.d.ts +3 -0
  241. package/dist/admin/src/history/pages/History.d.ts +27 -0
  242. package/dist/admin/src/history/routes.d.ts +6 -0
  243. package/dist/admin/src/history/services/historyVersion.d.ts +12 -0
  244. package/dist/admin/src/hooks/useContentManagerInitData.d.ts +15 -0
  245. package/dist/admin/src/hooks/useContentTypeSchema.d.ts +25 -0
  246. package/dist/admin/src/hooks/useDebounce.d.ts +1 -0
  247. package/dist/admin/src/hooks/useDocument.d.ts +118 -0
  248. package/dist/admin/src/hooks/useDocumentActions.d.ts +123 -0
  249. package/dist/admin/src/hooks/useDocumentLayout.d.ts +137 -0
  250. package/dist/admin/src/hooks/useDragAndDrop.d.ts +51 -0
  251. package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +14 -0
  252. package/dist/admin/src/hooks/useLazyComponents.d.ts +13 -0
  253. package/dist/admin/src/hooks/useOnce.d.ts +2 -0
  254. package/dist/admin/src/hooks/usePrev.d.ts +1 -0
  255. package/dist/admin/src/index.d.ts +17 -0
  256. package/dist/admin/src/layout.d.ts +2 -0
  257. package/dist/admin/src/modules/app.d.ts +20 -0
  258. package/dist/admin/src/modules/hooks.d.ts +10 -0
  259. package/dist/admin/src/modules/reducers.d.ts +6 -0
  260. package/dist/admin/src/pages/ComponentConfigurationPage.d.ts +3 -0
  261. package/dist/admin/src/pages/EditConfigurationPage.d.ts +3 -0
  262. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +3 -0
  263. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +76 -0
  264. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +16 -0
  265. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +3 -0
  266. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Heading.d.ts +3 -0
  267. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.d.ts +3 -0
  268. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.d.ts +3 -0
  269. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.d.ts +3 -0
  270. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Paragraph.d.ts +3 -0
  271. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Quote.d.ts +3 -0
  272. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.d.ts +6 -0
  273. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +61 -0
  274. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +11 -0
  275. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.d.ts +10 -0
  276. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.d.ts +10 -0
  277. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Modifiers.d.ts +16 -0
  278. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.d.ts +11 -0
  279. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.d.ts +9 -0
  280. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.d.ts +8 -0
  281. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  282. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/conversions.d.ts +13 -0
  283. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/enterKey.d.ts +6 -0
  284. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/links.d.ts +10 -0
  285. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.d.ts +10 -0
  286. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Initializer.d.ts +9 -0
  287. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +18 -0
  288. package/dist/admin/src/pages/EditView/components/FormInputs/Component/NonRepeatable.d.ts +5 -0
  289. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Repeatable.d.ts +5 -0
  290. package/dist/admin/src/pages/EditView/components/FormInputs/ComponentContext.d.ts +42 -0
  291. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/AddComponentButton.d.ts +11 -0
  292. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCard.d.ts +9 -0
  293. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +15 -0
  294. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.d.ts +9 -0
  295. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +14 -0
  296. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicZoneLabel.d.ts +12 -0
  297. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +14 -0
  298. package/dist/admin/src/pages/EditView/components/FormInputs/NotAllowed.d.ts +7 -0
  299. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +38 -0
  300. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +9 -0
  301. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Editor.d.ts +17 -0
  302. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +14 -0
  303. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +11 -0
  304. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/PreviewWysiwyg.d.ts +5 -0
  305. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +7 -0
  306. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.d.ts +17 -0
  307. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +18 -0
  308. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/continueList.d.ts +5 -0
  309. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/mdRenderer.d.ts +4 -0
  310. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/utils.d.ts +16 -0
  311. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +5 -0
  312. package/dist/admin/src/pages/EditView/components/Header.d.ts +35 -0
  313. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +9 -0
  314. package/dist/admin/src/pages/EditView/components/Panels.d.ts +10 -0
  315. package/dist/admin/src/pages/EditView/utils/data.d.ts +33 -0
  316. package/dist/admin/src/pages/EditView/utils/forms.d.ts +9 -0
  317. package/dist/admin/src/pages/ListConfiguration/ListConfigurationPage.d.ts +10 -0
  318. package/dist/admin/src/pages/ListConfiguration/components/DraggableCard.d.ts +12 -0
  319. package/dist/admin/src/pages/ListConfiguration/components/EditFieldForm.d.ts +8 -0
  320. package/dist/admin/src/pages/ListConfiguration/components/Header.d.ts +8 -0
  321. package/dist/admin/src/pages/ListConfiguration/components/Settings.d.ts +19 -0
  322. package/dist/admin/src/pages/ListConfiguration/components/SortDisplayedFields.d.ts +6 -0
  323. package/dist/admin/src/pages/ListView/ListViewPage.d.ts +3 -0
  324. package/dist/admin/src/pages/ListView/components/AutoCloneFailureModal.d.ts +7 -0
  325. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +24 -0
  326. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +15 -0
  327. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +14 -0
  328. package/dist/admin/src/pages/ListView/components/Filters.d.ts +8 -0
  329. package/dist/admin/src/pages/ListView/components/TableActions.d.ts +8 -0
  330. package/dist/admin/src/pages/ListView/components/TableCells/CellContent.d.ts +9 -0
  331. package/dist/admin/src/pages/ListView/components/TableCells/CellValue.d.ts +8 -0
  332. package/dist/admin/src/pages/ListView/components/TableCells/Components.d.ts +12 -0
  333. package/dist/admin/src/pages/ListView/components/TableCells/Media.d.ts +23 -0
  334. package/dist/admin/src/pages/ListView/components/TableCells/Relations.d.ts +12 -0
  335. package/dist/admin/src/pages/ListView/components/ViewSettingsMenu.d.ts +10 -0
  336. package/dist/admin/src/pages/NoContentTypePage.d.ts +2 -0
  337. package/dist/admin/src/pages/NoPermissionsPage.d.ts +2 -0
  338. package/dist/admin/src/router.d.ts +5 -0
  339. package/dist/admin/src/services/api.d.ts +2 -0
  340. package/dist/admin/src/services/components.d.ts +5 -0
  341. package/dist/admin/src/services/contentTypes.d.ts +17 -0
  342. package/dist/admin/src/services/documents.d.ts +103 -0
  343. package/dist/admin/src/services/init.d.ts +9 -0
  344. package/dist/admin/src/services/relations.d.ts +49 -0
  345. package/dist/admin/src/services/uid.d.ts +32 -0
  346. package/dist/admin/src/utils/api.d.ts +24 -0
  347. package/dist/admin/src/utils/attributes.d.ts +19 -0
  348. package/dist/admin/src/utils/objects.d.ts +33 -0
  349. package/dist/admin/src/utils/relations.d.ts +12 -0
  350. package/dist/admin/src/utils/strings.d.ts +2 -0
  351. package/dist/admin/src/utils/translations.d.ts +4 -0
  352. package/dist/admin/src/utils/urls.d.ts +2 -0
  353. package/dist/admin/src/utils/users.d.ts +6 -0
  354. package/dist/admin/src/utils/validation.d.ts +10 -0
  355. package/dist/server/index.js +4447 -0
  356. package/dist/server/index.js.map +1 -0
  357. package/dist/server/index.mjs +4423 -0
  358. package/dist/server/index.mjs.map +1 -0
  359. package/dist/server/src/bootstrap.d.ts +3 -0
  360. package/dist/server/src/bootstrap.d.ts.map +1 -0
  361. package/dist/server/src/config.d.ts +6 -0
  362. package/dist/server/src/config.d.ts.map +1 -0
  363. package/dist/server/src/constants/index.d.ts +6 -0
  364. package/dist/server/src/constants/index.d.ts.map +1 -0
  365. package/dist/server/src/controllers/collection-types.d.ts +23 -0
  366. package/dist/server/src/controllers/collection-types.d.ts.map +1 -0
  367. package/dist/server/src/controllers/components.d.ts +7 -0
  368. package/dist/server/src/controllers/components.d.ts.map +1 -0
  369. package/dist/server/src/controllers/content-types.d.ts +8 -0
  370. package/dist/server/src/controllers/content-types.d.ts.map +1 -0
  371. package/dist/server/src/controllers/index.d.ts +53 -0
  372. package/dist/server/src/controllers/index.d.ts.map +1 -0
  373. package/dist/server/src/controllers/init.d.ts +5 -0
  374. package/dist/server/src/controllers/init.d.ts.map +1 -0
  375. package/dist/server/src/controllers/relations.d.ts +13 -0
  376. package/dist/server/src/controllers/relations.d.ts.map +1 -0
  377. package/dist/server/src/controllers/single-types.d.ts +11 -0
  378. package/dist/server/src/controllers/single-types.d.ts.map +1 -0
  379. package/dist/server/src/controllers/uid.d.ts +6 -0
  380. package/dist/server/src/controllers/uid.d.ts.map +1 -0
  381. package/dist/server/src/controllers/utils/clone.d.ts +12 -0
  382. package/dist/server/src/controllers/utils/clone.d.ts.map +1 -0
  383. package/dist/server/src/controllers/utils/metadata.d.ts +8 -0
  384. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
  385. package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
  386. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
  387. package/dist/server/src/controllers/validation/index.d.ts +20 -0
  388. package/dist/server/src/controllers/validation/index.d.ts.map +1 -0
  389. package/dist/server/src/controllers/validation/model-configuration.d.ts +22 -0
  390. package/dist/server/src/controllers/validation/model-configuration.d.ts.map +1 -0
  391. package/dist/server/src/controllers/validation/relations.d.ts +4 -0
  392. package/dist/server/src/controllers/validation/relations.d.ts.map +1 -0
  393. package/dist/server/src/destroy.d.ts +4 -0
  394. package/dist/server/src/destroy.d.ts.map +1 -0
  395. package/dist/server/src/history/constants.d.ts +3 -0
  396. package/dist/server/src/history/constants.d.ts.map +1 -0
  397. package/dist/server/src/history/controllers/history-version.d.ts +19 -0
  398. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -0
  399. package/dist/server/src/history/controllers/index.d.ts +2 -0
  400. package/dist/server/src/history/controllers/index.d.ts.map +1 -0
  401. package/dist/server/src/history/controllers/validation/history-version.d.ts +2 -0
  402. package/dist/server/src/history/controllers/validation/history-version.d.ts.map +1 -0
  403. package/dist/server/src/history/index.d.ts +4 -0
  404. package/dist/server/src/history/index.d.ts.map +1 -0
  405. package/dist/server/src/history/models/history-version.d.ts +4 -0
  406. package/dist/server/src/history/models/history-version.d.ts.map +1 -0
  407. package/dist/server/src/history/routes/history-version.d.ts +4 -0
  408. package/dist/server/src/history/routes/history-version.d.ts.map +1 -0
  409. package/dist/server/src/history/routes/index.d.ts +8 -0
  410. package/dist/server/src/history/routes/index.d.ts.map +1 -0
  411. package/dist/server/src/history/services/history.d.ts +16 -0
  412. package/dist/server/src/history/services/history.d.ts.map +1 -0
  413. package/dist/server/src/history/services/index.d.ts +19 -0
  414. package/dist/server/src/history/services/index.d.ts.map +1 -0
  415. package/dist/server/src/history/services/lifecycles.d.ts +9 -0
  416. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -0
  417. package/dist/server/src/history/services/utils.d.ts +45 -0
  418. package/dist/server/src/history/services/utils.d.ts.map +1 -0
  419. package/dist/server/src/history/utils.d.ts +22 -0
  420. package/dist/server/src/history/utils.d.ts.map +1 -0
  421. package/dist/server/src/index.d.ts +353 -0
  422. package/dist/server/src/index.d.ts.map +1 -0
  423. package/dist/server/src/middlewares/index.d.ts +3 -0
  424. package/dist/server/src/middlewares/index.d.ts.map +1 -0
  425. package/dist/server/src/middlewares/routing.d.ts +4 -0
  426. package/dist/server/src/middlewares/routing.d.ts.map +1 -0
  427. package/dist/server/src/policies/hasPermissions.d.ts +7 -0
  428. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -0
  429. package/dist/server/src/policies/index.d.ts +9 -0
  430. package/dist/server/src/policies/index.d.ts.map +1 -0
  431. package/dist/server/src/register.d.ts +4 -0
  432. package/dist/server/src/register.d.ts.map +1 -0
  433. package/dist/server/src/routes/admin.d.ts +41 -0
  434. package/dist/server/src/routes/admin.d.ts.map +1 -0
  435. package/dist/server/src/routes/index.d.ts +43 -0
  436. package/dist/server/src/routes/index.d.ts.map +1 -0
  437. package/dist/server/src/services/components.d.ts +32 -0
  438. package/dist/server/src/services/components.d.ts.map +1 -0
  439. package/dist/server/src/services/configuration.d.ts +20 -0
  440. package/dist/server/src/services/configuration.d.ts.map +1 -0
  441. package/dist/server/src/services/content-types.d.ts +18 -0
  442. package/dist/server/src/services/content-types.d.ts.map +1 -0
  443. package/dist/server/src/services/data-mapper.d.ts +20 -0
  444. package/dist/server/src/services/data-mapper.d.ts.map +1 -0
  445. package/dist/server/src/services/document-manager.d.ts +48 -0
  446. package/dist/server/src/services/document-manager.d.ts.map +1 -0
  447. package/dist/server/src/services/document-metadata.d.ts +67 -0
  448. package/dist/server/src/services/document-metadata.d.ts.map +1 -0
  449. package/dist/server/src/services/field-sizes.d.ts +19 -0
  450. package/dist/server/src/services/field-sizes.d.ts.map +1 -0
  451. package/dist/server/src/services/index.d.ts +245 -0
  452. package/dist/server/src/services/index.d.ts.map +1 -0
  453. package/dist/server/src/services/metrics.d.ts +9 -0
  454. package/dist/server/src/services/metrics.d.ts.map +1 -0
  455. package/dist/server/src/services/permission-checker.d.ts +54 -0
  456. package/dist/server/src/services/permission-checker.d.ts.map +1 -0
  457. package/dist/server/src/services/permission.d.ts +12 -0
  458. package/dist/server/src/services/permission.d.ts.map +1 -0
  459. package/dist/server/src/services/populate-builder.d.ts +30 -0
  460. package/dist/server/src/services/populate-builder.d.ts.map +1 -0
  461. package/dist/server/src/services/uid.d.ts +25 -0
  462. package/dist/server/src/services/uid.d.ts.map +1 -0
  463. package/dist/server/src/services/utils/configuration/attributes.d.ts +17 -0
  464. package/dist/server/src/services/utils/configuration/attributes.d.ts.map +1 -0
  465. package/dist/server/src/services/utils/configuration/index.d.ts +21 -0
  466. package/dist/server/src/services/utils/configuration/index.d.ts.map +1 -0
  467. package/dist/server/src/services/utils/configuration/layouts.d.ts +14 -0
  468. package/dist/server/src/services/utils/configuration/layouts.d.ts.map +1 -0
  469. package/dist/server/src/services/utils/configuration/metadatas.d.ts +5 -0
  470. package/dist/server/src/services/utils/configuration/metadatas.d.ts.map +1 -0
  471. package/dist/server/src/services/utils/configuration/settings.d.ts +5 -0
  472. package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -0
  473. package/dist/server/src/services/utils/count.d.ts +5 -0
  474. package/dist/server/src/services/utils/count.d.ts.map +1 -0
  475. package/dist/server/src/services/utils/draft.d.ts +11 -0
  476. package/dist/server/src/services/utils/draft.d.ts.map +1 -0
  477. package/dist/server/src/services/utils/populate.d.ts +42 -0
  478. package/dist/server/src/services/utils/populate.d.ts.map +1 -0
  479. package/dist/server/src/services/utils/store.d.ts +16 -0
  480. package/dist/server/src/services/utils/store.d.ts.map +1 -0
  481. package/dist/server/src/utils/index.d.ts +9 -0
  482. package/dist/server/src/utils/index.d.ts.map +1 -0
  483. package/dist/server/src/validation/policies/hasPermissions.d.ts +2 -0
  484. package/dist/server/src/validation/policies/hasPermissions.d.ts.map +1 -0
  485. package/dist/shared/contracts/collection-types.d.ts +338 -0
  486. package/dist/shared/contracts/collection-types.d.ts.map +1 -0
  487. package/dist/shared/contracts/components.d.ts +65 -0
  488. package/dist/shared/contracts/components.d.ts.map +1 -0
  489. package/dist/shared/contracts/content-types.d.ts +113 -0
  490. package/dist/shared/contracts/content-types.d.ts.map +1 -0
  491. package/dist/shared/contracts/history-versions.d.ts +92 -0
  492. package/dist/shared/contracts/history-versions.d.ts.map +1 -0
  493. package/dist/shared/contracts/index.d.ts +10 -0
  494. package/dist/shared/contracts/index.d.ts.map +1 -0
  495. package/dist/shared/contracts/init.d.ts +24 -0
  496. package/dist/shared/contracts/init.d.ts.map +1 -0
  497. package/dist/shared/contracts/relations.d.ts +70 -0
  498. package/dist/shared/contracts/relations.d.ts.map +1 -0
  499. package/dist/shared/contracts/review-workflows.d.ts +78 -0
  500. package/dist/shared/contracts/review-workflows.d.ts.map +1 -0
  501. package/dist/shared/contracts/single-types.d.ts +113 -0
  502. package/dist/shared/contracts/single-types.d.ts.map +1 -0
  503. package/dist/shared/contracts/uid.d.ts +48 -0
  504. package/dist/shared/contracts/uid.d.ts.map +1 -0
  505. package/dist/shared/index.d.ts +2 -0
  506. package/dist/shared/index.d.ts.map +1 -0
  507. package/dist/shared/index.js +43 -0
  508. package/dist/shared/index.js.map +1 -0
  509. package/dist/shared/index.mjs +43 -0
  510. package/dist/shared/index.mjs.map +1 -0
  511. package/package.json +133 -0
@@ -0,0 +1,4099 @@
1
+ "use strict";
2
+ const Icons = require("@strapi/icons");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const strapiAdmin = require("@strapi/admin/strapi-admin");
5
+ const React = require("react");
6
+ const designSystem = require("@strapi/design-system");
7
+ const reactIntl = require("react-intl");
8
+ const reactRouterDom = require("react-router-dom");
9
+ const yup = require("yup");
10
+ const pipe = require("lodash/fp/pipe");
11
+ const dateFns = require("date-fns");
12
+ const styledComponents = require("styled-components");
13
+ const qs = require("qs");
14
+ const toolkit = require("@reduxjs/toolkit");
15
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
16
+ function _interopNamespace(e) {
17
+ if (e && e.__esModule)
18
+ return e;
19
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
20
+ if (e) {
21
+ for (const k in e) {
22
+ if (k !== "default") {
23
+ const d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: () => e[k]
27
+ });
28
+ }
29
+ }
30
+ }
31
+ n.default = e;
32
+ return Object.freeze(n);
33
+ }
34
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
35
+ const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
36
+ const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
37
+ const __variableDynamicImportRuntimeHelper = (glob, path) => {
38
+ const v = glob[path];
39
+ if (v) {
40
+ return typeof v === "function" ? v() : Promise.resolve(v);
41
+ }
42
+ return new Promise((_, reject) => {
43
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
44
+ });
45
+ };
46
+ const PLUGIN_ID = "content-manager";
47
+ const PERMISSIONS = [
48
+ "plugin::content-manager.explorer.create",
49
+ "plugin::content-manager.explorer.read",
50
+ "plugin::content-manager.explorer.update",
51
+ "plugin::content-manager.explorer.delete",
52
+ "plugin::content-manager.explorer.publish"
53
+ ];
54
+ const INJECTION_ZONES = {
55
+ editView: { informations: [], "right-links": [] },
56
+ listView: {
57
+ actions: [],
58
+ deleteModalAdditionalInfos: [],
59
+ publishModalAdditionalInfos: [],
60
+ unpublishModalAdditionalInfos: []
61
+ }
62
+ };
63
+ const InjectionZone = ({ area, ...props }) => {
64
+ const components = useInjectionZone(area);
65
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: components.map((component) => /* @__PURE__ */ jsxRuntime.jsx(component.Component, { ...props }, component.name)) });
66
+ };
67
+ const useInjectionZone = (area) => {
68
+ const getPlugin = strapiAdmin.useStrapiApp("useInjectionZone", (state) => state.getPlugin);
69
+ const contentManagerPlugin = getPlugin(PLUGIN_ID);
70
+ const [page, position] = area.split(".");
71
+ return contentManagerPlugin.getInjectedComponents(page, position);
72
+ };
73
+ const ID = "id";
74
+ const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
75
+ const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
76
+ const CREATOR_FIELDS = [CREATED_BY_ATTRIBUTE_NAME, UPDATED_BY_ATTRIBUTE_NAME];
77
+ const PUBLISHED_BY_ATTRIBUTE_NAME = "publishedBy";
78
+ const CREATED_AT_ATTRIBUTE_NAME = "createdAt";
79
+ const UPDATED_AT_ATTRIBUTE_NAME = "updatedAt";
80
+ const PUBLISHED_AT_ATTRIBUTE_NAME = "publishedAt";
81
+ const DOCUMENT_META_FIELDS = [
82
+ ID,
83
+ ...CREATOR_FIELDS,
84
+ PUBLISHED_BY_ATTRIBUTE_NAME,
85
+ CREATED_AT_ATTRIBUTE_NAME,
86
+ UPDATED_AT_ATTRIBUTE_NAME,
87
+ PUBLISHED_AT_ATTRIBUTE_NAME
88
+ ];
89
+ const ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = [
90
+ "dynamiczone",
91
+ "json",
92
+ "text",
93
+ "relation",
94
+ "component",
95
+ "boolean",
96
+ "media",
97
+ "password",
98
+ "richtext",
99
+ "timestamp",
100
+ "blocks"
101
+ ];
102
+ const SINGLE_TYPES = "single-types";
103
+ const COLLECTION_TYPES = "collection-types";
104
+ const [DocumentRBACProvider, useDocumentRBAC] = strapiAdmin.createContext(
105
+ "DocumentRBAC",
106
+ {
107
+ canCreate: false,
108
+ canCreateFields: [],
109
+ canDelete: false,
110
+ canPublish: false,
111
+ canRead: false,
112
+ canReadFields: [],
113
+ canUpdate: false,
114
+ canUpdateFields: [],
115
+ canUserAction: () => false,
116
+ isLoading: false
117
+ }
118
+ );
119
+ const DocumentRBAC = ({ children, permissions }) => {
120
+ const { slug } = reactRouterDom.useParams();
121
+ if (!slug) {
122
+ throw new Error("Cannot find the slug param in the URL");
123
+ }
124
+ const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
125
+ const contentTypePermissions = React__namespace.useMemo(() => {
126
+ const contentTypePermissions2 = userPermissions.filter(
127
+ (permission) => permission.subject === slug
128
+ );
129
+ return contentTypePermissions2.reduce((acc, permission) => {
130
+ const [action] = permission.action.split(".").slice(-1);
131
+ return { ...acc, [action]: [permission] };
132
+ }, {});
133
+ }, [slug, userPermissions]);
134
+ const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? void 0);
135
+ const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
136
+ const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
137
+ const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
138
+ const canUserAction = React__namespace.useCallback(
139
+ (fieldName, fieldsUserCanAction, fieldType) => {
140
+ const name = removeNumericalStrings(fieldName.split("."));
141
+ const componentFieldNames = fieldsUserCanAction.filter((field) => field.split(".").length > 1);
142
+ if (fieldType === "component") {
143
+ return componentFieldNames.some((field) => {
144
+ return field.includes(name.join("."));
145
+ });
146
+ }
147
+ if (name.length > 1) {
148
+ return componentFieldNames.includes(name.join("."));
149
+ }
150
+ return fieldsUserCanAction.includes(fieldName);
151
+ },
152
+ []
153
+ );
154
+ if (isLoading) {
155
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
156
+ }
157
+ return /* @__PURE__ */ jsxRuntime.jsx(
158
+ DocumentRBACProvider,
159
+ {
160
+ isLoading,
161
+ canCreateFields,
162
+ canReadFields,
163
+ canUpdateFields,
164
+ canUserAction,
165
+ ...allowedActions,
166
+ children
167
+ }
168
+ );
169
+ };
170
+ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permission) => permission.properties?.fields).filter(
171
+ (field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
172
+ );
173
+ const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
174
+ const contentManagerApi = strapiAdmin.adminApi.enhanceEndpoints({
175
+ addTagTypes: [
176
+ "ComponentConfiguration",
177
+ "ContentTypesConfiguration",
178
+ "ContentTypeSettings",
179
+ "Document",
180
+ "InitialData",
181
+ "HistoryVersion",
182
+ "Relations",
183
+ "UidAvailability"
184
+ ]
185
+ });
186
+ const documentApi = contentManagerApi.injectEndpoints({
187
+ overrideExisting: true,
188
+ endpoints: (builder) => ({
189
+ autoCloneDocument: builder.mutation({
190
+ query: ({ model, sourceId, query }) => ({
191
+ url: `/content-manager/collection-types/${model}/auto-clone/${sourceId}`,
192
+ method: "POST",
193
+ config: {
194
+ params: query
195
+ }
196
+ }),
197
+ invalidatesTags: (_result, error, { model }) => {
198
+ if (error) {
199
+ return [];
200
+ }
201
+ return [{ type: "Document", id: `${model}_LIST` }];
202
+ }
203
+ }),
204
+ cloneDocument: builder.mutation({
205
+ query: ({ model, sourceId, data, params }) => ({
206
+ url: `/content-manager/collection-types/${model}/clone/${sourceId}`,
207
+ method: "POST",
208
+ data,
209
+ config: {
210
+ params
211
+ }
212
+ }),
213
+ invalidatesTags: (_result, _error, { model }) => [
214
+ { type: "Document", id: `${model}_LIST` },
215
+ { type: "UidAvailability", id: model }
216
+ ]
217
+ }),
218
+ /**
219
+ * Creates a new collection-type document. This should ONLY be used for collection-types.
220
+ * single-types should always be using `updateDocument` since they always exist.
221
+ */
222
+ createDocument: builder.mutation({
223
+ query: ({ model, data, params }) => ({
224
+ url: `/content-manager/collection-types/${model}`,
225
+ method: "POST",
226
+ data,
227
+ config: {
228
+ params
229
+ }
230
+ }),
231
+ invalidatesTags: (result, _error, { model }) => [
232
+ { type: "Document", id: `${model}_LIST` },
233
+ "Relations",
234
+ { type: "UidAvailability", id: model }
235
+ ]
236
+ }),
237
+ deleteDocument: builder.mutation({
238
+ query: ({ collectionType, model, documentId, params }) => ({
239
+ url: `/content-manager/${collectionType}/${model}${collectionType !== SINGLE_TYPES && documentId ? `/${documentId}` : ""}`,
240
+ method: "DELETE",
241
+ config: {
242
+ params
243
+ }
244
+ }),
245
+ invalidatesTags: (_result, _error, { collectionType, model }) => [
246
+ { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
247
+ ]
248
+ }),
249
+ deleteManyDocuments: builder.mutation({
250
+ query: ({ model, params, ...body }) => ({
251
+ url: `/content-manager/collection-types/${model}/actions/bulkDelete`,
252
+ method: "POST",
253
+ data: body,
254
+ config: {
255
+ params
256
+ }
257
+ }),
258
+ invalidatesTags: (_res, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
259
+ }),
260
+ discardDocument: builder.mutation({
261
+ query: ({ collectionType, model, documentId, params }) => ({
262
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/discard` : `/content-manager/${collectionType}/${model}/actions/discard`,
263
+ method: "POST",
264
+ config: {
265
+ params
266
+ }
267
+ }),
268
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
269
+ return [
270
+ {
271
+ type: "Document",
272
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
273
+ },
274
+ { type: "Document", id: `${model}_LIST` },
275
+ "Relations",
276
+ { type: "UidAvailability", id: model }
277
+ ];
278
+ }
279
+ }),
280
+ /**
281
+ * Gets all documents of a collection type or single type.
282
+ * By passing different params you can get different results e.g. only published documents or 'es' documents.
283
+ */
284
+ getAllDocuments: builder.query({
285
+ query: ({ model, params }) => ({
286
+ url: `/content-manager/collection-types/${model}`,
287
+ method: "GET",
288
+ config: {
289
+ params
290
+ }
291
+ }),
292
+ providesTags: (result, _error, arg) => {
293
+ return [
294
+ { type: "Document", id: `ALL_LIST` },
295
+ { type: "Document", id: `${arg.model}_LIST` },
296
+ ...result?.results.map(({ documentId }) => ({
297
+ type: "Document",
298
+ id: `${arg.model}_${documentId}`
299
+ })) ?? []
300
+ ];
301
+ }
302
+ }),
303
+ getDraftRelationCount: builder.query({
304
+ query: ({ collectionType, model, documentId, params }) => ({
305
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/countDraftRelations` : `/content-manager/${collectionType}/${model}/actions/countDraftRelations`,
306
+ method: "GET",
307
+ config: {
308
+ params
309
+ }
310
+ })
311
+ }),
312
+ getDocument: builder.query({
313
+ // @ts-expect-error – TODO: fix ts error where data unknown doesn't work with response via an assertion?
314
+ queryFn: async ({ collectionType, model, documentId, params }, _api, _extraOpts, baseQuery) => {
315
+ const res = await baseQuery({
316
+ url: `/content-manager/${collectionType}/${model}${documentId ? `/${documentId}` : ""}`,
317
+ method: "GET",
318
+ config: {
319
+ params
320
+ }
321
+ });
322
+ if (res.error && res.error.name === "NotFoundError" && collectionType === SINGLE_TYPES) {
323
+ return { data: { document: void 0 }, error: void 0 };
324
+ }
325
+ return res;
326
+ },
327
+ providesTags: (result, _error, { collectionType, model, documentId }) => {
328
+ return [
329
+ // we prefer the result's id because we don't fetch single-types with an ID.
330
+ {
331
+ type: "Document",
332
+ id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
333
+ },
334
+ // Make it easy to invalidate all individual documents queries for a model
335
+ {
336
+ type: "Document",
337
+ id: `${model}_ALL_ITEMS`
338
+ }
339
+ ];
340
+ }
341
+ }),
342
+ getManyDraftRelationCount: builder.query({
343
+ query: ({ model, ...params }) => ({
344
+ url: `/content-manager/collection-types/${model}/actions/countManyEntriesDraftRelations`,
345
+ method: "GET",
346
+ config: {
347
+ params
348
+ }
349
+ }),
350
+ transformResponse: (response) => response.data
351
+ }),
352
+ /**
353
+ * This endpoint will either create or update documents at the same time as publishing.
354
+ */
355
+ publishDocument: builder.mutation({
356
+ query: ({ collectionType, model, documentId, params, data }) => ({
357
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/publish` : `/content-manager/${collectionType}/${model}/actions/publish`,
358
+ method: "POST",
359
+ data,
360
+ config: {
361
+ params
362
+ }
363
+ }),
364
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
365
+ return [
366
+ {
367
+ type: "Document",
368
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
369
+ },
370
+ { type: "Document", id: `${model}_LIST` },
371
+ "Relations"
372
+ ];
373
+ }
374
+ }),
375
+ publishManyDocuments: builder.mutation({
376
+ query: ({ model, params, ...body }) => ({
377
+ url: `/content-manager/collection-types/${model}/actions/bulkPublish`,
378
+ method: "POST",
379
+ data: body,
380
+ config: {
381
+ params
382
+ }
383
+ }),
384
+ invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
385
+ }),
386
+ updateDocument: builder.mutation({
387
+ query: ({ collectionType, model, documentId, data, params }) => ({
388
+ url: `/content-manager/${collectionType}/${model}${documentId ? `/${documentId}` : ""}`,
389
+ method: "PUT",
390
+ data,
391
+ config: {
392
+ params
393
+ }
394
+ }),
395
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
396
+ return [
397
+ {
398
+ type: "Document",
399
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
400
+ },
401
+ "Relations",
402
+ { type: "UidAvailability", id: model }
403
+ ];
404
+ },
405
+ async onQueryStarted({ data, ...patch }, { dispatch, queryFulfilled }) {
406
+ const patchResult = dispatch(
407
+ documentApi.util.updateQueryData("getDocument", patch, (draft) => {
408
+ Object.assign(draft.data, data);
409
+ })
410
+ );
411
+ try {
412
+ await queryFulfilled;
413
+ } catch {
414
+ patchResult.undo();
415
+ }
416
+ }
417
+ }),
418
+ unpublishDocument: builder.mutation({
419
+ query: ({ collectionType, model, documentId, params, data }) => ({
420
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/unpublish` : `/content-manager/${collectionType}/${model}/actions/unpublish`,
421
+ method: "POST",
422
+ data,
423
+ config: {
424
+ params
425
+ }
426
+ }),
427
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
428
+ return [
429
+ {
430
+ type: "Document",
431
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
432
+ }
433
+ ];
434
+ }
435
+ }),
436
+ unpublishManyDocuments: builder.mutation({
437
+ query: ({ model, params, ...body }) => ({
438
+ url: `/content-manager/collection-types/${model}/actions/bulkUnpublish`,
439
+ method: "POST",
440
+ data: body,
441
+ config: {
442
+ params
443
+ }
444
+ }),
445
+ invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
446
+ })
447
+ })
448
+ });
449
+ const {
450
+ useAutoCloneDocumentMutation,
451
+ useCloneDocumentMutation,
452
+ useCreateDocumentMutation,
453
+ useDeleteDocumentMutation,
454
+ useDeleteManyDocumentsMutation,
455
+ useDiscardDocumentMutation,
456
+ useGetAllDocumentsQuery,
457
+ useLazyGetDocumentQuery,
458
+ useGetDocumentQuery,
459
+ useLazyGetDraftRelationCountQuery,
460
+ useGetManyDraftRelationCountQuery,
461
+ usePublishDocumentMutation,
462
+ usePublishManyDocumentsMutation,
463
+ useUpdateDocumentMutation,
464
+ useUnpublishDocumentMutation,
465
+ useUnpublishManyDocumentsMutation
466
+ } = documentApi;
467
+ const buildValidParams = (query) => {
468
+ if (!query)
469
+ return query;
470
+ const { plugins: _, ...validQueryParams } = {
471
+ ...query,
472
+ ...Object.values(query?.plugins ?? {}).reduce(
473
+ (acc, current) => Object.assign(acc, current),
474
+ {}
475
+ )
476
+ };
477
+ if ("_q" in validQueryParams) {
478
+ validQueryParams._q = encodeURIComponent(validQueryParams._q);
479
+ }
480
+ return validQueryParams;
481
+ };
482
+ const isBaseQueryError = (error) => {
483
+ return error.name !== void 0;
484
+ };
485
+ const arrayValidator = (options) => ({
486
+ message: strapiAdmin.translatedErrors.required,
487
+ test(value) {
488
+ if (options.status === "draft") {
489
+ return true;
490
+ }
491
+ if (!value) {
492
+ return false;
493
+ }
494
+ if (Array.isArray(value) && value.length === 0) {
495
+ return false;
496
+ }
497
+ return true;
498
+ }
499
+ });
500
+ const createYupSchema = (attributes = {}, components = {}, options = { status: null }) => {
501
+ const createModelSchema = (attributes2) => yup__namespace.object().shape(
502
+ Object.entries(attributes2).reduce((acc, [name, attribute]) => {
503
+ if (DOCUMENT_META_FIELDS.includes(name)) {
504
+ return acc;
505
+ }
506
+ const validations = [
507
+ addNullableValidation,
508
+ addRequiredValidation,
509
+ addMinLengthValidation,
510
+ addMaxLengthValidation,
511
+ addMinValidation,
512
+ addMaxValidation,
513
+ addRegexValidation
514
+ ].map((fn) => fn(attribute, options));
515
+ const transformSchema = pipe__default.default(...validations);
516
+ switch (attribute.type) {
517
+ case "component": {
518
+ const { attributes: attributes3 } = components[attribute.component];
519
+ if (attribute.repeatable) {
520
+ return {
521
+ ...acc,
522
+ [name]: transformSchema(
523
+ yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
524
+ ).test(arrayValidator(options))
525
+ };
526
+ } else {
527
+ return {
528
+ ...acc,
529
+ [name]: transformSchema(createModelSchema(attributes3).nullable())
530
+ };
531
+ }
532
+ }
533
+ case "dynamiczone":
534
+ return {
535
+ ...acc,
536
+ [name]: transformSchema(
537
+ yup__namespace.array().of(
538
+ yup__namespace.lazy(
539
+ (data) => {
540
+ const attributes3 = components?.[data?.__component]?.attributes;
541
+ const validation = yup__namespace.object().shape({
542
+ __component: yup__namespace.string().required().oneOf(Object.keys(components))
543
+ }).nullable(false);
544
+ if (!attributes3) {
545
+ return validation;
546
+ }
547
+ return validation.concat(createModelSchema(attributes3));
548
+ }
549
+ )
550
+ )
551
+ ).test(arrayValidator(options))
552
+ };
553
+ case "relation":
554
+ return {
555
+ ...acc,
556
+ [name]: transformSchema(
557
+ yup__namespace.lazy((value) => {
558
+ if (!value) {
559
+ return yup__namespace.mixed().nullable(true);
560
+ } else if (Array.isArray(value)) {
561
+ return yup__namespace.array().of(
562
+ yup__namespace.object().shape({
563
+ id: yup__namespace.number().required()
564
+ })
565
+ );
566
+ } else if (typeof value === "object") {
567
+ return yup__namespace.object();
568
+ } else {
569
+ return yup__namespace.mixed().test(
570
+ "type-error",
571
+ "Relation values must be either null, an array of objects with {id} or an object.",
572
+ () => false
573
+ );
574
+ }
575
+ })
576
+ )
577
+ };
578
+ default:
579
+ return {
580
+ ...acc,
581
+ [name]: transformSchema(createAttributeSchema(attribute))
582
+ };
583
+ }
584
+ }, {})
585
+ ).default(null);
586
+ return createModelSchema(attributes);
587
+ };
588
+ const createAttributeSchema = (attribute) => {
589
+ switch (attribute.type) {
590
+ case "biginteger":
591
+ return yup__namespace.string().matches(/^-?\d*$/);
592
+ case "boolean":
593
+ return yup__namespace.boolean();
594
+ case "blocks":
595
+ return yup__namespace.mixed().test("isBlocks", strapiAdmin.translatedErrors.json, (value) => {
596
+ if (!value || Array.isArray(value)) {
597
+ return true;
598
+ } else {
599
+ return false;
600
+ }
601
+ });
602
+ case "decimal":
603
+ case "float":
604
+ case "integer":
605
+ return yup__namespace.number();
606
+ case "email":
607
+ return yup__namespace.string().email(strapiAdmin.translatedErrors.email);
608
+ case "enumeration":
609
+ return yup__namespace.string().oneOf([...attribute.enum, null]);
610
+ case "json":
611
+ return yup__namespace.mixed().test("isJSON", strapiAdmin.translatedErrors.json, (value) => {
612
+ if (!value || typeof value === "string" && value.length === 0) {
613
+ return true;
614
+ }
615
+ if (typeof value === "object") {
616
+ try {
617
+ JSON.stringify(value);
618
+ return true;
619
+ } catch (err) {
620
+ return false;
621
+ }
622
+ }
623
+ try {
624
+ JSON.parse(value);
625
+ return true;
626
+ } catch (err) {
627
+ return false;
628
+ }
629
+ });
630
+ case "password":
631
+ case "richtext":
632
+ case "string":
633
+ case "text":
634
+ return yup__namespace.string();
635
+ case "uid":
636
+ return yup__namespace.string().matches(/^[A-Za-z0-9-_.~]*$/);
637
+ default:
638
+ return yup__namespace.mixed();
639
+ }
640
+ };
641
+ const nullableSchema = (schema) => {
642
+ return schema?.nullable ? schema.nullable() : (
643
+ // In some cases '.nullable' will not be available on the schema.
644
+ // e.g. when the schema has been built using yup.lazy (e.g. for relations).
645
+ // In these cases we should just return the schema as it is.
646
+ schema
647
+ );
648
+ };
649
+ const addNullableValidation = (attribute) => (schema) => {
650
+ if (attribute.required) {
651
+ return schema;
652
+ }
653
+ return nullableSchema(schema);
654
+ };
655
+ const addRequiredValidation = (attribute, options) => (schema) => {
656
+ if (options.status === "draft" || !attribute.required) {
657
+ return schema;
658
+ }
659
+ if (attribute.required && "required" in schema) {
660
+ return schema.required(strapiAdmin.translatedErrors.required);
661
+ }
662
+ return schema;
663
+ };
664
+ const addMinLengthValidation = (attribute, options) => (schema) => {
665
+ if (options.status === "draft") {
666
+ return schema;
667
+ }
668
+ if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
669
+ return schema.min(attribute.minLength, {
670
+ ...strapiAdmin.translatedErrors.minLength,
671
+ values: {
672
+ min: attribute.minLength
673
+ }
674
+ });
675
+ }
676
+ return schema;
677
+ };
678
+ const addMaxLengthValidation = (attribute) => (schema) => {
679
+ if ("maxLength" in attribute && attribute.maxLength && Number.isInteger(attribute.maxLength) && "max" in schema) {
680
+ return schema.max(attribute.maxLength, {
681
+ ...strapiAdmin.translatedErrors.maxLength,
682
+ values: {
683
+ max: attribute.maxLength
684
+ }
685
+ });
686
+ }
687
+ return schema;
688
+ };
689
+ const addMinValidation = (attribute, options) => (schema) => {
690
+ if (options.status === "draft") {
691
+ return schema;
692
+ }
693
+ if ("min" in attribute && "min" in schema) {
694
+ const min = toInteger(attribute.min);
695
+ if (min) {
696
+ return schema.min(min, {
697
+ ...strapiAdmin.translatedErrors.min,
698
+ values: {
699
+ min
700
+ }
701
+ });
702
+ }
703
+ }
704
+ return schema;
705
+ };
706
+ const addMaxValidation = (attribute) => (schema) => {
707
+ if ("max" in attribute) {
708
+ const max = toInteger(attribute.max);
709
+ if ("max" in schema && max) {
710
+ return schema.max(max, {
711
+ ...strapiAdmin.translatedErrors.max,
712
+ values: {
713
+ max
714
+ }
715
+ });
716
+ }
717
+ }
718
+ return schema;
719
+ };
720
+ const toInteger = (val) => {
721
+ if (typeof val === "number" || val === void 0) {
722
+ return val;
723
+ } else {
724
+ const num = Number(val);
725
+ return isNaN(num) ? void 0 : num;
726
+ }
727
+ };
728
+ const addRegexValidation = (attribute) => (schema) => {
729
+ if ("regex" in attribute && attribute.regex && "matches" in schema) {
730
+ return schema.matches(new RegExp(attribute.regex), {
731
+ message: {
732
+ id: strapiAdmin.translatedErrors.regex.id,
733
+ defaultMessage: "The value does not match the defined pattern."
734
+ },
735
+ excludeEmptyString: !attribute.required
736
+ });
737
+ }
738
+ return schema;
739
+ };
740
+ const initApi = contentManagerApi.injectEndpoints({
741
+ endpoints: (builder) => ({
742
+ getInitialData: builder.query({
743
+ query: () => "/content-manager/init",
744
+ transformResponse: (response) => response.data,
745
+ providesTags: ["InitialData"]
746
+ })
747
+ })
748
+ });
749
+ const { useGetInitialDataQuery } = initApi;
750
+ const useContentTypeSchema = (model) => {
751
+ const { toggleNotification } = strapiAdmin.useNotification();
752
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
753
+ const { data, error, isLoading, isFetching } = useGetInitialDataQuery(void 0);
754
+ const { components, contentType, contentTypes } = React__namespace.useMemo(() => {
755
+ const contentType2 = data?.contentTypes.find((ct) => ct.uid === model);
756
+ const componentsByKey = data?.components.reduce((acc, component) => {
757
+ acc[component.uid] = component;
758
+ return acc;
759
+ }, {});
760
+ const components2 = extractContentTypeComponents(contentType2?.attributes, componentsByKey);
761
+ return {
762
+ components: Object.keys(components2).length === 0 ? void 0 : components2,
763
+ contentType: contentType2,
764
+ contentTypes: data?.contentTypes ?? []
765
+ };
766
+ }, [model, data]);
767
+ React__namespace.useEffect(() => {
768
+ if (error) {
769
+ toggleNotification({
770
+ type: "danger",
771
+ message: formatAPIError(error)
772
+ });
773
+ }
774
+ }, [toggleNotification, error, formatAPIError]);
775
+ return {
776
+ // This must be memoized to avoid inifiinite re-renders where the empty object is different everytime.
777
+ components: React__namespace.useMemo(() => components ?? {}, [components]),
778
+ schema: contentType,
779
+ schemas: contentTypes,
780
+ isLoading: isLoading || isFetching
781
+ };
782
+ };
783
+ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
784
+ const getComponents = (attributes2) => {
785
+ return attributes2.reduce((acc, attribute) => {
786
+ if (attribute.type === "component") {
787
+ const componentAttributes = Object.values(
788
+ allComponents[attribute.component]?.attributes ?? {}
789
+ );
790
+ acc.push(attribute.component, ...getComponents(componentAttributes));
791
+ } else if (attribute.type === "dynamiczone") {
792
+ acc.push(
793
+ ...attribute.components,
794
+ ...attribute.components.flatMap((componentUid) => {
795
+ const componentAttributes = Object.values(
796
+ allComponents[componentUid]?.attributes ?? {}
797
+ );
798
+ return getComponents(componentAttributes);
799
+ })
800
+ );
801
+ }
802
+ return acc;
803
+ }, []);
804
+ };
805
+ const componentUids = getComponents(Object.values(attributes));
806
+ const uniqueComponentUids = [...new Set(componentUids)];
807
+ const componentsByKey = uniqueComponentUids.reduce((acc, uid) => {
808
+ acc[uid] = allComponents[uid];
809
+ return acc;
810
+ }, {});
811
+ return componentsByKey;
812
+ };
813
+ const HOOKS = {
814
+ /**
815
+ * Hook that allows to mutate the displayed headers of the list view table
816
+ * @constant
817
+ * @type {string}
818
+ */
819
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
820
+ /**
821
+ * Hook that allows to mutate the CM's collection types links pre-set filters
822
+ * @constant
823
+ * @type {string}
824
+ */
825
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
826
+ /**
827
+ * Hook that allows to mutate the CM's edit view layout
828
+ * @constant
829
+ * @type {string}
830
+ */
831
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
832
+ /**
833
+ * Hook that allows to mutate the CM's single types links pre-set filters
834
+ * @constant
835
+ * @type {string}
836
+ */
837
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
838
+ };
839
+ const contentTypesApi = contentManagerApi.injectEndpoints({
840
+ endpoints: (builder) => ({
841
+ getContentTypeConfiguration: builder.query({
842
+ query: (uid) => ({
843
+ url: `/content-manager/content-types/${uid}/configuration`,
844
+ method: "GET"
845
+ }),
846
+ transformResponse: (response) => response.data,
847
+ providesTags: (_result, _error, uid) => [
848
+ { type: "ContentTypesConfiguration", id: uid },
849
+ { type: "ContentTypeSettings", id: "LIST" }
850
+ ]
851
+ }),
852
+ getAllContentTypeSettings: builder.query({
853
+ query: () => "/content-manager/content-types-settings",
854
+ transformResponse: (response) => response.data,
855
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
856
+ }),
857
+ updateContentTypeConfiguration: builder.mutation({
858
+ query: ({ uid, ...body }) => ({
859
+ url: `/content-manager/content-types/${uid}/configuration`,
860
+ method: "PUT",
861
+ data: body
862
+ }),
863
+ transformResponse: (response) => response.data,
864
+ invalidatesTags: (_result, _error, { uid }) => [
865
+ { type: "ContentTypesConfiguration", id: uid },
866
+ { type: "ContentTypeSettings", id: "LIST" },
867
+ // Is this necessary?
868
+ { type: "InitialData" }
869
+ ]
870
+ })
871
+ })
872
+ });
873
+ const {
874
+ useGetContentTypeConfigurationQuery,
875
+ useGetAllContentTypeSettingsQuery,
876
+ useUpdateContentTypeConfigurationMutation
877
+ } = contentTypesApi;
878
+ const checkIfAttributeIsDisplayable = (attribute) => {
879
+ const { type } = attribute;
880
+ if (type === "relation") {
881
+ return !attribute.relation.toLowerCase().includes("morph");
882
+ }
883
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
884
+ };
885
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
886
+ if (!mainFieldName) {
887
+ return void 0;
888
+ }
889
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
890
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
891
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
892
+ );
893
+ return {
894
+ name: mainFieldName,
895
+ type: mainFieldType ?? "string"
896
+ };
897
+ };
898
+ const DEFAULT_SETTINGS = {
899
+ bulkable: false,
900
+ filterable: false,
901
+ searchable: false,
902
+ pagination: false,
903
+ defaultSortBy: "",
904
+ defaultSortOrder: "asc",
905
+ mainField: "id",
906
+ pageSize: 10
907
+ };
908
+ const useDocumentLayout = (model) => {
909
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
910
+ const [{ query }] = strapiAdmin.useQueryParams();
911
+ const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
912
+ const { toggleNotification } = strapiAdmin.useNotification();
913
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
914
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
915
+ const {
916
+ data,
917
+ isLoading: isLoadingConfigs,
918
+ error,
919
+ isFetching: isFetchingConfigs
920
+ } = useGetContentTypeConfigurationQuery(model);
921
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
922
+ React__namespace.useEffect(() => {
923
+ if (error) {
924
+ toggleNotification({
925
+ type: "danger",
926
+ message: formatAPIError(error)
927
+ });
928
+ }
929
+ }, [error, formatAPIError, toggleNotification]);
930
+ const editLayout = React__namespace.useMemo(
931
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
932
+ layout: [],
933
+ components: {},
934
+ metadatas: {},
935
+ options: {},
936
+ settings: DEFAULT_SETTINGS
937
+ },
938
+ [data, isLoading, schemas, schema, components]
939
+ );
940
+ const listLayout = React__namespace.useMemo(() => {
941
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
942
+ layout: [],
943
+ metadatas: {},
944
+ options: {},
945
+ settings: DEFAULT_SETTINGS
946
+ };
947
+ }, [data, isLoading, schemas, schema, components]);
948
+ const { layout: edit } = React__namespace.useMemo(
949
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
950
+ layout: editLayout,
951
+ query
952
+ }),
953
+ [editLayout, query, runHookWaterfall]
954
+ );
955
+ return {
956
+ error,
957
+ isLoading,
958
+ edit,
959
+ list: listLayout
960
+ };
961
+ };
962
+ const useDocLayout = () => {
963
+ const { model } = useDoc();
964
+ return useDocumentLayout(model);
965
+ };
966
+ const formatEditLayout = (data, {
967
+ schemas,
968
+ schema,
969
+ components
970
+ }) => {
971
+ let currentPanelIndex = 0;
972
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
973
+ data.contentType.layouts.edit,
974
+ schema?.attributes,
975
+ data.contentType.metadatas,
976
+ { configurations: data.components, schemas: components },
977
+ schemas
978
+ ).reduce((panels, row) => {
979
+ if (row.some((field) => field.type === "dynamiczone")) {
980
+ panels.push([row]);
981
+ currentPanelIndex += 2;
982
+ } else {
983
+ if (!panels[currentPanelIndex]) {
984
+ panels.push([]);
985
+ }
986
+ panels[currentPanelIndex].push(row);
987
+ }
988
+ return panels;
989
+ }, []);
990
+ const componentEditAttributes = Object.entries(data.components).reduce(
991
+ (acc, [uid, configuration]) => {
992
+ acc[uid] = {
993
+ layout: convertEditLayoutToFieldLayouts(
994
+ configuration.layouts.edit,
995
+ components[uid].attributes,
996
+ configuration.metadatas,
997
+ { configurations: data.components, schemas: components }
998
+ ),
999
+ settings: {
1000
+ ...configuration.settings,
1001
+ icon: components[uid].info.icon,
1002
+ displayName: components[uid].info.displayName
1003
+ }
1004
+ };
1005
+ return acc;
1006
+ },
1007
+ {}
1008
+ );
1009
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
1010
+ (acc, [attribute, metadata]) => {
1011
+ return {
1012
+ ...acc,
1013
+ [attribute]: metadata.edit
1014
+ };
1015
+ },
1016
+ {}
1017
+ );
1018
+ return {
1019
+ layout: panelledEditAttributes,
1020
+ components: componentEditAttributes,
1021
+ metadatas: editMetadatas,
1022
+ settings: {
1023
+ ...data.contentType.settings,
1024
+ displayName: schema?.info.displayName
1025
+ },
1026
+ options: {
1027
+ ...schema?.options,
1028
+ ...schema?.pluginOptions,
1029
+ ...data.contentType.options
1030
+ }
1031
+ };
1032
+ };
1033
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
1034
+ return rows.map(
1035
+ (row) => row.map((field) => {
1036
+ const attribute = attributes[field.name];
1037
+ if (!attribute) {
1038
+ return null;
1039
+ }
1040
+ const { edit: metadata } = metadatas[field.name];
1041
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1042
+ return {
1043
+ attribute,
1044
+ disabled: !metadata.editable,
1045
+ hint: metadata.description,
1046
+ label: metadata.label ?? "",
1047
+ name: field.name,
1048
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
1049
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1050
+ schemas,
1051
+ components: components?.schemas ?? {}
1052
+ }),
1053
+ placeholder: metadata.placeholder ?? "",
1054
+ required: attribute.required ?? false,
1055
+ size: field.size,
1056
+ unique: "unique" in attribute ? attribute.unique : false,
1057
+ visible: metadata.visible ?? true,
1058
+ type: attribute.type
1059
+ };
1060
+ }).filter((field) => field !== null)
1061
+ );
1062
+ };
1063
+ const formatListLayout = (data, {
1064
+ schemas,
1065
+ schema,
1066
+ components
1067
+ }) => {
1068
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
1069
+ (acc, [attribute, metadata]) => {
1070
+ return {
1071
+ ...acc,
1072
+ [attribute]: metadata.list
1073
+ };
1074
+ },
1075
+ {}
1076
+ );
1077
+ const listAttributes = convertListLayoutToFieldLayouts(
1078
+ data.contentType.layouts.list,
1079
+ schema?.attributes,
1080
+ listMetadatas,
1081
+ { configurations: data.components, schemas: components },
1082
+ schemas
1083
+ );
1084
+ return {
1085
+ layout: listAttributes,
1086
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
1087
+ metadatas: listMetadatas,
1088
+ options: {
1089
+ ...schema?.options,
1090
+ ...schema?.pluginOptions,
1091
+ ...data.contentType.options
1092
+ }
1093
+ };
1094
+ };
1095
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
1096
+ return columns.map((name) => {
1097
+ const attribute = attributes[name];
1098
+ if (!attribute) {
1099
+ return null;
1100
+ }
1101
+ const metadata = metadatas[name];
1102
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
1103
+ return {
1104
+ attribute,
1105
+ label: metadata.label ?? "",
1106
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
1107
+ schemas,
1108
+ components: components?.schemas ?? {}
1109
+ }),
1110
+ name,
1111
+ searchable: metadata.searchable ?? true,
1112
+ sortable: metadata.sortable ?? true
1113
+ };
1114
+ }).filter((field) => field !== null);
1115
+ };
1116
+ const useDocument = (args, opts) => {
1117
+ const { toggleNotification } = strapiAdmin.useNotification();
1118
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1119
+ const {
1120
+ currentData: data,
1121
+ isLoading: isLoadingDocument,
1122
+ isFetching: isFetchingDocument,
1123
+ error
1124
+ } = useGetDocumentQuery(args, {
1125
+ ...opts,
1126
+ skip: !args.documentId && args.collectionType !== SINGLE_TYPES || opts?.skip
1127
+ });
1128
+ const {
1129
+ components,
1130
+ schema,
1131
+ schemas,
1132
+ isLoading: isLoadingSchema
1133
+ } = useContentTypeSchema(args.model);
1134
+ React__namespace.useEffect(() => {
1135
+ if (error) {
1136
+ toggleNotification({
1137
+ type: "danger",
1138
+ message: formatAPIError(error)
1139
+ });
1140
+ }
1141
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
1142
+ const validationSchema = React__namespace.useMemo(() => {
1143
+ if (!schema) {
1144
+ return null;
1145
+ }
1146
+ return createYupSchema(schema.attributes, components);
1147
+ }, [schema, components]);
1148
+ const validate = React__namespace.useCallback(
1149
+ (document) => {
1150
+ if (!validationSchema) {
1151
+ throw new Error(
1152
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
1153
+ );
1154
+ }
1155
+ try {
1156
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
1157
+ return null;
1158
+ } catch (error2) {
1159
+ if (error2 instanceof yup.ValidationError) {
1160
+ return strapiAdmin.getYupValidationErrors(error2);
1161
+ }
1162
+ throw error2;
1163
+ }
1164
+ },
1165
+ [validationSchema]
1166
+ );
1167
+ const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
1168
+ const hasError = !!error;
1169
+ return {
1170
+ components,
1171
+ document: data?.data,
1172
+ meta: data?.meta,
1173
+ isLoading,
1174
+ hasError,
1175
+ schema,
1176
+ schemas,
1177
+ validate
1178
+ };
1179
+ };
1180
+ const useDoc = () => {
1181
+ const { id, slug, collectionType, origin } = reactRouterDom.useParams();
1182
+ const [{ query }] = strapiAdmin.useQueryParams();
1183
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1184
+ if (!collectionType) {
1185
+ throw new Error("Could not find collectionType in url params");
1186
+ }
1187
+ if (!slug) {
1188
+ throw new Error("Could not find model in url params");
1189
+ }
1190
+ return {
1191
+ collectionType,
1192
+ model: slug,
1193
+ id: origin || id === "create" ? void 0 : id,
1194
+ ...useDocument(
1195
+ { documentId: origin || id, model: slug, collectionType, params },
1196
+ {
1197
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
1198
+ }
1199
+ )
1200
+ };
1201
+ };
1202
+ const useContentManagerContext = () => {
1203
+ const {
1204
+ collectionType,
1205
+ model,
1206
+ id,
1207
+ components,
1208
+ isLoading: isLoadingDoc,
1209
+ schema,
1210
+ schemas
1211
+ } = useDoc();
1212
+ const layout = useDocumentLayout(model);
1213
+ const form = strapiAdmin.useForm("useContentManagerContext", (state) => state);
1214
+ const isSingleType = collectionType === SINGLE_TYPES;
1215
+ const slug = model;
1216
+ const isCreatingEntry = id === "create";
1217
+ useContentTypeSchema();
1218
+ const isLoading = isLoadingDoc || layout.isLoading;
1219
+ const error = layout.error;
1220
+ return {
1221
+ error,
1222
+ isLoading,
1223
+ // Base metadata
1224
+ model,
1225
+ collectionType,
1226
+ id,
1227
+ slug,
1228
+ isCreatingEntry,
1229
+ isSingleType,
1230
+ hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,
1231
+ // All schema infos
1232
+ components,
1233
+ contentType: schema,
1234
+ contentTypes: schemas,
1235
+ // Form state
1236
+ form,
1237
+ // layout infos
1238
+ layout
1239
+ };
1240
+ };
1241
+ const prefixPluginTranslations = (trad, pluginId) => {
1242
+ if (!pluginId) {
1243
+ throw new TypeError("pluginId can't be empty");
1244
+ }
1245
+ return Object.keys(trad).reduce((acc, current) => {
1246
+ acc[`${pluginId}.${current}`] = trad[current];
1247
+ return acc;
1248
+ }, {});
1249
+ };
1250
+ const getTranslation = (id) => `content-manager.${id}`;
1251
+ const DEFAULT_UNEXPECTED_ERROR_MSG = {
1252
+ id: "notification.error",
1253
+ defaultMessage: "An error occurred, please try again"
1254
+ };
1255
+ const useDocumentActions = () => {
1256
+ const { toggleNotification } = strapiAdmin.useNotification();
1257
+ const { formatMessage } = reactIntl.useIntl();
1258
+ const { trackUsage } = strapiAdmin.useTracking();
1259
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
1260
+ const navigate = reactRouterDom.useNavigate();
1261
+ const setCurrentStep = strapiAdmin.useGuidedTour("useDocumentActions", (state) => state.setCurrentStep);
1262
+ const [deleteDocument] = useDeleteDocumentMutation();
1263
+ const _delete = React__namespace.useCallback(
1264
+ async ({ collectionType, model, documentId, params }, trackerProperty) => {
1265
+ try {
1266
+ trackUsage("willDeleteEntry", trackerProperty);
1267
+ const res = await deleteDocument({
1268
+ collectionType,
1269
+ model,
1270
+ documentId,
1271
+ params
1272
+ });
1273
+ if ("error" in res) {
1274
+ toggleNotification({
1275
+ type: "danger",
1276
+ message: formatAPIError(res.error)
1277
+ });
1278
+ return { error: res.error };
1279
+ }
1280
+ toggleNotification({
1281
+ type: "success",
1282
+ message: formatMessage({
1283
+ id: getTranslation("success.record.delete"),
1284
+ defaultMessage: "Deleted document"
1285
+ })
1286
+ });
1287
+ trackUsage("didDeleteEntry", trackerProperty);
1288
+ return res.data;
1289
+ } catch (err) {
1290
+ toggleNotification({
1291
+ type: "danger",
1292
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1293
+ });
1294
+ trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
1295
+ throw err;
1296
+ }
1297
+ },
1298
+ [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
1299
+ );
1300
+ const [deleteManyDocuments] = useDeleteManyDocumentsMutation();
1301
+ const deleteMany = React__namespace.useCallback(
1302
+ async ({ model, documentIds, params }) => {
1303
+ try {
1304
+ trackUsage("willBulkDeleteEntries");
1305
+ const res = await deleteManyDocuments({
1306
+ model,
1307
+ documentIds,
1308
+ params
1309
+ });
1310
+ if ("error" in res) {
1311
+ toggleNotification({
1312
+ type: "danger",
1313
+ message: formatAPIError(res.error)
1314
+ });
1315
+ return { error: res.error };
1316
+ }
1317
+ toggleNotification({
1318
+ type: "success",
1319
+ title: formatMessage({
1320
+ id: getTranslation("success.records.delete"),
1321
+ defaultMessage: "Successfully deleted."
1322
+ }),
1323
+ message: ""
1324
+ });
1325
+ trackUsage("didBulkDeleteEntries");
1326
+ return res.data;
1327
+ } catch (err) {
1328
+ toggleNotification({
1329
+ type: "danger",
1330
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1331
+ });
1332
+ trackUsage("didNotBulkDeleteEntries");
1333
+ throw err;
1334
+ }
1335
+ },
1336
+ [trackUsage, deleteManyDocuments, toggleNotification, formatMessage, formatAPIError]
1337
+ );
1338
+ const [discardDocument] = useDiscardDocumentMutation();
1339
+ const discard = React__namespace.useCallback(
1340
+ async ({ collectionType, model, documentId, params }) => {
1341
+ try {
1342
+ const res = await discardDocument({
1343
+ collectionType,
1344
+ model,
1345
+ documentId,
1346
+ params
1347
+ });
1348
+ if ("error" in res) {
1349
+ toggleNotification({
1350
+ type: "danger",
1351
+ message: formatAPIError(res.error)
1352
+ });
1353
+ return { error: res.error };
1354
+ }
1355
+ toggleNotification({
1356
+ type: "success",
1357
+ message: formatMessage({
1358
+ id: "content-manager.success.record.discard",
1359
+ defaultMessage: "Changes discarded"
1360
+ })
1361
+ });
1362
+ return res.data;
1363
+ } catch (err) {
1364
+ toggleNotification({
1365
+ type: "danger",
1366
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1367
+ });
1368
+ throw err;
1369
+ }
1370
+ },
1371
+ [discardDocument, formatAPIError, formatMessage, toggleNotification]
1372
+ );
1373
+ const [publishDocument] = usePublishDocumentMutation();
1374
+ const publish = React__namespace.useCallback(
1375
+ async ({ collectionType, model, documentId, params }, data) => {
1376
+ try {
1377
+ trackUsage("willPublishEntry");
1378
+ const res = await publishDocument({
1379
+ collectionType,
1380
+ model,
1381
+ documentId,
1382
+ data,
1383
+ params
1384
+ });
1385
+ if ("error" in res) {
1386
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1387
+ return { error: res.error };
1388
+ }
1389
+ trackUsage("didPublishEntry");
1390
+ toggleNotification({
1391
+ type: "success",
1392
+ message: formatMessage({
1393
+ id: getTranslation("success.record.publish"),
1394
+ defaultMessage: "Published document"
1395
+ })
1396
+ });
1397
+ return res.data;
1398
+ } catch (err) {
1399
+ toggleNotification({
1400
+ type: "danger",
1401
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1402
+ });
1403
+ throw err;
1404
+ }
1405
+ },
1406
+ [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
1407
+ );
1408
+ const [publishManyDocuments] = usePublishManyDocumentsMutation();
1409
+ const publishMany = React__namespace.useCallback(
1410
+ async ({ model, documentIds, params }) => {
1411
+ try {
1412
+ const res = await publishManyDocuments({
1413
+ model,
1414
+ documentIds,
1415
+ params
1416
+ });
1417
+ if ("error" in res) {
1418
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1419
+ return { error: res.error };
1420
+ }
1421
+ toggleNotification({
1422
+ type: "success",
1423
+ message: formatMessage({
1424
+ id: getTranslation("success.record.publish"),
1425
+ defaultMessage: "Published document"
1426
+ })
1427
+ });
1428
+ return res.data;
1429
+ } catch (err) {
1430
+ toggleNotification({
1431
+ type: "danger",
1432
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1433
+ });
1434
+ throw err;
1435
+ }
1436
+ },
1437
+ [
1438
+ // trackUsage,
1439
+ publishManyDocuments,
1440
+ toggleNotification,
1441
+ formatMessage,
1442
+ formatAPIError
1443
+ ]
1444
+ );
1445
+ const [updateDocument] = useUpdateDocumentMutation();
1446
+ const update = React__namespace.useCallback(
1447
+ async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1448
+ try {
1449
+ trackUsage("willEditEntry", trackerProperty);
1450
+ const res = await updateDocument({
1451
+ collectionType,
1452
+ model,
1453
+ documentId,
1454
+ data,
1455
+ params
1456
+ });
1457
+ if ("error" in res) {
1458
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1459
+ trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1460
+ return { error: res.error };
1461
+ }
1462
+ trackUsage("didEditEntry", trackerProperty);
1463
+ toggleNotification({
1464
+ type: "success",
1465
+ message: formatMessage({
1466
+ id: getTranslation("success.record.save"),
1467
+ defaultMessage: "Saved document"
1468
+ })
1469
+ });
1470
+ return res.data;
1471
+ } catch (err) {
1472
+ trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1473
+ toggleNotification({
1474
+ type: "danger",
1475
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1476
+ });
1477
+ throw err;
1478
+ }
1479
+ },
1480
+ [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1481
+ );
1482
+ const [unpublishDocument] = useUnpublishDocumentMutation();
1483
+ const unpublish = React__namespace.useCallback(
1484
+ async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1485
+ try {
1486
+ trackUsage("willUnpublishEntry");
1487
+ const res = await unpublishDocument({
1488
+ collectionType,
1489
+ model,
1490
+ documentId,
1491
+ params,
1492
+ data: {
1493
+ discardDraft
1494
+ }
1495
+ });
1496
+ if ("error" in res) {
1497
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1498
+ return { error: res.error };
1499
+ }
1500
+ trackUsage("didUnpublishEntry");
1501
+ toggleNotification({
1502
+ type: "success",
1503
+ message: formatMessage({
1504
+ id: getTranslation("success.record.unpublish"),
1505
+ defaultMessage: "Unpublished document"
1506
+ })
1507
+ });
1508
+ return res.data;
1509
+ } catch (err) {
1510
+ toggleNotification({
1511
+ type: "danger",
1512
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1513
+ });
1514
+ throw err;
1515
+ }
1516
+ },
1517
+ [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1518
+ );
1519
+ const [unpublishManyDocuments] = useUnpublishManyDocumentsMutation();
1520
+ const unpublishMany = React__namespace.useCallback(
1521
+ async ({ model, documentIds, params }) => {
1522
+ try {
1523
+ trackUsage("willBulkUnpublishEntries");
1524
+ const res = await unpublishManyDocuments({
1525
+ model,
1526
+ documentIds,
1527
+ params
1528
+ });
1529
+ if ("error" in res) {
1530
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1531
+ return { error: res.error };
1532
+ }
1533
+ trackUsage("didBulkUnpublishEntries");
1534
+ toggleNotification({
1535
+ type: "success",
1536
+ title: formatMessage({
1537
+ id: getTranslation("success.records.unpublish"),
1538
+ defaultMessage: "Successfully unpublished."
1539
+ }),
1540
+ message: ""
1541
+ });
1542
+ return res.data;
1543
+ } catch (err) {
1544
+ toggleNotification({
1545
+ type: "danger",
1546
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1547
+ });
1548
+ trackUsage("didNotBulkUnpublishEntries");
1549
+ throw err;
1550
+ }
1551
+ },
1552
+ [trackUsage, unpublishManyDocuments, toggleNotification, formatMessage, formatAPIError]
1553
+ );
1554
+ const [createDocument] = useCreateDocumentMutation();
1555
+ const create = React__namespace.useCallback(
1556
+ async ({ model, params }, data, trackerProperty) => {
1557
+ try {
1558
+ const res = await createDocument({
1559
+ model,
1560
+ data,
1561
+ params
1562
+ });
1563
+ if ("error" in res) {
1564
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1565
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1566
+ return { error: res.error };
1567
+ }
1568
+ trackUsage("didCreateEntry", trackerProperty);
1569
+ toggleNotification({
1570
+ type: "success",
1571
+ message: formatMessage({
1572
+ id: getTranslation("success.record.save"),
1573
+ defaultMessage: "Saved document"
1574
+ })
1575
+ });
1576
+ setCurrentStep("contentManager.success");
1577
+ return res.data;
1578
+ } catch (err) {
1579
+ toggleNotification({
1580
+ type: "danger",
1581
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1582
+ });
1583
+ trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1584
+ throw err;
1585
+ }
1586
+ },
1587
+ [createDocument, formatAPIError, formatMessage, toggleNotification, trackUsage]
1588
+ );
1589
+ const [autoCloneDocument] = useAutoCloneDocumentMutation();
1590
+ const autoClone = React__namespace.useCallback(
1591
+ async ({ model, sourceId }) => {
1592
+ try {
1593
+ const res = await autoCloneDocument({
1594
+ model,
1595
+ sourceId
1596
+ });
1597
+ if ("error" in res) {
1598
+ return { error: res.error };
1599
+ }
1600
+ toggleNotification({
1601
+ type: "success",
1602
+ message: formatMessage({
1603
+ id: getTranslation("success.record.clone"),
1604
+ defaultMessage: "Cloned document"
1605
+ })
1606
+ });
1607
+ return res.data;
1608
+ } catch (err) {
1609
+ toggleNotification({
1610
+ type: "danger",
1611
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1612
+ });
1613
+ throw err;
1614
+ }
1615
+ },
1616
+ [autoCloneDocument, formatMessage, toggleNotification]
1617
+ );
1618
+ const [cloneDocument] = useCloneDocumentMutation();
1619
+ const clone = React__namespace.useCallback(
1620
+ async ({ model, documentId, params }, body, trackerProperty) => {
1621
+ try {
1622
+ const { id: _id, ...restBody } = body;
1623
+ const res = await cloneDocument({
1624
+ model,
1625
+ sourceId: documentId,
1626
+ data: restBody,
1627
+ params
1628
+ });
1629
+ if ("error" in res) {
1630
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1631
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1632
+ return { error: res.error };
1633
+ }
1634
+ trackUsage("didCreateEntry", trackerProperty);
1635
+ toggleNotification({
1636
+ type: "success",
1637
+ message: formatMessage({
1638
+ id: getTranslation("success.record.clone"),
1639
+ defaultMessage: "Cloned document"
1640
+ })
1641
+ });
1642
+ navigate(`../../${res.data.data.documentId}`, { relative: "path" });
1643
+ return res.data;
1644
+ } catch (err) {
1645
+ toggleNotification({
1646
+ type: "danger",
1647
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1648
+ });
1649
+ trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1650
+ throw err;
1651
+ }
1652
+ },
1653
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError, navigate]
1654
+ );
1655
+ const [getDoc] = useLazyGetDocumentQuery();
1656
+ const getDocument = React__namespace.useCallback(
1657
+ async (args) => {
1658
+ const { data } = await getDoc(args);
1659
+ return data;
1660
+ },
1661
+ [getDoc]
1662
+ );
1663
+ return {
1664
+ autoClone,
1665
+ clone,
1666
+ create,
1667
+ delete: _delete,
1668
+ deleteMany,
1669
+ discard,
1670
+ getDocument,
1671
+ publish,
1672
+ publishMany,
1673
+ unpublish,
1674
+ unpublishMany,
1675
+ update
1676
+ };
1677
+ };
1678
+ const ProtectedHistoryPage = React.lazy(
1679
+ () => Promise.resolve().then(() => require("./History-CAM3gN3h.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1680
+ );
1681
+ const routes$1 = [
1682
+ {
1683
+ path: ":collectionType/:slug/:id/history",
1684
+ Component: ProtectedHistoryPage
1685
+ },
1686
+ {
1687
+ path: ":collectionType/:slug/history",
1688
+ Component: ProtectedHistoryPage
1689
+ }
1690
+ ];
1691
+ const ProtectedEditViewPage = React.lazy(
1692
+ () => Promise.resolve().then(() => require("./EditViewPage-CcWIJyJa.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1693
+ );
1694
+ const ProtectedListViewPage = React.lazy(
1695
+ () => Promise.resolve().then(() => require("./ListViewPage-DFzs-3jf.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1696
+ );
1697
+ const ProtectedListConfiguration = React.lazy(
1698
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-DMBKzujx.js")).then((mod) => ({
1699
+ default: mod.ProtectedListConfiguration
1700
+ }))
1701
+ );
1702
+ const ProtectedEditConfigurationPage = React.lazy(
1703
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-Sed22MMc.js")).then((mod) => ({
1704
+ default: mod.ProtectedEditConfigurationPage
1705
+ }))
1706
+ );
1707
+ const ProtectedComponentConfigurationPage = React.lazy(
1708
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-BX0PmIl_.js")).then((mod) => ({
1709
+ default: mod.ProtectedComponentConfigurationPage
1710
+ }))
1711
+ );
1712
+ const NoPermissions = React.lazy(
1713
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-DwcEM1UU.js")).then((mod) => ({ default: mod.NoPermissions }))
1714
+ );
1715
+ const NoContentType = React.lazy(
1716
+ () => Promise.resolve().then(() => require("./NoContentTypePage-BNfF_UU1.js")).then((mod) => ({ default: mod.NoContentType }))
1717
+ );
1718
+ const CollectionTypePages = () => {
1719
+ const { collectionType } = reactRouterDom.useParams();
1720
+ if (collectionType !== COLLECTION_TYPES && collectionType !== SINGLE_TYPES) {
1721
+ return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/404" });
1722
+ }
1723
+ return collectionType === COLLECTION_TYPES ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedListViewPage, {}) : /* @__PURE__ */ jsxRuntime.jsx(ProtectedEditViewPage, {});
1724
+ };
1725
+ const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1726
+ const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1727
+ const LIST_RELATIVE_PATH = ":collectionType/:slug";
1728
+ const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1729
+ const routes = [
1730
+ {
1731
+ path: LIST_RELATIVE_PATH,
1732
+ element: /* @__PURE__ */ jsxRuntime.jsx(CollectionTypePages, {})
1733
+ },
1734
+ {
1735
+ path: ":collectionType/:slug/:id",
1736
+ Component: ProtectedEditViewPage
1737
+ },
1738
+ {
1739
+ path: CLONE_RELATIVE_PATH,
1740
+ Component: ProtectedEditViewPage
1741
+ },
1742
+ {
1743
+ path: ":collectionType/:slug/configurations/list",
1744
+ Component: ProtectedListConfiguration
1745
+ },
1746
+ {
1747
+ path: "components/:slug/configurations/edit",
1748
+ Component: ProtectedComponentConfigurationPage
1749
+ },
1750
+ {
1751
+ path: ":collectionType/:slug/configurations/edit",
1752
+ Component: ProtectedEditConfigurationPage
1753
+ },
1754
+ {
1755
+ path: "403",
1756
+ Component: NoPermissions
1757
+ },
1758
+ {
1759
+ path: "no-content-types",
1760
+ Component: NoContentType
1761
+ },
1762
+ ...routes$1
1763
+ ];
1764
+ const DocumentActions = ({ actions: actions2 }) => {
1765
+ const { formatMessage } = reactIntl.useIntl();
1766
+ const [primaryAction, secondaryAction, ...restActions] = actions2.filter((action) => {
1767
+ if (action.position === void 0) {
1768
+ return true;
1769
+ }
1770
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
1771
+ return positions.includes("panel");
1772
+ });
1773
+ if (!primaryAction) {
1774
+ return null;
1775
+ }
1776
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, alignItems: "stretch", width: "100%", children: [
1777
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
1778
+ /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...primaryAction, variant: primaryAction.variant || "default" }),
1779
+ restActions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1780
+ DocumentActionsMenu,
1781
+ {
1782
+ actions: restActions,
1783
+ label: formatMessage({
1784
+ id: "content-manager.containers.edit.panels.default.more-actions",
1785
+ defaultMessage: "More document actions"
1786
+ })
1787
+ }
1788
+ ) : null
1789
+ ] }),
1790
+ secondaryAction ? /* @__PURE__ */ jsxRuntime.jsx(
1791
+ DocumentActionButton,
1792
+ {
1793
+ ...secondaryAction,
1794
+ variant: secondaryAction.variant || "secondary"
1795
+ }
1796
+ ) : null
1797
+ ] });
1798
+ };
1799
+ const DocumentActionButton = (action) => {
1800
+ const [dialogId, setDialogId] = React__namespace.useState(null);
1801
+ const { toggleNotification } = strapiAdmin.useNotification();
1802
+ const handleClick = (action2) => async (e) => {
1803
+ const { onClick = () => false, dialog, id } = action2;
1804
+ const muteDialog = await onClick(e);
1805
+ if (dialog && !muteDialog) {
1806
+ switch (dialog.type) {
1807
+ case "notification":
1808
+ toggleNotification({
1809
+ title: dialog.title,
1810
+ message: dialog.content,
1811
+ type: dialog.status,
1812
+ timeout: dialog.timeout,
1813
+ onClose: dialog.onClose
1814
+ });
1815
+ break;
1816
+ case "dialog":
1817
+ case "modal":
1818
+ e.preventDefault();
1819
+ setDialogId(id);
1820
+ }
1821
+ }
1822
+ };
1823
+ const handleClose = () => {
1824
+ setDialogId(null);
1825
+ };
1826
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1827
+ /* @__PURE__ */ jsxRuntime.jsx(
1828
+ designSystem.Button,
1829
+ {
1830
+ flex: "auto",
1831
+ startIcon: action.icon,
1832
+ disabled: action.disabled,
1833
+ onClick: handleClick(action),
1834
+ justifyContent: "center",
1835
+ variant: action.variant || "default",
1836
+ paddingTop: "7px",
1837
+ paddingBottom: "7px",
1838
+ children: action.label
1839
+ }
1840
+ ),
1841
+ action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
1842
+ DocumentActionConfirmDialog,
1843
+ {
1844
+ ...action.dialog,
1845
+ variant: action.dialog?.variant ?? action.variant,
1846
+ isOpen: dialogId === action.id,
1847
+ onClose: handleClose
1848
+ }
1849
+ ) : null,
1850
+ action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
1851
+ DocumentActionModal,
1852
+ {
1853
+ ...action.dialog,
1854
+ onModalClose: handleClose,
1855
+ isOpen: dialogId === action.id
1856
+ }
1857
+ ) : null
1858
+ ] });
1859
+ };
1860
+ const DocumentActionsMenu = ({
1861
+ actions: actions2,
1862
+ children,
1863
+ label,
1864
+ variant = "tertiary"
1865
+ }) => {
1866
+ const [isOpen, setIsOpen] = React__namespace.useState(false);
1867
+ const [dialogId, setDialogId] = React__namespace.useState(null);
1868
+ const { formatMessage } = reactIntl.useIntl();
1869
+ const { toggleNotification } = strapiAdmin.useNotification();
1870
+ const isDisabled = actions2.every((action) => action.disabled) || actions2.length === 0;
1871
+ const handleClick = (action) => async (e) => {
1872
+ const { onClick = () => false, dialog, id } = action;
1873
+ const muteDialog = await onClick(e);
1874
+ if (dialog && !muteDialog) {
1875
+ switch (dialog.type) {
1876
+ case "notification":
1877
+ toggleNotification({
1878
+ title: dialog.title,
1879
+ message: dialog.content,
1880
+ type: dialog.status,
1881
+ timeout: dialog.timeout,
1882
+ onClose: dialog.onClose
1883
+ });
1884
+ break;
1885
+ case "dialog":
1886
+ case "modal":
1887
+ setDialogId(id);
1888
+ }
1889
+ }
1890
+ };
1891
+ const handleClose = () => {
1892
+ setDialogId(null);
1893
+ setIsOpen(false);
1894
+ };
1895
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
1896
+ /* @__PURE__ */ jsxRuntime.jsxs(
1897
+ designSystem.Menu.Trigger,
1898
+ {
1899
+ disabled: isDisabled,
1900
+ size: "S",
1901
+ endIcon: null,
1902
+ paddingTop: "4px",
1903
+ paddingLeft: "7px",
1904
+ paddingRight: "7px",
1905
+ variant,
1906
+ children: [
1907
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
1908
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: label || formatMessage({
1909
+ id: "content-manager.containers.edit.panels.default.more-actions",
1910
+ defaultMessage: "More document actions"
1911
+ }) })
1912
+ ]
1913
+ }
1914
+ ),
1915
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1916
+ actions2.map((action) => {
1917
+ return /* @__PURE__ */ jsxRuntime.jsx(
1918
+ designSystem.Menu.Item,
1919
+ {
1920
+ disabled: action.disabled,
1921
+ onSelect: handleClick(action),
1922
+ display: "block",
1923
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1924
+ /* @__PURE__ */ jsxRuntime.jsxs(
1925
+ designSystem.Flex,
1926
+ {
1927
+ color: !action.disabled ? convertActionVariantToColor(action.variant) : "inherit",
1928
+ gap: 2,
1929
+ tag: "span",
1930
+ children: [
1931
+ /* @__PURE__ */ jsxRuntime.jsx(
1932
+ designSystem.Flex,
1933
+ {
1934
+ tag: "span",
1935
+ color: !action.disabled ? convertActionVariantToIconColor(action.variant) : "inherit",
1936
+ children: action.icon
1937
+ }
1938
+ ),
1939
+ action.label
1940
+ ]
1941
+ }
1942
+ ),
1943
+ action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1944
+ designSystem.Flex,
1945
+ {
1946
+ alignItems: "center",
1947
+ background: "alternative100",
1948
+ borderStyle: "solid",
1949
+ borderColor: "alternative200",
1950
+ borderWidth: "1px",
1951
+ height: 5,
1952
+ paddingLeft: 2,
1953
+ paddingRight: 2,
1954
+ hasRadius: true,
1955
+ color: "alternative600",
1956
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1957
+ }
1958
+ )
1959
+ ] })
1960
+ },
1961
+ action.id
1962
+ );
1963
+ }),
1964
+ children
1965
+ ] }),
1966
+ actions2.map((action) => {
1967
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
1968
+ action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
1969
+ DocumentActionConfirmDialog,
1970
+ {
1971
+ ...action.dialog,
1972
+ variant: action.variant,
1973
+ isOpen: dialogId === action.id,
1974
+ onClose: handleClose
1975
+ }
1976
+ ) : null,
1977
+ action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
1978
+ DocumentActionModal,
1979
+ {
1980
+ ...action.dialog,
1981
+ onModalClose: handleClose,
1982
+ isOpen: dialogId === action.id
1983
+ }
1984
+ ) : null
1985
+ ] }, action.id);
1986
+ })
1987
+ ] });
1988
+ };
1989
+ const convertActionVariantToColor = (variant = "secondary") => {
1990
+ switch (variant) {
1991
+ case "danger":
1992
+ return "danger600";
1993
+ case "secondary":
1994
+ return void 0;
1995
+ case "success":
1996
+ return "success600";
1997
+ default:
1998
+ return "primary600";
1999
+ }
2000
+ };
2001
+ const convertActionVariantToIconColor = (variant = "secondary") => {
2002
+ switch (variant) {
2003
+ case "danger":
2004
+ return "danger600";
2005
+ case "secondary":
2006
+ return "neutral500";
2007
+ case "success":
2008
+ return "success600";
2009
+ default:
2010
+ return "primary600";
2011
+ }
2012
+ };
2013
+ const DocumentActionConfirmDialog = ({
2014
+ onClose,
2015
+ onCancel,
2016
+ onConfirm,
2017
+ title,
2018
+ content,
2019
+ isOpen,
2020
+ variant = "secondary"
2021
+ }) => {
2022
+ const { formatMessage } = reactIntl.useIntl();
2023
+ const handleClose = async () => {
2024
+ if (onCancel) {
2025
+ await onCancel();
2026
+ }
2027
+ onClose();
2028
+ };
2029
+ const handleConfirm = async () => {
2030
+ if (onConfirm) {
2031
+ await onConfirm();
2032
+ }
2033
+ onClose();
2034
+ };
2035
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2036
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
2037
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: content }),
2038
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
2039
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", fullWidth: true, children: formatMessage({
2040
+ id: "app.components.Button.cancel",
2041
+ defaultMessage: "Cancel"
2042
+ }) }) }),
2043
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, fullWidth: true, children: formatMessage({
2044
+ id: "app.components.Button.confirm",
2045
+ defaultMessage: "Confirm"
2046
+ }) })
2047
+ ] })
2048
+ ] }) });
2049
+ };
2050
+ const DocumentActionModal = ({
2051
+ isOpen,
2052
+ title,
2053
+ onClose,
2054
+ footer: Footer,
2055
+ content: Content,
2056
+ onModalClose
2057
+ }) => {
2058
+ const handleClose = () => {
2059
+ if (onClose) {
2060
+ onClose();
2061
+ }
2062
+ onModalClose();
2063
+ };
2064
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
2065
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: title }) }),
2066
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: Content }),
2067
+ typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
2068
+ ] }) });
2069
+ };
2070
+ const PublishAction$1 = ({
2071
+ activeTab,
2072
+ documentId,
2073
+ model,
2074
+ collectionType,
2075
+ meta,
2076
+ document
2077
+ }) => {
2078
+ const { schema } = useDoc();
2079
+ const navigate = reactRouterDom.useNavigate();
2080
+ const { toggleNotification } = strapiAdmin.useNotification();
2081
+ const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
2082
+ const isListView = reactRouterDom.useMatch(LIST_PATH) !== null;
2083
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2084
+ const { formatMessage } = reactIntl.useIntl();
2085
+ const canPublish = useDocumentRBAC("PublishAction", ({ canPublish: canPublish2 }) => canPublish2);
2086
+ const { publish } = useDocumentActions();
2087
+ const [
2088
+ countDraftRelations,
2089
+ { isLoading: isLoadingDraftRelations, isError: isErrorDraftRelations }
2090
+ ] = useLazyGetDraftRelationCountQuery();
2091
+ const [localCountOfDraftRelations, setLocalCountOfDraftRelations] = React__namespace.useState(0);
2092
+ const [serverCountOfDraftRelations, setServerCountOfDraftRelations] = React__namespace.useState(0);
2093
+ const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
2094
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
2095
+ const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
2096
+ const setSubmitting = strapiAdmin.useForm("PublishAction", ({ setSubmitting: setSubmitting2 }) => setSubmitting2);
2097
+ const isSubmitting = strapiAdmin.useForm("PublishAction", ({ isSubmitting: isSubmitting2 }) => isSubmitting2);
2098
+ const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
2099
+ const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
2100
+ const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
2101
+ React__namespace.useEffect(() => {
2102
+ if (isErrorDraftRelations) {
2103
+ toggleNotification({
2104
+ type: "danger",
2105
+ message: formatMessage({
2106
+ id: getTranslation("error.records.fetch-draft-relatons"),
2107
+ defaultMessage: "An error occurred while fetching draft relations on this document."
2108
+ })
2109
+ });
2110
+ }
2111
+ }, [isErrorDraftRelations, toggleNotification, formatMessage]);
2112
+ React__namespace.useEffect(() => {
2113
+ const localDraftRelations = /* @__PURE__ */ new Set();
2114
+ const extractDraftRelations = (data) => {
2115
+ const relations = data.connect || [];
2116
+ relations.forEach((relation) => {
2117
+ if (relation.status === "draft") {
2118
+ localDraftRelations.add(relation.id);
2119
+ }
2120
+ });
2121
+ };
2122
+ const traverseAndExtract = (data) => {
2123
+ Object.entries(data).forEach(([key, value]) => {
2124
+ if (key === "connect" && Array.isArray(value)) {
2125
+ extractDraftRelations({ connect: value });
2126
+ } else if (typeof value === "object" && value !== null) {
2127
+ traverseAndExtract(value);
2128
+ }
2129
+ });
2130
+ };
2131
+ if (!documentId || modified) {
2132
+ traverseAndExtract(formValues);
2133
+ setLocalCountOfDraftRelations(localDraftRelations.size);
2134
+ }
2135
+ }, [documentId, modified, formValues, setLocalCountOfDraftRelations]);
2136
+ React__namespace.useEffect(() => {
2137
+ if (!document || !document.documentId || isListView) {
2138
+ return;
2139
+ }
2140
+ const fetchDraftRelationsCount = async () => {
2141
+ const { data, error } = await countDraftRelations({
2142
+ collectionType,
2143
+ model,
2144
+ documentId,
2145
+ params
2146
+ });
2147
+ if (error) {
2148
+ throw error;
2149
+ }
2150
+ if (data) {
2151
+ setServerCountOfDraftRelations(data.data);
2152
+ }
2153
+ };
2154
+ fetchDraftRelationsCount();
2155
+ }, [isListView, document, documentId, countDraftRelations, collectionType, model, params]);
2156
+ const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
2157
+ if (!schema?.options?.draftAndPublish) {
2158
+ return null;
2159
+ }
2160
+ const performPublish = async () => {
2161
+ setSubmitting(true);
2162
+ try {
2163
+ const { errors } = await validate(true, {
2164
+ status: "published"
2165
+ });
2166
+ if (errors) {
2167
+ toggleNotification({
2168
+ type: "danger",
2169
+ message: formatMessage({
2170
+ id: "content-manager.validation.error",
2171
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2172
+ })
2173
+ });
2174
+ return;
2175
+ }
2176
+ const res = await publish(
2177
+ {
2178
+ collectionType,
2179
+ model,
2180
+ documentId,
2181
+ params
2182
+ },
2183
+ formValues
2184
+ );
2185
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
2186
+ navigate({
2187
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
2188
+ search: rawQuery
2189
+ });
2190
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2191
+ setErrors(formatValidationErrors(res.error));
2192
+ }
2193
+ } finally {
2194
+ setSubmitting(false);
2195
+ }
2196
+ };
2197
+ const totalDraftRelations = localCountOfDraftRelations + serverCountOfDraftRelations;
2198
+ const enableDraftRelationsCount = false;
2199
+ const hasDraftRelations = enableDraftRelationsCount;
2200
+ return {
2201
+ /**
2202
+ * Disabled when:
2203
+ * - currently if you're cloning a document we don't support publish & clone at the same time.
2204
+ * - the form is submitting
2205
+ * - the active tab is the published tab
2206
+ * - the document is already published & not modified
2207
+ * - the document is being created & not modified
2208
+ * - the user doesn't have the permission to publish
2209
+ */
2210
+ disabled: isCloning || isSubmitting || isLoadingDraftRelations || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish,
2211
+ label: formatMessage({
2212
+ id: "app.utils.publish",
2213
+ defaultMessage: "Publish"
2214
+ }),
2215
+ onClick: async () => {
2216
+ await performPublish();
2217
+ },
2218
+ dialog: hasDraftRelations ? {
2219
+ type: "dialog",
2220
+ variant: "danger",
2221
+ footer: null,
2222
+ title: formatMessage({
2223
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.title`),
2224
+ defaultMessage: "Confirmation"
2225
+ }),
2226
+ content: formatMessage(
2227
+ {
2228
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
2229
+ defaultMessage: "This entry is related to {count, plural, one {# draft entry} other {# draft entries}}. Publishing it could leave broken links in your app."
2230
+ },
2231
+ {
2232
+ count: totalDraftRelations
2233
+ }
2234
+ ),
2235
+ onConfirm: async () => {
2236
+ await performPublish();
2237
+ }
2238
+ } : void 0
2239
+ };
2240
+ };
2241
+ PublishAction$1.type = "publish";
2242
+ const UpdateAction = ({
2243
+ activeTab,
2244
+ documentId,
2245
+ model,
2246
+ collectionType
2247
+ }) => {
2248
+ const navigate = reactRouterDom.useNavigate();
2249
+ const { toggleNotification } = strapiAdmin.useNotification();
2250
+ const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
2251
+ const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
2252
+ const isCloning = cloneMatch !== null;
2253
+ const { formatMessage } = reactIntl.useIntl();
2254
+ const { create, update, clone } = useDocumentActions();
2255
+ const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
2256
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
2257
+ const isSubmitting = strapiAdmin.useForm("UpdateAction", ({ isSubmitting: isSubmitting2 }) => isSubmitting2);
2258
+ const modified = strapiAdmin.useForm("UpdateAction", ({ modified: modified2 }) => modified2);
2259
+ const setSubmitting = strapiAdmin.useForm("UpdateAction", ({ setSubmitting: setSubmitting2 }) => setSubmitting2);
2260
+ const document = strapiAdmin.useForm("UpdateAction", ({ values }) => values);
2261
+ const validate = strapiAdmin.useForm("UpdateAction", (state) => state.validate);
2262
+ const setErrors = strapiAdmin.useForm("UpdateAction", (state) => state.setErrors);
2263
+ const resetForm = strapiAdmin.useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
2264
+ return {
2265
+ /**
2266
+ * Disabled when:
2267
+ * - the form is submitting
2268
+ * - the document is not modified & we're not cloning (you can save a clone entity straight away)
2269
+ * - the active tab is the published tab
2270
+ */
2271
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published",
2272
+ label: formatMessage({
2273
+ id: "content-manager.containers.Edit.save",
2274
+ defaultMessage: "Save"
2275
+ }),
2276
+ onClick: async () => {
2277
+ setSubmitting(true);
2278
+ try {
2279
+ const { errors } = await validate(true, {
2280
+ status: "draft"
2281
+ });
2282
+ if (errors) {
2283
+ toggleNotification({
2284
+ type: "danger",
2285
+ message: formatMessage({
2286
+ id: "content-manager.validation.error",
2287
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
2288
+ })
2289
+ });
2290
+ return;
2291
+ }
2292
+ if (isCloning) {
2293
+ const res = await clone(
2294
+ {
2295
+ model,
2296
+ documentId: cloneMatch.params.origin,
2297
+ params
2298
+ },
2299
+ document
2300
+ );
2301
+ if ("data" in res) {
2302
+ navigate(
2303
+ {
2304
+ pathname: `../${res.data.documentId}`,
2305
+ search: rawQuery
2306
+ },
2307
+ { relative: "path" }
2308
+ );
2309
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2310
+ setErrors(formatValidationErrors(res.error));
2311
+ }
2312
+ } else if (documentId || collectionType === SINGLE_TYPES) {
2313
+ const res = await update(
2314
+ {
2315
+ collectionType,
2316
+ model,
2317
+ documentId,
2318
+ params
2319
+ },
2320
+ document
2321
+ );
2322
+ if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2323
+ setErrors(formatValidationErrors(res.error));
2324
+ } else {
2325
+ resetForm();
2326
+ }
2327
+ } else {
2328
+ const res = await create(
2329
+ {
2330
+ model,
2331
+ params
2332
+ },
2333
+ document
2334
+ );
2335
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
2336
+ navigate(
2337
+ {
2338
+ pathname: `../${res.data.documentId}`,
2339
+ search: rawQuery
2340
+ },
2341
+ { replace: true, relative: "path" }
2342
+ );
2343
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
2344
+ setErrors(formatValidationErrors(res.error));
2345
+ }
2346
+ }
2347
+ } finally {
2348
+ setSubmitting(false);
2349
+ }
2350
+ }
2351
+ };
2352
+ };
2353
+ UpdateAction.type = "update";
2354
+ const UNPUBLISH_DRAFT_OPTIONS = {
2355
+ KEEP: "keep",
2356
+ DISCARD: "discard"
2357
+ };
2358
+ const UnpublishAction$1 = ({
2359
+ activeTab,
2360
+ documentId,
2361
+ model,
2362
+ collectionType,
2363
+ document
2364
+ }) => {
2365
+ const { formatMessage } = reactIntl.useIntl();
2366
+ const { schema } = useDoc();
2367
+ const canPublish = useDocumentRBAC("UnpublishAction", ({ canPublish: canPublish2 }) => canPublish2);
2368
+ const { unpublish } = useDocumentActions();
2369
+ const [{ query }] = strapiAdmin.useQueryParams();
2370
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
2371
+ const { toggleNotification } = strapiAdmin.useNotification();
2372
+ const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
2373
+ const isDocumentModified = document?.status === "modified";
2374
+ const handleChange = (value) => {
2375
+ setShouldKeepDraft(value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
2376
+ };
2377
+ if (!schema?.options?.draftAndPublish) {
2378
+ return null;
2379
+ }
2380
+ return {
2381
+ disabled: !canPublish || activeTab === "published" || document?.status !== "published" && document?.status !== "modified",
2382
+ label: formatMessage({
2383
+ id: "app.utils.unpublish",
2384
+ defaultMessage: "Unpublish"
2385
+ }),
2386
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
2387
+ onClick: async () => {
2388
+ if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
2389
+ if (!documentId) {
2390
+ console.error(
2391
+ "You're trying to unpublish a document without an id, this is likely a bug with Strapi. Please open an issue."
2392
+ );
2393
+ toggleNotification({
2394
+ message: formatMessage({
2395
+ id: "content-manager.actions.unpublish.error",
2396
+ defaultMessage: "An error occurred while trying to unpublish the document."
2397
+ }),
2398
+ type: "danger"
2399
+ });
2400
+ }
2401
+ return;
2402
+ }
2403
+ await unpublish({
2404
+ collectionType,
2405
+ model,
2406
+ documentId,
2407
+ params
2408
+ });
2409
+ },
2410
+ dialog: isDocumentModified ? {
2411
+ type: "dialog",
2412
+ title: formatMessage({
2413
+ id: "app.components.ConfirmDialog.title",
2414
+ defaultMessage: "Confirmation"
2415
+ }),
2416
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "flex-start", direction: "column", gap: 6, children: [
2417
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", direction: "column", gap: 2, children: [
2418
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2419
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2420
+ id: "content-manager.actions.unpublish.dialog.body",
2421
+ defaultMessage: "Are you sure?"
2422
+ }) })
2423
+ ] }),
2424
+ /* @__PURE__ */ jsxRuntime.jsxs(
2425
+ designSystem.Radio.Group,
2426
+ {
2427
+ defaultValue: UNPUBLISH_DRAFT_OPTIONS.KEEP,
2428
+ name: "discard-options",
2429
+ "aria-label": formatMessage({
2430
+ id: "content-manager.actions.unpublish.dialog.radio-label",
2431
+ defaultMessage: "Choose an option to unpublish the document."
2432
+ }),
2433
+ onValueChange: handleChange,
2434
+ children: [
2435
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.KEEP, children: formatMessage({
2436
+ id: "content-manager.actions.unpublish.dialog.option.keep-draft",
2437
+ defaultMessage: "Keep draft"
2438
+ }) }),
2439
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Radio.Item, { checked: !shouldKeepDraft, value: UNPUBLISH_DRAFT_OPTIONS.DISCARD, children: formatMessage({
2440
+ id: "content-manager.actions.unpublish.dialog.option.replace-draft",
2441
+ defaultMessage: "Replace draft"
2442
+ }) })
2443
+ ]
2444
+ }
2445
+ )
2446
+ ] }),
2447
+ onConfirm: async () => {
2448
+ if (!documentId && collectionType !== SINGLE_TYPES) {
2449
+ console.error(
2450
+ "You're trying to unpublish a document without an id, this is likely a bug with Strapi. Please open an issue."
2451
+ );
2452
+ toggleNotification({
2453
+ message: formatMessage({
2454
+ id: "content-manager.actions.unpublish.error",
2455
+ defaultMessage: "An error occurred while trying to unpublish the document."
2456
+ }),
2457
+ type: "danger"
2458
+ });
2459
+ }
2460
+ await unpublish(
2461
+ {
2462
+ collectionType,
2463
+ model,
2464
+ documentId,
2465
+ params
2466
+ },
2467
+ !shouldKeepDraft
2468
+ );
2469
+ }
2470
+ } : void 0,
2471
+ variant: "danger",
2472
+ position: ["panel", "table-row"]
2473
+ };
2474
+ };
2475
+ UnpublishAction$1.type = "unpublish";
2476
+ const DiscardAction = ({
2477
+ activeTab,
2478
+ documentId,
2479
+ model,
2480
+ collectionType,
2481
+ document
2482
+ }) => {
2483
+ const { formatMessage } = reactIntl.useIntl();
2484
+ const { schema } = useDoc();
2485
+ const canUpdate = useDocumentRBAC("DiscardAction", ({ canUpdate: canUpdate2 }) => canUpdate2);
2486
+ const { discard } = useDocumentActions();
2487
+ const [{ query }] = strapiAdmin.useQueryParams();
2488
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
2489
+ if (!schema?.options?.draftAndPublish) {
2490
+ return null;
2491
+ }
2492
+ return {
2493
+ disabled: !canUpdate || activeTab === "published" || document?.status !== "modified",
2494
+ label: formatMessage({
2495
+ id: "content-manager.actions.discard.label",
2496
+ defaultMessage: "Discard changes"
2497
+ }),
2498
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Cross, {}),
2499
+ position: ["panel", "table-row"],
2500
+ variant: "danger",
2501
+ dialog: {
2502
+ type: "dialog",
2503
+ title: formatMessage({
2504
+ id: "app.components.ConfirmDialog.title",
2505
+ defaultMessage: "Confirmation"
2506
+ }),
2507
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2508
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2509
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2510
+ id: "content-manager.actions.discard.dialog.body",
2511
+ defaultMessage: "Are you sure?"
2512
+ }) })
2513
+ ] }),
2514
+ onConfirm: async () => {
2515
+ await discard({
2516
+ collectionType,
2517
+ model,
2518
+ documentId,
2519
+ params
2520
+ });
2521
+ }
2522
+ }
2523
+ };
2524
+ };
2525
+ DiscardAction.type = "discard";
2526
+ const DEFAULT_ACTIONS = [PublishAction$1, UpdateAction, UnpublishAction$1, DiscardAction];
2527
+ const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2528
+ const RelativeTime = React__namespace.forwardRef(
2529
+ ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
2530
+ const { formatRelativeTime, formatDate, formatTime } = reactIntl.useIntl();
2531
+ const interval = dateFns.intervalToDuration({
2532
+ start: timestamp,
2533
+ end: Date.now()
2534
+ // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.
2535
+ });
2536
+ const unit = intervals.find((intervalUnit) => {
2537
+ return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2538
+ });
2539
+ const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
2540
+ const customInterval = customIntervals.find(
2541
+ (custom) => interval[custom.unit] < custom.threshold
2542
+ );
2543
+ const displayText = customInterval ? customInterval.text : formatRelativeTime(relativeTime, unit, { numeric: "auto" });
2544
+ return /* @__PURE__ */ jsxRuntime.jsx(
2545
+ "time",
2546
+ {
2547
+ ref: forwardedRef,
2548
+ dateTime: timestamp.toISOString(),
2549
+ role: "time",
2550
+ title: `${formatDate(timestamp)} ${formatTime(timestamp)}`,
2551
+ ...restProps,
2552
+ children: displayText
2553
+ }
2554
+ );
2555
+ }
2556
+ );
2557
+ const getDisplayName = ({
2558
+ firstname,
2559
+ lastname,
2560
+ username,
2561
+ email
2562
+ } = {}) => {
2563
+ if (username) {
2564
+ return username;
2565
+ }
2566
+ if (firstname) {
2567
+ return `${firstname} ${lastname ?? ""}`.trim();
2568
+ }
2569
+ return email ?? "";
2570
+ };
2571
+ const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2572
+ const DocumentStatus = ({ status = "draft", ...restProps }) => {
2573
+ const statusVariant = status === "draft" ? "secondary" : status === "published" ? "success" : "alternative";
2574
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Status, { ...restProps, showBullet: false, size: "S", variant: statusVariant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "span", variant: "omega", fontWeight: "bold", children: capitalise(status) }) });
2575
+ };
2576
+ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2577
+ const { formatMessage } = reactIntl.useIntl();
2578
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2579
+ const title = isCreating ? formatMessage({
2580
+ id: "content-manager.containers.edit.title.new",
2581
+ defaultMessage: "Create an entry"
2582
+ }) : documentTitle;
2583
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 6, paddingBottom: 4, gap: 2, children: [
2584
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
2585
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", justifyContent: "space-between", gap: "80px", alignItems: "flex-start", children: [
2586
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2587
+ /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
2588
+ ] }),
2589
+ status ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) }) : null
2590
+ ] });
2591
+ };
2592
+ const HeaderToolbar = () => {
2593
+ const { formatMessage } = reactIntl.useIntl();
2594
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2595
+ const [
2596
+ {
2597
+ query: { status = "draft" }
2598
+ }
2599
+ ] = strapiAdmin.useQueryParams();
2600
+ const { model, id, document, meta, collectionType } = useDoc();
2601
+ const plugins = strapiAdmin.useStrapiApp("HeaderToolbar", (state) => state.plugins);
2602
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
2603
+ /* @__PURE__ */ jsxRuntime.jsx(
2604
+ strapiAdmin.DescriptionComponentRenderer,
2605
+ {
2606
+ props: {
2607
+ activeTab: status,
2608
+ model,
2609
+ documentId: id,
2610
+ document: isCloning ? void 0 : document,
2611
+ meta: isCloning ? void 0 : meta,
2612
+ collectionType
2613
+ },
2614
+ descriptions: plugins["content-manager"].apis.getHeaderActions(),
2615
+ children: (actions2) => {
2616
+ if (actions2.length > 0) {
2617
+ return /* @__PURE__ */ jsxRuntime.jsx(HeaderActions, { actions: actions2 });
2618
+ } else {
2619
+ return null;
2620
+ }
2621
+ }
2622
+ }
2623
+ ),
2624
+ /* @__PURE__ */ jsxRuntime.jsx(
2625
+ strapiAdmin.DescriptionComponentRenderer,
2626
+ {
2627
+ props: {
2628
+ activeTab: status,
2629
+ model,
2630
+ documentId: id,
2631
+ document: isCloning ? void 0 : document,
2632
+ meta: isCloning ? void 0 : meta,
2633
+ collectionType
2634
+ },
2635
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
2636
+ children: (actions2) => {
2637
+ const headerActions = actions2.filter((action) => {
2638
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
2639
+ return positions.includes("header");
2640
+ });
2641
+ return /* @__PURE__ */ jsxRuntime.jsx(
2642
+ DocumentActionsMenu,
2643
+ {
2644
+ actions: headerActions,
2645
+ label: formatMessage({
2646
+ id: "content-manager.containers.edit.header.more-actions",
2647
+ defaultMessage: "More actions"
2648
+ }),
2649
+ children: /* @__PURE__ */ jsxRuntime.jsx(Information, { activeTab: status })
2650
+ }
2651
+ );
2652
+ }
2653
+ }
2654
+ )
2655
+ ] });
2656
+ };
2657
+ const Information = ({ activeTab }) => {
2658
+ const { formatMessage } = reactIntl.useIntl();
2659
+ const { document, meta } = useDoc();
2660
+ if (!document || !document.id) {
2661
+ return null;
2662
+ }
2663
+ const createAndUpdateDocument = activeTab === "draft" ? document : meta?.availableStatus.find((status) => status.publishedAt === null);
2664
+ const publishDocument = activeTab === "published" ? document : meta?.availableStatus.find((status) => status.publishedAt !== null);
2665
+ const creator = createAndUpdateDocument?.[CREATED_BY_ATTRIBUTE_NAME] ? getDisplayName(createAndUpdateDocument[CREATED_BY_ATTRIBUTE_NAME]) : null;
2666
+ const updator = createAndUpdateDocument?.[UPDATED_BY_ATTRIBUTE_NAME] ? getDisplayName(createAndUpdateDocument[UPDATED_BY_ATTRIBUTE_NAME]) : null;
2667
+ const information = [
2668
+ {
2669
+ isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2670
+ label: formatMessage({
2671
+ id: "content-manager.containers.edit.information.last-published.label",
2672
+ defaultMessage: "Published"
2673
+ }),
2674
+ value: formatMessage(
2675
+ {
2676
+ id: "content-manager.containers.edit.information.last-published.value",
2677
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2678
+ },
2679
+ {
2680
+ time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
2681
+ isAnonymous: !publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME],
2682
+ author: publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME] ? getDisplayName(publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME]) : null
2683
+ }
2684
+ )
2685
+ },
2686
+ {
2687
+ isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2688
+ label: formatMessage({
2689
+ id: "content-manager.containers.edit.information.last-draft.label",
2690
+ defaultMessage: "Updated"
2691
+ }),
2692
+ value: formatMessage(
2693
+ {
2694
+ id: "content-manager.containers.edit.information.last-draft.value",
2695
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2696
+ },
2697
+ {
2698
+ time: /* @__PURE__ */ jsxRuntime.jsx(
2699
+ RelativeTime,
2700
+ {
2701
+ timestamp: new Date(createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME])
2702
+ }
2703
+ ),
2704
+ isAnonymous: !updator,
2705
+ author: updator
2706
+ }
2707
+ )
2708
+ },
2709
+ {
2710
+ isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2711
+ label: formatMessage({
2712
+ id: "content-manager.containers.edit.information.document.label",
2713
+ defaultMessage: "Created"
2714
+ }),
2715
+ value: formatMessage(
2716
+ {
2717
+ id: "content-manager.containers.edit.information.document.value",
2718
+ defaultMessage: `{time}{isAnonymous, select, true {} other { by {author}}}`
2719
+ },
2720
+ {
2721
+ time: /* @__PURE__ */ jsxRuntime.jsx(
2722
+ RelativeTime,
2723
+ {
2724
+ timestamp: new Date(createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME])
2725
+ }
2726
+ ),
2727
+ isAnonymous: !creator,
2728
+ author: creator
2729
+ }
2730
+ )
2731
+ }
2732
+ ].filter((info) => info.isDisplayed);
2733
+ return /* @__PURE__ */ jsxRuntime.jsx(
2734
+ designSystem.Flex,
2735
+ {
2736
+ borderWidth: "1px 0 0 0",
2737
+ borderStyle: "solid",
2738
+ borderColor: "neutral150",
2739
+ direction: "column",
2740
+ marginTop: 2,
2741
+ tag: "dl",
2742
+ padding: 5,
2743
+ gap: 3,
2744
+ alignItems: "flex-start",
2745
+ marginLeft: "-0.4rem",
2746
+ marginRight: "-0.4rem",
2747
+ width: "calc(100% + 8px)",
2748
+ children: information.map((info) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, direction: "column", alignItems: "flex-start", children: [
2749
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dt", variant: "pi", fontWeight: "bold", children: info.label }),
2750
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dd", variant: "pi", textColor: "neutral600", children: info.value })
2751
+ ] }, info.label))
2752
+ }
2753
+ );
2754
+ };
2755
+ const HeaderActions = ({ actions: actions2 }) => {
2756
+ const [dialogId, setDialogId] = React__namespace.useState(null);
2757
+ const handleClick = (action) => async (e) => {
2758
+ if (!("options" in action)) {
2759
+ const { onClick = () => false, dialog, id } = action;
2760
+ const muteDialog = await onClick(e);
2761
+ if (dialog && !muteDialog) {
2762
+ e.preventDefault();
2763
+ setDialogId(id);
2764
+ }
2765
+ }
2766
+ };
2767
+ const handleClose = () => {
2768
+ setDialogId(null);
2769
+ };
2770
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 1, children: actions2.map((action) => {
2771
+ if (action.options) {
2772
+ return /* @__PURE__ */ jsxRuntime.jsx(
2773
+ designSystem.SingleSelect,
2774
+ {
2775
+ size: "S",
2776
+ onChange: action.onSelect,
2777
+ "aria-label": action.label,
2778
+ ...action,
2779
+ children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2780
+ },
2781
+ action.id
2782
+ );
2783
+ } else {
2784
+ if (action.type === "icon") {
2785
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2786
+ /* @__PURE__ */ jsxRuntime.jsx(
2787
+ designSystem.IconButton,
2788
+ {
2789
+ disabled: action.disabled,
2790
+ label: action.label,
2791
+ size: "S",
2792
+ onClick: handleClick(action),
2793
+ children: action.icon
2794
+ }
2795
+ ),
2796
+ action.dialog ? /* @__PURE__ */ jsxRuntime.jsx(
2797
+ HeaderActionDialog,
2798
+ {
2799
+ ...action.dialog,
2800
+ isOpen: dialogId === action.id,
2801
+ onClose: handleClose
2802
+ }
2803
+ ) : null
2804
+ ] }, action.id);
2805
+ }
2806
+ }
2807
+ }) });
2808
+ };
2809
+ const HeaderActionDialog = ({
2810
+ onClose,
2811
+ onCancel,
2812
+ title,
2813
+ content: Content,
2814
+ isOpen
2815
+ }) => {
2816
+ const handleClose = async () => {
2817
+ if (onCancel) {
2818
+ await onCancel();
2819
+ }
2820
+ onClose();
2821
+ };
2822
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
2823
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: title }),
2824
+ typeof Content === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Content, { onClose: handleClose }) : Content
2825
+ ] }) });
2826
+ };
2827
+ const ConfigureTheViewAction = ({ collectionType, model }) => {
2828
+ const navigate = reactRouterDom.useNavigate();
2829
+ const { formatMessage } = reactIntl.useIntl();
2830
+ return {
2831
+ label: formatMessage({
2832
+ id: "app.links.configure-view",
2833
+ defaultMessage: "Configure the view"
2834
+ }),
2835
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ListPlus, {}),
2836
+ onClick: () => {
2837
+ navigate(`../${collectionType}/${model}/configurations/edit`);
2838
+ },
2839
+ position: "header"
2840
+ };
2841
+ };
2842
+ ConfigureTheViewAction.type = "configure-the-view";
2843
+ const EditTheModelAction = ({ model }) => {
2844
+ const navigate = reactRouterDom.useNavigate();
2845
+ const { formatMessage } = reactIntl.useIntl();
2846
+ return {
2847
+ label: formatMessage({
2848
+ id: "content-manager.link-to-ctb",
2849
+ defaultMessage: "Edit the model"
2850
+ }),
2851
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, {}),
2852
+ onClick: () => {
2853
+ navigate(`/plugins/content-type-builder/content-types/${model}`);
2854
+ },
2855
+ position: "header"
2856
+ };
2857
+ };
2858
+ EditTheModelAction.type = "edit-the-model";
2859
+ const DeleteAction$1 = ({ documentId, model, collectionType, document }) => {
2860
+ const navigate = reactRouterDom.useNavigate();
2861
+ const { formatMessage } = reactIntl.useIntl();
2862
+ const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
2863
+ const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
2864
+ const { delete: deleteAction } = useDocumentActions();
2865
+ const { toggleNotification } = strapiAdmin.useNotification();
2866
+ const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2867
+ const isLocalized = document?.locale != null;
2868
+ return {
2869
+ disabled: !canDelete || !document,
2870
+ label: formatMessage(
2871
+ {
2872
+ id: "content-manager.actions.delete.label",
2873
+ defaultMessage: "Delete entry{isLocalized, select, true { (all locales)} other {}}"
2874
+ },
2875
+ { isLocalized }
2876
+ ),
2877
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2878
+ dialog: {
2879
+ type: "dialog",
2880
+ title: formatMessage({
2881
+ id: "app.components.ConfirmDialog.title",
2882
+ defaultMessage: "Confirmation"
2883
+ }),
2884
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2885
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2886
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2887
+ id: "content-manager.actions.delete.dialog.body",
2888
+ defaultMessage: "Are you sure?"
2889
+ }) })
2890
+ ] }),
2891
+ onConfirm: async () => {
2892
+ if (!listViewPathMatch) {
2893
+ setSubmitting(true);
2894
+ }
2895
+ try {
2896
+ if (!documentId && collectionType !== SINGLE_TYPES) {
2897
+ console.error(
2898
+ "You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
2899
+ );
2900
+ toggleNotification({
2901
+ message: formatMessage({
2902
+ id: "content-manager.actions.delete.error",
2903
+ defaultMessage: "An error occurred while trying to delete the document."
2904
+ }),
2905
+ type: "danger"
2906
+ });
2907
+ return;
2908
+ }
2909
+ const res = await deleteAction({
2910
+ documentId,
2911
+ model,
2912
+ collectionType,
2913
+ params: {
2914
+ locale: "*"
2915
+ }
2916
+ });
2917
+ if (!("error" in res)) {
2918
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2919
+ }
2920
+ } finally {
2921
+ if (!listViewPathMatch) {
2922
+ setSubmitting(false);
2923
+ }
2924
+ }
2925
+ }
2926
+ },
2927
+ variant: "danger",
2928
+ position: ["header", "table-row"]
2929
+ };
2930
+ };
2931
+ DeleteAction$1.type = "delete";
2932
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction$1];
2933
+ const Panels = () => {
2934
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2935
+ const [
2936
+ {
2937
+ query: { status }
2938
+ }
2939
+ ] = strapiAdmin.useQueryParams({
2940
+ status: "draft"
2941
+ });
2942
+ const { model, id, document, meta, collectionType } = useDoc();
2943
+ const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2944
+ const props = {
2945
+ activeTab: status,
2946
+ model,
2947
+ documentId: id,
2948
+ document: isCloning ? void 0 : document,
2949
+ meta: isCloning ? void 0 : meta,
2950
+ collectionType
2951
+ };
2952
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2953
+ strapiAdmin.DescriptionComponentRenderer,
2954
+ {
2955
+ props,
2956
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2957
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2958
+ }
2959
+ ) });
2960
+ };
2961
+ const ActionsPanel = () => {
2962
+ const { formatMessage } = reactIntl.useIntl();
2963
+ return {
2964
+ title: formatMessage({
2965
+ id: "content-manager.containers.edit.panels.default.title",
2966
+ defaultMessage: "Entry"
2967
+ }),
2968
+ content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2969
+ };
2970
+ };
2971
+ ActionsPanel.type = "actions";
2972
+ const ActionsPanelContent = () => {
2973
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2974
+ const [
2975
+ {
2976
+ query: { status = "draft" }
2977
+ }
2978
+ ] = strapiAdmin.useQueryParams();
2979
+ const { model, id, document, meta, collectionType } = useDoc();
2980
+ const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
2981
+ const props = {
2982
+ activeTab: status,
2983
+ model,
2984
+ documentId: id,
2985
+ document: isCloning ? void 0 : document,
2986
+ meta: isCloning ? void 0 : meta,
2987
+ collectionType
2988
+ };
2989
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
2990
+ /* @__PURE__ */ jsxRuntime.jsx(
2991
+ strapiAdmin.DescriptionComponentRenderer,
2992
+ {
2993
+ props,
2994
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
2995
+ children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
2996
+ }
2997
+ ),
2998
+ /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
2999
+ ] });
3000
+ };
3001
+ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
3002
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3003
+ designSystem.Flex,
3004
+ {
3005
+ ref,
3006
+ tag: "aside",
3007
+ "aria-labelledby": "additional-information",
3008
+ background: "neutral0",
3009
+ borderColor: "neutral150",
3010
+ hasRadius: true,
3011
+ paddingBottom: 4,
3012
+ paddingLeft: 4,
3013
+ paddingRight: 4,
3014
+ paddingTop: 4,
3015
+ shadow: "tableShadow",
3016
+ gap: 3,
3017
+ direction: "column",
3018
+ justifyContent: "stretch",
3019
+ alignItems: "flex-start",
3020
+ children: [
3021
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
3022
+ children
3023
+ ]
3024
+ }
3025
+ );
3026
+ });
3027
+ const ConfirmBulkActionDialog = ({
3028
+ onToggleDialog,
3029
+ isOpen = false,
3030
+ dialogBody,
3031
+ endAction
3032
+ }) => {
3033
+ const { formatMessage } = reactIntl.useIntl();
3034
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Root, { open: isOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Content, { children: [
3035
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Header, { children: formatMessage({
3036
+ id: "app.components.ConfirmDialog.title",
3037
+ defaultMessage: "Confirmation"
3038
+ }) }),
3039
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3040
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3041
+ dialogBody
3042
+ ] }) }),
3043
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog.Footer, { children: [
3044
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Dialog.Cancel, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { fullWidth: true, onClick: onToggleDialog, variant: "tertiary", children: formatMessage({
3045
+ id: "app.components.Button.cancel",
3046
+ defaultMessage: "Cancel"
3047
+ }) }) }),
3048
+ endAction
3049
+ ] })
3050
+ ] }) });
3051
+ };
3052
+ const BoldChunk$1 = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
3053
+ const ConfirmDialogPublishAll = ({
3054
+ isOpen,
3055
+ onToggleDialog,
3056
+ isConfirmButtonLoading = false,
3057
+ onConfirm
3058
+ }) => {
3059
+ const { formatMessage } = reactIntl.useIntl();
3060
+ const selectedEntries = strapiAdmin.useTable("ConfirmDialogPublishAll", (state) => state.selectedRows);
3061
+ const { toggleNotification } = strapiAdmin.useNotification();
3062
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler(getTranslation);
3063
+ const { model, schema } = useDoc();
3064
+ const [{ query }] = strapiAdmin.useQueryParams();
3065
+ const enableDraftRelationsCount = false;
3066
+ const {
3067
+ data: countDraftRelations = 0,
3068
+ isLoading,
3069
+ error
3070
+ } = useGetManyDraftRelationCountQuery(
3071
+ {
3072
+ model,
3073
+ documentIds: selectedEntries.map((entry) => entry.documentId),
3074
+ locale: query?.plugins?.i18n?.locale
3075
+ },
3076
+ {
3077
+ skip: !enableDraftRelationsCount
3078
+ }
3079
+ );
3080
+ React__namespace.useEffect(() => {
3081
+ if (error) {
3082
+ toggleNotification({ type: "danger", message: formatAPIError(error) });
3083
+ }
3084
+ }, [error, formatAPIError, toggleNotification]);
3085
+ if (error) {
3086
+ return null;
3087
+ }
3088
+ return /* @__PURE__ */ jsxRuntime.jsx(
3089
+ ConfirmBulkActionDialog,
3090
+ {
3091
+ isOpen: isOpen && !isLoading,
3092
+ onToggleDialog,
3093
+ dialogBody: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3094
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: [
3095
+ countDraftRelations > 0 && formatMessage(
3096
+ {
3097
+ id: getTranslation(`popUpwarning.warning.bulk-has-draft-relations.message`),
3098
+ defaultMessage: "<b>{count} {count, plural, one { relation } other { relations } } out of {entities} { entities, plural, one { entry } other { entries } } {count, plural, one { is } other { are } }</b> not published yet and might lead to unexpected behavior. "
3099
+ },
3100
+ {
3101
+ b: BoldChunk$1,
3102
+ count: countDraftRelations,
3103
+ entities: selectedEntries.length
3104
+ }
3105
+ ),
3106
+ formatMessage({
3107
+ id: getTranslation("popUpWarning.bodyMessage.contentType.publish.all"),
3108
+ defaultMessage: "Are you sure you want to publish these entries?"
3109
+ })
3110
+ ] }),
3111
+ schema?.pluginOptions && "i18n" in schema.pluginOptions && schema?.pluginOptions.i18n && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", textAlign: "center", children: formatMessage(
3112
+ {
3113
+ id: getTranslation("Settings.list.actions.publishAdditionalInfos"),
3114
+ defaultMessage: "This will publish the active locale versions <em>(from Internationalization)</em>"
3115
+ },
3116
+ {
3117
+ em: Emphasis
3118
+ }
3119
+ ) })
3120
+ ] }),
3121
+ endAction: /* @__PURE__ */ jsxRuntime.jsx(
3122
+ designSystem.Button,
3123
+ {
3124
+ onClick: onConfirm,
3125
+ variant: "secondary",
3126
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Check, {}),
3127
+ loading: isConfirmButtonLoading,
3128
+ children: formatMessage({
3129
+ id: "app.utils.publish",
3130
+ defaultMessage: "Publish"
3131
+ })
3132
+ }
3133
+ )
3134
+ }
3135
+ );
3136
+ };
3137
+ const TypographyMaxWidth = styledComponents.styled(designSystem.Typography)`
3138
+ max-width: 300px;
3139
+ `;
3140
+ const formatErrorMessages = (errors, parentKey, formatMessage) => {
3141
+ const messages = [];
3142
+ Object.entries(errors).forEach(([key, value]) => {
3143
+ const currentKey = parentKey ? `${parentKey}.${key}` : key;
3144
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
3145
+ if ("id" in value && "defaultMessage" in value) {
3146
+ messages.push(
3147
+ formatMessage(
3148
+ {
3149
+ id: `${value.id}.withField`,
3150
+ defaultMessage: value.defaultMessage
3151
+ },
3152
+ { field: currentKey }
3153
+ )
3154
+ );
3155
+ } else {
3156
+ messages.push(
3157
+ ...formatErrorMessages(
3158
+ // @ts-expect-error TODO: check why value is not compatible with FormErrors
3159
+ value,
3160
+ currentKey,
3161
+ formatMessage
3162
+ )
3163
+ );
3164
+ }
3165
+ } else {
3166
+ messages.push(
3167
+ formatMessage(
3168
+ {
3169
+ id: `${value}.withField`,
3170
+ defaultMessage: value
3171
+ },
3172
+ { field: currentKey }
3173
+ )
3174
+ );
3175
+ }
3176
+ });
3177
+ return messages;
3178
+ };
3179
+ const EntryValidationText = ({ validationErrors, status }) => {
3180
+ const { formatMessage } = reactIntl.useIntl();
3181
+ if (validationErrors) {
3182
+ const validationErrorsMessages = formatErrorMessages(validationErrors, "", formatMessage).join(
3183
+ " "
3184
+ );
3185
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
3186
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.CrossCircle, { fill: "danger600" }),
3187
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tooltip, { description: validationErrorsMessages, children: /* @__PURE__ */ jsxRuntime.jsx(TypographyMaxWidth, { textColor: "danger600", variant: "omega", fontWeight: "semiBold", ellipsis: true, children: validationErrorsMessages }) })
3188
+ ] });
3189
+ }
3190
+ if (status === "published") {
3191
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
3192
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
3193
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "success600", fontWeight: "bold", children: formatMessage({
3194
+ id: "content-manager.bulk-publish.already-published",
3195
+ defaultMessage: "Already Published"
3196
+ }) })
3197
+ ] });
3198
+ }
3199
+ if (status === "modified") {
3200
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
3201
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowsCounterClockwise, { fill: "alternative600" }),
3202
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
3203
+ id: "content-manager.bulk-publish.modified",
3204
+ defaultMessage: "Ready to publish changes"
3205
+ }) })
3206
+ ] });
3207
+ }
3208
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
3209
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, { fill: "success600" }),
3210
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
3211
+ id: "app.utils.ready-to-publish",
3212
+ defaultMessage: "Ready to publish"
3213
+ }) })
3214
+ ] });
3215
+ };
3216
+ const TABLE_HEADERS = [
3217
+ { name: "id", label: "id" },
3218
+ { name: "name", label: "name" },
3219
+ { name: "status", label: "status" },
3220
+ { name: "publicationStatus", label: "Publication status" }
3221
+ ];
3222
+ const SelectedEntriesTableContent = ({
3223
+ isPublishing,
3224
+ rowsToDisplay = [],
3225
+ entriesToPublish = [],
3226
+ validationErrors = {}
3227
+ }) => {
3228
+ const { pathname } = reactRouterDom.useLocation();
3229
+ const { formatMessage } = reactIntl.useIntl();
3230
+ const {
3231
+ list: {
3232
+ settings: { mainField }
3233
+ }
3234
+ } = useDocLayout();
3235
+ const shouldDisplayMainField = mainField != null && mainField !== "id";
3236
+ return /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Content, { children: [
3237
+ /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Head, { children: [
3238
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCheckboxCell, {}),
3239
+ TABLE_HEADERS.filter((head) => head.name !== "name" || shouldDisplayMainField).map(
3240
+ (head) => /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.HeaderCell, { ...head }, head.name)
3241
+ )
3242
+ ] }),
3243
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Loading, {}),
3244
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Body, { children: rowsToDisplay.map((row, index2) => /* @__PURE__ */ jsxRuntime.jsxs(strapiAdmin.Table.Row, { children: [
3245
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.CheckboxCell, { id: row.id }),
3246
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: row.id }) }),
3247
+ shouldDisplayMainField && /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: row[mainField] }) }),
3248
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: row.status, maxWidth: "min-content" }) }),
3249
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: isPublishing && entriesToPublish.includes(row.documentId) ? /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
3250
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
3251
+ id: "content-manager.success.record.publishing",
3252
+ defaultMessage: "Publishing..."
3253
+ }) }),
3254
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true })
3255
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx(
3256
+ EntryValidationText,
3257
+ {
3258
+ validationErrors: validationErrors[row.documentId],
3259
+ status: row.status
3260
+ }
3261
+ ) }),
3262
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Cell, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
3263
+ designSystem.IconButton,
3264
+ {
3265
+ tag: reactRouterDom.Link,
3266
+ to: {
3267
+ pathname: `${pathname}/${row.documentId}`,
3268
+ search: row.locale && `?plugins[i18n][locale]=${row.locale}`
3269
+ },
3270
+ state: { from: pathname },
3271
+ label: formatMessage(
3272
+ { id: "app.component.HelperPluginTable.edit", defaultMessage: "Edit {target}" },
3273
+ {
3274
+ target: formatMessage(
3275
+ {
3276
+ id: "content-manager.components.ListViewHelperPluginTable.row-line",
3277
+ defaultMessage: "item line {number}"
3278
+ },
3279
+ { number: index2 + 1 }
3280
+ )
3281
+ }
3282
+ ),
3283
+ target: "_blank",
3284
+ marginLeft: "auto",
3285
+ variant: "ghost",
3286
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Pencil, { width: "1.6rem", height: "1.6rem" })
3287
+ }
3288
+ ) }) })
3289
+ ] }, row.id)) })
3290
+ ] });
3291
+ };
3292
+ const BoldChunk = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: chunks });
3293
+ const SelectedEntriesModalContent = ({
3294
+ listViewSelectedEntries,
3295
+ toggleModal,
3296
+ setListViewSelectedDocuments,
3297
+ model
3298
+ }) => {
3299
+ const { formatMessage } = reactIntl.useIntl();
3300
+ const { schema, components } = useContentTypeSchema(model);
3301
+ const documentIds = listViewSelectedEntries.map(({ documentId }) => documentId);
3302
+ const [{ query }] = strapiAdmin.useQueryParams();
3303
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
3304
+ const { data, isLoading, isFetching, refetch } = useGetAllDocumentsQuery(
3305
+ {
3306
+ model,
3307
+ params: {
3308
+ page: "1",
3309
+ pageSize: documentIds.length.toString(),
3310
+ sort: query.sort,
3311
+ filters: {
3312
+ documentId: {
3313
+ $in: documentIds
3314
+ }
3315
+ },
3316
+ locale: query.plugins?.i18n?.locale
3317
+ }
3318
+ },
3319
+ {
3320
+ selectFromResult: ({ data: data2, ...restRes }) => ({ data: data2?.results ?? [], ...restRes })
3321
+ }
3322
+ );
3323
+ const { rows, validationErrors } = React__namespace.useMemo(() => {
3324
+ if (data.length > 0 && schema) {
3325
+ const validate = createYupSchema(
3326
+ schema.attributes,
3327
+ components,
3328
+ // Since this is the "Publish" action, the validation
3329
+ // schema must enforce the rules for published entities
3330
+ { status: "published" }
3331
+ );
3332
+ const validationErrors2 = {};
3333
+ const rows2 = data.map((entry) => {
3334
+ try {
3335
+ validate.validateSync(entry, { abortEarly: false });
3336
+ return entry;
3337
+ } catch (e) {
3338
+ if (e instanceof yup.ValidationError) {
3339
+ validationErrors2[entry.documentId] = strapiAdmin.getYupValidationErrors(e);
3340
+ }
3341
+ return entry;
3342
+ }
3343
+ });
3344
+ return { rows: rows2, validationErrors: validationErrors2 };
3345
+ }
3346
+ return {
3347
+ rows: [],
3348
+ validationErrors: {}
3349
+ };
3350
+ }, [components, data, schema]);
3351
+ const [publishedCount, setPublishedCount] = React__namespace.useState(0);
3352
+ const [isDialogOpen, setIsDialogOpen] = React__namespace.useState(false);
3353
+ const { publishMany: bulkPublishAction } = useDocumentActions();
3354
+ const [, { isLoading: isSubmittingForm }] = usePublishManyDocumentsMutation();
3355
+ const selectedRows = strapiAdmin.useTable("publishAction", (state) => state.selectedRows);
3356
+ const selectedEntries = rows.filter(
3357
+ (entry) => selectedRows.some((selectedEntry) => selectedEntry.documentId === entry.documentId)
3358
+ );
3359
+ const entriesToPublish = selectedEntries.filter((entry) => !validationErrors[entry.documentId]).map((entry) => entry.documentId);
3360
+ const selectedEntriesWithErrorsCount = selectedEntries.filter(
3361
+ ({ documentId }) => validationErrors[documentId]
3362
+ ).length;
3363
+ const selectedEntriesPublished = selectedEntries.filter(
3364
+ ({ status }) => status === "published"
3365
+ ).length;
3366
+ const selectedEntriesWithNoErrorsCount = selectedEntries.length - selectedEntriesWithErrorsCount - selectedEntriesPublished;
3367
+ const toggleDialog = () => setIsDialogOpen((prev) => !prev);
3368
+ const handleConfirmBulkPublish = async () => {
3369
+ toggleDialog();
3370
+ const res = await bulkPublishAction({ model, documentIds: entriesToPublish, params });
3371
+ if (!("error" in res)) {
3372
+ setPublishedCount(res.count);
3373
+ const unpublishedEntries = rows.filter((row) => {
3374
+ return !entriesToPublish.includes(row.documentId);
3375
+ });
3376
+ setListViewSelectedDocuments(unpublishedEntries);
3377
+ }
3378
+ };
3379
+ const getFormattedCountMessage = () => {
3380
+ if (publishedCount) {
3381
+ return formatMessage(
3382
+ {
3383
+ id: getTranslation("containers.list.selectedEntriesModal.publishedCount"),
3384
+ defaultMessage: "<b>{publishedCount}</b> {publishedCount, plural, =0 {entries} one {entry} other {entries}} published. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
3385
+ },
3386
+ {
3387
+ publishedCount,
3388
+ withErrorsCount: selectedEntriesWithErrorsCount,
3389
+ b: BoldChunk
3390
+ }
3391
+ );
3392
+ }
3393
+ return formatMessage(
3394
+ {
3395
+ id: getTranslation("containers.list.selectedEntriesModal.selectedCount"),
3396
+ defaultMessage: "<b>{alreadyPublishedCount}</b> {alreadyPublishedCount, plural, =0 {entries} one {entry} other {entries}} already published. <b>{readyToPublishCount}</b> {readyToPublishCount, plural, =0 {entries} one {entry} other {entries}} ready to publish. <b>{withErrorsCount}</b> {withErrorsCount, plural, =0 {entries} one {entry} other {entries}} waiting for action."
3397
+ },
3398
+ {
3399
+ readyToPublishCount: selectedEntriesWithNoErrorsCount,
3400
+ withErrorsCount: selectedEntriesWithErrorsCount,
3401
+ alreadyPublishedCount: selectedEntriesPublished,
3402
+ b: BoldChunk
3403
+ }
3404
+ );
3405
+ };
3406
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3407
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Body, { children: [
3408
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: getFormattedCountMessage() }),
3409
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 5, children: /* @__PURE__ */ jsxRuntime.jsx(
3410
+ SelectedEntriesTableContent,
3411
+ {
3412
+ isPublishing: isSubmittingForm,
3413
+ rowsToDisplay: rows,
3414
+ entriesToPublish,
3415
+ validationErrors
3416
+ }
3417
+ ) })
3418
+ ] }),
3419
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
3420
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: toggleModal, variant: "tertiary", children: formatMessage({
3421
+ id: "app.components.Button.cancel",
3422
+ defaultMessage: "Cancel"
3423
+ }) }),
3424
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
3425
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: refetch, variant: "tertiary", loading: isFetching, children: formatMessage({ id: "app.utils.refresh", defaultMessage: "Refresh" }) }),
3426
+ /* @__PURE__ */ jsxRuntime.jsx(
3427
+ designSystem.Button,
3428
+ {
3429
+ onClick: toggleDialog,
3430
+ disabled: selectedEntries.length === 0 || selectedEntries.length === selectedEntriesWithErrorsCount || selectedEntriesPublished === selectedEntries.length || isLoading,
3431
+ loading: isSubmittingForm,
3432
+ children: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" })
3433
+ }
3434
+ )
3435
+ ] })
3436
+ ] }),
3437
+ /* @__PURE__ */ jsxRuntime.jsx(
3438
+ ConfirmDialogPublishAll,
3439
+ {
3440
+ isOpen: isDialogOpen,
3441
+ onToggleDialog: toggleDialog,
3442
+ isConfirmButtonLoading: isSubmittingForm,
3443
+ onConfirm: handleConfirmBulkPublish
3444
+ }
3445
+ )
3446
+ ] });
3447
+ };
3448
+ const PublishAction = ({ documents, model }) => {
3449
+ const { formatMessage } = reactIntl.useIntl();
3450
+ const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
3451
+ const showPublishButton = hasPublishPermission && documents.some(({ status }) => status !== "published");
3452
+ const setListViewSelectedDocuments = strapiAdmin.useTable("publishAction", (state) => state.selectRow);
3453
+ const refetchList = () => {
3454
+ contentManagerApi.util.invalidateTags([{ type: "Document", id: `${model}_LIST` }]);
3455
+ };
3456
+ if (!showPublishButton)
3457
+ return null;
3458
+ return {
3459
+ actionType: "publish",
3460
+ variant: "tertiary",
3461
+ label: formatMessage({ id: "app.utils.publish", defaultMessage: "Publish" }),
3462
+ dialog: {
3463
+ type: "modal",
3464
+ title: formatMessage({
3465
+ id: getTranslation("containers.ListPage.selectedEntriesModal.title"),
3466
+ defaultMessage: "Publish entries"
3467
+ }),
3468
+ content: ({ onClose }) => {
3469
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Table.Root, { rows: documents, defaultSelectedRows: documents, headers: TABLE_HEADERS, children: /* @__PURE__ */ jsxRuntime.jsx(
3470
+ SelectedEntriesModalContent,
3471
+ {
3472
+ listViewSelectedEntries: documents,
3473
+ toggleModal: () => {
3474
+ onClose();
3475
+ refetchList();
3476
+ },
3477
+ setListViewSelectedDocuments,
3478
+ model
3479
+ }
3480
+ ) });
3481
+ },
3482
+ onClose: () => {
3483
+ refetchList();
3484
+ }
3485
+ }
3486
+ };
3487
+ };
3488
+ const BulkActionsRenderer = () => {
3489
+ const plugins = strapiAdmin.useStrapiApp("BulkActionsRenderer", (state) => state.plugins);
3490
+ const { model, collectionType } = useDoc();
3491
+ const { selectedRows } = strapiAdmin.useTable("BulkActionsRenderer", (state) => state);
3492
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
3493
+ strapiAdmin.DescriptionComponentRenderer,
3494
+ {
3495
+ props: {
3496
+ model,
3497
+ collectionType,
3498
+ documents: selectedRows
3499
+ },
3500
+ descriptions: plugins["content-manager"].apis.getBulkActions(),
3501
+ children: (actions2) => actions2.map((action) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...action }, action.id))
3502
+ }
3503
+ ) });
3504
+ };
3505
+ const DeleteAction = ({ documents, model }) => {
3506
+ const { formatMessage } = reactIntl.useIntl();
3507
+ const { schema: contentType } = useDoc();
3508
+ const selectRow = strapiAdmin.useTable("DeleteAction", (state) => state.selectRow);
3509
+ const hasI18nEnabled = Boolean(contentType?.pluginOptions?.i18n);
3510
+ const [{ query }] = strapiAdmin.useQueryParams();
3511
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
3512
+ const hasDeletePermission = useDocumentRBAC("deleteAction", (state) => state.canDelete);
3513
+ const { deleteMany: bulkDeleteAction } = useDocumentActions();
3514
+ const documentIds = documents.map(({ documentId }) => documentId);
3515
+ const handleConfirmBulkDelete = async () => {
3516
+ const res = await bulkDeleteAction({
3517
+ documentIds,
3518
+ model,
3519
+ params
3520
+ });
3521
+ if (!("error" in res)) {
3522
+ selectRow([]);
3523
+ }
3524
+ };
3525
+ if (!hasDeletePermission)
3526
+ return null;
3527
+ return {
3528
+ variant: "danger-light",
3529
+ label: formatMessage({ id: "global.delete", defaultMessage: "Delete" }),
3530
+ dialog: {
3531
+ type: "dialog",
3532
+ title: formatMessage({
3533
+ id: "app.components.ConfirmDialog.title",
3534
+ defaultMessage: "Confirmation"
3535
+ }),
3536
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3537
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3538
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3539
+ id: "popUpWarning.bodyMessage.contentType.delete.all",
3540
+ defaultMessage: "Are you sure you want to delete these entries?"
3541
+ }) }),
3542
+ hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
3543
+ {
3544
+ id: getTranslation("Settings.list.actions.deleteAdditionalInfos"),
3545
+ defaultMessage: "This will delete the active locale versions <em>(from Internationalization)</em>"
3546
+ },
3547
+ {
3548
+ em: Emphasis
3549
+ }
3550
+ ) }) })
3551
+ ] }),
3552
+ onConfirm: handleConfirmBulkDelete
3553
+ }
3554
+ };
3555
+ };
3556
+ DeleteAction.type = "delete";
3557
+ const UnpublishAction = ({ documents, model }) => {
3558
+ const { formatMessage } = reactIntl.useIntl();
3559
+ const { schema } = useDoc();
3560
+ const selectRow = strapiAdmin.useTable("UnpublishAction", (state) => state.selectRow);
3561
+ const hasPublishPermission = useDocumentRBAC("unpublishAction", (state) => state.canPublish);
3562
+ const hasI18nEnabled = Boolean(schema?.pluginOptions?.i18n);
3563
+ const hasDraftAndPublishEnabled = Boolean(schema?.options?.draftAndPublish);
3564
+ const { unpublishMany: bulkUnpublishAction } = useDocumentActions();
3565
+ const documentIds = documents.map(({ documentId }) => documentId);
3566
+ const [{ query }] = strapiAdmin.useQueryParams();
3567
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
3568
+ const handleConfirmBulkUnpublish = async () => {
3569
+ const data = await bulkUnpublishAction({ documentIds, model, params });
3570
+ if (!("error" in data)) {
3571
+ selectRow([]);
3572
+ }
3573
+ };
3574
+ const showUnpublishButton = hasDraftAndPublishEnabled && hasPublishPermission && documents.some((entry) => entry.status === "published" || entry.status === "modified");
3575
+ if (!showUnpublishButton)
3576
+ return null;
3577
+ return {
3578
+ variant: "tertiary",
3579
+ label: formatMessage({ id: "app.utils.unpublish", defaultMessage: "Unpublish" }),
3580
+ dialog: {
3581
+ type: "dialog",
3582
+ title: formatMessage({
3583
+ id: "app.components.ConfirmDialog.title",
3584
+ defaultMessage: "Confirmation"
3585
+ }),
3586
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
3587
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }) }),
3588
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { id: "confirm-description", textAlign: "center", children: formatMessage({
3589
+ id: "popUpWarning.bodyMessage.contentType.unpublish.all",
3590
+ defaultMessage: "Are you sure you want to unpublish these entries?"
3591
+ }) }),
3592
+ hasI18nEnabled && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { textAlign: "center", padding: 3, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger500", children: formatMessage(
3593
+ {
3594
+ id: getTranslation("Settings.list.actions.unpublishAdditionalInfos"),
3595
+ defaultMessage: "This will unpublish the active locale versions <em>(from Internationalization)</em>"
3596
+ },
3597
+ {
3598
+ em: Emphasis
3599
+ }
3600
+ ) }) })
3601
+ ] }),
3602
+ confirmButton: formatMessage({
3603
+ id: "app.utils.unpublish",
3604
+ defaultMessage: "Unpublish"
3605
+ }),
3606
+ onConfirm: handleConfirmBulkUnpublish
3607
+ }
3608
+ };
3609
+ };
3610
+ UnpublishAction.type = "unpublish";
3611
+ const Emphasis = (chunks) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "semiBold", textColor: "danger500", children: chunks });
3612
+ const DEFAULT_BULK_ACTIONS = [PublishAction, UnpublishAction, DeleteAction];
3613
+ const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
3614
+ const { formatMessage } = reactIntl.useIntl();
3615
+ const getDefaultErrorMessage = (reason) => {
3616
+ switch (reason) {
3617
+ case "relation":
3618
+ return "Duplicating the relation could remove it from the original entry.";
3619
+ case "unique":
3620
+ return "Identical values in a unique field are not allowed";
3621
+ default:
3622
+ return reason;
3623
+ }
3624
+ };
3625
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3626
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: formatMessage({
3627
+ id: getTranslation("containers.list.autoCloneModal.title"),
3628
+ defaultMessage: "This entry can't be duplicated directly."
3629
+ }) }),
3630
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
3631
+ id: getTranslation("containers.list.autoCloneModal.description"),
3632
+ defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
3633
+ }) }) }),
3634
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxRuntime.jsxs(
3635
+ designSystem.Flex,
3636
+ {
3637
+ direction: "column",
3638
+ gap: 2,
3639
+ alignItems: "flex-start",
3640
+ borderColor: "neutral200",
3641
+ hasRadius: true,
3642
+ padding: 6,
3643
+ children: [
3644
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "row", tag: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontWeight: "semiBold", tag: "li", children: [
3645
+ pathSegment,
3646
+ index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
3647
+ Icons.ChevronRight,
3648
+ {
3649
+ fill: "neutral500",
3650
+ height: "0.8rem",
3651
+ width: "0.8rem",
3652
+ style: { margin: "0 0.8rem" }
3653
+ }
3654
+ )
3655
+ ] }, index2)) }),
3656
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", textColor: "neutral600", children: formatMessage({
3657
+ id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
3658
+ defaultMessage: getDefaultErrorMessage(reason)
3659
+ }) })
3660
+ ]
3661
+ },
3662
+ fieldPath.join()
3663
+ )) })
3664
+ ] });
3665
+ };
3666
+ const TableActions = ({ document }) => {
3667
+ const { formatMessage } = reactIntl.useIntl();
3668
+ const { model, collectionType } = useDoc();
3669
+ const plugins = strapiAdmin.useStrapiApp("TableActions", (state) => state.plugins);
3670
+ const props = {
3671
+ activeTab: null,
3672
+ model,
3673
+ documentId: document.documentId,
3674
+ collectionType,
3675
+ document
3676
+ };
3677
+ return /* @__PURE__ */ jsxRuntime.jsx(
3678
+ strapiAdmin.DescriptionComponentRenderer,
3679
+ {
3680
+ props,
3681
+ descriptions: plugins["content-manager"].apis.getDocumentActions().filter((action) => action.name !== "PublishAction"),
3682
+ children: (actions2) => {
3683
+ const tableRowActions = actions2.filter((action) => {
3684
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
3685
+ return positions.includes("table-row");
3686
+ });
3687
+ return /* @__PURE__ */ jsxRuntime.jsx(
3688
+ DocumentActionsMenu,
3689
+ {
3690
+ actions: tableRowActions,
3691
+ label: formatMessage({
3692
+ id: "content-manager.containers.list.table.row-actions",
3693
+ defaultMessage: "Row action"
3694
+ }),
3695
+ variant: "ghost"
3696
+ }
3697
+ );
3698
+ }
3699
+ }
3700
+ );
3701
+ };
3702
+ const EditAction = ({ documentId }) => {
3703
+ const navigate = reactRouterDom.useNavigate();
3704
+ const { formatMessage } = reactIntl.useIntl();
3705
+ const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
3706
+ const { toggleNotification } = strapiAdmin.useNotification();
3707
+ const [{ query }] = strapiAdmin.useQueryParams();
3708
+ return {
3709
+ disabled: !canRead,
3710
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledPencil, {}),
3711
+ label: formatMessage({
3712
+ id: "content-manager.actions.edit.label",
3713
+ defaultMessage: "Edit"
3714
+ }),
3715
+ position: "table-row",
3716
+ onClick: async () => {
3717
+ if (!documentId) {
3718
+ console.error(
3719
+ "You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
3720
+ );
3721
+ toggleNotification({
3722
+ message: formatMessage({
3723
+ id: "content-manager.actions.edit.error",
3724
+ defaultMessage: "An error occurred while trying to edit the document."
3725
+ }),
3726
+ type: "danger"
3727
+ });
3728
+ return;
3729
+ }
3730
+ navigate({
3731
+ pathname: documentId,
3732
+ search: qs.stringify({
3733
+ plugins: query.plugins
3734
+ })
3735
+ });
3736
+ }
3737
+ };
3738
+ };
3739
+ EditAction.type = "edit";
3740
+ const StyledPencil = styledComponents.styled(Icons.Pencil)`
3741
+ path {
3742
+ fill: currentColor;
3743
+ }
3744
+ `;
3745
+ const CloneAction = ({ model, documentId }) => {
3746
+ const navigate = reactRouterDom.useNavigate();
3747
+ const { formatMessage } = reactIntl.useIntl();
3748
+ const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
3749
+ const { toggleNotification } = strapiAdmin.useNotification();
3750
+ const { autoClone } = useDocumentActions();
3751
+ const [prohibitedFields, setProhibitedFields] = React__namespace.useState([]);
3752
+ return {
3753
+ disabled: !canCreate,
3754
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledDuplicate, {}),
3755
+ label: formatMessage({
3756
+ id: "content-manager.actions.clone.label",
3757
+ defaultMessage: "Duplicate"
3758
+ }),
3759
+ position: "table-row",
3760
+ onClick: async () => {
3761
+ if (!documentId) {
3762
+ console.error(
3763
+ "You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
3764
+ );
3765
+ toggleNotification({
3766
+ message: formatMessage({
3767
+ id: "content-manager.actions.clone.error",
3768
+ defaultMessage: "An error occurred while trying to clone the document."
3769
+ }),
3770
+ type: "danger"
3771
+ });
3772
+ return;
3773
+ }
3774
+ const res = await autoClone({ model, sourceId: documentId });
3775
+ if ("data" in res) {
3776
+ navigate(res.data.documentId);
3777
+ return true;
3778
+ }
3779
+ if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
3780
+ const prohibitedFields2 = res.error.details.prohibitedFields;
3781
+ setProhibitedFields(prohibitedFields2);
3782
+ }
3783
+ },
3784
+ dialog: {
3785
+ type: "modal",
3786
+ title: formatMessage({
3787
+ id: "content-manager.containers.list.autoCloneModal.header",
3788
+ defaultMessage: "Duplicate"
3789
+ }),
3790
+ content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
3791
+ footer: ({ onClose }) => {
3792
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
3793
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
3794
+ id: "cancel",
3795
+ defaultMessage: "Cancel"
3796
+ }) }),
3797
+ /* @__PURE__ */ jsxRuntime.jsx(
3798
+ designSystem.LinkButton,
3799
+ {
3800
+ tag: reactRouterDom.NavLink,
3801
+ to: {
3802
+ pathname: `clone/${documentId}`
3803
+ },
3804
+ children: formatMessage({
3805
+ id: "content-manager.containers.list.autoCloneModal.create",
3806
+ defaultMessage: "Create"
3807
+ })
3808
+ }
3809
+ )
3810
+ ] });
3811
+ }
3812
+ }
3813
+ };
3814
+ };
3815
+ CloneAction.type = "clone";
3816
+ const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
3817
+ path {
3818
+ fill: currentColor;
3819
+ }
3820
+ `;
3821
+ const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
3822
+ class ContentManagerPlugin {
3823
+ /**
3824
+ * The following properties are the stored ones provided by any plugins registering with
3825
+ * the content-manager. The function calls however, need to be called at runtime in the
3826
+ * application, so instead we collate them and run them later with the complete list incl.
3827
+ * ones already registered & the context of the view.
3828
+ */
3829
+ bulkActions = [...DEFAULT_BULK_ACTIONS];
3830
+ documentActions = [
3831
+ ...DEFAULT_ACTIONS,
3832
+ ...DEFAULT_TABLE_ROW_ACTIONS,
3833
+ ...DEFAULT_HEADER_ACTIONS
3834
+ ];
3835
+ editViewSidePanels = [ActionsPanel];
3836
+ headerActions = [];
3837
+ constructor() {
3838
+ }
3839
+ addEditViewSidePanel(panels) {
3840
+ if (Array.isArray(panels)) {
3841
+ this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
3842
+ } else if (typeof panels === "function") {
3843
+ this.editViewSidePanels = panels(this.editViewSidePanels);
3844
+ } else {
3845
+ throw new Error(
3846
+ `Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
3847
+ panels
3848
+ )}`
3849
+ );
3850
+ }
3851
+ }
3852
+ addDocumentAction(actions2) {
3853
+ if (Array.isArray(actions2)) {
3854
+ this.documentActions = [...this.documentActions, ...actions2];
3855
+ } else if (typeof actions2 === "function") {
3856
+ this.documentActions = actions2(this.documentActions);
3857
+ } else {
3858
+ throw new Error(
3859
+ `Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
3860
+ actions2
3861
+ )}`
3862
+ );
3863
+ }
3864
+ }
3865
+ addDocumentHeaderAction(actions2) {
3866
+ if (Array.isArray(actions2)) {
3867
+ this.headerActions = [...this.headerActions, ...actions2];
3868
+ } else if (typeof actions2 === "function") {
3869
+ this.headerActions = actions2(this.headerActions);
3870
+ } else {
3871
+ throw new Error(
3872
+ `Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
3873
+ actions2
3874
+ )}`
3875
+ );
3876
+ }
3877
+ }
3878
+ addBulkAction(actions2) {
3879
+ if (Array.isArray(actions2)) {
3880
+ this.bulkActions = [...this.bulkActions, ...actions2];
3881
+ } else if (typeof actions2 === "function") {
3882
+ this.bulkActions = actions2(this.bulkActions);
3883
+ } else {
3884
+ throw new Error(
3885
+ `Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
3886
+ actions2
3887
+ )}`
3888
+ );
3889
+ }
3890
+ }
3891
+ get config() {
3892
+ return {
3893
+ id: PLUGIN_ID,
3894
+ name: "Content Manager",
3895
+ injectionZones: INJECTION_ZONES,
3896
+ apis: {
3897
+ addBulkAction: this.addBulkAction.bind(this),
3898
+ addDocumentAction: this.addDocumentAction.bind(this),
3899
+ addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
3900
+ addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
3901
+ getBulkActions: () => this.bulkActions,
3902
+ getDocumentActions: () => this.documentActions,
3903
+ getEditViewSidePanels: () => this.editViewSidePanels,
3904
+ getHeaderActions: () => this.headerActions
3905
+ }
3906
+ };
3907
+ }
3908
+ }
3909
+ const getPrintableType = (value) => {
3910
+ const nativeType = typeof value;
3911
+ if (nativeType === "object") {
3912
+ if (value === null)
3913
+ return "null";
3914
+ if (Array.isArray(value))
3915
+ return "array";
3916
+ if (value instanceof Object && value.constructor.name !== "Object") {
3917
+ return value.constructor.name;
3918
+ }
3919
+ }
3920
+ return nativeType;
3921
+ };
3922
+ const HistoryAction = ({ model, document }) => {
3923
+ const { formatMessage } = reactIntl.useIntl();
3924
+ const [{ query }] = strapiAdmin.useQueryParams();
3925
+ const navigate = reactRouterDom.useNavigate();
3926
+ const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
3927
+ if (!window.strapi.features.isEnabled("cms-content-history")) {
3928
+ return null;
3929
+ }
3930
+ return {
3931
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
3932
+ label: formatMessage({
3933
+ id: "content-manager.history.document-action",
3934
+ defaultMessage: "Content History"
3935
+ }),
3936
+ onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
3937
+ disabled: (
3938
+ /**
3939
+ * The user is creating a new document.
3940
+ * It hasn't been saved yet, so there's no history to go to
3941
+ */
3942
+ !document || /**
3943
+ * The document has been created but the current dimension has never been saved.
3944
+ * For example, the user is creating a new locale in an existing document,
3945
+ * so there's no history for the document in that locale
3946
+ */
3947
+ !document.id || /**
3948
+ * History is only available for content types created by the user.
3949
+ * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
3950
+ * which start with `admin::` or `plugin::`
3951
+ */
3952
+ !model.startsWith("api::")
3953
+ ),
3954
+ position: "header"
3955
+ };
3956
+ };
3957
+ HistoryAction.type = "history";
3958
+ const historyAdmin = {
3959
+ bootstrap(app) {
3960
+ const { addDocumentAction } = app.getPlugin("content-manager").apis;
3961
+ addDocumentAction((actions2) => {
3962
+ const indexOfDeleteAction = actions2.findIndex((action) => action.type === "delete");
3963
+ actions2.splice(indexOfDeleteAction, 0, HistoryAction);
3964
+ return actions2;
3965
+ });
3966
+ }
3967
+ };
3968
+ const initialState = {
3969
+ collectionTypeLinks: [],
3970
+ components: [],
3971
+ fieldSizes: {},
3972
+ models: [],
3973
+ singleTypeLinks: [],
3974
+ isLoading: true
3975
+ };
3976
+ const appSlice = toolkit.createSlice({
3977
+ name: "app",
3978
+ initialState,
3979
+ reducers: {
3980
+ setInitialData(state, action) {
3981
+ const {
3982
+ authorizedCollectionTypeLinks,
3983
+ authorizedSingleTypeLinks,
3984
+ components,
3985
+ contentTypeSchemas,
3986
+ fieldSizes
3987
+ } = action.payload;
3988
+ state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
3989
+ ({ isDisplayed }) => isDisplayed
3990
+ );
3991
+ state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
3992
+ state.components = components;
3993
+ state.models = contentTypeSchemas;
3994
+ state.fieldSizes = fieldSizes;
3995
+ state.isLoading = false;
3996
+ }
3997
+ }
3998
+ });
3999
+ const { actions, reducer: reducer$1 } = appSlice;
4000
+ const { setInitialData } = actions;
4001
+ const reducer = toolkit.combineReducers({
4002
+ app: reducer$1
4003
+ });
4004
+ const index = {
4005
+ register(app) {
4006
+ const cm = new ContentManagerPlugin();
4007
+ app.addReducers({
4008
+ [PLUGIN_ID]: reducer
4009
+ });
4010
+ app.addMenuLink({
4011
+ to: PLUGIN_ID,
4012
+ icon: Icons.Feather,
4013
+ intlLabel: {
4014
+ id: `content-manager.plugin.name`,
4015
+ defaultMessage: "Content Manager"
4016
+ },
4017
+ permissions: [],
4018
+ position: 1
4019
+ });
4020
+ app.router.addRoute({
4021
+ path: "content-manager/*",
4022
+ lazy: async () => {
4023
+ const { Layout } = await Promise.resolve().then(() => require("./layout-DeADP3ln.js"));
4024
+ return {
4025
+ Component: Layout
4026
+ };
4027
+ },
4028
+ children: routes
4029
+ });
4030
+ app.registerPlugin(cm.config);
4031
+ },
4032
+ bootstrap(app) {
4033
+ if (typeof historyAdmin.bootstrap === "function") {
4034
+ historyAdmin.bootstrap(app);
4035
+ }
4036
+ },
4037
+ async registerTrads({ locales }) {
4038
+ const importedTrads = await Promise.all(
4039
+ locales.map((locale) => {
4040
+ return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/ar.json": () => Promise.resolve().then(() => require("./ar-BUUWXIYu.js")), "./translations/ca.json": () => Promise.resolve().then(() => require("./ca-Cmk45QO6.js")), "./translations/cs.json": () => Promise.resolve().then(() => require("./cs-CkJy6B2v.js")), "./translations/de.json": () => Promise.resolve().then(() => require("./de-CCEmbAah.js")), "./translations/en.json": () => Promise.resolve().then(() => require("./en-Bm0D0IWz.js")), "./translations/es.json": () => Promise.resolve().then(() => require("./es-EUonQTon.js")), "./translations/eu.json": () => Promise.resolve().then(() => require("./eu-VDH-3ovk.js")), "./translations/fr.json": () => Promise.resolve().then(() => require("./fr-B7kGGg3E.js")), "./translations/gu.json": () => Promise.resolve().then(() => require("./gu-BRmF601H.js")), "./translations/hi.json": () => Promise.resolve().then(() => require("./hi-CCJBptSq.js")), "./translations/hu.json": () => Promise.resolve().then(() => require("./hu-sNV_yLYy.js")), "./translations/id.json": () => Promise.resolve().then(() => require("./id-B5Ser98A.js")), "./translations/it.json": () => Promise.resolve().then(() => require("./it-DkBIs7vD.js")), "./translations/ja.json": () => Promise.resolve().then(() => require("./ja-CcFe8diO.js")), "./translations/ko.json": () => Promise.resolve().then(() => require("./ko-woFZPmLk.js")), "./translations/ml.json": () => Promise.resolve().then(() => require("./ml-C2W8N8k1.js")), "./translations/ms.json": () => Promise.resolve().then(() => require("./ms-BuFotyP_.js")), "./translations/nl.json": () => Promise.resolve().then(() => require("./nl-bbEOHChV.js")), "./translations/pl.json": () => Promise.resolve().then(() => require("./pl-uzwG-hk7.js")), "./translations/pt-BR.json": () => Promise.resolve().then(() => require("./pt-BR-BiOz37D9.js")), "./translations/pt.json": () => Promise.resolve().then(() => require("./pt-CeXQuq50.js")), "./translations/ru.json": () => Promise.resolve().then(() => require("./ru-BT3ybNny.js")), "./translations/sa.json": () => Promise.resolve().then(() => require("./sa-CcvkYInH.js")), "./translations/sk.json": () => Promise.resolve().then(() => require("./sk-CvY09Xjv.js")), "./translations/sv.json": () => Promise.resolve().then(() => require("./sv-MYDuzgvT.js")), "./translations/th.json": () => Promise.resolve().then(() => require("./th-D9_GfAjc.js")), "./translations/tr.json": () => Promise.resolve().then(() => require("./tr-D9UH-O_R.js")), "./translations/uk.json": () => Promise.resolve().then(() => require("./uk-C8EiqJY7.js")), "./translations/vi.json": () => Promise.resolve().then(() => require("./vi-CJlYDheJ.js")), "./translations/zh-Hans.json": () => Promise.resolve().then(() => require("./zh-Hans-9kOncHGw.js")), "./translations/zh.json": () => Promise.resolve().then(() => require("./zh-CQQfszqR.js")) }), `./translations/${locale}.json`).then(({ default: data }) => {
4041
+ return {
4042
+ data: prefixPluginTranslations(data, PLUGIN_ID),
4043
+ locale
4044
+ };
4045
+ }).catch(() => {
4046
+ return {
4047
+ data: {},
4048
+ locale
4049
+ };
4050
+ });
4051
+ })
4052
+ );
4053
+ return Promise.resolve(importedTrads);
4054
+ }
4055
+ };
4056
+ exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
4057
+ exports.BulkActionsRenderer = BulkActionsRenderer;
4058
+ exports.CLONE_PATH = CLONE_PATH;
4059
+ exports.COLLECTION_TYPES = COLLECTION_TYPES;
4060
+ exports.CREATOR_FIELDS = CREATOR_FIELDS;
4061
+ exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
4062
+ exports.DOCUMENT_META_FIELDS = DOCUMENT_META_FIELDS;
4063
+ exports.DocumentRBAC = DocumentRBAC;
4064
+ exports.DocumentStatus = DocumentStatus;
4065
+ exports.HOOKS = HOOKS;
4066
+ exports.Header = Header;
4067
+ exports.InjectionZone = InjectionZone;
4068
+ exports.PERMISSIONS = PERMISSIONS;
4069
+ exports.Panels = Panels;
4070
+ exports.RelativeTime = RelativeTime;
4071
+ exports.SINGLE_TYPES = SINGLE_TYPES;
4072
+ exports.TableActions = TableActions;
4073
+ exports.buildValidParams = buildValidParams;
4074
+ exports.capitalise = capitalise;
4075
+ exports.checkIfAttributeIsDisplayable = checkIfAttributeIsDisplayable;
4076
+ exports.contentManagerApi = contentManagerApi;
4077
+ exports.convertEditLayoutToFieldLayouts = convertEditLayoutToFieldLayouts;
4078
+ exports.convertListLayoutToFieldLayouts = convertListLayoutToFieldLayouts;
4079
+ exports.createYupSchema = createYupSchema;
4080
+ exports.extractContentTypeComponents = extractContentTypeComponents;
4081
+ exports.getDisplayName = getDisplayName;
4082
+ exports.getMainField = getMainField;
4083
+ exports.getTranslation = getTranslation;
4084
+ exports.index = index;
4085
+ exports.setInitialData = setInitialData;
4086
+ exports.useContentManagerContext = useContentManagerContext;
4087
+ exports.useContentTypeSchema = useContentTypeSchema;
4088
+ exports.useDoc = useDoc;
4089
+ exports.useDocLayout = useDocLayout;
4090
+ exports.useDocument = useDocument;
4091
+ exports.useDocumentActions = useDocumentActions;
4092
+ exports.useDocumentLayout = useDocumentLayout;
4093
+ exports.useDocumentRBAC = useDocumentRBAC;
4094
+ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
4095
+ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
4096
+ exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
4097
+ exports.useGetInitialDataQuery = useGetInitialDataQuery;
4098
+ exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
4099
+ //# sourceMappingURL=index-DhdyY1Y8.js.map