@strapi/content-manager 0.0.0 → 5.0.0-beta.7

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 (507) hide show
  1. package/README.md +9 -1
  2. package/dist/_chunks/CardDragPreview-C0QyJgRA.js +69 -0
  3. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
  4. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs +70 -0
  5. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
  6. package/dist/_chunks/ComponentConfigurationPage-DMq0wvcL.js +255 -0
  7. package/dist/_chunks/ComponentConfigurationPage-DMq0wvcL.js.map +1 -0
  8. package/dist/_chunks/ComponentConfigurationPage-uTMkLI60.mjs +236 -0
  9. package/dist/_chunks/ComponentConfigurationPage-uTMkLI60.mjs.map +1 -0
  10. package/dist/_chunks/ComponentIcon-BBQsYCVn.js +170 -0
  11. package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +1 -0
  12. package/dist/_chunks/ComponentIcon-BOFnK76n.mjs +151 -0
  13. package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +1 -0
  14. package/dist/_chunks/EditConfigurationPage-B2HhCh-b.mjs +132 -0
  15. package/dist/_chunks/EditConfigurationPage-B2HhCh-b.mjs.map +1 -0
  16. package/dist/_chunks/EditConfigurationPage-BFpQwwbc.js +151 -0
  17. package/dist/_chunks/EditConfigurationPage-BFpQwwbc.js.map +1 -0
  18. package/dist/_chunks/EditViewPage-BVIrgjyG.mjs +203 -0
  19. package/dist/_chunks/EditViewPage-BVIrgjyG.mjs.map +1 -0
  20. package/dist/_chunks/EditViewPage-CXXue16T.js +222 -0
  21. package/dist/_chunks/EditViewPage-CXXue16T.js.map +1 -0
  22. package/dist/_chunks/Field-0_2h1vuK.mjs +5328 -0
  23. package/dist/_chunks/Field-0_2h1vuK.mjs.map +1 -0
  24. package/dist/_chunks/Field-ZgzKlgxR.js +5360 -0
  25. package/dist/_chunks/Field-ZgzKlgxR.js.map +1 -0
  26. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs +50 -0
  27. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -0
  28. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js +49 -0
  29. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -0
  30. package/dist/_chunks/Form-B7TUnQDd.mjs +737 -0
  31. package/dist/_chunks/Form-B7TUnQDd.mjs.map +1 -0
  32. package/dist/_chunks/Form-DgTc2qkx.js +758 -0
  33. package/dist/_chunks/Form-DgTc2qkx.js.map +1 -0
  34. package/dist/_chunks/History-DtHjQuqM.js +948 -0
  35. package/dist/_chunks/History-DtHjQuqM.js.map +1 -0
  36. package/dist/_chunks/History-Dug_4HIA.mjs +927 -0
  37. package/dist/_chunks/History-Dug_4HIA.mjs.map +1 -0
  38. package/dist/_chunks/ListConfigurationPage-BuSdTjfa.js +641 -0
  39. package/dist/_chunks/ListConfigurationPage-BuSdTjfa.js.map +1 -0
  40. package/dist/_chunks/ListConfigurationPage-CmEeNg6T.mjs +622 -0
  41. package/dist/_chunks/ListConfigurationPage-CmEeNg6T.mjs.map +1 -0
  42. package/dist/_chunks/ListViewPage-CExWwa4S.js +846 -0
  43. package/dist/_chunks/ListViewPage-CExWwa4S.js.map +1 -0
  44. package/dist/_chunks/ListViewPage-Dsoa3wEA.mjs +823 -0
  45. package/dist/_chunks/ListViewPage-Dsoa3wEA.mjs.map +1 -0
  46. package/dist/_chunks/NoContentTypePage-DCUL8gVi.js +51 -0
  47. package/dist/_chunks/NoContentTypePage-DCUL8gVi.js.map +1 -0
  48. package/dist/_chunks/NoContentTypePage-Dh38hBXB.mjs +51 -0
  49. package/dist/_chunks/NoContentTypePage-Dh38hBXB.mjs.map +1 -0
  50. package/dist/_chunks/NoPermissionsPage-BK-XCpIy.js +23 -0
  51. package/dist/_chunks/NoPermissionsPage-BK-XCpIy.js.map +1 -0
  52. package/dist/_chunks/NoPermissionsPage-Dt2O40ey.mjs +23 -0
  53. package/dist/_chunks/NoPermissionsPage-Dt2O40ey.mjs.map +1 -0
  54. package/dist/_chunks/Relations-CNypkp-g.js +712 -0
  55. package/dist/_chunks/Relations-CNypkp-g.js.map +1 -0
  56. package/dist/_chunks/Relations-DZyjWZHl.mjs +692 -0
  57. package/dist/_chunks/Relations-DZyjWZHl.mjs.map +1 -0
  58. package/dist/_chunks/ar-BUUWXIYu.js +226 -0
  59. package/dist/_chunks/ar-BUUWXIYu.js.map +1 -0
  60. package/dist/_chunks/ar-CCEVvqGG.mjs +226 -0
  61. package/dist/_chunks/ar-CCEVvqGG.mjs.map +1 -0
  62. package/dist/_chunks/ca-5U32ON2v.mjs +201 -0
  63. package/dist/_chunks/ca-5U32ON2v.mjs.map +1 -0
  64. package/dist/_chunks/ca-Cmk45QO6.js +201 -0
  65. package/dist/_chunks/ca-Cmk45QO6.js.map +1 -0
  66. package/dist/_chunks/cs-CM2aBUar.mjs +125 -0
  67. package/dist/_chunks/cs-CM2aBUar.mjs.map +1 -0
  68. package/dist/_chunks/cs-CkJy6B2v.js +125 -0
  69. package/dist/_chunks/cs-CkJy6B2v.js.map +1 -0
  70. package/dist/_chunks/de-C72KDNOl.mjs +199 -0
  71. package/dist/_chunks/de-C72KDNOl.mjs.map +1 -0
  72. package/dist/_chunks/de-CCEmbAah.js +199 -0
  73. package/dist/_chunks/de-CCEmbAah.js.map +1 -0
  74. package/dist/_chunks/en-C-V1_90f.js +285 -0
  75. package/dist/_chunks/en-C-V1_90f.js.map +1 -0
  76. package/dist/_chunks/en-MBPul9Su.mjs +285 -0
  77. package/dist/_chunks/en-MBPul9Su.mjs.map +1 -0
  78. package/dist/_chunks/es-CeXiYflN.mjs +196 -0
  79. package/dist/_chunks/es-CeXiYflN.mjs.map +1 -0
  80. package/dist/_chunks/es-EUonQTon.js +196 -0
  81. package/dist/_chunks/es-EUonQTon.js.map +1 -0
  82. package/dist/_chunks/eu-CdALomew.mjs +202 -0
  83. package/dist/_chunks/eu-CdALomew.mjs.map +1 -0
  84. package/dist/_chunks/eu-VDH-3ovk.js +202 -0
  85. package/dist/_chunks/eu-VDH-3ovk.js.map +1 -0
  86. package/dist/_chunks/fr-B7kGGg3E.js +206 -0
  87. package/dist/_chunks/fr-B7kGGg3E.js.map +1 -0
  88. package/dist/_chunks/fr-CD9VFbPM.mjs +206 -0
  89. package/dist/_chunks/fr-CD9VFbPM.mjs.map +1 -0
  90. package/dist/_chunks/gu-BRmF601H.js +200 -0
  91. package/dist/_chunks/gu-BRmF601H.js.map +1 -0
  92. package/dist/_chunks/gu-CNpaMDpH.mjs +200 -0
  93. package/dist/_chunks/gu-CNpaMDpH.mjs.map +1 -0
  94. package/dist/_chunks/hi-CCJBptSq.js +200 -0
  95. package/dist/_chunks/hi-CCJBptSq.js.map +1 -0
  96. package/dist/_chunks/hi-Dwvd04m3.mjs +200 -0
  97. package/dist/_chunks/hi-Dwvd04m3.mjs.map +1 -0
  98. package/dist/_chunks/hooks-BAaaKPS_.js +7 -0
  99. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -0
  100. package/dist/_chunks/hooks-E5u1mcgM.mjs +8 -0
  101. package/dist/_chunks/hooks-E5u1mcgM.mjs.map +1 -0
  102. package/dist/_chunks/hu-CeYvaaO0.mjs +202 -0
  103. package/dist/_chunks/hu-CeYvaaO0.mjs.map +1 -0
  104. package/dist/_chunks/hu-sNV_yLYy.js +202 -0
  105. package/dist/_chunks/hu-sNV_yLYy.js.map +1 -0
  106. package/dist/_chunks/id-B5Ser98A.js +160 -0
  107. package/dist/_chunks/id-B5Ser98A.js.map +1 -0
  108. package/dist/_chunks/id-BtwA9WJT.mjs +160 -0
  109. package/dist/_chunks/id-BtwA9WJT.mjs.map +1 -0
  110. package/dist/_chunks/index-B3c-4it4.mjs +3188 -0
  111. package/dist/_chunks/index-B3c-4it4.mjs.map +1 -0
  112. package/dist/_chunks/index-DFK7LwDW.js +3207 -0
  113. package/dist/_chunks/index-DFK7LwDW.js.map +1 -0
  114. package/dist/_chunks/it-BrVPqaf1.mjs +162 -0
  115. package/dist/_chunks/it-BrVPqaf1.mjs.map +1 -0
  116. package/dist/_chunks/it-DkBIs7vD.js +162 -0
  117. package/dist/_chunks/it-DkBIs7vD.js.map +1 -0
  118. package/dist/_chunks/ja-CcFe8diO.js +196 -0
  119. package/dist/_chunks/ja-CcFe8diO.js.map +1 -0
  120. package/dist/_chunks/ja-CtsUxOvk.mjs +196 -0
  121. package/dist/_chunks/ja-CtsUxOvk.mjs.map +1 -0
  122. package/dist/_chunks/ko-HVQRlfUI.mjs +195 -0
  123. package/dist/_chunks/ko-HVQRlfUI.mjs.map +1 -0
  124. package/dist/_chunks/ko-woFZPmLk.js +195 -0
  125. package/dist/_chunks/ko-woFZPmLk.js.map +1 -0
  126. package/dist/_chunks/layout-B5cm7cZj.mjs +453 -0
  127. package/dist/_chunks/layout-B5cm7cZj.mjs.map +1 -0
  128. package/dist/_chunks/layout-DLih5-_W.js +471 -0
  129. package/dist/_chunks/layout-DLih5-_W.js.map +1 -0
  130. package/dist/_chunks/ml-BihZwQit.mjs +200 -0
  131. package/dist/_chunks/ml-BihZwQit.mjs.map +1 -0
  132. package/dist/_chunks/ml-C2W8N8k1.js +200 -0
  133. package/dist/_chunks/ml-C2W8N8k1.js.map +1 -0
  134. package/dist/_chunks/ms-BuFotyP_.js +144 -0
  135. package/dist/_chunks/ms-BuFotyP_.js.map +1 -0
  136. package/dist/_chunks/ms-m_WjyWx7.mjs +144 -0
  137. package/dist/_chunks/ms-m_WjyWx7.mjs.map +1 -0
  138. package/dist/_chunks/nl-D4R9gHx5.mjs +202 -0
  139. package/dist/_chunks/nl-D4R9gHx5.mjs.map +1 -0
  140. package/dist/_chunks/nl-bbEOHChV.js +202 -0
  141. package/dist/_chunks/nl-bbEOHChV.js.map +1 -0
  142. package/dist/_chunks/objects-gigeqt7s.js +49 -0
  143. package/dist/_chunks/objects-gigeqt7s.js.map +1 -0
  144. package/dist/_chunks/objects-mKMAmfec.mjs +47 -0
  145. package/dist/_chunks/objects-mKMAmfec.mjs.map +1 -0
  146. package/dist/_chunks/pl-sbx9mSt_.mjs +199 -0
  147. package/dist/_chunks/pl-sbx9mSt_.mjs.map +1 -0
  148. package/dist/_chunks/pl-uzwG-hk7.js +199 -0
  149. package/dist/_chunks/pl-uzwG-hk7.js.map +1 -0
  150. package/dist/_chunks/pt-BR-BiOz37D9.js +201 -0
  151. package/dist/_chunks/pt-BR-BiOz37D9.js.map +1 -0
  152. package/dist/_chunks/pt-BR-C71iDxnh.mjs +201 -0
  153. package/dist/_chunks/pt-BR-C71iDxnh.mjs.map +1 -0
  154. package/dist/_chunks/pt-BsaFvS8-.mjs +95 -0
  155. package/dist/_chunks/pt-BsaFvS8-.mjs.map +1 -0
  156. package/dist/_chunks/pt-CeXQuq50.js +95 -0
  157. package/dist/_chunks/pt-CeXQuq50.js.map +1 -0
  158. package/dist/_chunks/relations-BZkrMa2z.mjs +135 -0
  159. package/dist/_chunks/relations-BZkrMa2z.mjs.map +1 -0
  160. package/dist/_chunks/relations-CTvkuINQ.js +134 -0
  161. package/dist/_chunks/relations-CTvkuINQ.js.map +1 -0
  162. package/dist/_chunks/ru-BE6A4Exp.mjs +231 -0
  163. package/dist/_chunks/ru-BE6A4Exp.mjs.map +1 -0
  164. package/dist/_chunks/ru-BT3ybNny.js +231 -0
  165. package/dist/_chunks/ru-BT3ybNny.js.map +1 -0
  166. package/dist/_chunks/sa-CcvkYInH.js +200 -0
  167. package/dist/_chunks/sa-CcvkYInH.js.map +1 -0
  168. package/dist/_chunks/sa-Dag0k-Z8.mjs +200 -0
  169. package/dist/_chunks/sa-Dag0k-Z8.mjs.map +1 -0
  170. package/dist/_chunks/sk-BFg-R8qJ.mjs +202 -0
  171. package/dist/_chunks/sk-BFg-R8qJ.mjs.map +1 -0
  172. package/dist/_chunks/sk-CvY09Xjv.js +202 -0
  173. package/dist/_chunks/sk-CvY09Xjv.js.map +1 -0
  174. package/dist/_chunks/sv-CUnfWGsh.mjs +202 -0
  175. package/dist/_chunks/sv-CUnfWGsh.mjs.map +1 -0
  176. package/dist/_chunks/sv-MYDuzgvT.js +202 -0
  177. package/dist/_chunks/sv-MYDuzgvT.js.map +1 -0
  178. package/dist/_chunks/th-BqbI8lIT.mjs +148 -0
  179. package/dist/_chunks/th-BqbI8lIT.mjs.map +1 -0
  180. package/dist/_chunks/th-D9_GfAjc.js +148 -0
  181. package/dist/_chunks/th-D9_GfAjc.js.map +1 -0
  182. package/dist/_chunks/tr-CgeK3wJM.mjs +199 -0
  183. package/dist/_chunks/tr-CgeK3wJM.mjs.map +1 -0
  184. package/dist/_chunks/tr-D9UH-O_R.js +199 -0
  185. package/dist/_chunks/tr-D9UH-O_R.js.map +1 -0
  186. package/dist/_chunks/uk-C8EiqJY7.js +144 -0
  187. package/dist/_chunks/uk-C8EiqJY7.js.map +1 -0
  188. package/dist/_chunks/uk-CR-zDhAY.mjs +144 -0
  189. package/dist/_chunks/uk-CR-zDhAY.mjs.map +1 -0
  190. package/dist/_chunks/urls-CbOsUOoW.mjs +7 -0
  191. package/dist/_chunks/urls-CbOsUOoW.mjs.map +1 -0
  192. package/dist/_chunks/urls-DzZya_gm.js +6 -0
  193. package/dist/_chunks/urls-DzZya_gm.js.map +1 -0
  194. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs +231 -0
  195. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -0
  196. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js +249 -0
  197. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -0
  198. package/dist/_chunks/vi-CJlYDheJ.js +111 -0
  199. package/dist/_chunks/vi-CJlYDheJ.js.map +1 -0
  200. package/dist/_chunks/vi-DUXIk_fw.mjs +111 -0
  201. package/dist/_chunks/vi-DUXIk_fw.mjs.map +1 -0
  202. package/dist/_chunks/zh-BWZspA60.mjs +209 -0
  203. package/dist/_chunks/zh-BWZspA60.mjs.map +1 -0
  204. package/dist/_chunks/zh-CQQfszqR.js +209 -0
  205. package/dist/_chunks/zh-CQQfszqR.js.map +1 -0
  206. package/dist/_chunks/zh-Hans-9kOncHGw.js +952 -0
  207. package/dist/_chunks/zh-Hans-9kOncHGw.js.map +1 -0
  208. package/dist/_chunks/zh-Hans-BPQcRIyH.mjs +952 -0
  209. package/dist/_chunks/zh-Hans-BPQcRIyH.mjs.map +1 -0
  210. package/dist/admin/index.js +11 -0
  211. package/dist/admin/index.js.map +1 -0
  212. package/dist/admin/index.mjs +11 -0
  213. package/dist/admin/index.mjs.map +1 -0
  214. package/dist/admin/src/components/ComponentIcon.d.ts +8 -0
  215. package/dist/admin/src/components/ConfigurationForm/EditFieldForm.d.ts +9 -0
  216. package/dist/admin/src/components/ConfigurationForm/Fields.d.ts +21 -0
  217. package/dist/admin/src/components/ConfigurationForm/Form.d.ts +32 -0
  218. package/dist/admin/src/components/DragLayer.d.ts +13 -0
  219. package/dist/admin/src/components/DragPreviews/CardDragPreview.d.ts +7 -0
  220. package/dist/admin/src/components/DragPreviews/ComponentDragPreview.d.ts +6 -0
  221. package/dist/admin/src/components/DragPreviews/RelationDragPreview.d.ts +11 -0
  222. package/dist/admin/src/components/FieldTypeIcon.d.ts +9 -0
  223. package/dist/admin/src/components/InjectionZone.d.ts +45 -0
  224. package/dist/admin/src/components/LeftMenu.d.ts +2 -0
  225. package/dist/admin/src/components/RelativeTime.d.ts +28 -0
  226. package/dist/admin/src/constants/attributes.d.ts +14 -0
  227. package/dist/admin/src/constants/collections.d.ts +3 -0
  228. package/dist/admin/src/constants/dragAndDrop.d.ts +8 -0
  229. package/dist/admin/src/constants/hooks.d.ts +26 -0
  230. package/dist/admin/src/constants/plugin.d.ts +3 -0
  231. package/dist/admin/src/content-manager.d.ts +133 -0
  232. package/dist/admin/src/exports.d.ts +11 -0
  233. package/dist/admin/src/features/DocumentRBAC.d.ts +36 -0
  234. package/dist/admin/src/history/components/HistoryAction.d.ts +3 -0
  235. package/dist/admin/src/history/components/VersionContent.d.ts +17 -0
  236. package/dist/admin/src/history/components/VersionHeader.d.ts +5 -0
  237. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +19 -0
  238. package/dist/admin/src/history/components/VersionsList.d.ts +2 -0
  239. package/dist/admin/src/history/pages/History.d.ts +27 -0
  240. package/dist/admin/src/history/routes.d.ts +6 -0
  241. package/dist/admin/src/history/services/historyVersion.d.ts +12 -0
  242. package/dist/admin/src/hooks/useContentManagerInitData.d.ts +15 -0
  243. package/dist/admin/src/hooks/useContentTypeSchema.d.ts +25 -0
  244. package/dist/admin/src/hooks/useDebounce.d.ts +1 -0
  245. package/dist/admin/src/hooks/useDocument.d.ts +90 -0
  246. package/dist/admin/src/hooks/useDocumentActions.d.ts +102 -0
  247. package/dist/admin/src/hooks/useDocumentLayout.d.ts +137 -0
  248. package/dist/admin/src/hooks/useDragAndDrop.d.ts +51 -0
  249. package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +14 -0
  250. package/dist/admin/src/hooks/useLazyComponents.d.ts +13 -0
  251. package/dist/admin/src/hooks/useOnce.d.ts +2 -0
  252. package/dist/admin/src/hooks/usePrev.d.ts +1 -0
  253. package/dist/admin/src/index.d.ts +16 -0
  254. package/dist/admin/src/layout.d.ts +2 -0
  255. package/dist/admin/src/modules/app.d.ts +20 -0
  256. package/dist/admin/src/modules/hooks.d.ts +10 -0
  257. package/dist/admin/src/modules/reducers.d.ts +6 -0
  258. package/dist/admin/src/pages/ComponentConfigurationPage.d.ts +3 -0
  259. package/dist/admin/src/pages/EditConfigurationPage.d.ts +3 -0
  260. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +3 -0
  261. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +69 -0
  262. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +16 -0
  263. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +3 -0
  264. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Heading.d.ts +3 -0
  265. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.d.ts +3 -0
  266. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.d.ts +3 -0
  267. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.d.ts +3 -0
  268. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Paragraph.d.ts +3 -0
  269. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Quote.d.ts +3 -0
  270. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.d.ts +6 -0
  271. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +61 -0
  272. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +11 -0
  273. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.d.ts +10 -0
  274. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.d.ts +10 -0
  275. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Modifiers.d.ts +16 -0
  276. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.d.ts +11 -0
  277. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.d.ts +9 -0
  278. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.d.ts +8 -0
  279. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/conversions.d.ts +13 -0
  280. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/enterKey.d.ts +6 -0
  281. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/links.d.ts +10 -0
  282. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.d.ts +10 -0
  283. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Initializer.d.ts +9 -0
  284. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +18 -0
  285. package/dist/admin/src/pages/EditView/components/FormInputs/Component/NonRepeatable.d.ts +5 -0
  286. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Repeatable.d.ts +5 -0
  287. package/dist/admin/src/pages/EditView/components/FormInputs/ComponentContext.d.ts +42 -0
  288. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/AddComponentButton.d.ts +11 -0
  289. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCard.d.ts +9 -0
  290. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +17 -0
  291. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentPicker.d.ts +9 -0
  292. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +14 -0
  293. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicZoneLabel.d.ts +12 -0
  294. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +14 -0
  295. package/dist/admin/src/pages/EditView/components/FormInputs/NotAllowed.d.ts +7 -0
  296. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +31 -0
  297. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +9 -0
  298. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Editor.d.ts +17 -0
  299. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +14 -0
  300. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +11 -0
  301. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/PreviewWysiwyg.d.ts +5 -0
  302. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +7 -0
  303. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.d.ts +17 -0
  304. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +49 -0
  305. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/continueList.d.ts +5 -0
  306. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/mdRenderer.d.ts +4 -0
  307. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/utils.d.ts +16 -0
  308. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +5 -0
  309. package/dist/admin/src/pages/EditView/components/Header.d.ts +35 -0
  310. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +17 -0
  311. package/dist/admin/src/pages/EditView/components/Panels.d.ts +10 -0
  312. package/dist/admin/src/pages/EditView/utils/data.d.ts +33 -0
  313. package/dist/admin/src/pages/EditView/utils/forms.d.ts +9 -0
  314. package/dist/admin/src/pages/ListConfiguration/ListConfigurationPage.d.ts +10 -0
  315. package/dist/admin/src/pages/ListConfiguration/components/DraggableCard.d.ts +12 -0
  316. package/dist/admin/src/pages/ListConfiguration/components/EditFieldForm.d.ts +8 -0
  317. package/dist/admin/src/pages/ListConfiguration/components/Header.d.ts +8 -0
  318. package/dist/admin/src/pages/ListConfiguration/components/Settings.d.ts +19 -0
  319. package/dist/admin/src/pages/ListConfiguration/components/SortDisplayedFields.d.ts +6 -0
  320. package/dist/admin/src/pages/ListView/ListViewPage.d.ts +3 -0
  321. package/dist/admin/src/pages/ListView/components/AutoCloneFailureModal.d.ts +7 -0
  322. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +51 -0
  323. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +15 -0
  324. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +31 -0
  325. package/dist/admin/src/pages/ListView/components/Filters.d.ts +8 -0
  326. package/dist/admin/src/pages/ListView/components/TableActions.d.ts +8 -0
  327. package/dist/admin/src/pages/ListView/components/TableCells/CellContent.d.ts +9 -0
  328. package/dist/admin/src/pages/ListView/components/TableCells/CellValue.d.ts +8 -0
  329. package/dist/admin/src/pages/ListView/components/TableCells/Components.d.ts +12 -0
  330. package/dist/admin/src/pages/ListView/components/TableCells/Media.d.ts +23 -0
  331. package/dist/admin/src/pages/ListView/components/TableCells/Relations.d.ts +12 -0
  332. package/dist/admin/src/pages/ListView/components/ViewSettingsMenu.d.ts +10 -0
  333. package/dist/admin/src/pages/NoContentTypePage.d.ts +2 -0
  334. package/dist/admin/src/pages/NoPermissionsPage.d.ts +2 -0
  335. package/dist/admin/src/router.d.ts +5 -0
  336. package/dist/admin/src/services/api.d.ts +3 -0
  337. package/dist/admin/src/services/components.d.ts +5 -0
  338. package/dist/admin/src/services/contentTypes.d.ts +17 -0
  339. package/dist/admin/src/services/documents.d.ts +89 -0
  340. package/dist/admin/src/services/init.d.ts +9 -0
  341. package/dist/admin/src/services/relations.d.ts +49 -0
  342. package/dist/admin/src/services/uid.d.ts +32 -0
  343. package/dist/admin/src/utils/api.d.ts +37 -0
  344. package/dist/admin/src/utils/attributes.d.ts +19 -0
  345. package/dist/admin/src/utils/objects.d.ts +33 -0
  346. package/dist/admin/src/utils/relations.d.ts +12 -0
  347. package/dist/admin/src/utils/strings.d.ts +2 -0
  348. package/dist/admin/src/utils/translations.d.ts +4 -0
  349. package/dist/admin/src/utils/urls.d.ts +2 -0
  350. package/dist/admin/src/utils/users.d.ts +6 -0
  351. package/dist/admin/src/utils/validation.d.ts +12 -0
  352. package/dist/server/index.js +4244 -0
  353. package/dist/server/index.js.map +1 -0
  354. package/dist/server/index.mjs +4220 -0
  355. package/dist/server/index.mjs.map +1 -0
  356. package/dist/server/src/bootstrap.d.ts +3 -0
  357. package/dist/server/src/bootstrap.d.ts.map +1 -0
  358. package/dist/server/src/config.d.ts +6 -0
  359. package/dist/server/src/config.d.ts.map +1 -0
  360. package/dist/server/src/constants/index.d.ts +6 -0
  361. package/dist/server/src/constants/index.d.ts.map +1 -0
  362. package/dist/server/src/controllers/collection-types.d.ts +23 -0
  363. package/dist/server/src/controllers/collection-types.d.ts.map +1 -0
  364. package/dist/server/src/controllers/components.d.ts +7 -0
  365. package/dist/server/src/controllers/components.d.ts.map +1 -0
  366. package/dist/server/src/controllers/content-types.d.ts +8 -0
  367. package/dist/server/src/controllers/content-types.d.ts.map +1 -0
  368. package/dist/server/src/controllers/index.d.ts +53 -0
  369. package/dist/server/src/controllers/index.d.ts.map +1 -0
  370. package/dist/server/src/controllers/init.d.ts +5 -0
  371. package/dist/server/src/controllers/init.d.ts.map +1 -0
  372. package/dist/server/src/controllers/relations.d.ts +13 -0
  373. package/dist/server/src/controllers/relations.d.ts.map +1 -0
  374. package/dist/server/src/controllers/single-types.d.ts +11 -0
  375. package/dist/server/src/controllers/single-types.d.ts.map +1 -0
  376. package/dist/server/src/controllers/uid.d.ts +6 -0
  377. package/dist/server/src/controllers/uid.d.ts.map +1 -0
  378. package/dist/server/src/controllers/utils/clone.d.ts +12 -0
  379. package/dist/server/src/controllers/utils/clone.d.ts.map +1 -0
  380. package/dist/server/src/controllers/utils/dimensions.d.ts +5 -0
  381. package/dist/server/src/controllers/utils/dimensions.d.ts.map +1 -0
  382. package/dist/server/src/controllers/validation/index.d.ts +20 -0
  383. package/dist/server/src/controllers/validation/index.d.ts.map +1 -0
  384. package/dist/server/src/controllers/validation/model-configuration.d.ts +22 -0
  385. package/dist/server/src/controllers/validation/model-configuration.d.ts.map +1 -0
  386. package/dist/server/src/controllers/validation/relations.d.ts +4 -0
  387. package/dist/server/src/controllers/validation/relations.d.ts.map +1 -0
  388. package/dist/server/src/destroy.d.ts +4 -0
  389. package/dist/server/src/destroy.d.ts.map +1 -0
  390. package/dist/server/src/history/constants.d.ts +3 -0
  391. package/dist/server/src/history/constants.d.ts.map +1 -0
  392. package/dist/server/src/history/controllers/history-version.d.ts +19 -0
  393. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -0
  394. package/dist/server/src/history/controllers/index.d.ts +2 -0
  395. package/dist/server/src/history/controllers/index.d.ts.map +1 -0
  396. package/dist/server/src/history/controllers/validation/history-version.d.ts +2 -0
  397. package/dist/server/src/history/controllers/validation/history-version.d.ts.map +1 -0
  398. package/dist/server/src/history/index.d.ts +4 -0
  399. package/dist/server/src/history/index.d.ts.map +1 -0
  400. package/dist/server/src/history/models/history-version.d.ts +4 -0
  401. package/dist/server/src/history/models/history-version.d.ts.map +1 -0
  402. package/dist/server/src/history/routes/history-version.d.ts +4 -0
  403. package/dist/server/src/history/routes/history-version.d.ts.map +1 -0
  404. package/dist/server/src/history/routes/index.d.ts +8 -0
  405. package/dist/server/src/history/routes/index.d.ts.map +1 -0
  406. package/dist/server/src/history/services/history.d.ts +16 -0
  407. package/dist/server/src/history/services/history.d.ts.map +1 -0
  408. package/dist/server/src/history/services/index.d.ts +19 -0
  409. package/dist/server/src/history/services/index.d.ts.map +1 -0
  410. package/dist/server/src/history/services/lifecycles.d.ts +9 -0
  411. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -0
  412. package/dist/server/src/history/services/utils.d.ts +44 -0
  413. package/dist/server/src/history/services/utils.d.ts.map +1 -0
  414. package/dist/server/src/history/utils.d.ts +22 -0
  415. package/dist/server/src/history/utils.d.ts.map +1 -0
  416. package/dist/server/src/index.d.ts +374 -0
  417. package/dist/server/src/index.d.ts.map +1 -0
  418. package/dist/server/src/middlewares/index.d.ts +3 -0
  419. package/dist/server/src/middlewares/index.d.ts.map +1 -0
  420. package/dist/server/src/middlewares/routing.d.ts +4 -0
  421. package/dist/server/src/middlewares/routing.d.ts.map +1 -0
  422. package/dist/server/src/policies/hasPermissions.d.ts +7 -0
  423. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -0
  424. package/dist/server/src/policies/index.d.ts +9 -0
  425. package/dist/server/src/policies/index.d.ts.map +1 -0
  426. package/dist/server/src/register.d.ts +4 -0
  427. package/dist/server/src/register.d.ts.map +1 -0
  428. package/dist/server/src/routes/admin.d.ts +41 -0
  429. package/dist/server/src/routes/admin.d.ts.map +1 -0
  430. package/dist/server/src/routes/index.d.ts +43 -0
  431. package/dist/server/src/routes/index.d.ts.map +1 -0
  432. package/dist/server/src/services/components.d.ts +32 -0
  433. package/dist/server/src/services/components.d.ts.map +1 -0
  434. package/dist/server/src/services/configuration.d.ts +20 -0
  435. package/dist/server/src/services/configuration.d.ts.map +1 -0
  436. package/dist/server/src/services/content-types.d.ts +18 -0
  437. package/dist/server/src/services/content-types.d.ts.map +1 -0
  438. package/dist/server/src/services/data-mapper.d.ts +20 -0
  439. package/dist/server/src/services/data-mapper.d.ts.map +1 -0
  440. package/dist/server/src/services/document-manager.d.ts +48 -0
  441. package/dist/server/src/services/document-manager.d.ts.map +1 -0
  442. package/dist/server/src/services/document-metadata.d.ts +88 -0
  443. package/dist/server/src/services/document-metadata.d.ts.map +1 -0
  444. package/dist/server/src/services/field-sizes.d.ts +19 -0
  445. package/dist/server/src/services/field-sizes.d.ts.map +1 -0
  446. package/dist/server/src/services/index.d.ts +266 -0
  447. package/dist/server/src/services/index.d.ts.map +1 -0
  448. package/dist/server/src/services/metrics.d.ts +9 -0
  449. package/dist/server/src/services/metrics.d.ts.map +1 -0
  450. package/dist/server/src/services/permission-checker.d.ts +54 -0
  451. package/dist/server/src/services/permission-checker.d.ts.map +1 -0
  452. package/dist/server/src/services/permission.d.ts +12 -0
  453. package/dist/server/src/services/permission.d.ts.map +1 -0
  454. package/dist/server/src/services/populate-builder.d.ts +30 -0
  455. package/dist/server/src/services/populate-builder.d.ts.map +1 -0
  456. package/dist/server/src/services/uid.d.ts +25 -0
  457. package/dist/server/src/services/uid.d.ts.map +1 -0
  458. package/dist/server/src/services/utils/configuration/attributes.d.ts +17 -0
  459. package/dist/server/src/services/utils/configuration/attributes.d.ts.map +1 -0
  460. package/dist/server/src/services/utils/configuration/index.d.ts +21 -0
  461. package/dist/server/src/services/utils/configuration/index.d.ts.map +1 -0
  462. package/dist/server/src/services/utils/configuration/layouts.d.ts +14 -0
  463. package/dist/server/src/services/utils/configuration/layouts.d.ts.map +1 -0
  464. package/dist/server/src/services/utils/configuration/metadatas.d.ts +5 -0
  465. package/dist/server/src/services/utils/configuration/metadatas.d.ts.map +1 -0
  466. package/dist/server/src/services/utils/configuration/settings.d.ts +5 -0
  467. package/dist/server/src/services/utils/configuration/settings.d.ts.map +1 -0
  468. package/dist/server/src/services/utils/count.d.ts +5 -0
  469. package/dist/server/src/services/utils/count.d.ts.map +1 -0
  470. package/dist/server/src/services/utils/draft.d.ts +11 -0
  471. package/dist/server/src/services/utils/draft.d.ts.map +1 -0
  472. package/dist/server/src/services/utils/populate.d.ts +35 -0
  473. package/dist/server/src/services/utils/populate.d.ts.map +1 -0
  474. package/dist/server/src/services/utils/store.d.ts +16 -0
  475. package/dist/server/src/services/utils/store.d.ts.map +1 -0
  476. package/dist/server/src/utils/index.d.ts +9 -0
  477. package/dist/server/src/utils/index.d.ts.map +1 -0
  478. package/dist/server/src/validation/policies/hasPermissions.d.ts +2 -0
  479. package/dist/server/src/validation/policies/hasPermissions.d.ts.map +1 -0
  480. package/dist/shared/contracts/collection-types.d.ts +330 -0
  481. package/dist/shared/contracts/collection-types.d.ts.map +1 -0
  482. package/dist/shared/contracts/components.d.ts +65 -0
  483. package/dist/shared/contracts/components.d.ts.map +1 -0
  484. package/dist/shared/contracts/content-types.d.ts +113 -0
  485. package/dist/shared/contracts/content-types.d.ts.map +1 -0
  486. package/dist/shared/contracts/history-versions.d.ts +92 -0
  487. package/dist/shared/contracts/history-versions.d.ts.map +1 -0
  488. package/dist/shared/contracts/index.d.ts +10 -0
  489. package/dist/shared/contracts/index.d.ts.map +1 -0
  490. package/dist/shared/contracts/init.d.ts +24 -0
  491. package/dist/shared/contracts/init.d.ts.map +1 -0
  492. package/dist/shared/contracts/relations.d.ts +70 -0
  493. package/dist/shared/contracts/relations.d.ts.map +1 -0
  494. package/dist/shared/contracts/review-workflows.d.ts +78 -0
  495. package/dist/shared/contracts/review-workflows.d.ts.map +1 -0
  496. package/dist/shared/contracts/single-types.d.ts +113 -0
  497. package/dist/shared/contracts/single-types.d.ts.map +1 -0
  498. package/dist/shared/contracts/uid.d.ts +48 -0
  499. package/dist/shared/contracts/uid.d.ts.map +1 -0
  500. package/dist/shared/index.d.ts +2 -0
  501. package/dist/shared/index.d.ts.map +1 -0
  502. package/dist/shared/index.js +43 -0
  503. package/dist/shared/index.js.map +1 -0
  504. package/dist/shared/index.mjs +43 -0
  505. package/dist/shared/index.mjs.map +1 -0
  506. package/package.json +113 -2
  507. package/strapi-server.js +3 -0
