@strapi/content-manager 0.0.0-experimental.5b211b38912691ee2eab22d47b5095ea2fcfec76 → 0.0.0-experimental.5bd54472327d69041855d9b38a3d4e445535c9a3

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 (227) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
  3. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
  4. package/dist/_chunks/{ComponentConfigurationPage-DmwmiFQy.mjs → ComponentConfigurationPage-9_4yUE9L.mjs} +4 -4
  5. package/dist/_chunks/{ComponentConfigurationPage-DmwmiFQy.mjs.map → ComponentConfigurationPage-9_4yUE9L.mjs.map} +1 -1
  6. package/dist/_chunks/{ComponentConfigurationPage-C-49MccQ.js → ComponentConfigurationPage-DBSh-kET.js} +5 -6
  7. package/dist/_chunks/{ComponentConfigurationPage-C-49MccQ.js.map → ComponentConfigurationPage-DBSh-kET.js.map} +1 -1
  8. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
  9. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
  10. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
  11. package/dist/_chunks/{EditConfigurationPage-DjFJw56M.js → EditConfigurationPage-Bl_U2JgH.js} +5 -6
  12. package/dist/_chunks/{EditConfigurationPage-DjFJw56M.js.map → EditConfigurationPage-Bl_U2JgH.js.map} +1 -1
  13. package/dist/_chunks/{EditConfigurationPage-JT3E7NZy.mjs → EditConfigurationPage-COe6hjPC.mjs} +4 -4
  14. package/dist/_chunks/{EditConfigurationPage-JT3E7NZy.mjs.map → EditConfigurationPage-COe6hjPC.mjs.map} +1 -1
  15. package/dist/_chunks/{EditViewPage-zT3fBr4Y.js → EditViewPage-D4yFJET6.js} +36 -49
  16. package/dist/_chunks/EditViewPage-D4yFJET6.js.map +1 -0
  17. package/dist/_chunks/{EditViewPage-CPj61RMh.mjs → EditViewPage-DrmVmYN0.mjs} +34 -46
  18. package/dist/_chunks/EditViewPage-DrmVmYN0.mjs.map +1 -0
  19. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  20. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  21. package/dist/_chunks/{Form-y5g1SRsh.js → Form-C4rSaGsz.js} +39 -21
  22. package/dist/_chunks/Form-C4rSaGsz.js.map +1 -0
  23. package/dist/_chunks/{Form-DHrru2AV.mjs → Form-DamaxNpG.mjs} +37 -18
  24. package/dist/_chunks/Form-DamaxNpG.mjs.map +1 -0
  25. package/dist/_chunks/{History-Bru_KoeP.mjs → History-D1PreDSY.mjs} +108 -116
  26. package/dist/_chunks/History-D1PreDSY.mjs.map +1 -0
  27. package/dist/_chunks/{History-CqN6K7SX.js → History-DTm8UCCQ.js} +118 -127
  28. package/dist/_chunks/History-DTm8UCCQ.js.map +1 -0
  29. package/dist/_chunks/{Field-Boxf9Ajp.js → Input-B7sapvBG.js} +1431 -1312
  30. package/dist/_chunks/Input-B7sapvBG.js.map +1 -0
  31. package/dist/_chunks/{Field-dha5VnIQ.mjs → Input-CZ1YvjHR.mjs} +1439 -1320
  32. package/dist/_chunks/Input-CZ1YvjHR.mjs.map +1 -0
  33. package/dist/_chunks/{ListConfigurationPage-D8wGABj0.mjs → ListConfigurationPage-Bbi32isk.mjs} +25 -12
  34. package/dist/_chunks/ListConfigurationPage-Bbi32isk.mjs.map +1 -0
  35. package/dist/_chunks/{ListConfigurationPage-R_p-SbHZ.js → ListConfigurationPage-ysFMjKI3.js} +25 -13
  36. package/dist/_chunks/ListConfigurationPage-ysFMjKI3.js.map +1 -0
  37. package/dist/_chunks/{ListViewPage-SID6TRb9.mjs → ListViewPage-Bud_jBDQ.mjs} +122 -78
  38. package/dist/_chunks/ListViewPage-Bud_jBDQ.mjs.map +1 -0
  39. package/dist/_chunks/{ListViewPage-pEw_zug9.js → ListViewPage-DTuuxU3n.js} +121 -78
  40. package/dist/_chunks/ListViewPage-DTuuxU3n.js.map +1 -0
  41. package/dist/_chunks/{NoContentTypePage-C5dcQojD.js → NoContentTypePage-CL7VVeYs.js} +2 -2
  42. package/dist/_chunks/{NoContentTypePage-C5dcQojD.js.map → NoContentTypePage-CL7VVeYs.js.map} +1 -1
  43. package/dist/_chunks/{NoContentTypePage-CJ7UXwrQ.mjs → NoContentTypePage-DVhkugsf.mjs} +2 -2
  44. package/dist/_chunks/{NoContentTypePage-CJ7UXwrQ.mjs.map → NoContentTypePage-DVhkugsf.mjs.map} +1 -1
  45. package/dist/_chunks/{NoPermissionsPage-B7syEq5E.mjs → NoPermissionsPage-CMdM-dCo.mjs} +2 -2
  46. package/dist/_chunks/{NoPermissionsPage-B7syEq5E.mjs.map → NoPermissionsPage-CMdM-dCo.mjs.map} +1 -1
  47. package/dist/_chunks/{NoPermissionsPage-BtPrImPP.js → NoPermissionsPage-v7I599vC.js} +2 -2
  48. package/dist/_chunks/{NoPermissionsPage-BtPrImPP.js.map → NoPermissionsPage-v7I599vC.js.map} +1 -1
  49. package/dist/_chunks/Preview-BNuU0SuQ.mjs +287 -0
  50. package/dist/_chunks/Preview-BNuU0SuQ.mjs.map +1 -0
  51. package/dist/_chunks/Preview-Cxq-uI6D.js +305 -0
  52. package/dist/_chunks/Preview-Cxq-uI6D.js.map +1 -0
  53. package/dist/_chunks/{Relations-B9Crnhnn.mjs → Relations-C2Ahkrdg.mjs} +76 -42
  54. package/dist/_chunks/Relations-C2Ahkrdg.mjs.map +1 -0
  55. package/dist/_chunks/{Relations-DjTQ5kGB.js → Relations-CWS79QQn.js} +76 -43
  56. package/dist/_chunks/Relations-CWS79QQn.js.map +1 -0
  57. package/dist/_chunks/{en-fbKQxLGn.js → en-BR48D_RH.js} +39 -18
  58. package/dist/_chunks/{en-fbKQxLGn.js.map → en-BR48D_RH.js.map} +1 -1
  59. package/dist/_chunks/{en-Ux26r5pl.mjs → en-D65uIF6Y.mjs} +39 -18
  60. package/dist/_chunks/{en-Ux26r5pl.mjs.map → en-D65uIF6Y.mjs.map} +1 -1
  61. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  62. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  63. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  64. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  65. package/dist/_chunks/{fr-B7kGGg3E.js → fr-C43IbhA_.js} +16 -3
  66. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-C43IbhA_.js.map} +1 -1
  67. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr-DBseuRuB.mjs} +16 -3
  68. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr-DBseuRuB.mjs.map} +1 -1
  69. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  70. package/dist/_chunks/{index-DVPWZkbS.js → index-DQsvBb_N.js} +1463 -762
  71. package/dist/_chunks/index-DQsvBb_N.js.map +1 -0
  72. package/dist/_chunks/{index-DJXJw9V5.mjs → index-ZKrsjv-2.mjs} +1481 -780
  73. package/dist/_chunks/index-ZKrsjv-2.mjs.map +1 -0
  74. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  75. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  76. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  77. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  78. package/dist/_chunks/{layout-Dm6fbiQj.js → layout-Cl0NhlQB.js} +26 -14
  79. package/dist/_chunks/layout-Cl0NhlQB.js.map +1 -0
  80. package/dist/_chunks/{layout-Bau7ZfLV.mjs → layout-fQk1rMk9.mjs} +26 -13
  81. package/dist/_chunks/layout-fQk1rMk9.mjs.map +1 -0
  82. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  83. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  84. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  85. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  86. package/dist/_chunks/{relations-CKnpRgrN.js → relations-BRfBxVbX.js} +6 -7
  87. package/dist/_chunks/relations-BRfBxVbX.js.map +1 -0
  88. package/dist/_chunks/{relations-BH_kBSJ0.mjs → relations-BakOFl_1.mjs} +6 -7
  89. package/dist/_chunks/relations-BakOFl_1.mjs.map +1 -0
  90. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  91. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  92. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  93. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  94. package/dist/_chunks/usePrev-CZGy2Vjf.mjs +29 -0
  95. package/dist/_chunks/usePrev-CZGy2Vjf.mjs.map +1 -0
  96. package/dist/_chunks/{usePrev-B9w_-eYc.js → usePrev-D5J_2fEu.js} +14 -1
  97. package/dist/_chunks/usePrev-D5J_2fEu.js.map +1 -0
  98. package/dist/admin/index.js +3 -1
  99. package/dist/admin/index.js.map +1 -1
  100. package/dist/admin/index.mjs +6 -4
  101. package/dist/admin/src/content-manager.d.ts +3 -2
  102. package/dist/admin/src/exports.d.ts +2 -1
  103. package/dist/admin/src/history/index.d.ts +3 -0
  104. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  105. package/dist/admin/src/hooks/useDocument.d.ts +49 -1
  106. package/dist/admin/src/index.d.ts +1 -0
  107. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  108. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +2 -1
  109. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
  110. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  111. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  112. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
  113. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
  114. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
  115. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  116. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  117. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  118. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +4 -48
  119. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
  120. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  121. package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
  122. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  123. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  124. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  125. package/dist/admin/src/preview/index.d.ts +4 -0
  126. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  127. package/dist/admin/src/preview/routes.d.ts +3 -0
  128. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  129. package/dist/admin/src/router.d.ts +1 -1
  130. package/dist/admin/src/services/api.d.ts +1 -1
  131. package/dist/admin/src/services/components.d.ts +2 -2
  132. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  133. package/dist/admin/src/services/documents.d.ts +19 -20
  134. package/dist/admin/src/services/init.d.ts +1 -1
  135. package/dist/admin/src/services/relations.d.ts +2 -2
  136. package/dist/admin/src/services/uid.d.ts +3 -3
  137. package/dist/admin/src/utils/validation.d.ts +4 -1
  138. package/dist/server/index.js +762 -432
  139. package/dist/server/index.js.map +1 -1
  140. package/dist/server/index.mjs +763 -432
  141. package/dist/server/index.mjs.map +1 -1
  142. package/dist/server/src/bootstrap.d.ts.map +1 -1
  143. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  144. package/dist/server/src/controllers/index.d.ts.map +1 -1
  145. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  146. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  147. package/dist/server/src/controllers/utils/metadata.d.ts +16 -1
  148. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  149. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  150. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  151. package/dist/server/src/history/controllers/history-version.d.ts +1 -1
  152. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  153. package/dist/server/src/history/services/history.d.ts +3 -3
  154. package/dist/server/src/history/services/history.d.ts.map +1 -1
  155. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  156. package/dist/server/src/history/services/utils.d.ts +8 -12
  157. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  158. package/dist/server/src/index.d.ts +7 -6
  159. package/dist/server/src/index.d.ts.map +1 -1
  160. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  161. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  162. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  163. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  164. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  165. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  166. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  167. package/dist/server/src/preview/index.d.ts +4 -0
  168. package/dist/server/src/preview/index.d.ts.map +1 -0
  169. package/dist/server/src/preview/routes/index.d.ts +8 -0
  170. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  171. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  172. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  173. package/dist/server/src/preview/services/index.d.ts +16 -0
  174. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  175. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  176. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  177. package/dist/server/src/preview/services/preview.d.ts +12 -0
  178. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  179. package/dist/server/src/preview/utils.d.ts +19 -0
  180. package/dist/server/src/preview/utils.d.ts.map +1 -0
  181. package/dist/server/src/register.d.ts.map +1 -1
  182. package/dist/server/src/routes/index.d.ts.map +1 -1
  183. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  184. package/dist/server/src/services/document-metadata.d.ts +12 -10
  185. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  186. package/dist/server/src/services/index.d.ts +7 -6
  187. package/dist/server/src/services/index.d.ts.map +1 -1
  188. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  189. package/dist/server/src/services/utils/populate.d.ts +2 -2
  190. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  191. package/dist/server/src/utils/index.d.ts +2 -0
  192. package/dist/server/src/utils/index.d.ts.map +1 -1
  193. package/dist/shared/contracts/collection-types.d.ts +3 -1
  194. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  195. package/dist/shared/contracts/index.d.ts +1 -0
  196. package/dist/shared/contracts/index.d.ts.map +1 -1
  197. package/dist/shared/contracts/preview.d.ts +27 -0
  198. package/dist/shared/contracts/preview.d.ts.map +1 -0
  199. package/dist/shared/index.js +4 -0
  200. package/dist/shared/index.js.map +1 -1
  201. package/dist/shared/index.mjs +4 -0
  202. package/dist/shared/index.mjs.map +1 -1
  203. package/package.json +17 -16
  204. package/dist/_chunks/EditViewPage-CPj61RMh.mjs.map +0 -1
  205. package/dist/_chunks/EditViewPage-zT3fBr4Y.js.map +0 -1
  206. package/dist/_chunks/Field-Boxf9Ajp.js.map +0 -1
  207. package/dist/_chunks/Field-dha5VnIQ.mjs.map +0 -1
  208. package/dist/_chunks/Form-DHrru2AV.mjs.map +0 -1
  209. package/dist/_chunks/Form-y5g1SRsh.js.map +0 -1
  210. package/dist/_chunks/History-Bru_KoeP.mjs.map +0 -1
  211. package/dist/_chunks/History-CqN6K7SX.js.map +0 -1
  212. package/dist/_chunks/ListConfigurationPage-D8wGABj0.mjs.map +0 -1
  213. package/dist/_chunks/ListConfigurationPage-R_p-SbHZ.js.map +0 -1
  214. package/dist/_chunks/ListViewPage-SID6TRb9.mjs.map +0 -1
  215. package/dist/_chunks/ListViewPage-pEw_zug9.js.map +0 -1
  216. package/dist/_chunks/Relations-B9Crnhnn.mjs.map +0 -1
  217. package/dist/_chunks/Relations-DjTQ5kGB.js.map +0 -1
  218. package/dist/_chunks/index-DJXJw9V5.mjs.map +0 -1
  219. package/dist/_chunks/index-DVPWZkbS.js.map +0 -1
  220. package/dist/_chunks/layout-Bau7ZfLV.mjs.map +0 -1
  221. package/dist/_chunks/layout-Dm6fbiQj.js.map +0 -1
  222. package/dist/_chunks/relations-BH_kBSJ0.mjs.map +0 -1
  223. package/dist/_chunks/relations-CKnpRgrN.js.map +0 -1
  224. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  225. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  226. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  227. package/strapi-server.js +0 -3
@@ -3,23 +3,73 @@ const jsxRuntime = require("react/jsx-runtime");
3
3
  const React = require("react");
4
4
  const strapiAdmin = require("@strapi/admin/strapi-admin");
5
5
  const designSystem = require("@strapi/design-system");
6
- const pipe$1 = require("lodash/fp/pipe");
7
- const reactIntl = require("react-intl");
8
- const index = require("./index-DVPWZkbS.js");
9
- const fractionalIndexing = require("fractional-indexing");
10
- const Relations = require("./Relations-DjTQ5kGB.js");
11
6
  const Icons = require("@strapi/icons");
7
+ const reactIntl = require("react-intl");
8
+ const index = require("./index-DQsvBb_N.js");
12
9
  const styledComponents = require("styled-components");
13
- const ComponentIcon = require("./ComponentIcon-BXdiCGQp.js");
14
- const reactDndHtml5Backend = require("react-dnd-html5-backend");
15
- const useDragAndDrop = require("./useDragAndDrop-J0TUUbR6.js");
16
- const objects = require("./objects-gigeqt7s.js");
17
10
  const slate = require("slate");
18
11
  const slateHistory = require("slate-history");
19
12
  const slateReact = require("slate-react");
20
- const usePrev = require("./usePrev-B9w_-eYc.js");
13
+ const Prism = require("prismjs");
14
+ require("prismjs/themes/prism-solarizedlight.css");
15
+ require("prismjs/components/prism-asmatmel");
16
+ require("prismjs/components/prism-bash");
17
+ require("prismjs/components/prism-basic");
18
+ require("prismjs/components/prism-c");
19
+ require("prismjs/components/prism-clojure");
20
+ require("prismjs/components/prism-cobol");
21
+ require("prismjs/components/prism-cpp");
22
+ require("prismjs/components/prism-csharp");
23
+ require("prismjs/components/prism-dart");
24
+ require("prismjs/components/prism-docker");
25
+ require("prismjs/components/prism-elixir");
26
+ require("prismjs/components/prism-erlang");
27
+ require("prismjs/components/prism-fortran");
28
+ require("prismjs/components/prism-fsharp");
29
+ require("prismjs/components/prism-go");
30
+ require("prismjs/components/prism-graphql");
31
+ require("prismjs/components/prism-groovy");
32
+ require("prismjs/components/prism-haskell");
33
+ require("prismjs/components/prism-haxe");
34
+ require("prismjs/components/prism-ini");
35
+ require("prismjs/components/prism-java");
36
+ require("prismjs/components/prism-javascript");
37
+ require("prismjs/components/prism-jsx");
38
+ require("prismjs/components/prism-json");
39
+ require("prismjs/components/prism-julia");
40
+ require("prismjs/components/prism-kotlin");
41
+ require("prismjs/components/prism-latex");
42
+ require("prismjs/components/prism-lua");
43
+ require("prismjs/components/prism-markdown");
44
+ require("prismjs/components/prism-matlab");
45
+ require("prismjs/components/prism-makefile");
46
+ require("prismjs/components/prism-objectivec");
47
+ require("prismjs/components/prism-perl");
48
+ require("prismjs/components/prism-php");
49
+ require("prismjs/components/prism-powershell");
50
+ require("prismjs/components/prism-python");
51
+ require("prismjs/components/prism-r");
52
+ require("prismjs/components/prism-ruby");
53
+ require("prismjs/components/prism-rust");
54
+ require("prismjs/components/prism-sas");
55
+ require("prismjs/components/prism-scala");
56
+ require("prismjs/components/prism-scheme");
57
+ require("prismjs/components/prism-sql");
58
+ require("prismjs/components/prism-stata");
59
+ require("prismjs/components/prism-swift");
60
+ require("prismjs/components/prism-typescript");
61
+ require("prismjs/components/prism-tsx");
62
+ require("prismjs/components/prism-vbnet");
63
+ require("prismjs/components/prism-yaml");
64
+ const usePrev = require("./usePrev-D5J_2fEu.js");
65
+ const useDragAndDrop = require("./useDragAndDrop-BMtgCYzL.js");
21
66
  const Toolbar = require("@radix-ui/react-toolbar");
