@strapi/content-manager 0.0.0-experimental.4ddd402c7194d1a969a797313bf007c93148d59a → 0.0.0-experimental.51e87e311df34df634a6bce7b841df8be31f1efb

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 (226) 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-Cxz51Sve.mjs → ComponentConfigurationPage-D4H-v0et.mjs} +4 -4
  5. package/dist/_chunks/{ComponentConfigurationPage-Cxz51Sve.mjs.map → ComponentConfigurationPage-D4H-v0et.mjs.map} +1 -1
  6. package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js → ComponentConfigurationPage-DdkVGfXC.js} +5 -6
  7. package/dist/_chunks/{ComponentConfigurationPage-BZIaEffq.js.map → ComponentConfigurationPage-DdkVGfXC.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-CZLbgfIp.mjs → EditConfigurationPage-D1nvB7Br.mjs} +4 -4
  12. package/dist/_chunks/{EditConfigurationPage-CZLbgfIp.mjs.map → EditConfigurationPage-D1nvB7Br.mjs.map} +1 -1
  13. package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js → EditConfigurationPage-LYEvR4fW.js} +5 -6
  14. package/dist/_chunks/{EditConfigurationPage-CM62NN0L.js.map → EditConfigurationPage-LYEvR4fW.js.map} +1 -1
  15. package/dist/_chunks/EditViewPage-Bcnff6Vd.mjs +191 -0
  16. package/dist/_chunks/EditViewPage-Bcnff6Vd.mjs.map +1 -0
  17. package/dist/_chunks/{EditViewPage-CU7724gt.js → EditViewPage-DqelJ9UK.js} +71 -84
  18. package/dist/_chunks/EditViewPage-DqelJ9UK.js.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-BOR8NOe1.js → Form-CnHfBeiB.js} +55 -38
  22. package/dist/_chunks/Form-CnHfBeiB.js.map +1 -0
  23. package/dist/_chunks/{Form-COLpvlnv.mjs → Form-CzPCJi3B.mjs} +55 -37
  24. package/dist/_chunks/Form-CzPCJi3B.mjs.map +1 -0
  25. package/dist/_chunks/{History-Bu53Yfw-.mjs → History-CcmSn3Mj.mjs} +201 -130
  26. package/dist/_chunks/History-CcmSn3Mj.mjs.map +1 -0
  27. package/dist/_chunks/{History-CW2akQ6h.js → History-zArjENzj.js} +208 -138
  28. package/dist/_chunks/History-zArjENzj.js.map +1 -0
  29. package/dist/_chunks/{Field-Dh1yZyqy.js → Input-CDHKQd7o.js} +1748 -1373
  30. package/dist/_chunks/Input-CDHKQd7o.js.map +1 -0
  31. package/dist/_chunks/{Field-QtUSh5mU.mjs → Input-aV8SSoTa.mjs} +1757 -1382
  32. package/dist/_chunks/Input-aV8SSoTa.mjs.map +1 -0
  33. package/dist/_chunks/{ListConfigurationPage-TqrmwjPN.mjs → ListConfigurationPage-BPvzENJJ.mjs} +63 -52
  34. package/dist/_chunks/ListConfigurationPage-BPvzENJJ.mjs.map +1 -0
  35. package/dist/_chunks/{ListConfigurationPage-jzdhEk_u.js → ListConfigurationPage-ByZAO_9H.js} +62 -51
  36. package/dist/_chunks/ListConfigurationPage-ByZAO_9H.js.map +1 -0
  37. package/dist/_chunks/{ListViewPage-B3bMOrMv.js → ListViewPage-BVKBeQAA.js} +154 -128
  38. package/dist/_chunks/ListViewPage-BVKBeQAA.js.map +1 -0
  39. package/dist/_chunks/{ListViewPage-BO_mOXIl.mjs → ListViewPage-HljQVnFH.mjs} +155 -128
  40. package/dist/_chunks/ListViewPage-HljQVnFH.mjs.map +1 -0
  41. package/dist/_chunks/{NoContentTypePage-D77xsNHj.js → NoContentTypePage-BV5zfDxr.js} +2 -2
  42. package/dist/_chunks/{NoContentTypePage-D77xsNHj.js.map → NoContentTypePage-BV5zfDxr.js.map} +1 -1
  43. package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs → NoContentTypePage-BfHaSM-K.mjs} +2 -2
  44. package/dist/_chunks/{NoContentTypePage-DqB0QV0k.mjs.map → NoContentTypePage-BfHaSM-K.mjs.map} +1 -1
  45. package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs → NoPermissionsPage-D6ze2nQL.mjs} +2 -2
  46. package/dist/_chunks/{NoPermissionsPage-DTXi042N.mjs.map → NoPermissionsPage-D6ze2nQL.mjs.map} +1 -1
  47. package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js → NoPermissionsPage-vdNpc6jb.js} +2 -2
  48. package/dist/_chunks/{NoPermissionsPage-C6qTGogm.js.map → NoPermissionsPage-vdNpc6jb.js.map} +1 -1
  49. package/dist/_chunks/Preview-DEHdENT1.js +305 -0
  50. package/dist/_chunks/Preview-DEHdENT1.js.map +1 -0
  51. package/dist/_chunks/Preview-vfWOtPG5.mjs +287 -0
  52. package/dist/_chunks/Preview-vfWOtPG5.mjs.map +1 -0
  53. package/dist/_chunks/{Relations-CJ4qdkRo.mjs → Relations-B7_hbF0w.mjs} +79 -44
  54. package/dist/_chunks/Relations-B7_hbF0w.mjs.map +1 -0
  55. package/dist/_chunks/{Relations-B6fb2POW.js → Relations-DcoOBejP.js} +79 -45
  56. package/dist/_chunks/Relations-DcoOBejP.js.map +1 -0
  57. package/dist/_chunks/{en-DZXjRiWA.js → en-BR48D_RH.js} +41 -18
  58. package/dist/_chunks/{en-DZXjRiWA.js.map → en-BR48D_RH.js.map} +1 -1
  59. package/dist/_chunks/{en-9GwRW_ku.mjs → en-D65uIF6Y.mjs} +41 -18
  60. package/dist/_chunks/{en-9GwRW_ku.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-DcUu-_72.js → index-CxLSGwnk.js} +1504 -960
  71. package/dist/_chunks/index-CxLSGwnk.js.map +1 -0
  72. package/dist/_chunks/{index-Dahjdw4h.mjs → index-EH8ZtHd5.mjs} +1524 -980
  73. package/dist/_chunks/index-EH8ZtHd5.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-omucV6TV.mjs → layout-CxDMdJ13.mjs} +28 -15
  79. package/dist/_chunks/layout-CxDMdJ13.mjs.map +1 -0
  80. package/dist/_chunks/{layout-jcY4dyUG.js → layout-DSeUTfMv.js} +27 -15
  81. package/dist/_chunks/layout-DSeUTfMv.js.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-CN0-aw6p.mjs → relations-B8_Uu38Q.mjs} +21 -8
  87. package/dist/_chunks/relations-B8_Uu38Q.mjs.map +1 -0
  88. package/dist/_chunks/{relations-DGzD7ORa.js → relations-S5nNKdN3.js} +20 -7
  89. package/dist/_chunks/relations-S5nNKdN3.js.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-B9w_-eYc.js.map +1 -1
  95. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -1
  96. package/dist/admin/index.js +3 -1
  97. package/dist/admin/index.js.map +1 -1
  98. package/dist/admin/index.mjs +6 -4
  99. package/dist/admin/src/content-manager.d.ts +3 -2
  100. package/dist/admin/src/exports.d.ts +2 -1
  101. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  102. package/dist/admin/src/history/index.d.ts +3 -0
  103. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  104. package/dist/admin/src/hooks/useDocument.d.ts +49 -1
  105. package/dist/admin/src/index.d.ts +1 -0
  106. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  107. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +9 -4
  108. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
  109. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  110. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  111. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
  112. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
  113. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
  114. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  115. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  116. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  117. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +6 -58
  118. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
  119. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  120. package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
  121. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  122. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  123. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  124. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  125. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  126. package/dist/admin/src/preview/index.d.ts +4 -0
  127. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  128. package/dist/admin/src/preview/routes.d.ts +3 -0
  129. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  130. package/dist/admin/src/router.d.ts +1 -1
  131. package/dist/admin/src/services/api.d.ts +1 -1
  132. package/dist/admin/src/services/components.d.ts +2 -2
  133. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  134. package/dist/admin/src/services/documents.d.ts +19 -20
  135. package/dist/admin/src/services/init.d.ts +1 -1
  136. package/dist/admin/src/services/relations.d.ts +2 -2
  137. package/dist/admin/src/services/uid.d.ts +3 -3
  138. package/dist/admin/src/utils/validation.d.ts +4 -1
  139. package/dist/server/index.js +765 -434
  140. package/dist/server/index.js.map +1 -1
  141. package/dist/server/index.mjs +766 -434
  142. package/dist/server/index.mjs.map +1 -1
  143. package/dist/server/src/bootstrap.d.ts.map +1 -1
  144. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  145. package/dist/server/src/controllers/index.d.ts.map +1 -1
  146. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  147. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  148. package/dist/server/src/controllers/utils/metadata.d.ts +16 -1
  149. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  150. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  151. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  152. package/dist/server/src/history/controllers/history-version.d.ts +1 -1
  153. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  154. package/dist/server/src/history/services/history.d.ts +3 -3
  155. package/dist/server/src/history/services/history.d.ts.map +1 -1
  156. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  157. package/dist/server/src/history/services/utils.d.ts +8 -12
  158. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  159. package/dist/server/src/index.d.ts +7 -6
  160. package/dist/server/src/index.d.ts.map +1 -1
  161. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  162. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  163. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  164. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  165. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  166. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  167. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  168. package/dist/server/src/preview/index.d.ts +4 -0
  169. package/dist/server/src/preview/index.d.ts.map +1 -0
  170. package/dist/server/src/preview/routes/index.d.ts +8 -0
  171. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  172. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  173. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  174. package/dist/server/src/preview/services/index.d.ts +16 -0
  175. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  176. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  177. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  178. package/dist/server/src/preview/services/preview.d.ts +12 -0
  179. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  180. package/dist/server/src/preview/utils.d.ts +19 -0
  181. package/dist/server/src/preview/utils.d.ts.map +1 -0
  182. package/dist/server/src/register.d.ts.map +1 -1
  183. package/dist/server/src/routes/index.d.ts.map +1 -1
  184. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  185. package/dist/server/src/services/document-metadata.d.ts +12 -10
  186. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  187. package/dist/server/src/services/index.d.ts +7 -6
  188. package/dist/server/src/services/index.d.ts.map +1 -1
  189. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  190. package/dist/server/src/services/utils/populate.d.ts +2 -2
  191. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  192. package/dist/server/src/utils/index.d.ts +2 -0
  193. package/dist/server/src/utils/index.d.ts.map +1 -1
  194. package/dist/shared/contracts/collection-types.d.ts +3 -1
  195. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  196. package/dist/shared/contracts/index.d.ts +1 -0
  197. package/dist/shared/contracts/index.d.ts.map +1 -1
  198. package/dist/shared/contracts/preview.d.ts +27 -0
  199. package/dist/shared/contracts/preview.d.ts.map +1 -0
  200. package/dist/shared/index.js +4 -0
  201. package/dist/shared/index.js.map +1 -1
  202. package/dist/shared/index.mjs +4 -0
  203. package/dist/shared/index.mjs.map +1 -1
  204. package/package.json +17 -16
  205. package/dist/_chunks/EditViewPage-CU7724gt.js.map +0 -1
  206. package/dist/_chunks/EditViewPage-CzuJgWWp.mjs +0 -203
  207. package/dist/_chunks/EditViewPage-CzuJgWWp.mjs.map +0 -1
  208. package/dist/_chunks/Field-Dh1yZyqy.js.map +0 -1
  209. package/dist/_chunks/Field-QtUSh5mU.mjs.map +0 -1
  210. package/dist/_chunks/Form-BOR8NOe1.js.map +0 -1
  211. package/dist/_chunks/Form-COLpvlnv.mjs.map +0 -1
  212. package/dist/_chunks/History-Bu53Yfw-.mjs.map +0 -1
  213. package/dist/_chunks/History-CW2akQ6h.js.map +0 -1
  214. package/dist/_chunks/ListConfigurationPage-TqrmwjPN.mjs.map +0 -1
  215. package/dist/_chunks/ListConfigurationPage-jzdhEk_u.js.map +0 -1
  216. package/dist/_chunks/ListViewPage-B3bMOrMv.js.map +0 -1
  217. package/dist/_chunks/ListViewPage-BO_mOXIl.mjs.map +0 -1
  218. package/dist/_chunks/Relations-B6fb2POW.js.map +0 -1
  219. package/dist/_chunks/Relations-CJ4qdkRo.mjs.map +0 -1
  220. package/dist/_chunks/index-Dahjdw4h.mjs.map +0 -1
  221. package/dist/_chunks/index-DcUu-_72.js.map +0 -1
  222. package/dist/_chunks/layout-jcY4dyUG.js.map +0 -1
  223. package/dist/_chunks/layout-omucV6TV.mjs.map +0 -1
  224. package/dist/_chunks/relations-CN0-aw6p.mjs.map +0 -1
  225. package/dist/_chunks/relations-DGzD7ORa.js.map +0 -1
  226. package/strapi-server.js +0 -3
@@ -3,23 +3,74 @@ 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-DcUu-_72.js");
9
- const fractionalIndexing = require("fractional-indexing");
10
- const Relations = require("./Relations-B6fb2POW.js");
11
6
  const Icons = require("@strapi/icons");
7
+ const reactIntl = require("react-intl");
8
+ const index = require("./index-CxLSGwnk.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");
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");
20
64
  const usePrev = require("./usePrev-B9w_-eYc.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-DcoOBejP.js");
71
+ const pipe$1 = require("lodash/fp/pipe");
72
+ const ComponentIcon = require("./ComponentIcon-CRbtQEUV.js");
73
+ const relations = require("./relations-S5nNKdN3.js");
23
74
  const CodeMirror = require("codemirror5");
24
75
  const sanitizeHtml = require("sanitize-html");
25
76
  const highlight_js = require("highlight.js");
@@ -37,8 +88,7 @@ require("highlight.js/styles/solarized-dark.css");
37
88
  require("codemirror5/addon/display/placeholder");
