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

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