67
+ const reactDndHtml5Backend = require("react-dnd-html5-backend");
22
68
  const reactRouterDom = require("react-router-dom");
69
+ const objects = require("./objects-BcXOv6_9.js");
70
+ const Relations = require("./Relations-CWS79QQn.js");
71
+ const pipe$1 = require("lodash/fp/pipe");
72
+ const ComponentIcon = require("./ComponentIcon-CRbtQEUV.js");
23
73
  const CodeMirror = require("codemirror5");
24
74
  const sanitizeHtml = require("sanitize-html");
25
75
  const highlight_js = require("highlight.js");
@@ -37,8 +87,7 @@ require("highlight.js/styles/solarized-dark.css");
37
87
  require("codemirror5/addon/display/placeholder");
38
88
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
39
89
  function _interopNamespace(e) {
40
- if (e && e.__esModule)
41
- return e;
90
+ if (e && e.__esModule) return e;
42
91
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
43
92
  if (e) {
44
93
  for (const k in e) {
@@ -55,8 +104,9 @@ function _interopNamespace(e) {
55
104
  return Object.freeze(n);
56
105
  }
57
106
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
58
- const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
107
+ const Prism__namespace = /* @__PURE__ */ _interopNamespace(Prism);
59
108
  const Toolbar__namespace = /* @__PURE__ */ _interopNamespace(Toolbar);
109
+ const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
60
110
  const CodeMirror__default = /* @__PURE__ */ _interopDefault(CodeMirror);
61
111
  const sanitizeHtml__default = /* @__PURE__ */ _interopDefault(sanitizeHtml);
62
112
  const Markdown__default = /* @__PURE__ */ _interopDefault(Markdown);
@@ -69,93 +119,6 @@ const ins__default = /* @__PURE__ */ _interopDefault(ins);
69
119
  const mark__default = /* @__PURE__ */ _interopDefault(mark);
70
120
  const sub__default = /* @__PURE__ */ _interopDefault(sub);
71
121
  const sup__default = /* @__PURE__ */ _interopDefault(sup);
72
- const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
73
- const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
74
- const traverse = (datum, attributes) => {
75
- return Object.entries(datum).reduce((acc, [key, value]) => {
76
- const attribute = attributes[key];
77
- if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
78
- acc[key] = value;
79
- return acc;
80
- }
81
- if (attribute.type === "component") {
82
- if (attribute.repeatable) {
83
- const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
84
- acc[key] = componentValue.map(
85
- (componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
86
- );
87
- } else {
88
- const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
89
- acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
90
- }
91
- } else if (attribute.type === "dynamiczone") {
92
- const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
93
- acc[key] = dynamicZoneValue.map(
94
- (componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
95
- );
96
- } else if (predicate(attribute, value)) {
97
- acc[key] = transform(value, attribute);
98
- } else {
99
- acc[key] = value;
100
- }
101
- return acc;
102
- }, {});
103
- };
104
- return traverse(data, schema.attributes);
105
- };
106
- const removeProhibitedFields = (prohibitedFields) => traverseData(
107
- (attribute) => prohibitedFields.includes(attribute.type),
108
- () => ""
109
- );
110
- const prepareRelations = traverseData(
111
- (attribute) => attribute.type === "relation",
112
- () => ({
113
- connect: [],
114
- disconnect: []
115
- })
116
- );
117
- const prepareTempKeys = traverseData(
118
- (attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
119
- (data) => {
120
- if (Array.isArray(data) && data.length > 0) {
121
- const keys = fractionalIndexing.generateNKeysBetween(void 0, void 0, data.length);
122
- return data.map((datum, index2) => ({
123
- ...datum,
124
- __temp_key__: keys[index2]
125
- }));
126
- }
127
- return data;
128
- }
129
- );
130
- const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
131
- const schemaKeys = Object.keys(schema.attributes);
132
- const dataKeys = Object.keys(data);
133
- const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
134
- const revisedData = [...keysToRemove, ...index.DOCUMENT_META_FIELDS].reduce((acc, key) => {
135
- delete acc[key];
136
- return acc;
137
- }, structuredClone(data));
138
- return revisedData;
139
- };
140
- const removeNullValues = (data) => {
141
- return Object.entries(data).reduce((acc, [key, value]) => {
142
- if (value === null) {
143
- return acc;
144
- }
145
- acc[key] = value;
146
- return acc;
147
- }, {});
148
- };
149
- const transformDocument = (schema, components = {}) => (document2) => {
150
- const transformations = pipe__default.default(
151
- removeFieldsThatDontExistOnSchema(schema),
152
- removeProhibitedFields(["password"])(schema, components),
153
- removeNullValues,
154
- prepareRelations(schema, components),
155
- prepareTempKeys(schema, components)
156
- );
157
- return transformations(document2);
158
- };
159
122
  const componentStore = /* @__PURE__ */ new Map();
160
123
  const useLazyComponents = (componentUids = []) => {
161
124
  const [lazyComponentStore, setLazyComponentStore] = React.useState(Object.fromEntries(componentStore));
@@ -197,7 +160,8 @@ const useLazyComponents = (componentUids = []) => {
197
160
  const codeLanguages = [
198
161
  {
199
162
  value: "asm",
200
- label: "Assembly"
163
+ label: "Assembly",
164
+ decorate: "asmatmel"
201
165
  },
202
166
  {
203
167
  value: "bash",
@@ -233,7 +197,8 @@ const codeLanguages = [
233
197
  },
234
198
  {
235
199
  value: "dockerfile",
236
- label: "Dockerfile"
200
+ label: "Dockerfile",
201
+ decorate: "docker"
237
202
  },
238
203
  {
239
204
  value: "elixir",
@@ -389,7 +354,8 @@ const codeLanguages = [
389
354
  },
390
355
  {
391
356
  value: "typescript",
392
- label: "TypeScript"
357
+ label: "TypeScript",
358
+ decorate: "ts"
393
359
  },
394
360
  {
395
361
  value: "tsx",
@@ -405,7 +371,8 @@ const codeLanguages = [
405
371
  },
406
372
  {
407
373
  value: "yaml",
408
- label: "YAML"
374
+ label: "YAML",
375
+ decorate: "yml"
409
376
  }
410
377
  ];
411
378
  const baseHandleConvert = (editor, attributesToSet) => {
@@ -471,6 +438,29 @@ const pressEnterTwiceToExit = (editor) => {
471
438
  });
472
439
  }
473
440
  };
441
+ const decorateCode = ([node, path]) => {
442
+ const ranges = [];
443
+ if (!slate.Element.isElement(node) || node.type !== "code") return ranges;
444
+ const text = slate.Node.string(node);
445
+ const language = codeLanguages.find((lang) => lang.value === node.language);
446
+ const decorateKey = language?.decorate ?? language?.value;
447
+ const selectedLanguage = Prism__namespace.languages[decorateKey || "plaintext"];
448
+ const tokens = Prism__namespace.tokenize(text, selectedLanguage);
449
+ let start = 0;
450
+ for (const token of tokens) {
451
+ const length = token.length;
452
+ const end = start + length;
453
+ if (typeof token !== "string") {
454
+ ranges.push({
455
+ anchor: { path, offset: start },
456
+ focus: { path, offset: end },
457
+ className: `token ${token.type}`
458
+ });
459
+ }
460
+ start = end;
461
+ }
462
+ return ranges;
463
+ };
474
464
  const CodeBlock = styledComponents.styled.pre`
475
465
  border-radius: ${({ theme }) => theme.borderRadius};
476
466
  background-color: ${({ theme }) => theme.colors.neutral100};
@@ -542,7 +532,7 @@ const CodeEditor = (props) => {
542
532
  const codeBlocks = {
543
533
  code: {
544
534
  renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(CodeEditor, { ...props }),
545
- icon: Icons.Code,
535
+ icon: Icons.CodeBlock,
546
536
  label: {
547
537
  id: "components.Blocks.blocks.code",
548
538
  defaultMessage: "Code block"
@@ -555,8 +545,7 @@ const codeBlocks = {
555
545
  handleEnterKey(editor) {
556
546
  pressEnterTwiceToExit(editor);
557
547
  },
558
- snippets: ["```"],
559
- dragHandleTopMargin: "10px"
548
+ snippets: ["```"]
560
549
  }
561
550
  };
562
551
  const H1 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h1" })`
@@ -731,8 +720,7 @@ const ImageDialog = () => {
731
720
  const [isOpen, setIsOpen] = React__namespace.useState(true);
732
721
  const { editor } = useBlocksEditorContext("ImageDialog");
733
722
  const components = strapiAdmin.useStrapiApp("ImageDialog", (state) => state.components);
734
- if (!components || !isOpen)
735
- return null;
723
+ if (!components || !isOpen) return null;
736
724
  const MediaLibraryDialog = components["media-library"];
737
725
  const insertImages = (images) => {
738
726
  slate.Transforms.unwrapNodes(editor, {
@@ -741,14 +729,12 @@ const ImageDialog = () => {
741
729
  });
742
730
  const nodeEntryBeingReplaced = slate.Editor.above(editor, {
743
731
  match(node) {
744
- if (slate.Editor.isEditor(node))
745
- return false;
732
+ if (slate.Editor.isEditor(node)) return false;
746
733
  const isInlineNode = ["text", "link"].includes(node.type);
747
734
  return !isInlineNode;
748
735
  }
749
736
  });
750
- if (!nodeEntryBeingReplaced)
751
- return;
737
+ if (!nodeEntryBeingReplaced) return;
752
738
  const [, pathToInsert] = nodeEntryBeingReplaced;
753
739
  slate.Transforms.removeNodes(editor);
754
740
  const nodesToInsert = images.map((image) => {
@@ -894,20 +880,8 @@ const LinkContent = React__namespace.forwardRef(
894
880
  const [linkText, setLinkText] = React__namespace.useState(elementText);
895
881
  const [linkUrl, setLinkUrl] = React__namespace.useState(link.url);
896
882
  const linkInputRef = React__namespace.useRef(null);
897
- const [showRemoveButton, setShowRemoveButton] = React__namespace.useState(false);
883
+ const isLastInsertedLink = editor.lastInsertedLinkPath ? !slate.Path.equals(path, editor.lastInsertedLinkPath) : true;
898
884
  const [isSaveDisabled, setIsSaveDisabled] = React__namespace.useState(false);
899
- const handleOpenChange = (isOpen) => {
900
- if (isOpen) {
901
- setPopoverOpen(isOpen);
902
- setShowRemoveButton(isOpen);
903
- } else {
904
- setPopoverOpen(isOpen);
905
- if (link.url === "") {
906
- removeLink(editor);
907
- }
908
- slateReact.ReactEditor.focus(editor);
909
- }
910
- };
911
885
  const onLinkChange = (e) => {
912
886
  setIsSaveDisabled(false);
913
887
  setLinkUrl(e.target.value);
@@ -928,15 +902,32 @@ const LinkContent = React__namespace.forwardRef(
928
902
  editLink(editor, { url: linkUrl, text: linkText });
929
903
  setPopoverOpen(false);
930
904
  editor.lastInsertedLinkPath = null;
905
+ slateReact.ReactEditor.focus(editor);
906
+ };
907
+ const handleClose = () => {
908
+ if (link.url === "") {
909
+ removeLink(editor);
910
+ }
911
+ setPopoverOpen(false);
912
+ slateReact.ReactEditor.focus(editor);
931
913
  };
932
914
  React__namespace.useEffect(() => {
933
- if (popoverOpen)
934
- linkInputRef.current?.focus();
915
+ if (popoverOpen) linkInputRef.current?.focus();
935
916
  }, [popoverOpen]);
936
917
  const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
937
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { onOpenChange: handleOpenChange, open: popoverOpen, children: [
938
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(StyledBaseLink, { ...attributes, ref: forwardedRef, href: link.url, color: "primary600", children }) }),
939
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 4, tag: "form", onSubmit: handleSave, direction: "column", gap: 4, children: [
918
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { open: popoverOpen, children: [
919
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
920
+ StyledBaseLink,
921
+ {
922
+ ...attributes,
923
+ ref: forwardedRef,
924
+ href: link.url,
925
+ onClick: () => setPopoverOpen(true),
926
+ color: "primary600",
927
+ children
928
+ }
929
+ ) }),
930
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { onPointerDownOutside: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 4, direction: "column", gap: 4, children: [
940
931
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { width: "368px", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
941
932
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
942
933
  id: "components.Blocks.popover.text",
@@ -982,7 +973,7 @@ const LinkContent = React__namespace.forwardRef(
982
973
  {
983
974
  variant: "danger-light",
984
975
  onClick: () => removeLink(editor),
985
- $visible: showRemoveButton,
976
+ $visible: isLastInsertedLink,
986
977
  children: formatMessage({
987
978
  id: "components.Blocks.popover.remove",
988
979
  defaultMessage: "Remove"
@@ -990,12 +981,12 @@ const LinkContent = React__namespace.forwardRef(
990
981
  }
991
982
  ),
992
983
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
993
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: () => handleOpenChange(false), children: formatMessage({
994
- id: "components.Blocks.popover.cancel",
984
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
985
+ id: "global.cancel",
995
986
  defaultMessage: "Cancel"
996
987
  }) }),
997
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { type: "submit", disabled: Boolean(inputNotDirty) || isSaveDisabled, children: formatMessage({
998
- id: "components.Blocks.popover.save",
988
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
989
+ id: "global.save",
999
990
  defaultMessage: "Save"
1000
991
  }) })
1001
992
  ] })
@@ -1076,8 +1067,7 @@ const isText$1 = (node) => {
1076
1067
  return slate.Node.isNode(node) && !slate.Editor.isEditor(node) && node.type === "text";
1077
1068
  };
1078
1069
  const handleBackspaceKeyOnList = (editor, event) => {
1079
- if (!editor.selection)
1080
- return;
1070
+ if (!editor.selection) return;
1081
1071
  const [currentListItem, currentListItemPath] = slate.Editor.parent(editor, editor.selection.anchor);
1082
1072
  const [currentList, currentListPath] = slate.Editor.parent(editor, currentListItemPath);
1083
1073
  const isListEmpty = currentList.children.length === 1 && isText$1(currentListItem.children[0]) && currentListItem.children[0].text === "";
@@ -1186,8 +1176,7 @@ const handleEnterKeyOnList = (editor) => {
1186
1176
  };
1187
1177
  const handleConvertToList = (editor, format) => {
1188
1178
  const convertedPath = baseHandleConvert(editor, { type: "list-item" });
1189
- if (!convertedPath)
1190
- return;
1179
+ if (!convertedPath) return;
1191
1180
  slate.Transforms.wrapNodes(editor, { type: "list", format, children: [] }, { at: convertedPath });
1192
1181
  };
1193
1182
  const handleTabOnList = (editor) => {
@@ -1199,8 +1188,7 @@ const handleTabOnList = (editor) => {
1199
1188
  }
1200
1189
  const [currentListItem, currentListItemPath] = currentListItemEntry;
1201
1190
  const [currentList] = slate.Editor.parent(editor, currentListItemPath);
1202
- if (currentListItem === currentList.children[0])
1203
- return;
1191
+ if (currentListItem === currentList.children[0]) return;
1204
1192
  const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);
1205
1193
  const previousNode = currentList.children[currentListItemIndex - 1];
1206
1194
  if (previousNode.type === "list") {
@@ -1336,13 +1324,13 @@ const quoteBlocks = {
1336
1324
  handleEnterKey(editor) {
1337
1325
  pressEnterTwiceToExit(editor);
1338
1326
  },
1339
- snippets: [">"],
1340
- dragHandleTopMargin: "6px"
1327
+ snippets: [">"]
1341
1328
  }
1342
1329
  };
1343
1330
  const ToolbarWrapper = styledComponents.styled(designSystem.Flex)`
1344
1331
  &[aria-disabled='true'] {
1345
1332
  cursor: not-allowed;
1333
+ background: ${({ theme }) => theme.colors.neutral150};
1346
1334
  }
1347
1335
  `;
1348
1336
  const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
@@ -1353,7 +1341,7 @@ const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
1353
1341
  const FlexButton = styledComponents.styled(designSystem.Flex)`
1354
1342
  // Inherit the not-allowed cursor from ToolbarWrapper when disabled
1355
1343
  &[aria-disabled] {
1356
- cursor: inherit;
1344
+ cursor: not-allowed;
1357
1345
  }
1358
1346
 
1359
1347
  &[aria-disabled='false'] {
@@ -1435,7 +1423,7 @@ const ToolbarButton = ({
1435
1423
  width: 7,
1436
1424
  height: 7,
1437
1425
  hasRadius: true,
1438
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { width: "1.2rem", height: "1.2rem", fill: disabled ? "neutral300" : enabledColor })
1426
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { fill: disabled ? "neutral300" : enabledColor })
1439
1427
  }
1440
1428
  )
1441
1429
  }
@@ -1567,8 +1555,7 @@ const isListNode = (node) => {
1567
1555
  const ListButton = ({ block, format }) => {
1568
1556
  const { editor, disabled, blocks } = useBlocksEditorContext("ListButton");
1569
1557
  const isListActive = () => {
1570
- if (!editor.selection)
1571
- return false;
1558
+ if (!editor.selection) return false;
1572
1559
  const currentListEntry = slate.Editor.above(editor, {
1573
1560
  match: (node) => !slate.Editor.isEditor(node) && node.type === "list",
1574
1561
  at: editor.selection.anchor
@@ -1580,6 +1567,26 @@ const ListButton = ({ block, format }) => {
1580
1567
  }
1581
1568
  return false;
1582
1569
  };
1570
+ const isListDisabled = () => {
1571
+ if (disabled) {
1572
+ return true;
1573
+ }
1574
+ if (!editor.selection) {
1575
+ return false;
1576
+ }
1577
+ const anchorNodeEntry = slate.Editor.above(editor, {
1578
+ at: editor.selection.anchor,
1579
+ match: (node) => !slate.Editor.isEditor(node) && node.type !== "text"
1580
+ });
1581
+ const focusNodeEntry = slate.Editor.above(editor, {
1582
+ at: editor.selection.focus,
1583
+ match: (node) => !slate.Editor.isEditor(node) && node.type !== "text"
1584
+ });
1585
+ if (!anchorNodeEntry || !focusNodeEntry) {
1586
+ return false;
1587
+ }
1588
+ return anchorNodeEntry[0] !== focusNodeEntry[0];
1589
+ };
1583
1590
  const toggleList = (format2) => {
1584
1591
  let currentListEntry;
1585
1592
  if (editor.selection) {
@@ -1613,7 +1620,7 @@ const ListButton = ({ block, format }) => {
1613
1620
  name: format,
1614
1621
  label: block.label,
1615
1622
  isActive: isListActive(),
1616
- disabled,
1623
+ disabled: isListDisabled(),
1617
1624
  handleClick: () => toggleList(format)
1618
1625
  }
1619
1626
  );
@@ -1622,8 +1629,7 @@ const LinkButton = ({ disabled }) => {
1622
1629
  const { editor } = useBlocksEditorContext("LinkButton");
1623
1630
  const isLinkActive = () => {
1624
1631
  const { selection } = editor;
1625
- if (!selection)
1626
- return false;
1632
+ if (!selection) return false;
1627
1633
  const [match] = Array.from(
1628
1634
  slate.Editor.nodes(editor, {
1629
1635
  at: slate.Editor.unhangRange(editor, selection),
@@ -1687,7 +1693,7 @@ const BlocksToolbar = () => {
1687
1693
  return false;
1688
1694
  };
1689
1695
  const isButtonDisabled = checkButtonDisabled();
1690
- return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, children: [
1696
+ return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, width: "100%", children: [
1691
1697
  /* @__PURE__ */ jsxRuntime.jsx(BlocksDropdown, {}),
1692
1698
  /* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
1693
1699
  /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.ToggleGroup, { type: "multiple", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, children: [
@@ -1757,33 +1763,36 @@ const DragItem = styledComponents.styled(designSystem.Flex)`
1757
1763
  }
1758
1764
  `;
1759
1765
  const DragIconButton = styledComponents.styled(designSystem.IconButton)`
1766
+ user-select: none;
1760
1767
  display: flex;
1761
1768
  align-items: center;
1762
1769
  justify-content: center;
1770
+ border: none;
1763
1771
  border-radius: ${({ theme }) => theme.borderRadius};
1764
- width: ${({ theme }) => theme.spaces[4]};
1765
- height: ${({ theme }) => theme.spaces[6]};
1772
+ padding-left: ${({ theme }) => theme.spaces[0]};
1773
+ padding-right: ${({ theme }) => theme.spaces[0]};
1774
+ padding-top: ${({ theme }) => theme.spaces[1]};
1775
+ padding-bottom: ${({ theme }) => theme.spaces[1]};
1766
1776
  visibility: hidden;
1767
1777
  cursor: grab;
1768
1778
  opacity: inherit;
1769
1779
  margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
1770
1780
 
1771
1781
  &:hover {
1772
- background: ${({ theme }) => theme.colors.neutral200};
1782
+ background: ${({ theme }) => theme.colors.neutral100};
1773
1783
  }
1774
1784
  &:active {
1775
1785
  cursor: grabbing;
1786
+ background: ${({ theme }) => theme.colors.neutral150};
1776
1787
  }
1777
1788
  &[aria-disabled='true'] {
1778
- cursor: not-allowed;
1779
- background: transparent;
1789
+ visibility: hidden;
1780
1790
  }
1781
1791
  svg {
1782
- height: auto;
1783
- width: ${({ theme }) => theme.spaces[3]};
1792
+ min-width: ${({ theme }) => theme.spaces[3]};
1784
1793
 
1785
1794
  path {
1786
- fill: ${({ theme }) => theme.colors.neutral700};
1795
+ fill: ${({ theme }) => theme.colors.neutral500};
1787
1796
  }
1788
1797
  }
1789
1798
  `;
@@ -1828,8 +1837,7 @@ const DragAndDropElement = ({
1828
1837
  displayedValue: children
1829
1838
  },
1830
1839
  onDropItem(currentIndex, newIndex) {
1831
- if (newIndex)
1832
- handleMoveBlock(newIndex, currentIndex);
1840
+ if (newIndex) handleMoveBlock(newIndex, currentIndex);
1833
1841
  }
1834
1842
  });
1835
1843
  const composedBoxRefs = designSystem.useComposedRefs(blockRef, dropRef);
@@ -1885,6 +1893,7 @@ const DragAndDropElement = ({
1885
1893
  DragIconButton,
1886
1894
  {
1887
1895
  tag: "div",
1896
+ contentEditable: false,
1888
1897
  role: "button",
1889
1898
  tabIndex: 0,
1890
1899
  withTooltip: false,
@@ -1897,7 +1906,7 @@ const DragAndDropElement = ({
1897
1906
  disabled,
1898
1907
  draggable: true,
1899
1908
  $dragHandleTopMargin: dragHandleTopMargin,
1900
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, { color: "neutral600" })
1909
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, { color: "primary500" })
1901
1910
  }
1902
1911
  ),
1903
1912
  children
@@ -1934,7 +1943,7 @@ const baseRenderLeaf = (props, modifiers2) => {
1934
1943
  }
1935
1944
  return currentChildren;
1936
1945
  }, props.children);
1937
- return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, children: wrappedChildren });
1946
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, className: props.leaf.className, children: wrappedChildren });
1938
1947
  };
1939
1948
  const baseRenderElement = ({
1940
1949
  props,
@@ -1972,8 +1981,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1972
1981
  [modifiers2]
1973
1982
  );
1974
1983
  const handleMoveBlocks = (editor2, event) => {
1975
- if (!editor2.selection)
1976
- return;
1984
+ if (!editor2.selection) return;
1977
1985
  const start = slate.Range.start(editor2.selection);
1978
1986
  const currentIndex = [start.path[0]];
1979
1987
  let newIndexPosition = 0;
@@ -2110,8 +2118,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
2110
2118
  }
2111
2119
  };
2112
2120
  const handleScrollSelectionIntoView = () => {
2113
- if (!editor.selection)
2114
- return;
2121
+ if (!editor.selection) return;
2115
2122
  const domRange = slateReact.ReactEditor.toDOMRange(editor, editor.selection);
2116
2123
  const domRect = domRange.getBoundingClientRect();
2117
2124
  const blocksInput = blocksRef.current;
@@ -2138,7 +2145,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
2138
2145
  background: "neutral0",
2139
2146
  color: "neutral800",
2140
2147
  lineHeight: 6,
2141
- paddingRight: 4,
2148
+ paddingRight: 7,
2142
2149
  paddingTop: 6,
2143
2150
  paddingBottom: 3,
2144
2151
  children: [
@@ -2149,6 +2156,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
2149
2156
  readOnly: disabled,
2150
2157
  placeholder,
2151
2158
  isExpandedMode,
2159
+ decorate: decorateCode,
2152
2160
  renderElement,
2153
2161
  renderLeaf,
2154
2162
  onKeyDown: handleKeyDown,
@@ -2221,7 +2229,7 @@ const EditorLayout$1 = ({
2221
2229
  /* @__PURE__ */ jsxRuntime.jsx(
2222
2230
  CollapseIconButton,
2223
2231
  {
2224
- "aria-label": formatMessage({
2232
+ label: formatMessage({
2225
2233
  id: index.getTranslation("components.Blocks.collapse"),
2226
2234
  defaultMessage: "Collapse"
2227
2235
  }),
@@ -2305,8 +2313,7 @@ const InlineCode = styledComponents.styled.code`
2305
2313
  `;
2306
2314
  const baseCheckIsActive = (editor, name2) => {
2307
2315
  const marks = slate.Editor.marks(editor);
2308
- if (!marks)
2309
- return false;
2316
+ if (!marks) return false;
2310
2317
  return Boolean(marks[name2]);
2311
2318
  };
2312
2319
  const baseHandleToggle = (editor, name2) => {
@@ -2472,6 +2479,7 @@ const ExpandIconButton = styledComponents.styled(designSystem.IconButton)`
2472
2479
  position: absolute;
2473
2480
  bottom: 1.2rem;
2474
2481
  right: 1.2rem;
2482
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2475
2483
  `;
2476
2484
  function useResetKey(value) {
2477
2485
  const slateUpdatesCount = React__namespace.useRef(0);
@@ -2560,7 +2568,7 @@ const BlocksEditor = React__namespace.forwardRef(
2560
2568
  !isExpandedMode && /* @__PURE__ */ jsxRuntime.jsx(
2561
2569
  ExpandIconButton,
2562
2570
  {
2563
- "aria-label": formatMessage({
2571
+ label: formatMessage({
2564
2572
  id: index.getTranslation("components.Blocks.expand"),
2565
2573
  defaultMessage: "Expand"
2566
2574
  }),
@@ -2603,147 +2611,485 @@ const BlocksInput = React__namespace.forwardRef(
2603
2611
  }
2604
2612
  );
2605
2613
  const MemoizedBlocksInput = React__namespace.memo(BlocksInput);
2606
- const createDefaultForm = (contentType, components = {}) => {
2607
- const traverseSchema = (attributes) => {
2608
- return Object.entries(attributes).reduce((acc, [key, attribute]) => {
2609
- if ("default" in attribute) {
2610
- acc[key] = attribute.default;
2611
- } else if (attribute.type === "component" && attribute.required) {
2612
- const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
2613
- if (attribute.repeatable) {
2614
- acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
2615
- } else {
2616
- acc[key] = defaultComponentForm;
2617
- }
2618
- } else if (attribute.type === "dynamiczone" && attribute.required) {
2619
- acc[key] = [];
2620
- }
2621
- return acc;
2622
- }, {});
2623
- };
2624
- return traverseSchema(contentType.attributes);
2625
- };
2626
2614
  const Initializer = ({ disabled, name: name2, onClick }) => {
2627
2615
  const { formatMessage } = reactIntl.useIntl();
2628
2616
  const field = strapiAdmin.useField(name2);
2629
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2630
- /* @__PURE__ */ jsxRuntime.jsx(
2631
- designSystem.Box,
2617
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
2618
+ designSystem.Box,
2619
+ {
2620
+ tag: "button",
2621
+ background: disabled ? "neutral150" : "neutral100",
2622
+ borderColor: field.error ? "danger600" : "neutral200",
2623
+ hasRadius: true,
2624
+ disabled,
2625
+ onClick,
2626
+ paddingTop: 9,
2627
+ paddingBottom: 9,
2628
+ type: "button",
2629
+ style: { cursor: disabled ? "not-allowed" : "pointer" },
2630
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2631
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
2632
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
2633
+ designSystem.Typography,
2634
+ {
2635
+ textColor: disabled ? "neutral600" : "primary600",
2636
+ variant: "pi",
2637
+ fontWeight: "bold",
2638
+ children: formatMessage({
2639
+ id: index.getTranslation("components.empty-repeatable"),
2640
+ defaultMessage: "No entry yet. Click to add one."
2641
+ })
2642
+ }
2643
+ ) })
2644
+ ] })
2645
+ }
2646
+ ) });
2647
+ };
2648
+ const AddComponentButton = ({
2649
+ hasError,
2650
+ isDisabled,
2651
+ isOpen,
2652
+ children,
2653
+ onClick
2654
+ }) => {
2655
+ return /* @__PURE__ */ jsxRuntime.jsx(
2656
+ StyledButton,
2657
+ {
2658
+ type: "button",
2659
+ onClick,
2660
+ disabled: isDisabled,
2661
+ background: "neutral0",
2662
+ style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2663
+ variant: "tertiary",
2664
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
2665
+ /* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2666
+ /* @__PURE__ */ jsxRuntime.jsx(
2667
+ designSystem.Typography,
2668
+ {
2669
+ variant: "pi",
2670
+ fontWeight: "bold",
2671
+ textColor: hasError && !isOpen ? "danger600" : "neutral600",
2672
+ children
2673
+ }
2674
+ )
2675
+ ] })
2676
+ }
2677
+ );
2678
+ };
2679
+ const StyledAddIcon = styledComponents.styled(Icons.PlusCircle)`
2680
+ height: ${({ theme }) => theme.spaces[6]};
2681
+ width: ${({ theme }) => theme.spaces[6]};
2682
+ transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
2683
+
2684
+ > circle {
2685
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
2686
+ }
2687
+ > path {
2688
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral500};
2689
+ }
2690
+ `;
2691
+ const StyledButton = styledComponents.styled(designSystem.Button)`
2692
+ padding-left: ${({ theme }) => theme.spaces[3]};
2693
+ border-radius: 26px;
2694
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2695
+ height: 5rem;
2696
+ `;
2697
+ const ComponentCategory = ({
2698
+ category,
2699
+ components = [],
2700
+ variant = "primary",
2701
+ onAddComponent
2702
+ }) => {
2703
+ const { formatMessage } = reactIntl.useIntl();
2704
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: category, children: [
2705
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
2706
+ /* @__PURE__ */ jsxRuntime.jsx(ResponsiveAccordionContent, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
2707
+ ComponentBox,
2632
2708
  {
2633
2709
  tag: "button",
2710
+ type: "button",
2634
2711
  background: "neutral100",
2635
- borderColor: field.error ? "danger600" : "neutral200",
2712
+ justifyContent: "center",
2713
+ onClick: onAddComponent(uid),
2636
2714
  hasRadius: true,
2637
- disabled,
2638
- onClick,
2639
- paddingTop: 9,
2640
- paddingBottom: 9,
2641
- type: "button",
2642
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2643
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(CircleIcon, {}) }),
2644
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
2645
- id: index.getTranslation("components.empty-repeatable"),
2646
- defaultMessage: "No entry yet. Click on the button below to add one."
2647
- }) }) })
2715
+ height: "8.4rem",
2716
+ shrink: 0,
2717
+ borderColor: "neutral200",
2718
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2719
+ /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
2720
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2648
2721
  ] })
2649
- }
2650
- ),
2651
- field.error && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", variant: "pi", children: field.error })
2722
+ },
2723
+ uid
2724
+ )) }) })
2652
2725
  ] });
2653
2726
  };
2654
- const CircleIcon = styledComponents.styled(Icons.PlusCircle)`
2655
- width: 2.4rem;
2656
- height: 2.4rem;
2657
- > circle {
2658
- fill: ${({ theme }) => theme.colors.primary200};
2727
+ const ResponsiveAccordionContent = styledComponents.styled(designSystem.Accordion.Content)`
2728
+ container-type: inline-size;
2729
+ `;
2730
+ const Grid = styledComponents.styled(designSystem.Box)`
2731
+ display: grid;
2732
+ grid-template-columns: repeat(auto-fill, 100%);
2733
+ grid-gap: ${({ theme }) => theme.spaces[1]};
2734
+
2735
+ @container (min-width: ${() => RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
2736
+ grid-template-columns: repeat(auto-fill, 14rem);
2659
2737
  }
2660
- > path {
2661
- fill: ${({ theme }) => theme.colors.primary600};
2738
+ `;
2739
+ const ComponentBox = styledComponents.styled(designSystem.Flex)`
2740
+ color: ${({ theme }) => theme.colors.neutral600};
2741
+ cursor: pointer;
2742
+
2743
+ @media (prefers-reduced-motion: no-preference) {
2744
+ transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2745
+ }
2746
+
2747
+ &:focus,
2748
+ &:hover {
2749
+ border: 1px solid ${({ theme }) => theme.colors.primary200};
2750
+ background: ${({ theme }) => theme.colors.primary100};
2751
+ color: ${({ theme }) => theme.colors.primary600};
2662
2752
  }
2663
2753
  `;
2664
- const NonRepeatableComponent = ({
2665
- attribute,
2666
- name: name2,
2667
- children,
2668
- layout
2754
+ const ComponentPicker = ({
2755
+ dynamicComponentsByCategory = {},
2756
+ isOpen,
2757
+ onClickAddComponent
2669
2758
  }) => {
2670
- const { value } = strapiAdmin.useField(name2);
2671
- const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
2672
- const isNested = level > 0;
2673
- return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
2759
+ const { formatMessage } = reactIntl.useIntl();
2760
+ const handleAddComponentToDz = (componentUid) => () => {
2761
+ onClickAddComponent(componentUid);
2762
+ };
2763
+ if (!isOpen) {
2764
+ return null;
2765
+ }
2766
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2674
2767
  designSystem.Box,
2675
2768
  {
2676
- background: "neutral100",
2677
- paddingLeft: 6,
2678
- paddingRight: 6,
2679
2769
  paddingTop: 6,
2680
2770
  paddingBottom: 6,
2681
- hasRadius: isNested,
2682
- borderColor: isNested ? "neutral200" : void 0,
2683
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
2684
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2685
- const completeFieldName = `${name2}.${field.name}`;
2686
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2687
- }) }, index2);
2688
- }) })
2689
- }
2690
- ) });
2691
- };
2692
- const RepeatableComponent = ({
2693
- attribute,
2694
- disabled,
2695
- name: name2,
2696
- mainField,
2697
- children,
2698
- layout
2699
- }) => {
2700
- const { toggleNotification } = strapiAdmin.useNotification();
2701
- const { formatMessage } = reactIntl.useIntl();
2702
- const { search: searchString } = reactRouterDom.useLocation();
2703
- const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
2704
- const { components } = index.useDoc();
2705
- const { value = [], error } = strapiAdmin.useField(name2);
2706
- const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
2707
- const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
2708
- const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
2709
- const { max = Infinity } = attribute;
2710
- const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
2711
- const [liveText, setLiveText] = React__namespace.useState("");
2712
- const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
2713
- if (search.has("field")) {
2714
- const fieldParam = search.get("field");
2715
- if (!fieldParam) {
2716
- return void 0;
2717
- }
2718
- const [, path] = fieldParam.split(`${name2}.`);
2719
- if (objects.getIn(value, path, void 0) !== void 0) {
2720
- const [subpath] = path.split(".");
2721
- return objects.getIn(value, subpath, void 0)?.__temp_key__;
2722
- }
2771
+ paddingLeft: 5,
2772
+ paddingRight: 5,
2773
+ background: "neutral0",
2774
+ shadow: "tableShadow",
2775
+ borderColor: "neutral150",
2776
+ hasRadius: true,
2777
+ children: [
2778
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
2779
+ id: index.getTranslation("components.DynamicZone.ComponentPicker-label"),
2780
+ defaultMessage: "Pick one component"
2781
+ }) }) }),
2782
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index2) => /* @__PURE__ */ jsxRuntime.jsx(
2783
+ ComponentCategory,
2784
+ {
2785
+ category,
2786
+ components,
2787
+ onAddComponent: handleAddComponentToDz,
2788
+ variant: index2 % 2 === 1 ? "primary" : "secondary"
2789
+ },
2790
+ category
2791
+ )) }) })
2792
+ ]
2723
2793
  }