38
89
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
39
90
  function _interopNamespace(e) {
40
- if (e && e.__esModule)
41
- return e;
91
+ if (e && e.__esModule) return e;
42
92
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
43
93
  if (e) {
44
94
  for (const k in e) {
@@ -55,8 +105,9 @@ function _interopNamespace(e) {
55
105
  return Object.freeze(n);
56
106
  }
57
107
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
58
- const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
108
+ const Prism__namespace = /* @__PURE__ */ _interopNamespace(Prism);
59
109
  const Toolbar__namespace = /* @__PURE__ */ _interopNamespace(Toolbar);
110
+ const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
60
111
  const CodeMirror__default = /* @__PURE__ */ _interopDefault(CodeMirror);
61
112
  const sanitizeHtml__default = /* @__PURE__ */ _interopDefault(sanitizeHtml);
62
113
  const Markdown__default = /* @__PURE__ */ _interopDefault(Markdown);
@@ -69,93 +120,6 @@ const ins__default = /* @__PURE__ */ _interopDefault(ins);
69
120
  const mark__default = /* @__PURE__ */ _interopDefault(mark);
70
121
  const sub__default = /* @__PURE__ */ _interopDefault(sub);
71
122
  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
123
  const componentStore = /* @__PURE__ */ new Map();
160
124
  const useLazyComponents = (componentUids = []) => {
161
125
  const [lazyComponentStore, setLazyComponentStore] = React.useState(Object.fromEntries(componentStore));
@@ -194,6 +158,224 @@ const useLazyComponents = (componentUids = []) => {
194
158
  }, []);
195
159
  return { isLazyLoading: loading, lazyComponentStore, cleanup };
196
160
  };
161
+ const codeLanguages = [
162
+ {
163
+ value: "asm",
164
+ label: "Assembly",
165
+ decorate: "asmatmel"
166
+ },
167
+ {
168
+ value: "bash",
169
+ label: "Bash"
170
+ },
171
+ {
172
+ value: "c",
173
+ label: "C"
174
+ },
175
+ {
176
+ value: "clojure",
177
+ label: "Clojure"
178
+ },
179
+ {
180
+ value: "cobol",
181
+ label: "COBOL"
182
+ },
183
+ {
184
+ value: "cpp",
185
+ label: "C++"
186
+ },
187
+ {
188
+ value: "csharp",
189
+ label: "C#"
190
+ },
191
+ {
192
+ value: "css",
193
+ label: "CSS"
194
+ },
195
+ {
196
+ value: "dart",
197
+ label: "Dart"
198
+ },
199
+ {
200
+ value: "dockerfile",
201
+ label: "Dockerfile",
202
+ decorate: "docker"
203
+ },
204
+ {
205
+ value: "elixir",
206
+ label: "Elixir"
207
+ },
208
+ {
209
+ value: "erlang",
210
+ label: "Erlang"
211
+ },
212
+ {
213
+ value: "fortran",
214
+ label: "Fortran"
215
+ },
216
+ {
217
+ value: "fsharp",
218
+ label: "F#"
219
+ },
220
+ {
221
+ value: "go",
222
+ label: "Go"
223
+ },
224
+ {
225
+ value: "graphql",
226
+ label: "GraphQL"
227
+ },
228
+ {
229
+ value: "groovy",
230
+ label: "Groovy"
231
+ },
232
+ {
233
+ value: "haskell",
234
+ label: "Haskell"
235
+ },
236
+ {
237
+ value: "haxe",
238
+ label: "Haxe"
239
+ },
240
+ {
241
+ value: "html",
242
+ label: "HTML"
243
+ },
244
+ {
245
+ value: "ini",
246
+ label: "INI"
247
+ },
248
+ {
249
+ value: "java",
250
+ label: "Java"
251
+ },
252
+ {
253
+ value: "javascript",
254
+ label: "JavaScript"
255
+ },
256
+ {
257
+ value: "jsx",
258
+ label: "JavaScript (React)"
259
+ },
260
+ {
261
+ value: "json",
262
+ label: "JSON"
263
+ },
264
+ {
265
+ value: "julia",
266
+ label: "Julia"
267
+ },
268
+ {
269
+ value: "kotlin",
270
+ label: "Kotlin"
271
+ },
272
+ {
273
+ value: "latex",
274
+ label: "LaTeX"
275
+ },
276
+ {
277
+ value: "lua",
278
+ label: "Lua"
279
+ },
280
+ {
281
+ value: "markdown",
282
+ label: "Markdown"
283
+ },
284
+ {
285
+ value: "matlab",
286
+ label: "MATLAB"
287
+ },
288
+ {
289
+ value: "makefile",
290
+ label: "Makefile"
291
+ },
292
+ {
293
+ value: "objectivec",
294
+ label: "Objective-C"
295
+ },
296
+ {
297
+ value: "perl",
298
+ label: "Perl"
299
+ },
300
+ {
301
+ value: "php",
302
+ label: "PHP"
303
+ },
304
+ {
305
+ value: "plaintext",
306
+ label: "Plain text"
307
+ },
308
+ {
309
+ value: "powershell",
310
+ label: "PowerShell"
311
+ },
312
+ {
313
+ value: "python",
314
+ label: "Python"
315
+ },
316
+ {
317
+ value: "r",
318
+ label: "R"
319
+ },
320
+ {
321
+ value: "ruby",
322
+ label: "Ruby"
323
+ },
324
+ {
325
+ value: "rust",
326
+ label: "Rust"
327
+ },
328
+ {
329
+ value: "sas",
330
+ label: "SAS"
331
+ },
332
+ {
333
+ value: "scala",
334
+ label: "Scala"
335
+ },
336
+ {
337
+ value: "scheme",
338
+ label: "Scheme"
339
+ },
340
+ {
341
+ value: "shell",
342
+ label: "Shell"
343
+ },
344
+ {
345
+ value: "sql",
346
+ label: "SQL"
347
+ },
348
+ {
349
+ value: "stata",
350
+ label: "Stata"
351
+ },
352
+ {
353
+ value: "swift",
354
+ label: "Swift"
355
+ },
356
+ {
357
+ value: "typescript",
358
+ label: "TypeScript",
359
+ decorate: "ts"
360
+ },
361
+ {
362
+ value: "tsx",
363
+ label: "TypeScript (React)"
364
+ },
365
+ {
366
+ value: "vbnet",
367
+ label: "VB.NET"
368
+ },
369
+ {
370
+ value: "xml",
371
+ label: "XML"
372
+ },
373
+ {
374
+ value: "yaml",
375
+ label: "YAML",
376
+ decorate: "yml"
377
+ }
378
+ ];
197
379
  const baseHandleConvert = (editor, attributesToSet) => {
198
380
  const [_, lastNodePath] = slate.Editor.last(editor, []);
199
381
  slate.Transforms.unwrapNodes(editor, {
@@ -257,6 +439,29 @@ const pressEnterTwiceToExit = (editor) => {
257
439
  });
258
440
  }
259
441
  };
442
+ const decorateCode = ([node, path]) => {
443
+ const ranges = [];
444
+ if (!slate.Element.isElement(node) || node.type !== "code") return ranges;
445
+ const text = slate.Node.string(node);
446
+ const language = codeLanguages.find((lang) => lang.value === node.language);
447
+ const decorateKey = language?.decorate ?? language?.value;
448
+ const selectedLanguage = Prism__namespace.languages[decorateKey || "plaintext"];
449
+ const tokens = Prism__namespace.tokenize(text, selectedLanguage);
450
+ let start = 0;
451
+ for (const token of tokens) {
452
+ const length = token.length;
453
+ const end = start + length;
454
+ if (typeof token !== "string") {
455
+ ranges.push({
456
+ anchor: { path, offset: start },
457
+ focus: { path, offset: end },
458
+ className: `token ${token.type}`
459
+ });
460
+ }
461
+ start = end;
462
+ }
463
+ return ranges;
464
+ };
260
465
  const CodeBlock = styledComponents.styled.pre`
261
466
  border-radius: ${({ theme }) => theme.borderRadius};
262
467
  background-color: ${({ theme }) => theme.colors.neutral100};
@@ -264,6 +469,7 @@ const CodeBlock = styledComponents.styled.pre`
264
469
  overflow: auto;
265
470
  padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};
266
471
  flex-shrink: 1;
472
+
267
473
  & > code {
268
474
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,
269
475
  monospace;
@@ -272,10 +478,62 @@ const CodeBlock = styledComponents.styled.pre`
272
478
  max-width: 100%;
273
479
  }
274
480
  `;
481
+ const CodeEditor = (props) => {
482
+ const { editor } = useBlocksEditorContext("ImageDialog");
483
+ const editorIsFocused = slateReact.useFocused();
484
+ const imageIsSelected = slateReact.useSelected();
485
+ const { formatMessage } = reactIntl.useIntl();
486
+ const [isSelectOpen, setIsSelectOpen] = React__namespace.useState(false);
487
+ const shouldDisplayLanguageSelect = editorIsFocused && imageIsSelected || isSelectOpen;
488
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { position: "relative", width: "100%", children: [
489
+ /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: props.children }) }),
490
+ shouldDisplayLanguageSelect && /* @__PURE__ */ jsxRuntime.jsx(
491
+ designSystem.Box,
492
+ {
493
+ position: "absolute",
494
+ background: "neutral0",
495
+ borderColor: "neutral150",
496
+ borderStyle: "solid",
497
+ borderWidth: "0.5px",
498
+ shadow: "tableShadow",
499
+ top: "100%",
500
+ marginTop: 1,
501
+ right: 0,
502
+ padding: 1,
503
+ hasRadius: true,
504
+ children: /* @__PURE__ */ jsxRuntime.jsx(
505
+ designSystem.SingleSelect,
506
+ {
507
+ onChange: (open) => {
508
+ slate.Transforms.setNodes(
509
+ editor,
510
+ { language: open.toString() },
511
+ { match: (node) => !slate.Editor.isEditor(node) && node.type === "code" }
512
+ );
513
+ },
514
+ value: props.element.type === "code" && props.element.language || "plaintext",
515
+ onOpenChange: (open) => {
516
+ setIsSelectOpen(open);
517
+ if (!open) {
518
+ slateReact.ReactEditor.focus(editor);
519
+ }
520
+ },
521
+ onCloseAutoFocus: (e) => e.preventDefault(),
522
+ "aria-label": formatMessage({
523
+ id: "components.Blocks.blocks.code.languageLabel",
524
+ defaultMessage: "Select a language"
525
+ }),
526
+ children: codeLanguages.map(({ value, label }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value, children: label }, value))
527
+ }
528
+ )
529
+ }
530
+ )
531
+ ] });
532
+ };
275
533
  const codeBlocks = {
276
534
  code: {
277
- renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: props.children }) }),
278
- icon: Icons.Code,
535
+ renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(CodeEditor, { ...props }),
536
+ icon: Icons.CodeBlock,
279
537
  label: {
280
538
  id: "components.Blocks.blocks.code",
281
539
  defaultMessage: "Code block"
@@ -283,13 +541,12 @@ const codeBlocks = {
283
541
  matchNode: (node) => node.type === "code",
284
542
  isInBlocksSelector: true,
285
543
  handleConvert(editor) {
286
- baseHandleConvert(editor, { type: "code" });
544
+ baseHandleConvert(editor, { type: "code", language: "plaintext" });
287
545
  },
288
546
  handleEnterKey(editor) {
289
547
  pressEnterTwiceToExit(editor);
290
548
  },
291
- snippets: ["```"],
292
- dragHandleTopMargin: "10px"
549
+ snippets: ["```"]
293
550
  }
294
551
  };
295
552
  const H1 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h1" })`