@@ -0,0 +1,3207 @@
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 qs = require("qs");
6
+ const reactIntl = require("react-intl");
7
+ const reactRouterDom = require("react-router-dom");
8
+ const React = require("react");
9
+ const designSystem = require("@strapi/design-system");
10
+ const styledComponents = require("styled-components");
11
+ const yup = require("yup");
12
+ const react = require("@reduxjs/toolkit/query/react");
13
+ const pipe = require("lodash/fp/pipe");
14
+ const dateFns = require("date-fns");
15
+ const toolkit = require("@reduxjs/toolkit");
16
+ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
17
+ function _interopNamespace(e) {
18
+ if (e && e.__esModule)
19
+ return e;
20
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
21
+ if (e) {
22
+ for (const k in e) {
23
+ if (k !== "default") {
24
+ const d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: () => e[k]
28
+ });
29
+ }
30
+ }
31
+ }
32
+ n.default = e;
33
+ return Object.freeze(n);
34
+ }
35
+ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
36
+ const yup__namespace = /* @__PURE__ */ _interopNamespace(yup);
37
+ const pipe__default = /* @__PURE__ */ _interopDefault(pipe);
38
+ const __variableDynamicImportRuntimeHelper = (glob, path) => {
39
+ const v = glob[path];
40
+ if (v) {
41
+ return typeof v === "function" ? v() : Promise.resolve(v);
42
+ }
43
+ return new Promise((_, reject) => {
44
+ (typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(reject.bind(null, new Error("Unknown variable dynamic import: " + path)));
45
+ });
46
+ };
47
+ const PLUGIN_ID = "content-manager";
48
+ const PERMISSIONS = [
49
+ "plugin::content-manager.explorer.create",
50
+ "plugin::content-manager.explorer.read",
51
+ "plugin::content-manager.explorer.update",
52
+ "plugin::content-manager.explorer.delete",
53
+ "plugin::content-manager.explorer.publish"
54
+ ];
55
+ const INJECTION_ZONES = {
56
+ editView: { informations: [], "right-links": [] },
57
+ listView: {
58
+ actions: [],
59
+ deleteModalAdditionalInfos: [],
60
+ publishModalAdditionalInfos: [],
61
+ unpublishModalAdditionalInfos: []
62
+ }
63
+ };
64
+ const InjectionZone = ({ area, ...props }) => {
65
+ const components = useInjectionZone(area);
66
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: components.map((component) => /* @__PURE__ */ jsxRuntime.jsx(component.Component, { ...props }, component.name)) });
67
+ };
68
+ const useInjectionZone = (area) => {
69
+ const getPlugin = strapiAdmin.useStrapiApp("useInjectionZone", (state) => state.getPlugin);
70
+ const contentManagerPlugin = getPlugin(PLUGIN_ID);
71
+ const [page, position] = area.split(".");
72
+ return contentManagerPlugin.getInjectedComponents(page, position);
73
+ };
74
+ const HistoryAction = ({ model, document }) => {
75
+ const { formatMessage } = reactIntl.useIntl();
76
+ const [{ query }] = strapiAdmin.useQueryParams();
77
+ const navigate = reactRouterDom.useNavigate();
78
+ const pluginsQueryParams = qs.stringify({ plugins: query.plugins }, { encode: false });
79
+ if (!window.strapi.features.isEnabled("cms-content-history")) {
80
+ return null;
81
+ }
82
+ return {
83
+ icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.ClockCounterClockwise, {}),
84
+ label: formatMessage({
85
+ id: "content-manager.history.document-action",
86
+ defaultMessage: "Content History"
87
+ }),
88
+ onClick: () => navigate({ pathname: "history", search: pluginsQueryParams }),
89
+ disabled: (
90
+ /**
91
+ * The user is creating a new document.
92
+ * It hasn't been saved yet, so there's no history to go to
93
+ */
94
+ !document || /**
95
+ * The document has been created but the current dimension has never been saved.
96
+ * For example, the user is creating a new locale in an existing document,
97
+ * so there's no history for the document in that locale
98
+ */
99
+ !document.id || /**
100
+ * History is only available for content types created by the user.
101
+ * These have the `api::` prefix, as opposed to the ones created by Strapi or plugins,
102
+ * which start with `admin::` or `plugin::`
103
+ */
104
+ !model.startsWith("api::")
105
+ ),
106
+ position: "header"
107
+ };
108
+ };
109
+ HistoryAction.type = "history";
110
+ const ID = "id";
111
+ const CREATED_BY_ATTRIBUTE_NAME = "createdBy";
112
+ const UPDATED_BY_ATTRIBUTE_NAME = "updatedBy";
113
+ const CREATOR_FIELDS = [CREATED_BY_ATTRIBUTE_NAME, UPDATED_BY_ATTRIBUTE_NAME];
114
+ const PUBLISHED_BY_ATTRIBUTE_NAME = "publishedBy";
115
+ const CREATED_AT_ATTRIBUTE_NAME = "createdAt";
116
+ const UPDATED_AT_ATTRIBUTE_NAME = "updatedAt";
117
+ const PUBLISHED_AT_ATTRIBUTE_NAME = "publishedAt";
118
+ const DOCUMENT_META_FIELDS = [
119
+ ID,
120
+ ...CREATOR_FIELDS,
121
+ PUBLISHED_BY_ATTRIBUTE_NAME,
122
+ CREATED_AT_ATTRIBUTE_NAME,
123
+ UPDATED_AT_ATTRIBUTE_NAME,
124
+ PUBLISHED_AT_ATTRIBUTE_NAME
125
+ ];
126
+ const ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = [
127
+ "dynamiczone",
128
+ "json",
129
+ "text",
130
+ "relation",
131
+ "component",
132
+ "boolean",
133
+ "media",
134
+ "password",
135
+ "richtext",
136
+ "timestamp",
137
+ "blocks"
138
+ ];
139
+ const SINGLE_TYPES = "single-types";
140
+ const COLLECTION_TYPES = "collection-types";
141
+ const [DocumentRBACProvider, useDocumentRBAC] = strapiAdmin.createContext(
142
+ "DocumentRBAC",
143
+ {
144
+ canCreate: false,
145
+ canCreateFields: [],
146
+ canDelete: false,
147
+ canPublish: false,
148
+ canRead: false,
149
+ canReadFields: [],
150
+ canUpdate: false,
151
+ canUpdateFields: [],
152
+ canUserAction: () => false,
153
+ isLoading: false
154
+ }
155
+ );
156
+ const DocumentRBAC = ({ children, permissions }) => {
157
+ const { slug } = reactRouterDom.useParams();
158
+ if (!slug) {
159
+ throw new Error("Cannot find the slug param in the URL");
160
+ }
161
+ const userPermissions = strapiAdmin.useAuth("DocumentRBAC", (state) => state.permissions);
162
+ const contentTypePermissions = React__namespace.useMemo(() => {
163
+ const contentTypePermissions2 = userPermissions.filter(
164
+ (permission) => permission.subject === slug
165
+ );
166
+ return contentTypePermissions2.reduce((acc, permission) => {
167
+ const [action] = permission.action.split(".").slice(-1);
168
+ return { ...acc, [action]: [permission] };
169
+ }, {});
170
+ }, [slug, userPermissions]);
171
+ const { isLoading, allowedActions } = strapiAdmin.useRBAC(contentTypePermissions, permissions ?? void 0);
172
+ const canCreateFields = !isLoading && allowedActions.canCreate ? extractAndDedupeFields(contentTypePermissions.create) : [];
173
+ const canReadFields = !isLoading && allowedActions.canRead ? extractAndDedupeFields(contentTypePermissions.read) : [];
174
+ const canUpdateFields = !isLoading && allowedActions.canUpdate ? extractAndDedupeFields(contentTypePermissions.update) : [];
175
+ const canUserAction = React__namespace.useCallback(
176
+ (fieldName, fieldsUserCanAction, fieldType) => {
177
+ const name = removeNumericalStrings(fieldName.split("."));
178
+ const componentFieldNames = fieldsUserCanAction.filter((field) => field.split(".").length > 1);
179
+ if (fieldType === "component") {
180
+ const componentOrDynamicZoneFields = componentFieldNames.map((field) => field.split("."));
181
+ return componentOrDynamicZoneFields.some((field) => {
182
+ return field.includes(fieldName);
183
+ });
184
+ }
185
+ if (name.length > 1) {
186
+ return componentFieldNames.includes(name.join("."));
187
+ }
188
+ return fieldsUserCanAction.includes(fieldName);
189
+ },
190
+ []
191
+ );
192
+ if (isLoading) {
193
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
194
+ }
195
+ return /* @__PURE__ */ jsxRuntime.jsx(
196
+ DocumentRBACProvider,
197
+ {
198
+ isLoading,
199
+ canCreateFields,
200
+ canReadFields,
201
+ canUpdateFields,
202
+ canUserAction,
203
+ ...allowedActions,
204
+ children
205
+ }
206
+ );
207
+ };
208
+ const extractAndDedupeFields = (permissions = []) => permissions.flatMap((permission) => permission.properties?.fields).filter(
209
+ (field, index2, arr) => arr.indexOf(field) === index2 && typeof field === "string"
210
+ );
211
+ const removeNumericalStrings = (arr) => arr.filter((item) => isNaN(Number(item)));
212
+ const buildValidParams = (query) => {
213
+ if (!query)
214
+ return query;
215
+ const { plugins: _, ...validQueryParams } = {
216
+ ...query,
217
+ ...Object.values(query?.plugins ?? {}).reduce(
218
+ (acc, current) => Object.assign(acc, current),
219
+ {}
220
+ )
221
+ };
222
+ if ("_q" in validQueryParams) {
223
+ validQueryParams._q = encodeURIComponent(validQueryParams._q);
224
+ }
225
+ return validQueryParams;
226
+ };
227
+ const fetchBaseQuery = () => async (query, { signal }) => {
228
+ try {
229
+ const { get, post, del, put } = strapiAdmin.getFetchClient();
230
+ if (typeof query === "string") {
231
+ const result = await get(query, {
232
+ signal
233
+ });
234
+ return { data: result.data };
235
+ } else {
236
+ const { url, method = "GET", data, config } = query;
237
+ if (method === "POST") {
238
+ const result2 = await post(url, data, {
239
+ ...config,
240
+ signal
241
+ });
242
+ return { data: result2.data };
243
+ }
244
+ if (method === "DELETE") {
245
+ const result2 = await del(url, {
246
+ ...config,
247
+ signal
248
+ });
249
+ return { data: result2.data };
250
+ }
251
+ if (method === "PUT") {
252
+ const result2 = await put(url, data, {
253
+ ...config,
254
+ signal
255
+ });
256
+ return { data: result2.data };
257
+ }
258
+ const result = await get(url, {
259
+ ...config,
260
+ signal
261
+ });
262
+ return { data: result.data };
263
+ }
264
+ } catch (err) {
265
+ if (strapiAdmin.isFetchError(err)) {
266
+ if (typeof err.response?.data === "object" && err.response?.data !== null && "error" in err.response?.data) {
267
+ return { data: void 0, error: err.response?.data.error };
268
+ } else {
269
+ return {
270
+ data: void 0,
271
+ error: {
272
+ name: "UnknownError",
273
+ message: "There was an unknown error response from the API",
274
+ details: err.response,
275
+ status: err.status
276
+ }
277
+ };
278
+ }
279
+ }
280
+ const error = err;
281
+ return {
282
+ data: void 0,
283
+ error: {
284
+ name: error.name,
285
+ message: error.message,
286
+ stack: error.stack
287
+ }
288
+ };
289
+ }
290
+ };
291
+ const isBaseQueryError = (error) => {
292
+ return error.name !== void 0;
293
+ };
294
+ const contentManagerApi = react.createApi({
295
+ reducerPath: "contentManagerApi",
296
+ baseQuery: fetchBaseQuery(),
297
+ tagTypes: [
298
+ "ComponentConfiguration",
299
+ "ContentTypesConfiguration",
300
+ "ContentTypeSettings",
301
+ "Document",
302
+ "InitialData",
303
+ "HistoryVersion",
304
+ "Relations"
305
+ ],
306
+ endpoints: () => ({})
307
+ });
308
+ const documentApi = contentManagerApi.injectEndpoints({
309
+ endpoints: (builder) => ({
310
+ autoCloneDocument: builder.mutation({
311
+ query: ({ model, sourceId, query }) => ({
312
+ url: `/content-manager/collection-types/${model}/auto-clone/${sourceId}`,
313
+ method: "POST",
314
+ config: {
315
+ params: query
316
+ }
317
+ }),
318
+ invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
319
+ }),
320
+ cloneDocument: builder.mutation({
321
+ query: ({ model, sourceId, data, params }) => ({
322
+ url: `/content-manager/collection-types/${model}/clone/${sourceId}`,
323
+ method: "POST",
324
+ data,
325
+ config: {
326
+ params
327
+ }
328
+ }),
329
+ invalidatesTags: (_result, _error, { model }) => [{ type: "Document", id: `${model}_LIST` }]
330
+ }),
331
+ /**
332
+ * Creates a new collection-type document. This should ONLY be used for collection-types.
333
+ * single-types should always be using `updateDocument` since they always exist.
334
+ */
335
+ createDocument: builder.mutation({
336
+ query: ({ model, data, params }) => ({
337
+ url: `/content-manager/collection-types/${model}`,
338
+ method: "POST",
339
+ data,
340
+ config: {
341
+ params
342
+ }
343
+ }),
344
+ invalidatesTags: (result, _error, { model }) => [
345
+ { type: "Document", id: `${model}_LIST` },
346
+ "Relations"
347
+ ]
348
+ }),
349
+ deleteDocument: builder.mutation({
350
+ query: ({ collectionType, model, documentId, params }) => ({
351
+ url: `/content-manager/${collectionType}/${model}${collectionType !== SINGLE_TYPES && documentId ? `/${documentId}` : ""}`,
352
+ method: "DELETE",
353
+ config: {
354
+ params
355
+ }
356
+ }),
357
+ invalidatesTags: (_result, _error, { collectionType, model }) => [
358
+ { type: "Document", id: collectionType !== SINGLE_TYPES ? `${model}_LIST` : model }
359
+ ]
360
+ }),
361
+ deleteManyDocuments: builder.mutation({
362
+ query: ({ model, ...body }) => ({
363
+ url: `/content-manager/collection-types/${model}/actions/bulkDelete`,
364
+ method: "POST",
365
+ data: body
366
+ }),
367
+ invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
368
+ }),
369
+ discardDocument: builder.mutation({
370
+ query: ({ collectionType, model, documentId, params }) => ({
371
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/discard` : `/content-manager/${collectionType}/${model}/actions/discard`,
372
+ method: "POST",
373
+ config: {
374
+ params
375
+ }
376
+ }),
377
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
378
+ return [
379
+ {
380
+ type: "Document",
381
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
382
+ },
383
+ { type: "Document", id: `${model}_LIST` },
384
+ "Relations"
385
+ ];
386
+ }
387
+ }),
388
+ /**
389
+ * Gets all documents of a collection type or single type.
390
+ * By passing different params you can get different results e.g. only published documents or 'es' documents.
391
+ */
392
+ getAllDocuments: builder.query({
393
+ query: ({ model, params }) => ({
394
+ url: `/content-manager/collection-types/${model}`,
395
+ method: "GET",
396
+ config: {
397
+ params
398
+ }
399
+ }),
400
+ providesTags: (result, _error, arg) => {
401
+ return [
402
+ { type: "Document", id: `${arg.model}_LIST` },
403
+ ...result?.results.map(({ documentId }) => ({
404
+ type: "Document",
405
+ id: `${arg.model}_${documentId}`
406
+ })) ?? []
407
+ ];
408
+ }
409
+ }),
410
+ getDraftRelationCount: builder.query({
411
+ query: ({ collectionType, model, documentId, params }) => ({
412
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/countDraftRelations` : `/content-manager/${collectionType}/${model}/actions/countDraftRelations`,
413
+ method: "GET",
414
+ config: {
415
+ params
416
+ }
417
+ })
418
+ }),
419
+ getDocument: builder.query({
420
+ // @ts-expect-error – TODO: fix ts error where data unknown doesn't work with response via an assertion?
421
+ queryFn: async ({ collectionType, model, documentId, params }, _api, _extraOpts, baseQuery) => {
422
+ const res = await baseQuery({
423
+ url: `/content-manager/${collectionType}/${model}${documentId ? `/${documentId}` : ""}`,
424
+ method: "GET",
425
+ config: {
426
+ params
427
+ }
428
+ });
429
+ if (res.error && res.error.name === "NotFoundError" && collectionType === SINGLE_TYPES) {
430
+ return { data: { document: void 0 }, error: void 0 };
431
+ }
432
+ return res;
433
+ },
434
+ providesTags: (result, _error, { collectionType, model, documentId }) => {
435
+ return [
436
+ // we prefer the result's id because we don't fetch single-types with an ID.
437
+ {
438
+ type: "Document",
439
+ id: collectionType !== SINGLE_TYPES ? `${model}_${result && "documentId" in result ? result.documentId : documentId}` : model
440
+ }
441
+ ];
442
+ }
443
+ }),
444
+ getManyDraftRelationCount: builder.query({
445
+ query: ({ model, ...params }) => ({
446
+ url: `/content-manager/collection-types/${model}/actions/countManyEntriesDraftRelations`,
447
+ method: "GET",
448
+ config: {
449
+ params
450
+ }
451
+ }),
452
+ transformResponse: (response) => response.data
453
+ }),
454
+ /**
455
+ * This endpoint will either create or update documents at the same time as publishing.
456
+ */
457
+ publishDocument: builder.mutation({
458
+ query: ({ collectionType, model, documentId, params, data }) => ({
459
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/publish` : `/content-manager/${collectionType}/${model}/actions/publish`,
460
+ method: "POST",
461
+ data,
462
+ config: {
463
+ params
464
+ }
465
+ }),
466
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
467
+ return [
468
+ {
469
+ type: "Document",
470
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
471
+ },
472
+ { type: "Document", id: `${model}_LIST` },
473
+ "Relations"
474
+ ];
475
+ }
476
+ }),
477
+ publishManyDocuments: builder.mutation({
478
+ query: ({ model, ...body }) => ({
479
+ url: `/content-manager/collection-types/${model}/actions/bulkPublish`,
480
+ method: "POST",
481
+ data: body
482
+ }),
483
+ invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
484
+ }),
485
+ updateDocument: builder.mutation({
486
+ query: ({ collectionType, model, documentId, data, params }) => ({
487
+ url: `/content-manager/${collectionType}/${model}${documentId ? `/${documentId}` : ""}`,
488
+ method: "PUT",
489
+ data,
490
+ config: {
491
+ params
492
+ }
493
+ }),
494
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
495
+ return [
496
+ {
497
+ type: "Document",
498
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
499
+ },
500
+ "Relations"
501
+ ];
502
+ }
503
+ }),
504
+ unpublishDocument: builder.mutation({
505
+ query: ({ collectionType, model, documentId, params, data }) => ({
506
+ url: documentId ? `/content-manager/${collectionType}/${model}/${documentId}/actions/unpublish` : `/content-manager/${collectionType}/${model}/actions/unpublish`,
507
+ method: "POST",
508
+ data,
509
+ config: {
510
+ params
511
+ }
512
+ }),
513
+ invalidatesTags: (_result, _error, { collectionType, model, documentId }) => {
514
+ return [
515
+ {
516
+ type: "Document",
517
+ id: collectionType !== SINGLE_TYPES ? `${model}_${documentId}` : model
518
+ }
519
+ ];
520
+ }
521
+ }),
522
+ unpublishManyDocuments: builder.mutation({
523
+ query: ({ model, ...body }) => ({
524
+ url: `/content-manager/collection-types/${model}/actions/bulkUnpublish`,
525
+ method: "POST",
526
+ data: body
527
+ }),
528
+ invalidatesTags: (_res, _error, { model, documentIds }) => documentIds.map((id) => ({ type: "Document", id: `${model}_${id}` }))
529
+ })
530
+ })
531
+ });
532
+ const {
533
+ useAutoCloneDocumentMutation,
534
+ useCloneDocumentMutation,
535
+ useCreateDocumentMutation,
536
+ useDeleteDocumentMutation,
537
+ useDeleteManyDocumentsMutation,
538
+ useDiscardDocumentMutation,
539
+ useGetAllDocumentsQuery,
540
+ useLazyGetDocumentQuery,
541
+ useGetDocumentQuery,
542
+ useLazyGetDraftRelationCountQuery,
543
+ useGetManyDraftRelationCountQuery,
544
+ usePublishDocumentMutation,
545
+ usePublishManyDocumentsMutation,
546
+ useUpdateDocumentMutation,
547
+ useUnpublishDocumentMutation,
548
+ useUnpublishManyDocumentsMutation
549
+ } = documentApi;
550
+ const createYupSchema = (attributes = {}, components = {}) => {
551
+ const createModelSchema = (attributes2) => yup__namespace.object().shape(
552
+ Object.entries(attributes2).reduce((acc, [name, attribute]) => {
553
+ if (DOCUMENT_META_FIELDS.includes(name)) {
554
+ return acc;
555
+ }
556
+ const validations = [
557
+ addRequiredValidation,
558
+ addMinLengthValidation,
559
+ addMaxLengthValidation,
560
+ addMinValidation,
561
+ addMaxValidation,
562
+ addRegexValidation
563
+ ].map((fn) => fn(attribute));
564
+ const transformSchema = pipe__default.default(...validations);
565
+ switch (attribute.type) {
566
+ case "component": {
567
+ const { attributes: attributes3 } = components[attribute.component];
568
+ if (attribute.repeatable) {
569
+ return {
570
+ ...acc,
571
+ [name]: transformSchema(
572
+ yup__namespace.array().of(createModelSchema(attributes3).nullable(false))
573
+ )
574
+ };
575
+ } else {
576
+ return {
577
+ ...acc,
578
+ [name]: transformSchema(createModelSchema(attributes3))
579
+ };
580
+ }
581
+ }
582
+ case "dynamiczone":
583
+ return {
584
+ ...acc,
585
+ [name]: transformSchema(
586
+ yup__namespace.array().of(
587
+ yup__namespace.lazy(
588
+ (data) => {
589
+ const { attributes: attributes3 } = components[data.__component];
590
+ return yup__namespace.object().shape({
591
+ __component: yup__namespace.string().required().oneOf(Object.keys(components))
592
+ }).nullable(false).concat(createModelSchema(attributes3));
593
+ }
594
+ )
595
+ )
596
+ )
597
+ };
598
+ case "relation":
599
+ return {
600
+ ...acc,
601
+ [name]: transformSchema(
602
+ yup__namespace.array().of(
603
+ yup__namespace.object().shape({
604
+ id: yup__namespace.string().required()
605
+ })
606
+ )
607
+ )
608
+ };
609
+ default:
610
+ return {
611
+ ...acc,
612
+ [name]: transformSchema(createAttributeSchema(attribute))
613
+ };
614
+ }
615
+ }, {})
616
+ ).default(null);
617
+ return createModelSchema(attributes);
618
+ };
619
+ const createAttributeSchema = (attribute) => {
620
+ switch (attribute.type) {
621
+ case "biginteger":
622
+ return yup__namespace.string().matches(/^-?\d*$/);
623
+ case "boolean":
624
+ return yup__namespace.boolean();
625
+ case "blocks":
626
+ return yup__namespace.mixed().test("isBlocks", strapiAdmin.translatedErrors.json, (value) => {
627
+ if (!value || Array.isArray(value)) {
628
+ return true;
629
+ } else {
630
+ return false;
631
+ }
632
+ });
633
+ case "decimal":
634
+ case "float":
635
+ case "integer":
636
+ return yup__namespace.number();
637
+ case "email":
638
+ return yup__namespace.string().email(strapiAdmin.translatedErrors.email);
639
+ case "enumeration":
640
+ return yup__namespace.string().oneOf([...attribute.enum, null]);
641
+ case "json":
642
+ return yup__namespace.mixed().test("isJSON", strapiAdmin.translatedErrors.json, (value) => {
643
+ if (!value || typeof value === "string" && value.length === 0) {
644
+ return true;
645
+ }
646
+ try {
647
+ JSON.parse(value);
648
+ return true;
649
+ } catch (err) {
650
+ return false;
651
+ }
652
+ });
653
+ case "password":
654
+ case "richtext":
655
+ case "string":
656
+ case "text":
657
+ return yup__namespace.string();
658
+ case "uid":
659
+ return yup__namespace.string().matches(/^[A-Za-z0-9-_.~]*$/);
660
+ default:
661
+ return yup__namespace.mixed();
662
+ }
663
+ };
664
+ const addRequiredValidation = (attribute) => (schema) => {
665
+ if (attribute.required) {
666
+ return schema.required({
667
+ id: strapiAdmin.translatedErrors.required.id,
668
+ defaultMessage: "This field is required."
669
+ });
670
+ }
671
+ return schema.nullable();
672
+ };
673
+ const addMinLengthValidation = (attribute) => (schema) => {
674
+ if ("minLength" in attribute && attribute.minLength && Number.isInteger(attribute.minLength) && "min" in schema) {
675
+ return schema.min(attribute.minLength, {
676
+ ...strapiAdmin.translatedErrors.minLength,
677
+ values: {
678
+ min: attribute.minLength
679
+ }
680
+ });
681
+ }
682
+ return schema;
683
+ };
684
+ const addMaxLengthValidation = (attribute) => (schema) => {
685
+ if ("maxLength" in attribute && attribute.maxLength && Number.isInteger(attribute.maxLength) && "max" in schema) {
686
+ return schema.max(attribute.maxLength, {
687
+ ...strapiAdmin.translatedErrors.maxLength,
688
+ values: {
689
+ max: attribute.maxLength
690
+ }
691
+ });
692
+ }
693
+ return schema;
694
+ };
695
+ const addMinValidation = (attribute) => (schema) => {
696
+ if ("min" in attribute) {
697
+ const min = toInteger(attribute.min);
698
+ if ("min" in schema && min) {
699
+ return schema.min(min, {
700
+ ...strapiAdmin.translatedErrors.min,
701
+ values: {
702
+ min
703
+ }
704
+ });
705
+ }
706
+ }
707
+ return schema;
708
+ };
709
+ const addMaxValidation = (attribute) => (schema) => {
710
+ if ("max" in attribute) {
711
+ const max = toInteger(attribute.max);
712
+ if ("max" in schema && max) {
713
+ return schema.max(max, {
714
+ ...strapiAdmin.translatedErrors.max,
715
+ values: {
716
+ max
717
+ }
718
+ });
719
+ }
720
+ }
721
+ return schema;
722
+ };
723
+ const toInteger = (val) => {
724
+ if (typeof val === "number" || val === void 0) {
725
+ return val;
726
+ } else {
727
+ const num = Number(val);
728
+ return isNaN(num) ? void 0 : num;
729
+ }
730
+ };
731
+ const addRegexValidation = (attribute) => (schema) => {
732
+ if ("regex" in attribute && attribute.regex && "matches" in schema) {
733
+ return schema.matches(new RegExp(attribute.regex), {
734
+ message: {
735
+ id: strapiAdmin.translatedErrors.regex.id,
736
+ defaultMessage: "The value does not match the defined pattern."
737
+ },
738
+ excludeEmptyString: !attribute.required
739
+ });
740
+ }
741
+ return schema;
742
+ };
743
+ const extractValuesFromYupError = (errorType, errorParams) => {
744
+ if (!errorType || !errorParams) {
745
+ return {};
746
+ }
747
+ return {
748
+ [errorType]: errorParams[errorType]
749
+ };
750
+ };
751
+ const getInnerErrors = (error) => (error?.inner || []).reduce((acc, currentError) => {
752
+ if (currentError.path) {
753
+ acc[currentError.path.split("[").join(".").split("]").join("")] = {
754
+ id: currentError.message,
755
+ defaultMessage: currentError.message,
756
+ values: extractValuesFromYupError(currentError?.type, currentError?.params)
757
+ };
758
+ }
759
+ return acc;
760
+ }, {});
761
+ const initApi = contentManagerApi.injectEndpoints({
762
+ endpoints: (builder) => ({
763
+ getInitialData: builder.query({
764
+ query: () => "/content-manager/init",
765
+ transformResponse: (response) => response.data,
766
+ providesTags: ["InitialData"]
767
+ })
768
+ })
769
+ });
770
+ const { useGetInitialDataQuery } = initApi;
771
+ const useContentTypeSchema = (model) => {
772
+ const { toggleNotification } = strapiAdmin.useNotification();
773
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
774
+ const { components, contentType, contentTypes, error, isLoading, isFetching } = useGetInitialDataQuery(void 0, {
775
+ selectFromResult: (res) => {
776
+ const contentType2 = res.data?.contentTypes.find((ct) => ct.uid === model);
777
+ const componentsByKey = res.data?.components.reduce(
778
+ (acc, component) => {
779
+ acc[component.uid] = component;
780
+ return acc;
781
+ },
782
+ {}
783
+ );
784
+ const components2 = extractContentTypeComponents(contentType2?.attributes, componentsByKey);
785
+ return {
786
+ isLoading: res.isLoading,
787
+ isFetching: res.isFetching,
788
+ error: res.error,
789
+ components: Object.keys(components2).length === 0 ? void 0 : components2,
790
+ contentType: contentType2,
791
+ contentTypes: res.data?.contentTypes ?? []
792
+ };
793
+ }
794
+ });
795
+ React__namespace.useEffect(() => {
796
+ if (error) {
797
+ toggleNotification({
798
+ type: "danger",
799
+ message: formatAPIError(error)
800
+ });
801
+ }
802
+ }, [toggleNotification, error, formatAPIError]);
803
+ return {
804
+ // This must be memoized to avoid inifiinite re-renders where the empty object is different everytime.
805
+ components: React__namespace.useMemo(() => components ?? {}, [components]),
806
+ schema: contentType,
807
+ schemas: contentTypes,
808
+ isLoading: isLoading || isFetching
809
+ };
810
+ };
811
+ const extractContentTypeComponents = (attributes = {}, allComponents = {}) => {
812
+ const getComponents = (attributes2) => {
813
+ return attributes2.reduce((acc, attribute) => {
814
+ if (attribute.type === "component") {
815
+ const componentAttributes = Object.values(
816
+ allComponents[attribute.component]?.attributes ?? {}
817
+ );
818
+ acc.push(attribute.component, ...getComponents(componentAttributes));
819
+ } else if (attribute.type === "dynamiczone") {
820
+ acc.push(
821
+ ...attribute.components,
822
+ ...attribute.components.flatMap((componentUid) => {
823
+ const componentAttributes = Object.values(
824
+ allComponents[componentUid]?.attributes ?? {}
825
+ );
826
+ return getComponents(componentAttributes);
827
+ })
828
+ );
829
+ }
830
+ return acc;
831
+ }, []);
832
+ };
833
+ const componentUids = getComponents(Object.values(attributes));
834
+ const uniqueComponentUids = [...new Set(componentUids)];
835
+ const componentsByKey = uniqueComponentUids.reduce((acc, uid) => {
836
+ acc[uid] = allComponents[uid];
837
+ return acc;
838
+ }, {});
839
+ return componentsByKey;
840
+ };
841
+ const useDocument = (args, opts) => {
842
+ const { toggleNotification } = strapiAdmin.useNotification();
843
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
844
+ const {
845
+ currentData: data,
846
+ isLoading: isLoadingDocument,
847
+ isFetching: isFetchingDocument,
848
+ error
849
+ } = useGetDocumentQuery(args, opts);
850
+ const { components, schema, isLoading: isLoadingSchema } = useContentTypeSchema(args.model);
851
+ React__namespace.useEffect(() => {
852
+ if (error) {
853
+ toggleNotification({
854
+ type: "danger",
855
+ message: formatAPIError(error)
856
+ });
857
+ }
858
+ }, [toggleNotification, error, formatAPIError, args.collectionType]);
859
+ const validationSchema = React__namespace.useMemo(() => {
860
+ if (!schema) {
861
+ return null;
862
+ }
863
+ return createYupSchema(schema.attributes, components);
864
+ }, [schema, components]);
865
+ const validate = React__namespace.useCallback(
866
+ (document) => {
867
+ if (!validationSchema) {
868
+ throw new Error(
869
+ "There is no validation schema generated, this is likely due to the schema not being loaded yet."
870
+ );
871
+ }
872
+ try {
873
+ validationSchema.validateSync(document, { abortEarly: false, strict: true });
874
+ return null;
875
+ } catch (error2) {
876
+ if (error2 instanceof yup.ValidationError) {
877
+ return getInnerErrors(error2);
878
+ }
879
+ throw error2;
880
+ }
881
+ },
882
+ [validationSchema]
883
+ );
884
+ const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;
885
+ return {
886
+ components,
887
+ document: data?.data,
888
+ meta: data?.meta,
889
+ isLoading,
890
+ schema,
891
+ validate
892
+ };
893
+ };
894
+ const useDoc = () => {
895
+ const { id, slug, collectionType, origin } = reactRouterDom.useParams();
896
+ const [{ query }] = strapiAdmin.useQueryParams();
897
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
898
+ if (!collectionType) {
899
+ throw new Error("Could not find collectionType in url params");
900
+ }
901
+ if (!slug) {
902
+ throw new Error("Could not find model in url params");
903
+ }
904
+ return {
905
+ collectionType,
906
+ model: slug,
907
+ id: origin || id === "create" ? void 0 : id,
908
+ ...useDocument(
909
+ { documentId: origin || id, model: slug, collectionType, params },
910
+ {
911
+ skip: id === "create" || !origin && !id && collectionType !== SINGLE_TYPES
912
+ }
913
+ )
914
+ };
915
+ };
916
+ const prefixPluginTranslations = (trad, pluginId) => {
917
+ if (!pluginId) {
918
+ throw new TypeError("pluginId can't be empty");
919
+ }
920
+ return Object.keys(trad).reduce((acc, current) => {
921
+ acc[`${pluginId}.${current}`] = trad[current];
922
+ return acc;
923
+ }, {});
924
+ };
925
+ const getTranslation = (id) => `content-manager.${id}`;
926
+ const DEFAULT_UNEXPECTED_ERROR_MSG = {
927
+ id: "notification.error",
928
+ defaultMessage: "An error occurred, please try again"
929
+ };
930
+ const useDocumentActions = () => {
931
+ const { toggleNotification } = strapiAdmin.useNotification();
932
+ const { formatMessage } = reactIntl.useIntl();
933
+ const { trackUsage } = strapiAdmin.useTracking();
934
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
935
+ const [deleteDocument] = useDeleteDocumentMutation();
936
+ const _delete = React__namespace.useCallback(
937
+ async ({ collectionType, model, documentId, params }, trackerProperty) => {
938
+ try {
939
+ trackUsage("willDeleteEntry", trackerProperty);
940
+ const res = await deleteDocument({
941
+ collectionType,
942
+ model,
943
+ documentId,
944
+ params
945
+ });
946
+ if ("error" in res) {
947
+ toggleNotification({
948
+ type: "danger",
949
+ message: formatAPIError(res.error)
950
+ });
951
+ return { error: res.error };
952
+ }
953
+ toggleNotification({
954
+ type: "success",
955
+ message: formatMessage({
956
+ id: getTranslation("success.record.delete"),
957
+ defaultMessage: "Deleted document"
958
+ })
959
+ });
960
+ trackUsage("didDeleteEntry", trackerProperty);
961
+ return res.data;
962
+ } catch (err) {
963
+ toggleNotification({
964
+ type: "danger",
965
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
966
+ });
967
+ trackUsage("didNotDeleteEntry", { error: err, ...trackerProperty });
968
+ throw err;
969
+ }
970
+ },
971
+ [trackUsage, deleteDocument, toggleNotification, formatMessage, formatAPIError]
972
+ );
973
+ const [discardDocument] = useDiscardDocumentMutation();
974
+ const discard = React__namespace.useCallback(
975
+ async ({ collectionType, model, documentId }) => {
976
+ try {
977
+ const res = await discardDocument({
978
+ collectionType,
979
+ model,
980
+ documentId
981
+ });
982
+ if ("error" in res) {
983
+ toggleNotification({
984
+ type: "danger",
985
+ message: formatAPIError(res.error)
986
+ });
987
+ return { error: res.error };
988
+ }
989
+ toggleNotification({
990
+ type: "success",
991
+ message: formatMessage({
992
+ id: "content-manager.success.record.discard",
993
+ defaultMessage: "Changes discarded"
994
+ })
995
+ });
996
+ return res.data;
997
+ } catch (err) {
998
+ toggleNotification({
999
+ type: "danger",
1000
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1001
+ });
1002
+ throw err;
1003
+ }
1004
+ },
1005
+ [discardDocument, formatAPIError, formatMessage, toggleNotification]
1006
+ );
1007
+ const [publishDocument] = usePublishDocumentMutation();
1008
+ const publish = React__namespace.useCallback(
1009
+ async ({ collectionType, model, documentId, params }, data) => {
1010
+ try {
1011
+ trackUsage("willPublishEntry");
1012
+ const res = await publishDocument({
1013
+ collectionType,
1014
+ model,
1015
+ documentId,
1016
+ data,
1017
+ params
1018
+ });
1019
+ if ("error" in res) {
1020
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1021
+ return { error: res.error };
1022
+ }
1023
+ trackUsage("didPublishEntry");
1024
+ toggleNotification({
1025
+ type: "success",
1026
+ message: formatMessage({
1027
+ id: getTranslation("success.record.publish"),
1028
+ defaultMessage: "Published document"
1029
+ })
1030
+ });
1031
+ return res.data;
1032
+ } catch (err) {
1033
+ toggleNotification({
1034
+ type: "danger",
1035
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1036
+ });
1037
+ throw err;
1038
+ }
1039
+ },
1040
+ [trackUsage, publishDocument, toggleNotification, formatMessage, formatAPIError]
1041
+ );
1042
+ const [updateDocument] = useUpdateDocumentMutation();
1043
+ const update = React__namespace.useCallback(
1044
+ async ({ collectionType, model, documentId, params }, data, trackerProperty) => {
1045
+ try {
1046
+ trackUsage("willEditEntry", trackerProperty);
1047
+ const res = await updateDocument({
1048
+ collectionType,
1049
+ model,
1050
+ documentId,
1051
+ data,
1052
+ params
1053
+ });
1054
+ if ("error" in res) {
1055
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1056
+ trackUsage("didNotEditEntry", { error: res.error, ...trackerProperty });
1057
+ return { error: res.error };
1058
+ }
1059
+ trackUsage("didEditEntry", trackerProperty);
1060
+ toggleNotification({
1061
+ type: "success",
1062
+ message: formatMessage({
1063
+ id: getTranslation("success.record.save"),
1064
+ defaultMessage: "Saved document"
1065
+ })
1066
+ });
1067
+ return res.data;
1068
+ } catch (err) {
1069
+ trackUsage("didNotEditEntry", { error: err, ...trackerProperty });
1070
+ toggleNotification({
1071
+ type: "danger",
1072
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1073
+ });
1074
+ throw err;
1075
+ }
1076
+ },
1077
+ [trackUsage, updateDocument, toggleNotification, formatMessage, formatAPIError]
1078
+ );
1079
+ const [unpublishDocument] = useUnpublishDocumentMutation();
1080
+ const unpublish = React__namespace.useCallback(
1081
+ async ({ collectionType, model, documentId, params }, discardDraft = false) => {
1082
+ try {
1083
+ trackUsage("willUnpublishEntry");
1084
+ const res = await unpublishDocument({
1085
+ collectionType,
1086
+ model,
1087
+ documentId,
1088
+ params,
1089
+ data: {
1090
+ discardDraft
1091
+ }
1092
+ });
1093
+ if ("error" in res) {
1094
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1095
+ return { error: res.error };
1096
+ }
1097
+ trackUsage("didUnpublishEntry");
1098
+ toggleNotification({
1099
+ type: "success",
1100
+ message: formatMessage({
1101
+ id: getTranslation("success.record.unpublish"),
1102
+ defaultMessage: "Unpublished document"
1103
+ })
1104
+ });
1105
+ return res.data;
1106
+ } catch (err) {
1107
+ toggleNotification({
1108
+ type: "danger",
1109
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1110
+ });
1111
+ throw err;
1112
+ }
1113
+ },
1114
+ [trackUsage, unpublishDocument, toggleNotification, formatMessage, formatAPIError]
1115
+ );
1116
+ const [createDocument] = useCreateDocumentMutation();
1117
+ const create = React__namespace.useCallback(
1118
+ async ({ model, params }, data, trackerProperty) => {
1119
+ try {
1120
+ const res = await createDocument({
1121
+ model,
1122
+ data,
1123
+ params
1124
+ });
1125
+ if ("error" in res) {
1126
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1127
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1128
+ return { error: res.error };
1129
+ }
1130
+ trackUsage("didCreateEntry", trackerProperty);
1131
+ toggleNotification({
1132
+ type: "success",
1133
+ message: formatMessage({
1134
+ id: getTranslation("success.record.save"),
1135
+ defaultMessage: "Saved document"
1136
+ })
1137
+ });
1138
+ return res.data;
1139
+ } catch (err) {
1140
+ toggleNotification({
1141
+ type: "danger",
1142
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1143
+ });
1144
+ trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1145
+ throw err;
1146
+ }
1147
+ },
1148
+ [createDocument, formatAPIError, formatMessage, toggleNotification, trackUsage]
1149
+ );
1150
+ const [autoCloneDocument] = useAutoCloneDocumentMutation();
1151
+ const autoClone = React__namespace.useCallback(
1152
+ async ({ model, sourceId }) => {
1153
+ try {
1154
+ const res = await autoCloneDocument({
1155
+ model,
1156
+ sourceId
1157
+ });
1158
+ if ("error" in res) {
1159
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1160
+ return { error: res.error };
1161
+ }
1162
+ toggleNotification({
1163
+ type: "success",
1164
+ message: formatMessage({
1165
+ id: getTranslation("success.record.clone"),
1166
+ defaultMessage: "Cloned document"
1167
+ })
1168
+ });
1169
+ return res.data;
1170
+ } catch (err) {
1171
+ toggleNotification({
1172
+ type: "danger",
1173
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1174
+ });
1175
+ throw err;
1176
+ }
1177
+ },
1178
+ [autoCloneDocument, formatAPIError, formatMessage, toggleNotification]
1179
+ );
1180
+ const [cloneDocument] = useCloneDocumentMutation();
1181
+ const clone = React__namespace.useCallback(
1182
+ async ({ model, documentId, params }, body, trackerProperty) => {
1183
+ try {
1184
+ const { id: _id, ...restBody } = body;
1185
+ const res = await cloneDocument({
1186
+ model,
1187
+ sourceId: documentId,
1188
+ data: restBody,
1189
+ params
1190
+ });
1191
+ if ("error" in res) {
1192
+ toggleNotification({ type: "danger", message: formatAPIError(res.error) });
1193
+ trackUsage("didNotCreateEntry", { error: res.error, ...trackerProperty });
1194
+ return { error: res.error };
1195
+ }
1196
+ trackUsage("didCreateEntry", trackerProperty);
1197
+ toggleNotification({
1198
+ type: "success",
1199
+ message: formatMessage({
1200
+ id: getTranslation("success.record.clone"),
1201
+ defaultMessage: "Cloned document"
1202
+ })
1203
+ });
1204
+ return res.data;
1205
+ } catch (err) {
1206
+ toggleNotification({
1207
+ type: "danger",
1208
+ message: formatMessage(DEFAULT_UNEXPECTED_ERROR_MSG)
1209
+ });
1210
+ trackUsage("didNotCreateEntry", { error: err, ...trackerProperty });
1211
+ throw err;
1212
+ }
1213
+ },
1214
+ [cloneDocument, trackUsage, toggleNotification, formatMessage, formatAPIError]
1215
+ );
1216
+ const [getDoc] = useLazyGetDocumentQuery();
1217
+ const getDocument = React__namespace.useCallback(
1218
+ async (args) => {
1219
+ const { data } = await getDoc(args);
1220
+ return data;
1221
+ },
1222
+ [getDoc]
1223
+ );
1224
+ return {
1225
+ autoClone,
1226
+ clone,
1227
+ create,
1228
+ delete: _delete,
1229
+ discard,
1230
+ getDocument,
1231
+ publish,
1232
+ unpublish,
1233
+ update
1234
+ };
1235
+ };
1236
+ const ProtectedHistoryPage = React.lazy(
1237
+ () => Promise.resolve().then(() => require("./History-DtHjQuqM.js")).then((mod) => ({ default: mod.ProtectedHistoryPage }))
1238
+ );
1239
+ const routes$1 = [
1240
+ {
1241
+ path: ":collectionType/:slug/:id/history",
1242
+ Component: ProtectedHistoryPage
1243
+ },
1244
+ {
1245
+ path: ":collectionType/:slug/history",
1246
+ Component: ProtectedHistoryPage
1247
+ }
1248
+ ];
1249
+ const ProtectedEditViewPage = React.lazy(
1250
+ () => Promise.resolve().then(() => require("./EditViewPage-CXXue16T.js")).then((mod) => ({ default: mod.ProtectedEditViewPage }))
1251
+ );
1252
+ const ProtectedListViewPage = React.lazy(
1253
+ () => Promise.resolve().then(() => require("./ListViewPage-CExWwa4S.js")).then((mod) => ({ default: mod.ProtectedListViewPage }))
1254
+ );
1255
+ const ProtectedListConfiguration = React.lazy(
1256
+ () => Promise.resolve().then(() => require("./ListConfigurationPage-BuSdTjfa.js")).then((mod) => ({
1257
+ default: mod.ProtectedListConfiguration
1258
+ }))
1259
+ );
1260
+ const ProtectedEditConfigurationPage = React.lazy(
1261
+ () => Promise.resolve().then(() => require("./EditConfigurationPage-BFpQwwbc.js")).then((mod) => ({
1262
+ default: mod.ProtectedEditConfigurationPage
1263
+ }))
1264
+ );
1265
+ const ProtectedComponentConfigurationPage = React.lazy(
1266
+ () => Promise.resolve().then(() => require("./ComponentConfigurationPage-DMq0wvcL.js")).then((mod) => ({
1267
+ default: mod.ProtectedComponentConfigurationPage
1268
+ }))
1269
+ );
1270
+ const NoPermissions = React.lazy(
1271
+ () => Promise.resolve().then(() => require("./NoPermissionsPage-BK-XCpIy.js")).then((mod) => ({ default: mod.NoPermissions }))
1272
+ );
1273
+ const NoContentType = React.lazy(
1274
+ () => Promise.resolve().then(() => require("./NoContentTypePage-DCUL8gVi.js")).then((mod) => ({ default: mod.NoContentType }))
1275
+ );
1276
+ const CollectionTypePages = () => {
1277
+ const { collectionType } = reactRouterDom.useParams();
1278
+ if (collectionType !== COLLECTION_TYPES && collectionType !== SINGLE_TYPES) {
1279
+ return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/404" });
1280
+ }
1281
+ return collectionType === COLLECTION_TYPES ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedListViewPage, {}) : /* @__PURE__ */ jsxRuntime.jsx(ProtectedEditViewPage, {});
1282
+ };
1283
+ const CLONE_RELATIVE_PATH = ":collectionType/:slug/clone/:origin";
1284
+ const CLONE_PATH = `/content-manager/${CLONE_RELATIVE_PATH}`;
1285
+ const LIST_RELATIVE_PATH = ":collectionType/:slug";
1286
+ const LIST_PATH = `/content-manager/${LIST_RELATIVE_PATH}`;
1287
+ const routes = [
1288
+ {
1289
+ path: LIST_RELATIVE_PATH,
1290
+ element: /* @__PURE__ */ jsxRuntime.jsx(CollectionTypePages, {})
1291
+ },
1292
+ {
1293
+ path: ":collectionType/:slug/:id",
1294
+ Component: ProtectedEditViewPage
1295
+ },
1296
+ {
1297
+ path: CLONE_RELATIVE_PATH,
1298
+ Component: ProtectedEditViewPage
1299
+ },
1300
+ {
1301
+ path: ":collectionType/:slug/configurations/list",
1302
+ Component: ProtectedListConfiguration
1303
+ },
1304
+ {
1305
+ path: "components/:slug/configurations/edit",
1306
+ Component: ProtectedComponentConfigurationPage
1307
+ },
1308
+ {
1309
+ path: ":collectionType/:slug/configurations/edit",
1310
+ Component: ProtectedEditConfigurationPage
1311
+ },
1312
+ {
1313
+ path: "403",
1314
+ Component: NoPermissions
1315
+ },
1316
+ {
1317
+ path: "no-content-types",
1318
+ Component: NoContentType
1319
+ },
1320
+ ...routes$1
1321
+ ];
1322
+ const DocumentActions = ({ actions: actions2 }) => {
1323
+ const { formatMessage } = reactIntl.useIntl();
1324
+ const [primaryAction, secondaryAction, ...restActions] = actions2.filter((action) => {
1325
+ if (action.position === void 0) {
1326
+ return true;
1327
+ }
1328
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
1329
+ return positions.includes("panel");
1330
+ });
1331
+ if (!primaryAction) {
1332
+ return null;
1333
+ }
1334
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, alignItems: "stretch", width: "100%", children: [
1335
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
1336
+ /* @__PURE__ */ jsxRuntime.jsx(DocumentActionButton, { ...primaryAction, variant: primaryAction.variant || "default" }),
1337
+ restActions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1338
+ DocumentActionsMenu,
1339
+ {
1340
+ actions: restActions,
1341
+ label: formatMessage({
1342
+ id: "content-manager.containers.edit.panels.default.more-actions",
1343
+ defaultMessage: "More document actions"
1344
+ })
1345
+ }
1346
+ ) : null
1347
+ ] }),
1348
+ secondaryAction ? /* @__PURE__ */ jsxRuntime.jsx(
1349
+ DocumentActionButton,
1350
+ {
1351
+ ...secondaryAction,
1352
+ variant: secondaryAction.variant || "secondary"
1353
+ }
1354
+ ) : null
1355
+ ] });
1356
+ };
1357
+ const DocumentActionButton = (action) => {
1358
+ const [dialogId, setDialogId] = React__namespace.useState(null);
1359
+ const { toggleNotification } = strapiAdmin.useNotification();
1360
+ const handleClick = (action2) => async (e) => {
1361
+ const { onClick = () => false, dialog, id } = action2;
1362
+ const muteDialog = await onClick(e);
1363
+ if (dialog && !muteDialog) {
1364
+ switch (dialog.type) {
1365
+ case "notification":
1366
+ toggleNotification({
1367
+ title: dialog.title,
1368
+ message: dialog.content,
1369
+ type: dialog.status,
1370
+ timeout: dialog.timeout,
1371
+ onClose: dialog.onClose
1372
+ });
1373
+ break;
1374
+ case "dialog":
1375
+ case "modal":
1376
+ e.preventDefault();
1377
+ setDialogId(id);
1378
+ }
1379
+ }
1380
+ };
1381
+ const handleClose = () => {
1382
+ setDialogId(null);
1383
+ };
1384
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1385
+ /* @__PURE__ */ jsxRuntime.jsx(
1386
+ designSystem.Button,
1387
+ {
1388
+ flex: 1,
1389
+ startIcon: action.icon,
1390
+ disabled: action.disabled,
1391
+ onClick: handleClick(action),
1392
+ justifyContent: "center",
1393
+ variant: action.variant || "default",
1394
+ children: action.label
1395
+ }
1396
+ ),
1397
+ action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
1398
+ DocumentActionConfirmDialog,
1399
+ {
1400
+ ...action.dialog,
1401
+ variant: action.variant,
1402
+ isOpen: dialogId === action.id,
1403
+ onClose: handleClose
1404
+ }
1405
+ ) : null,
1406
+ action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
1407
+ DocumentActionModal,
1408
+ {
1409
+ ...action.dialog,
1410
+ onModalClose: handleClose,
1411
+ isOpen: dialogId === action.id
1412
+ }
1413
+ ) : null
1414
+ ] });
1415
+ };
1416
+ const DocumentActionsMenu = ({
1417
+ actions: actions2,
1418
+ children,
1419
+ label,
1420
+ variant = "tertiary"
1421
+ }) => {
1422
+ const [isOpen, setIsOpen] = React__namespace.useState(false);
1423
+ const [dialogId, setDialogId] = React__namespace.useState(null);
1424
+ const { formatMessage } = reactIntl.useIntl();
1425
+ const { toggleNotification } = strapiAdmin.useNotification();
1426
+ const isDisabled = actions2.every((action) => action.disabled) || actions2.length === 0;
1427
+ const handleClick = (action) => async (e) => {
1428
+ const { onClick = () => false, dialog, id } = action;
1429
+ const muteDialog = await onClick(e);
1430
+ if (dialog && !muteDialog) {
1431
+ switch (dialog.type) {
1432
+ case "notification":
1433
+ toggleNotification({
1434
+ title: dialog.title,
1435
+ message: dialog.content,
1436
+ type: dialog.status,
1437
+ timeout: dialog.timeout,
1438
+ onClose: dialog.onClose
1439
+ });
1440
+ break;
1441
+ case "dialog":
1442
+ case "modal":
1443
+ setDialogId(id);
1444
+ }
1445
+ }
1446
+ };
1447
+ const handleClose = () => {
1448
+ setDialogId(null);
1449
+ setIsOpen(false);
1450
+ };
1451
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { open: isOpen, onOpenChange: setIsOpen, children: [
1452
+ /* @__PURE__ */ jsxRuntime.jsxs(
1453
+ designSystem.Menu.Trigger,
1454
+ {
1455
+ disabled: isDisabled,
1456
+ size: "S",
1457
+ endIcon: null,
1458
+ paddingTop: "7px",
1459
+ paddingLeft: "9px",
1460
+ paddingRight: "9px",
1461
+ variant,
1462
+ children: [
1463
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
1464
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: label || formatMessage({
1465
+ id: "content-manager.containers.edit.panels.default.more-actions",
1466
+ defaultMessage: "More document actions"
1467
+ }) })
1468
+ ]
1469
+ }
1470
+ ),
1471
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { top: "4px", maxHeight: void 0, popoverPlacement: "bottom-end", children: [
1472
+ actions2.map((action) => {
1473
+ return /* @__PURE__ */ jsxRuntime.jsx(
1474
+ designSystem.Menu.Item,
1475
+ {
1476
+ disabled: action.disabled,
1477
+ onSelect: handleClick(action),
1478
+ display: "block",
1479
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", gap: 4, children: [
1480
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { color: convertActionVariantToColor(action.variant), gap: 2, tag: "span", children: [
1481
+ action.icon,
1482
+ action.label
1483
+ ] }),
1484
+ action.id.startsWith("HistoryAction") && /* @__PURE__ */ jsxRuntime.jsx(
1485
+ designSystem.Flex,
1486
+ {
1487
+ alignItems: "center",
1488
+ background: "alternative100",
1489
+ borderStyle: "solid",
1490
+ borderColor: "alternative200",
1491
+ borderWidth: "1px",
1492
+ height: 5,
1493
+ paddingLeft: 2,
1494
+ paddingRight: 2,
1495
+ hasRadius: true,
1496
+ color: "alternative600",
1497
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", fontWeight: "bold", lineHeight: 1, children: formatMessage({ id: "global.new", defaultMessage: "New" }) })
1498
+ }
1499
+ )
1500
+ ] })
1501
+ },
1502
+ action.id
1503
+ );
1504
+ }),
1505
+ children
1506
+ ] }),
1507
+ actions2.map((action) => {
1508
+ return /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
1509
+ action.dialog?.type === "dialog" ? /* @__PURE__ */ jsxRuntime.jsx(
1510
+ DocumentActionConfirmDialog,
1511
+ {
1512
+ ...action.dialog,
1513
+ variant: action.variant,
1514
+ isOpen: dialogId === action.id,
1515
+ onClose: handleClose
1516
+ }
1517
+ ) : null,
1518
+ action.dialog?.type === "modal" ? /* @__PURE__ */ jsxRuntime.jsx(
1519
+ DocumentActionModal,
1520
+ {
1521
+ ...action.dialog,
1522
+ onModalClose: handleClose,
1523
+ isOpen: dialogId === action.id
1524
+ }
1525
+ ) : null
1526
+ ] }, action.id);
1527
+ })
1528
+ ] });
1529
+ };
1530
+ const convertActionVariantToColor = (variant = "secondary") => {
1531
+ switch (variant) {
1532
+ case "danger":
1533
+ return "danger600";
1534
+ case "secondary":
1535
+ return void 0;
1536
+ case "success":
1537
+ return "success600";
1538
+ default:
1539
+ return "primary600";
1540
+ }
1541
+ };
1542
+ const DocumentActionConfirmDialog = ({
1543
+ onClose,
1544
+ onCancel,
1545
+ onConfirm,
1546
+ title,
1547
+ content,
1548
+ isOpen,
1549
+ variant = "secondary"
1550
+ }) => {
1551
+ const { formatMessage } = reactIntl.useIntl();
1552
+ const handleClose = async () => {
1553
+ if (onCancel) {
1554
+ await onCancel();
1555
+ }
1556
+ onClose();
1557
+ };
1558
+ const handleConfirm = async () => {
1559
+ if (onConfirm) {
1560
+ await onConfirm();
1561
+ }
1562
+ onClose();
1563
+ };
1564
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Dialog, { isOpen, title, onClose: handleClose, children: [
1565
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.DialogBody, { children: content }),
1566
+ /* @__PURE__ */ jsxRuntime.jsx(
1567
+ designSystem.DialogFooter,
1568
+ {
1569
+ startAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleClose, variant: "tertiary", children: formatMessage({
1570
+ id: "app.components.Button.cancel",
1571
+ defaultMessage: "Cancel"
1572
+ }) }),
1573
+ endAction: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: handleConfirm, variant, children: formatMessage({
1574
+ id: "app.components.Button.confirm",
1575
+ defaultMessage: "Confirm"
1576
+ }) })
1577
+ }
1578
+ )
1579
+ ] });
1580
+ };
1581
+ const DocumentActionModal = ({
1582
+ isOpen,
1583
+ title,
1584
+ onClose,
1585
+ footer: Footer,
1586
+ content,
1587
+ onModalClose
1588
+ }) => {
1589
+ const id = React__namespace.useId();
1590
+ if (!isOpen) {
1591
+ return null;
1592
+ }
1593
+ const handleClose = () => {
1594
+ if (onClose) {
1595
+ onClose();
1596
+ }
1597
+ onModalClose();
1598
+ };
1599
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.ModalLayout, { borderRadius: "4px", overflow: "hidden", onClose: handleClose, labelledBy: id, children: [
1600
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", tag: "h2", id, children: title }) }),
1601
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.ModalBody, { children: content }),
1602
+ /* @__PURE__ */ jsxRuntime.jsx(
1603
+ designSystem.Box,
1604
+ {
1605
+ paddingTop: 4,
1606
+ paddingBottom: 4,
1607
+ paddingLeft: 5,
1608
+ paddingRight: 5,
1609
+ borderWidth: "1px 0 0 0",
1610
+ borderStyle: "solid",
1611
+ borderColor: "neutral150",
1612
+ background: "neutral100",
1613
+ children: typeof Footer === "function" ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { onClose: handleClose }) : Footer
1614
+ }
1615
+ )
1616
+ ] });
1617
+ };
1618
+ const PublishAction = ({
1619
+ activeTab,
1620
+ documentId,
1621
+ model,
1622
+ collectionType,
1623
+ meta,
1624
+ document
1625
+ }) => {
1626
+ const { schema } = useDoc();
1627
+ const navigate = reactRouterDom.useNavigate();
1628
+ const { toggleNotification } = strapiAdmin.useNotification();
1629
+ const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
1630
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
1631
+ const { formatMessage } = reactIntl.useIntl();
1632
+ const { canPublish, canCreate, canUpdate } = useDocumentRBAC(
1633
+ "PublishAction",
1634
+ ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 }) => ({ canPublish: canPublish2, canCreate: canCreate2, canUpdate: canUpdate2 })
1635
+ );
1636
+ const { publish } = useDocumentActions();
1637
+ const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
1638
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1639
+ const modified = strapiAdmin.useForm("PublishAction", ({ modified: modified2 }) => modified2);
1640
+ const setSubmitting = strapiAdmin.useForm("PublishAction", ({ setSubmitting: setSubmitting2 }) => setSubmitting2);
1641
+ const isSubmitting = strapiAdmin.useForm("PublishAction", ({ isSubmitting: isSubmitting2 }) => isSubmitting2);
1642
+ const validate = strapiAdmin.useForm("PublishAction", (state) => state.validate);
1643
+ const setErrors = strapiAdmin.useForm("PublishAction", (state) => state.setErrors);
1644
+ const formValues = strapiAdmin.useForm("PublishAction", ({ values }) => values);
1645
+ const isDocumentPublished = (document?.[PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc) => doc[PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== "modified";
1646
+ if (!schema?.options?.draftAndPublish) {
1647
+ return null;
1648
+ }
1649
+ return {
1650
+ /**
1651
+ * Disabled when:
1652
+ * - currently if you're cloning a document we don't support publish & clone at the same time.
1653
+ * - the form is submitting
1654
+ * - the active tab is the published tab
1655
+ * - the document is already published & not modified
1656
+ * - the document is being created & not modified
1657
+ * - the user doesn't have the permission to publish
1658
+ * - the user doesn't have the permission to create a new document
1659
+ * - the user doesn't have the permission to update the document
1660
+ */
1661
+ disabled: isCloning || isSubmitting || activeTab === "published" || !modified && isDocumentPublished || !modified && !document?.documentId || !canPublish || Boolean(!document?.documentId && !canCreate || document?.documentId && !canUpdate),
1662
+ label: formatMessage({
1663
+ id: "app.utils.publish",
1664
+ defaultMessage: "Publish"
1665
+ }),
1666
+ onClick: async () => {
1667
+ setSubmitting(true);
1668
+ try {
1669
+ const { errors } = await validate();
1670
+ if (errors) {
1671
+ toggleNotification({
1672
+ type: "danger",
1673
+ message: formatMessage({
1674
+ id: "content-manager.validation.error",
1675
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
1676
+ })
1677
+ });
1678
+ return;
1679
+ }
1680
+ const res = await publish(
1681
+ {
1682
+ collectionType,
1683
+ model,
1684
+ documentId,
1685
+ params
1686
+ },
1687
+ formValues
1688
+ );
1689
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
1690
+ navigate({
1691
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1692
+ search: rawQuery
1693
+ });
1694
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1695
+ setErrors(formatValidationErrors(res.error));
1696
+ }
1697
+ } finally {
1698
+ setSubmitting(false);
1699
+ }
1700
+ }
1701
+ };
1702
+ };
1703
+ PublishAction.type = "publish";
1704
+ const UpdateAction = ({
1705
+ activeTab,
1706
+ documentId,
1707
+ model,
1708
+ collectionType
1709
+ }) => {
1710
+ const navigate = reactRouterDom.useNavigate();
1711
+ const { toggleNotification } = strapiAdmin.useNotification();
1712
+ const { _unstableFormatValidationErrors: formatValidationErrors } = strapiAdmin.useAPIErrorHandler();
1713
+ const cloneMatch = reactRouterDom.useMatch(CLONE_PATH);
1714
+ const isCloning = cloneMatch !== null;
1715
+ const { formatMessage } = reactIntl.useIntl();
1716
+ const { canCreate, canUpdate } = useDocumentRBAC("UpdateAction", ({ canCreate: canCreate2, canUpdate: canUpdate2 }) => ({
1717
+ canCreate: canCreate2,
1718
+ canUpdate: canUpdate2
1719
+ }));
1720
+ const { create, update, clone } = useDocumentActions();
1721
+ const [{ query, rawQuery }] = strapiAdmin.useQueryParams();
1722
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1723
+ const isSubmitting = strapiAdmin.useForm("UpdateAction", ({ isSubmitting: isSubmitting2 }) => isSubmitting2);
1724
+ const modified = strapiAdmin.useForm("UpdateAction", ({ modified: modified2 }) => modified2);
1725
+ const setSubmitting = strapiAdmin.useForm("UpdateAction", ({ setSubmitting: setSubmitting2 }) => setSubmitting2);
1726
+ const document = strapiAdmin.useForm("UpdateAction", ({ values }) => values);
1727
+ const validate = strapiAdmin.useForm("UpdateAction", (state) => state.validate);
1728
+ const setErrors = strapiAdmin.useForm("UpdateAction", (state) => state.setErrors);
1729
+ const resetForm = strapiAdmin.useForm("PublishAction", ({ resetForm: resetForm2 }) => resetForm2);
1730
+ return {
1731
+ /**
1732
+ * Disabled when:
1733
+ * - the form is submitting
1734
+ * - the document is not modified & we're not cloning (you can save a clone entity straight away)
1735
+ * - the active tab is the published tab
1736
+ * - the user doesn't have the permission to create a new document
1737
+ * - the user doesn't have the permission to update the document
1738
+ */
1739
+ disabled: isSubmitting || !modified && !isCloning || activeTab === "published" || Boolean(!documentId && !canCreate || documentId && !canUpdate),
1740
+ label: formatMessage({
1741
+ id: "content-manager.containers.Edit.save",
1742
+ defaultMessage: "Save"
1743
+ }),
1744
+ onClick: async () => {
1745
+ setSubmitting(true);
1746
+ try {
1747
+ const { errors } = await validate();
1748
+ if (errors) {
1749
+ toggleNotification({
1750
+ type: "danger",
1751
+ message: formatMessage({
1752
+ id: "content-manager.validation.error",
1753
+ defaultMessage: "There are validation errors in your document. Please fix them before saving."
1754
+ })
1755
+ });
1756
+ return;
1757
+ }
1758
+ if (isCloning) {
1759
+ const res = await clone(
1760
+ {
1761
+ model,
1762
+ documentId: cloneMatch.params.origin,
1763
+ params
1764
+ },
1765
+ document
1766
+ );
1767
+ if ("data" in res) {
1768
+ navigate({
1769
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1770
+ search: rawQuery
1771
+ });
1772
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1773
+ setErrors(formatValidationErrors(res.error));
1774
+ }
1775
+ } else if (documentId || collectionType === SINGLE_TYPES) {
1776
+ const res = await update(
1777
+ {
1778
+ collectionType,
1779
+ model,
1780
+ documentId,
1781
+ params
1782
+ },
1783
+ document
1784
+ );
1785
+ if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1786
+ setErrors(formatValidationErrors(res.error));
1787
+ } else {
1788
+ resetForm();
1789
+ }
1790
+ } else {
1791
+ const res = await create(
1792
+ {
1793
+ model,
1794
+ params
1795
+ },
1796
+ document
1797
+ );
1798
+ if ("data" in res && collectionType !== SINGLE_TYPES) {
1799
+ navigate({
1800
+ pathname: `../${collectionType}/${model}/${res.data.documentId}`,
1801
+ search: rawQuery
1802
+ });
1803
+ } else if ("error" in res && isBaseQueryError(res.error) && res.error.name === "ValidationError") {
1804
+ setErrors(formatValidationErrors(res.error));
1805
+ }
1806
+ }
1807
+ } finally {
1808
+ setSubmitting(false);
1809
+ }
1810
+ }
1811
+ };
1812
+ };
1813
+ UpdateAction.type = "update";
1814
+ const UNPUBLISH_DRAFT_OPTIONS = {
1815
+ KEEP: "keep",
1816
+ DISCARD: "discard"
1817
+ };
1818
+ const UnpublishAction = ({
1819
+ activeTab,
1820
+ documentId,
1821
+ model,
1822
+ collectionType,
1823
+ document
1824
+ }) => {
1825
+ const { formatMessage } = reactIntl.useIntl();
1826
+ const { schema } = useDoc();
1827
+ const canPublish = useDocumentRBAC("UnpublishAction", ({ canPublish: canPublish2 }) => canPublish2);
1828
+ const { unpublish } = useDocumentActions();
1829
+ const [{ query }] = strapiAdmin.useQueryParams();
1830
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1831
+ const { toggleNotification } = strapiAdmin.useNotification();
1832
+ const [shouldKeepDraft, setShouldKeepDraft] = React__namespace.useState(true);
1833
+ const isDocumentModified = document?.status === "modified";
1834
+ const handleChange = (e) => {
1835
+ if ("value" in e.target) {
1836
+ setShouldKeepDraft(e.target.value === UNPUBLISH_DRAFT_OPTIONS.KEEP);
1837
+ }
1838
+ };
1839
+ if (!schema?.options?.draftAndPublish) {
1840
+ return null;
1841
+ }
1842
+ return {
1843
+ disabled: !canPublish || activeTab === "published" || document?.status !== "published" && document?.status !== "modified",
1844
+ label: formatMessage({
1845
+ id: "app.utils.unpublish",
1846
+ defaultMessage: "Unpublish"
1847
+ }),
1848
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
1849
+ onClick: async () => {
1850
+ if (!documentId && collectionType !== SINGLE_TYPES || isDocumentModified) {
1851
+ if (!documentId) {
1852
+ console.error(
1853
+ "You're trying to unpublish a document without an id, this is likely a bug with Strapi. Please open an issue."
1854
+ );
1855
+ toggleNotification({
1856
+ message: formatMessage({
1857
+ id: "content-manager.actions.unpublish.error",
1858
+ defaultMessage: "An error occurred while trying to unpublish the document."
1859
+ }),
1860
+ type: "danger"
1861
+ });
1862
+ }
1863
+ return;
1864
+ }
1865
+ await unpublish({
1866
+ collectionType,
1867
+ model,
1868
+ documentId,
1869
+ params
1870
+ });
1871
+ },
1872
+ dialog: isDocumentModified ? {
1873
+ type: "dialog",
1874
+ title: formatMessage({
1875
+ id: "app.components.ConfirmDialog.title",
1876
+ defaultMessage: "Confirmation"
1877
+ }),
1878
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "flex-start", direction: "column", gap: 6, children: [
1879
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { width: "100%", direction: "column", gap: 2, children: [
1880
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
1881
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
1882
+ id: "content-manager.actions.unpublish.dialog.body",
1883
+ defaultMessage: "Are you sure?"
1884
+ }) })
1885
+ ] }),
1886
+ /* @__PURE__ */ jsxRuntime.jsxs(
1887
+ designSystem.Flex,
1888
+ {
1889
+ onChange: handleChange,
1890
+ direction: "column",
1891
+ alignItems: "flex-start",
1892
+ tag: "fieldset",
1893
+ gap: 3,
1894
+ children: [
1895
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "legend" }),
1896
+ /* @__PURE__ */ jsxRuntime.jsx(
1897
+ designSystem.Radio,
1898
+ {
1899
+ checked: shouldKeepDraft,
1900
+ value: UNPUBLISH_DRAFT_OPTIONS.KEEP,
1901
+ name: "discard-options",
1902
+ children: formatMessage({
1903
+ id: "content-manager.actions.unpublish.dialog.option.keep-draft",
1904
+ defaultMessage: "Keep draft"
1905
+ })
1906
+ }
1907
+ ),
1908
+ /* @__PURE__ */ jsxRuntime.jsx(
1909
+ designSystem.Radio,
1910
+ {
1911
+ checked: !shouldKeepDraft,
1912
+ value: UNPUBLISH_DRAFT_OPTIONS.DISCARD,
1913
+ name: "discard-options",
1914
+ children: formatMessage({
1915
+ id: "content-manager.actions.unpublish.dialog.option.replace-draft",
1916
+ defaultMessage: "Replace draft"
1917
+ })
1918
+ }
1919
+ )
1920
+ ]
1921
+ }
1922
+ )
1923
+ ] }),
1924
+ onConfirm: async () => {
1925
+ if (!documentId && collectionType !== SINGLE_TYPES) {
1926
+ console.error(
1927
+ "You're trying to unpublish a document without an id, this is likely a bug with Strapi. Please open an issue."
1928
+ );
1929
+ toggleNotification({
1930
+ message: formatMessage({
1931
+ id: "content-manager.actions.unpublish.error",
1932
+ defaultMessage: "An error occurred while trying to unpublish the document."
1933
+ }),
1934
+ type: "danger"
1935
+ });
1936
+ }
1937
+ await unpublish(
1938
+ {
1939
+ collectionType,
1940
+ model,
1941
+ documentId,
1942
+ params
1943
+ },
1944
+ !shouldKeepDraft
1945
+ );
1946
+ }
1947
+ } : void 0,
1948
+ variant: "danger",
1949
+ position: ["panel", "table-row"]
1950
+ };
1951
+ };
1952
+ UnpublishAction.type = "unpublish";
1953
+ const DiscardAction = ({
1954
+ activeTab,
1955
+ documentId,
1956
+ model,
1957
+ collectionType,
1958
+ document
1959
+ }) => {
1960
+ const { formatMessage } = reactIntl.useIntl();
1961
+ const { schema } = useDoc();
1962
+ const canUpdate = useDocumentRBAC("DiscardAction", ({ canUpdate: canUpdate2 }) => canUpdate2);
1963
+ const { discard } = useDocumentActions();
1964
+ const [{ query }] = strapiAdmin.useQueryParams();
1965
+ const params = React__namespace.useMemo(() => buildValidParams(query), [query]);
1966
+ if (!schema?.options?.draftAndPublish) {
1967
+ return null;
1968
+ }
1969
+ return {
1970
+ disabled: !canUpdate || activeTab === "published" || document?.status !== "modified",
1971
+ label: formatMessage({
1972
+ id: "content-manager.actions.discard.label",
1973
+ defaultMessage: "Discard changes"
1974
+ }),
1975
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCrossCircle, {}),
1976
+ position: ["panel", "table-row"],
1977
+ variant: "danger",
1978
+ dialog: {
1979
+ type: "dialog",
1980
+ title: formatMessage({
1981
+ id: "app.components.ConfirmDialog.title",
1982
+ defaultMessage: "Confirmation"
1983
+ }),
1984
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
1985
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
1986
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
1987
+ id: "content-manager.actions.discard.dialog.body",
1988
+ defaultMessage: "Are you sure?"
1989
+ }) })
1990
+ ] }),
1991
+ onConfirm: async () => {
1992
+ await discard({
1993
+ collectionType,
1994
+ model,
1995
+ documentId,
1996
+ params
1997
+ });
1998
+ }
1999
+ }
2000
+ };
2001
+ };
2002
+ DiscardAction.type = "discard";
2003
+ const StyledCrossCircle = styledComponents.styled(Icons.CrossCircle)`
2004
+ path {
2005
+ fill: currentColor;
2006
+ }
2007
+ `;
2008
+ const DEFAULT_ACTIONS = [PublishAction, UpdateAction, UnpublishAction, DiscardAction];
2009
+ const intervals = ["years", "months", "days", "hours", "minutes", "seconds"];
2010
+ const RelativeTime = React__namespace.forwardRef(
2011
+ ({ timestamp, customIntervals = [], ...restProps }, forwardedRef) => {
2012
+ const { formatRelativeTime, formatDate, formatTime } = reactIntl.useIntl();
2013
+ const interval = dateFns.intervalToDuration({
2014
+ start: timestamp,
2015
+ end: Date.now()
2016
+ // see https://github.com/date-fns/date-fns/issues/2891 – No idea why it's all partial it returns it every time.
2017
+ });
2018
+ const unit = intervals.find((intervalUnit) => {
2019
+ return interval[intervalUnit] > 0 && Object.keys(interval).includes(intervalUnit);
2020
+ });
2021
+ const relativeTime = dateFns.isPast(timestamp) ? -interval[unit] : interval[unit];
2022
+ const customInterval = customIntervals.find(
2023
+ (custom) => interval[custom.unit] < custom.threshold
2024
+ );
2025
+ const displayText = customInterval ? customInterval.text : formatRelativeTime(relativeTime, unit, { numeric: "auto" });
2026
+ return /* @__PURE__ */ jsxRuntime.jsx(
2027
+ "time",
2028
+ {
2029
+ ref: forwardedRef,
2030
+ dateTime: timestamp.toISOString(),
2031
+ role: "time",
2032
+ title: `${formatDate(timestamp)} ${formatTime(timestamp)}`,
2033
+ ...restProps,
2034
+ children: displayText
2035
+ }
2036
+ );
2037
+ }
2038
+ );
2039
+ const getDisplayName = ({
2040
+ firstname,
2041
+ lastname,
2042
+ username,
2043
+ email
2044
+ } = {}) => {
2045
+ if (username) {
2046
+ return username;
2047
+ }
2048
+ if (firstname) {
2049
+ return `${firstname} ${lastname ?? ""}`.trim();
2050
+ }
2051
+ return email ?? "";
2052
+ };
2053
+ const capitalise = (str) => str.charAt(0).toUpperCase() + str.slice(1);
2054
+ const DocumentStatus = ({ status = "draft", ...restProps }) => {
2055
+ const statusVariant = status === "draft" ? "primary" : status === "published" ? "success" : "alternative";
2056
+ 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) }) });
2057
+ };
2058
+ const Header = ({ isCreating, status, title: documentTitle = "Untitled" }) => {
2059
+ const { formatMessage } = reactIntl.useIntl();
2060
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2061
+ const title = isCreating ? formatMessage({
2062
+ id: "content-manager.containers.edit.title.new",
2063
+ defaultMessage: "Create an entry"
2064
+ }) : documentTitle;
2065
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", paddingTop: 8, paddingBottom: 4, gap: 3, children: [
2066
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.BackButton, {}),
2067
+ /* @__PURE__ */ jsxRuntime.jsxs(
2068
+ designSystem.Flex,
2069
+ {
2070
+ width: "100%",
2071
+ justifyContent: "space-between",
2072
+ paddingTop: 1,
2073
+ gap: "80px",
2074
+ alignItems: "flex-start",
2075
+ children: [
2076
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: title }),
2077
+ /* @__PURE__ */ jsxRuntime.jsx(HeaderToolbar, {})
2078
+ ]
2079
+ }
2080
+ ),
2081
+ status ? /* @__PURE__ */ jsxRuntime.jsx(DocumentStatus, { status: isCloning ? "draft" : status }) : null
2082
+ ] });
2083
+ };
2084
+ const HeaderToolbar = () => {
2085
+ const { formatMessage } = reactIntl.useIntl();
2086
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2087
+ const [
2088
+ {
2089
+ query: { status = "draft" }
2090
+ }
2091
+ ] = strapiAdmin.useQueryParams();
2092
+ const { model, id, document, meta, collectionType } = useDoc();
2093
+ const plugins = strapiAdmin.useStrapiApp("HeaderToolbar", (state) => state.plugins);
2094
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
2095
+ /* @__PURE__ */ jsxRuntime.jsx(
2096
+ strapiAdmin.DescriptionComponentRenderer,
2097
+ {
2098
+ props: {
2099
+ activeTab: status,
2100
+ model,
2101
+ documentId: id,
2102
+ document: isCloning ? void 0 : document,
2103
+ meta: isCloning ? void 0 : meta,
2104
+ collectionType
2105
+ },
2106
+ descriptions: plugins["content-manager"].apis.getHeaderActions(),
2107
+ children: (actions2) => {
2108
+ if (actions2.length > 0) {
2109
+ return /* @__PURE__ */ jsxRuntime.jsx(HeaderActions, { actions: actions2 });
2110
+ } else {
2111
+ return null;
2112
+ }
2113
+ }
2114
+ }
2115
+ ),
2116
+ /* @__PURE__ */ jsxRuntime.jsx(
2117
+ strapiAdmin.DescriptionComponentRenderer,
2118
+ {
2119
+ props: {
2120
+ activeTab: status,
2121
+ model,
2122
+ documentId: id,
2123
+ document: isCloning ? void 0 : document,
2124
+ meta: isCloning ? void 0 : meta,
2125
+ collectionType
2126
+ },
2127
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
2128
+ children: (actions2) => {
2129
+ const headerActions = actions2.filter((action) => {
2130
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
2131
+ return positions.includes("header");
2132
+ });
2133
+ return /* @__PURE__ */ jsxRuntime.jsx(
2134
+ DocumentActionsMenu,
2135
+ {
2136
+ actions: headerActions,
2137
+ label: formatMessage({
2138
+ id: "content-manager.containers.edit.header.more-actions",
2139
+ defaultMessage: "More actions"
2140
+ }),
2141
+ children: /* @__PURE__ */ jsxRuntime.jsx(Information, { activeTab: status })
2142
+ }
2143
+ );
2144
+ }
2145
+ }
2146
+ )
2147
+ ] });
2148
+ };
2149
+ const Information = ({ activeTab }) => {
2150
+ const { formatMessage } = reactIntl.useIntl();
2151
+ const { document, meta } = useDoc();
2152
+ if (!document || !document.id) {
2153
+ return null;
2154
+ }
2155
+ const createAndUpdateDocument = activeTab === "draft" ? document : meta?.availableStatus.find((status) => status.publishedAt === null);
2156
+ const publishDocument = activeTab === "published" ? document : meta?.availableStatus.find((status) => status.publishedAt !== null);
2157
+ const creator = createAndUpdateDocument?.[CREATED_BY_ATTRIBUTE_NAME] ? getDisplayName(createAndUpdateDocument[CREATED_BY_ATTRIBUTE_NAME]) : null;
2158
+ const updator = createAndUpdateDocument?.[UPDATED_BY_ATTRIBUTE_NAME] ? getDisplayName(createAndUpdateDocument[UPDATED_BY_ATTRIBUTE_NAME]) : null;
2159
+ const information = [
2160
+ {
2161
+ isDisplayed: !!publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME],
2162
+ label: formatMessage({
2163
+ id: "content-manager.containers.edit.information.last-published.label",
2164
+ defaultMessage: "Last published"
2165
+ }),
2166
+ value: formatMessage(
2167
+ {
2168
+ id: "content-manager.containers.edit.information.last-published.value",
2169
+ defaultMessage: `Published {time}{isAnonymous, select, true {} other { by {author}}}`
2170
+ },
2171
+ {
2172
+ time: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { timestamp: new Date(publishDocument?.[PUBLISHED_AT_ATTRIBUTE_NAME]) }),
2173
+ isAnonymous: !publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME],
2174
+ author: publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME] ? getDisplayName(publishDocument?.[PUBLISHED_BY_ATTRIBUTE_NAME]) : null
2175
+ }
2176
+ )
2177
+ },
2178
+ {
2179
+ isDisplayed: !!createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME],
2180
+ label: formatMessage({
2181
+ id: "content-manager.containers.edit.information.last-draft.label",
2182
+ defaultMessage: "Last draft"
2183
+ }),
2184
+ value: formatMessage(
2185
+ {
2186
+ id: "content-manager.containers.edit.information.last-draft.value",
2187
+ defaultMessage: `Modified {time}{isAnonymous, select, true {} other { by {author}}}`
2188
+ },
2189
+ {
2190
+ time: /* @__PURE__ */ jsxRuntime.jsx(
2191
+ RelativeTime,
2192
+ {
2193
+ timestamp: new Date(createAndUpdateDocument?.[UPDATED_AT_ATTRIBUTE_NAME])
2194
+ }
2195
+ ),
2196
+ isAnonymous: !updator,
2197
+ author: updator
2198
+ }
2199
+ )
2200
+ },
2201
+ {
2202
+ isDisplayed: !!createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME],
2203
+ label: formatMessage({
2204
+ id: "content-manager.containers.edit.information.document.label",
2205
+ defaultMessage: "Document"
2206
+ }),
2207
+ value: formatMessage(
2208
+ {
2209
+ id: "content-manager.containers.edit.information.document.value",
2210
+ defaultMessage: `Created {time}{isAnonymous, select, true {} other { by {author}}}`
2211
+ },
2212
+ {
2213
+ time: /* @__PURE__ */ jsxRuntime.jsx(
2214
+ RelativeTime,
2215
+ {
2216
+ timestamp: new Date(createAndUpdateDocument?.[CREATED_AT_ATTRIBUTE_NAME])
2217
+ }
2218
+ ),
2219
+ isAnonymous: !creator,
2220
+ author: creator
2221
+ }
2222
+ )
2223
+ }
2224
+ ].filter((info) => info.isDisplayed);
2225
+ return /* @__PURE__ */ jsxRuntime.jsx(
2226
+ designSystem.Flex,
2227
+ {
2228
+ borderWidth: "1px 0 0 0",
2229
+ borderStyle: "solid",
2230
+ borderColor: "neutral150",
2231
+ direction: "column",
2232
+ marginTop: 2,
2233
+ tag: "dl",
2234
+ padding: 5,
2235
+ gap: 3,
2236
+ alignItems: "flex-start",
2237
+ marginLeft: "-0.4rem",
2238
+ marginRight: "-0.4rem",
2239
+ width: "calc(100% + 8px)",
2240
+ children: information.map((info) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, direction: "column", alignItems: "flex-start", children: [
2241
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dt", variant: "pi", fontWeight: "bold", children: info.label }),
2242
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "dd", variant: "pi", textColor: "neutral600", children: info.value })
2243
+ ] }, info.label))
2244
+ }
2245
+ );
2246
+ };
2247
+ const HeaderActions = ({ actions: actions2 }) => {
2248
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { children: actions2.map((action) => {
2249
+ if ("options" in action) {
2250
+ return /* @__PURE__ */ jsxRuntime.jsx(
2251
+ designSystem.SingleSelect,
2252
+ {
2253
+ size: "S",
2254
+ disabled: action.disabled,
2255
+ "aria-label": action.label,
2256
+ onChange: action.onSelect,
2257
+ value: action.value,
2258
+ children: action.options.map(({ label, ...option }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { ...option, children: label }, option.value))
2259
+ },
2260
+ action.id
2261
+ );
2262
+ } else {
2263
+ return null;
2264
+ }
2265
+ }) });
2266
+ };
2267
+ const ConfigureTheViewAction = ({ collectionType, model }) => {
2268
+ const navigate = reactRouterDom.useNavigate();
2269
+ const { formatMessage } = reactIntl.useIntl();
2270
+ return {
2271
+ label: formatMessage({
2272
+ id: "app.links.configure-view",
2273
+ defaultMessage: "Configure the view"
2274
+ }),
2275
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledCog, {}),
2276
+ onClick: () => {
2277
+ navigate(`../${collectionType}/${model}/configurations/edit`);
2278
+ },
2279
+ position: "header"
2280
+ };
2281
+ };
2282
+ ConfigureTheViewAction.type = "configure-the-view";
2283
+ const StyledCog = styledComponents.styled(Icons.Cog)`
2284
+ path {
2285
+ fill: currentColor;
2286
+ }
2287
+ `;
2288
+ const EditTheModelAction = ({ model }) => {
2289
+ const navigate = reactRouterDom.useNavigate();
2290
+ const { formatMessage } = reactIntl.useIntl();
2291
+ return {
2292
+ label: formatMessage({
2293
+ id: "content-manager.link-to-ctb",
2294
+ defaultMessage: "Edit the model"
2295
+ }),
2296
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledPencil$1, {}),
2297
+ onClick: () => {
2298
+ navigate(`/plugins/content-type-builder/content-types/${model}`);
2299
+ },
2300
+ position: "header"
2301
+ };
2302
+ };
2303
+ EditTheModelAction.type = "edit-the-model";
2304
+ const StyledPencil$1 = styledComponents.styled(Icons.Pencil)`
2305
+ path {
2306
+ fill: currentColor;
2307
+ }
2308
+ `;
2309
+ const DeleteAction = ({ documentId, model, collectionType, document }) => {
2310
+ const navigate = reactRouterDom.useNavigate();
2311
+ const { formatMessage } = reactIntl.useIntl();
2312
+ const listViewPathMatch = reactRouterDom.useMatch(LIST_PATH);
2313
+ const canDelete = useDocumentRBAC("DeleteAction", (state) => state.canDelete);
2314
+ const { delete: deleteAction } = useDocumentActions();
2315
+ const { toggleNotification } = strapiAdmin.useNotification();
2316
+ const setSubmitting = strapiAdmin.useForm("DeleteAction", (state) => state.setSubmitting);
2317
+ return {
2318
+ disabled: !canDelete || !document,
2319
+ label: formatMessage({
2320
+ id: "content-manager.actions.delete.label",
2321
+ defaultMessage: "Delete document"
2322
+ }),
2323
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledTrash, {}),
2324
+ dialog: {
2325
+ type: "dialog",
2326
+ title: formatMessage({
2327
+ id: "app.components.ConfirmDialog.title",
2328
+ defaultMessage: "Confirmation"
2329
+ }),
2330
+ content: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2331
+ /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, { width: "24px", height: "24px", fill: "danger600" }),
2332
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", textAlign: "center", children: formatMessage({
2333
+ id: "content-manager.actions.delete.dialog.body",
2334
+ defaultMessage: "Are you sure?"
2335
+ }) })
2336
+ ] }),
2337
+ onConfirm: async () => {
2338
+ if (!listViewPathMatch) {
2339
+ setSubmitting(true);
2340
+ }
2341
+ try {
2342
+ if (!documentId && collectionType !== SINGLE_TYPES) {
2343
+ console.error(
2344
+ "You're trying to delete a document without an id, this is likely a bug with Strapi. Please open an issue."
2345
+ );
2346
+ toggleNotification({
2347
+ message: formatMessage({
2348
+ id: "content-manager.actions.delete.error",
2349
+ defaultMessage: "An error occurred while trying to delete the document."
2350
+ }),
2351
+ type: "danger"
2352
+ });
2353
+ return;
2354
+ }
2355
+ const res = await deleteAction({
2356
+ documentId,
2357
+ model,
2358
+ collectionType,
2359
+ params: {
2360
+ locale: "*"
2361
+ }
2362
+ });
2363
+ if (!("error" in res)) {
2364
+ navigate({ pathname: `../${collectionType}/${model}` }, { replace: true });
2365
+ }
2366
+ } finally {
2367
+ if (!listViewPathMatch) {
2368
+ setSubmitting(false);
2369
+ }
2370
+ }
2371
+ }
2372
+ },
2373
+ variant: "danger",
2374
+ position: ["header", "table-row"]
2375
+ };
2376
+ };
2377
+ DeleteAction.type = "delete";
2378
+ const StyledTrash = styledComponents.styled(Icons.Trash)`
2379
+ path {
2380
+ fill: currentColor;
2381
+ }
2382
+ `;
2383
+ const DEFAULT_HEADER_ACTIONS = [EditTheModelAction, ConfigureTheViewAction, DeleteAction];
2384
+ const Panels = () => {
2385
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2386
+ const [
2387
+ {
2388
+ query: { status }
2389
+ }
2390
+ ] = strapiAdmin.useQueryParams({
2391
+ status: "draft"
2392
+ });
2393
+ const { model, id, document, meta, collectionType } = useDoc();
2394
+ const plugins = strapiAdmin.useStrapiApp("Panels", (state) => state.plugins);
2395
+ const props = {
2396
+ activeTab: status,
2397
+ model,
2398
+ documentId: id,
2399
+ document: isCloning ? void 0 : document,
2400
+ meta: isCloning ? void 0 : meta,
2401
+ collectionType
2402
+ };
2403
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
2404
+ strapiAdmin.DescriptionComponentRenderer,
2405
+ {
2406
+ props,
2407
+ descriptions: plugins["content-manager"].apis.getEditViewSidePanels(),
2408
+ children: (panels) => panels.map(({ content, id: id2, ...description }) => /* @__PURE__ */ jsxRuntime.jsx(Panel, { ...description, children: content }, id2))
2409
+ }
2410
+ ) });
2411
+ };
2412
+ const ActionsPanel = () => {
2413
+ const { formatMessage } = reactIntl.useIntl();
2414
+ return {
2415
+ title: formatMessage({
2416
+ id: "content-manager.containers.edit.panels.default.title",
2417
+ defaultMessage: "Document"
2418
+ }),
2419
+ content: /* @__PURE__ */ jsxRuntime.jsx(ActionsPanelContent, {})
2420
+ };
2421
+ };
2422
+ ActionsPanel.type = "actions";
2423
+ const ActionsPanelContent = () => {
2424
+ const isCloning = reactRouterDom.useMatch(CLONE_PATH) !== null;
2425
+ const [
2426
+ {
2427
+ query: { status = "draft" }
2428
+ }
2429
+ ] = strapiAdmin.useQueryParams();
2430
+ const { model, id, document, meta, collectionType } = useDoc();
2431
+ const plugins = strapiAdmin.useStrapiApp("ActionsPanel", (state) => state.plugins);
2432
+ const props = {
2433
+ activeTab: status,
2434
+ model,
2435
+ documentId: id,
2436
+ document: isCloning ? void 0 : document,
2437
+ meta: isCloning ? void 0 : meta,
2438
+ collectionType
2439
+ };
2440
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, width: "100%", children: [
2441
+ /* @__PURE__ */ jsxRuntime.jsx(
2442
+ strapiAdmin.DescriptionComponentRenderer,
2443
+ {
2444
+ props,
2445
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
2446
+ children: (actions2) => /* @__PURE__ */ jsxRuntime.jsx(DocumentActions, { actions: actions2 })
2447
+ }
2448
+ ),
2449
+ /* @__PURE__ */ jsxRuntime.jsx(InjectionZone, { area: "editView.right-links", slug: model })
2450
+ ] });
2451
+ };
2452
+ const Panel = React__namespace.forwardRef(({ children, title }, ref) => {
2453
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2454
+ designSystem.Flex,
2455
+ {
2456
+ ref,
2457
+ tag: "aside",
2458
+ "aria-labelledby": "additional-information",
2459
+ background: "neutral0",
2460
+ borderColor: "neutral150",
2461
+ hasRadius: true,
2462
+ paddingBottom: 4,
2463
+ paddingLeft: 4,
2464
+ paddingRight: 4,
2465
+ paddingTop: 4,
2466
+ shadow: "tableShadow",
2467
+ gap: 3,
2468
+ direction: "column",
2469
+ justifyContent: "stretch",
2470
+ alignItems: "flex-start",
2471
+ children: [
2472
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "h2", variant: "sigma", textTransform: "uppercase", children: title }),
2473
+ children
2474
+ ]
2475
+ }
2476
+ );
2477
+ });
2478
+ const DEFAULT_BULK_ACTIONS = [];
2479
+ const AutoCloneFailureModalBody = ({ prohibitedFields }) => {
2480
+ const { formatMessage } = reactIntl.useIntl();
2481
+ const getDefaultErrorMessage = (reason) => {
2482
+ switch (reason) {
2483
+ case "relation":
2484
+ return "Duplicating the relation could remove it from the original entry.";
2485
+ case "unique":
2486
+ return "Identical values in a unique field are not allowed";
2487
+ default:
2488
+ return reason;
2489
+ }
2490
+ };
2491
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2492
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: formatMessage({
2493
+ id: getTranslation("containers.list.autoCloneModal.title"),
2494
+ defaultMessage: "This entry can't be duplicated directly."
2495
+ }) }),
2496
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral600", children: formatMessage({
2497
+ id: getTranslation("containers.list.autoCloneModal.description"),
2498
+ defaultMessage: "A new entry will be created with the same content, but you'll have to change the following fields to save it."
2499
+ }) }) }),
2500
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { marginTop: 6, gap: 2, direction: "column", alignItems: "stretch", children: prohibitedFields.map(([fieldPath, reason]) => /* @__PURE__ */ jsxRuntime.jsxs(
2501
+ designSystem.Flex,
2502
+ {
2503
+ direction: "column",
2504
+ gap: 2,
2505
+ alignItems: "flex-start",
2506
+ borderColor: "neutral200",
2507
+ hasRadius: true,
2508
+ padding: 6,
2509
+ children: [
2510
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "row", tag: "ol", children: fieldPath.map((pathSegment, index2) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { fontWeight: "semiBold", tag: "li", children: [
2511
+ pathSegment,
2512
+ index2 !== fieldPath.length - 1 && /* @__PURE__ */ jsxRuntime.jsx(
2513
+ Icons.ChevronRight,
2514
+ {
2515
+ fill: "neutral500",
2516
+ height: "0.8rem",
2517
+ width: "0.8rem",
2518
+ style: { margin: "0 0.8rem" }
2519
+ }
2520
+ )
2521
+ ] }, index2)) }),
2522
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", textColor: "neutral600", children: formatMessage({
2523
+ id: getTranslation(`containers.list.autoCloneModal.error.${reason}`),
2524
+ defaultMessage: getDefaultErrorMessage(reason)
2525
+ }) })
2526
+ ]
2527
+ },
2528
+ fieldPath.join()
2529
+ )) })
2530
+ ] });
2531
+ };
2532
+ const TableActions = ({ document }) => {
2533
+ const { formatMessage } = reactIntl.useIntl();
2534
+ const { model, collectionType } = useDoc();
2535
+ const plugins = strapiAdmin.useStrapiApp("TableActions", (state) => state.plugins);
2536
+ const props = {
2537
+ activeTab: null,
2538
+ model,
2539
+ documentId: document.documentId,
2540
+ collectionType,
2541
+ document
2542
+ };
2543
+ return /* @__PURE__ */ jsxRuntime.jsx(
2544
+ strapiAdmin.DescriptionComponentRenderer,
2545
+ {
2546
+ props,
2547
+ descriptions: plugins["content-manager"].apis.getDocumentActions(),
2548
+ children: (actions2) => {
2549
+ const tableRowActions = actions2.filter((action) => {
2550
+ const positions = Array.isArray(action.position) ? action.position : [action.position];
2551
+ return positions.includes("table-row");
2552
+ });
2553
+ return /* @__PURE__ */ jsxRuntime.jsx(
2554
+ DocumentActionsMenu,
2555
+ {
2556
+ actions: tableRowActions,
2557
+ label: formatMessage({
2558
+ id: "content-manager.containers.list.table.row-actions",
2559
+ defaultMessage: "Row action"
2560
+ }),
2561
+ variant: "ghost"
2562
+ }
2563
+ );
2564
+ }
2565
+ }
2566
+ );
2567
+ };
2568
+ const EditAction = ({ documentId }) => {
2569
+ const navigate = reactRouterDom.useNavigate();
2570
+ const { formatMessage } = reactIntl.useIntl();
2571
+ const { canRead } = useDocumentRBAC("EditAction", ({ canRead: canRead2 }) => ({ canRead: canRead2 }));
2572
+ const { toggleNotification } = strapiAdmin.useNotification();
2573
+ const [{ query }] = strapiAdmin.useQueryParams();
2574
+ return {
2575
+ disabled: !canRead,
2576
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledPencil, {}),
2577
+ label: formatMessage({
2578
+ id: "content-manager.actions.edit.label",
2579
+ defaultMessage: "Edit"
2580
+ }),
2581
+ position: "table-row",
2582
+ onClick: async () => {
2583
+ if (!documentId) {
2584
+ console.error(
2585
+ "You're trying to edit a document without an id, this is likely a bug with Strapi. Please open an issue."
2586
+ );
2587
+ toggleNotification({
2588
+ message: formatMessage({
2589
+ id: "content-manager.actions.edit.error",
2590
+ defaultMessage: "An error occurred while trying to edit the document."
2591
+ }),
2592
+ type: "danger"
2593
+ });
2594
+ return;
2595
+ }
2596
+ navigate({
2597
+ pathname: documentId,
2598
+ search: qs.stringify({
2599
+ plugins: query.plugins
2600
+ })
2601
+ });
2602
+ }
2603
+ };
2604
+ };
2605
+ EditAction.type = "edit";
2606
+ const StyledPencil = styledComponents.styled(Icons.Pencil)`
2607
+ path {
2608
+ fill: currentColor;
2609
+ }
2610
+ `;
2611
+ const CloneAction = ({ model, documentId }) => {
2612
+ const navigate = reactRouterDom.useNavigate();
2613
+ const { formatMessage } = reactIntl.useIntl();
2614
+ const { canCreate } = useDocumentRBAC("CloneAction", ({ canCreate: canCreate2 }) => ({ canCreate: canCreate2 }));
2615
+ const { toggleNotification } = strapiAdmin.useNotification();
2616
+ const { autoClone } = useDocumentActions();
2617
+ const [prohibitedFields, setProhibitedFields] = React__namespace.useState([]);
2618
+ return {
2619
+ disabled: !canCreate,
2620
+ icon: /* @__PURE__ */ jsxRuntime.jsx(StyledDuplicate, {}),
2621
+ label: formatMessage({
2622
+ id: "content-manager.actions.clone.label",
2623
+ defaultMessage: "Duplicate"
2624
+ }),
2625
+ position: "table-row",
2626
+ onClick: async () => {
2627
+ if (!documentId) {
2628
+ console.error(
2629
+ "You're trying to clone a document in the table without an id, this is likely a bug with Strapi. Please open an issue."
2630
+ );
2631
+ toggleNotification({
2632
+ message: formatMessage({
2633
+ id: "content-manager.actions.clone.error",
2634
+ defaultMessage: "An error occurred while trying to clone the document."
2635
+ }),
2636
+ type: "danger"
2637
+ });
2638
+ return;
2639
+ }
2640
+ const res = await autoClone({ model, sourceId: documentId });
2641
+ if ("data" in res) {
2642
+ navigate(res.data.documentId);
2643
+ return true;
2644
+ }
2645
+ if (isBaseQueryError(res.error) && res.error.details && typeof res.error.details === "object" && "prohibitedFields" in res.error.details && Array.isArray(res.error.details.prohibitedFields)) {
2646
+ const prohibitedFields2 = res.error.details.prohibitedFields;
2647
+ setProhibitedFields(prohibitedFields2);
2648
+ }
2649
+ },
2650
+ dialog: {
2651
+ type: "modal",
2652
+ title: formatMessage({
2653
+ id: "content-manager.containers.list.autoCloneModal.header",
2654
+ defaultMessage: "Duplicate"
2655
+ }),
2656
+ content: /* @__PURE__ */ jsxRuntime.jsx(AutoCloneFailureModalBody, { prohibitedFields }),
2657
+ footer: ({ onClose }) => {
2658
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
2659
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: formatMessage({
2660
+ id: "cancel",
2661
+ defaultMessage: "Cancel"
2662
+ }) }),
2663
+ /* @__PURE__ */ jsxRuntime.jsx(
2664
+ designSystem.LinkButton,
2665
+ {
2666
+ tag: reactRouterDom.NavLink,
2667
+ to: {
2668
+ pathname: `clone/${documentId}`
2669
+ },
2670
+ children: formatMessage({
2671
+ id: "content-manager.containers.list.autoCloneModal.create",
2672
+ defaultMessage: "Create"
2673
+ })
2674
+ }
2675
+ )
2676
+ ] });
2677
+ }
2678
+ }
2679
+ };
2680
+ };
2681
+ CloneAction.type = "clone";
2682
+ const StyledDuplicate = styledComponents.styled(Icons.Duplicate)`
2683
+ path {
2684
+ fill: currentColor;
2685
+ }
2686
+ `;
2687
+ const DEFAULT_TABLE_ROW_ACTIONS = [EditAction, CloneAction];
2688
+ class ContentManagerPlugin {
2689
+ /**
2690
+ * The following properties are the stored ones provided by any plugins registering with
2691
+ * the content-manager. The function calls however, need to be called at runtime in the
2692
+ * application, so instead we collate them and run them later with the complete list incl.
2693
+ * ones already registered & the context of the view.
2694
+ */
2695
+ bulkActions = [...DEFAULT_BULK_ACTIONS];
2696
+ documentActions = [
2697
+ ...DEFAULT_ACTIONS,
2698
+ ...DEFAULT_TABLE_ROW_ACTIONS,
2699
+ ...DEFAULT_HEADER_ACTIONS,
2700
+ HistoryAction
2701
+ ];
2702
+ editViewSidePanels = [ActionsPanel];
2703
+ headerActions = [];
2704
+ constructor() {
2705
+ }
2706
+ addEditViewSidePanel(panels) {
2707
+ if (Array.isArray(panels)) {
2708
+ this.editViewSidePanels = [...this.editViewSidePanels, ...panels];
2709
+ } else if (typeof panels === "function") {
2710
+ this.editViewSidePanels = panels(this.editViewSidePanels);
2711
+ } else {
2712
+ throw new Error(
2713
+ `Expected the \`panels\` passed to \`addEditViewSidePanel\` to be an array or a function, but received ${getPrintableType(
2714
+ panels
2715
+ )}`
2716
+ );
2717
+ }
2718
+ }
2719
+ addDocumentAction(actions2) {
2720
+ if (Array.isArray(actions2)) {
2721
+ this.documentActions = [...this.documentActions, ...actions2];
2722
+ } else if (typeof actions2 === "function") {
2723
+ this.documentActions = actions2(this.documentActions);
2724
+ } else {
2725
+ throw new Error(
2726
+ `Expected the \`actions\` passed to \`addDocumentAction\` to be an array or a function, but received ${getPrintableType(
2727
+ actions2
2728
+ )}`
2729
+ );
2730
+ }
2731
+ }
2732
+ addDocumentHeaderAction(actions2) {
2733
+ if (Array.isArray(actions2)) {
2734
+ this.headerActions = [...this.headerActions, ...actions2];
2735
+ } else if (typeof actions2 === "function") {
2736
+ this.headerActions = actions2(this.headerActions);
2737
+ } else {
2738
+ throw new Error(
2739
+ `Expected the \`actions\` passed to \`addDocumentHeaderAction\` to be an array or a function, but received ${getPrintableType(
2740
+ actions2
2741
+ )}`
2742
+ );
2743
+ }
2744
+ }
2745
+ addBulkAction(actions2) {
2746
+ if (Array.isArray(actions2)) {
2747
+ this.bulkActions = [...this.bulkActions, ...actions2];
2748
+ } else if (typeof actions2 === "function") {
2749
+ this.bulkActions = actions2(this.bulkActions);
2750
+ } else {
2751
+ throw new Error(
2752
+ `Expected the \`actions\` passed to \`addBulkAction\` to be an array or a function, but received ${getPrintableType(
2753
+ actions2
2754
+ )}`
2755
+ );
2756
+ }
2757
+ }
2758
+ get config() {
2759
+ return {
2760
+ id: PLUGIN_ID,
2761
+ name: "Content Manager",
2762
+ injectionZones: INJECTION_ZONES,
2763
+ apis: {
2764
+ addBulkAction: this.addBulkAction.bind(this),
2765
+ addDocumentAction: this.addDocumentAction.bind(this),
2766
+ addDocumentHeaderAction: this.addDocumentHeaderAction.bind(this),
2767
+ addEditViewSidePanel: this.addEditViewSidePanel.bind(this),
2768
+ getBulkActions: () => this.bulkActions,
2769
+ getDocumentActions: () => this.documentActions,
2770
+ getEditViewSidePanels: () => this.editViewSidePanels,
2771
+ getHeaderActions: () => this.headerActions
2772
+ }
2773
+ };
2774
+ }
2775
+ }
2776
+ const getPrintableType = (value) => {
2777
+ const nativeType = typeof value;
2778
+ if (nativeType === "object") {
2779
+ if (value === null)
2780
+ return "null";
2781
+ if (Array.isArray(value))
2782
+ return "array";
2783
+ if (value instanceof Object && value.constructor.name !== "Object") {
2784
+ return value.constructor.name;
2785
+ }
2786
+ }
2787
+ return nativeType;
2788
+ };
2789
+ const initialState = {
2790
+ collectionTypeLinks: [],
2791
+ components: [],
2792
+ fieldSizes: {},
2793
+ models: [],
2794
+ singleTypeLinks: [],
2795
+ isLoading: true
2796
+ };
2797
+ const appSlice = toolkit.createSlice({
2798
+ name: "app",
2799
+ initialState,
2800
+ reducers: {
2801
+ setInitialData(state, action) {
2802
+ const {
2803
+ authorizedCollectionTypeLinks,
2804
+ authorizedSingleTypeLinks,
2805
+ components,
2806
+ contentTypeSchemas,
2807
+ fieldSizes
2808
+ } = action.payload;
2809
+ state.collectionTypeLinks = authorizedCollectionTypeLinks.filter(
2810
+ ({ isDisplayed }) => isDisplayed
2811
+ );
2812
+ state.singleTypeLinks = authorizedSingleTypeLinks.filter(({ isDisplayed }) => isDisplayed);
2813
+ state.components = components;
2814
+ state.models = contentTypeSchemas;
2815
+ state.fieldSizes = fieldSizes;
2816
+ state.isLoading = false;
2817
+ }
2818
+ }
2819
+ });
2820
+ const { actions, reducer: reducer$1 } = appSlice;
2821
+ const { setInitialData } = actions;
2822
+ const reducer = toolkit.combineReducers({
2823
+ app: reducer$1
2824
+ });
2825
+ const HOOKS = {
2826
+ /**
2827
+ * Hook that allows to mutate the displayed headers of the list view table
2828
+ * @constant
2829
+ * @type {string}
2830
+ */
2831
+ INJECT_COLUMN_IN_TABLE: "Admin/CM/pages/ListView/inject-column-in-table",
2832
+ /**
2833
+ * Hook that allows to mutate the CM's collection types links pre-set filters
2834
+ * @constant
2835
+ * @type {string}
2836
+ */
2837
+ MUTATE_COLLECTION_TYPES_LINKS: "Admin/CM/pages/App/mutate-collection-types-links",
2838
+ /**
2839
+ * Hook that allows to mutate the CM's edit view layout
2840
+ * @constant
2841
+ * @type {string}
2842
+ */
2843
+ MUTATE_EDIT_VIEW_LAYOUT: "Admin/CM/pages/EditView/mutate-edit-view-layout",
2844
+ /**
2845
+ * Hook that allows to mutate the CM's single types links pre-set filters
2846
+ * @constant
2847
+ * @type {string}
2848
+ */
2849
+ MUTATE_SINGLE_TYPES_LINKS: "Admin/CM/pages/App/mutate-single-types-links"
2850
+ };
2851
+ const contentTypesApi = contentManagerApi.injectEndpoints({
2852
+ endpoints: (builder) => ({
2853
+ getContentTypeConfiguration: builder.query({
2854
+ query: (uid) => ({
2855
+ url: `/content-manager/content-types/${uid}/configuration`,
2856
+ method: "GET"
2857
+ }),
2858
+ transformResponse: (response) => response.data,
2859
+ providesTags: (_result, _error, uid) => [
2860
+ { type: "ContentTypesConfiguration", id: uid },
2861
+ { type: "ContentTypeSettings", id: "LIST" }
2862
+ ]
2863
+ }),
2864
+ getAllContentTypeSettings: builder.query({
2865
+ query: () => "/content-manager/content-types-settings",
2866
+ transformResponse: (response) => response.data,
2867
+ providesTags: [{ type: "ContentTypeSettings", id: "LIST" }]
2868
+ }),
2869
+ updateContentTypeConfiguration: builder.mutation({
2870
+ query: ({ uid, ...body }) => ({
2871
+ url: `/content-manager/content-types/${uid}/configuration`,
2872
+ method: "PUT",
2873
+ data: body
2874
+ }),
2875
+ transformResponse: (response) => response.data,
2876
+ invalidatesTags: (_result, _error, { uid }) => [
2877
+ { type: "ContentTypesConfiguration", id: uid },
2878
+ { type: "ContentTypeSettings", id: "LIST" },
2879
+ // Is this necessary?
2880
+ { type: "InitialData" }
2881
+ ]
2882
+ })
2883
+ })
2884
+ });
2885
+ const {
2886
+ useGetContentTypeConfigurationQuery,
2887
+ useGetAllContentTypeSettingsQuery,
2888
+ useUpdateContentTypeConfigurationMutation
2889
+ } = contentTypesApi;
2890
+ const checkIfAttributeIsDisplayable = (attribute) => {
2891
+ const { type } = attribute;
2892
+ if (type === "relation") {
2893
+ return !attribute.relation.toLowerCase().includes("morph");
2894
+ }
2895
+ return !["json", "dynamiczone", "richtext", "password", "blocks"].includes(type) && !!type;
2896
+ };
2897
+ const getMainField = (attribute, mainFieldName, { schemas, components }) => {
2898
+ if (!mainFieldName) {
2899
+ return void 0;
2900
+ }
2901
+ const mainFieldType = attribute.type === "component" ? components[attribute.component].attributes[mainFieldName].type : (
2902
+ // @ts-expect-error – `targetModel` does exist on the attribute for a relation.
2903
+ schemas.find((schema) => schema.uid === attribute.targetModel)?.attributes[mainFieldName].type
2904
+ );
2905
+ return {
2906
+ name: mainFieldName,
2907
+ type: mainFieldType ?? "string"
2908
+ };
2909
+ };
2910
+ const DEFAULT_SETTINGS = {
2911
+ bulkable: false,
2912
+ filterable: false,
2913
+ searchable: false,
2914
+ pagination: false,
2915
+ defaultSortBy: "",
2916
+ defaultSortOrder: "asc",
2917
+ mainField: "id",
2918
+ pageSize: 10
2919
+ };
2920
+ const useDocumentLayout = (model) => {
2921
+ const { schema, components } = useDocument({ model, collectionType: "" }, { skip: true });
2922
+ const [{ query }] = strapiAdmin.useQueryParams();
2923
+ const runHookWaterfall = strapiAdmin.useStrapiApp("useDocumentLayout", (state) => state.runHookWaterfall);
2924
+ const { toggleNotification } = strapiAdmin.useNotification();
2925
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
2926
+ const { isLoading: isLoadingSchemas, schemas } = useContentTypeSchema();
2927
+ const {
2928
+ data,
2929
+ isLoading: isLoadingConfigs,
2930
+ error,
2931
+ isFetching: isFetchingConfigs
2932
+ } = useGetContentTypeConfigurationQuery(model);
2933
+ const isLoading = isLoadingSchemas || isFetchingConfigs || isLoadingConfigs;
2934
+ React__namespace.useEffect(() => {
2935
+ if (error) {
2936
+ toggleNotification({
2937
+ type: "danger",
2938
+ message: formatAPIError(error)
2939
+ });
2940
+ }
2941
+ }, [error, formatAPIError, toggleNotification]);
2942
+ const editLayout = React__namespace.useMemo(
2943
+ () => data && !isLoading ? formatEditLayout(data, { schemas, schema, components }) : {
2944
+ layout: [],
2945
+ components: {},
2946
+ metadatas: {},
2947
+ options: {},
2948
+ settings: DEFAULT_SETTINGS
2949
+ },
2950
+ [data, isLoading, schemas, schema, components]
2951
+ );
2952
+ const listLayout = React__namespace.useMemo(() => {
2953
+ return data && !isLoading ? formatListLayout(data, { schemas, schema, components }) : {
2954
+ layout: [],
2955
+ metadatas: {},
2956
+ options: {},
2957
+ settings: DEFAULT_SETTINGS
2958
+ };
2959
+ }, [data, isLoading, schemas, schema, components]);
2960
+ const { layout: edit } = React__namespace.useMemo(
2961
+ () => runHookWaterfall(HOOKS.MUTATE_EDIT_VIEW_LAYOUT, {
2962
+ layout: editLayout,
2963
+ query
2964
+ }),
2965
+ [editLayout, query, runHookWaterfall]
2966
+ );
2967
+ return {
2968
+ error,
2969
+ isLoading,
2970
+ edit,
2971
+ list: listLayout
2972
+ };
2973
+ };
2974
+ const useDocLayout = () => {
2975
+ const { model } = useDoc();
2976
+ return useDocumentLayout(model);
2977
+ };
2978
+ const formatEditLayout = (data, {
2979
+ schemas,
2980
+ schema,
2981
+ components
2982
+ }) => {
2983
+ let currentPanelIndex = 0;
2984
+ const panelledEditAttributes = convertEditLayoutToFieldLayouts(
2985
+ data.contentType.layouts.edit,
2986
+ schema?.attributes,
2987
+ data.contentType.metadatas,
2988
+ { configurations: data.components, schemas: components },
2989
+ schemas
2990
+ ).reduce((panels, row) => {
2991
+ if (row.some((field) => field.type === "dynamiczone")) {
2992
+ panels.push([row]);
2993
+ currentPanelIndex += 2;
2994
+ } else {
2995
+ if (!panels[currentPanelIndex]) {
2996
+ panels.push([]);
2997
+ }
2998
+ panels[currentPanelIndex].push(row);
2999
+ }
3000
+ return panels;
3001
+ }, []);
3002
+ const componentEditAttributes = Object.entries(data.components).reduce(
3003
+ (acc, [uid, configuration]) => {
3004
+ acc[uid] = {
3005
+ layout: convertEditLayoutToFieldLayouts(
3006
+ configuration.layouts.edit,
3007
+ components[uid].attributes,
3008
+ configuration.metadatas
3009
+ ),
3010
+ settings: {
3011
+ ...configuration.settings,
3012
+ icon: components[uid].info.icon,
3013
+ displayName: components[uid].info.displayName
3014
+ }
3015
+ };
3016
+ return acc;
3017
+ },
3018
+ {}
3019
+ );
3020
+ const editMetadatas = Object.entries(data.contentType.metadatas).reduce(
3021
+ (acc, [attribute, metadata]) => {
3022
+ return {
3023
+ ...acc,
3024
+ [attribute]: metadata.edit
3025
+ };
3026
+ },
3027
+ {}
3028
+ );
3029
+ return {
3030
+ layout: panelledEditAttributes,
3031
+ components: componentEditAttributes,
3032
+ metadatas: editMetadatas,
3033
+ settings: {
3034
+ ...data.contentType.settings,
3035
+ displayName: schema?.info.displayName
3036
+ },
3037
+ options: {
3038
+ ...schema?.options,
3039
+ ...schema?.pluginOptions,
3040
+ ...data.contentType.options
3041
+ }
3042
+ };
3043
+ };
3044
+ const convertEditLayoutToFieldLayouts = (rows, attributes = {}, metadatas, components, schemas = []) => {
3045
+ return rows.map(
3046
+ (row) => row.map((field) => {
3047
+ const attribute = attributes[field.name];
3048
+ if (!attribute) {
3049
+ return null;
3050
+ }
3051
+ const { edit: metadata } = metadatas[field.name];
3052
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
3053
+ return {
3054
+ attribute,
3055
+ disabled: !metadata.editable,
3056
+ hint: metadata.description,
3057
+ label: metadata.label ?? "",
3058
+ name: field.name,
3059
+ // @ts-expect-error – mainField does exist on the metadata for a relation.
3060
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
3061
+ schemas,
3062
+ components: components?.schemas ?? {}
3063
+ }),
3064
+ placeholder: metadata.placeholder ?? "",
3065
+ required: attribute.required ?? false,
3066
+ size: field.size,
3067
+ unique: "unique" in attribute ? attribute.unique : false,
3068
+ visible: metadata.visible ?? true,
3069
+ type: attribute.type
3070
+ };
3071
+ }).filter((field) => field !== null)
3072
+ );
3073
+ };
3074
+ const formatListLayout = (data, {
3075
+ schemas,
3076
+ schema,
3077
+ components
3078
+ }) => {
3079
+ const listMetadatas = Object.entries(data.contentType.metadatas).reduce(
3080
+ (acc, [attribute, metadata]) => {
3081
+ return {
3082
+ ...acc,
3083
+ [attribute]: metadata.list
3084
+ };
3085
+ },
3086
+ {}
3087
+ );
3088
+ const listAttributes = convertListLayoutToFieldLayouts(
3089
+ data.contentType.layouts.list,
3090
+ schema?.attributes,
3091
+ listMetadatas,
3092
+ { configurations: data.components, schemas: components },
3093
+ schemas
3094
+ );
3095
+ return {
3096
+ layout: listAttributes,
3097
+ settings: { ...data.contentType.settings, displayName: schema?.info.displayName },
3098
+ metadatas: listMetadatas,
3099
+ options: {
3100
+ ...schema?.options,
3101
+ ...schema?.pluginOptions,
3102
+ ...data.contentType.options
3103
+ }
3104
+ };
3105
+ };
3106
+ const convertListLayoutToFieldLayouts = (columns, attributes = {}, metadatas, components, schemas = []) => {
3107
+ return columns.map((name) => {
3108
+ const attribute = attributes[name];
3109
+ if (!attribute) {
3110
+ return null;
3111
+ }
3112
+ const metadata = metadatas[name];
3113
+ const settings = attribute.type === "component" && components ? components.configurations[attribute.component].settings : {};
3114
+ return {
3115
+ attribute,
3116
+ label: metadata.label ?? "",
3117
+ mainField: getMainField(attribute, metadata.mainField || settings.mainField, {
3118
+ schemas,
3119
+ components: components?.schemas ?? {}
3120
+ }),
3121
+ name,
3122
+ searchable: metadata.searchable ?? true,
3123
+ sortable: metadata.sortable ?? true
3124
+ };
3125
+ }).filter((field) => field !== null);
3126
+ };
3127
+ const index = {
3128
+ register(app) {
3129
+ const cm = new ContentManagerPlugin();
3130
+ app.addReducers({
3131
+ [contentManagerApi.reducerPath]: contentManagerApi.reducer,
3132
+ [PLUGIN_ID]: reducer
3133
+ });
3134
+ app.addMiddlewares([() => contentManagerApi.middleware]);
3135
+ app.addMenuLink({
3136
+ to: PLUGIN_ID,
3137
+ icon: Icons.Feather,
3138
+ intlLabel: {
3139
+ id: `content-manager.plugin.name`,
3140
+ defaultMessage: "Content Manager"
3141
+ },
3142
+ permissions: [],
3143
+ Component: () => Promise.resolve().then(() => require("./layout-DLih5-_W.js")).then((mod) => ({ default: mod.Layout }))
3144
+ });
3145
+ app.registerPlugin(cm.config);
3146
+ },
3147
+ async registerTrads({ locales }) {
3148
+ const importedTrads = await Promise.all(
3149
+ locales.map((locale) => {
3150
+ 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-C-V1_90f.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 }) => {
3151
+ return {
3152
+ data: prefixPluginTranslations(data, PLUGIN_ID),
3153
+ locale
3154
+ };
3155
+ }).catch(() => {
3156
+ return {
3157
+ data: {},
3158
+ locale
3159
+ };
3160
+ });
3161
+ })
3162
+ );
3163
+ return Promise.resolve(importedTrads);
3164
+ }
3165
+ };
3166
+ exports.ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD = ATTRIBUTE_TYPES_THAT_CANNOT_BE_MAIN_FIELD;
3167
+ exports.COLLECTION_TYPES = COLLECTION_TYPES;
3168
+ exports.CREATOR_FIELDS = CREATOR_FIELDS;
3169
+ exports.DEFAULT_SETTINGS = DEFAULT_SETTINGS;
3170
+ exports.DOCUMENT_META_FIELDS = DOCUMENT_META_FIELDS;
3171
+ exports.DocumentRBAC = DocumentRBAC;
3172
+ exports.DocumentStatus = DocumentStatus;
3173
+ exports.HOOKS = HOOKS;
3174
+ exports.Header = Header;
3175
+ exports.InjectionZone = InjectionZone;
3176
+ exports.PERMISSIONS = PERMISSIONS;
3177
+ exports.Panels = Panels;
3178
+ exports.RelativeTime = RelativeTime;
3179
+ exports.SINGLE_TYPES = SINGLE_TYPES;
3180
+ exports.TableActions = TableActions;
3181
+ exports.buildValidParams = buildValidParams;
3182
+ exports.capitalise = capitalise;
3183
+ exports.checkIfAttributeIsDisplayable = checkIfAttributeIsDisplayable;
3184
+ exports.contentManagerApi = contentManagerApi;
3185
+ exports.convertEditLayoutToFieldLayouts = convertEditLayoutToFieldLayouts;
3186
+ exports.convertListLayoutToFieldLayouts = convertListLayoutToFieldLayouts;
3187
+ exports.createYupSchema = createYupSchema;
3188
+ exports.extractContentTypeComponents = extractContentTypeComponents;
3189
+ exports.getDisplayName = getDisplayName;
3190
+ exports.getMainField = getMainField;
3191
+ exports.getTranslation = getTranslation;
3192
+ exports.index = index;
3193
+ exports.routes = routes;
3194
+ exports.setInitialData = setInitialData;
3195
+ exports.useContentTypeSchema = useContentTypeSchema;
3196
+ exports.useDoc = useDoc;
3197
+ exports.useDocLayout = useDocLayout;
3198
+ exports.useDocument = useDocument;
3199
+ exports.useDocumentActions = useDocumentActions;
3200
+ exports.useDocumentLayout = useDocumentLayout;
3201
+ exports.useDocumentRBAC = useDocumentRBAC;
3202
+ exports.useGetAllContentTypeSettingsQuery = useGetAllContentTypeSettingsQuery;
3203
+ exports.useGetAllDocumentsQuery = useGetAllDocumentsQuery;
3204
+ exports.useGetContentTypeConfigurationQuery = useGetContentTypeConfigurationQuery;
3205
+ exports.useGetInitialDataQuery = useGetInitialDataQuery;
3206
+ exports.useUpdateContentTypeConfigurationMutation = useUpdateContentTypeConfigurationMutation;
3207
+ //# sourceMappingURL=index-DFK7LwDW.js.map