2724
- return void 0;
2725
- }, [search, name2, value]);
2726
- const prevValue = usePrev.usePrev(value);
2794
+ );
2795
+ };
2796
+ const DynamicComponent = ({
2797
+ componentUid,
2798
+ disabled,
2799
+ index: index$1,
2800
+ name: name2,
2801
+ onRemoveComponentClick,
2802
+ onMoveComponent,
2803
+ onGrabItem,
2804
+ onDropItem,
2805
+ onCancel,
2806
+ dynamicComponentsByCategory = {},
2807
+ onAddComponent,
2808
+ children
2809
+ }) => {
2810
+ const { formatMessage } = reactIntl.useIntl();
2811
+ const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
2812
+ const {
2813
+ edit: { components }
2814
+ } = index.useDocLayout();
2815
+ const title = React__namespace.useMemo(() => {
2816
+ const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
2817
+ const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
2818
+ const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
2819
+ const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
2820
+ return mainValue;
2821
+ }, [componentUid, components, formValues, name2, index$1]);
2822
+ const { icon, displayName } = React__namespace.useMemo(() => {
2823
+ const [category] = componentUid.split(".");
2824
+ const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
2825
+ (component) => component.uid === componentUid
2826
+ ) ?? { icon: null, displayName: null };
2827
+ return { icon: icon2, displayName: displayName2 };
2828
+ }, [componentUid, dynamicComponentsByCategory]);
2829
+ const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
2830
+ type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
2831
+ index: index$1,
2832
+ item: {
2833
+ index: index$1,
2834
+ displayedValue: `${displayName} ${title}`,
2835
+ icon
2836
+ },
2837
+ onMoveItem: onMoveComponent,
2838
+ onDropItem,
2839
+ onGrabItem,
2840
+ onCancel
2841
+ });
2727
2842
  React__namespace.useEffect(() => {
2728
- if (prevValue && prevValue.length < value.length) {
2729
- setCollapseToOpen(value[value.length - 1].__temp_key__);
2730
- }
2731
- }, [value, prevValue]);
2843
+ dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
2844
+ }, [dragPreviewRef, index$1]);
2845
+ const accordionValue = React__namespace.useId();
2846
+ const { value = [], rawError } = strapiAdmin.useField(`${name2}.${index$1}`);
2847
+ const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
2732
2848
  React__namespace.useEffect(() => {
2733
- if (typeof componentTmpKeyWithFocussedField === "string") {
2734
- setCollapseToOpen(componentTmpKeyWithFocussedField);
2849
+ if (rawError && value) {
2850
+ setCollapseToOpen(accordionValue);
2735
2851
  }
2736
- }, [componentTmpKeyWithFocussedField]);
2737
- const toggleCollapses = () => {
2738
- setCollapseToOpen("");
2852
+ }, [rawError, value, accordionValue]);
2853
+ const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
2854
+ const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2855
+ /* @__PURE__ */ jsxRuntime.jsx(
2856
+ designSystem.IconButton,
2857
+ {
2858
+ variant: "ghost",
2859
+ label: formatMessage(
2860
+ {
2861
+ id: index.getTranslation("components.DynamicZone.delete-label"),
2862
+ defaultMessage: "Delete {name}"
2863
+ },
2864
+ { name: title }
2865
+ ),
2866
+ onClick: onRemoveComponentClick,
2867
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
2868
+ }
2869
+ ),
2870
+ /* @__PURE__ */ jsxRuntime.jsx(
2871
+ designSystem.IconButton,
2872
+ {
2873
+ variant: "ghost",
2874
+ onClick: (e) => e.stopPropagation(),
2875
+ "data-handler-id": handlerId,
2876
+ ref: dragRef,
2877
+ label: formatMessage({
2878
+ id: index.getTranslation("components.DragHandle-label"),
2879
+ defaultMessage: "Drag"
2880
+ }),
2881
+ onKeyDown: handleKeyDown,
2882
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
2883
+ }
2884
+ ),
2885
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
2886
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 0, paddingRight: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
2887
+ designSystem.IconButton,
2888
+ {
2889
+ variant: "ghost",
2890
+ label: formatMessage({
2891
+ id: index.getTranslation("components.DynamicZone.more-actions"),
2892
+ defaultMessage: "More actions"
2893
+ }),
2894
+ tag: "span",
2895
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false })
2896
+ }
2897
+ ) }),
2898
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
2899
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
2900
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
2901
+ id: index.getTranslation("components.DynamicZone.add-item-above"),
2902
+ defaultMessage: "Add component above"
2903
+ }) }),
2904
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2905
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
2906
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
2907
+ ] }, category)) })
2908
+ ] }),
2909
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
2910
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
2911
+ id: index.getTranslation("components.DynamicZone.add-item-below"),
2912
+ defaultMessage: "Add component below"
2913
+ }) }),
2914
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2915
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
2916
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
2917
+ ] }, category)) })
2918
+ ] })
2919
+ ] })
2920
+ ] })
2921
+ ] });
2922
+ const accordionTitle = title ? `${displayName} ${title}` : displayName;
2923
+ return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
2924
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
2925
+ /* @__PURE__ */ jsxRuntime.jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview$1, {}) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: accordionValue, children: [
2926
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
2927
+ /* @__PURE__ */ jsxRuntime.jsx(
2928
+ designSystem.Accordion.Trigger,
2929
+ {
2930
+ icon: icon && ComponentIcon.COMPONENT_ICONS[icon] ? ComponentIcon.COMPONENT_ICONS[icon] : ComponentIcon.COMPONENT_ICONS.dashboard,
2931
+ children: accordionTitle
2932
+ }
2933
+ ),
2934
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
2935
+ ] }),
2936
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsxRuntime.jsx(
2937
+ designSystem.Grid.Item,
2938
+ {
2939
+ col: 12,
2940
+ s: 12,
2941
+ xs: 12,
2942
+ direction: "column",
2943
+ alignItems: "stretch",
2944
+ children: /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
2945
+ const fieldName = `${name2}.${index$1}.${field.name}`;
2946
+ const fieldWithTranslatedLabel = {
2947
+ ...field,
2948
+ label: formatMessage({
2949
+ id: `content-manager.components.${componentUid}.${field.name}`,
2950
+ defaultMessage: field.label
2951
+ })
2952
+ };
2953
+ return /* @__PURE__ */ jsxRuntime.jsx(
2954
+ ResponsiveGridItem,
2955
+ {
2956
+ col: size,
2957
+ s: 12,
2958
+ xs: 12,
2959
+ direction: "column",
2960
+ alignItems: "stretch",
2961
+ children: children ? children({ ...fieldWithTranslatedLabel, name: fieldName }) : /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
2962
+ },
2963
+ fieldName
2964
+ );
2965
+ }) })
2966
+ },
2967
+ rowInd
2968
+ )) }) }) }) })
2969
+ ] }) }) })
2970
+ ] });
2971
+ };
2972
+ const StyledBox = styledComponents.styled(designSystem.Box)`
2973
+ > div:first-child {
2974
+ box-shadow: ${({ theme }) => theme.shadows.tableShadow};
2975
+ }
2976
+ `;
2977
+ const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
2978
+ border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
2979
+ `;
2980
+ const Rectangle = styledComponents.styled(designSystem.Box)`
2981
+ width: ${({ theme }) => theme.spaces[2]};
2982
+ height: ${({ theme }) => theme.spaces[4]};
2983
+ `;
2984
+ const Preview$1 = styledComponents.styled.span`
2985
+ display: block;
2986
+ background-color: ${({ theme }) => theme.colors.primary100};
2987
+ outline: 1px dashed ${({ theme }) => theme.colors.primary500};
2988
+ outline-offset: -1px;
2989
+ padding: ${({ theme }) => theme.spaces[6]};
2990
+ `;
2991
+ const ComponentContainer = styledComponents.styled(designSystem.Box)`
2992
+ list-style: none;
2993
+ padding: 0;
2994
+ margin: 0;
2995
+ `;
2996
+ const DynamicZoneLabel = ({
2997
+ hint,
2998
+ label,
2999
+ labelAction,
3000
+ name: name2,
3001
+ numberOfComponents = 0,
3002
+ required
3003
+ }) => {
3004
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
3005
+ designSystem.Box,
3006
+ {
3007
+ paddingTop: 3,
3008
+ paddingBottom: 3,
3009
+ paddingRight: 4,
3010
+ paddingLeft: 4,
3011
+ borderRadius: "26px",
3012
+ background: "neutral0",
3013
+ shadow: "filterShadow",
3014
+ color: "neutral500",
3015
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
3016
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
3017
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
3018
+ label || name2,
3019
+ " "
3020
+ ] }),
3021
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
3022
+ "(",
3023
+ numberOfComponents,
3024
+ ")"
3025
+ ] }),
3026
+ required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
3027
+ labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
3028
+ ] }),
3029
+ hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
3030
+ ] })
3031
+ }
3032
+ ) });
3033
+ };
3034
+ const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
3035
+ "DynamicZone",
3036
+ {
3037
+ isInDynamicZone: false
3038
+ }
3039
+ );
3040
+ const DynamicZone = ({
3041
+ attribute,
3042
+ disabled: disabledProp,
3043
+ hint,
3044
+ label,
3045
+ labelAction,
3046
+ name: name2,
3047
+ required = false,
3048
+ children
3049
+ }) => {
3050
+ const { max = Infinity, min = -Infinity } = attribute ?? {};
3051
+ const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
3052
+ const [liveText, setLiveText] = React__namespace.useState("");
3053
+ const { components, isLoading } = index.useDoc();
3054
+ const disabled = disabledProp || isLoading;
3055
+ const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
3056
+ "DynamicZone",
3057
+ ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
3058
+ addFieldRow: addFieldRow2,
3059
+ removeFieldRow: removeFieldRow2,
3060
+ moveFieldRow: moveFieldRow2
3061
+ })
3062
+ );
3063
+ const { value = [], error } = strapiAdmin.useField(name2);
3064
+ const dynamicComponentsByCategory = React__namespace.useMemo(() => {
3065
+ return attribute.components.reduce((acc, componentUid) => {
3066
+ const { category, info } = components[componentUid] ?? { info: {} };
3067
+ const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
3068
+ if (!acc[category]) {
3069
+ acc[category] = [];
3070
+ }
3071
+ acc[category] = [...acc[category], component];
3072
+ return acc;
3073
+ }, {});
3074
+ }, [attribute.components, components]);
3075
+ const { formatMessage } = reactIntl.useIntl();
3076
+ const { toggleNotification } = strapiAdmin.useNotification();
3077
+ const dynamicDisplayedComponentsLength = value.length;
3078
+ const handleAddComponent = (uid, position) => {
3079
+ setAddComponentIsOpen(false);
3080
+ const schema = components[uid];
3081
+ const form = index.createDefaultForm(schema, components);
3082
+ const transformations = pipe__default.default(index.transformDocument(schema, components), (data2) => ({
3083
+ ...data2,
3084
+ __component: uid
3085
+ }));
3086
+ const data = transformations(form);
3087
+ addFieldRow(name2, data, position);
2739
3088
  };
2740
- const handleClick = () => {
2741
- if (value.length < max) {
2742
- const schema = components[attribute.component];
2743
- const form = createDefaultForm(schema, components);
2744
- const data = transformDocument(schema, components)(form);
2745
- addFieldRow(name2, data);
2746
- } else if (value.length >= max) {
3089
+ const handleClickOpenPicker = () => {
3090
+ if (dynamicDisplayedComponentsLength < max) {
3091
+ setAddComponentIsOpen((prev) => !prev);
3092
+ } else {
2747
3093
  toggleNotification({
2748
3094
  type: "info",
2749
3095
  message: formatMessage({
@@ -2752,7 +3098,7 @@ const RepeatableComponent = ({
2752
3098
  });
2753
3099
  }
2754
3100
  };
2755
- const handleMoveComponentField = (newIndex, currentIndex) => {
3101
+ const handleMoveComponent = (newIndex, currentIndex) => {
2756
3102
  setLiveText(
2757
3103
  formatMessage(
2758
3104
  {
@@ -2767,9 +3113,6 @@ const RepeatableComponent = ({
2767
3113
  );
2768
3114
  moveFieldRow(name2, currentIndex, newIndex);
2769
3115
  };
2770
- const handleValueChange = (key) => {
2771
- setCollapseToOpen(key);
2772
- };
2773
3116
  const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
2774
3117
  const handleCancel = (index$1) => {
2775
3118
  setLiveText(
@@ -2779,452 +3122,142 @@ const RepeatableComponent = ({
2779
3122
  defaultMessage: "{item}, dropped. Re-order cancelled."
2780
3123
  },
2781
3124
  {
2782
- item: `${name2}.${index$1}`
2783
- }
2784
- )
2785
- );
2786
- };
2787
- const handleGrabItem = (index$1) => {
2788
- setLiveText(
2789
- formatMessage(
2790
- {
2791
- id: index.getTranslation("dnd.grab-item"),
2792
- defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
2793
- },
2794
- {
2795
- item: `${name2}.${index$1}`,
2796
- position: getItemPos(index$1)
2797
- }
2798
- )
2799
- );
2800
- };
2801
- const handleDropItem = (index$1) => {
2802
- setLiveText(
2803
- formatMessage(
2804
- {
2805
- id: index.getTranslation("dnd.drop-item"),
2806
- defaultMessage: `{item}, dropped. Final position in list: {position}.`
2807
- },
2808
- {
2809
- item: `${name2}.${index$1}`,
2810
- position: getItemPos(index$1)
2811
- }
2812
- )
2813
- );
2814
- };
2815
- const ariaDescriptionId = React__namespace.useId();
2816
- const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
2817
- if (value.length === 0) {
2818
- return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
2819
- }
2820
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
2821
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
2822
- id: index.getTranslation("dnd.instructions"),
2823
- defaultMessage: `Press spacebar to grab and re-order`
2824
- }) }),
2825
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
2826
- /* @__PURE__ */ jsxRuntime.jsxs(
2827
- AccordionRoot,
2828
- {
2829
- $error: error,
2830
- value: collapseToOpen,
2831
- onValueChange: handleValueChange,
2832
- "aria-describedby": ariaDescriptionId,
2833
- children: [
2834
- value.map(({ __temp_key__: key, id }, index2) => {
2835
- const nameWithIndex = `${name2}.${index2}`;
2836
- return /* @__PURE__ */ jsxRuntime.jsx(
2837
- Relations.ComponentProvider,
2838
- {
2839
- id,
2840
- uid: attribute.component,
2841
- level: level + 1,
2842
- type: "repeatable",
2843
- children: /* @__PURE__ */ jsxRuntime.jsx(
2844
- Component,
2845
- {
2846
- disabled,
2847
- name: nameWithIndex,
2848
- attribute,
2849
- index: index2,
2850
- mainField,
2851
- onMoveItem: handleMoveComponentField,
2852
- onDeleteComponent: () => {
2853
- removeFieldRow(name2, index2);
2854
- toggleCollapses();
2855
- },
2856
- toggleCollapses,
2857
- onCancel: handleCancel,
2858
- onDropItem: handleDropItem,
2859
- onGrabItem: handleGrabItem,
2860
- __temp_key__: key,
2861
- children: layout.map((row, index22) => {
2862
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2863
- const completeFieldName = `${nameWithIndex}.${field.name}`;
2864
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2865
- }) }, index22);
2866
- })
2867
- }
2868
- )
2869
- },
2870
- key
2871
- );
2872
- }),
2873
- /* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
2874
- id: index.getTranslation("containers.EditView.add.new-entry"),
2875
- defaultMessage: "Add an entry"
2876
- }) })
2877
- ]
2878
- }
2879
- )
2880
- ] });
2881
- };
2882
- const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
2883
- border: 1px solid
2884
- ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
2885
- `;
2886
- const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
2887
- width: 100%;
2888
- display: flex;
2889
- justify-content: center;
2890
- border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2891
- padding-inline: ${(props) => props.theme.spaces[6]};
2892
- padding-block: ${(props) => props.theme.spaces[3]};
2893
-
2894
- &:not([disabled]) {
2895
- cursor: pointer;
2896
-
2897
- &:hover {
2898
- background-color: ${(props) => props.theme.colors.primary100};
2899
- }
2900
- }
2901
-
2902
- span {
2903
- font-weight: 600;
2904
- font-size: 1.4rem;
2905
- line-height: 2.4rem;
2906
- }
2907
-
2908
- @media (prefers-reduced-motion: no-preference) {
2909
- transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2910
- }
2911
- `;
2912
- const Component = ({
2913
- disabled,
2914
- index: index$1,
2915
- name: name2,
2916
- mainField = {
2917
- name: "id",
2918
- type: "integer"
2919
- },
2920
- children,
2921
- onDeleteComponent,
2922
- toggleCollapses,
2923
- __temp_key__,
2924
- ...dragProps
2925
- }) => {
2926
- const { formatMessage } = reactIntl.useIntl();
2927
- const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
2928
- return objects.getIn(state.values, [...name2.split("."), mainField.name]);
2929
- });
2930
- const accordionRef = React__namespace.useRef(null);
2931
- const componentKey = name2.split(".").slice(0, -1).join(".");
2932
- const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
2933
- type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
2934
- index: index$1,
2935
- item: {
2936
- index: index$1,
2937
- displayedValue: displayValue
2938
- },
2939
- onStart() {
2940
- toggleCollapses();
2941
- },
2942
- ...dragProps
2943
- });
2944
- React__namespace.useEffect(() => {
2945
- dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
2946
- }, [dragPreviewRef, index$1]);
2947
- const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
2948
- const composedBoxRefs = designSystem.useComposedRefs(
2949
- boxRef,
2950
- dropRef
2951
- );
2952
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview$1, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
2953
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
2954
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: displayValue }),
2955
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Actions, { children: [
2956
- /* @__PURE__ */ jsxRuntime.jsx(
2957
- designSystem.IconButton,
2958
- {
2959
- borderWidth: 0,
2960
- onClick: onDeleteComponent,
2961
- label: formatMessage({
2962
- id: index.getTranslation("containers.Edit.delete"),
2963
- defaultMessage: "Delete"
2964
- }),
2965
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
2966
- }
2967
- ),
2968
- /* @__PURE__ */ jsxRuntime.jsx(
2969
- designSystem.IconButton,
2970
- {
2971
- ref: composedAccordionRefs,
2972
- borderWidth: 0,
2973
- onClick: (e) => e.stopPropagation(),
2974
- "data-handler-id": handlerId,
2975
- label: formatMessage({
2976
- id: index.getTranslation("components.DragHandle-label"),
2977
- defaultMessage: "Drag"
2978
- }),
2979
- onKeyDown: handleKeyDown,
2980
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
2981
- }
2982
- )
2983
- ] })
2984
- ] }),
2985
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
2986
- designSystem.Flex,
2987
- {
2988
- direction: "column",
2989
- alignItems: "stretch",
2990
- background: "neutral100",
2991
- padding: 6,
2992
- gap: 6,
2993
- children
2994
- }
2995
- ) })
2996
- ] }) });
2997
- };
2998
- const Preview$1 = () => {
2999
- return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
3000
- };
3001
- const StyledSpan = styledComponents.styled(designSystem.Box)`
3002
- display: block;
3003
- outline: 1px dashed ${({ theme }) => theme.colors.primary500};
3004
- outline-offset: -1px;
3005
- `;
3006
- const ComponentInput = ({
3007
- label,
3008
- required,
3009
- name: name2,
3010
- attribute,
3011
- disabled,
3012
- labelAction,
3013
- ...props
3014
- }) => {
3015
- const { formatMessage } = reactIntl.useIntl();
3016
- const field = strapiAdmin.useField(name2);
3017
- const showResetComponent = !attribute.repeatable && field.value && !disabled;
3018
- const { components } = index.useDoc();
3019
- const handleInitialisationClick = () => {
3020
- const schema = components[attribute.component];
3021
- const form = createDefaultForm(schema, components);
3022
- const data = transformDocument(schema, components)(form);
3023
- field.onChange(name2, data);
3125
+ item: `${name2}.${index$1}`
3126
+ }
3127
+ )
3128
+ );
3024
3129
  };
3025
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
3026
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
3027
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
3028
- label,
3029
- attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3030
- " (",
3031
- Array.isArray(field.value) ? field.value.length : 0,
3032
- ")"
3033
- ] })
3034
- ] }),
3035
- showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
3036
- designSystem.IconButton,
3130
+ const handleGrabItem = (index$1) => {
3131
+ setLiveText(
3132
+ formatMessage(
3037
3133
  {
3038
- label: formatMessage({
3039
- id: index.getTranslation("components.reset-entry"),
3040
- defaultMessage: "Reset Entry"
3041
- }),
3042
- borderWidth: 0,
3043
- onClick: () => {
3044
- field.onChange(name2, null);
3045
- },
3046
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
3134
+ id: index.getTranslation("dnd.grab-item"),
3135
+ defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
3136
+ },
3137
+ {
3138
+ item: `${name2}.${index$1}`,
3139
+ position: getItemPos(index$1)
3047
3140
  }
3048
3141
  )
3049
- ] }),
3050
- !attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
3051
- !attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
3052
- attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
3053
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
3054
- ] });
3055
- };
3056
- const MemoizedComponentInput = React__namespace.memo(ComponentInput);
3057
- const AddComponentButton = ({
3058
- hasError,
3059
- isDisabled,
3060
- isOpen,
3061
- children,
3062
- onClick
3063
- }) => {
3064
- return /* @__PURE__ */ jsxRuntime.jsx(
3065
- StyledButton,
3066
- {
3067
- type: "button",
3068
- onClick,
3069
- disabled: isDisabled,
3070
- background: "neutral0",
3071
- paddingTop: 3,
3072
- paddingBottom: 3,
3073
- paddingLeft: 4,
3074
- paddingRight: 4,
3075
- style: { cursor: isDisabled ? "not-allowed" : "pointer" },
3076
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
3077
- /* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
3078
- /* @__PURE__ */ jsxRuntime.jsx(
3079
- AddComponentTitle,
3080
- {
3081
- variant: "pi",
3082
- fontWeight: "bold",
3083
- textColor: hasError && !isOpen ? "danger600" : "neutral500",
3084
- children
3085
- }
3086
- )
3087
- ] })
3088
- }
3089
- );
3090
- };
3091
- const StyledAddIcon = styledComponents.styled(Icons.PlusCircle)`
3092
- height: ${({ theme }) => theme.spaces[6]};
3093
- width: ${({ theme }) => theme.spaces[6]};
3094
- transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
3095
-
3096
- > circle {
3097
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
3098
- }
3099
- > path {
3100
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
3101
- }
3102
- `;
3103
- const AddComponentTitle = styledComponents.styled(designSystem.Typography)``;
3104
- const StyledButton = styledComponents.styled(designSystem.BaseButton)`
3105
- border-radius: 26px;
3106
- border-color: ${({ theme }) => theme.colors.neutral150};
3107
- box-shadow: ${({ theme }) => theme.shadows.filterShadow};
3108
-
3109
- &:hover {
3110
- ${AddComponentTitle} {
3111
- color: ${({ theme }) => theme.colors.primary600};
3112
- }
3113
-
3114
- ${StyledAddIcon} {
3115
- > circle {
3116
- fill: ${({ theme }) => theme.colors.primary600};
3117
- }
3118
- > path {
3119
- fill: ${({ theme }) => theme.colors.neutral100};
3120
- }
3142
+ );
3143
+ };
3144
+ const handleDropItem = (index$1) => {
3145
+ setLiveText(
3146
+ formatMessage(
3147
+ {
3148
+ id: index.getTranslation("dnd.drop-item"),
3149
+ defaultMessage: `{item}, dropped. Final position in list: {position}.`
3150
+ },
3151
+ {
3152
+ item: `${name2}.${index$1}`,
3153
+ position: getItemPos(index$1)
3154
+ }
3155
+ )
3156
+ );
3157
+ };
3158
+ const handleRemoveComponent = (name22, currentIndex) => () => {
3159
+ removeFieldRow(name22, currentIndex);
3160
+ };
3161
+ const hasError = error !== void 0;
3162
+ const renderButtonLabel = () => {
3163
+ if (addComponentIsOpen) {
3164
+ return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
3121
3165
  }
3122
- }
3123
- &:active {
3124
- ${AddComponentTitle} {
3125
- color: ${({ theme }) => theme.colors.primary600};
3166
+ if (hasError && dynamicDisplayedComponentsLength > max) {
3167
+ return formatMessage(
3168
+ {
3169
+ id: index.getTranslation(`components.DynamicZone.extra-components`),
3170
+ defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
3171
+ },
3172
+ {
3173
+ number: dynamicDisplayedComponentsLength - max
3174
+ }
3175
+ );
3126
3176
  }
3127
- ${StyledAddIcon} {
3128
- > circle {
3129
- fill: ${({ theme }) => theme.colors.primary600};
3130
- }
3131
- > path {
3132
- fill: ${({ theme }) => theme.colors.neutral100};
3133
- }
3177
+ if (hasError && dynamicDisplayedComponentsLength < min) {
3178
+ return formatMessage(
3179
+ {
3180
+ id: index.getTranslation(`components.DynamicZone.missing-components`),
3181
+ defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
3182
+ },
3183
+ { number: min - dynamicDisplayedComponentsLength }
3184
+ );
3134
3185
  }
3135
- }
3136
- `;
3137
- const ComponentCategory = ({
3138
- category,
3139
- components = [],
3140
- variant = "primary",
3141
- onAddComponent
3142
- }) => {
3143
- const { formatMessage } = reactIntl.useIntl();
3144
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: category, children: [
3145
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
3146
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
3147
- ComponentBox,
3186
+ return formatMessage(
3148
3187
  {
3149
- tag: "button",
3150
- type: "button",
3151
- background: "neutral100",
3152
- justifyContent: "center",
3153
- onClick: onAddComponent(uid),
3154
- hasRadius: true,
3155
- height: "8.4rem",
3156
- shrink: 0,
3157
- borderColor: "neutral200",
3158
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
3159
- /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
3160
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
3161
- ] })
3188
+ id: index.getTranslation("components.DynamicZone.add-component"),
3189
+ defaultMessage: "Add a component to {componentName}"
3162
3190
  },
3163
- uid
3164
- )) }) })
3165
- ] });
3166
- };
3167
- const Grid = styledComponents.styled(designSystem.Box)`
3168
- display: grid;
3169
- grid-template-columns: repeat(auto-fit, 14rem);
3170
- grid-gap: ${({ theme }) => theme.spaces[1]};
3171
- `;
3172
- const ComponentBox = styledComponents.styled(designSystem.Flex)`
3173
- color: ${({ theme }) => theme.colors.neutral600};
3174
- cursor: pointer;
3175
-
3176
- @media (prefers-reduced-motion: no-preference) {
3177
- transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
3178
- }
3179
-
3180
- &:focus,
3181
- &:hover {
3182
- border: 1px solid ${({ theme }) => theme.colors.primary200};
3183
- background: ${({ theme }) => theme.colors.primary100};
3184
- color: ${({ theme }) => theme.colors.primary600};
3185
- }
3186
- `;
3187
- const ComponentPicker = ({
3188
- dynamicComponentsByCategory = {},
3189
- isOpen,
3190
- onClickAddComponent
3191
- }) => {
3192
- const { formatMessage } = reactIntl.useIntl();
3193
- const handleAddComponentToDz = (componentUid) => () => {
3194
- onClickAddComponent(componentUid);
3191
+ { componentName: label || name2 }
3192
+ );
3195
3193
  };
3196
- if (!isOpen) {
3197
- return null;
3198
- }
3199
- return /* @__PURE__ */ jsxRuntime.jsxs(
3200
- designSystem.Box,
3201
- {
3202
- paddingTop: 6,
3203
- paddingBottom: 6,
3204
- paddingLeft: 5,
3205
- paddingRight: 5,
3206
- background: "neutral0",
3207
- shadow: "tableShadow",
3208
- borderColor: "neutral150",
3209
- hasRadius: true,
3210
- children: [
3211
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
3212
- id: index.getTranslation("components.DynamicZone.ComponentPicker-label"),
3213
- defaultMessage: "Pick one component"
3214
- }) }) }),
3215
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index2) => /* @__PURE__ */ jsxRuntime.jsx(
3216
- ComponentCategory,
3217
- {
3218
- category,
3219
- components,
3220
- onAddComponent: handleAddComponentToDz,
3221
- variant: index2 % 2 === 1 ? "primary" : "secondary"
3222
- },
3223
- category
3224
- )) }) })
3225
- ]
3226
- }
3227
- );
3194
+ const level = Relations.useComponent("DynamicZone", (state) => state.level);
3195
+ const ariaDescriptionId = React__namespace.useId();
3196
+ return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3197
+ dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
3198
+ /* @__PURE__ */ jsxRuntime.jsx(
3199
+ DynamicZoneLabel,
3200
+ {
3201
+ hint,
3202
+ label,
3203
+ labelAction,
3204
+ name: name2,
3205
+ numberOfComponents: dynamicDisplayedComponentsLength,
3206
+ required
3207
+ }
3208
+ ),
3209
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
3210
+ id: index.getTranslation("dnd.instructions"),
3211
+ defaultMessage: `Press spacebar to grab and re-order`
3212
+ }) }),
3213
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
3214
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
3215
+ Relations.ComponentProvider,
3216
+ {
3217
+ level: level + 1,
3218
+ uid: field.__component,
3219
+ id: field.id,
3220
+ type: "dynamiczone",
3221
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3222
+ DynamicComponent,
3223
+ {
3224
+ disabled,
3225
+ name: name2,
3226
+ index: index2,
3227
+ componentUid: field.__component,
3228
+ onMoveComponent: handleMoveComponent,
3229
+ onRemoveComponentClick: handleRemoveComponent(name2, index2),
3230
+ onCancel: handleCancel,
3231
+ onDropItem: handleDropItem,
3232
+ onGrabItem: handleGrabItem,
3233
+ onAddComponent: handleAddComponent,
3234
+ dynamicComponentsByCategory,
3235
+ children
3236
+ }
3237
+ )
3238
+ },
3239
+ field.__temp_key__
3240
+ )) })
3241
+ ] }),
3242
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
3243
+ AddComponentButton,
3244
+ {
3245
+ hasError,
3246
+ isDisabled: disabled,
3247
+ isOpen: addComponentIsOpen,
3248
+ onClick: handleClickOpenPicker,
3249
+ children: renderButtonLabel()
3250
+ }
3251
+ ) }),
3252
+ /* @__PURE__ */ jsxRuntime.jsx(
3253
+ ComponentPicker,
3254
+ {
3255
+ dynamicComponentsByCategory,
3256
+ isOpen: addComponentIsOpen,
3257
+ onClickAddComponent: handleAddComponent
3258
+ }
3259
+ )
3260
+ ] }) });
3228
3261
  };
3229
3262
  const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
3230
3263
  const { formatMessage } = reactIntl.useIntl();
@@ -3247,18 +3280,6 @@ const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
3247
3280
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
3248
3281
  ] });
3249
3282
  };
3250
- function useDebounce(value, delay) {
3251
- const [debouncedValue, setDebouncedValue] = React.useState(value);
3252
- React.useEffect(() => {
3253
- const handler = setTimeout(() => {
3254
- setDebouncedValue(value);
3255
- }, delay);
3256
- return () => {
3257
- clearTimeout(handler);
3258
- };
3259
- }, [value, delay]);
3260
- return debouncedValue;
3261
- }
3262
3283
  const uidApi = index.contentManagerApi.injectEndpoints({
3263
3284
  endpoints: (builder) => ({
3264
3285
  getDefaultUID: builder.query({
@@ -3293,7 +3314,10 @@ const uidApi = index.contentManagerApi.injectEndpoints({
3293
3314
  config: {
3294
3315
  params
3295
3316
  }
3296
- })
3317
+ }),
3318
+ providesTags: (_res, _error, params) => [
3319
+ { type: "UidAvailability", id: params.contentTypeUID }
3320
+ ]
3297
3321
  })
3298
3322
  })
3299
3323
  });
@@ -3305,8 +3329,10 @@ const UIDInput = React__namespace.forwardRef(
3305
3329
  const allFormValues = strapiAdmin.useForm("InputUID", (form) => form.values);
3306
3330
  const [availability, setAvailability] = React__namespace.useState();
3307
3331
  const [showRegenerate, setShowRegenerate] = React__namespace.useState(false);
3332
+ const isCloning = reactRouterDom.useMatch(index.CLONE_PATH) !== null;
3308
3333
  const field = strapiAdmin.useField(name2);
3309
- const debouncedValue = useDebounce(field.value, 300);
3334
+ const debouncedValue = usePrev.useDebounce(field.value, 300);
3335
+ const hasChanged = debouncedValue !== field.initialValue;
3310
3336
  const { toggleNotification } = strapiAdmin.useNotification();
3311
3337
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
3312
3338
  const { formatMessage } = reactIntl.useIntl();
@@ -3382,8 +3408,9 @@ const UIDInput = React__namespace.forwardRef(
3382
3408
  params
3383
3409
  },
3384
3410
  {
3411
+ // Don't check availability if the value is empty or wasn't changed
3385
3412
  skip: !Boolean(
3386
- debouncedValue !== field.initialValue && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3413
+ (hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3387
3414
  )
3388
3415
  }
3389
3416
  );
@@ -3412,6 +3439,7 @@ const UIDInput = React__namespace.forwardRef(
3412
3439
  const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
3413
3440
  const fieldRef = strapiAdmin.useFocusInputField(name2);
3414
3441
  const composedRefs = designSystem.useComposedRefs(ref, fieldRef);
3442
+ const shouldShowAvailability = (hasChanged || isCloning) && debouncedValue != null && availability && !showRegenerate;
3415
3443
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { hint, name: name2, error: field.error, required, children: [
3416
3444
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
3417
3445
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3420,7 +3448,7 @@ const UIDInput = React__namespace.forwardRef(
3420
3448
  ref: composedRefs,
3421
3449
  disabled: props.disabled,
3422
3450
  endAction: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { position: "relative", gap: 1, children: [
3423
- availability && !showRegenerate && /* @__PURE__ */ jsxRuntime.jsxs(
3451
+ shouldShowAvailability && /* @__PURE__ */ jsxRuntime.jsxs(
3424
3452
  TextValidation,
3425
3453
  {
3426
3454
  alignItems: "center",
@@ -3709,8 +3737,7 @@ const Wrapper = styledComponents.styled.div`
3709
3737
  `;
3710
3738
  var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/;
3711
3739
  function newlineAndIndentContinueMarkdownList(cm) {
3712
- if (cm.getOption("disableInput"))
3713
- return CodeMirror__default.default.Pass;
3740
+ if (cm.getOption("disableInput")) return CodeMirror__default.default.Pass;
3714
3741
  var ranges = cm.listSelections(), replacements = [];
3715
3742
  for (var i = 0; i < ranges.length; i++) {
3716
3743
  var pos = ranges[i].head;
@@ -3744,8 +3771,7 @@ function newlineAndIndentContinueMarkdownList(cm) {
3744
3771
  var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
3745
3772
  var bullet = numbered ? parseInt(match[3], 10) + 1 + match[4] : match[2].replace("x", " ");
3746
3773
  replacements[i] = "\n" + indent + bullet + after;
3747
- if (numbered)
3748
- incrementRemainingMarkdownListNumbers(cm, pos);
3774
+ if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
3749
3775
  }
3750
3776
  }
3751
3777
  cm.replaceSelections(replacements);
@@ -3763,10 +3789,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3763
3789
  var newNumber = parseInt(startItem[3], 10) + lookAhead - skipCount;
3764
3790
  var nextNumber = parseInt(nextItem[3], 10), itemNumber = nextNumber;
3765
3791
  if (startIndent === nextIndent && !isNaN(nextNumber)) {
3766
- if (newNumber === nextNumber)
3767
- itemNumber = nextNumber + 1;
3768
- if (newNumber > nextNumber)
3769
- itemNumber = newNumber + 1;
3792
+ if (newNumber === nextNumber) itemNumber = nextNumber + 1;
3793
+ if (newNumber > nextNumber) itemNumber = newNumber + 1;
3770
3794
  cm.replaceRange(
3771
3795
  nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
3772
3796
  {
@@ -3779,10 +3803,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3779
3803
  }
3780
3804
  );
3781
3805
  } else {
3782
- if (startIndent.length > nextIndent.length)
3783
- return;
3784
- if (startIndent.length < nextIndent.length && lookAhead === 1)
3785
- return;
3806
+ if (startIndent.length > nextIndent.length) return;
3807
+ if (startIndent.length < nextIndent.length && lookAhead === 1) return;
3786
3808
  skipCount += 1;
3787
3809
  }
3788
3810
  }
@@ -4254,7 +4276,7 @@ const EditorLayout = ({
4254
4276
  justifyContent: "flex-end",
4255
4277
  shrink: 0,
4256
4278
  width: "100%",
4257
- children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton$1, { onClick: onCollapse, children: [
4279
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton$1, { onClick: onCollapse, variant: "tertiary", size: "M", children: [
4258
4280
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
4259
4281
  id: "components.Wysiwyg.collapse",
4260
4282
  defaultMessage: "Collapse"
@@ -4272,12 +4294,14 @@ const EditorLayout = ({
4272
4294
  ) }) });
4273
4295
  }
4274
4296
  return /* @__PURE__ */ jsxRuntime.jsx(
4275
- designSystem.Box,
4297
+ designSystem.Flex,
4276
4298
  {
4277
4299
  borderColor: error ? "danger600" : "neutral200",
4278
4300
  borderStyle: "solid",
4279
4301
  borderWidth: "1px",
4280
4302
  hasRadius: true,
4303
+ direction: "column",
4304
+ alignItems: "stretch",
4281
4305
  children
4282
4306
  }
4283
4307
  );
@@ -4288,11 +4312,19 @@ const ExpandWrapper = styledComponents.styled(designSystem.Flex)`
4288
4312
  const BoxWithBorder = styledComponents.styled(designSystem.Box)`
4289
4313
  border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
4290
4314
  `;
4291
- const ExpandButton$1 = styledComponents.styled(designSystem.BaseButton)`
4315
+ const ExpandButton$1 = styledComponents.styled(designSystem.Button)`
4292
4316
  background-color: transparent;
4293
4317
  border: none;
4294
4318
  align-items: center;
4295
4319
 
4320
+ & > span {
4321
+ display: flex;
4322
+ justify-content: space-between;
4323
+ align-items: center;
4324
+ width: 100%;
4325
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4326
+ }
4327
+
4296
4328
  svg {
4297
4329
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4298
4330
 
@@ -4559,40 +4591,28 @@ const quoteAndCodeHandler = (editor, markdownType) => {
4559
4591
  insertWithoutTextToEdit(editor, markdownType, line, contentLength);
4560
4592
  }
4561
4593
  };
4562
- const CustomIconButton = styledComponents.styled(designSystem.IconButton)`
4563
- padding: ${({ theme }) => theme.spaces[2]};
4564
-
4565
- svg {
4566
- width: 1.8rem;
4567
- height: 1.8rem;
4568
- }
4569
- `;
4570
- const CustomLinkIconButton = styledComponents.styled(CustomIconButton)`
4571
- svg {
4572
- width: 0.8rem;
4573
- height: 0.8rem;
4574
- }
4575
- `;
4576
4594
  const MainButtons = styledComponents.styled(designSystem.IconButtonGroup)`
4577
4595
  margin-left: ${({ theme }) => theme.spaces[4]};
4578
4596
  `;
4579
4597
  const MoreButton = styledComponents.styled(designSystem.IconButton)`
4580
4598
  margin: ${({ theme }) => `0 ${theme.spaces[2]}`};
4581
- padding: ${({ theme }) => theme.spaces[2]};
4582
-
4583
- svg {
4584
- width: 1.8rem;
4585
- height: 1.8rem;
4586
- }
4587
4599
  `;
4588
4600
  const IconButtonGroupMargin = styledComponents.styled(designSystem.IconButtonGroup)`
4589
4601
  margin-right: ${({ theme }) => `${theme.spaces[2]}`};
4590
4602
  `;
4591
- const ExpandButton = styledComponents.styled(designSystem.BaseButton)`
4603
+ const ExpandButton = styledComponents.styled(designSystem.Button)`
4592
4604
  background-color: transparent;
4593
4605
  border: none;
4594
4606
  align-items: center;
4595
4607
 
4608
+ & > span {
4609
+ display: flex;
4610
+ justify-content: space-between;
4611
+ align-items: center;
4612
+ width: 100%;
4613
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4614
+ }
4615
+
4596
4616
  svg {
4597
4617
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4598
4618
  path {
@@ -4604,8 +4624,8 @@ const ExpandButton = styledComponents.styled(designSystem.BaseButton)`
4604
4624
  `;
4605
4625
  const WysiwygFooter = ({ onToggleExpand }) => {
4606
4626
  const { formatMessage } = reactIntl.useIntl();
4607
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, children: [
4608
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
4627
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, variant: "tertiary", size: "M", children: [
4628
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: formatMessage({
4609
4629
  id: "components.WysiwygBottomControls.fullscreen",
4610
4630
  defaultMessage: "Expand"
4611
4631
  }) }),
@@ -4641,18 +4661,27 @@ const WysiwygNav = ({
4641
4661
  borderRadius: `0.4rem 0.4rem 0 0`,
4642
4662
  children: [
4643
4663
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
4644
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { disabled: true, placeholder: selectPlaceholder, "aria-label": selectPlaceholder, children: [
4645
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4646
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
4647
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h3", children: "h3" }),
4648
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h4", children: "h4" }),
4649
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h5", children: "h5" }),
4650
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h6", children: "h6" })
4651
- ] }) }),
4664
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4665
+ designSystem.SingleSelect,
4666
+ {
4667
+ disabled: true,
4668
+ placeholder: selectPlaceholder,
4669
+ "aria-label": selectPlaceholder,
4670
+ size: "S",
4671
+ children: [
4672
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4673
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
4674
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h3", children: "h3" }),
4675
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h4", children: "h4" }),
4676
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h5", children: "h5" }),
4677
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h6", children: "h6" })
4678
+ ]
4679
+ }
4680
+ ) }),
4652
4681
  /* @__PURE__ */ jsxRuntime.jsxs(MainButtons, { children: [
4653
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4654
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Italic, {}) }),
4655
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Underline, {}) })
4682
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4683
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Italic, {}) }),
4684
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Underline, {}) })
4656
4685
  ] }),