@@ -464,8 +721,7 @@ const ImageDialog = () => {
464
721
  const [isOpen, setIsOpen] = React__namespace.useState(true);
465
722
  const { editor } = useBlocksEditorContext("ImageDialog");
466
723
  const components = strapiAdmin.useStrapiApp("ImageDialog", (state) => state.components);
467
- if (!components || !isOpen)
468
- return null;
724
+ if (!components || !isOpen) return null;
469
725
  const MediaLibraryDialog = components["media-library"];
470
726
  const insertImages = (images) => {
471
727
  slate.Transforms.unwrapNodes(editor, {
@@ -474,14 +730,12 @@ const ImageDialog = () => {
474
730
  });
475
731
  const nodeEntryBeingReplaced = slate.Editor.above(editor, {
476
732
  match(node) {
477
- if (slate.Editor.isEditor(node))
478
- return false;
733
+ if (slate.Editor.isEditor(node)) return false;
479
734
  const isInlineNode = ["text", "link"].includes(node.type);
480
735
  return !isInlineNode;
481
736
  }
482
737
  });
483
- if (!nodeEntryBeingReplaced)
484
- return;
738
+ if (!nodeEntryBeingReplaced) return;
485
739
  const [, pathToInsert] = nodeEntryBeingReplaced;
486
740
  slate.Transforms.removeNodes(editor);
487
741
  const nodesToInsert = images.map((image) => {
@@ -623,18 +877,12 @@ const LinkContent = React__namespace.forwardRef(
623
877
  const [popoverOpen, setPopoverOpen] = React__namespace.useState(
624
878
  editor.lastInsertedLinkPath ? slate.Path.equals(path, editor.lastInsertedLinkPath) : false
625
879
  );
626
- const linkRef = React__namespace.useRef(null);
627
880
  const elementText = link.children.map((child) => child.text).join("");
628
881
  const [linkText, setLinkText] = React__namespace.useState(elementText);
629
882
  const [linkUrl, setLinkUrl] = React__namespace.useState(link.url);
630
883
  const linkInputRef = React__namespace.useRef(null);
631
- const [showRemoveButton, setShowRemoveButton] = React__namespace.useState(false);
884
+ const isLastInsertedLink = editor.lastInsertedLinkPath ? !slate.Path.equals(path, editor.lastInsertedLinkPath) : true;
632
885
  const [isSaveDisabled, setIsSaveDisabled] = React__namespace.useState(false);
633
- const handleOpenEditPopover = (e) => {
634
- e.preventDefault();
635
- setPopoverOpen(true);
636
- setShowRemoveButton(true);
637
- };
638
886
  const onLinkChange = (e) => {
639
887
  setIsSaveDisabled(false);
640
888
  setLinkUrl(e.target.value);
@@ -655,33 +903,32 @@ const LinkContent = React__namespace.forwardRef(
655
903
  editLink(editor, { url: linkUrl, text: linkText });
656
904
  setPopoverOpen(false);
657
905
  editor.lastInsertedLinkPath = null;
906
+ slateReact.ReactEditor.focus(editor);
658
907
  };
659
- const handleDismiss = () => {
660
- setPopoverOpen(false);
908
+ const handleClose = () => {
661
909
  if (link.url === "") {
662
910
  removeLink(editor);
663
911
  }
912
+ setPopoverOpen(false);
664
913
  slateReact.ReactEditor.focus(editor);
665
914
  };
666
- const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
667
- const composedRefs = designSystem.useComposedRefs(linkRef, forwardedRef);
668
915
  React__namespace.useEffect(() => {
669
- if (popoverOpen)
670
- linkInputRef.current?.focus();
916
+ if (popoverOpen) linkInputRef.current?.focus();
671
917
  }, [popoverOpen]);
672
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
673
- /* @__PURE__ */ jsxRuntime.jsx(
918
+ const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
919
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { open: popoverOpen, children: [
920
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
674
921
  StyledBaseLink,
675
922
  {
676
923
  ...attributes,
677
- ref: composedRefs,
924
+ ref: forwardedRef,
678
925
  href: link.url,
679
- onClick: handleOpenEditPopover,
926
+ onClick: () => setPopoverOpen(true),
680
927
  color: "primary600",
681
928
  children
682
929
  }
683
- ),
684
- popoverOpen && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover, { source: linkRef, onDismiss: handleDismiss, padding: 4, contentEditable: false, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "form", onSubmit: handleSave, direction: "column", gap: 4, children: [
930
+ ) }),
931
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { onPointerDownOutside: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 4, direction: "column", gap: 4, children: [
685
932
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { width: "368px", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
686
933
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
687
934
  id: "components.Blocks.popover.text",
@@ -727,7 +974,7 @@ const LinkContent = React__namespace.forwardRef(
727
974
  {
728
975
  variant: "danger-light",
729
976
  onClick: () => removeLink(editor),
730
- $visible: showRemoveButton,
977
+ $visible: isLastInsertedLink,
731
978
  children: formatMessage({
732
979
  id: "components.Blocks.popover.remove",
733
980
  defaultMessage: "Remove"
@@ -735,12 +982,12 @@ const LinkContent = React__namespace.forwardRef(
735
982
  }
736
983
  ),
737
984
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
738
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: handleDismiss, children: formatMessage({
739
- id: "components.Blocks.popover.cancel",
985
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
986
+ id: "global.cancel",
740
987
  defaultMessage: "Cancel"
741
988
  }) }),
742
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { type: "submit", disabled: Boolean(inputNotDirty) || isSaveDisabled, children: formatMessage({
743
- id: "components.Blocks.popover.save",
989
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
990
+ id: "global.save",
744
991
  defaultMessage: "Save"
745
992
  }) })
746
993
  ] })
@@ -821,8 +1068,7 @@ const isText$1 = (node) => {
821
1068
  return slate.Node.isNode(node) && !slate.Editor.isEditor(node) && node.type === "text";
822
1069
  };
823
1070
  const handleBackspaceKeyOnList = (editor, event) => {
824
- if (!editor.selection)
825
- return;
1071
+ if (!editor.selection) return;
826
1072
  const [currentListItem, currentListItemPath] = slate.Editor.parent(editor, editor.selection.anchor);
827
1073
  const [currentList, currentListPath] = slate.Editor.parent(editor, currentListItemPath);
828
1074
  const isListEmpty = currentList.children.length === 1 && isText$1(currentListItem.children[0]) && currentListItem.children[0].text === "";
@@ -931,8 +1177,7 @@ const handleEnterKeyOnList = (editor) => {
931
1177
  };
932
1178
  const handleConvertToList = (editor, format) => {
933
1179
  const convertedPath = baseHandleConvert(editor, { type: "list-item" });
934
- if (!convertedPath)
935
- return;
1180
+ if (!convertedPath) return;
936
1181
  slate.Transforms.wrapNodes(editor, { type: "list", format, children: [] }, { at: convertedPath });
937
1182
  };
938
1183
  const handleTabOnList = (editor) => {
@@ -944,8 +1189,7 @@ const handleTabOnList = (editor) => {
944
1189
  }
945
1190
  const [currentListItem, currentListItemPath] = currentListItemEntry;
946
1191
  const [currentList] = slate.Editor.parent(editor, currentListItemPath);
947
- if (currentListItem === currentList.children[0])
948
- return;
1192
+ if (currentListItem === currentList.children[0]) return;
949
1193
  const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);
950
1194
  const previousNode = currentList.children[currentListItemIndex - 1];
951
1195
  if (previousNode.type === "list") {
@@ -1081,13 +1325,13 @@ const quoteBlocks = {
1081
1325
  handleEnterKey(editor) {
1082
1326
  pressEnterTwiceToExit(editor);
1083
1327
  },
1084
- snippets: [">"],
1085
- dragHandleTopMargin: "6px"
1328
+ snippets: [">"]
1086
1329
  }
1087
1330
  };
1088
1331
  const ToolbarWrapper = styledComponents.styled(designSystem.Flex)`
1089
1332
  &[aria-disabled='true'] {
1090
1333
  cursor: not-allowed;
1334
+ background: ${({ theme }) => theme.colors.neutral150};
1091
1335
  }
1092
1336
  `;
1093
1337
  const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
@@ -1098,7 +1342,7 @@ const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
1098
1342
  const FlexButton = styledComponents.styled(designSystem.Flex)`
1099
1343
  // Inherit the not-allowed cursor from ToolbarWrapper when disabled
1100
1344
  &[aria-disabled] {
1101
- cursor: inherit;
1345
+ cursor: not-allowed;
1102
1346
  }
1103
1347
 
1104
1348
  &[aria-disabled='false'] {
@@ -1180,7 +1424,7 @@ const ToolbarButton = ({
1180
1424
  width: 7,
1181
1425
  height: 7,
1182
1426
  hasRadius: true,
1183
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { width: "1.2rem", height: "1.2rem", fill: disabled ? "neutral300" : enabledColor })
1427
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { fill: disabled ? "neutral300" : enabledColor })
1184
1428
  }
1185
1429
  )
1186
1430
  }
@@ -1312,8 +1556,7 @@ const isListNode = (node) => {
1312
1556
  const ListButton = ({ block, format }) => {
1313
1557
  const { editor, disabled, blocks } = useBlocksEditorContext("ListButton");
1314
1558
  const isListActive = () => {
1315
- if (!editor.selection)
1316
- return false;
1559
+ if (!editor.selection) return false;
1317
1560
  const currentListEntry = slate.Editor.above(editor, {
1318
1561
  match: (node) => !slate.Editor.isEditor(node) && node.type === "list",
1319
1562
  at: editor.selection.anchor
@@ -1325,6 +1568,26 @@ const ListButton = ({ block, format }) => {
1325
1568
  }
1326
1569
  return false;
1327
1570
  };
1571
+ const isListDisabled = () => {
1572
+ if (disabled) {
1573
+ return true;
1574
+ }
1575
+ if (!editor.selection) {
1576
+ return false;
1577
+ }
1578
+ const anchorNodeEntry = slate.Editor.above(editor, {
1579
+ at: editor.selection.anchor,
1580
+ match: (node) => !slate.Editor.isEditor(node) && node.type !== "text"
1581
+ });
1582
+ const focusNodeEntry = slate.Editor.above(editor, {
1583
+ at: editor.selection.focus,
1584
+ match: (node) => !slate.Editor.isEditor(node) && node.type !== "text"
1585
+ });
1586
+ if (!anchorNodeEntry || !focusNodeEntry) {
1587
+ return false;
1588
+ }
1589
+ return anchorNodeEntry[0] !== focusNodeEntry[0];
1590
+ };
1328
1591
  const toggleList = (format2) => {
1329
1592
  let currentListEntry;
1330
1593
  if (editor.selection) {
@@ -1358,7 +1621,7 @@ const ListButton = ({ block, format }) => {
1358
1621
  name: format,
1359
1622
  label: block.label,
1360
1623
  isActive: isListActive(),
1361
- disabled,
1624
+ disabled: isListDisabled(),
1362
1625
  handleClick: () => toggleList(format)
1363
1626
  }
1364
1627
  );
@@ -1367,8 +1630,7 @@ const LinkButton = ({ disabled }) => {
1367
1630
  const { editor } = useBlocksEditorContext("LinkButton");
1368
1631
  const isLinkActive = () => {
1369
1632
  const { selection } = editor;
1370
- if (!selection)
1371
- return false;
1633
+ if (!selection) return false;
1372
1634
  const [match] = Array.from(
1373
1635
  slate.Editor.nodes(editor, {
1374
1636
  at: slate.Editor.unhangRange(editor, selection),
@@ -1432,7 +1694,7 @@ const BlocksToolbar = () => {
1432
1694
  return false;
1433
1695
  };
1434
1696
  const isButtonDisabled = checkButtonDisabled();
1435
- return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, children: [
1697
+ return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, width: "100%", children: [
1436
1698
  /* @__PURE__ */ jsxRuntime.jsx(BlocksDropdown, {}),
1437
1699
  /* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
1438
1700
  /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.ToggleGroup, { type: "multiple", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, children: [
@@ -1502,33 +1764,36 @@ const DragItem = styledComponents.styled(designSystem.Flex)`
1502
1764
  }
1503
1765
  `;
1504
1766
  const DragIconButton = styledComponents.styled(designSystem.IconButton)`
1767
+ user-select: none;
1505
1768
  display: flex;
1506
1769
  align-items: center;
1507
1770
  justify-content: center;
1771
+ border: none;
1508
1772
  border-radius: ${({ theme }) => theme.borderRadius};
1509
- width: ${({ theme }) => theme.spaces[4]};
1510
- height: ${({ theme }) => theme.spaces[6]};
1773
+ padding-left: ${({ theme }) => theme.spaces[0]};
1774
+ padding-right: ${({ theme }) => theme.spaces[0]};
1775
+ padding-top: ${({ theme }) => theme.spaces[1]};
1776
+ padding-bottom: ${({ theme }) => theme.spaces[1]};
1511
1777
  visibility: hidden;
1512
1778
  cursor: grab;
1513
1779
  opacity: inherit;
1514
1780
  margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
1515
1781
 
1516
1782
  &:hover {
1517
- background: ${({ theme }) => theme.colors.neutral200};
1783
+ background: ${({ theme }) => theme.colors.neutral100};
1518
1784
  }
1519
1785
  &:active {
1520
1786
  cursor: grabbing;
1787
+ background: ${({ theme }) => theme.colors.neutral150};
1521
1788
  }
1522
1789
  &[aria-disabled='true'] {
1523
- cursor: not-allowed;
1524
- background: transparent;
1790
+ visibility: hidden;
1525
1791
  }
1526
1792
  svg {
1527
- height: auto;
1528
- width: ${({ theme }) => theme.spaces[3]};
1793
+ min-width: ${({ theme }) => theme.spaces[3]};
1529
1794
 
1530
1795
  path {
1531
- fill: ${({ theme }) => theme.colors.neutral700};
1796
+ fill: ${({ theme }) => theme.colors.neutral500};
1532
1797
  }
1533
1798
  }
1534
1799
  `;
@@ -1573,8 +1838,7 @@ const DragAndDropElement = ({
1573
1838
  displayedValue: children
1574
1839
  },
1575
1840
  onDropItem(currentIndex, newIndex) {
1576
- if (newIndex)
1577
- handleMoveBlock(newIndex, currentIndex);
1841
+ if (newIndex) handleMoveBlock(newIndex, currentIndex);
1578
1842
  }
1579
1843
  });
1580
1844
  const composedBoxRefs = designSystem.useComposedRefs(blockRef, dropRef);
@@ -1630,6 +1894,7 @@ const DragAndDropElement = ({
1630
1894
  DragIconButton,
1631
1895
  {
1632
1896
  tag: "div",
1897
+ contentEditable: false,
1633
1898
  role: "button",
1634
1899
  tabIndex: 0,
1635
1900
  withTooltip: false,
@@ -1642,7 +1907,7 @@ const DragAndDropElement = ({
1642
1907
  disabled,
1643
1908
  draggable: true,
1644
1909
  $dragHandleTopMargin: dragHandleTopMargin,
1645
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, { color: "neutral600" })
1910
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, { color: "primary500" })
1646
1911
  }
1647
1912
  ),
1648
1913
  children
@@ -1679,7 +1944,7 @@ const baseRenderLeaf = (props, modifiers2) => {
1679
1944
  }
1680
1945
  return currentChildren;
1681
1946
  }, props.children);
1682
- return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, children: wrappedChildren });
1947
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, className: props.leaf.className, children: wrappedChildren });
1683
1948
  };
1684
1949
  const baseRenderElement = ({
1685
1950
  props,
@@ -1717,8 +1982,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1717
1982
  [modifiers2]
1718
1983
  );
1719
1984
  const handleMoveBlocks = (editor2, event) => {
1720
- if (!editor2.selection)
1721
- return;
1985
+ if (!editor2.selection) return;
1722
1986
  const start = slate.Range.start(editor2.selection);
1723
1987
  const currentIndex = [start.path[0]];
1724
1988
  let newIndexPosition = 0;
@@ -1855,8 +2119,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1855
2119
  }
1856
2120
  };
1857
2121
  const handleScrollSelectionIntoView = () => {
1858
- if (!editor.selection)
1859
- return;
2122
+ if (!editor.selection) return;
1860
2123
  const domRange = slateReact.ReactEditor.toDOMRange(editor, editor.selection);
1861
2124
  const domRect = domRange.getBoundingClientRect();
1862
2125
  const blocksInput = blocksRef.current;
@@ -1883,7 +2146,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1883
2146
  background: "neutral0",
1884
2147
  color: "neutral800",
1885
2148
  lineHeight: 6,
1886
- paddingRight: 4,
2149
+ paddingRight: 7,
1887
2150
  paddingTop: 6,
1888
2151
  paddingBottom: 3,
1889
2152
  children: [
@@ -1894,6 +2157,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1894
2157
  readOnly: disabled,
1895
2158
  placeholder,
1896
2159
  isExpandedMode,
2160
+ decorate: decorateCode,
1897
2161
  renderElement,
1898
2162
  renderLeaf,
1899
2163
  onKeyDown: handleKeyDown,
@@ -1966,7 +2230,7 @@ const EditorLayout$1 = ({
1966
2230
  /* @__PURE__ */ jsxRuntime.jsx(
1967
2231
  CollapseIconButton,
1968
2232
  {
1969
- "aria-label": formatMessage({
2233
+ label: formatMessage({
1970
2234
  id: index.getTranslation("components.Blocks.collapse"),
1971
2235
  defaultMessage: "Collapse"
1972
2236
  }),
@@ -2050,8 +2314,7 @@ const InlineCode = styledComponents.styled.code`
2050
2314
  `;
2051
2315
  const baseCheckIsActive = (editor, name2) => {
2052
2316
  const marks = slate.Editor.marks(editor);
2053
- if (!marks)
2054
- return false;
2317
+ if (!marks) return false;
2055
2318
  return Boolean(marks[name2]);
2056
2319
  };
2057
2320
  const baseHandleToggle = (editor, name2) => {
@@ -2217,6 +2480,7 @@ const ExpandIconButton = styledComponents.styled(designSystem.IconButton)`
2217
2480
  position: absolute;
2218
2481
  bottom: 1.2rem;
2219
2482
  right: 1.2rem;
2483
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2220
2484
  `;
2221
2485
  function useResetKey(value) {
2222
2486
  const slateUpdatesCount = React__namespace.useRef(0);
@@ -2305,7 +2569,7 @@ const BlocksEditor = React__namespace.forwardRef(
2305
2569
  !isExpandedMode && /* @__PURE__ */ jsxRuntime.jsx(
2306
2570
  ExpandIconButton,
2307
2571
  {
2308
- "aria-label": formatMessage({
2572
+ label: formatMessage({
2309
2573
  id: index.getTranslation("components.Blocks.expand"),
2310
2574
  defaultMessage: "Expand"
2311
2575
  }),
@@ -2348,172 +2612,507 @@ const BlocksInput = React__namespace.forwardRef(
2348
2612
  }
2349
2613
  );
2350
2614
  const MemoizedBlocksInput = React__namespace.memo(BlocksInput);
2351
- const createDefaultForm = (contentType, components = {}) => {
2352
- const traverseSchema = (attributes) => {
2353
- return Object.entries(attributes).reduce((acc, [key, attribute]) => {
2354
- if ("default" in attribute) {
2355
- acc[key] = attribute.default;
2356
- } else if (attribute.type === "component" && attribute.required) {
2357
- const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
2358
- if (attribute.repeatable) {
2359
- acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
2360
- } else {
2361
- acc[key] = defaultComponentForm;
2362
- }
2363
- } else if (attribute.type === "dynamiczone" && attribute.required) {
2364
- acc[key] = [];
2365
- }
2366
- return acc;
2367
- }, {});
2368
- };
2369
- return traverseSchema(contentType.attributes);
2370
- };
2371
2615
  const Initializer = ({ disabled, name: name2, onClick }) => {
2372
2616
  const { formatMessage } = reactIntl.useIntl();
2373
2617
  const field = strapiAdmin.useField(name2);
2374
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2375
- /* @__PURE__ */ jsxRuntime.jsx(
2376
- designSystem.Box,
2377
- {
2378
- tag: "button",
2379
- background: "neutral100",
2380
- borderColor: field.error ? "danger600" : "neutral200",
2381
- hasRadius: true,
2382
- disabled,
2383
- onClick,
2384
- paddingTop: 9,
2385
- paddingBottom: 9,
2386
- type: "button",
2387
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2388
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(CircleIcon, {}) }),
2389
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
2390
- id: index.getTranslation("components.empty-repeatable"),
2391
- defaultMessage: "No entry yet. Click on the button below to add one."
2392
- }) }) })
2393
- ] })
2394
- }
2395
- ),
2396
- field.error && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", variant: "pi", children: field.error })
2397
- ] });
2618
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
2619
+ designSystem.Box,
2620
+ {
2621
+ tag: "button",
2622
+ background: disabled ? "neutral150" : "neutral100",
2623
+ borderColor: field.error ? "danger600" : "neutral200",
2624
+ hasRadius: true,
2625
+ disabled,
2626
+ onClick,
2627
+ paddingTop: 9,
2628
+ paddingBottom: 9,
2629
+ type: "button",
2630
+ style: { cursor: disabled ? "not-allowed" : "pointer" },
2631
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2632
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
2633
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
2634
+ designSystem.Typography,
2635
+ {
2636
+ textColor: disabled ? "neutral600" : "primary600",
2637
+ variant: "pi",
2638
+ fontWeight: "bold",
2639
+ children: formatMessage({
2640
+ id: index.getTranslation("components.empty-repeatable"),
2641
+ defaultMessage: "No entry yet. Click to add one."
2642
+ })
2643
+ }
2644
+ ) })
2645
+ ] })
2646
+ }
2647
+ ) });
2398
2648
  };
2399
- const CircleIcon = styledComponents.styled(Icons.PlusCircle)`
2400
- width: 2.4rem;
2401
- height: 2.4rem;
2402
- > circle {
2403
- fill: ${({ theme }) => theme.colors.primary200};
2404
- }
2649
+ const AddComponentButton = ({
2650
+ hasError,
2651
+ isDisabled,
2652
+ isOpen,
2653
+ children,
2654
+ onClick
2655
+ }) => {
2656
+ return /* @__PURE__ */ jsxRuntime.jsx(
2657
+ StyledButton,
2658
+ {
2659
+ type: "button",
2660
+ onClick,
2661
+ disabled: isDisabled,
2662
+ background: "neutral0",
2663
+ style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2664
+ variant: "tertiary",
2665
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
2666
+ /* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2667
+ /* @__PURE__ */ jsxRuntime.jsx(
2668
+ designSystem.Typography,
2669
+ {
2670
+ variant: "pi",
2671
+ fontWeight: "bold",
2672
+ textColor: hasError && !isOpen ? "danger600" : "neutral600",
2673
+ children
2674
+ }
2675
+ )
2676
+ ] })
2677
+ }
2678
+ );
2679
+ };
2680
+ const StyledAddIcon = styledComponents.styled(Icons.PlusCircle)`
2681
+ height: ${({ theme }) => theme.spaces[6]};
2682
+ width: ${({ theme }) => theme.spaces[6]};
2683
+ transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
2684
+
2685
+ > circle {
2686
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
2687
+ }
2405
2688
  > path {
2406
- fill: ${({ theme }) => theme.colors.primary600};
2689
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral500};
2407
2690
  }
2408
2691
  `;
2409
- const NonRepeatableComponent = ({
2410
- attribute,
2411
- name: name2,
2412
- children,
2413
- layout
2692
+ const StyledButton = styledComponents.styled(designSystem.Button)`
2693
+ padding-left: ${({ theme }) => theme.spaces[3]};
2694
+ border-radius: 26px;
2695
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2696
+ height: 5rem;
2697
+ `;
2698
+ const ComponentCategory = ({
2699
+ category,
2700
+ components = [],
2701
+ variant = "primary",
2702
+ onAddComponent
2414
2703
  }) => {
2415
- const { value } = strapiAdmin.useField(name2);
2416
- const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
2417
- const isNested = level > 0;
2418
- return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
2704
+ const { formatMessage } = reactIntl.useIntl();
2705
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: category, children: [
2706
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
2707
+ /* @__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(
2708
+ ComponentBox,
2709
+ {
2710
+ tag: "button",
2711
+ type: "button",
2712
+ background: "neutral100",
2713
+ justifyContent: "center",
2714
+ onClick: onAddComponent(uid),
2715
+ hasRadius: true,
2716
+ height: "8.4rem",
2717
+ shrink: 0,
2718
+ borderColor: "neutral200",
2719
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2720
+ /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
2721
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2722
+ ] })
2723
+ },
2724
+ uid
2725
+ )) }) })
2726
+ ] });
2727
+ };
2728
+ const ResponsiveAccordionContent = styledComponents.styled(designSystem.Accordion.Content)`
2729
+ container-type: inline-size;
2730
+ `;
2731
+ const Grid = styledComponents.styled(designSystem.Box)`
2732
+ display: grid;
2733
+ grid-template-columns: repeat(auto-fill, 100%);
2734
+ grid-gap: ${({ theme }) => theme.spaces[1]};
2735
+
2736
+ @container (min-width: ${() => RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
2737
+ grid-template-columns: repeat(auto-fill, 14rem);
2738
+ }
2739
+ `;
2740
+ const ComponentBox = styledComponents.styled(designSystem.Flex)`
2741
+ color: ${({ theme }) => theme.colors.neutral600};
2742
+ cursor: pointer;
2743
+
2744
+ @media (prefers-reduced-motion: no-preference) {
2745
+ transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2746
+ }
2747
+
2748
+ &:focus,
2749
+ &:hover {
2750
+ border: 1px solid ${({ theme }) => theme.colors.primary200};
2751
+ background: ${({ theme }) => theme.colors.primary100};
2752
+ color: ${({ theme }) => theme.colors.primary600};
2753
+ }
2754
+ `;
2755
+ const ComponentPicker = ({
2756
+ dynamicComponentsByCategory = {},
2757
+ isOpen,
2758
+ onClickAddComponent
2759
+ }) => {
2760
+ const { formatMessage } = reactIntl.useIntl();
2761
+ const handleAddComponentToDz = (componentUid) => () => {
2762
+ onClickAddComponent(componentUid);
2763
+ };
2764
+ if (!isOpen) {
2765
+ return null;
2766
+ }
2767
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2419
2768
  designSystem.Box,
2420
2769
  {
2421
- background: "neutral100",
2422
- paddingLeft: 6,
2423
- paddingRight: 6,
2424
2770
  paddingTop: 6,
2425
2771
  paddingBottom: 6,
2426
- hasRadius: isNested,
2427
- borderColor: isNested ? "neutral200" : void 0,
2428
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
2429
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid, { gap: 4, children: row.map(({ size, ...field }) => {
2430
- const completeFieldName = `${name2}.${field.name}`;
2431
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2432
- }) }, index2);
2433
- }) })
2772
+ paddingLeft: 5,
2773
+ paddingRight: 5,
2774
+ background: "neutral0",
2775
+ shadow: "tableShadow",
2776
+ borderColor: "neutral150",
2777
+ hasRadius: true,
2778
+ children: [
2779
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
2780
+ id: index.getTranslation("components.DynamicZone.ComponentPicker-label"),
2781
+ defaultMessage: "Pick one component"
2782
+ }) }) }),
2783
+ /* @__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(
2784
+ ComponentCategory,
2785
+ {
2786
+ category,
2787
+ components,
2788
+ onAddComponent: handleAddComponentToDz,
2789
+ variant: index2 % 2 === 1 ? "primary" : "secondary"
2790
+ },
2791
+ category
2792
+ )) }) })
2793
+ ]
2434
2794
  }
2435
- ) });
2795
+ );
2436
2796
  };
2437
- const RepeatableComponent = ({
2438
- attribute,
2797
+ const DynamicComponent = ({
2798
+ componentUid,
2439
2799
  disabled,
2800
+ index: index$1,
2440
2801
  name: name2,
2441
- mainField,
2442
- children,
2443
- layout
2802
+ onRemoveComponentClick,
2803
+ onMoveComponent,
2804
+ onGrabItem,
2805
+ onDropItem,
2806
+ onCancel,
2807
+ dynamicComponentsByCategory = {},
2808
+ onAddComponent,
2809
+ children
2444
2810
  }) => {
2445
- const { toggleNotification } = strapiAdmin.useNotification();
2446
2811
  const { formatMessage } = reactIntl.useIntl();
2447
- const { search: searchString } = reactRouterDom.useLocation();
2448
- const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
2449
- const { components } = index.useDoc();
2450
- const { value = [], error } = strapiAdmin.useField(name2);
2451
- const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
2452
- const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
2453
- const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
2454
- const { max = Infinity } = attribute;
2455
- const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
2456
- const [liveText, setLiveText] = React__namespace.useState("");
2457
- const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
2458
- if (search.has("field")) {
2459
- const fieldParam = search.get("field");
2460
- if (!fieldParam) {
2461
- return void 0;
2462
- }
2463
- const [, path] = fieldParam.split(`${name2}.`);
2464
- if (objects.getIn(value, path, void 0) !== void 0) {
2465
- const [subpath] = path.split(".");
2466
- return objects.getIn(value, subpath, void 0)?.__temp_key__;
2467
- }
2468
- }
2469
- return void 0;
2470
- }, [search, name2, value]);
2471
- const prevValue = usePrev.usePrev(value);
2812
+ const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
2813
+ const {
2814
+ edit: { components }
2815
+ } = index.useDocLayout();
2816
+ const title = React__namespace.useMemo(() => {
2817
+ const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
2818
+ const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
2819
+ const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
2820
+ const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
2821
+ return mainValue;
2822
+ }, [componentUid, components, formValues, name2, index$1]);
2823
+ const { icon, displayName } = React__namespace.useMemo(() => {
2824
+ const [category] = componentUid.split(".");
2825
+ const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
2826
+ (component) => component.uid === componentUid
2827
+ ) ?? { icon: null, displayName: null };
2828
+ return { icon: icon2, displayName: displayName2 };
2829
+ }, [componentUid, dynamicComponentsByCategory]);
2830
+ const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
2831
+ type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
2832
+ index: index$1,
2833
+ item: {
2834
+ index: index$1,
2835
+ displayedValue: `${displayName} ${title}`,
2836
+ icon
2837
+ },
2838
+ onMoveItem: onMoveComponent,
2839
+ onDropItem,
2840
+ onGrabItem,
2841
+ onCancel
2842
+ });
2472
2843
  React__namespace.useEffect(() => {
2473
- if (prevValue && prevValue.length < value.length) {
2474
- setCollapseToOpen(value[value.length - 1].__temp_key__);
2475
- }
2476
- }, [value, prevValue]);
2844
+ dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
2845
+ }, [dragPreviewRef, index$1]);
2846
+ const accordionValue = React__namespace.useId();
2847
+ const { value = [], rawError } = strapiAdmin.useField(`${name2}.${index$1}`);
2848
+ const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
2477
2849
  React__namespace.useEffect(() => {
2478
- if (typeof componentTmpKeyWithFocussedField === "string") {
2479
- setCollapseToOpen(componentTmpKeyWithFocussedField);
2850
+ if (rawError && value) {
2851
+ setCollapseToOpen(accordionValue);
2480
2852
  }
2481
- }, [componentTmpKeyWithFocussedField]);
2482
- const toggleCollapses = () => {
2483
- setCollapseToOpen("");
2484
- };
2485
- const handleClick = () => {
2486
- if (value.length < max) {
2487
- const schema = components[attribute.component];
2488
- const form = createDefaultForm(schema, components);
2489
- const data = transformDocument(schema, components)(form);
2490
- addFieldRow(name2, data);
2491
- } else if (value.length >= max) {
2492
- toggleNotification({
2493
- type: "info",
2494
- message: formatMessage({
2495
- id: index.getTranslation("components.notification.info.maximum-requirement")
2496
- })
2497
- });
2498
- }
2499
- };
2500
- const handleMoveComponentField = (newIndex, currentIndex) => {
2501
- setLiveText(
2502
- formatMessage(
2503
- {
2504
- id: index.getTranslation("dnd.reorder"),
2505
- defaultMessage: "{item}, moved. New position in list: {position}."
2506
- },
2507
- {
2508
- item: `${name2}.${currentIndex}`,
2509
- position: getItemPos(newIndex)
2510
- }
2511
- )
2512
- );
2513
- moveFieldRow(name2, currentIndex, newIndex);
2514
- };
2515
- const handleValueChange = (key) => {
2516
- setCollapseToOpen(key);
2853
+ }, [rawError, value, accordionValue]);
2854
+ const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
2855
+ const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2856
+ /* @__PURE__ */ jsxRuntime.jsx(
2857
+ designSystem.IconButton,
2858
+ {
2859
+ variant: "ghost",
2860
+ label: formatMessage(
2861
+ {
2862
+ id: index.getTranslation("components.DynamicZone.delete-label"),
2863
+ defaultMessage: "Delete {name}"
2864
+ },
2865
+ { name: title }
2866
+ ),
2867
+ onClick: onRemoveComponentClick,
2868
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
2869
+ }
2870
+ ),
2871
+ /* @__PURE__ */ jsxRuntime.jsx(
2872
+ designSystem.IconButton,
2873
+ {
2874
+ variant: "ghost",
2875
+ onClick: (e) => e.stopPropagation(),
2876
+ "data-handler-id": handlerId,
2877
+ ref: dragRef,
2878
+ label: formatMessage({
2879
+ id: index.getTranslation("components.DragHandle-label"),
2880
+ defaultMessage: "Drag"
2881
+ }),
2882
+ onKeyDown: handleKeyDown,
2883
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
2884
+ }
2885
+ ),
2886
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
2887
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 0, paddingRight: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
2888
+ designSystem.IconButton,
2889
+ {
2890
+ variant: "ghost",
2891
+ label: formatMessage({
2892
+ id: index.getTranslation("components.DynamicZone.more-actions"),
2893
+ defaultMessage: "More actions"
2894
+ }),
2895
+ tag: "span",
2896
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false })
2897
+ }
2898
+ ) }),
2899
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
2900
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
2901
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
2902
+ id: index.getTranslation("components.DynamicZone.add-item-above"),
2903
+ defaultMessage: "Add component above"
2904
+ }) }),
2905
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2906
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
2907
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
2908
+ ] }, category)) })
2909
+ ] }),
2910
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
2911
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
2912
+ id: index.getTranslation("components.DynamicZone.add-item-below"),
2913
+ defaultMessage: "Add component below"
2914
+ }) }),
2915
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2916
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
2917
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
2918
+ ] }, category)) })
2919
+ ] })
2920
+ ] })
2921
+ ] })
2922
+ ] });
2923
+ const accordionTitle = title ? `${displayName} ${title}` : displayName;
2924
+ return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
2925
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
2926
+ /* @__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: [
2927
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
2928
+ /* @__PURE__ */ jsxRuntime.jsx(
2929
+ designSystem.Accordion.Trigger,
2930
+ {
2931
+ icon: icon && ComponentIcon.COMPONENT_ICONS[icon] ? ComponentIcon.COMPONENT_ICONS[icon] : ComponentIcon.COMPONENT_ICONS.dashboard,
2932
+ children: accordionTitle
2933
+ }
2934
+ ),
2935
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
2936
+ ] }),
2937
+ /* @__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(
2938
+ designSystem.Grid.Item,
2939
+ {
2940
+ col: 12,
2941
+ s: 12,
2942
+ xs: 12,
2943
+ direction: "column",
2944
+ alignItems: "stretch",
2945
+ children: /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
2946
+ const fieldName = `${name2}.${index$1}.${field.name}`;
2947
+ const fieldWithTranslatedLabel = {
2948
+ ...field,
2949
+ label: formatMessage({
2950
+ id: `content-manager.components.${componentUid}.${field.name}`,
2951
+ defaultMessage: field.label
2952
+ })
2953
+ };
2954
+ return /* @__PURE__ */ jsxRuntime.jsx(
2955
+ ResponsiveGridItem,
2956
+ {
2957
+ col: size,
2958
+ s: 12,
2959
+ xs: 12,
2960
+ direction: "column",
2961
+ alignItems: "stretch",
2962
+ children: children ? children({ ...fieldWithTranslatedLabel, name: fieldName }) : /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
2963
+ },
2964
+ fieldName
2965
+ );
2966
+ }) })
2967
+ },
2968
+ rowInd
2969
+ )) }) }) }) })
2970
+ ] }) }) })
2971
+ ] });
2972
+ };
2973
+ const StyledBox = styledComponents.styled(designSystem.Box)`
2974
+ > div:first-child {
2975
+ box-shadow: ${({ theme }) => theme.shadows.tableShadow};
2976
+ }
2977
+ `;
2978
+ const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
2979
+ border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
2980
+ `;
2981
+ const Rectangle = styledComponents.styled(designSystem.Box)`
2982
+ width: ${({ theme }) => theme.spaces[2]};
2983
+ height: ${({ theme }) => theme.spaces[4]};
2984
+ `;
2985
+ const Preview$1 = styledComponents.styled.span`
2986
+ display: block;
2987
+ background-color: ${({ theme }) => theme.colors.primary100};
2988
+ outline: 1px dashed ${({ theme }) => theme.colors.primary500};
2989
+ outline-offset: -1px;
2990
+ padding: ${({ theme }) => theme.spaces[6]};
2991
+ `;
2992
+ const ComponentContainer = styledComponents.styled(designSystem.Box)`
2993
+ list-style: none;
2994
+ padding: 0;
2995
+ margin: 0;
2996
+ `;
2997
+ const DynamicZoneLabel = ({
2998
+ hint,
2999
+ label,
3000
+ labelAction,
3001
+ name: name2,
3002
+ numberOfComponents = 0,
3003
+ required
3004
+ }) => {
3005
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
3006
+ designSystem.Box,
3007
+ {
3008
+ paddingTop: 3,
3009
+ paddingBottom: 3,
3010
+ paddingRight: 4,
3011
+ paddingLeft: 4,
3012
+ borderRadius: "26px",
3013
+ background: "neutral0",
3014
+ shadow: "filterShadow",
3015
+ color: "neutral500",
3016
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
3017
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
3018
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
3019
+ label || name2,
3020
+ " "
3021
+ ] }),
3022
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
3023
+ "(",
3024
+ numberOfComponents,
3025
+ ")"
3026
+ ] }),
3027
+ required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
3028
+ labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
3029
+ ] }),
3030
+ 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 }) })
3031
+ ] })
3032
+ }
3033
+ ) });
3034
+ };
3035
+ const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
3036
+ "DynamicZone",
3037
+ {
3038
+ isInDynamicZone: false
3039
+ }
3040
+ );
3041
+ const DynamicZone = ({
3042
+ attribute,
3043
+ disabled: disabledProp,
3044
+ hint,
3045
+ label,
3046
+ labelAction,
3047
+ name: name2,
3048
+ required = false,
3049
+ children
3050
+ }) => {
3051
+ const { max = Infinity, min = -Infinity } = attribute ?? {};
3052
+ const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
3053
+ const [liveText, setLiveText] = React__namespace.useState("");
3054
+ const { components, isLoading } = index.useDoc();
3055
+ const disabled = disabledProp || isLoading;
3056
+ const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
3057
+ "DynamicZone",
3058
+ ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
3059
+ addFieldRow: addFieldRow2,
3060
+ removeFieldRow: removeFieldRow2,
3061
+ moveFieldRow: moveFieldRow2
3062
+ })
3063
+ );
3064
+ const { value = [], error } = strapiAdmin.useField(name2);
3065
+ const dynamicComponentsByCategory = React__namespace.useMemo(() => {
3066
+ return attribute.components.reduce((acc, componentUid) => {
3067
+ const { category, info } = components[componentUid] ?? { info: {} };
3068
+ const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
3069
+ if (!acc[category]) {
3070
+ acc[category] = [];
3071
+ }
3072
+ acc[category] = [...acc[category], component];
3073
+ return acc;
3074
+ }, {});
3075
+ }, [attribute.components, components]);
3076
+ const { formatMessage } = reactIntl.useIntl();
3077
+ const { toggleNotification } = strapiAdmin.useNotification();
3078
+ const dynamicDisplayedComponentsLength = value.length;
3079
+ const handleAddComponent = (uid, position) => {
3080
+ setAddComponentIsOpen(false);
3081
+ const schema = components[uid];
3082
+ const form = index.createDefaultForm(schema, components);
3083
+ const transformations = pipe__default.default(index.transformDocument(schema, components), (data2) => ({
3084
+ ...data2,
3085
+ __component: uid
3086
+ }));
3087
+ const data = transformations(form);
3088
+ addFieldRow(name2, data, position);
3089
+ };
3090
+ const handleClickOpenPicker = () => {
3091
+ if (dynamicDisplayedComponentsLength < max) {
3092
+ setAddComponentIsOpen((prev) => !prev);
3093
+ } else {
3094
+ toggleNotification({
3095
+ type: "info",
3096
+ message: formatMessage({
3097
+ id: index.getTranslation("components.notification.info.maximum-requirement")
3098
+ })
3099
+ });
3100
+ }
3101
+ };
3102
+ const handleMoveComponent = (newIndex, currentIndex) => {
3103
+ setLiveText(
3104
+ formatMessage(
3105
+ {
3106
+ id: index.getTranslation("dnd.reorder"),
3107
+ defaultMessage: "{item}, moved. New position in list: {position}."
3108
+ },
3109
+ {
3110
+ item: `${name2}.${currentIndex}`,
3111
+ position: getItemPos(newIndex)
3112
+ }
3113
+ )
3114
+ );
3115
+ moveFieldRow(name2, currentIndex, newIndex);
2517
3116
  };
2518
3117
  const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
2519
3118
  const handleCancel = (index$1) => {
@@ -2557,419 +3156,109 @@ const RepeatableComponent = ({
2557
3156
  )
2558
3157
  );
2559
3158
  };
2560
- const ariaDescriptionId = React__namespace.useId();
2561
- const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
2562
- if (value.length === 0) {
2563
- return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
2564
- }
2565
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
2566
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
2567
- id: index.getTranslation("dnd.instructions"),
2568
- defaultMessage: `Press spacebar to grab and re-order`
2569
- }) }),
2570
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
2571
- /* @__PURE__ */ jsxRuntime.jsxs(
2572
- AccordionRoot,
2573
- {
2574
- $error: error,
2575
- value: collapseToOpen,
2576
- onValueChange: handleValueChange,
2577
- "aria-describedby": ariaDescriptionId,
2578
- children: [
2579
- value.map(({ __temp_key__: key, id }, index2) => {
2580
- const nameWithIndex = `${name2}.${index2}`;
2581
- return /* @__PURE__ */ jsxRuntime.jsx(
2582
- Relations.ComponentProvider,
2583
- {
2584
- id,
2585
- uid: attribute.component,
2586
- level: level + 1,
2587
- type: "repeatable",
2588
- children: /* @__PURE__ */ jsxRuntime.jsx(
2589
- Component,
2590
- {
2591
- disabled,
2592
- name: nameWithIndex,
2593
- attribute,
2594
- index: index2,
2595
- mainField,
2596
- onMoveItem: handleMoveComponentField,
2597
- onDeleteComponent: () => {
2598
- removeFieldRow(name2, index2);
2599
- toggleCollapses();
2600
- },
2601
- toggleCollapses,
2602
- onCancel: handleCancel,
2603
- onDropItem: handleDropItem,
2604
- onGrabItem: handleGrabItem,
2605
- __temp_key__: key,
2606
- children: layout.map((row, index22) => {
2607
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid, { gap: 4, children: row.map(({ size, ...field }) => {
2608
- const completeFieldName = `${nameWithIndex}.${field.name}`;
2609
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2610
- }) }, index22);
2611
- })
2612
- }
2613
- )
2614
- },
2615
- key
2616
- );
2617
- }),
2618
- /* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
2619
- id: index.getTranslation("containers.EditView.add.new-entry"),
2620
- defaultMessage: "Add an entry"
2621
- }) })
2622
- ]
2623
- }
2624
- )
2625
- ] });
2626
- };
2627
- const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
2628
- border: 1px solid
2629
- ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
2630
- `;
2631
- const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
2632
- width: 100%;
2633
- display: flex;
2634
- justify-content: center;
2635
- border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2636
- padding-inline: ${(props) => props.theme.spaces[6]};
2637
- padding-block: ${(props) => props.theme.spaces[3]};
2638
-
2639
- &:not([disabled]) {
2640
- cursor: pointer;
2641
-
2642
- &:hover {
2643
- background-color: ${(props) => props.theme.colors.primary100};
2644
- }
2645
- }
2646
-
2647
- span {
2648
- font-weight: 600;
2649
- font-size: 1.4rem;
2650
- line-height: 2.4rem;
2651
- }
2652
-
2653
- @media (prefers-reduced-motion: no-preference) {
2654
- transition: background-color 120ms ${(props) => props.theme.easings.easeOutQuad};
2655
- }
2656
- `;
2657
- const Component = ({
2658
- disabled,
2659
- index: index$1,
2660
- name: name2,
2661
- mainField = {
2662
- name: "id",
2663
- type: "integer"
2664
- },
2665
- children,
2666
- onDeleteComponent,
2667
- toggleCollapses,
2668
- __temp_key__,
2669
- ...dragProps
2670
- }) => {
2671
- const { formatMessage } = reactIntl.useIntl();
2672
- const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
2673
- return objects.getIn(state.values, [...name2.split("."), mainField.name]);
2674
- });
2675
- const accordionRef = React__namespace.useRef(null);
2676
- const componentKey = name2.split(".").slice(0, -1).join(".");
2677
- const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
2678
- type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
2679
- index: index$1,
2680
- item: {
2681
- index: index$1,
2682
- displayedValue: displayValue
2683
- },
2684
- onStart() {
2685
- toggleCollapses();
2686
- },
2687
- ...dragProps
2688
- });
2689
- React__namespace.useEffect(() => {
2690
- dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
2691
- }, [dragPreviewRef, index$1]);
2692
- const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
2693
- const composedBoxRefs = designSystem.useComposedRefs(
2694
- boxRef,
2695
- dropRef
2696
- );
2697
- 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: [
2698
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
2699
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: displayValue }),
2700
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Actions, { children: [
2701
- /* @__PURE__ */ jsxRuntime.jsx(
2702
- designSystem.IconButton,
2703
- {
2704
- borderWidth: 0,
2705
- onClick: onDeleteComponent,
2706
- label: formatMessage({
2707
- id: index.getTranslation("containers.Edit.delete"),
2708
- defaultMessage: "Delete"
2709
- }),
2710
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
2711
- }
2712
- ),
2713
- /* @__PURE__ */ jsxRuntime.jsx(
2714
- designSystem.IconButton,
2715
- {
2716
- ref: composedAccordionRefs,
2717
- borderWidth: 0,
2718
- onClick: (e) => e.stopPropagation(),
2719
- "data-handler-id": handlerId,
2720
- label: formatMessage({
2721
- id: index.getTranslation("components.DragHandle-label"),
2722
- defaultMessage: "Drag"
2723
- }),
2724
- onKeyDown: handleKeyDown,
2725
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
2726
- }
2727
- )
2728
- ] })
2729
- ] }),
2730
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
2731
- designSystem.Flex,
2732
- {
2733
- direction: "column",
2734
- alignItems: "stretch",
2735
- background: "neutral100",
2736
- padding: 6,
2737
- gap: 6,
2738
- children
2739
- }
2740
- ) })
2741
- ] }) });
2742
- };
2743
- const Preview$1 = () => {
2744
- return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
2745
- };
2746
- const StyledSpan = styledComponents.styled(designSystem.Box)`
2747
- display: block;
2748
- outline: 1px dashed ${({ theme }) => theme.colors.primary500};
2749
- outline-offset: -1px;
2750
- `;
2751
- const ComponentInput = ({
2752
- label,
2753
- required,
2754
- name: name2,
2755
- attribute,
2756
- disabled,
2757
- labelAction,
2758
- ...props
2759
- }) => {
2760
- const { formatMessage } = reactIntl.useIntl();
2761
- const field = strapiAdmin.useField(name2);
2762
- const showResetComponent = !attribute.repeatable && field.value && !disabled;
2763
- const { components } = index.useDoc();
2764
- const handleInitialisationClick = () => {
2765
- const schema = components[attribute.component];
2766
- const form = createDefaultForm(schema, components);
2767
- const data = transformDocument(schema, components)(form);
2768
- field.onChange(name2, data);
3159
+ const handleRemoveComponent = (name22, currentIndex) => () => {
3160
+ removeFieldRow(name22, currentIndex);
2769
3161
  };
2770
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
2771
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
2772
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
2773
- label,
2774
- attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2775
- (",
2776
- Array.isArray(field.value) ? field.value.length : 0,
2777
- ")"
2778
- ] })
2779
- ] }),
2780
- showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
2781
- designSystem.IconButton,
3162
+ const hasError = error !== void 0;
3163
+ const renderButtonLabel = () => {
3164
+ if (addComponentIsOpen) {
3165
+ return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
3166
+ }
3167
+ if (hasError && dynamicDisplayedComponentsLength > max) {
3168
+ return formatMessage(
2782
3169
  {
2783
- label: formatMessage({
2784
- id: index.getTranslation("components.reset-entry"),
2785
- defaultMessage: "Reset Entry"
2786
- }),
2787
- borderWidth: 0,
2788
- onClick: () => {
2789
- field.onChange(name2, null);
2790
- },
2791
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
3170
+ id: index.getTranslation(`components.DynamicZone.extra-components`),
3171
+ defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
3172
+ },
3173
+ {
3174
+ number: dynamicDisplayedComponentsLength - max
2792
3175
  }
2793
- )
2794
- ] }),
2795
- !attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
2796
- !attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
2797
- attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
2798
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
2799
- ] });
2800
- };
2801
- const MemoizedComponentInput = React__namespace.memo(ComponentInput);
2802
- const AddComponentButton = ({
2803
- hasError,
2804
- isDisabled,
2805
- isOpen,
2806
- children,
2807
- onClick
2808
- }) => {
2809
- return /* @__PURE__ */ jsxRuntime.jsx(
2810
- StyledButton,
2811
- {
2812
- type: "button",
2813
- onClick,
2814
- disabled: isDisabled,
2815
- background: "neutral0",
2816
- paddingTop: 3,
2817
- paddingBottom: 3,
2818
- paddingLeft: 4,
2819
- paddingRight: 4,
2820
- style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2821
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
2822
- /* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2823
- /* @__PURE__ */ jsxRuntime.jsx(
2824
- AddComponentTitle,
2825
- {
2826
- variant: "pi",
2827
- fontWeight: "bold",
2828
- textColor: hasError && !isOpen ? "danger600" : "neutral500",
2829
- children
2830
- }
2831
- )
2832
- ] })
2833
- }
2834
- );
2835
- };
2836
- const StyledAddIcon = styledComponents.styled(Icons.PlusCircle)`
2837
- height: ${({ theme }) => theme.spaces[6]};
2838
- width: ${({ theme }) => theme.spaces[6]};
2839
- transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
2840
-
2841
- > circle {
2842
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
2843
- }
2844
- > path {
2845
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
2846
- }
2847
- `;
2848
- const AddComponentTitle = styledComponents.styled(designSystem.Typography)``;
2849
- const StyledButton = styledComponents.styled(designSystem.BaseButton)`
2850
- border-radius: 26px;
2851
- border-color: ${({ theme }) => theme.colors.neutral150};
2852
- box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2853
-
2854
- &:hover {
2855
- ${AddComponentTitle} {
2856
- color: ${({ theme }) => theme.colors.primary600};
2857
- }
2858
-
2859
- ${StyledAddIcon} {
2860
- > circle {
2861
- fill: ${({ theme }) => theme.colors.primary600};
2862
- }
2863
- > path {
2864
- fill: ${({ theme }) => theme.colors.neutral100};
2865
- }
2866
- }
2867
- }
2868
- &:active {
2869
- ${AddComponentTitle} {
2870
- color: ${({ theme }) => theme.colors.primary600};
3176
+ );
2871
3177
  }
2872
- ${StyledAddIcon} {
2873
- > circle {
2874
- fill: ${({ theme }) => theme.colors.primary600};
2875
- }
2876
- > path {
2877
- fill: ${({ theme }) => theme.colors.neutral100};
2878
- }
3178
+ if (hasError && dynamicDisplayedComponentsLength < min) {
3179
+ return formatMessage(
3180
+ {
3181
+ id: index.getTranslation(`components.DynamicZone.missing-components`),
3182
+ defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
3183
+ },
3184
+ { number: min - dynamicDisplayedComponentsLength }
3185
+ );
2879
3186
  }
2880
- }
2881
- `;
2882
- const ComponentCategory = ({
2883
- category,
2884
- components = [],
2885
- variant = "primary",
2886
- onAddComponent
2887
- }) => {
2888
- const { formatMessage } = reactIntl.useIntl();
2889
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: category, children: [
2890
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
2891
- /* @__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(
2892
- ComponentBox,
3187
+ return formatMessage(
2893
3188
  {
2894
- tag: "button",
2895
- type: "button",
2896
- background: "neutral100",
2897
- justifyContent: "center",
2898
- onClick: onAddComponent(uid),
2899
- hasRadius: true,
2900
- height: "8.4rem",
2901
- shrink: 0,
2902
- borderColor: "neutral200",
2903
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2904
- /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
2905
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2906
- ] })
3189
+ id: index.getTranslation("components.DynamicZone.add-component"),
3190
+ defaultMessage: "Add a component to {componentName}"
2907
3191
  },
2908
- uid
2909
- )) }) })
2910
- ] });
2911
- };
2912
- const Grid = styledComponents.styled(designSystem.Box)`
2913
- display: grid;
2914
- grid-template-columns: repeat(auto-fit, 14rem);
2915
- grid-gap: ${({ theme }) => theme.spaces[1]};
2916
- `;
2917
- const ComponentBox = styledComponents.styled(designSystem.Flex)`
2918
- color: ${({ theme }) => theme.colors.neutral600};
2919
- cursor: pointer;
2920
-
2921
- @media (prefers-reduced-motion: no-preference) {
2922
- transition: color 120ms ${(props) => props.theme.easings.easeOutQuad};
2923
- }
2924
-
2925
- &:focus,
2926
- &:hover {
2927
- border: 1px solid ${({ theme }) => theme.colors.primary200};
2928
- background: ${({ theme }) => theme.colors.primary100};
2929
- color: ${({ theme }) => theme.colors.primary600};
2930
- }
2931
- `;
2932
- const ComponentPicker = ({
2933
- dynamicComponentsByCategory = {},
2934
- isOpen,
2935
- onClickAddComponent
2936
- }) => {
2937
- const { formatMessage } = reactIntl.useIntl();
2938
- const handleAddComponentToDz = (componentUid) => () => {
2939
- onClickAddComponent(componentUid);
3192
+ { componentName: label || name2 }
3193
+ );
2940
3194
  };
2941
- if (!isOpen) {
2942
- return null;
2943
- }
2944
- return /* @__PURE__ */ jsxRuntime.jsxs(
2945
- designSystem.Box,
2946
- {
2947
- paddingTop: 6,
2948
- paddingBottom: 6,
2949
- paddingLeft: 5,
2950
- paddingRight: 5,
2951
- background: "neutral0",
2952
- shadow: "tableShadow",
2953
- borderColor: "neutral150",
2954
- hasRadius: true,
2955
- children: [
2956
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
2957
- id: index.getTranslation("components.DynamicZone.ComponentPicker-label"),
2958
- defaultMessage: "Pick one component"
2959
- }) }) }),
2960
- /* @__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(
2961
- ComponentCategory,
2962
- {
2963
- category,
2964
- components,
2965
- onAddComponent: handleAddComponentToDz,
2966
- variant: index2 % 2 === 1 ? "primary" : "secondary"
2967
- },
2968
- category
2969
- )) }) })
2970
- ]
2971
- }
2972
- );
3195
+ const level = Relations.useComponent("DynamicZone", (state) => state.level);
3196
+ const ariaDescriptionId = React__namespace.useId();
3197
+ return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3198
+ dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
3199
+ /* @__PURE__ */ jsxRuntime.jsx(
3200
+ DynamicZoneLabel,
3201
+ {
3202
+ hint,
3203
+ label,
3204
+ labelAction,
3205
+ name: name2,
3206
+ numberOfComponents: dynamicDisplayedComponentsLength,
3207
+ required
3208
+ }
3209
+ ),
3210
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
3211
+ id: index.getTranslation("dnd.instructions"),
3212
+ defaultMessage: `Press spacebar to grab and re-order`
3213
+ }) }),
3214
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
3215
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
3216
+ Relations.ComponentProvider,
3217
+ {
3218
+ level: level + 1,
3219
+ uid: field.__component,
3220
+ id: field.id,
3221
+ type: "dynamiczone",
3222
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3223
+ DynamicComponent,
3224
+ {
3225
+ disabled,
3226
+ name: name2,
3227
+ index: index2,
3228
+ componentUid: field.__component,
3229
+ onMoveComponent: handleMoveComponent,
3230
+ onRemoveComponentClick: handleRemoveComponent(name2, index2),
3231
+ onCancel: handleCancel,
3232
+ onDropItem: handleDropItem,
3233
+ onGrabItem: handleGrabItem,
3234
+ onAddComponent: handleAddComponent,
3235
+ dynamicComponentsByCategory,
3236
+ children
3237
+ }
3238
+ )
3239
+ },
3240
+ field.__temp_key__
3241
+ )) })
3242
+ ] }),
3243
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
3244
+ AddComponentButton,
3245
+ {
3246
+ hasError,
3247
+ isDisabled: disabled,
3248
+ isOpen: addComponentIsOpen,
3249
+ onClick: handleClickOpenPicker,
3250
+ children: renderButtonLabel()
3251
+ }
3252
+ ) }),
3253
+ /* @__PURE__ */ jsxRuntime.jsx(
3254
+ ComponentPicker,
3255
+ {
3256
+ dynamicComponentsByCategory,
3257
+ isOpen: addComponentIsOpen,
3258
+ onClickAddComponent: handleAddComponent
3259
+ }
3260
+ )
3261
+ ] }) });
2973
3262
  };
2974
3263
  const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
2975
3264
  const { formatMessage } = reactIntl.useIntl();
@@ -2992,18 +3281,6 @@ const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
2992
3281
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
2993
3282
  ] });
2994
3283
  };
2995
- function useDebounce(value, delay) {
2996
- const [debouncedValue, setDebouncedValue] = React.useState(value);
2997
- React.useEffect(() => {
2998
- const handler = setTimeout(() => {
2999
- setDebouncedValue(value);
3000
- }, delay);
3001
- return () => {
3002
- clearTimeout(handler);
3003
- };
3004
- }, [value, delay]);
3005
- return debouncedValue;
3006
- }
3007
3284
  const uidApi = index.contentManagerApi.injectEndpoints({
3008
3285
  endpoints: (builder) => ({
3009
3286
  getDefaultUID: builder.query({
@@ -3038,7 +3315,10 @@ const uidApi = index.contentManagerApi.injectEndpoints({
3038
3315
  config: {
3039
3316
  params
3040
3317
  }
3041
- })
3318
+ }),
3319
+ providesTags: (_res, _error, params) => [
3320
+ { type: "UidAvailability", id: params.contentTypeUID }
3321
+ ]
3042
3322
  })
3043
3323
  })
3044
3324
  });
@@ -3050,8 +3330,10 @@ const UIDInput = React__namespace.forwardRef(
3050
3330
  const allFormValues = strapiAdmin.useForm("InputUID", (form) => form.values);
3051
3331
  const [availability, setAvailability] = React__namespace.useState();
3052
3332
  const [showRegenerate, setShowRegenerate] = React__namespace.useState(false);
3333
+ const isCloning = reactRouterDom.useMatch(index.CLONE_PATH) !== null;
3053
3334
  const field = strapiAdmin.useField(name2);
3054
- const debouncedValue = useDebounce(field.value, 300);
3335
+ const debouncedValue = relations.useDebounce(field.value, 300);
3336
+ const hasChanged = debouncedValue !== field.initialValue;
3055
3337
  const { toggleNotification } = strapiAdmin.useNotification();
3056
3338
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
3057
3339
  const { formatMessage } = reactIntl.useIntl();
@@ -3127,8 +3409,9 @@ const UIDInput = React__namespace.forwardRef(
3127
3409
  params
3128
3410
  },
3129
3411
  {
3412
+ // Don't check availability if the value is empty or wasn't changed
3130
3413
  skip: !Boolean(
3131
- debouncedValue !== field.initialValue && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3414
+ (hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3132
3415
  )
3133
3416
  }
3134
3417
  );
@@ -3157,6 +3440,7 @@ const UIDInput = React__namespace.forwardRef(
3157
3440
  const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
3158
3441
  const fieldRef = strapiAdmin.useFocusInputField(name2);
3159
3442
  const composedRefs = designSystem.useComposedRefs(ref, fieldRef);
3443
+ const shouldShowAvailability = (hasChanged || isCloning) && debouncedValue != null && availability && !showRegenerate;
3160
3444
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { hint, name: name2, error: field.error, required, children: [
3161
3445
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
3162
3446
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3165,7 +3449,7 @@ const UIDInput = React__namespace.forwardRef(
3165
3449
  ref: composedRefs,
3166
3450
  disabled: props.disabled,
3167
3451
  endAction: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { position: "relative", gap: 1, children: [
3168
- availability && !showRegenerate && /* @__PURE__ */ jsxRuntime.jsxs(
3452
+ shouldShowAvailability && /* @__PURE__ */ jsxRuntime.jsxs(
3169
3453
  TextValidation,
3170
3454
  {
3171
3455
  alignItems: "center",
@@ -3454,8 +3738,7 @@ const Wrapper = styledComponents.styled.div`
3454
3738
  `;
3455
3739
  var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/;
3456
3740
  function newlineAndIndentContinueMarkdownList(cm) {
3457
- if (cm.getOption("disableInput"))
3458
- return CodeMirror__default.default.Pass;
3741
+ if (cm.getOption("disableInput")) return CodeMirror__default.default.Pass;
3459
3742
  var ranges = cm.listSelections(), replacements = [];
3460
3743
  for (var i = 0; i < ranges.length; i++) {
3461
3744
  var pos = ranges[i].head;
@@ -3489,8 +3772,7 @@ function newlineAndIndentContinueMarkdownList(cm) {
3489
3772
  var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
3490
3773
  var bullet = numbered ? parseInt(match[3], 10) + 1 + match[4] : match[2].replace("x", " ");
3491
3774
  replacements[i] = "\n" + indent + bullet + after;
3492
- if (numbered)
3493
- incrementRemainingMarkdownListNumbers(cm, pos);
3775
+ if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
3494
3776
  }
3495
3777
  }
3496
3778
  cm.replaceSelections(replacements);
@@ -3508,10 +3790,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3508
3790
  var newNumber = parseInt(startItem[3], 10) + lookAhead - skipCount;
3509
3791
  var nextNumber = parseInt(nextItem[3], 10), itemNumber = nextNumber;
3510
3792
  if (startIndent === nextIndent && !isNaN(nextNumber)) {
3511
- if (newNumber === nextNumber)
3512
- itemNumber = nextNumber + 1;
3513
- if (newNumber > nextNumber)
3514
- itemNumber = newNumber + 1;
3793
+ if (newNumber === nextNumber) itemNumber = nextNumber + 1;
3794
+ if (newNumber > nextNumber) itemNumber = newNumber + 1;
3515
3795
  cm.replaceRange(
3516
3796
  nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
3517
3797
  {
@@ -3524,10 +3804,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3524
3804
  }
3525
3805
  );
3526
3806
  } else {
3527
- if (startIndent.length > nextIndent.length)
3528
- return;
3529
- if (startIndent.length < nextIndent.length && lookAhead === 1)
3530
- return;
3807
+ if (startIndent.length > nextIndent.length) return;
3808
+ if (startIndent.length < nextIndent.length && lookAhead === 1) return;
3531
3809
  skipCount += 1;
3532
3810
  }
3533
3811
  }
@@ -3999,7 +4277,7 @@ const EditorLayout = ({
3999
4277
  justifyContent: "flex-end",
4000
4278
  shrink: 0,
4001
4279
  width: "100%",
4002
- children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton$1, { onClick: onCollapse, children: [
4280
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton$1, { onClick: onCollapse, variant: "tertiary", size: "M", children: [
4003
4281
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
4004
4282
  id: "components.Wysiwyg.collapse",
4005
4283
  defaultMessage: "Collapse"
@@ -4017,12 +4295,14 @@ const EditorLayout = ({
4017
4295
  ) }) });
4018
4296
  }
4019
4297
  return /* @__PURE__ */ jsxRuntime.jsx(
4020
- designSystem.Box,
4298
+ designSystem.Flex,
4021
4299
  {
4022
4300
  borderColor: error ? "danger600" : "neutral200",
4023
4301
  borderStyle: "solid",
4024
4302
  borderWidth: "1px",
4025
4303
  hasRadius: true,
4304
+ direction: "column",
4305
+ alignItems: "stretch",
4026
4306
  children
4027
4307
  }
4028
4308
  );
@@ -4033,11 +4313,19 @@ const ExpandWrapper = styledComponents.styled(designSystem.Flex)`
4033
4313
  const BoxWithBorder = styledComponents.styled(designSystem.Box)`
4034
4314
  border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
4035
4315
  `;