4657
4686
  /* @__PURE__ */ jsxRuntime.jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, {}) })
4658
4687
  ] }),
@@ -4679,6 +4708,7 @@ const WysiwygNav = ({
4679
4708
  placeholder: selectPlaceholder,
4680
4709
  "aria-label": selectPlaceholder,
4681
4710
  onChange: (value) => onActionClick(value, editorRef),
4711
+ size: "S",
4682
4712
  children: [
4683
4713
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4684
4714
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
@@ -4690,17 +4720,9 @@ const WysiwygNav = ({
4690
4720
  }
4691
4721
  ) }),
4692
4722
  /* @__PURE__ */ jsxRuntime.jsxs(MainButtons, { children: [
4723
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { onClick: () => onActionClick("Bold", editorRef), label: "Bold", name: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4693
4724
  /* @__PURE__ */ jsxRuntime.jsx(
4694
- CustomIconButton,
4695
- {
4696
- onClick: () => onActionClick("Bold", editorRef),
4697
- label: "Bold",
4698
- name: "Bold",
4699
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {})
4700
- }
4701
- ),
4702
- /* @__PURE__ */ jsxRuntime.jsx(
4703
- CustomIconButton,
4725
+ designSystem.IconButton,
4704
4726
  {
4705
4727
  onClick: () => onActionClick("Italic", editorRef),
4706
4728
  label: "Italic",
@@ -4709,7 +4731,7 @@ const WysiwygNav = ({
4709
4731
  }
4710
4732
  ),
4711
4733
  /* @__PURE__ */ jsxRuntime.jsx(
4712
- CustomIconButton,
4734
+ designSystem.IconButton,
4713
4735
  {
4714
4736
  onClick: () => onActionClick("Underline", editorRef),
4715
4737
  label: "Underline",
@@ -4723,7 +4745,7 @@ const WysiwygNav = ({
4723
4745
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 2, children: [
4724
4746
  /* @__PURE__ */ jsxRuntime.jsxs(IconButtonGroupMargin, { children: [
4725
4747
  /* @__PURE__ */ jsxRuntime.jsx(
4726
- CustomIconButton,
4748
+ designSystem.IconButton,
4727
4749
  {
4728
4750
  onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4729
4751
  label: "Strikethrough",
@@ -4732,7 +4754,7 @@ const WysiwygNav = ({
4732
4754
  }
4733
4755
  ),
4734
4756
  /* @__PURE__ */ jsxRuntime.jsx(
4735
- CustomIconButton,
4757
+ designSystem.IconButton,
4736
4758
  {
4737
4759
  onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4738
4760
  label: "BulletList",
@@ -4741,7 +4763,7 @@ const WysiwygNav = ({
4741
4763
  }
4742
4764
  ),
4743
4765
  /* @__PURE__ */ jsxRuntime.jsx(
4744
- CustomIconButton,
4766
+ designSystem.IconButton,
4745
4767
  {
4746
4768
  onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4747
4769
  label: "NumberList",
@@ -4752,7 +4774,7 @@ const WysiwygNav = ({
4752
4774
  ] }),
4753
4775
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.IconButtonGroup, { children: [
4754
4776
  /* @__PURE__ */ jsxRuntime.jsx(
4755
- CustomIconButton,
4777
+ designSystem.IconButton,
4756
4778
  {
4757
4779
  onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4758
4780
  label: "Code",
@@ -4761,7 +4783,7 @@ const WysiwygNav = ({
4761
4783
  }
4762
4784
  ),
4763
4785
  /* @__PURE__ */ jsxRuntime.jsx(
4764
- CustomIconButton,
4786
+ designSystem.IconButton,
4765
4787
  {
4766
4788
  onClick: () => {
4767
4789
  handleTogglePopover();
@@ -4773,7 +4795,7 @@ const WysiwygNav = ({
4773
4795
  }
4774
4796
  ),
4775
4797
  /* @__PURE__ */ jsxRuntime.jsx(
4776
- CustomLinkIconButton,
4798
+ designSystem.IconButton,
4777
4799
  {
4778
4800
  onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4779
4801
  label: "Link",
@@ -4782,7 +4804,7 @@ const WysiwygNav = ({
4782
4804
  }
4783
4805
  ),
4784
4806
  /* @__PURE__ */ jsxRuntime.jsx(
4785
- CustomIconButton,
4807
+ designSystem.IconButton,
4786
4808
  {
4787
4809
  onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4788
4810
  label: "Quote",
@@ -4919,15 +4941,19 @@ const Wysiwyg = React__namespace.forwardRef(
4919
4941
  );
4920
4942
  const MemoizedWysiwyg = React__namespace.memo(Wysiwyg);
4921
4943
  const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4922
- const { id } = index.useDoc();
4944
+ const { id, document: document2, collectionType } = index.useDoc();
4923
4945
  const isFormDisabled = strapiAdmin.useForm("InputRenderer", (state) => state.disabled);
4924
4946
  const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
4925
4947
  const canCreateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
4926
4948
  const canReadFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
4927
4949
  const canUpdateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
4928
4950
  const canUserAction = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
4929
- const editableFields = id ? canUpdateFields : canCreateFields;
4930
- const readableFields = id ? canReadFields : canCreateFields;
4951
+ let idToCheck = id;
4952
+ if (collectionType === index.SINGLE_TYPES) {
4953
+ idToCheck = document2?.documentId;
4954
+ }
4955
+ const editableFields = idToCheck ? canUpdateFields : canCreateFields;
4956
+ const readableFields = idToCheck ? canReadFields : canCreateFields;
4931
4957
  const canUserReadField = canUserAction(props.name, readableFields, props.type);
4932
4958
  const canUserEditField = canUserAction(props.name, editableFields, props.type);
4933
4959
  const fields = strapiAdmin.useStrapiApp("InputRenderer", (app) => app.fields);
@@ -4938,6 +4964,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4938
4964
  const {
4939
4965
  edit: { components }
4940
4966
  } = index.useDocLayout();
4967
+ const field = strapiAdmin.useField(props.name);
4941
4968
  if (!visible) {
4942
4969
  return null;
4943
4970
  }
@@ -4948,551 +4975,643 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4948
4975
  if (attributeHasCustomFieldProperty(props.attribute)) {
4949
4976
  const CustomInput = lazyComponentStore[props.attribute.customField];
4950
4977
  if (CustomInput) {
4951
- return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4978
+ return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
4979
+ }
4980
+ return /* @__PURE__ */ jsxRuntime.jsx(
4981
+ strapiAdmin.InputRenderer,
4982
+ {
4983
+ ...props,
4984
+ hint,
4985
+ type: props.attribute.customField,
4986
+ disabled: fieldIsDisabled
4987
+ }
4988
+ );
4989
+ }
4990
+ const addedInputTypes = Object.keys(fields);
4991
+ if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4992
+ const CustomInput = fields[props.type];
4993
+ return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4994
+ }
4995
+ switch (props.type) {
4996
+ case "blocks":
4997
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4998
+ case "component":
4999
+ return /* @__PURE__ */ jsxRuntime.jsx(
5000
+ MemoizedComponentInput,
5001
+ {
5002
+ ...props,
5003
+ hint,
5004
+ layout: components[props.attribute.component].layout,
5005
+ disabled: fieldIsDisabled,
5006
+ children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
5007
+ }
5008
+ );
5009
+ case "dynamiczone":
5010
+ return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
5011
+ case "relation":
5012
+ return /* @__PURE__ */ jsxRuntime.jsx(Relations.MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
5013
+ case "richtext":
5014
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5015
+ case "uid":
5016
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5017
+ case "enumeration":
5018
+ return /* @__PURE__ */ jsxRuntime.jsx(
5019
+ strapiAdmin.InputRenderer,
5020
+ {
5021
+ ...props,
5022
+ hint,
5023
+ options: props.attribute.enum.map((value) => ({ value })),
5024
+ type: props.customField ? "custom-field" : props.type,
5025
+ disabled: fieldIsDisabled
5026
+ }
5027
+ );
5028
+ default:
5029
+ const { unique: _unique, mainField: _mainField, ...restProps } = props;
5030
+ return /* @__PURE__ */ jsxRuntime.jsx(
5031
+ strapiAdmin.InputRenderer,
5032
+ {
5033
+ ...restProps,
5034
+ hint,
5035
+ type: props.customField ? "custom-field" : props.type,
5036
+ disabled: fieldIsDisabled
5037
+ }
5038
+ );
5039
+ }
5040
+ };
5041
+ const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
5042
+ const useFieldHint = (hint = void 0, attribute) => {
5043
+ const { formatMessage } = reactIntl.useIntl();
5044
+ const { maximum, minimum } = getMinMax(attribute);
5045
+ if (!maximum && !minimum) {
5046
+ return hint;
5047
+ }
5048
+ const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
5049
+ attribute.type
5050
+ ) ? formatMessage(
5051
+ {
5052
+ id: "content-manager.form.Input.hint.character.unit",
5053
+ defaultMessage: "{maxValue, plural, one { character} other { characters}}"
5054
+ },
5055
+ {
5056
+ maxValue: Math.max(minimum || 0, maximum || 0)
5057
+ }
5058
+ ) : null;
5059
+ const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
5060
+ return formatMessage(
5061
+ {
5062
+ id: "content-manager.form.Input.hint.text",
5063
+ defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
5064
+ },
5065
+ {
5066
+ min: minimum,
5067
+ max: maximum,
5068
+ description: hint,
5069
+ unit: units,
5070
+ divider: hasMinAndMax ? formatMessage({
5071
+ id: "content-manager.form.Input.hint.minMaxDivider",
5072
+ defaultMessage: " / "
5073
+ }) : null,
5074
+ br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
5075
+ }
5076
+ );
5077
+ };
5078
+ const getMinMax = (attribute) => {
5079
+ if ("min" in attribute || "max" in attribute) {
5080
+ return {
5081
+ maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
5082
+ minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
5083
+ };
5084
+ } else if ("maxLength" in attribute || "minLength" in attribute) {
5085
+ return { maximum: attribute.maxLength, minimum: attribute.minLength };
5086
+ } else {
5087
+ return { maximum: void 0, minimum: void 0 };
5088
+ }
5089
+ };
5090
+ const MemoizedInputRenderer = React.memo(InputRenderer);
5091
+ const RESPONSIVE_CONTAINER_BREAKPOINTS = {
5092
+ sm: "27.5rem"
5093
+ // 440px
5094
+ };
5095
+ const ResponsiveGridRoot = styledComponents.styled(designSystem.Grid.Root)`
5096
+ container-type: inline-size;
5097
+ `;
5098
+ const ResponsiveGridItem = styledComponents.styled(designSystem.Grid.Item)`
5099
+ grid-column: span 12;
5100
+
5101
+ @container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
5102
+ ${({ col }) => col && `grid-column: span ${col};`}
5103
+ }
5104
+ `;
5105
+ const FormLayout = ({ layout }) => {
5106
+ const { formatMessage } = reactIntl.useIntl();
5107
+ const { model } = index.useDoc();
5108
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index2) => {
5109
+ if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
5110
+ const [row] = panel;
5111
+ const [field] = row;
5112
+ const fieldWithTranslatedLabel = {
5113
+ ...field,
5114
+ label: formatMessage({
5115
+ id: `content-manager.content-types.${model}.${field.name}`,
5116
+ defaultMessage: field.label
5117
+ })
5118
+ };
5119
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, s: 12, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel }) }) }, field.name);
5120
+ }
5121
+ return /* @__PURE__ */ jsxRuntime.jsx(
5122
+ designSystem.Box,
5123
+ {
5124
+ hasRadius: true,
5125
+ background: "neutral0",
5126
+ shadow: "tableShadow",
5127
+ paddingLeft: 6,
5128
+ paddingRight: 6,
5129
+ paddingTop: 6,
5130
+ paddingBottom: 6,
5131
+ borderColor: "neutral150",
5132
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: panel.map((row, gridRowIndex) => /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5133
+ const fieldWithTranslatedLabel = {
5134
+ ...field,
5135
+ label: formatMessage({
5136
+ id: `content-manager.content-types.${model}.${field.name}`,
5137
+ defaultMessage: field.label
5138
+ })
5139
+ };
5140
+ return /* @__PURE__ */ jsxRuntime.jsx(
5141
+ ResponsiveGridItem,
5142
+ {
5143
+ col: size,
5144
+ s: 12,
5145
+ xs: 12,
5146
+ direction: "column",
5147
+ alignItems: "stretch",
5148
+ children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
5149
+ },
5150
+ field.name
5151
+ );
5152
+ }) }, gridRowIndex)) })
5153
+ },
5154
+ index2
5155
+ );
5156
+ }) });
5157
+ };
5158
+ const NonRepeatableComponent = ({
5159
+ attribute,
5160
+ name: name2,
5161
+ children,
5162
+ layout
5163
+ }) => {
5164
+ const { formatMessage } = reactIntl.useIntl();
5165
+ const { value } = strapiAdmin.useField(name2);
5166
+ const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
5167
+ const isNested = level > 0;
5168
+ return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
5169
+ designSystem.Box,
5170
+ {
5171
+ background: "neutral100",
5172
+ paddingLeft: 6,
5173
+ paddingRight: 6,
5174
+ paddingTop: 6,
5175
+ paddingBottom: 6,
5176
+ hasRadius: isNested,
5177
+ borderColor: isNested ? "neutral200" : void 0,
5178
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
5179
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5180
+ const completeFieldName = `${name2}.${field.name}`;
5181
+ const translatedLabel = formatMessage({
5182
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5183
+ defaultMessage: field.label
5184
+ });
5185
+ return /* @__PURE__ */ jsxRuntime.jsx(
5186
+ ResponsiveGridItem,
5187
+ {
5188
+ col: size,
5189
+ s: 12,
5190
+ xs: 12,
5191
+ direction: "column",
5192
+ alignItems: "stretch",
5193
+ children: children({ ...field, label: translatedLabel, name: completeFieldName })
5194
+ },
5195
+ completeFieldName
5196
+ );
5197
+ }) }, index2);
5198
+ }) })
5199
+ }
5200
+ ) });
5201
+ };
5202
+ const RepeatableComponent = ({
5203
+ attribute,
5204
+ disabled,
5205
+ name: name2,
5206
+ mainField,
5207
+ children,
5208
+ layout
5209
+ }) => {
5210
+ const { toggleNotification } = strapiAdmin.useNotification();
5211
+ const { formatMessage } = reactIntl.useIntl();
5212
+ const { search: searchString } = reactRouterDom.useLocation();
5213
+ const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
5214
+ const { components } = index.useDoc();
5215
+ const {
5216
+ value = [],
5217
+ error,
5218
+ rawError
5219
+ } = strapiAdmin.useField(name2);
5220
+ const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
5221
+ const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
5222
+ const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
5223
+ const { max = Infinity } = attribute;
5224
+ const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
5225
+ const [liveText, setLiveText] = React__namespace.useState("");
5226
+ React__namespace.useEffect(() => {
5227
+ const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
5228
+ const hasNestedValue = value && Array.isArray(value) && value.length > 0;
5229
+ if (hasNestedErrors && hasNestedValue) {
5230
+ const errorOpenItems = rawError.map((_, idx) => {
5231
+ return value[idx] ? value[idx].__temp_key__ : null;
5232
+ }).filter((value2) => !!value2);
5233
+ if (errorOpenItems && errorOpenItems.length > 0) {
5234
+ setCollapseToOpen((collapseToOpen2) => {
5235
+ if (!errorOpenItems.includes(collapseToOpen2)) {
5236
+ return errorOpenItems[0];
5237
+ }
5238
+ return collapseToOpen2;
5239
+ });
5240
+ }
4952
5241
  }
4953
- return /* @__PURE__ */ jsxRuntime.jsx(
4954
- strapiAdmin.InputRenderer,
4955
- {
4956
- ...props,
4957
- hint,
4958
- type: props.attribute.customField,
4959
- disabled: fieldIsDisabled
5242
+ }, [rawError, value]);
5243
+ const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
5244
+ if (search.has("field")) {
5245
+ const fieldParam = search.get("field");
5246
+ if (!fieldParam) {
5247
+ return void 0;
5248
+ }
5249
+ const [, path] = fieldParam.split(`${name2}.`);
5250
+ if (objects.getIn(value, path, void 0) !== void 0) {
5251
+ const [subpath] = path.split(".");
5252
+ return objects.getIn(value, subpath, void 0)?.__temp_key__;
4960
5253
  }
5254
+ }
5255
+ return void 0;
5256
+ }, [search, name2, value]);
5257
+ const prevValue = usePrev.usePrev(value);
5258
+ React__namespace.useEffect(() => {
5259
+ if (prevValue && prevValue.length < value.length) {
5260
+ setCollapseToOpen(value[value.length - 1].__temp_key__);
5261
+ }
5262
+ }, [value, prevValue]);
5263
+ React__namespace.useEffect(() => {
5264
+ if (typeof componentTmpKeyWithFocussedField === "string") {
5265
+ setCollapseToOpen(componentTmpKeyWithFocussedField);
5266
+ }
5267
+ }, [componentTmpKeyWithFocussedField]);
5268
+ const toggleCollapses = () => {
5269
+ setCollapseToOpen("");
5270
+ };
5271
+ const handleClick = () => {
5272
+ if (value.length < max) {
5273
+ const schema = components[attribute.component];
5274
+ const form = index.createDefaultForm(schema, components);
5275
+ const data = index.transformDocument(schema, components)(form);
5276
+ addFieldRow(name2, data);
5277
+ } else if (value.length >= max) {
5278
+ toggleNotification({
5279
+ type: "info",
5280
+ message: formatMessage({
5281
+ id: index.getTranslation("components.notification.info.maximum-requirement")
5282
+ })
5283
+ });
5284
+ }
5285
+ };
5286
+ const handleMoveComponentField = (newIndex, currentIndex) => {
5287
+ setLiveText(
5288
+ formatMessage(
5289
+ {
5290
+ id: index.getTranslation("dnd.reorder"),
5291
+ defaultMessage: "{item}, moved. New position in list: {position}."
5292
+ },
5293
+ {
5294
+ item: `${name2}.${currentIndex}`,
5295
+ position: getItemPos(newIndex)
5296
+ }
5297
+ )
4961
5298
  );
4962
- }
4963
- const addedInputTypes = Object.keys(fields);
4964
- if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4965
- const CustomInput = fields[props.type];
4966
- return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4967
- }
4968
- switch (props.type) {
4969
- case "blocks":
4970
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4971
- case "component":
4972
- return /* @__PURE__ */ jsxRuntime.jsx(
4973
- MemoizedComponentInput,
5299
+ moveFieldRow(name2, currentIndex, newIndex);
5300
+ };
5301
+ const handleValueChange = (key) => {
5302
+ setCollapseToOpen(key);
5303
+ };
5304
+ const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
5305
+ const handleCancel = (index$1) => {
5306
+ setLiveText(
5307
+ formatMessage(
4974
5308
  {
4975
- ...props,
4976
- hint,
4977
- layout: components[props.attribute.component].layout,
4978
- disabled: fieldIsDisabled,
4979
- children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
5309
+ id: index.getTranslation("dnd.cancel-item"),
5310
+ defaultMessage: "{item}, dropped. Re-order cancelled."
5311
+ },
5312
+ {
5313
+ item: `${name2}.${index$1}`
4980
5314
  }
4981
- );
4982
- case "dynamiczone":
4983
- return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
4984
- case "relation":
4985
- return /* @__PURE__ */ jsxRuntime.jsx(Relations.MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
4986
- case "richtext":
4987
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4988
- case "uid":
4989
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4990
- case "enumeration":
4991
- return /* @__PURE__ */ jsxRuntime.jsx(
4992
- strapiAdmin.InputRenderer,
5315
+ )
5316
+ );
5317
+ };
5318
+ const handleGrabItem = (index$1) => {
5319
+ setLiveText(
5320
+ formatMessage(
4993
5321
  {
4994
- ...props,
4995
- hint,
4996
- options: props.attribute.enum.map((value) => ({ value })),
4997
- type: props.customField ? "custom-field" : props.type,
4998
- disabled: fieldIsDisabled
5322
+ id: index.getTranslation("dnd.grab-item"),
5323
+ defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
5324
+ },
5325
+ {
5326
+ item: `${name2}.${index$1}`,
5327
+ position: getItemPos(index$1)
4999
5328
  }
5000
- );
5001
- default:
5002
- const { unique: _unique, mainField: _mainField, ...restProps } = props;
5003
- return /* @__PURE__ */ jsxRuntime.jsx(
5004
- strapiAdmin.InputRenderer,
5329
+ )
5330
+ );
5331
+ };
5332
+ const handleDropItem = (index$1) => {
5333
+ setLiveText(
5334
+ formatMessage(
5005
5335
  {
5006
- ...restProps,
5007
- hint,
5008
- type: props.customField ? "custom-field" : props.type,
5009
- disabled: fieldIsDisabled
5336
+ id: index.getTranslation("dnd.drop-item"),
5337
+ defaultMessage: `{item}, dropped. Final position in list: {position}.`
5338
+ },
5339
+ {
5340
+ item: `${name2}.${index$1}`,
5341
+ position: getItemPos(index$1)
5010
5342
  }
5011
- );
5343
+ )
5344
+ );
5345
+ };
5346
+ const ariaDescriptionId = React__namespace.useId();
5347
+ const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
5348
+ if (value.length === 0) {
5349
+ return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
5012
5350
  }
5351
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
5352
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5353
+ id: index.getTranslation("dnd.instructions"),
5354
+ defaultMessage: `Press spacebar to grab and re-order`
5355
+ }) }),
5356
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5357
+ /* @__PURE__ */ jsxRuntime.jsxs(
5358
+ AccordionRoot,
5359
+ {
5360
+ $error: error,
5361
+ value: collapseToOpen,
5362
+ onValueChange: handleValueChange,
5363
+ "aria-describedby": ariaDescriptionId,
5364
+ children: [
5365
+ value.map(({ __temp_key__: key, id }, index2) => {
5366
+ const nameWithIndex = `${name2}.${index2}`;
5367
+ return /* @__PURE__ */ jsxRuntime.jsx(
5368
+ Relations.ComponentProvider,
5369
+ {
5370
+ id,
5371
+ uid: attribute.component,
5372
+ level: level + 1,
5373
+ type: "repeatable",
5374
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5375
+ Component,
5376
+ {
5377
+ disabled,
5378
+ name: nameWithIndex,
5379
+ attribute,
5380
+ index: index2,
5381
+ mainField,
5382
+ onMoveItem: handleMoveComponentField,
5383
+ onDeleteComponent: () => {
5384
+ removeFieldRow(name2, index2);
5385
+ toggleCollapses();
5386
+ },
5387
+ toggleCollapses,
5388
+ onCancel: handleCancel,
5389
+ onDropItem: handleDropItem,
5390
+ onGrabItem: handleGrabItem,
5391
+ __temp_key__: key,
5392
+ children: layout.map((row, index22) => {
5393
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5394
+ const completeFieldName = `${nameWithIndex}.${field.name}`;
5395
+ const translatedLabel = formatMessage({
5396
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5397
+ defaultMessage: field.label
5398
+ });
5399
+ return /* @__PURE__ */ jsxRuntime.jsx(
5400
+ ResponsiveGridItem,
5401
+ {
5402
+ col: size,
5403
+ s: 12,
5404
+ xs: 12,
5405
+ direction: "column",
5406
+ alignItems: "stretch",
5407
+ children: children({
5408
+ ...field,
5409
+ label: translatedLabel,
5410
+ name: completeFieldName
5411
+ })
5412
+ },
5413
+ completeFieldName
5414
+ );
5415
+ }) }, index22);
5416
+ })
5417
+ }
5418
+ )
5419
+ },
5420
+ key
5421
+ );
5422
+ }),
5423
+ /* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
5424
+ id: index.getTranslation("containers.EditView.add.new-entry"),
5425
+ defaultMessage: "Add an entry"
5426
+ }) })
5427
+ ]
5428
+ }
5429
+ )
5430
+ ] });
5013
5431
  };
5014
- const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
5015
- const useFieldHint = (hint = void 0, attribute) => {
5016
- const { formatMessage } = reactIntl.useIntl();
5017
- const { maximum, minimum } = getMinMax(attribute);
5018
- if (!maximum && !minimum) {
5019
- return hint;
5020
- }
5021
- const units = !["biginteger", "integer", "number"].includes(attribute.type) ? formatMessage(
5022
- {
5023
- id: "content-manager.form.Input.hint.character.unit",
5024
- defaultMessage: "{maxValue, plural, one { character} other { characters}}"
5025
- },
5026
- {
5027
- maxValue: Math.max(minimum || 0, maximum || 0)
5028
- }
5029
- ) : null;
5030
- const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
5031
- return formatMessage(
5032
- {
5033
- id: "content-manager.form.Input.hint.text",
5034
- defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
5035
- },
5036
- {
5037
- min: minimum,
5038
- max: maximum,
5039
- description: hint,
5040
- unit: units,
5041
- divider: hasMinAndMax ? formatMessage({
5042
- id: "content-manager.form.Input.hint.minMaxDivider",
5043
- defaultMessage: " / "
5044
- }) : null,
5045
- br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
5432
+ const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
5433
+ border: 1px solid
5434
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
5435
+ `;
5436
+ const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
5437
+ width: 100%;
5438
+ display: flex;
5439
+ justify-content: center;
5440
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
5441
+ padding-inline: ${(props) => props.theme.spaces[6]};
5442
+ padding-block: ${(props) => props.theme.spaces[3]};
5443
+
5444
+ &:not([disabled]) {
5445
+ cursor: pointer;
5446
+
5447
+ &:hover {
5448
+ background-color: ${(props) => props.theme.colors.primary100};
5046
5449
  }
5047
- );
5048
- };
5049
- const getMinMax = (attribute) => {
5050
- if ("min" in attribute || "max" in attribute) {
5051
- return {
5052
- maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
5053
- minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
5054
- };
5055
- } else if ("maxLength" in attribute || "minLength" in attribute) {
5056
- return { maximum: attribute.maxLength, minimum: attribute.minLength };
5057
- } else {
5058
- return { maximum: void 0, minimum: void 0 };
5059
5450
  }
5060
- };
5061
- const MemoizedInputRenderer = React.memo(InputRenderer);
5062
- const DynamicComponent = ({
5063
- componentUid,
5451
+
5452
+ span {
5453
+ font-weight: 600;
5454
+ font-size: 1.4rem;
5455
+ line-height: 2.4rem;
5456
+ }
5457
+
5458
+ @media (prefers-reduced-motion: no-preference) {
5459
+ transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
5460
+ }
5461
+ `;
5462
+ const Component = ({
5064
5463
  disabled,
5065
5464
  index: index$1,
5066
5465
  name: name2,
5067
- onRemoveComponentClick,
5068
- onMoveComponent,
5069
- onGrabItem,
5070
- onDropItem,
5071
- onCancel,
5072
- dynamicComponentsByCategory = {},
5073
- onAddComponent
5466
+ mainField = {
5467
+ name: "id",
5468
+ type: "integer"
5469
+ },
5470
+ children,
5471
+ onDeleteComponent,
5472
+ toggleCollapses,
5473
+ __temp_key__,
5474
+ ...dragProps
5074
5475
  }) => {
5075
5476
  const { formatMessage } = reactIntl.useIntl();
5076
- const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
5077
- const {
5078
- edit: { components }
5079
- } = index.useDocLayout();
5080
- const title = React__namespace.useMemo(() => {
5081
- const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
5082
- const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
5083
- const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
5084
- const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
5085
- return mainValue;
5086
- }, [componentUid, components, formValues, name2, index$1]);
5087
- const { icon, displayName } = React__namespace.useMemo(() => {
5088
- const [category] = componentUid.split(".");
5089
- const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
5090
- (component) => component.uid === componentUid
5091
- ) ?? { icon: null, displayName: null };
5092
- return { icon: icon2, displayName: displayName2 };
5093
- }, [componentUid, dynamicComponentsByCategory]);
5477
+ const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
5478
+ return objects.getIn(state.values, [...name2.split("."), mainField.name]);
5479
+ });
5480
+ const accordionRef = React__namespace.useRef(null);
5481
+ const componentKey = name2.split(".").slice(0, -1).join(".");
5094
5482
  const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
5095
- type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
5483
+ type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
5096
5484
  index: index$1,
5097
5485
  item: {
5098
5486
  index: index$1,
5099
- displayedValue: `${displayName} ${title}`,
5100
- icon
5487
+ displayedValue: displayValue
5101
5488
  },
5102
- onMoveItem: onMoveComponent,
5103
- onDropItem,
5104
- onGrabItem,
5105
- onCancel
5489
+ onStart() {
5490
+ toggleCollapses();
5491
+ },
5492
+ ...dragProps
5106
5493
  });
5107
5494
  React__namespace.useEffect(() => {
5108
5495
  dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
5109
5496
  }, [dragPreviewRef, index$1]);
5110
- const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
5111
- const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5112
- /* @__PURE__ */ jsxRuntime.jsx(
5113
- designSystem.IconButton,
5114
- {
5115
- borderWidth: 0,
5116
- label: formatMessage(
5497
+ const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
5498
+ const composedBoxRefs = designSystem.useComposedRefs(
5499
+ boxRef,
5500
+ dropRef
5501
+ );
5502
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
5503
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
5504
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: displayValue }),
5505
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Actions, { children: [
5506
+ /* @__PURE__ */ jsxRuntime.jsx(
5507
+ designSystem.IconButton,
5117
5508
  {
5118
- id: index.getTranslation("components.DynamicZone.delete-label"),
5119
- defaultMessage: "Delete {name}"
5120
- },
5121
- { name: title }
5509
+ variant: "ghost",
5510
+ onClick: onDeleteComponent,
5511
+ label: formatMessage({
5512
+ id: index.getTranslation("containers.Edit.delete"),
5513
+ defaultMessage: "Delete"
5514
+ }),
5515
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5516
+ }
5122
5517
  ),
5123
- onClick: onRemoveComponentClick,
5124
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5125
- }
5126
- ),
5127
- /* @__PURE__ */ jsxRuntime.jsx(
5128
- designSystem.IconButton,
5129
- {
5130
- borderWidth: 0,
5131
- onClick: (e) => e.stopPropagation(),
5132
- "data-handler-id": handlerId,
5133
- ref: dragRef,
5134
- label: formatMessage({
5135
- id: index.getTranslation("components.DragHandle-label"),
5136
- defaultMessage: "Drag"
5137
- }),
5138
- onKeyDown: handleKeyDown,
5139
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
5140
- }
5141
- ),
5142
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
5143
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
5144
- /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
5145
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: formatMessage({
5146
- id: index.getTranslation("components.DynamicZone.more-actions"),
5147
- defaultMessage: "More actions"
5148
- }) })
5149
- ] }),
5150
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
5151
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
5152
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
5153
- id: index.getTranslation("components.DynamicZone.add-item-above"),
5154
- defaultMessage: "Add component above"
5155
- }) }),
5156
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
5157
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
5158
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
5159
- ] }, category)) })
5160
- ] }),
5161
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
5162
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
5163
- id: index.getTranslation("components.DynamicZone.add-item-below"),
5164
- defaultMessage: "Add component below"
5165
- }) }),
5166
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
5167
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
5168
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
5169
- ] }, category)) })
5170
- ] })
5171
- ] })
5172
- ] })
5173
- ] });
5174
- const accordionTitle = title ? `${displayName} ${title}` : displayName;
5175
- const accordionValue = React__namespace.useId();
5176
- return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
5177
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
5178
- /* @__PURE__ */ jsxRuntime.jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: accordionValue, children: [
5179
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
5180
5518
  /* @__PURE__ */ jsxRuntime.jsx(
5181
- designSystem.Accordion.Trigger,
5519
+ designSystem.IconButton,
5182
5520
  {
5183
- icon: icon && ComponentIcon.COMPONENT_ICONS[icon] ? ComponentIcon.COMPONENT_ICONS[icon] : ComponentIcon.COMPONENT_ICONS.dashboard,
5184
- children: accordionTitle
5521
+ ref: composedAccordionRefs,
5522
+ variant: "ghost",
5523
+ onClick: (e) => e.stopPropagation(),
5524
+ "data-handler-id": handlerId,
5525
+ label: formatMessage({
5526
+ id: index.getTranslation("components.DragHandle-label"),
5527
+ defaultMessage: "Drag"
5528
+ }),
5529
+ onKeyDown: handleKeyDown,
5530
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
5185
5531
  }
5186
- ),
5187
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
5188
- ] }),
5189
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
5190
- const fieldName = `${name2}.${index$1}.${field.name}`;
5191
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: size, s: 12, xs: 12, children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...field, name: fieldName }) }, fieldName);
5192
- }) }, rowInd)) }) }) })
5193
- ] }) }) })
5194
- ] });
5195
- };
5196
- const StyledBox = styledComponents.styled(designSystem.Box)`
5197
- > div:first-child {
5198
- box-shadow: ${({ theme }) => theme.shadows.tableShadow};
5199
- }
5200
- `;
5201
- const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
5202
- border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
5203
- `;
5204
- const Rectangle = styledComponents.styled(designSystem.Box)`
5205
- width: ${({ theme }) => theme.spaces[2]};
5206
- height: ${({ theme }) => theme.spaces[4]};
5207
- `;
5208
- const Preview = styledComponents.styled.span`
5209
- display: block;
5210
- background-color: ${({ theme }) => theme.colors.primary100};
5211
- outline: 1px dashed ${({ theme }) => theme.colors.primary500};
5212
- outline-offset: -1px;
5213
- padding: ${({ theme }) => theme.spaces[6]};
5214
- `;
5215
- const ComponentContainer = styledComponents.styled(designSystem.Box)`
5216
- list-style: none;
5217
- padding: 0;
5218
- margin: 0;
5219
- `;
5220
- const DynamicZoneLabel = ({
5221
- hint,
5222
- label,
5223
- labelAction,
5224
- name: name2,
5225
- numberOfComponents = 0,
5226
- required
5227
- }) => {
5228
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
5229
- designSystem.Box,
5230
- {
5231
- paddingTop: 3,
5232
- paddingBottom: 3,
5233
- paddingRight: 4,
5234
- paddingLeft: 4,
5235
- borderRadius: "26px",
5236
- background: "neutral0",
5237
- shadow: "filterShadow",
5238
- color: "neutral500",
5239
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
5240
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
5241
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
5242
- label || name2,
5243
- " "
5244
- ] }),
5245
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
5246
- "(",
5247
- numberOfComponents,
5248
- ")"
5249
- ] }),
5250
- required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
5251
- labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
5252
- ] }),
5253
- hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
5532
+ )
5254
5533
  ] })
5255
- }
5256
- ) });
5534
+ ] }),
5535
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
5536
+ designSystem.Flex,
5537
+ {
5538
+ direction: "column",
5539
+ alignItems: "stretch",
5540
+ background: "neutral100",
5541
+ padding: 6,
5542
+ gap: 6,
5543
+ children
5544
+ }
5545
+ ) })
5546
+ ] }) });
5257
5547
  };
5258
- const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
5259
- "DynamicZone",
5260
- {
5261
- isInDynamicZone: false
5262
- }
5263
- );
5264
- const DynamicZone = ({
5265
- attribute,
5266
- disabled: disabledProp,
5267
- hint,
5548
+ const Preview = () => {
5549
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
5550
+ };
5551
+ const StyledSpan = styledComponents.styled(designSystem.Box)`
5552
+ display: block;
5553
+ outline: 1px dashed ${({ theme }) => theme.colors.primary500};
5554
+ outline-offset: -1px;
5555
+ `;
5556
+ const ComponentInput = ({
5268
5557
  label,
5269
- labelAction,
5558
+ required,
5270
5559
  name: name2,
5271
- required = false
5560
+ attribute,
5561
+ disabled,
5562
+ labelAction,
5563
+ ...props
5272
5564
  }) => {
5273
- const { max = Infinity, min = -Infinity } = attribute ?? {};
5274
- const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
5275
- const [liveText, setLiveText] = React__namespace.useState("");
5276
- const { components, isLoading } = index.useDoc();
5277
- const disabled = disabledProp || isLoading;
5278
- const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
5279
- "DynamicZone",
5280
- ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
5281
- addFieldRow: addFieldRow2,
5282
- removeFieldRow: removeFieldRow2,
5283
- moveFieldRow: moveFieldRow2
5284
- })
5285
- );
5286
- const { value = [], error } = strapiAdmin.useField(name2);
5287
- const dynamicComponentsByCategory = React__namespace.useMemo(() => {
5288
- return attribute.components.reduce((acc, componentUid) => {
5289
- const { category, info } = components[componentUid] ?? { info: {} };
5290
- const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
5291
- if (!acc[category]) {
5292
- acc[category] = [];
5293
- }
5294
- acc[category] = [...acc[category], component];
5295
- return acc;
5296
- }, {});
5297
- }, [attribute.components, components]);
5298
5565
  const { formatMessage } = reactIntl.useIntl();
5299
- const { toggleNotification } = strapiAdmin.useNotification();
5300
- const dynamicDisplayedComponentsLength = value.length;
5301
- const handleAddComponent = (uid, position) => {
5302
- setAddComponentIsOpen(false);
5303
- const schema = components[uid];
5304
- const form = createDefaultForm(schema, components);
5305
- const transformations = pipe__default.default(transformDocument(schema, components), (data2) => ({
5306
- ...data2,
5307
- __component: uid
5308
- }));
5309
- const data = transformations(form);
5310
- addFieldRow(name2, data, position);
5311
- };
5312
- const handleClickOpenPicker = () => {
5313
- if (dynamicDisplayedComponentsLength < max) {
5314
- setAddComponentIsOpen((prev) => !prev);
5315
- } else {
5316
- toggleNotification({
5317
- type: "info",
5318
- message: formatMessage({
5319
- id: index.getTranslation("components.notification.info.maximum-requirement")
5320
- })
5321
- });
5322
- }
5323
- };
5324
- const handleMoveComponent = (newIndex, currentIndex) => {
5325
- setLiveText(
5326
- formatMessage(
5327
- {
5328
- id: index.getTranslation("dnd.reorder"),
5329
- defaultMessage: "{item}, moved. New position in list: {position}."
5330
- },
5331
- {
5332
- item: `${name2}.${currentIndex}`,
5333
- position: getItemPos(newIndex)
5334
- }
5335
- )
5336
- );
5337
- moveFieldRow(name2, currentIndex, newIndex);
5338
- };
5339
- const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
5340
- const handleCancel = (index$1) => {
5341
- setLiveText(
5342
- formatMessage(
5343
- {
5344
- id: index.getTranslation("dnd.cancel-item"),
5345
- defaultMessage: "{item}, dropped. Re-order cancelled."
5346
- },
5347
- {
5348
- item: `${name2}.${index$1}`
5349
- }
5350
- )
5351
- );
5352
- };
5353
- const handleGrabItem = (index$1) => {
5354
- setLiveText(
5355
- formatMessage(
5356
- {
5357
- id: index.getTranslation("dnd.grab-item"),
5358
- defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
5359
- },
5360
- {
5361
- item: `${name2}.${index$1}`,
5362
- position: getItemPos(index$1)
5363
- }
5364
- )
5365
- );
5566
+ const field = strapiAdmin.useField(name2);
5567
+ const showResetComponent = !attribute.repeatable && field.value && !disabled;
5568
+ const { components } = index.useDoc();
5569
+ const handleInitialisationClick = () => {
5570
+ const schema = components[attribute.component];
5571
+ const form = index.createDefaultForm(schema, components);
5572
+ const data = index.transformDocument(schema, components)(form);
5573
+ field.onChange(name2, data);
5366
5574
  };
5367
- const handleDropItem = (index$1) => {
5368
- setLiveText(
5369
- formatMessage(
5370
- {
5371
- id: index.getTranslation("dnd.drop-item"),
5372
- defaultMessage: `{item}, dropped. Final position in list: {position}.`
5373
- },
5575
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
5576
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
5577
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
5578
+ label,
5579
+ attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5580
+ " (",
5581
+ Array.isArray(field.value) ? field.value.length : 0,
5582
+ ")"
5583
+ ] })
5584
+ ] }),
5585
+ showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
5586
+ designSystem.IconButton,
5374
5587
  {
5375
- item: `${name2}.${index$1}`,
5376
- position: getItemPos(index$1)
5588
+ label: formatMessage({
5589
+ id: index.getTranslation("components.reset-entry"),
5590
+ defaultMessage: "Reset Entry"
5591
+ }),
5592
+ variant: "ghost",
5593
+ onClick: () => {
5594
+ field.onChange(name2, null);
5595
+ },
5596
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5377
5597
  }
5378
5598
  )
5379
- );
5380
- };
5381
- const handleRemoveComponent = (name22, currentIndex) => () => {
5382
- removeFieldRow(name22, currentIndex);
5383
- };
5384
- const hasError = error !== void 0 || dynamicDisplayedComponentsLength < min || dynamicDisplayedComponentsLength > max;
5385
- const renderButtonLabel = () => {
5386
- if (addComponentIsOpen) {
5387
- return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
5388
- }
5389
- if (hasError && dynamicDisplayedComponentsLength > max) {
5390
- return formatMessage(
5391
- {
5392
- id: index.getTranslation(`components.DynamicZone.extra-components`),
5393
- defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
5394
- },
5395
- {
5396
- number: dynamicDisplayedComponentsLength - max
5397
- }
5398
- );
5399
- }
5400
- if (hasError && dynamicDisplayedComponentsLength < min) {
5401
- return formatMessage(
5402
- {
5403
- id: index.getTranslation(`components.DynamicZone.missing-components`),
5404
- defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
5405
- },
5406
- { number: min - dynamicDisplayedComponentsLength }
5407
- );
5408
- }
5409
- return formatMessage(
5410
- {
5411
- id: index.getTranslation("components.DynamicZone.add-component"),
5412
- defaultMessage: "Add a component to {componentName}"
5413
- },
5414
- { componentName: label || name2 }
5415
- );
5416
- };
5417
- const level = Relations.useComponent("DynamicZone", (state) => state.level);
5418
- const ariaDescriptionId = React__namespace.useId();
5419
- return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
5420
- dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
5421
- /* @__PURE__ */ jsxRuntime.jsx(
5422
- DynamicZoneLabel,
5423
- {
5424
- hint,
5425
- label,
5426
- labelAction,
5427
- name: name2,
5428
- numberOfComponents: dynamicDisplayedComponentsLength,
5429
- required
5430
- }
5431
- ),
5432
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5433
- id: index.getTranslation("dnd.instructions"),
5434
- defaultMessage: `Press spacebar to grab and re-order`
5435
- }) }),
5436
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5437
- /* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
5438
- Relations.ComponentProvider,
5439
- {
5440
- level: level + 1,
5441
- uid: field.__component,
5442
- id: field.id,
5443
- type: "dynamiczone",
5444
- children: /* @__PURE__ */ jsxRuntime.jsx(
5445
- DynamicComponent,
5446
- {
5447
- disabled,
5448
- name: name2,
5449
- index: index2,
5450
- componentUid: field.__component,
5451
- onMoveComponent: handleMoveComponent,
5452
- onRemoveComponentClick: handleRemoveComponent(name2, index2),
5453
- onCancel: handleCancel,
5454
- onDropItem: handleDropItem,
5455
- onGrabItem: handleGrabItem,
5456
- onAddComponent: handleAddComponent,
5457
- dynamicComponentsByCategory
5458
- }
5459
- )
5460
- },
5461
- field.__temp_key__
5462
- )) })
5463
5599
  ] }),
5464
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
5465
- AddComponentButton,
5466
- {
5467
- hasError,
5468
- isDisabled: disabled,
5469
- isOpen: addComponentIsOpen,
5470
- onClick: handleClickOpenPicker,
5471
- children: renderButtonLabel()
5472
- }
5473
- ) }),
5474
- /* @__PURE__ */ jsxRuntime.jsx(
5475
- ComponentPicker,
5476
- {
5477
- dynamicComponentsByCategory,
5478
- isOpen: addComponentIsOpen,
5479
- onClickAddComponent: handleAddComponent
5480
- }
5481
- )
5482
- ] }) });
5600
+ !attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
5601
+ !attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
5602
+ attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
5603
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
5604
+ ] });
5483
5605
  };
5606
+ const MemoizedComponentInput = React__namespace.memo(ComponentInput);
5484
5607
  exports.DynamicZone = DynamicZone;
5608
+ exports.FormLayout = FormLayout;
5485
5609
  exports.MemoizedBlocksInput = MemoizedBlocksInput;
5486
5610
  exports.MemoizedComponentInput = MemoizedComponentInput;
5487
- exports.MemoizedInputRenderer = MemoizedInputRenderer;
5488
5611
  exports.MemoizedUIDInput = MemoizedUIDInput;
5489
5612
  exports.MemoizedWysiwyg = MemoizedWysiwyg;
5490
5613
  exports.NotAllowedInput = NotAllowedInput;
5491
- exports.createDefaultForm = createDefaultForm;
5492
- exports.prepareTempKeys = prepareTempKeys;
5493
- exports.removeFieldsThatDontExistOnSchema = removeFieldsThatDontExistOnSchema;
5494
- exports.transformDocument = transformDocument;
5495
5614
  exports.useDynamicZone = useDynamicZone;
5496
5615
  exports.useFieldHint = useFieldHint;
5497
5616
  exports.useLazyComponents = useLazyComponents;
5498
- //# sourceMappingURL=Field-Boxf9Ajp.js.map
5617
+ //# sourceMappingURL=Input-B7sapvBG.js.map