4036
- const ExpandButton$1 = styledComponents.styled(designSystem.BaseButton)`
4316
+ const ExpandButton$1 = styledComponents.styled(designSystem.Button)`
4037
4317
  background-color: transparent;
4038
4318
  border: none;
4039
4319
  align-items: center;
4040
4320
 
4321
+ & > span {
4322
+ display: flex;
4323
+ justify-content: space-between;
4324
+ align-items: center;
4325
+ width: 100%;
4326
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4327
+ }
4328
+
4041
4329
  svg {
4042
4330
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4043
4331
 
@@ -4301,45 +4589,31 @@ const quoteAndCodeHandler = (editor, markdownType) => {
4301
4589
  if (textToEdit) {
4302
4590
  insertWithTextToEdit(editor, markdownType, line, contentLength, textToEdit);
4303
4591
  } else {
4304
- insertWithoutTextToEdit(editor, markdownType, line, contentLength);
4305
- }
4306
- };
4307
- const CustomIconButton = styledComponents.styled(designSystem.IconButton)`
4308
- padding: ${({ theme }) => theme.spaces[2]};
4309
- /* Trick to prevent the outline from overflowing because of the general outline-offset */
4310
- outline-offset: -2px !important;
4311
-
4312
- svg {
4313
- width: 1.8rem;
4314
- height: 1.8rem;
4315
- }
4316
- `;
4317
- const CustomLinkIconButton = styledComponents.styled(CustomIconButton)`
4318
- svg {
4319
- width: 0.8rem;
4320
- height: 0.8rem;
4592
+ insertWithoutTextToEdit(editor, markdownType, line, contentLength);
4321
4593
  }
4322
- `;
4594
+ };
4323
4595
  const MainButtons = styledComponents.styled(designSystem.IconButtonGroup)`
4324
4596
  margin-left: ${({ theme }) => theme.spaces[4]};
4325
4597
  `;
4326
4598
  const MoreButton = styledComponents.styled(designSystem.IconButton)`
4327
4599
  margin: ${({ theme }) => `0 ${theme.spaces[2]}`};
4328
- padding: ${({ theme }) => theme.spaces[2]};
4329
-
4330
- svg {
4331
- width: 1.8rem;
4332
- height: 1.8rem;
4333
- }
4334
4600
  `;
4335
4601
  const IconButtonGroupMargin = styledComponents.styled(designSystem.IconButtonGroup)`
4336
4602
  margin-right: ${({ theme }) => `${theme.spaces[2]}`};
4337
4603
  `;
4338
- const ExpandButton = styledComponents.styled(designSystem.BaseButton)`
4604
+ const ExpandButton = styledComponents.styled(designSystem.Button)`
4339
4605
  background-color: transparent;
4340
4606
  border: none;
4341
4607
  align-items: center;
4342
4608
 
4609
+ & > span {
4610
+ display: flex;
4611
+ justify-content: space-between;
4612
+ align-items: center;
4613
+ width: 100%;
4614
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4615
+ }
4616
+
4343
4617
  svg {
4344
4618
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4345
4619
  path {
@@ -4351,8 +4625,8 @@ const ExpandButton = styledComponents.styled(designSystem.BaseButton)`
4351
4625
  `;
4352
4626
  const WysiwygFooter = ({ onToggleExpand }) => {
4353
4627
  const { formatMessage } = reactIntl.useIntl();
4354
- 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: [
4355
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
4628
+ 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: [
4629
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: formatMessage({
4356
4630
  id: "components.WysiwygBottomControls.fullscreen",
4357
4631
  defaultMessage: "Expand"
4358
4632
  }) }),
@@ -4374,7 +4648,7 @@ const WysiwygNav = ({
4374
4648
  id: "components.Wysiwyg.selectOptions.title",
4375
4649
  defaultMessage: "Add a title"
4376
4650
  });
4377
- const buttonMoreRef = React__namespace.useRef(null);
4651
+ React__namespace.useRef(null);
4378
4652
  const handleTogglePopover = () => {
4379
4653
  setVisiblePopover((prev) => !prev);
4380
4654
  };
@@ -4388,18 +4662,27 @@ const WysiwygNav = ({
4388
4662
  borderRadius: `0.4rem 0.4rem 0 0`,
4389
4663
  children: [
4390
4664
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
4391
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { disabled: true, placeholder: selectPlaceholder, "aria-label": selectPlaceholder, children: [
4392
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4393
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
4394
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h3", children: "h3" }),
4395
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h4", children: "h4" }),
4396
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h5", children: "h5" }),
4397
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h6", children: "h6" })
4398
- ] }) }),
4665
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4666
+ designSystem.SingleSelect,
4667
+ {
4668
+ disabled: true,
4669
+ placeholder: selectPlaceholder,
4670
+ "aria-label": selectPlaceholder,
4671
+ size: "S",
4672
+ children: [
4673
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4674
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
4675
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h3", children: "h3" }),
4676
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h4", children: "h4" }),
4677
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h5", children: "h5" }),
4678
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h6", children: "h6" })
4679
+ ]
4680
+ }
4681
+ ) }),
4399
4682
  /* @__PURE__ */ jsxRuntime.jsxs(MainButtons, { children: [
4400
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4401
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Italic, {}) }),
4402
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Underline, {}) })
4683
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4684
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Italic, {}) }),
4685
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Underline, {}) })
4403
4686
  ] }),
4404
4687
  /* @__PURE__ */ jsxRuntime.jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, {}) })
4405
4688
  ] }),
@@ -4426,6 +4709,7 @@ const WysiwygNav = ({
4426
4709
  placeholder: selectPlaceholder,
4427
4710
  "aria-label": selectPlaceholder,
4428
4711
  onChange: (value) => onActionClick(value, editorRef),
4712
+ size: "S",
4429
4713
  children: [
4430
4714
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4431
4715
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
@@ -4437,17 +4721,9 @@ const WysiwygNav = ({
4437
4721
  }
4438
4722
  ) }),
4439
4723
  /* @__PURE__ */ jsxRuntime.jsxs(MainButtons, { children: [
4724
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { onClick: () => onActionClick("Bold", editorRef), label: "Bold", name: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4440
4725
  /* @__PURE__ */ jsxRuntime.jsx(
4441
- CustomIconButton,
4442
- {
4443
- onClick: () => onActionClick("Bold", editorRef),
4444
- label: "Bold",
4445
- name: "Bold",
4446
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {})
4447
- }
4448
- ),
4449
- /* @__PURE__ */ jsxRuntime.jsx(
4450
- CustomIconButton,
4726
+ designSystem.IconButton,
4451
4727
  {
4452
4728
  onClick: () => onActionClick("Italic", editorRef),
4453
4729
  label: "Italic",
@@ -4456,7 +4732,7 @@ const WysiwygNav = ({
4456
4732
  }
4457
4733
  ),
4458
4734
  /* @__PURE__ */ jsxRuntime.jsx(
4459
- CustomIconButton,
4735
+ designSystem.IconButton,
4460
4736
  {
4461
4737
  onClick: () => onActionClick("Underline", editorRef),
4462
4738
  label: "Underline",
@@ -4465,79 +4741,81 @@ const WysiwygNav = ({
4465
4741
  }
4466
4742
  )
4467
4743
  ] }),
4468
- /* @__PURE__ */ jsxRuntime.jsx(MoreButton, { ref: buttonMoreRef, onClick: handleTogglePopover, label: "More", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, {}) }),
4469
- visiblePopover && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover, { onDismiss: handleTogglePopover, centered: true, source: buttonMoreRef, spacing: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
4470
- /* @__PURE__ */ jsxRuntime.jsxs(IconButtonGroupMargin, { children: [
4471
- /* @__PURE__ */ jsxRuntime.jsx(
4472
- CustomIconButton,
4473
- {
4474
- onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4475
- label: "Strikethrough",
4476
- name: "Strikethrough",
4477
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.StrikeThrough, {})
4478
- }
4479
- ),
4480
- /* @__PURE__ */ jsxRuntime.jsx(
4481
- CustomIconButton,
4482
- {
4483
- onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4484
- label: "BulletList",
4485
- name: "BulletList",
4486
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.BulletList, {})
4487
- }
4488
- ),
4489
- /* @__PURE__ */ jsxRuntime.jsx(
4490
- CustomIconButton,
4491
- {
4492
- onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4493
- label: "NumberList",
4494
- name: "NumberList",
4495
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.NumberList, {})
4496
- }
4497
- )
4498
- ] }),
4499
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.IconButtonGroup, { children: [
4500
- /* @__PURE__ */ jsxRuntime.jsx(
4501
- CustomIconButton,
4502
- {
4503
- onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4504
- label: "Code",
4505
- name: "Code",
4506
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Code, {})
4507
- }
4508
- ),
4509
- /* @__PURE__ */ jsxRuntime.jsx(
4510
- CustomIconButton,
4511
- {
4512
- onClick: () => {
4513
- handleTogglePopover();
4514
- onToggleMediaLib();
4515
- },
4516
- label: "Image",
4517
- name: "Image",
4518
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Image, {})
4519
- }
4520
- ),
4521
- /* @__PURE__ */ jsxRuntime.jsx(
4522
- CustomLinkIconButton,
4523
- {
4524
- onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4525
- label: "Link",
4526
- name: "Link",
4527
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Link, {})
4528
- }
4529
- ),
4530
- /* @__PURE__ */ jsxRuntime.jsx(
4531
- CustomIconButton,
4532
- {
4533
- onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4534
- label: "Quote",
4535
- name: "Quote",
4536
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Quotes, {})
4537
- }
4538
- )
4539
- ] })
4540
- ] }) })
4744
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { children: [
4745
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(MoreButton, { label: "More", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, {}) }) }),
4746
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 2, children: [
4747
+ /* @__PURE__ */ jsxRuntime.jsxs(IconButtonGroupMargin, { children: [
4748
+ /* @__PURE__ */ jsxRuntime.jsx(
4749
+ designSystem.IconButton,
4750
+ {
4751
+ onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4752
+ label: "Strikethrough",
4753
+ name: "Strikethrough",
4754
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.StrikeThrough, {})
4755
+ }
4756
+ ),
4757
+ /* @__PURE__ */ jsxRuntime.jsx(
4758
+ designSystem.IconButton,
4759
+ {
4760
+ onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4761
+ label: "BulletList",
4762
+ name: "BulletList",
4763
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.BulletList, {})
4764
+ }
4765
+ ),
4766
+ /* @__PURE__ */ jsxRuntime.jsx(
4767
+ designSystem.IconButton,
4768
+ {
4769
+ onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4770
+ label: "NumberList",
4771
+ name: "NumberList",
4772
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.NumberList, {})
4773
+ }
4774
+ )
4775
+ ] }),
4776
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.IconButtonGroup, { children: [
4777
+ /* @__PURE__ */ jsxRuntime.jsx(
4778
+ designSystem.IconButton,
4779
+ {
4780
+ onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4781
+ label: "Code",
4782
+ name: "Code",
4783
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Code, {})
4784
+ }
4785
+ ),
4786
+ /* @__PURE__ */ jsxRuntime.jsx(
4787
+ designSystem.IconButton,
4788
+ {
4789
+ onClick: () => {
4790
+ handleTogglePopover();
4791
+ onToggleMediaLib();
4792
+ },
4793
+ label: "Image",
4794
+ name: "Image",
4795
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Image, {})
4796
+ }
4797
+ ),
4798
+ /* @__PURE__ */ jsxRuntime.jsx(
4799
+ designSystem.IconButton,
4800
+ {
4801
+ onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4802
+ label: "Link",
4803
+ name: "Link",
4804
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Link, {})
4805
+ }
4806
+ ),
4807
+ /* @__PURE__ */ jsxRuntime.jsx(
4808
+ designSystem.IconButton,
4809
+ {
4810
+ onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4811
+ label: "Quote",
4812
+ name: "Quote",
4813
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Quotes, {})
4814
+ }
4815
+ )
4816
+ ] })
4817
+ ] }) })
4818
+ ] })
4541
4819
  ] }),
4542
4820
  onTogglePreviewMode && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
4543
4821
  id: "components.Wysiwyg.ToggleMode.preview-mode",
@@ -4664,15 +4942,19 @@ const Wysiwyg = React__namespace.forwardRef(
4664
4942
  );
4665
4943
  const MemoizedWysiwyg = React__namespace.memo(Wysiwyg);
4666
4944
  const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4667
- const { id } = index.useDoc();
4945
+ const { id, document: document2, collectionType } = index.useDoc();
4668
4946
  const isFormDisabled = strapiAdmin.useForm("InputRenderer", (state) => state.disabled);
4669
4947
  const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
4670
4948
  const canCreateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
4671
4949
  const canReadFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
4672
4950
  const canUpdateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
4673
4951
  const canUserAction = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
4674
- const editableFields = id ? canUpdateFields : canCreateFields;
4675
- const readableFields = id ? canReadFields : canCreateFields;
4952
+ let idToCheck = id;
4953
+ if (collectionType === index.SINGLE_TYPES) {
4954
+ idToCheck = document2?.documentId;
4955
+ }
4956
+ const editableFields = idToCheck ? canUpdateFields : canCreateFields;
4957
+ const readableFields = idToCheck ? canReadFields : canCreateFields;
4676
4958
  const canUserReadField = canUserAction(props.name, readableFields, props.type);
4677
4959
  const canUserEditField = canUserAction(props.name, editableFields, props.type);
4678
4960
  const fields = strapiAdmin.useStrapiApp("InputRenderer", (app) => app.fields);
@@ -4683,6 +4965,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4683
4965
  const {
4684
4966
  edit: { components }
4685
4967
  } = index.useDocLayout();
4968
+ const field = strapiAdmin.useField(props.name);
4686
4969
  if (!visible) {
4687
4970
  return null;
4688
4971
  }
@@ -4693,551 +4976,643 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4693
4976
  if (attributeHasCustomFieldProperty(props.attribute)) {
4694
4977
  const CustomInput = lazyComponentStore[props.attribute.customField];
4695
4978
  if (CustomInput) {
4696
- return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4979
+ return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
4980
+ }
4981
+ return /* @__PURE__ */ jsxRuntime.jsx(
4982
+ strapiAdmin.InputRenderer,
4983
+ {
4984
+ ...props,
4985
+ hint,
4986
+ type: props.attribute.customField,
4987
+ disabled: fieldIsDisabled
4988
+ }
4989
+ );
4990
+ }
4991
+ const addedInputTypes = Object.keys(fields);
4992
+ if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4993
+ const CustomInput = fields[props.type];
4994
+ return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4995
+ }
4996
+ switch (props.type) {
4997
+ case "blocks":
4998
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4999
+ case "component":
5000
+ return /* @__PURE__ */ jsxRuntime.jsx(
5001
+ MemoizedComponentInput,
5002
+ {
5003
+ ...props,
5004
+ hint,
5005
+ layout: components[props.attribute.component].layout,
5006
+ disabled: fieldIsDisabled,
5007
+ children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
5008
+ }
5009
+ );
5010
+ case "dynamiczone":
5011
+ return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
5012
+ case "relation":
5013
+ return /* @__PURE__ */ jsxRuntime.jsx(Relations.MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
5014
+ case "richtext":
5015
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5016
+ case "uid":
5017
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5018
+ case "enumeration":
5019
+ return /* @__PURE__ */ jsxRuntime.jsx(
5020
+ strapiAdmin.InputRenderer,
5021
+ {
5022
+ ...props,
5023
+ hint,
5024
+ options: props.attribute.enum.map((value) => ({ value })),
5025
+ type: props.customField ? "custom-field" : props.type,
5026
+ disabled: fieldIsDisabled
5027
+ }
5028
+ );
5029
+ default:
5030
+ const { unique: _unique, mainField: _mainField, ...restProps } = props;
5031
+ return /* @__PURE__ */ jsxRuntime.jsx(
5032
+ strapiAdmin.InputRenderer,
5033
+ {
5034
+ ...restProps,
5035
+ hint,
5036
+ type: props.customField ? "custom-field" : props.type,
5037
+ disabled: fieldIsDisabled
5038
+ }
5039
+ );
5040
+ }
5041
+ };
5042
+ const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
5043
+ const useFieldHint = (hint = void 0, attribute) => {
5044
+ const { formatMessage } = reactIntl.useIntl();
5045
+ const { maximum, minimum } = getMinMax(attribute);
5046
+ if (!maximum && !minimum) {
5047
+ return hint;
5048
+ }
5049
+ const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
5050
+ attribute.type
5051
+ ) ? formatMessage(
5052
+ {
5053
+ id: "content-manager.form.Input.hint.character.unit",
5054
+ defaultMessage: "{maxValue, plural, one { character} other { characters}}"
5055
+ },
5056
+ {
5057
+ maxValue: Math.max(minimum || 0, maximum || 0)
5058
+ }
5059
+ ) : null;
5060
+ const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
5061
+ return formatMessage(
5062
+ {
5063
+ id: "content-manager.form.Input.hint.text",
5064
+ defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
5065
+ },
5066
+ {
5067
+ min: minimum,
5068
+ max: maximum,
5069
+ description: hint,
5070
+ unit: units,
5071
+ divider: hasMinAndMax ? formatMessage({
5072
+ id: "content-manager.form.Input.hint.minMaxDivider",
5073
+ defaultMessage: " / "
5074
+ }) : null,
5075
+ br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
5076
+ }
5077
+ );
5078
+ };
5079
+ const getMinMax = (attribute) => {
5080
+ if ("min" in attribute || "max" in attribute) {
5081
+ return {
5082
+ maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
5083
+ minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
5084
+ };
5085
+ } else if ("maxLength" in attribute || "minLength" in attribute) {
5086
+ return { maximum: attribute.maxLength, minimum: attribute.minLength };
5087
+ } else {
5088
+ return { maximum: void 0, minimum: void 0 };
5089
+ }
5090
+ };
5091
+ const MemoizedInputRenderer = React.memo(InputRenderer);
5092
+ const RESPONSIVE_CONTAINER_BREAKPOINTS = {
5093
+ sm: "27.5rem"
5094
+ // 440px
5095
+ };
5096
+ const ResponsiveGridRoot = styledComponents.styled(designSystem.Grid.Root)`
5097
+ container-type: inline-size;
5098
+ `;
5099
+ const ResponsiveGridItem = styledComponents.styled(designSystem.Grid.Item)`
5100
+ grid-column: span 12;
5101
+
5102
+ @container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
5103
+ ${({ col }) => col && `grid-column: span ${col};`}
5104
+ }
5105
+ `;
5106
+ const FormLayout = ({ layout }) => {
5107
+ const { formatMessage } = reactIntl.useIntl();
5108
+ const { model } = index.useDoc();
5109
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index2) => {
5110
+ if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
5111
+ const [row] = panel;
5112
+ const [field] = row;
5113
+ const fieldWithTranslatedLabel = {
5114
+ ...field,
5115
+ label: formatMessage({
5116
+ id: `content-manager.content-types.${model}.${field.name}`,
5117
+ defaultMessage: field.label
5118
+ })
5119
+ };
5120
+ 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);
5121
+ }
5122
+ return /* @__PURE__ */ jsxRuntime.jsx(
5123
+ designSystem.Box,
5124
+ {
5125
+ hasRadius: true,
5126
+ background: "neutral0",
5127
+ shadow: "tableShadow",
5128
+ paddingLeft: 6,
5129
+ paddingRight: 6,
5130
+ paddingTop: 6,
5131
+ paddingBottom: 6,
5132
+ borderColor: "neutral150",
5133
+ 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 }) => {
5134
+ const fieldWithTranslatedLabel = {
5135
+ ...field,
5136
+ label: formatMessage({
5137
+ id: `content-manager.content-types.${model}.${field.name}`,
5138
+ defaultMessage: field.label
5139
+ })
5140
+ };
5141
+ return /* @__PURE__ */ jsxRuntime.jsx(
5142
+ ResponsiveGridItem,
5143
+ {
5144
+ col: size,
5145
+ s: 12,
5146
+ xs: 12,
5147
+ direction: "column",
5148
+ alignItems: "stretch",
5149
+ children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
5150
+ },
5151
+ field.name
5152
+ );
5153
+ }) }, gridRowIndex)) })
5154
+ },
5155
+ index2
5156
+ );
5157
+ }) });
5158
+ };
5159
+ const NonRepeatableComponent = ({
5160
+ attribute,
5161
+ name: name2,
5162
+ children,
5163
+ layout
5164
+ }) => {
5165
+ const { formatMessage } = reactIntl.useIntl();
5166
+ const { value } = strapiAdmin.useField(name2);
5167
+ const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
5168
+ const isNested = level > 0;
5169
+ return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
5170
+ designSystem.Box,
5171
+ {
5172
+ background: "neutral100",
5173
+ paddingLeft: 6,
5174
+ paddingRight: 6,
5175
+ paddingTop: 6,
5176
+ paddingBottom: 6,
5177
+ hasRadius: isNested,
5178
+ borderColor: isNested ? "neutral200" : void 0,
5179
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
5180
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5181
+ const completeFieldName = `${name2}.${field.name}`;
5182
+ const translatedLabel = formatMessage({
5183
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5184
+ defaultMessage: field.label
5185
+ });
5186
+ return /* @__PURE__ */ jsxRuntime.jsx(
5187
+ ResponsiveGridItem,
5188
+ {
5189
+ col: size,
5190
+ s: 12,
5191
+ xs: 12,
5192
+ direction: "column",
5193
+ alignItems: "stretch",
5194
+ children: children({ ...field, label: translatedLabel, name: completeFieldName })
5195
+ },
5196
+ completeFieldName
5197
+ );
5198
+ }) }, index2);
5199
+ }) })
5200
+ }
5201
+ ) });
5202
+ };
5203
+ const RepeatableComponent = ({
5204
+ attribute,
5205
+ disabled,
5206
+ name: name2,
5207
+ mainField,
5208
+ children,
5209
+ layout
5210
+ }) => {
5211
+ const { toggleNotification } = strapiAdmin.useNotification();
5212
+ const { formatMessage } = reactIntl.useIntl();
5213
+ const { search: searchString } = reactRouterDom.useLocation();
5214
+ const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
5215
+ const { components } = index.useDoc();
5216
+ const {
5217
+ value = [],
5218
+ error,
5219
+ rawError
5220
+ } = strapiAdmin.useField(name2);
5221
+ const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
5222
+ const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
5223
+ const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
5224
+ const { max = Infinity } = attribute;
5225
+ const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
5226
+ const [liveText, setLiveText] = React__namespace.useState("");
5227
+ React__namespace.useEffect(() => {
5228
+ const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
5229
+ const hasNestedValue = value && Array.isArray(value) && value.length > 0;
5230
+ if (hasNestedErrors && hasNestedValue) {
5231
+ const errorOpenItems = rawError.map((_, idx) => {
5232
+ return value[idx] ? value[idx].__temp_key__ : null;
5233
+ }).filter((value2) => !!value2);
5234
+ if (errorOpenItems && errorOpenItems.length > 0) {
5235
+ setCollapseToOpen((collapseToOpen2) => {
5236
+ if (!errorOpenItems.includes(collapseToOpen2)) {
5237
+ return errorOpenItems[0];
5238
+ }
5239
+ return collapseToOpen2;
5240
+ });
5241
+ }
4697
5242
  }
4698
- return /* @__PURE__ */ jsxRuntime.jsx(
4699
- strapiAdmin.InputRenderer,
4700
- {
4701
- ...props,
4702
- hint,
4703
- type: props.attribute.customField,
4704
- disabled: fieldIsDisabled
5243
+ }, [rawError, value]);
5244
+ const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
5245
+ if (search.has("field")) {
5246
+ const fieldParam = search.get("field");
5247
+ if (!fieldParam) {
5248
+ return void 0;
5249
+ }
5250
+ const [, path] = fieldParam.split(`${name2}.`);
5251
+ if (objects.getIn(value, path, void 0) !== void 0) {
5252
+ const [subpath] = path.split(".");
5253
+ return objects.getIn(value, subpath, void 0)?.__temp_key__;
4705
5254
  }
5255
+ }
5256
+ return void 0;
5257
+ }, [search, name2, value]);
5258
+ const prevValue = usePrev.usePrev(value);
5259
+ React__namespace.useEffect(() => {
5260
+ if (prevValue && prevValue.length < value.length) {
5261
+ setCollapseToOpen(value[value.length - 1].__temp_key__);
5262
+ }
5263
+ }, [value, prevValue]);
5264
+ React__namespace.useEffect(() => {
5265
+ if (typeof componentTmpKeyWithFocussedField === "string") {
5266
+ setCollapseToOpen(componentTmpKeyWithFocussedField);
5267
+ }
5268
+ }, [componentTmpKeyWithFocussedField]);
5269
+ const toggleCollapses = () => {
5270
+ setCollapseToOpen("");
5271
+ };
5272
+ const handleClick = () => {
5273
+ if (value.length < max) {
5274
+ const schema = components[attribute.component];
5275
+ const form = index.createDefaultForm(schema, components);
5276
+ const data = index.transformDocument(schema, components)(form);
5277
+ addFieldRow(name2, data);
5278
+ } else if (value.length >= max) {
5279
+ toggleNotification({
5280
+ type: "info",
5281
+ message: formatMessage({
5282
+ id: index.getTranslation("components.notification.info.maximum-requirement")
5283
+ })
5284
+ });
5285
+ }
5286
+ };
5287
+ const handleMoveComponentField = (newIndex, currentIndex) => {
5288
+ setLiveText(
5289
+ formatMessage(
5290
+ {
5291
+ id: index.getTranslation("dnd.reorder"),
5292
+ defaultMessage: "{item}, moved. New position in list: {position}."
5293
+ },
5294
+ {
5295
+ item: `${name2}.${currentIndex}`,
5296
+ position: getItemPos(newIndex)
5297
+ }
5298
+ )
4706
5299
  );
4707
- }
4708
- const addedInputTypes = Object.keys(fields);
4709
- if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4710
- const CustomInput = fields[props.type];
4711
- return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4712
- }
4713
- switch (props.type) {
4714
- case "blocks":
4715
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4716
- case "component":
4717
- return /* @__PURE__ */ jsxRuntime.jsx(
4718
- MemoizedComponentInput,
5300
+ moveFieldRow(name2, currentIndex, newIndex);
5301
+ };
5302
+ const handleValueChange = (key) => {
5303
+ setCollapseToOpen(key);
5304
+ };
5305
+ const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
5306
+ const handleCancel = (index$1) => {
5307
+ setLiveText(
5308
+ formatMessage(
4719
5309
  {
4720
- ...props,
4721
- hint,
4722
- layout: components[props.attribute.component].layout,
4723
- disabled: fieldIsDisabled,
4724
- children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
5310
+ id: index.getTranslation("dnd.cancel-item"),
5311
+ defaultMessage: "{item}, dropped. Re-order cancelled."
5312
+ },
5313
+ {
5314
+ item: `${name2}.${index$1}`
4725
5315
  }
4726
- );
4727
- case "dynamiczone":
4728
- return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
4729
- case "relation":
4730
- return /* @__PURE__ */ jsxRuntime.jsx(Relations.MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
4731
- case "richtext":
4732
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4733
- case "uid":
4734
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4735
- case "enumeration":
4736
- return /* @__PURE__ */ jsxRuntime.jsx(
4737
- strapiAdmin.InputRenderer,
5316
+ )
5317
+ );
5318
+ };
5319
+ const handleGrabItem = (index$1) => {
5320
+ setLiveText(
5321
+ formatMessage(
4738
5322
  {
4739
- ...props,
4740
- hint,
4741
- options: props.attribute.enum.map((value) => ({ value })),
4742
- type: props.customField ? "custom-field" : props.type,
4743
- disabled: fieldIsDisabled
5323
+ id: index.getTranslation("dnd.grab-item"),
5324
+ defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
5325
+ },
5326
+ {
5327
+ item: `${name2}.${index$1}`,
5328
+ position: getItemPos(index$1)
4744
5329
  }
4745
- );
4746
- default:
4747
- const { unique: _unique, mainField: _mainField, ...restProps } = props;
4748
- return /* @__PURE__ */ jsxRuntime.jsx(
4749
- strapiAdmin.InputRenderer,
5330
+ )
5331
+ );
5332
+ };
5333
+ const handleDropItem = (index$1) => {
5334
+ setLiveText(
5335
+ formatMessage(
4750
5336
  {
4751
- ...restProps,
4752
- hint,
4753
- type: props.customField ? "custom-field" : props.type,
4754
- disabled: fieldIsDisabled
5337
+ id: index.getTranslation("dnd.drop-item"),
5338
+ defaultMessage: `{item}, dropped. Final position in list: {position}.`
5339
+ },
5340
+ {
5341
+ item: `${name2}.${index$1}`,
5342
+ position: getItemPos(index$1)
4755
5343
  }
4756
- );
5344
+ )
5345
+ );
5346
+ };
5347
+ const ariaDescriptionId = React__namespace.useId();
5348
+ const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
5349
+ if (value.length === 0) {
5350
+ return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
4757
5351
  }
5352
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
5353
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5354
+ id: index.getTranslation("dnd.instructions"),
5355
+ defaultMessage: `Press spacebar to grab and re-order`
5356
+ }) }),
5357
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5358
+ /* @__PURE__ */ jsxRuntime.jsxs(
5359
+ AccordionRoot,
5360
+ {
5361
+ $error: error,
5362
+ value: collapseToOpen,
5363
+ onValueChange: handleValueChange,
5364
+ "aria-describedby": ariaDescriptionId,
5365
+ children: [
5366
+ value.map(({ __temp_key__: key, id }, index2) => {
5367
+ const nameWithIndex = `${name2}.${index2}`;
5368
+ return /* @__PURE__ */ jsxRuntime.jsx(
5369
+ Relations.ComponentProvider,
5370
+ {
5371
+ id,
5372
+ uid: attribute.component,
5373
+ level: level + 1,
5374
+ type: "repeatable",
5375
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5376
+ Component,
5377
+ {
5378
+ disabled,
5379
+ name: nameWithIndex,
5380
+ attribute,
5381
+ index: index2,
5382
+ mainField,
5383
+ onMoveItem: handleMoveComponentField,
5384
+ onDeleteComponent: () => {
5385
+ removeFieldRow(name2, index2);
5386
+ toggleCollapses();
5387
+ },
5388
+ toggleCollapses,
5389
+ onCancel: handleCancel,
5390
+ onDropItem: handleDropItem,
5391
+ onGrabItem: handleGrabItem,
5392
+ __temp_key__: key,
5393
+ children: layout.map((row, index22) => {
5394
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5395
+ const completeFieldName = `${nameWithIndex}.${field.name}`;
5396
+ const translatedLabel = formatMessage({
5397
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5398
+ defaultMessage: field.label
5399
+ });
5400
+ return /* @__PURE__ */ jsxRuntime.jsx(
5401
+ ResponsiveGridItem,
5402
+ {
5403
+ col: size,
5404
+ s: 12,
5405
+ xs: 12,
5406
+ direction: "column",
5407
+ alignItems: "stretch",
5408
+ children: children({
5409
+ ...field,
5410
+ label: translatedLabel,
5411
+ name: completeFieldName
5412
+ })
5413
+ },
5414
+ completeFieldName
5415
+ );
5416
+ }) }, index22);
5417
+ })
5418
+ }
5419
+ )
5420
+ },
5421
+ key
5422
+ );
5423
+ }),
5424
+ /* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
5425
+ id: index.getTranslation("containers.EditView.add.new-entry"),
5426
+ defaultMessage: "Add an entry"
5427
+ }) })
5428
+ ]
5429
+ }
5430
+ )
5431
+ ] });
4758
5432
  };
4759
- const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
4760
- const useFieldHint = (hint = void 0, attribute) => {
4761
- const { formatMessage } = reactIntl.useIntl();
4762
- const { maximum, minimum } = getMinMax(attribute);
4763
- if (!maximum && !minimum) {
4764
- return hint;
4765
- }
4766
- const units = !["biginteger", "integer", "number"].includes(attribute.type) ? formatMessage(
4767
- {
4768
- id: "content-manager.form.Input.hint.character.unit",
4769
- defaultMessage: "{maxValue, plural, one { character} other { characters}}"
4770
- },
4771
- {
4772
- maxValue: Math.max(minimum || 0, maximum || 0)
4773
- }
4774
- ) : null;
4775
- const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
4776
- return formatMessage(
4777
- {
4778
- id: "content-manager.form.Input.hint.text",
4779
- defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
4780
- },
4781
- {
4782
- min: minimum,
4783
- max: maximum,
4784
- description: hint,
4785
- unit: units,
4786
- divider: hasMinAndMax ? formatMessage({
4787
- id: "content-manager.form.Input.hint.minMaxDivider",
4788
- defaultMessage: " / "
4789
- }) : null,
4790
- br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
5433
+ const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
5434
+ border: 1px solid
5435
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
5436
+ `;
5437
+ const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
5438
+ width: 100%;
5439
+ display: flex;
5440
+ justify-content: center;
5441
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
5442
+ padding-inline: ${(props) => props.theme.spaces[6]};
5443
+ padding-block: ${(props) => props.theme.spaces[3]};
5444
+
5445
+ &:not([disabled]) {
5446
+ cursor: pointer;
5447
+
5448
+ &:hover {
5449
+ background-color: ${(props) => props.theme.colors.primary100};
4791
5450
  }
4792
- );
4793
- };
4794
- const getMinMax = (attribute) => {
4795
- if ("min" in attribute || "max" in attribute) {
4796
- return {
4797
- maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
4798
- minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
4799
- };
4800
- } else if ("maxLength" in attribute || "minLength" in attribute) {
4801
- return { maximum: attribute.maxLength, minimum: attribute.minLength };
4802
- } else {
4803
- return { maximum: void 0, minimum: void 0 };
4804
5451
  }
4805
- };
4806
- const MemoizedInputRenderer = React.memo(InputRenderer);
4807
- const DynamicComponent = ({
4808
- componentUid,
5452
+
5453
+ span {
5454
+ font-weight: 600;
5455
+ font-size: 1.4rem;
5456
+ line-height: 2.4rem;
5457
+ }
5458
+
5459
+ @media (prefers-reduced-motion: no-preference) {
5460
+ transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
5461
+ }
5462
+ `;
5463
+ const Component = ({
4809
5464
  disabled,
4810
5465
  index: index$1,
4811
5466
  name: name2,
4812
- onRemoveComponentClick,
4813
- onMoveComponent,
4814
- onGrabItem,
4815
- onDropItem,
4816
- onCancel,
4817
- dynamicComponentsByCategory = {},
4818
- onAddComponent
5467
+ mainField = {
5468
+ name: "id",
5469
+ type: "integer"
5470
+ },
5471
+ children,
5472
+ onDeleteComponent,
5473
+ toggleCollapses,
5474
+ __temp_key__,
5475
+ ...dragProps
4819
5476
  }) => {
4820
5477
  const { formatMessage } = reactIntl.useIntl();
4821
- const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
4822
- const {
4823
- edit: { components }
4824
- } = index.useDocLayout();
4825
- const title = React__namespace.useMemo(() => {
4826
- const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
4827
- const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
4828
- const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
4829
- const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
4830
- return mainValue;
4831
- }, [componentUid, components, formValues, name2, index$1]);
4832
- const { icon, displayName } = React__namespace.useMemo(() => {
4833
- const [category] = componentUid.split(".");
4834
- const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
4835
- (component) => component.uid === componentUid
4836
- ) ?? { icon: null, displayName: null };
4837
- return { icon: icon2, displayName: displayName2 };
4838
- }, [componentUid, dynamicComponentsByCategory]);
5478
+ const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
5479
+ return objects.getIn(state.values, [...name2.split("."), mainField.name]);
5480
+ });
5481
+ const accordionRef = React__namespace.useRef(null);
5482
+ const componentKey = name2.split(".").slice(0, -1).join(".");
4839
5483
  const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
4840
- type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
5484
+ type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
4841
5485
  index: index$1,
4842
5486
  item: {
4843
5487
  index: index$1,
4844
- displayedValue: `${displayName} ${title}`,
4845
- icon
5488
+ displayedValue: displayValue
4846
5489
  },
4847
- onMoveItem: onMoveComponent,
4848
- onDropItem,
4849
- onGrabItem,
4850
- onCancel
5490
+ onStart() {
5491
+ toggleCollapses();
5492
+ },
5493
+ ...dragProps
4851
5494
  });
4852
5495
  React__namespace.useEffect(() => {
4853
5496
  dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
4854
5497
  }, [dragPreviewRef, index$1]);
4855
- const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
4856
- const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
4857
- /* @__PURE__ */ jsxRuntime.jsx(
4858
- designSystem.IconButton,
4859
- {
4860
- borderWidth: 0,
4861
- label: formatMessage(
5498
+ const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
5499
+ const composedBoxRefs = designSystem.useComposedRefs(
5500
+ boxRef,
5501
+ dropRef
5502
+ );
5503
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
5504
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
5505
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: displayValue }),
5506
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Actions, { children: [
5507
+ /* @__PURE__ */ jsxRuntime.jsx(
5508
+ designSystem.IconButton,
4862
5509
  {
4863
- id: index.getTranslation("components.DynamicZone.delete-label"),
4864
- defaultMessage: "Delete {name}"
4865
- },
4866
- { name: title }
5510
+ variant: "ghost",
5511
+ onClick: onDeleteComponent,
5512
+ label: formatMessage({
5513
+ id: index.getTranslation("containers.Edit.delete"),
5514
+ defaultMessage: "Delete"
5515
+ }),
5516
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5517
+ }
4867
5518
  ),
4868
- onClick: onRemoveComponentClick,
4869
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
4870
- }
4871
- ),
4872
- /* @__PURE__ */ jsxRuntime.jsx(
4873
- designSystem.IconButton,
4874
- {
4875
- borderWidth: 0,
4876
- onClick: (e) => e.stopPropagation(),
4877
- "data-handler-id": handlerId,
4878
- ref: dragRef,
4879
- label: formatMessage({
4880
- id: index.getTranslation("components.DragHandle-label"),
4881
- defaultMessage: "Drag"
4882
- }),
4883
- onKeyDown: handleKeyDown,
4884
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
4885
- }
4886
- ),
4887
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
4888
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
4889
- /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
4890
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: formatMessage({
4891
- id: index.getTranslation("components.DynamicZone.more-actions"),
4892
- defaultMessage: "More actions"
4893
- }) })
4894
- ] }),
4895
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
4896
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
4897
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
4898
- id: index.getTranslation("components.DynamicZone.add-item-above"),
4899
- defaultMessage: "Add component above"
4900
- }) }),
4901
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
4902
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
4903
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
4904
- ] }, category)) })
4905
- ] }),
4906
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
4907
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
4908
- id: index.getTranslation("components.DynamicZone.add-item-below"),
4909
- defaultMessage: "Add component below"
4910
- }) }),
4911
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
4912
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
4913
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
4914
- ] }, category)) })
4915
- ] })
4916
- ] })
4917
- ] })
4918
- ] });
4919
- const accordionTitle = title ? `${displayName} ${title}` : displayName;
4920
- const accordionValue = React__namespace.useId();
4921
- return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
4922
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
4923
- /* @__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: [
4924
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
4925
5519
  /* @__PURE__ */ jsxRuntime.jsx(
4926
- designSystem.Accordion.Trigger,
5520
+ designSystem.IconButton,
4927
5521
  {
4928
- icon: icon && ComponentIcon.COMPONENT_ICONS[icon] ? ComponentIcon.COMPONENT_ICONS[icon] : ComponentIcon.COMPONENT_ICONS.dashboard,
4929
- children: accordionTitle
5522
+ ref: composedAccordionRefs,
5523
+ variant: "ghost",
5524
+ onClick: (e) => e.stopPropagation(),
5525
+ "data-handler-id": handlerId,
5526
+ label: formatMessage({
5527
+ id: index.getTranslation("components.DragHandle-label"),
5528
+ defaultMessage: "Drag"
5529
+ }),
5530
+ onKeyDown: handleKeyDown,
5531
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
4930
5532
  }
4931
- ),
4932
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
4933
- ] }),
4934
- /* @__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, { gap: 4, children: row.map(({ size, ...field }) => {
4935
- const fieldName = `${name2}.${index$1}.${field.name}`;
4936
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: size, s: 12, xs: 12, children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...field, name: fieldName }) }, fieldName);
4937
- }) }, rowInd)) }) }) })
4938
- ] }) }) })
4939
- ] });
4940
- };
4941
- const StyledBox = styledComponents.styled(designSystem.Box)`
4942
- > div:first-child {
4943
- box-shadow: ${({ theme }) => theme.shadows.tableShadow};
4944
- }
4945
- `;
4946
- const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
4947
- border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
4948
- `;
4949
- const Rectangle = styledComponents.styled(designSystem.Box)`
4950
- width: ${({ theme }) => theme.spaces[2]};
4951
- height: ${({ theme }) => theme.spaces[4]};
4952
- `;
4953
- const Preview = styledComponents.styled.span`
4954
- display: block;
4955
- background-color: ${({ theme }) => theme.colors.primary100};
4956
- outline: 1px dashed ${({ theme }) => theme.colors.primary500};
4957
- outline-offset: -1px;
4958
- padding: ${({ theme }) => theme.spaces[6]};
4959
- `;
4960
- const ComponentContainer = styledComponents.styled(designSystem.Box)`
4961
- list-style: none;
4962
- padding: 0;
4963
- margin: 0;
4964
- `;
4965
- const DynamicZoneLabel = ({
4966
- hint,
4967
- label,
4968
- labelAction,
4969
- name: name2,
4970
- numberOfComponents = 0,
4971
- required
4972
- }) => {
4973
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
4974
- designSystem.Box,
4975
- {
4976
- paddingTop: 3,
4977
- paddingBottom: 3,
4978
- paddingRight: 4,
4979
- paddingLeft: 4,
4980
- borderRadius: "26px",
4981
- background: "neutral0",
4982
- shadow: "filterShadow",
4983
- color: "neutral500",
4984
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
4985
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
4986
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
4987
- label || name2,
4988
- " "
4989
- ] }),
4990
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
4991
- "(",
4992
- numberOfComponents,
4993
- ")"
4994
- ] }),
4995
- required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
4996
- labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
4997
- ] }),
4998
- 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 }) })
5533
+ )
4999
5534
  ] })
5000
- }
5001
- ) });
5535
+ ] }),
5536
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
5537
+ designSystem.Flex,
5538
+ {
5539
+ direction: "column",
5540
+ alignItems: "stretch",
5541
+ background: "neutral100",
5542
+ padding: 6,
5543
+ gap: 6,
5544
+ children
5545
+ }
5546
+ ) })
5547
+ ] }) });
5002
5548
  };
5003
- const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
5004
- "DynamicZone",
5005
- {
5006
- isInDynamicZone: false
5007
- }
5008
- );
5009
- const DynamicZone = ({
5010
- attribute,
5011
- disabled: disabledProp,
5012
- hint,
5549
+ const Preview = () => {
5550
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
5551
+ };
5552
+ const StyledSpan = styledComponents.styled(designSystem.Box)`
5553
+ display: block;
5554
+ outline: 1px dashed ${({ theme }) => theme.colors.primary500};
5555
+ outline-offset: -1px;
5556
+ `;
5557
+ const ComponentInput = ({
5013
5558
  label,
5014
- labelAction,
5559
+ required,
5015
5560
  name: name2,
5016
- required = false
5561
+ attribute,
5562
+ disabled,
5563
+ labelAction,
5564
+ ...props
5017
5565
  }) => {
5018
- const { max = Infinity, min = -Infinity } = attribute ?? {};
5019
- const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
5020
- const [liveText, setLiveText] = React__namespace.useState("");
5021
- const { components, isLoading } = index.useDoc();
5022
- const disabled = disabledProp || isLoading;
5023
- const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
5024
- "DynamicZone",
5025
- ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
5026
- addFieldRow: addFieldRow2,
5027
- removeFieldRow: removeFieldRow2,
5028
- moveFieldRow: moveFieldRow2
5029
- })
5030
- );
5031
- const { value = [], error } = strapiAdmin.useField(name2);
5032
- const dynamicComponentsByCategory = React__namespace.useMemo(() => {
5033
- return attribute.components.reduce((acc, componentUid) => {
5034
- const { category, info } = components[componentUid] ?? { info: {} };
5035
- const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
5036
- if (!acc[category]) {
5037
- acc[category] = [];
5038
- }
5039
- acc[category] = [...acc[category], component];
5040
- return acc;
5041
- }, {});
5042
- }, [attribute.components, components]);
5043
5566
  const { formatMessage } = reactIntl.useIntl();
5044
- const { toggleNotification } = strapiAdmin.useNotification();
5045
- const dynamicDisplayedComponentsLength = value.length;
5046
- const handleAddComponent = (uid, position) => {
5047
- setAddComponentIsOpen(false);
5048
- const schema = components[uid];
5049
- const form = createDefaultForm(schema, components);
5050
- const transformations = pipe__default.default(transformDocument(schema, components), (data2) => ({
5051
- ...data2,
5052
- __component: uid
5053
- }));
5054
- const data = transformations(form);
5055
- addFieldRow(name2, data, position);
5056
- };
5057
- const handleClickOpenPicker = () => {
5058
- if (dynamicDisplayedComponentsLength < max) {
5059
- setAddComponentIsOpen((prev) => !prev);
5060
- } else {
5061
- toggleNotification({
5062
- type: "info",
5063
- message: formatMessage({
5064
- id: index.getTranslation("components.notification.info.maximum-requirement")
5065
- })
5066
- });
5067
- }
5068
- };
5069
- const handleMoveComponent = (newIndex, currentIndex) => {
5070
- setLiveText(
5071
- formatMessage(
5072
- {
5073
- id: index.getTranslation("dnd.reorder"),
5074
- defaultMessage: "{item}, moved. New position in list: {position}."
5075
- },
5076
- {
5077
- item: `${name2}.${currentIndex}`,
5078
- position: getItemPos(newIndex)
5079
- }
5080
- )
5081
- );
5082
- moveFieldRow(name2, currentIndex, newIndex);
5083
- };
5084
- const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
5085
- const handleCancel = (index$1) => {
5086
- setLiveText(
5087
- formatMessage(
5088
- {
5089
- id: index.getTranslation("dnd.cancel-item"),
5090
- defaultMessage: "{item}, dropped. Re-order cancelled."
5091
- },
5092
- {
5093
- item: `${name2}.${index$1}`
5094
- }
5095
- )
5096
- );
5097
- };
5098
- const handleGrabItem = (index$1) => {
5099
- setLiveText(
5100
- formatMessage(
5101
- {
5102
- id: index.getTranslation("dnd.grab-item"),
5103
- defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
5104
- },
5105
- {
5106
- item: `${name2}.${index$1}`,
5107
- position: getItemPos(index$1)
5108
- }
5109
- )
5110
- );
5567
+ const field = strapiAdmin.useField(name2);
5568
+ const showResetComponent = !attribute.repeatable && field.value && !disabled;
5569
+ const { components } = index.useDoc();
5570
+ const handleInitialisationClick = () => {
5571
+ const schema = components[attribute.component];
5572
+ const form = index.createDefaultForm(schema, components);
5573
+ const data = index.transformDocument(schema, components)(form);
5574
+ field.onChange(name2, data);
5111
5575
  };
5112
- const handleDropItem = (index$1) => {
5113
- setLiveText(
5114
- formatMessage(
5115
- {
5116
- id: index.getTranslation("dnd.drop-item"),
5117
- defaultMessage: `{item}, dropped. Final position in list: {position}.`
5118
- },
5576
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
5577
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
5578
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
5579
+ label,
5580
+ attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5581
+ " (",
5582
+ Array.isArray(field.value) ? field.value.length : 0,
5583
+ ")"
5584
+ ] })
5585
+ ] }),
5586
+ showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
5587
+ designSystem.IconButton,
5119
5588
  {
5120
- item: `${name2}.${index$1}`,
5121
- position: getItemPos(index$1)
5589
+ label: formatMessage({
5590
+ id: index.getTranslation("components.reset-entry"),
5591
+ defaultMessage: "Reset Entry"
5592
+ }),
5593
+ variant: "ghost",
5594
+ onClick: () => {
5595
+ field.onChange(name2, null);
5596
+ },
5597
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5122
5598
  }
5123
5599
  )
5124
- );
5125
- };
5126
- const handleRemoveComponent = (name22, currentIndex) => () => {
5127
- removeFieldRow(name22, currentIndex);
5128
- };
5129
- const hasError = error !== void 0 || dynamicDisplayedComponentsLength < min || dynamicDisplayedComponentsLength > max;
5130
- const renderButtonLabel = () => {
5131
- if (addComponentIsOpen) {
5132
- return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
5133
- }
5134
- if (hasError && dynamicDisplayedComponentsLength > max) {
5135
- return formatMessage(
5136
- {
5137
- id: index.getTranslation(`components.DynamicZone.extra-components`),
5138
- defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
5139
- },
5140
- {
5141
- number: dynamicDisplayedComponentsLength - max
5142
- }
5143
- );
5144
- }
5145
- if (hasError && dynamicDisplayedComponentsLength < min) {
5146
- return formatMessage(
5147
- {
5148
- id: index.getTranslation(`components.DynamicZone.missing-components`),
5149
- defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
5150
- },
5151
- { number: min - dynamicDisplayedComponentsLength }
5152
- );
5153
- }
5154
- return formatMessage(
5155
- {
5156
- id: index.getTranslation("components.DynamicZone.add-component"),
5157
- defaultMessage: "Add a component to {componentName}"
5158
- },
5159
- { componentName: label || name2 }
5160
- );
5161
- };
5162
- const level = Relations.useComponent("DynamicZone", (state) => state.level);
5163
- const ariaDescriptionId = React__namespace.useId();
5164
- return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
5165
- dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
5166
- /* @__PURE__ */ jsxRuntime.jsx(
5167
- DynamicZoneLabel,
5168
- {
5169
- hint,
5170
- label,
5171
- labelAction,
5172
- name: name2,
5173
- numberOfComponents: dynamicDisplayedComponentsLength,
5174
- required
5175
- }
5176
- ),
5177
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5178
- id: index.getTranslation("dnd.instructions"),
5179
- defaultMessage: `Press spacebar to grab and re-order`
5180
- }) }),
5181
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5182
- /* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
5183
- Relations.ComponentProvider,
5184
- {
5185
- level: level + 1,
5186
- uid: field.__component,
5187
- id: field.id,
5188
- type: "dynamiczone",
5189
- children: /* @__PURE__ */ jsxRuntime.jsx(
5190
- DynamicComponent,
5191
- {
5192
- disabled,
5193
- name: name2,
5194
- index: index2,
5195
- componentUid: field.__component,
5196
- onMoveComponent: handleMoveComponent,
5197
- onRemoveComponentClick: handleRemoveComponent(name2, index2),
5198
- onCancel: handleCancel,
5199
- onDropItem: handleDropItem,
5200
- onGrabItem: handleGrabItem,
5201
- onAddComponent: handleAddComponent,
5202
- dynamicComponentsByCategory
5203
- }
5204
- )
5205
- },
5206
- field.__temp_key__
5207
- )) })
5208
5600
  ] }),
5209
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
5210
- AddComponentButton,
5211
- {
5212
- hasError,
5213
- isDisabled: disabled,
5214
- isOpen: addComponentIsOpen,
5215
- onClick: handleClickOpenPicker,
5216
- children: renderButtonLabel()
5217
- }
5218
- ) }),
5219
- /* @__PURE__ */ jsxRuntime.jsx(
5220
- ComponentPicker,
5221
- {
5222
- dynamicComponentsByCategory,
5223
- isOpen: addComponentIsOpen,
5224
- onClickAddComponent: handleAddComponent
5225
- }
5226
- )
5227
- ] }) });
5601
+ !attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
5602
+ !attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
5603
+ attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
5604
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
5605
+ ] });
5228
5606
  };
5607
+ const MemoizedComponentInput = React__namespace.memo(ComponentInput);
5229
5608
  exports.DynamicZone = DynamicZone;
5609
+ exports.FormLayout = FormLayout;
5230
5610
  exports.MemoizedBlocksInput = MemoizedBlocksInput;
5231
5611
  exports.MemoizedComponentInput = MemoizedComponentInput;
5232
- exports.MemoizedInputRenderer = MemoizedInputRenderer;
5233
5612
  exports.MemoizedUIDInput = MemoizedUIDInput;
5234
5613
  exports.MemoizedWysiwyg = MemoizedWysiwyg;
5235
5614
  exports.NotAllowedInput = NotAllowedInput;
5236
- exports.createDefaultForm = createDefaultForm;
5237
- exports.prepareTempKeys = prepareTempKeys;
5238
- exports.removeFieldsThatDontExistOnSchema = removeFieldsThatDontExistOnSchema;
5239
- exports.transformDocument = transformDocument;
5240
5615
  exports.useDynamicZone = useDynamicZone;
5241
5616
  exports.useFieldHint = useFieldHint;
5242
5617
  exports.useLazyComponents = useLazyComponents;
5243
- //# sourceMappingURL=Field-Dh1yZyqy.js.map
5618
+ //# sourceMappingURL=Input-CDHKQd7o.js.map