@strapi/content-manager 0.0.0-experimental.17b4116f461a49b8ce5386f7c8d79c511d40fb3b → 0.0.0-experimental.19d775295eb622de3e659110caf22fcd2cd5d10d

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 (264) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/{CardDragPreview-DSVYodBX.js → CardDragPreview-C0QyJgRA.js} +10 -14
  3. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
  4. package/dist/_chunks/{CardDragPreview-ikSG4M46.mjs → CardDragPreview-DOxamsuj.mjs} +7 -9
  5. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
  6. package/dist/_chunks/{ComponentConfigurationPage-DjQBdcKF.mjs → ComponentConfigurationPage-B_99pmC0.mjs} +4 -4
  7. package/dist/_chunks/{ComponentConfigurationPage-DjQBdcKF.mjs.map → ComponentConfigurationPage-B_99pmC0.mjs.map} +1 -1
  8. package/dist/_chunks/{ComponentConfigurationPage-2iOVVhqV.js → ComponentConfigurationPage-NeMPjY5M.js} +5 -6
  9. package/dist/_chunks/{ComponentConfigurationPage-2iOVVhqV.js.map → ComponentConfigurationPage-NeMPjY5M.js.map} +1 -1
  10. package/dist/_chunks/{ComponentIcon-BBQsYCVn.js → ComponentIcon-CRbtQEUV.js} +9 -4
  11. package/dist/_chunks/ComponentIcon-CRbtQEUV.js.map +1 -0
  12. package/dist/_chunks/{ComponentIcon-BOFnK76n.mjs → ComponentIcon-u4bIXTFY.mjs} +9 -3
  13. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
  14. package/dist/_chunks/{EditConfigurationPage-BoBb-DLH.mjs → EditConfigurationPage-B0kNlNoj.mjs} +4 -4
  15. package/dist/_chunks/{EditConfigurationPage-BoBb-DLH.mjs.map → EditConfigurationPage-B0kNlNoj.mjs.map} +1 -1
  16. package/dist/_chunks/{EditConfigurationPage-B7dw5_cS.js → EditConfigurationPage-n7_xHayb.js} +5 -6
  17. package/dist/_chunks/{EditConfigurationPage-B7dw5_cS.js.map → EditConfigurationPage-n7_xHayb.js.map} +1 -1
  18. package/dist/_chunks/EditViewPage-BT7Achc-.js +209 -0
  19. package/dist/_chunks/EditViewPage-BT7Achc-.js.map +1 -0
  20. package/dist/_chunks/EditViewPage-DYXZs4_2.mjs +191 -0
  21. package/dist/_chunks/EditViewPage-DYXZs4_2.mjs.map +1 -0
  22. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  23. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  24. package/dist/_chunks/{Form-CQ67ZifP.js → Form-BRmk2Dp3.js} +68 -49
  25. package/dist/_chunks/Form-BRmk2Dp3.js.map +1 -0
  26. package/dist/_chunks/{Form-Jgh5hGTu.mjs → Form-D3paRF1F.mjs} +67 -46
  27. package/dist/_chunks/Form-D3paRF1F.mjs.map +1 -0
  28. package/dist/_chunks/{History-BLEnudTX.js → History-BQpDoOu8.js} +211 -148
  29. package/dist/_chunks/History-BQpDoOu8.js.map +1 -0
  30. package/dist/_chunks/{History-DKhZAPcK.mjs → History-CzQbTOwa.mjs} +204 -139
  31. package/dist/_chunks/History-CzQbTOwa.mjs.map +1 -0
  32. package/dist/_chunks/{Field-kVFO4ZKB.mjs → Input-ww3KFYZr.mjs} +1996 -1730
  33. package/dist/_chunks/Input-ww3KFYZr.mjs.map +1 -0
  34. package/dist/_chunks/{Field-kq1c2TF1.js → Input-yM6HnyQa.js} +2035 -1770
  35. package/dist/_chunks/Input-yM6HnyQa.js.map +1 -0
  36. package/dist/_chunks/{ListConfigurationPage-Zso_LUjn.js → ListConfigurationPage-B6NsS-0m.js} +72 -63
  37. package/dist/_chunks/ListConfigurationPage-B6NsS-0m.js.map +1 -0
  38. package/dist/_chunks/{ListConfigurationPage-nrXcxNYi.mjs → ListConfigurationPage-Bbw8w5cS.mjs} +68 -57
  39. package/dist/_chunks/ListConfigurationPage-Bbw8w5cS.mjs.map +1 -0
  40. package/dist/_chunks/{ListViewPage-ChhYmA-L.mjs → ListViewPage-DnOP55pM.mjs} +179 -160
  41. package/dist/_chunks/ListViewPage-DnOP55pM.mjs.map +1 -0
  42. package/dist/_chunks/{ListViewPage-DsaOakWQ.js → ListViewPage-Dt8OUTwO.js} +183 -165
  43. package/dist/_chunks/ListViewPage-Dt8OUTwO.js.map +1 -0
  44. package/dist/_chunks/{NoContentTypePage-BrdFcN33.mjs → NoContentTypePage-CXKXHNMa.mjs} +3 -3
  45. package/dist/_chunks/NoContentTypePage-CXKXHNMa.mjs.map +1 -0
  46. package/dist/_chunks/{NoContentTypePage-DPCuS9Y1.js → NoContentTypePage-Dgm-uj-6.js} +3 -3
  47. package/dist/_chunks/NoContentTypePage-Dgm-uj-6.js.map +1 -0
  48. package/dist/_chunks/{NoPermissionsPage-DdyOfdKb.js → NoPermissionsPage-CLbU5SOt.js} +2 -2
  49. package/dist/_chunks/{NoPermissionsPage-DdyOfdKb.js.map → NoPermissionsPage-CLbU5SOt.js.map} +1 -1
  50. package/dist/_chunks/{NoPermissionsPage-B9dqrtTy.mjs → NoPermissionsPage-kaj1rPiW.mjs} +2 -2
  51. package/dist/_chunks/{NoPermissionsPage-B9dqrtTy.mjs.map → NoPermissionsPage-kaj1rPiW.mjs.map} +1 -1
  52. package/dist/_chunks/Preview-Bieh13Ro.mjs +287 -0
  53. package/dist/_chunks/Preview-Bieh13Ro.mjs.map +1 -0
  54. package/dist/_chunks/Preview-CbXHXqBg.js +305 -0
  55. package/dist/_chunks/Preview-CbXHXqBg.js.map +1 -0
  56. package/dist/_chunks/{Relations-DjFiYd7-.mjs → Relations-7rWJcZ3_.mjs} +138 -94
  57. package/dist/_chunks/Relations-7rWJcZ3_.mjs.map +1 -0
  58. package/dist/_chunks/{Relations-CY8Isqdu.js → Relations-CvifV6Y6.js} +142 -100
  59. package/dist/_chunks/Relations-CvifV6Y6.js.map +1 -0
  60. package/dist/_chunks/{en-C-V1_90f.js → en-BR48D_RH.js} +45 -18
  61. package/dist/_chunks/{en-C-V1_90f.js.map → en-BR48D_RH.js.map} +1 -1
  62. package/dist/_chunks/{en-MBPul9Su.mjs → en-D65uIF6Y.mjs} +45 -18
  63. package/dist/_chunks/{en-MBPul9Su.mjs.map → en-D65uIF6Y.mjs.map} +1 -1
  64. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  65. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  66. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  67. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  68. package/dist/_chunks/{fr-B7kGGg3E.js → fr-C43IbhA_.js} +16 -3
  69. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-C43IbhA_.js.map} +1 -1
  70. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr-DBseuRuB.mjs} +16 -3
  71. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr-DBseuRuB.mjs.map} +1 -1
  72. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  73. package/dist/_chunks/{index-CAc9yTnx.mjs → index-BH2JnYpF.mjs} +2302 -995
  74. package/dist/_chunks/index-BH2JnYpF.mjs.map +1 -0
  75. package/dist/_chunks/{index-DNa1J4HE.js → index-DkJQjlak.js} +2273 -967
  76. package/dist/_chunks/index-DkJQjlak.js.map +1 -0
  77. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  78. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  79. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  80. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  81. package/dist/_chunks/{layout-BqtLA6Lb.js → layout-4BqLFW_b.js} +47 -32
  82. package/dist/_chunks/layout-4BqLFW_b.js.map +1 -0
  83. package/dist/_chunks/{layout-CXsHbc3E.mjs → layout-bbOlPwLA.mjs} +46 -28
  84. package/dist/_chunks/layout-bbOlPwLA.mjs.map +1 -0
  85. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  86. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  87. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  88. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  89. package/dist/_chunks/{relations-mMFEcZRq.mjs → relations-HsflnFpO.mjs} +6 -7
  90. package/dist/_chunks/relations-HsflnFpO.mjs.map +1 -0
  91. package/dist/_chunks/{relations-BHY_KDJ_.js → relations-Yc0Z6A20.js} +6 -7
  92. package/dist/_chunks/relations-Yc0Z6A20.js.map +1 -0
  93. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  94. package/dist/_chunks/useDragAndDrop-BMtgCYzL.js.map +1 -0
  95. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  96. package/dist/_chunks/useDragAndDrop-DJ6jqvZN.mjs.map +1 -0
  97. package/dist/_chunks/usePrev-CZGy2Vjf.mjs +29 -0
  98. package/dist/_chunks/usePrev-CZGy2Vjf.mjs.map +1 -0
  99. package/dist/_chunks/usePrev-D5J_2fEu.js +28 -0
  100. package/dist/_chunks/usePrev-D5J_2fEu.js.map +1 -0
  101. package/dist/admin/index.js +4 -1
  102. package/dist/admin/index.js.map +1 -1
  103. package/dist/admin/index.mjs +10 -7
  104. package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
  105. package/dist/admin/src/content-manager.d.ts +7 -5
  106. package/dist/admin/src/exports.d.ts +3 -1
  107. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  108. package/dist/admin/src/history/index.d.ts +3 -0
  109. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  110. package/dist/admin/src/hooks/useDocument.d.ts +54 -9
  111. package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
  112. package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
  113. package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
  114. package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
  115. package/dist/admin/src/index.d.ts +1 -0
  116. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  117. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +12 -5
  118. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
  119. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  120. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  121. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
  122. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
  123. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
  124. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
  125. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
  126. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
  127. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +30 -18
  128. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
  129. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
  130. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +2 -2
  131. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  132. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +16 -53
  133. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
  134. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  135. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
  136. package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
  137. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  138. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  139. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
  140. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  141. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  142. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  143. package/dist/admin/src/preview/index.d.ts +4 -0
  144. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  145. package/dist/admin/src/preview/routes.d.ts +3 -0
  146. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  147. package/dist/admin/src/router.d.ts +1 -1
  148. package/dist/admin/src/services/api.d.ts +2 -3
  149. package/dist/admin/src/services/components.d.ts +2 -2
  150. package/dist/admin/src/services/contentTypes.d.ts +5 -5
  151. package/dist/admin/src/services/documents.d.ts +31 -20
  152. package/dist/admin/src/services/init.d.ts +2 -2
  153. package/dist/admin/src/services/relations.d.ts +3 -3
  154. package/dist/admin/src/services/uid.d.ts +3 -3
  155. package/dist/admin/src/utils/api.d.ts +4 -18
  156. package/dist/admin/src/utils/validation.d.ts +5 -7
  157. package/dist/server/index.js +959 -543
  158. package/dist/server/index.js.map +1 -1
  159. package/dist/server/index.mjs +960 -543
  160. package/dist/server/index.mjs.map +1 -1
  161. package/dist/server/src/bootstrap.d.ts.map +1 -1
  162. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  163. package/dist/server/src/controllers/index.d.ts.map +1 -1
  164. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  165. package/dist/server/src/controllers/single-types.d.ts.map +1 -1
  166. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  167. package/dist/server/src/controllers/utils/metadata.d.ts +23 -0
  168. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
  169. package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
  170. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
  171. package/dist/server/src/controllers/validation/index.d.ts +1 -1
  172. package/dist/server/src/history/controllers/history-version.d.ts +1 -1
  173. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  174. package/dist/server/src/history/services/history.d.ts +3 -3
  175. package/dist/server/src/history/services/history.d.ts.map +1 -1
  176. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  177. package/dist/server/src/history/services/utils.d.ts +8 -12
  178. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  179. package/dist/server/src/index.d.ts +21 -36
  180. package/dist/server/src/index.d.ts.map +1 -1
  181. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  182. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  183. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  184. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  185. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  186. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  187. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  188. package/dist/server/src/preview/index.d.ts +4 -0
  189. package/dist/server/src/preview/index.d.ts.map +1 -0
  190. package/dist/server/src/preview/routes/index.d.ts +8 -0
  191. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  192. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  193. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  194. package/dist/server/src/preview/services/index.d.ts +16 -0
  195. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  196. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  197. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  198. package/dist/server/src/preview/services/preview.d.ts +12 -0
  199. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  200. package/dist/server/src/preview/utils.d.ts +19 -0
  201. package/dist/server/src/preview/utils.d.ts.map +1 -0
  202. package/dist/server/src/register.d.ts.map +1 -1
  203. package/dist/server/src/routes/index.d.ts.map +1 -1
  204. package/dist/server/src/services/document-manager.d.ts +11 -6
  205. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  206. package/dist/server/src/services/document-metadata.d.ts +16 -35
  207. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  208. package/dist/server/src/services/index.d.ts +21 -36
  209. package/dist/server/src/services/index.d.ts.map +1 -1
  210. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  211. package/dist/server/src/services/utils/populate.d.ts +8 -1
  212. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  213. package/dist/server/src/utils/index.d.ts +2 -0
  214. package/dist/server/src/utils/index.d.ts.map +1 -1
  215. package/dist/shared/contracts/collection-types.d.ts +17 -7
  216. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  217. package/dist/shared/contracts/index.d.ts +1 -0
  218. package/dist/shared/contracts/index.d.ts.map +1 -1
  219. package/dist/shared/contracts/preview.d.ts +27 -0
  220. package/dist/shared/contracts/preview.d.ts.map +1 -0
  221. package/dist/shared/contracts/relations.d.ts +2 -2
  222. package/dist/shared/contracts/relations.d.ts.map +1 -1
  223. package/dist/shared/index.js +4 -0
  224. package/dist/shared/index.js.map +1 -1
  225. package/dist/shared/index.mjs +4 -0
  226. package/dist/shared/index.mjs.map +1 -1
  227. package/package.json +22 -22
  228. package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
  229. package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
  230. package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
  231. package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
  232. package/dist/_chunks/EditViewPage-KRG56aCq.js +0 -224
  233. package/dist/_chunks/EditViewPage-KRG56aCq.js.map +0 -1
  234. package/dist/_chunks/EditViewPage-aUnqL-63.mjs +0 -203
  235. package/dist/_chunks/EditViewPage-aUnqL-63.mjs.map +0 -1
  236. package/dist/_chunks/Field-kVFO4ZKB.mjs.map +0 -1
  237. package/dist/_chunks/Field-kq1c2TF1.js.map +0 -1
  238. package/dist/_chunks/Form-CQ67ZifP.js.map +0 -1
  239. package/dist/_chunks/Form-Jgh5hGTu.mjs.map +0 -1
  240. package/dist/_chunks/History-BLEnudTX.js.map +0 -1
  241. package/dist/_chunks/History-DKhZAPcK.mjs.map +0 -1
  242. package/dist/_chunks/ListConfigurationPage-Zso_LUjn.js.map +0 -1
  243. package/dist/_chunks/ListConfigurationPage-nrXcxNYi.mjs.map +0 -1
  244. package/dist/_chunks/ListViewPage-ChhYmA-L.mjs.map +0 -1
  245. package/dist/_chunks/ListViewPage-DsaOakWQ.js.map +0 -1
  246. package/dist/_chunks/NoContentTypePage-BrdFcN33.mjs.map +0 -1
  247. package/dist/_chunks/NoContentTypePage-DPCuS9Y1.js.map +0 -1
  248. package/dist/_chunks/Relations-CY8Isqdu.js.map +0 -1
  249. package/dist/_chunks/Relations-DjFiYd7-.mjs.map +0 -1
  250. package/dist/_chunks/index-CAc9yTnx.mjs.map +0 -1
  251. package/dist/_chunks/index-DNa1J4HE.js.map +0 -1
  252. package/dist/_chunks/layout-BqtLA6Lb.js.map +0 -1
  253. package/dist/_chunks/layout-CXsHbc3E.mjs.map +0 -1
  254. package/dist/_chunks/relations-BHY_KDJ_.js.map +0 -1
  255. package/dist/_chunks/relations-mMFEcZRq.mjs.map +0 -1
  256. package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
  257. package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
  258. package/dist/_chunks/urls-DzZya_gm.js +0 -6
  259. package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
  260. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +0 -1
  261. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +0 -1
  262. package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
  263. package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
  264. package/strapi-server.js +0 -3
@@ -3,23 +3,73 @@ const jsxRuntime = require("react/jsx-runtime");
3
3
  const React = require("react");
4
4
  const strapiAdmin = require("@strapi/admin/strapi-admin");
5
5
  const designSystem = require("@strapi/design-system");
6
- const pipe$1 = require("lodash/fp/pipe");
7
- const reactIntl = require("react-intl");
8
- const index = require("./index-DNa1J4HE.js");
9
- const fractionalIndexing = require("fractional-indexing");
10
- const Relations = require("./Relations-CY8Isqdu.js");
11
6
  const Icons = require("@strapi/icons");
12
- const styled = require("styled-components");
13
- const ComponentIcon = require("./ComponentIcon-BBQsYCVn.js");
14
- const reactDndHtml5Backend = require("react-dnd-html5-backend");
15
- const useDragAndDrop = require("./useDragAndDrop-J0TUUbR6.js");
16
- const objects = require("./objects-gigeqt7s.js");
7
+ const reactIntl = require("react-intl");
8
+ const index = require("./index-DkJQjlak.js");
9
+ const styledComponents = require("styled-components");
17
10
  const slate = require("slate");
18
11
  const slateHistory = require("slate-history");
19
12
  const slateReact = require("slate-react");
20
- const urls = require("./urls-DzZya_gm.js");
13
+ const Prism = require("prismjs");
14
+ require("prismjs/themes/prism-solarizedlight.css");
15
+ require("prismjs/components/prism-asmatmel");
16
+ require("prismjs/components/prism-bash");
17
+ require("prismjs/components/prism-basic");
18
+ require("prismjs/components/prism-c");
19
+ require("prismjs/components/prism-clojure");
20
+ require("prismjs/components/prism-cobol");
21
+ require("prismjs/components/prism-cpp");
22
+ require("prismjs/components/prism-csharp");
23
+ require("prismjs/components/prism-dart");
24
+ require("prismjs/components/prism-docker");
25
+ require("prismjs/components/prism-elixir");
26
+ require("prismjs/components/prism-erlang");
27
+ require("prismjs/components/prism-fortran");
28
+ require("prismjs/components/prism-fsharp");
29
+ require("prismjs/components/prism-go");
30
+ require("prismjs/components/prism-graphql");
31
+ require("prismjs/components/prism-groovy");
32
+ require("prismjs/components/prism-haskell");
33
+ require("prismjs/components/prism-haxe");
34
+ require("prismjs/components/prism-ini");
35
+ require("prismjs/components/prism-java");
36
+ require("prismjs/components/prism-javascript");
37
+ require("prismjs/components/prism-jsx");
38
+ require("prismjs/components/prism-json");
39
+ require("prismjs/components/prism-julia");
40
+ require("prismjs/components/prism-kotlin");
41
+ require("prismjs/components/prism-latex");
42
+ require("prismjs/components/prism-lua");
43
+ require("prismjs/components/prism-markdown");
44
+ require("prismjs/components/prism-matlab");
45
+ require("prismjs/components/prism-makefile");
46
+ require("prismjs/components/prism-objectivec");
47
+ require("prismjs/components/prism-perl");
48
+ require("prismjs/components/prism-php");
49
+ require("prismjs/components/prism-powershell");
50
+ require("prismjs/components/prism-python");
51
+ require("prismjs/components/prism-r");
52
+ require("prismjs/components/prism-ruby");
53
+ require("prismjs/components/prism-rust");
54
+ require("prismjs/components/prism-sas");
55
+ require("prismjs/components/prism-scala");
56
+ require("prismjs/components/prism-scheme");
57
+ require("prismjs/components/prism-sql");
58
+ require("prismjs/components/prism-stata");
59
+ require("prismjs/components/prism-swift");
60
+ require("prismjs/components/prism-typescript");
61
+ require("prismjs/components/prism-tsx");
62
+ require("prismjs/components/prism-vbnet");
63
+ require("prismjs/components/prism-yaml");
64
+ const usePrev = require("./usePrev-D5J_2fEu.js");
65
+ const useDragAndDrop = require("./useDragAndDrop-BMtgCYzL.js");
21
66
  const Toolbar = require("@radix-ui/react-toolbar");
67
+ const reactDndHtml5Backend = require("react-dnd-html5-backend");
22
68
  const reactRouterDom = require("react-router-dom");
69
+ const objects = require("./objects-BcXOv6_9.js");
70
+ const Relations = require("./Relations-CvifV6Y6.js");
71
+ const pipe$1 = require("lodash/fp/pipe");
72
+ const ComponentIcon = require("./ComponentIcon-CRbtQEUV.js");
23
73
  const CodeMirror = require("codemirror5");
24
74
  const sanitizeHtml = require("sanitize-html");
25
75
  const highlight_js = require("highlight.js");
@@ -37,8 +87,7 @@ require("highlight.js/styles/solarized-dark.css");
37
87
  require("codemirror5/addon/display/placeholder");
38
88
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
39
89
  function _interopNamespace(e) {
40
- if (e && e.__esModule)
41
- return e;
90
+ if (e && e.__esModule) return e;
42
91
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
43
92
  if (e) {
44
93
  for (const k in e) {
@@ -55,9 +104,9 @@ function _interopNamespace(e) {
55
104
  return Object.freeze(n);
56
105
  }
57
106
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
58
- const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
59
- const styled__default = /* @__PURE__ */ _interopDefault(styled);
107
+ const Prism__namespace = /* @__PURE__ */ _interopNamespace(Prism);
60
108
  const Toolbar__namespace = /* @__PURE__ */ _interopNamespace(Toolbar);
109
+ const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
61
110
  const CodeMirror__default = /* @__PURE__ */ _interopDefault(CodeMirror);
62
111
  const sanitizeHtml__default = /* @__PURE__ */ _interopDefault(sanitizeHtml);
63
112
  const Markdown__default = /* @__PURE__ */ _interopDefault(Markdown);
@@ -70,93 +119,6 @@ const ins__default = /* @__PURE__ */ _interopDefault(ins);
70
119
  const mark__default = /* @__PURE__ */ _interopDefault(mark);
71
120
  const sub__default = /* @__PURE__ */ _interopDefault(sub);
72
121
  const sup__default = /* @__PURE__ */ _interopDefault(sup);
73
- const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
74
- const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
75
- const traverse = (datum, attributes) => {
76
- return Object.entries(datum).reduce((acc, [key, value]) => {
77
- const attribute = attributes[key];
78
- if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
79
- acc[key] = value;
80
- return acc;
81
- }
82
- if (attribute.type === "component") {
83
- if (attribute.repeatable) {
84
- const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
85
- acc[key] = componentValue.map(
86
- (componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
87
- );
88
- } else {
89
- const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
90
- acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
91
- }
92
- } else if (attribute.type === "dynamiczone") {
93
- const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
94
- acc[key] = dynamicZoneValue.map(
95
- (componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
96
- );
97
- } else if (predicate(attribute, value)) {
98
- acc[key] = transform(value, attribute);
99
- } else {
100
- acc[key] = value;
101
- }
102
- return acc;
103
- }, {});
104
- };
105
- return traverse(data, schema.attributes);
106
- };
107
- const removeProhibitedFields = (prohibitedFields) => traverseData(
108
- (attribute) => prohibitedFields.includes(attribute.type),
109
- () => ""
110
- );
111
- const prepareRelations = traverseData(
112
- (attribute) => attribute.type === "relation",
113
- () => ({
114
- connect: [],
115
- disconnect: []
116
- })
117
- );
118
- const prepareTempKeys = traverseData(
119
- (attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
120
- (data) => {
121
- if (Array.isArray(data) && data.length > 0) {
122
- const keys = fractionalIndexing.generateNKeysBetween(void 0, void 0, data.length);
123
- return data.map((datum, index2) => ({
124
- ...datum,
125
- __temp_key__: keys[index2]
126
- }));
127
- }
128
- return data;
129
- }
130
- );
131
- const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
132
- const schemaKeys = Object.keys(schema.attributes);
133
- const dataKeys = Object.keys(data);
134
- const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
135
- const revisedData = [...keysToRemove, ...index.DOCUMENT_META_FIELDS].reduce((acc, key) => {
136
- delete acc[key];
137
- return acc;
138
- }, structuredClone(data));
139
- return revisedData;
140
- };
141
- const removeNullValues = (data) => {
142
- return Object.entries(data).reduce((acc, [key, value]) => {
143
- if (value === null) {
144
- return acc;
145
- }
146
- acc[key] = value;
147
- return acc;
148
- }, {});
149
- };
150
- const transformDocument = (schema, components = {}) => (document2) => {
151
- const transformations = pipe__default.default(
152
- removeFieldsThatDontExistOnSchema(schema),
153
- removeProhibitedFields(["password"])(schema, components),
154
- removeNullValues,
155
- prepareRelations(schema, components),
156
- prepareTempKeys(schema, components)
157
- );
158
- return transformations(document2);
159
- };
160
122
  const componentStore = /* @__PURE__ */ new Map();
161
123
  const useLazyComponents = (componentUids = []) => {
162
124
  const [lazyComponentStore, setLazyComponentStore] = React.useState(Object.fromEntries(componentStore));
@@ -195,6 +157,224 @@ const useLazyComponents = (componentUids = []) => {
195
157
  }, []);
196
158
  return { isLazyLoading: loading, lazyComponentStore, cleanup };
197
159
  };
160
+ const codeLanguages = [
161
+ {
162
+ value: "asm",
163
+ label: "Assembly",
164
+ decorate: "asmatmel"
165
+ },
166
+ {
167
+ value: "bash",
168
+ label: "Bash"
169
+ },
170
+ {
171
+ value: "c",
172
+ label: "C"
173
+ },
174
+ {
175
+ value: "clojure",
176
+ label: "Clojure"
177
+ },
178
+ {
179
+ value: "cobol",
180
+ label: "COBOL"
181
+ },
182
+ {
183
+ value: "cpp",
184
+ label: "C++"
185
+ },
186
+ {
187
+ value: "csharp",
188
+ label: "C#"
189
+ },
190
+ {
191
+ value: "css",
192
+ label: "CSS"
193
+ },
194
+ {
195
+ value: "dart",
196
+ label: "Dart"
197
+ },
198
+ {
199
+ value: "dockerfile",
200
+ label: "Dockerfile",
201
+ decorate: "docker"
202
+ },
203
+ {
204
+ value: "elixir",
205
+ label: "Elixir"
206
+ },
207
+ {
208
+ value: "erlang",
209
+ label: "Erlang"
210
+ },
211
+ {
212
+ value: "fortran",
213
+ label: "Fortran"
214
+ },
215
+ {
216
+ value: "fsharp",
217
+ label: "F#"
218
+ },
219
+ {
220
+ value: "go",
221
+ label: "Go"
222
+ },
223
+ {
224
+ value: "graphql",
225
+ label: "GraphQL"
226
+ },
227
+ {
228
+ value: "groovy",
229
+ label: "Groovy"
230
+ },
231
+ {
232
+ value: "haskell",
233
+ label: "Haskell"
234
+ },
235
+ {
236
+ value: "haxe",
237
+ label: "Haxe"
238
+ },
239
+ {
240
+ value: "html",
241
+ label: "HTML"
242
+ },
243
+ {
244
+ value: "ini",
245
+ label: "INI"
246
+ },
247
+ {
248
+ value: "java",
249
+ label: "Java"
250
+ },
251
+ {
252
+ value: "javascript",
253
+ label: "JavaScript"
254
+ },
255
+ {
256
+ value: "jsx",
257
+ label: "JavaScript (React)"
258
+ },
259
+ {
260
+ value: "json",
261
+ label: "JSON"
262
+ },
263
+ {
264
+ value: "julia",
265
+ label: "Julia"
266
+ },
267
+ {
268
+ value: "kotlin",
269
+ label: "Kotlin"
270
+ },
271
+ {
272
+ value: "latex",
273
+ label: "LaTeX"
274
+ },
275
+ {
276
+ value: "lua",
277
+ label: "Lua"
278
+ },
279
+ {
280
+ value: "markdown",
281
+ label: "Markdown"
282
+ },
283
+ {
284
+ value: "matlab",
285
+ label: "MATLAB"
286
+ },
287
+ {
288
+ value: "makefile",
289
+ label: "Makefile"
290
+ },
291
+ {
292
+ value: "objectivec",
293
+ label: "Objective-C"
294
+ },
295
+ {
296
+ value: "perl",
297
+ label: "Perl"
298
+ },
299
+ {
300
+ value: "php",
301
+ label: "PHP"
302
+ },
303
+ {
304
+ value: "plaintext",
305
+ label: "Plain text"
306
+ },
307
+ {
308
+ value: "powershell",
309
+ label: "PowerShell"
310
+ },
311
+ {
312
+ value: "python",
313
+ label: "Python"
314
+ },
315
+ {
316
+ value: "r",
317
+ label: "R"
318
+ },
319
+ {
320
+ value: "ruby",
321
+ label: "Ruby"
322
+ },
323
+ {
324
+ value: "rust",
325
+ label: "Rust"
326
+ },
327
+ {
328
+ value: "sas",
329
+ label: "SAS"
330
+ },
331
+ {
332
+ value: "scala",
333
+ label: "Scala"
334
+ },
335
+ {
336
+ value: "scheme",
337
+ label: "Scheme"
338
+ },
339
+ {
340
+ value: "shell",
341
+ label: "Shell"
342
+ },
343
+ {
344
+ value: "sql",
345
+ label: "SQL"
346
+ },
347
+ {
348
+ value: "stata",
349
+ label: "Stata"
350
+ },
351
+ {
352
+ value: "swift",
353
+ label: "Swift"
354
+ },
355
+ {
356
+ value: "typescript",
357
+ label: "TypeScript",
358
+ decorate: "ts"
359
+ },
360
+ {
361
+ value: "tsx",
362
+ label: "TypeScript (React)"
363
+ },
364
+ {
365
+ value: "vbnet",
366
+ label: "VB.NET"
367
+ },
368
+ {
369
+ value: "xml",
370
+ label: "XML"
371
+ },
372
+ {
373
+ value: "yaml",
374
+ label: "YAML",
375
+ decorate: "yml"
376
+ }
377
+ ];
198
378
  const baseHandleConvert = (editor, attributesToSet) => {
199
379
  const [_, lastNodePath] = slate.Editor.last(editor, []);
200
380
  slate.Transforms.unwrapNodes(editor, {
@@ -258,13 +438,37 @@ const pressEnterTwiceToExit = (editor) => {
258
438
  });
259
439
  }
260
440
  };
261
- const CodeBlock = styled__default.default.pre.attrs({ role: "code" })`
441
+ const decorateCode = ([node, path]) => {
442
+ const ranges = [];
443
+ if (!slate.Element.isElement(node) || node.type !== "code") return ranges;
444
+ const text = slate.Node.string(node);
445
+ const language = codeLanguages.find((lang) => lang.value === node.language);
446
+ const decorateKey = language?.decorate ?? language?.value;
447
+ const selectedLanguage = Prism__namespace.languages[decorateKey || "plaintext"];
448
+ const tokens = Prism__namespace.tokenize(text, selectedLanguage);
449
+ let start = 0;
450
+ for (const token of tokens) {
451
+ const length = token.length;
452
+ const end = start + length;
453
+ if (typeof token !== "string") {
454
+ ranges.push({
455
+ anchor: { path, offset: start },
456
+ focus: { path, offset: end },
457
+ className: `token ${token.type}`
458
+ });
459
+ }
460
+ start = end;
461
+ }
462
+ return ranges;
463
+ };
464
+ const CodeBlock = styledComponents.styled.pre`
262
465
  border-radius: ${({ theme }) => theme.borderRadius};
263
466
  background-color: ${({ theme }) => theme.colors.neutral100};
264
467
  max-width: 100%;
265
468
  overflow: auto;
266
469
  padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};
267
470
  flex-shrink: 1;
471
+
268
472
  & > code {
269
473
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,
270
474
  monospace;
@@ -273,10 +477,62 @@ const CodeBlock = styled__default.default.pre.attrs({ role: "code" })`
273
477
  max-width: 100%;
274
478
  }
275
479
  `;
480
+ const CodeEditor = (props) => {
481
+ const { editor } = useBlocksEditorContext("ImageDialog");
482
+ const editorIsFocused = slateReact.useFocused();
483
+ const imageIsSelected = slateReact.useSelected();
484
+ const { formatMessage } = reactIntl.useIntl();
485
+ const [isSelectOpen, setIsSelectOpen] = React__namespace.useState(false);
486
+ const shouldDisplayLanguageSelect = editorIsFocused && imageIsSelected || isSelectOpen;
487
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { position: "relative", width: "100%", children: [
488
+ /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: props.children }) }),
489
+ shouldDisplayLanguageSelect && /* @__PURE__ */ jsxRuntime.jsx(
490
+ designSystem.Box,
491
+ {
492
+ position: "absolute",
493
+ background: "neutral0",
494
+ borderColor: "neutral150",
495
+ borderStyle: "solid",
496
+ borderWidth: "0.5px",
497
+ shadow: "tableShadow",
498
+ top: "100%",
499
+ marginTop: 1,
500
+ right: 0,
501
+ padding: 1,
502
+ hasRadius: true,
503
+ children: /* @__PURE__ */ jsxRuntime.jsx(
504
+ designSystem.SingleSelect,
505
+ {
506
+ onChange: (open) => {
507
+ slate.Transforms.setNodes(
508
+ editor,
509
+ { language: open.toString() },
510
+ { match: (node) => !slate.Editor.isEditor(node) && node.type === "code" }
511
+ );
512
+ },
513
+ value: props.element.type === "code" && props.element.language || "plaintext",
514
+ onOpenChange: (open) => {
515
+ setIsSelectOpen(open);
516
+ if (!open) {
517
+ slateReact.ReactEditor.focus(editor);
518
+ }
519
+ },
520
+ onCloseAutoFocus: (e) => e.preventDefault(),
521
+ "aria-label": formatMessage({
522
+ id: "components.Blocks.blocks.code.languageLabel",
523
+ defaultMessage: "Select a language"
524
+ }),
525
+ children: codeLanguages.map(({ value, label }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value, children: label }, value))
526
+ }
527
+ )
528
+ }
529
+ )
530
+ ] });
531
+ };
276
532
  const codeBlocks = {
277
533
  code: {
278
- renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: props.children }) }),
279
- icon: Icons.Code,
534
+ renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(CodeEditor, { ...props }),
535
+ icon: Icons.CodeBlock,
280
536
  label: {
281
537
  id: "components.Blocks.blocks.code",
282
538
  defaultMessage: "Code block"
@@ -284,36 +540,35 @@ const codeBlocks = {
284
540
  matchNode: (node) => node.type === "code",
285
541
  isInBlocksSelector: true,
286
542
  handleConvert(editor) {
287
- baseHandleConvert(editor, { type: "code" });
543
+ baseHandleConvert(editor, { type: "code", language: "plaintext" });
288
544
  },
289
545
  handleEnterKey(editor) {
290
546
  pressEnterTwiceToExit(editor);
291
547
  },
292
- snippets: ["```"],
293
- dragHandleTopMargin: "10px"
548
+ snippets: ["```"]
294
549
  }
295
550
  };
296
- const H1 = styled__default.default(designSystem.Typography).attrs({ as: "h1" })`
551
+ const H1 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h1" })`
297
552
  font-size: 4.2rem;
298
553
  line-height: ${({ theme }) => theme.lineHeights[1]};
299
554
  `;
300
- const H2 = styled__default.default(designSystem.Typography).attrs({ as: "h2" })`
555
+ const H2 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h2" })`
301
556
  font-size: 3.5rem;
302
557
  line-height: ${({ theme }) => theme.lineHeights[1]};
303
558
  `;
304
- const H3 = styled__default.default(designSystem.Typography).attrs({ as: "h3" })`
559
+ const H3 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h3" })`
305
560
  font-size: 2.9rem;
306
561
  line-height: ${({ theme }) => theme.lineHeights[1]};
307
562
  `;
308
- const H4 = styled__default.default(designSystem.Typography).attrs({ as: "h4" })`
563
+ const H4 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h4" })`
309
564
  font-size: 2.4rem;
310
565
  line-height: ${({ theme }) => theme.lineHeights[1]};
311
566
  `;
312
- const H5 = styled__default.default(designSystem.Typography).attrs({ as: "h5" })`
567
+ const H5 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h5" })`
313
568
  font-size: 2rem;
314
569
  line-height: ${({ theme }) => theme.lineHeights[1]};
315
570
  `;
316
- const H6 = styled__default.default(designSystem.Typography).attrs({ as: "h6" })`
571
+ const H6 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h6" })`
317
572
  font-size: 1.6rem;
318
573
  line-height: ${({ theme }) => theme.lineHeights[1]};
319
574
  `;
@@ -399,10 +654,10 @@ const headingBlocks = {
399
654
  dragHandleTopMargin: "-2px"
400
655
  }
401
656
  };
402
- const ImageWrapper = styled__default.default(designSystem.Flex)`
657
+ const ImageWrapper = styledComponents.styled(designSystem.Flex)`
403
658
  transition-property: box-shadow;
404
659
  transition-duration: 0.2s;
405
- ${(props) => props.isFocused && styled.css`
660
+ ${(props) => props.$isFocused && styledComponents.css`
406
661
  box-shadow: ${props.theme.colors.primary600} 0px 0px 0px 3px;
407
662
  `}
408
663
 
@@ -454,7 +709,7 @@ const Image = ({ attributes, children, element }) => {
454
709
  background: "neutral100",
455
710
  contentEditable: false,
456
711
  justifyContent: "center",
457
- isFocused: editorIsFocused && imageIsSelected,
712
+ $isFocused: editorIsFocused && imageIsSelected,
458
713
  hasRadius: true,
459
714
  children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: alternativeText, width, height })
460
715
  }
@@ -465,8 +720,7 @@ const ImageDialog = () => {
465
720
  const [isOpen, setIsOpen] = React__namespace.useState(true);
466
721
  const { editor } = useBlocksEditorContext("ImageDialog");
467
722
  const components = strapiAdmin.useStrapiApp("ImageDialog", (state) => state.components);
468
- if (!components || !isOpen)
469
- return null;
723
+ if (!components || !isOpen) return null;
470
724
  const MediaLibraryDialog = components["media-library"];
471
725
  const insertImages = (images) => {
472
726
  slate.Transforms.unwrapNodes(editor, {
@@ -475,14 +729,12 @@ const ImageDialog = () => {
475
729
  });
476
730
  const nodeEntryBeingReplaced = slate.Editor.above(editor, {
477
731
  match(node) {
478
- if (slate.Editor.isEditor(node))
479
- return false;
732
+ if (slate.Editor.isEditor(node)) return false;
480
733
  const isInlineNode = ["text", "link"].includes(node.type);
481
734
  return !isInlineNode;
482
735
  }
483
736
  });
484
- if (!nodeEntryBeingReplaced)
485
- return;
737
+ if (!nodeEntryBeingReplaced) return;
486
738
  const [, pathToInsert] = nodeEntryBeingReplaced;
487
739
  slate.Transforms.removeNodes(editor);
488
740
  const nodesToInsert = images.map((image) => {
@@ -502,7 +754,7 @@ const ImageDialog = () => {
502
754
  const nodeImage = {
503
755
  ...expectedImage,
504
756
  alternativeText: expectedImage.alternativeText || expectedImage.name,
505
- url: urls.prefixFileUrlWithBackendUrl(image.url)
757
+ url: usePrev.prefixFileUrlWithBackendUrl(image.url)
506
758
  };
507
759
  return nodeImage;
508
760
  });
@@ -610,11 +862,11 @@ const isLinkNode = (element) => {
610
862
  const isListNode$1 = (element) => {
611
863
  return element.type === "list";
612
864
  };
613
- const StyledBaseLink = styled__default.default(designSystem.BaseLink)`
865
+ const StyledBaseLink = styledComponents.styled(designSystem.BaseLink)`
614
866
  text-decoration: none;
615
867
  `;
616
- const RemoveButton = styled__default.default(designSystem.Button)`
617
- visibility: ${(props) => props.visible ? "visible" : "hidden"};
868
+ const RemoveButton = styledComponents.styled(designSystem.Button)`
869
+ visibility: ${(props) => props.$visible ? "visible" : "hidden"};
618
870
  `;
619
871
  const LinkContent = React__namespace.forwardRef(
620
872
  ({ link, children, attributes }, forwardedRef) => {
@@ -624,18 +876,12 @@ const LinkContent = React__namespace.forwardRef(
624
876
  const [popoverOpen, setPopoverOpen] = React__namespace.useState(
625
877
  editor.lastInsertedLinkPath ? slate.Path.equals(path, editor.lastInsertedLinkPath) : false
626
878
  );
627
- const linkRef = React__namespace.useRef(null);
628
879
  const elementText = link.children.map((child) => child.text).join("");
629
880
  const [linkText, setLinkText] = React__namespace.useState(elementText);
630
881
  const [linkUrl, setLinkUrl] = React__namespace.useState(link.url);
631
882
  const linkInputRef = React__namespace.useRef(null);
632
- const [showRemoveButton, setShowRemoveButton] = React__namespace.useState(false);
883
+ const isLastInsertedLink = editor.lastInsertedLinkPath ? !slate.Path.equals(path, editor.lastInsertedLinkPath) : true;
633
884
  const [isSaveDisabled, setIsSaveDisabled] = React__namespace.useState(false);
634
- const handleOpenEditPopover = (e) => {
635
- e.preventDefault();
636
- setPopoverOpen(true);
637
- setShowRemoveButton(true);
638
- };
639
885
  const onLinkChange = (e) => {
640
886
  setIsSaveDisabled(false);
641
887
  setLinkUrl(e.target.value);
@@ -656,40 +902,39 @@ const LinkContent = React__namespace.forwardRef(
656
902
  editLink(editor, { url: linkUrl, text: linkText });
657
903
  setPopoverOpen(false);
658
904
  editor.lastInsertedLinkPath = null;
905
+ slateReact.ReactEditor.focus(editor);
659
906
  };
660
- const handleDismiss = () => {
661
- setPopoverOpen(false);
907
+ const handleClose = () => {
662
908
  if (link.url === "") {
663
909
  removeLink(editor);
664
910
  }
911
+ setPopoverOpen(false);
665
912
  slateReact.ReactEditor.focus(editor);
666
913
  };
667
- const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
668
- const composedRefs = designSystem.useComposedRefs(linkRef, forwardedRef);
669
914
  React__namespace.useEffect(() => {
670
- if (popoverOpen)
671
- linkInputRef.current?.focus();
915
+ if (popoverOpen) linkInputRef.current?.focus();
672
916
  }, [popoverOpen]);
673
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
674
- /* @__PURE__ */ jsxRuntime.jsx(
917
+ const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
918
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { open: popoverOpen, children: [
919
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(
675
920
  StyledBaseLink,
676
921
  {
677
922
  ...attributes,
678
- ref: composedRefs,
923
+ ref: forwardedRef,
679
924
  href: link.url,
680
- onClick: handleOpenEditPopover,
925
+ onClick: () => setPopoverOpen(true),
681
926
  color: "primary600",
682
927
  children
683
928
  }
684
- ),
685
- popoverOpen && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover, { source: linkRef, onDismiss: handleDismiss, padding: 4, contentEditable: false, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { as: "form", onSubmit: handleSave, direction: "column", gap: 4, children: [
686
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field, { width: "368px", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
687
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { children: formatMessage({
929
+ ) }),
930
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { onPointerDownOutside: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 4, direction: "column", gap: 4, children: [
931
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { width: "368px", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
932
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
688
933
  id: "components.Blocks.popover.text",
689
934
  defaultMessage: "Text"
690
935
  }) }),
691
936
  /* @__PURE__ */ jsxRuntime.jsx(
692
- designSystem.FieldInput,
937
+ designSystem.Field.Input,
693
938
  {
694
939
  name: "text",
695
940
  placeholder: formatMessage({
@@ -703,13 +948,13 @@ const LinkContent = React__namespace.forwardRef(
703
948
  }
704
949
  )
705
950
  ] }) }),
706
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field, { width: "368px", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
707
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { children: formatMessage({
951
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { width: "368px", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
952
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: formatMessage({
708
953
  id: "components.Blocks.popover.link",
709
954
  defaultMessage: "Link"
710
955
  }) }),
711
956
  /* @__PURE__ */ jsxRuntime.jsx(
712
- designSystem.FieldInput,
957
+ designSystem.Field.Input,
713
958
  {
714
959
  ref: linkInputRef,
715
960
  name: "url",
@@ -728,7 +973,7 @@ const LinkContent = React__namespace.forwardRef(
728
973
  {
729
974
  variant: "danger-light",
730
975
  onClick: () => removeLink(editor),
731
- visible: showRemoveButton,
976
+ $visible: isLastInsertedLink,
732
977
  children: formatMessage({
733
978
  id: "components.Blocks.popover.remove",
734
979
  defaultMessage: "Remove"
@@ -736,12 +981,12 @@ const LinkContent = React__namespace.forwardRef(
736
981
  }
737
982
  ),
738
983
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
739
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: handleDismiss, children: formatMessage({
740
- id: "components.Blocks.popover.cancel",
984
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
985
+ id: "global.cancel",
741
986
  defaultMessage: "Cancel"
742
987
  }) }),
743
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { type: "submit", disabled: Boolean(inputNotDirty) || isSaveDisabled, children: formatMessage({
744
- id: "components.Blocks.popover.save",
988
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
989
+ id: "global.save",
745
990
  defaultMessage: "Save"
746
991
  }) })
747
992
  ] })
@@ -764,7 +1009,7 @@ const linkBlocks = {
764
1009
  isInBlocksSelector: false
765
1010
  }
766
1011
  };
767
- const listStyle = styled.css`
1012
+ const listStyle = styledComponents.css`
768
1013
  display: flex;
769
1014
  flex-direction: column;
770
1015
  gap: ${({ theme }) => theme.spaces[2]};
@@ -782,12 +1027,12 @@ const listStyle = styled.css`
782
1027
  margin-inline-start: ${({ theme }) => theme.spaces[3]};
783
1028
  }
784
1029
  `;
785
- const Orderedlist = styled__default.default.ol`
786
- list-style-type: ${(props) => props.listStyleType};
1030
+ const Orderedlist = styledComponents.styled.ol`
1031
+ list-style-type: ${(props) => props.$listStyleType};
787
1032
  ${listStyle}
788
1033
  `;
789
- const Unorderedlist = styled__default.default.ul`
790
- list-style-type: ${(props) => props.listStyleType};
1034
+ const Unorderedlist = styledComponents.styled.ul`
1035
+ list-style-type: ${(props) => props.$listStyleType};
791
1036
  ${listStyle}
792
1037
  `;
793
1038
  const orderedStyles = ["decimal", "lower-alpha", "upper-roman"];
@@ -800,9 +1045,9 @@ const List = ({ attributes, children, element }) => {
800
1045
  const nextIndex = (element.indentLevel || 0) % listStyles.length;
801
1046
  const listStyleType = listStyles[nextIndex];
802
1047
  if (element.format === "ordered") {
803
- return /* @__PURE__ */ jsxRuntime.jsx(Orderedlist, { listStyleType, ...attributes, children });
1048
+ return /* @__PURE__ */ jsxRuntime.jsx(Orderedlist, { $listStyleType: listStyleType, ...attributes, children });
804
1049
  }
805
- return /* @__PURE__ */ jsxRuntime.jsx(Unorderedlist, { listStyleType, ...attributes, children });
1050
+ return /* @__PURE__ */ jsxRuntime.jsx(Unorderedlist, { $listStyleType: listStyleType, ...attributes, children });
806
1051
  };
807
1052
  const replaceListWithEmptyBlock = (editor, currentListPath) => {
808
1053
  slate.Transforms.removeNodes(editor, { at: currentListPath });
@@ -822,8 +1067,7 @@ const isText$1 = (node) => {
822
1067
  return slate.Node.isNode(node) && !slate.Editor.isEditor(node) && node.type === "text";
823
1068
  };
824
1069
  const handleBackspaceKeyOnList = (editor, event) => {
825
- if (!editor.selection)
826
- return;
1070
+ if (!editor.selection) return;
827
1071
  const [currentListItem, currentListItemPath] = slate.Editor.parent(editor, editor.selection.anchor);
828
1072
  const [currentList, currentListPath] = slate.Editor.parent(editor, currentListItemPath);
829
1073
  const isListEmpty = currentList.children.length === 1 && isText$1(currentListItem.children[0]) && currentListItem.children[0].text === "";
@@ -932,8 +1176,7 @@ const handleEnterKeyOnList = (editor) => {
932
1176
  };
933
1177
  const handleConvertToList = (editor, format) => {
934
1178
  const convertedPath = baseHandleConvert(editor, { type: "list-item" });
935
- if (!convertedPath)
936
- return;
1179
+ if (!convertedPath) return;
937
1180
  slate.Transforms.wrapNodes(editor, { type: "list", format, children: [] }, { at: convertedPath });
938
1181
  };
939
1182
  const handleTabOnList = (editor) => {
@@ -945,8 +1188,7 @@ const handleTabOnList = (editor) => {
945
1188
  }
946
1189
  const [currentListItem, currentListItemPath] = currentListItemEntry;
947
1190
  const [currentList] = slate.Editor.parent(editor, currentListItemPath);
948
- if (currentListItem === currentList.children[0])
949
- return;
1191
+ if (currentListItem === currentList.children[0]) return;
950
1192
  const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);
951
1193
  const previousNode = currentList.children[currentListItemIndex - 1];
952
1194
  if (previousNode.type === "list") {
@@ -999,7 +1241,7 @@ const listBlocks = {
999
1241
  snippets: ["-", "*", "+"]
1000
1242
  },
1001
1243
  "list-item": {
1002
- renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { as: "li", ...props.attributes, children: props.children }),
1244
+ renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "li", ...props.attributes, children: props.children }),
1003
1245
  // No handleConvert, list items are created when converting to the parent list
1004
1246
  matchNode: (node) => node.type === "list-item",
1005
1247
  isInBlocksSelector: false,
@@ -1008,7 +1250,7 @@ const listBlocks = {
1008
1250
  };
1009
1251
  const paragraphBlocks = {
1010
1252
  paragraph: {
1011
- renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { as: "p", variant: "omega", ...props.attributes, children: props.children }),
1253
+ renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "p", variant: "omega", ...props.attributes, children: props.children }),
1012
1254
  icon: Icons.Paragraph,
1013
1255
  label: {
1014
1256
  id: "components.Blocks.blocks.text",
@@ -1056,7 +1298,7 @@ const paragraphBlocks = {
1056
1298
  }
1057
1299
  }
1058
1300
  };
1059
- const Blockquote = styled__default.default.blockquote.attrs({ role: "blockquote" })`
1301
+ const Blockquote = styledComponents.styled.blockquote.attrs({ role: "blockquote" })`
1060
1302
  font-weight: ${({ theme }) => theme.fontWeights.regular};
1061
1303
  border-left: ${({ theme }) => `${theme.spaces[1]} solid ${theme.colors.neutral200}`};
1062
1304
  padding: ${({ theme }) => theme.spaces[2]} ${({ theme }) => theme.spaces[4]};
@@ -1082,24 +1324,24 @@ const quoteBlocks = {
1082
1324
  handleEnterKey(editor) {
1083
1325
  pressEnterTwiceToExit(editor);
1084
1326
  },
1085
- snippets: [">"],
1086
- dragHandleTopMargin: "6px"
1327
+ snippets: [">"]
1087
1328
  }
1088
1329
  };
1089
- const ToolbarWrapper = styled__default.default(designSystem.Flex)`
1330
+ const ToolbarWrapper = styledComponents.styled(designSystem.Flex)`
1090
1331
  &[aria-disabled='true'] {
1091
1332
  cursor: not-allowed;
1333
+ background: ${({ theme }) => theme.colors.neutral150};
1092
1334
  }
1093
1335
  `;
1094
- const Separator = styled__default.default(Toolbar__namespace.Separator)`
1336
+ const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
1095
1337
  background: ${({ theme }) => theme.colors.neutral150};
1096
1338
  width: 1px;
1097
1339
  height: 2.4rem;
1098
1340
  `;
1099
- const FlexButton = styled__default.default(designSystem.Flex)`
1341
+ const FlexButton = styledComponents.styled(designSystem.Flex)`
1100
1342
  // Inherit the not-allowed cursor from ToolbarWrapper when disabled
1101
1343
  &[aria-disabled] {
1102
- cursor: inherit;
1344
+ cursor: not-allowed;
1103
1345
  }
1104
1346
 
1105
1347
  &[aria-disabled='false'] {
@@ -1111,7 +1353,7 @@ const FlexButton = styled__default.default(designSystem.Flex)`
1111
1353
  }
1112
1354
  }
1113
1355
  `;
1114
- const SelectWrapper = styled__default.default(designSystem.Box)`
1356
+ const SelectWrapper = styledComponents.styled(designSystem.Box)`
1115
1357
  // Styling changes to SingleSelect component don't work, so adding wrapper to target SingleSelect
1116
1358
  div[role='combobox'] {
1117
1359
  border: none;
@@ -1174,14 +1416,14 @@ const ToolbarButton = ({
1174
1416
  children: /* @__PURE__ */ jsxRuntime.jsx(
1175
1417
  FlexButton,
1176
1418
  {
1177
- as: "button",
1419
+ tag: "button",
1178
1420
  background: isActive ? "primary100" : "",
1179
1421
  alignItems: "center",
1180
1422
  justifyContent: "center",
1181
1423
  width: 7,
1182
1424
  height: 7,
1183
1425
  hasRadius: true,
1184
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { width: "1.2rem", height: "1.2rem", fill: disabled ? "neutral300" : enabledColor })
1426
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { fill: disabled ? "neutral300" : enabledColor })
1185
1427
  }
1186
1428
  )
1187
1429
  }
@@ -1313,8 +1555,7 @@ const isListNode = (node) => {
1313
1555
  const ListButton = ({ block, format }) => {
1314
1556
  const { editor, disabled, blocks } = useBlocksEditorContext("ListButton");
1315
1557
  const isListActive = () => {
1316
- if (!editor.selection)
1317
- return false;
1558
+ if (!editor.selection) return false;
1318
1559
  const currentListEntry = slate.Editor.above(editor, {
1319
1560
  match: (node) => !slate.Editor.isEditor(node) && node.type === "list",
1320
1561
  at: editor.selection.anchor
@@ -1326,6 +1567,26 @@ const ListButton = ({ block, format }) => {
1326
1567
  }
1327
1568
  return false;
1328
1569
  };
1570
+ const isListDisabled = () => {
1571
+ if (disabled) {
1572
+ return true;
1573
+ }
1574
+ if (!editor.selection) {
1575
+ return false;
1576
+ }
1577
+ const anchorNodeEntry = slate.Editor.above(editor, {
1578
+ at: editor.selection.anchor,
1579
+ match: (node) => !slate.Editor.isEditor(node) && node.type !== "text"
1580
+ });
1581
+ const focusNodeEntry = slate.Editor.above(editor, {
1582
+ at: editor.selection.focus,
1583
+ match: (node) => !slate.Editor.isEditor(node) && node.type !== "text"
1584
+ });
1585
+ if (!anchorNodeEntry || !focusNodeEntry) {
1586
+ return false;
1587
+ }
1588
+ return anchorNodeEntry[0] !== focusNodeEntry[0];
1589
+ };
1329
1590
  const toggleList = (format2) => {
1330
1591
  let currentListEntry;
1331
1592
  if (editor.selection) {
@@ -1359,7 +1620,7 @@ const ListButton = ({ block, format }) => {
1359
1620
  name: format,
1360
1621
  label: block.label,
1361
1622
  isActive: isListActive(),
1362
- disabled,
1623
+ disabled: isListDisabled(),
1363
1624
  handleClick: () => toggleList(format)
1364
1625
  }
1365
1626
  );
@@ -1368,8 +1629,7 @@ const LinkButton = ({ disabled }) => {
1368
1629
  const { editor } = useBlocksEditorContext("LinkButton");
1369
1630
  const isLinkActive = () => {
1370
1631
  const { selection } = editor;
1371
- if (!selection)
1372
- return false;
1632
+ if (!selection) return false;
1373
1633
  const [match] = Array.from(
1374
1634
  slate.Editor.nodes(editor, {
1375
1635
  at: slate.Editor.unhangRange(editor, selection),
@@ -1433,7 +1693,7 @@ const BlocksToolbar = () => {
1433
1693
  return false;
1434
1694
  };
1435
1695
  const isButtonDisabled = checkButtonDisabled();
1436
- return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, children: [
1696
+ return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, width: "100%", children: [
1437
1697
  /* @__PURE__ */ jsxRuntime.jsx(BlocksDropdown, {}),
1438
1698
  /* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
1439
1699
  /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.ToggleGroup, { type: "multiple", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, children: [
@@ -1458,7 +1718,7 @@ const BlocksToolbar = () => {
1458
1718
  ] }) })
1459
1719
  ] }) });
1460
1720
  };
1461
- const StyledEditable = styled__default.default(slateReact.Editable)`
1721
+ const StyledEditable = styledComponents.styled(slateReact.Editable)`
1462
1722
  // The outline style is set on the wrapper with :focus-within
1463
1723
  outline: none;
1464
1724
  display: flex;
@@ -1473,20 +1733,20 @@ const StyledEditable = styled__default.default(slateReact.Editable)`
1473
1733
  padding-bottom: ${({ theme }) => theme.spaces[3]};
1474
1734
  }
1475
1735
  `;
1476
- const Wrapper$1 = styled__default.default(designSystem.Box)`
1736
+ const Wrapper$1 = styledComponents.styled(designSystem.Box)`
1477
1737
  position: ${({ isOverDropTarget }) => isOverDropTarget && "relative"};
1478
1738
  `;
1479
- const DropPlaceholder = styled__default.default(designSystem.Box)`
1739
+ const DropPlaceholder = styledComponents.styled(designSystem.Box)`
1480
1740
  position: absolute;
1481
1741
  right: 0;
1482
1742
 
1483
1743
  // Show drop placeholder 8px above or below the drop target
1484
- ${({ dragDirection, theme, placeholderMargin }) => styled.css`
1744
+ ${({ dragDirection, theme, placeholderMargin }) => styledComponents.css`
1485
1745
  top: ${dragDirection === useDragAndDrop.DIRECTIONS.UPWARD && `-${theme.spaces[placeholderMargin]}`};
1486
1746
  bottom: ${dragDirection === useDragAndDrop.DIRECTIONS.DOWNWARD && `-${theme.spaces[placeholderMargin]}`};
1487
1747
  `}
1488
1748
  `;
1489
- const DragItem = styled__default.default(designSystem.Flex)`
1749
+ const DragItem = styledComponents.styled(designSystem.Flex)`
1490
1750
  // Style each block rendered using renderElement()
1491
1751
  & > [data-slate-node='element'] {
1492
1752
  width: 100%;
@@ -1495,41 +1755,44 @@ const DragItem = styled__default.default(designSystem.Flex)`
1495
1755
 
1496
1756
  // Set the visibility of drag button
1497
1757
  [role='button'] {
1498
- visibility: ${(props) => props.dragVisibility};
1758
+ visibility: ${(props) => props.$dragVisibility};
1499
1759
  opacity: inherit;
1500
1760
  }
1501
1761
  &[aria-disabled='true'] {
1502
1762
  user-drag: none;
1503
1763
  }
1504
1764
  `;
1505
- const DragIconButton = styled__default.default(designSystem.IconButton)`
1765
+ const DragIconButton = styledComponents.styled(designSystem.IconButton)`
1766
+ user-select: none;
1506
1767
  display: flex;
1507
1768
  align-items: center;
1508
1769
  justify-content: center;
1770
+ border: none;
1509
1771
  border-radius: ${({ theme }) => theme.borderRadius};
1510
- width: ${({ theme }) => theme.spaces[4]};
1511
- height: ${({ theme }) => theme.spaces[6]};
1772
+ padding-left: ${({ theme }) => theme.spaces[0]};
1773
+ padding-right: ${({ theme }) => theme.spaces[0]};
1774
+ padding-top: ${({ theme }) => theme.spaces[1]};
1775
+ padding-bottom: ${({ theme }) => theme.spaces[1]};
1512
1776
  visibility: hidden;
1513
1777
  cursor: grab;
1514
1778
  opacity: inherit;
1515
- margin-top: ${(props) => props.dragHandleTopMargin ?? 0};
1779
+ margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
1516
1780
 
1517
1781
  &:hover {
1518
- background: ${({ theme }) => theme.colors.neutral200};
1782
+ background: ${({ theme }) => theme.colors.neutral100};
1519
1783
  }
1520
1784
  &:active {
1521
1785
  cursor: grabbing;
1786
+ background: ${({ theme }) => theme.colors.neutral150};
1522
1787
  }
1523
1788
  &[aria-disabled='true'] {
1524
- cursor: not-allowed;
1525
- background: transparent;
1789
+ visibility: hidden;
1526
1790
  }
1527
1791
  svg {
1528
- height: auto;
1529
- width: ${({ theme }) => theme.spaces[3]};
1792
+ min-width: ${({ theme }) => theme.spaces[3]};
1530
1793
 
1531
1794
  path {
1532
- fill: ${({ theme }) => theme.colors.neutral700};
1795
+ fill: ${({ theme }) => theme.colors.neutral500};
1533
1796
  }
1534
1797
  }
1535
1798
  `;
@@ -1574,8 +1837,7 @@ const DragAndDropElement = ({
1574
1837
  displayedValue: children
1575
1838
  },
1576
1839
  onDropItem(currentIndex, newIndex) {
1577
- if (newIndex)
1578
- handleMoveBlock(newIndex, currentIndex);
1840
+ if (newIndex) handleMoveBlock(newIndex, currentIndex);
1579
1841
  }
1580
1842
  });
1581
1843
  const composedBoxRefs = designSystem.useComposedRefs(blockRef, dropRef);
@@ -1587,7 +1849,7 @@ const DragAndDropElement = ({
1587
1849
  React__namespace.useEffect(() => {
1588
1850
  setDragVisibility("hidden");
1589
1851
  }, [editor.selection]);
1590
- return /* @__PURE__ */ jsxRuntime.jsxs(Wrapper$1, { ref: (ref) => composedBoxRefs(ref), isOverDropTarget, children: [
1852
+ return /* @__PURE__ */ jsxRuntime.jsxs(Wrapper$1, { ref: composedBoxRefs, isOverDropTarget, children: [
1591
1853
  isOverDropTarget && /* @__PURE__ */ jsxRuntime.jsx(
1592
1854
  DropPlaceholder,
1593
1855
  {
@@ -1625,15 +1887,17 @@ const DragAndDropElement = ({
1625
1887
  onSelect: () => setDragVisibility("visible"),
1626
1888
  onMouseLeave: () => setDragVisibility("hidden"),
1627
1889
  "aria-disabled": disabled,
1628
- dragVisibility,
1890
+ $dragVisibility: dragVisibility,
1629
1891
  children: [
1630
1892
  /* @__PURE__ */ jsxRuntime.jsx(
1631
1893
  DragIconButton,
1632
1894
  {
1633
- forwardedAs: "div",
1895
+ tag: "div",
1896
+ contentEditable: false,
1634
1897
  role: "button",
1635
1898
  tabIndex: 0,
1636
- "aria-label": formatMessage({
1899
+ withTooltip: false,
1900
+ label: formatMessage({
1637
1901
  id: index.getTranslation("components.DragHandle-label"),
1638
1902
  defaultMessage: "Drag"
1639
1903
  }),
@@ -1641,8 +1905,8 @@ const DragAndDropElement = ({
1641
1905
  "aria-disabled": disabled,
1642
1906
  disabled,
1643
1907
  draggable: true,
1644
- dragHandleTopMargin,
1645
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, { color: "neutral600" })
1908
+ $dragHandleTopMargin: dragHandleTopMargin,
1909
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, { color: "primary500" })
1646
1910
  }
1647
1911
  ),
1648
1912
  children
@@ -1653,17 +1917,18 @@ const DragAndDropElement = ({
1653
1917
  };
1654
1918
  const CloneDragItem = ({ children, dragHandleTopMargin }) => {
1655
1919
  const { formatMessage } = reactIntl.useIntl();
1656
- return /* @__PURE__ */ jsxRuntime.jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", dragVisibility: "visible", children: [
1920
+ return /* @__PURE__ */ jsxRuntime.jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", $dragVisibility: "visible", children: [
1657
1921
  /* @__PURE__ */ jsxRuntime.jsx(
1658
1922
  DragIconButton,
1659
1923
  {
1660
- forwardedAs: "div",
1924
+ tag: "div",
1661
1925
  role: "button",
1662
- "aria-label": formatMessage({
1926
+ withTooltip: false,
1927
+ label: formatMessage({
1663
1928
  id: index.getTranslation("components.DragHandle-label"),
1664
1929
  defaultMessage: "Drag"
1665
1930
  }),
1666
- dragHandleTopMargin,
1931
+ $dragHandleTopMargin: dragHandleTopMargin,
1667
1932
  children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, { color: "neutral600" })
1668
1933
  }
1669
1934
  ),
@@ -1678,7 +1943,7 @@ const baseRenderLeaf = (props, modifiers2) => {
1678
1943
  }
1679
1944
  return currentChildren;
1680
1945
  }, props.children);
1681
- return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, children: wrappedChildren });
1946
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, className: props.leaf.className, children: wrappedChildren });
1682
1947
  };
1683
1948
  const baseRenderElement = ({
1684
1949
  props,
@@ -1716,8 +1981,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1716
1981
  [modifiers2]
1717
1982
  );
1718
1983
  const handleMoveBlocks = (editor2, event) => {
1719
- if (!editor2.selection)
1720
- return;
1984
+ if (!editor2.selection) return;
1721
1985
  const start = slate.Range.start(editor2.selection);
1722
1986
  const currentIndex = [start.path[0]];
1723
1987
  let newIndexPosition = 0;
@@ -1854,8 +2118,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1854
2118
  }
1855
2119
  };
1856
2120
  const handleScrollSelectionIntoView = () => {
1857
- if (!editor.selection)
1858
- return;
2121
+ if (!editor.selection) return;
1859
2122
  const domRange = slateReact.ReactEditor.toDOMRange(editor, editor.selection);
1860
2123
  const domRect = domRange.getBoundingClientRect();
1861
2124
  const blocksInput = blocksRef.current;
@@ -1882,7 +2145,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1882
2145
  background: "neutral0",
1883
2146
  color: "neutral800",
1884
2147
  lineHeight: 6,
1885
- paddingRight: 4,
2148
+ paddingRight: 7,
1886
2149
  paddingTop: 6,
1887
2150
  paddingBottom: 3,
1888
2151
  children: [
@@ -1893,6 +2156,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1893
2156
  readOnly: disabled,
1894
2157
  placeholder,
1895
2158
  isExpandedMode,
2159
+ decorate: decorateCode,
1896
2160
  renderElement,
1897
2161
  renderLeaf,
1898
2162
  onKeyDown: handleKeyDown,
@@ -1910,12 +2174,12 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1910
2174
  }
1911
2175
  );
1912
2176
  };
1913
- const CollapseIconButton = styled__default.default(designSystem.IconButton)`
2177
+ const CollapseIconButton = styledComponents.styled(designSystem.IconButton)`
1914
2178
  position: absolute;
1915
2179
  bottom: 1.2rem;
1916
2180
  right: 1.2rem;
1917
2181
  `;
1918
- const ExpandWrapper$1 = styled__default.default(designSystem.Flex)`
2182
+ const ExpandWrapper$1 = styledComponents.styled(designSystem.Flex)`
1919
2183
  // Background with 20% opacity
1920
2184
  background: ${({ theme }) => `${theme.colors.neutral800}1F`};
1921
2185
  `;
@@ -1965,7 +2229,7 @@ const EditorLayout$1 = ({
1965
2229
  /* @__PURE__ */ jsxRuntime.jsx(
1966
2230
  CollapseIconButton,
1967
2231
  {
1968
- "aria-label": formatMessage({
2232
+ label: formatMessage({
1969
2233
  id: index.getTranslation("components.Blocks.collapse"),
1970
2234
  defaultMessage: "Collapse"
1971
2235
  }),
@@ -1980,13 +2244,13 @@ const EditorLayout$1 = ({
1980
2244
  ) }) });
1981
2245
  }
1982
2246
  return /* @__PURE__ */ jsxRuntime.jsx(
1983
- designSystem.InputWrapper,
2247
+ InputWrapper,
1984
2248
  {
1985
2249
  direction: "column",
1986
2250
  alignItems: "flex-start",
1987
2251
  height: "512px",
1988
- disabled,
1989
- hasError: Boolean(error),
2252
+ $disabled: disabled,
2253
+ $hasError: Boolean(error),
1990
2254
  style: { overflow: "hidden" },
1991
2255
  "aria-describedby": ariaDescriptionId,
1992
2256
  position: "relative",
@@ -1994,25 +2258,52 @@ const EditorLayout$1 = ({
1994
2258
  }
1995
2259
  );
1996
2260
  };
1997
- const stylesToInherit = styled.css`
2261
+ const InputWrapper = styledComponents.styled(designSystem.Flex)`
2262
+ border: 1px solid
2263
+ ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral200};
2264
+ border-radius: ${({ theme }) => theme.borderRadius};
2265
+ background: ${({ theme }) => theme.colors.neutral0};
2266
+
2267
+ ${({ theme, $hasError = false }) => styledComponents.css`
2268
+ outline: none;
2269
+ box-shadow: 0;
2270
+ transition-property: border-color, box-shadow, fill;
2271
+ transition-duration: 0.2s;
2272
+
2273
+ &:focus-within {
2274
+ border: 1px solid ${$hasError ? theme.colors.danger600 : theme.colors.primary600};
2275
+ box-shadow: ${$hasError ? theme.colors.danger600 : theme.colors.primary600} 0px 0px 0px 2px;
2276
+ }
2277
+ `}
2278
+
2279
+ ${({ theme, $disabled }) => $disabled ? styledComponents.css`
2280
+ color: ${theme.colors.neutral600};
2281
+ background: ${theme.colors.neutral150};
2282
+ ` : void 0}
2283
+ `;
2284
+ const stylesToInherit = styledComponents.css`
1998
2285
  font-size: inherit;
1999
2286
  color: inherit;
2000
2287
  line-height: inherit;
2001
2288
  `;
2002
- const BoldText = styled__default.default(designSystem.Typography).attrs({ fontWeight: "bold" })`
2289
+ const BoldText = styledComponents.styled(designSystem.Typography).attrs({ fontWeight: "bold" })`
2003
2290
  ${stylesToInherit}
2004
2291
  `;
2005
- const ItalicText = styled__default.default(designSystem.Typography)`
2292
+ const ItalicText = styledComponents.styled(designSystem.Typography)`
2006
2293
  font-style: italic;
2007
2294
  ${stylesToInherit}
2008
2295
  `;
2009
- const UnderlineText = styled__default.default(designSystem.Typography).attrs({ textDecoration: "underline" })`
2296
+ const UnderlineText = styledComponents.styled(designSystem.Typography).attrs({
2297
+ textDecoration: "underline"
2298
+ })`
2010
2299
  ${stylesToInherit}
2011
2300
  `;
2012
- const StrikeThroughText = styled__default.default(designSystem.Typography).attrs({ textDecoration: "line-through" })`
2301
+ const StrikeThroughText = styledComponents.styled(designSystem.Typography).attrs({
2302
+ textDecoration: "line-through"
2303
+ })`
2013
2304
  ${stylesToInherit}
2014
2305
  `;
2015
- const InlineCode = styled__default.default.code`
2306
+ const InlineCode = styledComponents.styled.code`
2016
2307
  background-color: ${({ theme }) => theme.colors.neutral150};
2017
2308
  border-radius: ${({ theme }) => theme.borderRadius};
2018
2309
  padding: ${({ theme }) => `0 ${theme.spaces[2]}`};
@@ -2022,8 +2313,7 @@ const InlineCode = styled__default.default.code`
2022
2313
  `;
2023
2314
  const baseCheckIsActive = (editor, name2) => {
2024
2315
  const marks = slate.Editor.marks(editor);
2025
- if (!marks)
2026
- return false;
2316
+ if (!marks) return false;
2027
2317
  return Boolean(marks[name2]);
2028
2318
  };
2029
2319
  const baseHandleToggle = (editor, name2) => {
@@ -2182,13 +2472,14 @@ function useBlocksEditorContext(consumerName) {
2182
2472
  editor
2183
2473
  };
2184
2474
  }
2185
- const EditorDivider = styled__default.default(designSystem.Divider)`
2475
+ const EditorDivider = styledComponents.styled(designSystem.Divider)`
2186
2476
  background: ${({ theme }) => theme.colors.neutral200};
2187
2477
  `;
2188
- const ExpandIconButton = styled__default.default(designSystem.IconButton)`
2478
+ const ExpandIconButton = styledComponents.styled(designSystem.IconButton)`
2189
2479
  position: absolute;
2190
2480
  bottom: 1.2rem;
2191
2481
  right: 1.2rem;
2482
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2192
2483
  `;
2193
2484
  function useResetKey(value) {
2194
2485
  const slateUpdatesCount = React__namespace.useRef(0);
@@ -2277,7 +2568,7 @@ const BlocksEditor = React__namespace.forwardRef(
2277
2568
  !isExpandedMode && /* @__PURE__ */ jsxRuntime.jsx(
2278
2569
  ExpandIconButton,
2279
2570
  {
2280
- "aria-label": formatMessage({
2571
+ label: formatMessage({
2281
2572
  id: index.getTranslation("components.Blocks.expand"),
2282
2573
  defaultMessage: "Expand"
2283
2574
  }),
@@ -2300,8 +2591,8 @@ const BlocksInput = React__namespace.forwardRef(
2300
2591
  ({ label, name: name2, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {
2301
2592
  const id = React__namespace.useId();
2302
2593
  const field = strapiAdmin.useField(name2);
2303
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
2304
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { action: labelAction, children: label }),
2594
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
2595
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
2305
2596
  /* @__PURE__ */ jsxRuntime.jsx(
2306
2597
  BlocksEditor,
2307
2598
  {
@@ -2314,675 +2605,150 @@ const BlocksInput = React__namespace.forwardRef(
2314
2605
  ...editorProps
2315
2606
  }
2316
2607
  ),
2317
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldHint, {}),
2318
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldError, {})
2608
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
2609
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
2319
2610
  ] }) });
2320
2611
  }
2321
2612
  );
2322
- const createDefaultForm = (contentType, components = {}) => {
2323
- const traverseSchema = (attributes) => {
2324
- return Object.entries(attributes).reduce((acc, [key, attribute]) => {
2325
- if ("default" in attribute) {
2326
- acc[key] = attribute.default;
2327
- } else if (attribute.type === "component" && attribute.required) {
2328
- const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
2329
- if (attribute.repeatable) {
2330
- acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
2331
- } else {
2332
- acc[key] = defaultComponentForm;
2333
- }
2334
- } else if (attribute.type === "dynamiczone" && attribute.required) {
2335
- acc[key] = [];
2336
- }
2337
- return acc;
2338
- }, {});
2339
- };
2340
- return traverseSchema(contentType.attributes);
2341
- };
2613
+ const MemoizedBlocksInput = React__namespace.memo(BlocksInput);
2342
2614
  const Initializer = ({ disabled, name: name2, onClick }) => {
2343
2615
  const { formatMessage } = reactIntl.useIntl();
2344
2616
  const field = strapiAdmin.useField(name2);
2345
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2346
- /* @__PURE__ */ jsxRuntime.jsx(
2347
- designSystem.Box,
2348
- {
2349
- as: "button",
2350
- background: "neutral100",
2351
- borderColor: field.error ? "danger600" : "neutral200",
2352
- hasRadius: true,
2353
- disabled,
2354
- onClick,
2355
- paddingTop: 9,
2356
- paddingBottom: 9,
2357
- type: "button",
2358
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2359
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(CircleIcon, {}) }),
2360
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
2361
- id: index.getTranslation("components.empty-repeatable"),
2362
- defaultMessage: "No entry yet. Click on the button below to add one."
2363
- }) }) })
2364
- ] })
2365
- }
2366
- ),
2367
- field.error && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", variant: "pi", children: field.error })
2368
- ] });
2369
- };
2370
- const CircleIcon = styled__default.default(Icons.PlusCircle)`
2371
- width: 2.4rem;
2372
- height: 2.4rem;
2373
- > circle {
2374
- fill: ${({ theme }) => theme.colors.primary200};
2375
- }
2376
- > path {
2377
- fill: ${({ theme }) => theme.colors.primary600};
2378
- }
2379
- `;
2380
- const NonRepeatableComponent = ({
2381
- attribute,
2382
- name: name2,
2383
- children,
2384
- layout
2385
- }) => {
2386
- const { value } = strapiAdmin.useField(name2);
2387
- const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
2388
- const isNested = level > 0;
2389
- return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
2617
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
2390
2618
  designSystem.Box,
2391
2619
  {
2392
- background: "neutral100",
2393
- paddingLeft: 6,
2394
- paddingRight: 6,
2395
- paddingTop: 6,
2396
- paddingBottom: 6,
2397
- hasRadius: isNested,
2398
- borderColor: isNested ? "neutral200" : void 0,
2399
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
2400
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid, { gap: 4, children: row.map(({ size, ...field }) => {
2401
- const completeFieldName = `${name2}.${field.name}`;
2402
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2403
- }) }, index2);
2404
- }) })
2620
+ tag: "button",
2621
+ background: disabled ? "neutral150" : "neutral100",
2622
+ borderColor: field.error ? "danger600" : "neutral200",
2623
+ hasRadius: true,
2624
+ disabled,
2625
+ onClick,
2626
+ paddingTop: 9,
2627
+ paddingBottom: 9,
2628
+ type: "button",
2629
+ style: { cursor: disabled ? "not-allowed" : "pointer" },
2630
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2631
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
2632
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
2633
+ designSystem.Typography,
2634
+ {
2635
+ textColor: disabled ? "neutral600" : "primary600",
2636
+ variant: "pi",
2637
+ fontWeight: "bold",
2638
+ children: formatMessage({
2639
+ id: index.getTranslation("components.empty-repeatable"),
2640
+ defaultMessage: "No entry yet. Click to add one."
2641
+ })
2642
+ }
2643
+ ) })
2644
+ ] })
2405
2645
  }
2406
2646
  ) });
2407
2647
  };
2408
- const RepeatableComponent = ({
2409
- attribute,
2410
- disabled,
2411
- name: name2,
2412
- mainField,
2648
+ const AddComponentButton = ({
2649
+ hasError,
2650
+ isDisabled,
2651
+ isOpen,
2413
2652
  children,
2414
- layout
2653
+ onClick
2415
2654
  }) => {
2416
- const { toggleNotification } = strapiAdmin.useNotification();
2417
- const { formatMessage } = reactIntl.useIntl();
2418
- const { search: searchString } = reactRouterDom.useLocation();
2419
- const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
2420
- const { components } = index.useDoc();
2421
- const { value = [], error } = strapiAdmin.useField(name2);
2422
- const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
2423
- const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
2424
- const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
2425
- const { max = Infinity } = attribute;
2426
- const [collapseToOpen, setCollapseToOpen] = React__namespace.useState(null);
2427
- const [liveText, setLiveText] = React__namespace.useState("");
2428
- const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
2429
- if (search.has("field")) {
2430
- const fieldParam = search.get("field");
2431
- if (!fieldParam) {
2432
- return void 0;
2433
- }
2434
- const [, path] = fieldParam.split(`${name2}.`);
2435
- if (objects.getIn(value, path, void 0) !== void 0) {
2436
- const [subpath] = path.split(".");
2437
- return objects.getIn(value, subpath, void 0)?.__temp_key__;
2438
- }
2439
- }
2440
- return void 0;
2441
- }, [search, name2, value]);
2442
- React__namespace.useEffect(() => {
2443
- if (typeof componentTmpKeyWithFocussedField === "number") {
2444
- setCollapseToOpen(componentTmpKeyWithFocussedField);
2445
- }
2446
- }, [componentTmpKeyWithFocussedField]);
2447
- const toggleCollapses = () => {
2448
- setCollapseToOpen(null);
2449
- };
2450
- const handleClick = () => {
2451
- if (value.length < max) {
2452
- const schema = components[attribute.component];
2453
- const form = createDefaultForm(schema, components);
2454
- const data = transformDocument(schema, components)(form);
2455
- addFieldRow(name2, data);
2456
- } else if (value.length >= max) {
2457
- toggleNotification({
2458
- type: "info",
2459
- message: formatMessage({
2460
- id: index.getTranslation("components.notification.info.maximum-requirement")
2461
- })
2462
- });
2463
- }
2464
- };
2465
- const handleMoveComponentField = (newIndex, currentIndex) => {
2466
- setLiveText(
2467
- formatMessage(
2468
- {
2469
- id: index.getTranslation("dnd.reorder"),
2470
- defaultMessage: "{item}, moved. New position in list: {position}."
2471
- },
2472
- {
2473
- item: `${name2}.${currentIndex}`,
2474
- position: getItemPos(newIndex)
2475
- }
2476
- )
2477
- );
2478
- moveFieldRow(name2, currentIndex, newIndex);
2479
- };
2480
- const handleToggle = (key) => () => {
2481
- if (collapseToOpen === key) {
2482
- setCollapseToOpen(null);
2483
- } else {
2484
- setCollapseToOpen(key);
2485
- }
2486
- };
2487
- const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
2488
- const handleCancel = (index$1) => {
2489
- setLiveText(
2490
- formatMessage(
2491
- {
2492
- id: index.getTranslation("dnd.cancel-item"),
2493
- defaultMessage: "{item}, dropped. Re-order cancelled."
2494
- },
2495
- {
2496
- item: `${name2}.${index$1}`
2497
- }
2498
- )
2499
- );
2500
- };
2501
- const handleGrabItem = (index$1) => {
2502
- setLiveText(
2503
- formatMessage(
2504
- {
2505
- id: index.getTranslation("dnd.grab-item"),
2506
- defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
2507
- },
2508
- {
2509
- item: `${name2}.${index$1}`,
2510
- position: getItemPos(index$1)
2511
- }
2512
- )
2513
- );
2514
- };
2515
- const handleDropItem = (index$1) => {
2516
- setLiveText(
2517
- formatMessage(
2518
- {
2519
- id: index.getTranslation("dnd.drop-item"),
2520
- defaultMessage: `{item}, dropped. Final position in list: {position}.`
2521
- },
2522
- {
2523
- item: `${name2}.${index$1}`,
2524
- position: getItemPos(index$1)
2525
- }
2526
- )
2527
- );
2528
- };
2529
- const ariaDescriptionId = React__namespace.useId();
2530
- const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
2531
- if (value.length === 0) {
2532
- return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
2533
- }
2534
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
2535
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
2536
- id: index.getTranslation("dnd.instructions"),
2537
- defaultMessage: `Press spacebar to grab and re-order`
2538
- }) }),
2539
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
2540
- /* @__PURE__ */ jsxRuntime.jsxs(AccordionGroup, { error, children: [
2541
- /* @__PURE__ */ jsxRuntime.jsx(AccordionContent, { "aria-describedby": ariaDescriptionId, children: value.map(({ __temp_key__: key, id }, index2) => {
2542
- const nameWithIndex = `${name2}.${index2}`;
2543
- return /* @__PURE__ */ jsxRuntime.jsx(
2544
- Relations.ComponentProvider,
2655
+ return /* @__PURE__ */ jsxRuntime.jsx(
2656
+ StyledButton,
2657
+ {
2658
+ type: "button",
2659
+ onClick,
2660
+ disabled: isDisabled,
2661
+ background: "neutral0",
2662
+ style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2663
+ variant: "tertiary",
2664
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
2665
+ /* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2666
+ /* @__PURE__ */ jsxRuntime.jsx(
2667
+ designSystem.Typography,
2545
2668
  {
2546
- id,
2547
- uid: attribute.component,
2548
- level: level + 1,
2549
- type: "repeatable",
2550
- children: /* @__PURE__ */ jsxRuntime.jsx(
2551
- Component,
2552
- {
2553
- disabled,
2554
- name: nameWithIndex,
2555
- attribute,
2556
- index: index2,
2557
- isOpen: collapseToOpen === key,
2558
- mainField,
2559
- onMoveItem: handleMoveComponentField,
2560
- onClickToggle: handleToggle(key),
2561
- onDeleteComponent: () => {
2562
- removeFieldRow(name2, index2);
2563
- toggleCollapses();
2564
- },
2565
- toggleCollapses,
2566
- onCancel: handleCancel,
2567
- onDropItem: handleDropItem,
2568
- onGrabItem: handleGrabItem,
2569
- children: layout.map((row, index22) => {
2570
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid, { gap: 4, children: row.map(({ size, ...field }) => {
2571
- const completeFieldName = `${nameWithIndex}.${field.name}`;
2572
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2573
- }) }, index22);
2574
- })
2575
- }
2576
- )
2577
- },
2578
- key
2579
- );
2580
- }) }),
2581
- /* @__PURE__ */ jsxRuntime.jsx(AccordionFooter, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", height: "48px", background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
2582
- id: index.getTranslation("containers.EditView.add.new-entry"),
2583
- defaultMessage: "Add an entry"
2584
- }) }) }) })
2585
- ] })
2586
- ] });
2669
+ variant: "pi",
2670
+ fontWeight: "bold",
2671
+ textColor: hasError && !isOpen ? "danger600" : "neutral600",
2672
+ children
2673
+ }
2674
+ )
2675
+ ] })
2676
+ }
2677
+ );
2587
2678
  };
2588
- const TextButtonCustom = styled__default.default(designSystem.TextButton)`
2589
- height: 100%;
2590
- width: 100%;
2591
- border-radius: 0 0 4px 4px;
2592
- display: flex;
2593
- justify-content: center;
2594
- span {
2595
- font-weight: 600;
2596
- font-size: 14px;
2597
- }
2598
- `;
2599
- const AccordionFooter = styled__default.default(designSystem.Box)`
2600
- overflow: hidden;
2601
- border-bottom: 1px solid ${({ theme }) => theme.colors.neutral200};
2602
- border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
2603
- border-left: 1px solid ${({ theme }) => theme.colors.neutral200};
2604
- border-radius: 0 0 ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius};
2605
- `;
2606
- const AccordionContent = styled__default.default(designSystem.Box)`
2607
- border-bottom: none;
2608
-
2609
- /* add the borders and make sure the top is transparent to avoid jumping with the hover effect */
2610
- & > div > div {
2611
- border: 1px solid ${({ theme }) => theme.colors.neutral200};
2612
- border-top-color: transparent;
2613
- }
2614
-
2615
- /* the top accordion _does_ need a border though */
2616
- & > div:first-child > div {
2617
- border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2618
- }
2619
-
2620
- /* Reset all the border-radius' */
2621
- & > div > div,
2622
- & > div > div > div {
2623
- border-radius: unset;
2624
- }
2679
+ const StyledAddIcon = styledComponents.styled(Icons.PlusCircle)`
2680
+ height: ${({ theme }) => theme.spaces[6]};
2681
+ width: ${({ theme }) => theme.spaces[6]};
2682
+ transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
2625
2683
 
2626
- /* Give the border radius back to the first accordion */
2627
- & > div:first-child > div,
2628
- & > div:first-child > div > div {
2629
- border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
2684
+ > circle {
2685
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
2630
2686
  }
2631
-
2632
- & > div > div[data-strapi-expanded='true'] {
2633
- border: 1px solid ${({ theme }) => theme.colors.primary600};
2687
+ > path {
2688
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral500};
2634
2689
  }
2635
2690
  `;
2636
- const AccordionGroup = ({ children, error }) => {
2637
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.KeyboardNavigable, { attributeName: "data-strapi-accordion-toggle", children: [
2638
- children,
2639
- error && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "danger600", children: error }) })
2691
+ const StyledButton = styledComponents.styled(designSystem.Button)`
2692
+ padding-left: ${({ theme }) => theme.spaces[3]};
2693
+ border-radius: 26px;
2694
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2695
+ height: 5rem;
2696
+ `;
2697
+ const ComponentCategory = ({
2698
+ category,
2699
+ components = [],
2700
+ variant = "primary",
2701
+ onAddComponent
2702
+ }) => {
2703
+ const { formatMessage } = reactIntl.useIntl();
2704
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: category, children: [
2705
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
2706
+ /* @__PURE__ */ jsxRuntime.jsx(ResponsiveAccordionContent, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
2707
+ ComponentBox,
2708
+ {
2709
+ tag: "button",
2710
+ type: "button",
2711
+ background: "neutral100",
2712
+ justifyContent: "center",
2713
+ onClick: onAddComponent(uid),
2714
+ hasRadius: true,
2715
+ height: "8.4rem",
2716
+ shrink: 0,
2717
+ borderColor: "neutral200",
2718
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2719
+ /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
2720
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2721
+ ] })
2722
+ },
2723
+ uid
2724
+ )) }) })
2640
2725
  ] });
2641
2726
  };
2642
- const CustomIconButton$1 = styled__default.default(designSystem.IconButton)`
2643
- background-color: transparent;
2727
+ const ResponsiveAccordionContent = styledComponents.styled(designSystem.Accordion.Content)`
2728
+ container-type: inline-size;
2729
+ `;
2730
+ const Grid = styledComponents.styled(designSystem.Box)`
2731
+ display: grid;
2732
+ grid-template-columns: repeat(auto-fill, 100%);
2733
+ grid-gap: ${({ theme }) => theme.spaces[1]};
2644
2734
 
2645
- svg {
2646
- path {
2647
- fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
2648
- }
2735
+ @container (min-width: ${() => RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
2736
+ grid-template-columns: repeat(auto-fill, 14rem);
2737
+ }
2738
+ `;
2739
+ const ComponentBox = styledComponents.styled(designSystem.Flex)`
2740
+ color: ${({ theme }) => theme.colors.neutral600};
2741
+ cursor: pointer;
2742
+
2743
+ @media (prefers-reduced-motion: no-preference) {
2744
+ transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2649
2745
  }
2650
2746
 
2747
+ &:focus,
2651
2748
  &:hover {
2652
- svg {
2653
- path {
2654
- fill: ${({ theme }) => theme.colors.primary600};
2655
- }
2656
- }
2657
- }
2658
- `;
2659
- const ActionsFlex$1 = styled__default.default(designSystem.Flex)`
2660
- & .drag-handle {
2661
- background: unset;
2662
-
2663
- svg {
2664
- path {
2665
- fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : void 0};
2666
- }
2667
- }
2668
-
2669
- &:hover {
2670
- svg {
2671
- path {
2672
- /* keeps the hover style of the accordion */
2673
- fill: ${({ theme }) => theme.colors.primary600};
2674
- }
2675
- }
2676
- }
2677
- }
2678
- `;
2679
- const Component = ({
2680
- disabled,
2681
- index: index$1,
2682
- isOpen,
2683
- name: name2,
2684
- mainField = {
2685
- name: "id",
2686
- type: "integer"
2687
- },
2688
- children,
2689
- onClickToggle,
2690
- onDeleteComponent,
2691
- toggleCollapses,
2692
- ...dragProps
2693
- }) => {
2694
- const { formatMessage } = reactIntl.useIntl();
2695
- const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
2696
- return objects.getIn(state.values, [...name2.split("."), mainField.name]);
2697
- });
2698
- const accordionRef = React__namespace.useRef(null);
2699
- const componentKey = name2.split(".").slice(0, -1).join(".");
2700
- const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
2701
- type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
2702
- index: index$1,
2703
- item: {
2704
- index: index$1,
2705
- displayedValue: displayValue
2706
- },
2707
- onStart() {
2708
- toggleCollapses();
2709
- },
2710
- ...dragProps
2711
- });
2712
- React__namespace.useEffect(() => {
2713
- dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
2714
- }, [dragPreviewRef, index$1]);
2715
- const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
2716
- const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
2717
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { ref: (ref) => composedBoxRefs(ref), children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview$1, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion, { expanded: isOpen, onToggle: onClickToggle, id: name2, size: "S", children: [
2718
- /* @__PURE__ */ jsxRuntime.jsx(
2719
- designSystem.AccordionToggle,
2720
- {
2721
- action: disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(ActionsFlex$1, { gap: 0, expanded: isOpen, children: [
2722
- /* @__PURE__ */ jsxRuntime.jsx(
2723
- CustomIconButton$1,
2724
- {
2725
- expanded: isOpen,
2726
- borderWidth: 0,
2727
- onClick: onDeleteComponent,
2728
- label: formatMessage({
2729
- id: index.getTranslation("containers.Edit.delete"),
2730
- defaultMessage: "Delete"
2731
- }),
2732
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
2733
- }
2734
- ),
2735
- /* @__PURE__ */ jsxRuntime.jsx(
2736
- designSystem.IconButton,
2737
- {
2738
- className: "drag-handle",
2739
- ref: composedAccordionRefs,
2740
- forwardedAs: "div",
2741
- role: "button",
2742
- borderWidth: 0,
2743
- tabIndex: 0,
2744
- onClick: (e) => e.stopPropagation(),
2745
- "data-handler-id": handlerId,
2746
- label: formatMessage({
2747
- id: index.getTranslation("components.DragHandle-label"),
2748
- defaultMessage: "Drag"
2749
- }),
2750
- onKeyDown: handleKeyDown,
2751
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
2752
- }
2753
- )
2754
- ] }),
2755
- title: displayValue,
2756
- togglePosition: "left"
2757
- }
2758
- ),
2759
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.AccordionContent, { children: /* @__PURE__ */ jsxRuntime.jsx(
2760
- designSystem.Flex,
2761
- {
2762
- direction: "column",
2763
- alignItems: "stretch",
2764
- background: "neutral100",
2765
- padding: 6,
2766
- gap: 6,
2767
- children
2768
- }
2769
- ) })
2770
- ] }) });
2771
- };
2772
- const Preview$1 = () => {
2773
- return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { as: "span", padding: 6, background: "primary100" });
2774
- };
2775
- const StyledSpan = styled__default.default(designSystem.Box)`
2776
- display: block;
2777
- outline: 1px dashed ${({ theme }) => theme.colors.primary500};
2778
- outline-offset: -1px;
2779
- `;
2780
- const ComponentInput = ({
2781
- label,
2782
- required,
2783
- name: name2,
2784
- attribute,
2785
- disabled,
2786
- labelAction,
2787
- ...props
2788
- }) => {
2789
- const { formatMessage } = reactIntl.useIntl();
2790
- const field = strapiAdmin.useField(name2);
2791
- const showResetComponent = !attribute.repeatable && field.value && !disabled;
2792
- const { components } = index.useDoc();
2793
- const handleInitialisationClick = () => {
2794
- const schema = components[attribute.component];
2795
- const form = createDefaultForm(schema, components);
2796
- const data = transformDocument(schema, components)(form);
2797
- field.onChange(name2, data);
2798
- };
2799
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
2800
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
2801
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { paddingBottom: 1, children: [
2802
- /* @__PURE__ */ jsxRuntime.jsxs(
2803
- designSystem.Typography,
2804
- {
2805
- textColor: "neutral800",
2806
- htmlFor: name2,
2807
- variant: "pi",
2808
- fontWeight: "bold",
2809
- as: "label",
2810
- children: [
2811
- label,
2812
- attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2813
- " (",
2814
- Array.isArray(field.value) ? field.value.length : 0,
2815
- ")"
2816
- ] }),
2817
- required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" })
2818
- ]
2819
- }
2820
- ),
2821
- labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
2822
- ] }),
2823
- showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
2824
- designSystem.IconButton,
2825
- {
2826
- label: formatMessage({
2827
- id: index.getTranslation("components.reset-entry"),
2828
- defaultMessage: "Reset Entry"
2829
- }),
2830
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {}),
2831
- borderWidth: 0,
2832
- onClick: () => {
2833
- field.onChange(name2, null);
2834
- }
2835
- }
2836
- )
2837
- ] }),
2838
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
2839
- !attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
2840
- !attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
2841
- attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children })
2842
- ] })
2843
- ] });
2844
- };
2845
- const AddComponentButton = ({
2846
- hasError,
2847
- isDisabled,
2848
- isOpen,
2849
- children,
2850
- onClick
2851
- }) => {
2852
- return /* @__PURE__ */ jsxRuntime.jsx(
2853
- StyledButton,
2854
- {
2855
- type: "button",
2856
- onClick,
2857
- disabled: isDisabled,
2858
- background: "neutral0",
2859
- paddingTop: 3,
2860
- paddingBottom: 3,
2861
- paddingLeft: 4,
2862
- paddingRight: 4,
2863
- style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2864
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { as: "span", gap: 2, children: [
2865
- /* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2866
- /* @__PURE__ */ jsxRuntime.jsx(
2867
- designSystem.Typography,
2868
- {
2869
- variant: "pi",
2870
- fontWeight: "bold",
2871
- textColor: hasError && !isOpen ? "danger600" : "neutral500",
2872
- children
2873
- }
2874
- )
2875
- ] })
2876
- }
2877
- );
2878
- };
2879
- const StyledAddIcon = styled__default.default(Icons.PlusCircle)`
2880
- height: ${({ theme }) => theme.spaces[6]};
2881
- width: ${({ theme }) => theme.spaces[6]};
2882
- transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
2883
-
2884
- > circle {
2885
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
2886
- }
2887
- > path {
2888
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
2889
- }
2890
- `;
2891
- const StyledButton = styled__default.default(designSystem.BaseButton)`
2892
- border-radius: 26px;
2893
- border-color: ${({ theme }) => theme.colors.neutral150};
2894
- box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2895
-
2896
- &:hover {
2897
- ${designSystem.Typography} {
2898
- color: ${({ theme }) => theme.colors.primary600};
2899
- }
2900
-
2901
- ${StyledAddIcon} {
2902
- > circle {
2903
- fill: ${({ theme }) => theme.colors.primary600};
2904
- }
2905
- > path {
2906
- fill: ${({ theme }) => theme.colors.neutral100};
2907
- }
2908
- }
2909
- }
2910
- &:active {
2911
- ${designSystem.Typography} {
2912
- color: ${({ theme }) => theme.colors.primary600};
2913
- }
2914
- ${StyledAddIcon} {
2915
- > circle {
2916
- fill: ${({ theme }) => theme.colors.primary600};
2917
- }
2918
- > path {
2919
- fill: ${({ theme }) => theme.colors.neutral100};
2920
- }
2921
- }
2922
- }
2923
- `;
2924
- const ComponentCategory = ({
2925
- category,
2926
- components = [],
2927
- variant = "primary",
2928
- isOpen,
2929
- onAddComponent,
2930
- onToggle
2931
- }) => {
2932
- const { formatMessage } = reactIntl.useIntl();
2933
- const handleToggle = () => {
2934
- onToggle(category);
2935
- };
2936
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion, { expanded: isOpen, onToggle: handleToggle, size: "S", children: [
2937
- /* @__PURE__ */ jsxRuntime.jsx(
2938
- designSystem.AccordionToggle,
2939
- {
2940
- variant,
2941
- title: formatMessage({ id: category, defaultMessage: category }),
2942
- togglePosition: "left"
2943
- }
2944
- ),
2945
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.AccordionContent, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
2946
- ComponentBox,
2947
- {
2948
- as: "button",
2949
- type: "button",
2950
- background: "neutral100",
2951
- justifyContent: "center",
2952
- onClick: onAddComponent(uid),
2953
- hasRadius: true,
2954
- height: "8.4rem",
2955
- shrink: 0,
2956
- borderColor: "neutral200",
2957
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2958
- /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { icon }),
2959
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral600", children: displayName })
2960
- ] })
2961
- },
2962
- uid
2963
- )) }) }) })
2964
- ] });
2965
- };
2966
- const Grid = styled__default.default.div`
2967
- display: grid;
2968
- grid-template-columns: repeat(auto-fit, 14rem);
2969
- grid-gap: ${({ theme }) => theme.spaces[1]};
2970
- `;
2971
- const ComponentBox = styled__default.default(designSystem.Flex)`
2972
- &:focus,
2973
- &:hover {
2974
- border: 1px solid ${({ theme }) => theme.colors.primary200};
2975
- background: ${({ theme }) => theme.colors.primary100};
2976
-
2977
- ${designSystem.Typography} {
2978
- color: ${({ theme }) => theme.colors.primary600};
2979
- }
2980
-
2981
- /* > Flex > ComponentIcon */
2982
- > div > div:first-child {
2983
- background: ${({ theme }) => theme.colors.primary200};
2984
- color: ${({ theme }) => theme.colors.primary600};
2985
- }
2749
+ border: 1px solid ${({ theme }) => theme.colors.primary200};
2750
+ background: ${({ theme }) => theme.colors.primary100};
2751
+ color: ${({ theme }) => theme.colors.primary600};
2986
2752
  }
2987
2753
  `;
2988
2754
  const ComponentPicker = ({
@@ -2991,19 +2757,8 @@ const ComponentPicker = ({
2991
2757
  onClickAddComponent
2992
2758
  }) => {
2993
2759
  const { formatMessage } = reactIntl.useIntl();
2994
- const [categoryToOpen, setCategoryToOpen] = React__namespace.useState("");
2995
- React__namespace.useEffect(() => {
2996
- const categoryKeys = Object.keys(dynamicComponentsByCategory);
2997
- if (isOpen && categoryKeys.length > 0) {
2998
- setCategoryToOpen(categoryKeys[0]);
2999
- }
3000
- }, [isOpen, dynamicComponentsByCategory]);
3001
2760
  const handleAddComponentToDz = (componentUid) => () => {
3002
2761
  onClickAddComponent(componentUid);
3003
- setCategoryToOpen("");
3004
- };
3005
- const handleClickToggle = (categoryName) => {
3006
- setCategoryToOpen((currentCat) => currentCat === categoryName ? "" : categoryName);
3007
2762
  };
3008
2763
  if (!isOpen) {
3009
2764
  return null;
@@ -3024,14 +2779,12 @@ const ComponentPicker = ({
3024
2779
  id: index.getTranslation("components.DynamicZone.ComponentPicker-label"),
3025
2780
  defaultMessage: "Pick one component"
3026
2781
  }) }) }),
3027
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.KeyboardNavigable, { attributeName: "data-strapi-accordion-toggle", children: Object.entries(dynamicComponentsByCategory).map(([category, components], index2) => /* @__PURE__ */ jsxRuntime.jsx(
2782
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index2) => /* @__PURE__ */ jsxRuntime.jsx(
3028
2783
  ComponentCategory,
3029
2784
  {
3030
2785
  category,
3031
2786
  components,
3032
2787
  onAddComponent: handleAddComponentToDz,
3033
- isOpen: category === categoryToOpen,
3034
- onToggle: handleClickToggle,
3035
2788
  variant: index2 % 2 === 1 ? "primary" : "secondary"
3036
2789
  },
3037
2790
  category
@@ -3040,45 +2793,493 @@ const ComponentPicker = ({
3040
2793
  }
3041
2794
  );
3042
2795
  };
2796
+ const DynamicComponent = ({
2797
+ componentUid,
2798
+ disabled,
2799
+ index: index$1,
2800
+ name: name2,
2801
+ onRemoveComponentClick,
2802
+ onMoveComponent,
2803
+ onGrabItem,
2804
+ onDropItem,
2805
+ onCancel,
2806
+ dynamicComponentsByCategory = {},
2807
+ onAddComponent,
2808
+ children
2809
+ }) => {
2810
+ const { formatMessage } = reactIntl.useIntl();
2811
+ const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
2812
+ const {
2813
+ edit: { components }
2814
+ } = index.useDocLayout();
2815
+ const title = React__namespace.useMemo(() => {
2816
+ const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
2817
+ const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
2818
+ const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
2819
+ const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
2820
+ return mainValue;
2821
+ }, [componentUid, components, formValues, name2, index$1]);
2822
+ const { icon, displayName } = React__namespace.useMemo(() => {
2823
+ const [category] = componentUid.split(".");
2824
+ const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
2825
+ (component) => component.uid === componentUid
2826
+ ) ?? { icon: null, displayName: null };
2827
+ return { icon: icon2, displayName: displayName2 };
2828
+ }, [componentUid, dynamicComponentsByCategory]);
2829
+ const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
2830
+ type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
2831
+ index: index$1,
2832
+ item: {
2833
+ index: index$1,
2834
+ displayedValue: `${displayName} ${title}`,
2835
+ icon
2836
+ },
2837
+ onMoveItem: onMoveComponent,
2838
+ onDropItem,
2839
+ onGrabItem,
2840
+ onCancel
2841
+ });
2842
+ React__namespace.useEffect(() => {
2843
+ dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
2844
+ }, [dragPreviewRef, index$1]);
2845
+ const accordionValue = React__namespace.useId();
2846
+ const { value = [], rawError } = strapiAdmin.useField(`${name2}.${index$1}`);
2847
+ const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
2848
+ React__namespace.useEffect(() => {
2849
+ if (rawError && value) {
2850
+ setCollapseToOpen(accordionValue);
2851
+ }
2852
+ }, [rawError, value, accordionValue]);
2853
+ const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
2854
+ const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2855
+ /* @__PURE__ */ jsxRuntime.jsx(
2856
+ designSystem.IconButton,
2857
+ {
2858
+ variant: "ghost",
2859
+ label: formatMessage(
2860
+ {
2861
+ id: index.getTranslation("components.DynamicZone.delete-label"),
2862
+ defaultMessage: "Delete {name}"
2863
+ },
2864
+ { name: title }
2865
+ ),
2866
+ onClick: onRemoveComponentClick,
2867
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
2868
+ }
2869
+ ),
2870
+ /* @__PURE__ */ jsxRuntime.jsx(
2871
+ designSystem.IconButton,
2872
+ {
2873
+ variant: "ghost",
2874
+ onClick: (e) => e.stopPropagation(),
2875
+ "data-handler-id": handlerId,
2876
+ ref: dragRef,
2877
+ label: formatMessage({
2878
+ id: index.getTranslation("components.DragHandle-label"),
2879
+ defaultMessage: "Drag"
2880
+ }),
2881
+ onKeyDown: handleKeyDown,
2882
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
2883
+ }
2884
+ ),
2885
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
2886
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 0, paddingRight: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
2887
+ designSystem.IconButton,
2888
+ {
2889
+ variant: "ghost",
2890
+ label: formatMessage({
2891
+ id: index.getTranslation("components.DynamicZone.more-actions"),
2892
+ defaultMessage: "More actions"
2893
+ }),
2894
+ tag: "span",
2895
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false })
2896
+ }
2897
+ ) }),
2898
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
2899
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
2900
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
2901
+ id: index.getTranslation("components.DynamicZone.add-item-above"),
2902
+ defaultMessage: "Add component above"
2903
+ }) }),
2904
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2905
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
2906
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
2907
+ ] }, category)) })
2908
+ ] }),
2909
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
2910
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
2911
+ id: index.getTranslation("components.DynamicZone.add-item-below"),
2912
+ defaultMessage: "Add component below"
2913
+ }) }),
2914
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2915
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
2916
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
2917
+ ] }, category)) })
2918
+ ] })
2919
+ ] })
2920
+ ] })
2921
+ ] });
2922
+ const accordionTitle = title ? `${displayName} ${title}` : displayName;
2923
+ return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
2924
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
2925
+ /* @__PURE__ */ jsxRuntime.jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview$1, {}) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: accordionValue, children: [
2926
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
2927
+ /* @__PURE__ */ jsxRuntime.jsx(
2928
+ designSystem.Accordion.Trigger,
2929
+ {
2930
+ icon: icon && ComponentIcon.COMPONENT_ICONS[icon] ? ComponentIcon.COMPONENT_ICONS[icon] : ComponentIcon.COMPONENT_ICONS.dashboard,
2931
+ children: accordionTitle
2932
+ }
2933
+ ),
2934
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
2935
+ ] }),
2936
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsxRuntime.jsx(
2937
+ designSystem.Grid.Item,
2938
+ {
2939
+ col: 12,
2940
+ s: 12,
2941
+ xs: 12,
2942
+ direction: "column",
2943
+ alignItems: "stretch",
2944
+ children: /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
2945
+ const fieldName = `${name2}.${index$1}.${field.name}`;
2946
+ const fieldWithTranslatedLabel = {
2947
+ ...field,
2948
+ label: formatMessage({
2949
+ id: `content-manager.components.${componentUid}.${field.name}`,
2950
+ defaultMessage: field.label
2951
+ })
2952
+ };
2953
+ return /* @__PURE__ */ jsxRuntime.jsx(
2954
+ ResponsiveGridItem,
2955
+ {
2956
+ col: size,
2957
+ s: 12,
2958
+ xs: 12,
2959
+ direction: "column",
2960
+ alignItems: "stretch",
2961
+ children: children ? children({ ...fieldWithTranslatedLabel, name: fieldName }) : /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
2962
+ },
2963
+ fieldName
2964
+ );
2965
+ }) })
2966
+ },
2967
+ rowInd
2968
+ )) }) }) }) })
2969
+ ] }) }) })
2970
+ ] });
2971
+ };
2972
+ const StyledBox = styledComponents.styled(designSystem.Box)`
2973
+ > div:first-child {
2974
+ box-shadow: ${({ theme }) => theme.shadows.tableShadow};
2975
+ }
2976
+ `;
2977
+ const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
2978
+ border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
2979
+ `;
2980
+ const Rectangle = styledComponents.styled(designSystem.Box)`
2981
+ width: ${({ theme }) => theme.spaces[2]};
2982
+ height: ${({ theme }) => theme.spaces[4]};
2983
+ `;
2984
+ const Preview$1 = styledComponents.styled.span`
2985
+ display: block;
2986
+ background-color: ${({ theme }) => theme.colors.primary100};
2987
+ outline: 1px dashed ${({ theme }) => theme.colors.primary500};
2988
+ outline-offset: -1px;
2989
+ padding: ${({ theme }) => theme.spaces[6]};
2990
+ `;
2991
+ const ComponentContainer = styledComponents.styled(designSystem.Box)`
2992
+ list-style: none;
2993
+ padding: 0;
2994
+ margin: 0;
2995
+ `;
2996
+ const DynamicZoneLabel = ({
2997
+ hint,
2998
+ label,
2999
+ labelAction,
3000
+ name: name2,
3001
+ numberOfComponents = 0,
3002
+ required
3003
+ }) => {
3004
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
3005
+ designSystem.Box,
3006
+ {
3007
+ paddingTop: 3,
3008
+ paddingBottom: 3,
3009
+ paddingRight: 4,
3010
+ paddingLeft: 4,
3011
+ borderRadius: "26px",
3012
+ background: "neutral0",
3013
+ shadow: "filterShadow",
3014
+ color: "neutral500",
3015
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
3016
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
3017
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
3018
+ label || name2,
3019
+ " "
3020
+ ] }),
3021
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
3022
+ "(",
3023
+ numberOfComponents,
3024
+ ")"
3025
+ ] }),
3026
+ required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
3027
+ labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
3028
+ ] }),
3029
+ hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
3030
+ ] })
3031
+ }
3032
+ ) });
3033
+ };
3034
+ const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
3035
+ "DynamicZone",
3036
+ {
3037
+ isInDynamicZone: false
3038
+ }
3039
+ );
3040
+ const DynamicZone = ({
3041
+ attribute,
3042
+ disabled: disabledProp,
3043
+ hint,
3044
+ label,
3045
+ labelAction,
3046
+ name: name2,
3047
+ required = false,
3048
+ children
3049
+ }) => {
3050
+ const { max = Infinity, min = -Infinity } = attribute ?? {};
3051
+ const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
3052
+ const [liveText, setLiveText] = React__namespace.useState("");
3053
+ const { components, isLoading } = index.useDoc();
3054
+ const disabled = disabledProp || isLoading;
3055
+ const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
3056
+ "DynamicZone",
3057
+ ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
3058
+ addFieldRow: addFieldRow2,
3059
+ removeFieldRow: removeFieldRow2,
3060
+ moveFieldRow: moveFieldRow2
3061
+ })
3062
+ );
3063
+ const { value = [], error } = strapiAdmin.useField(name2);
3064
+ const dynamicComponentsByCategory = React__namespace.useMemo(() => {
3065
+ return attribute.components.reduce((acc, componentUid) => {
3066
+ const { category, info } = components[componentUid] ?? { info: {} };
3067
+ const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
3068
+ if (!acc[category]) {
3069
+ acc[category] = [];
3070
+ }
3071
+ acc[category] = [...acc[category], component];
3072
+ return acc;
3073
+ }, {});
3074
+ }, [attribute.components, components]);
3075
+ const { formatMessage } = reactIntl.useIntl();
3076
+ const { toggleNotification } = strapiAdmin.useNotification();
3077
+ const dynamicDisplayedComponentsLength = value.length;
3078
+ const handleAddComponent = (uid, position) => {
3079
+ setAddComponentIsOpen(false);
3080
+ const schema = components[uid];
3081
+ const form = index.createDefaultForm(schema, components);
3082
+ const transformations = pipe__default.default(index.transformDocument(schema, components), (data2) => ({
3083
+ ...data2,
3084
+ __component: uid
3085
+ }));
3086
+ const data = transformations(form);
3087
+ addFieldRow(name2, data, position);
3088
+ };
3089
+ const handleClickOpenPicker = () => {
3090
+ if (dynamicDisplayedComponentsLength < max) {
3091
+ setAddComponentIsOpen((prev) => !prev);
3092
+ } else {
3093
+ toggleNotification({
3094
+ type: "info",
3095
+ message: formatMessage({
3096
+ id: index.getTranslation("components.notification.info.maximum-requirement")
3097
+ })
3098
+ });
3099
+ }
3100
+ };
3101
+ const handleMoveComponent = (newIndex, currentIndex) => {
3102
+ setLiveText(
3103
+ formatMessage(
3104
+ {
3105
+ id: index.getTranslation("dnd.reorder"),
3106
+ defaultMessage: "{item}, moved. New position in list: {position}."
3107
+ },
3108
+ {
3109
+ item: `${name2}.${currentIndex}`,
3110
+ position: getItemPos(newIndex)
3111
+ }
3112
+ )
3113
+ );
3114
+ moveFieldRow(name2, currentIndex, newIndex);
3115
+ };
3116
+ const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
3117
+ const handleCancel = (index$1) => {
3118
+ setLiveText(
3119
+ formatMessage(
3120
+ {
3121
+ id: index.getTranslation("dnd.cancel-item"),
3122
+ defaultMessage: "{item}, dropped. Re-order cancelled."
3123
+ },
3124
+ {
3125
+ item: `${name2}.${index$1}`
3126
+ }
3127
+ )
3128
+ );
3129
+ };
3130
+ const handleGrabItem = (index$1) => {
3131
+ setLiveText(
3132
+ formatMessage(
3133
+ {
3134
+ id: index.getTranslation("dnd.grab-item"),
3135
+ defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
3136
+ },
3137
+ {
3138
+ item: `${name2}.${index$1}`,
3139
+ position: getItemPos(index$1)
3140
+ }
3141
+ )
3142
+ );
3143
+ };
3144
+ const handleDropItem = (index$1) => {
3145
+ setLiveText(
3146
+ formatMessage(
3147
+ {
3148
+ id: index.getTranslation("dnd.drop-item"),
3149
+ defaultMessage: `{item}, dropped. Final position in list: {position}.`
3150
+ },
3151
+ {
3152
+ item: `${name2}.${index$1}`,
3153
+ position: getItemPos(index$1)
3154
+ }
3155
+ )
3156
+ );
3157
+ };
3158
+ const handleRemoveComponent = (name22, currentIndex) => () => {
3159
+ removeFieldRow(name22, currentIndex);
3160
+ };
3161
+ const hasError = error !== void 0;
3162
+ const renderButtonLabel = () => {
3163
+ if (addComponentIsOpen) {
3164
+ return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
3165
+ }
3166
+ if (hasError && dynamicDisplayedComponentsLength > max) {
3167
+ return formatMessage(
3168
+ {
3169
+ id: index.getTranslation(`components.DynamicZone.extra-components`),
3170
+ defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
3171
+ },
3172
+ {
3173
+ number: dynamicDisplayedComponentsLength - max
3174
+ }
3175
+ );
3176
+ }
3177
+ if (hasError && dynamicDisplayedComponentsLength < min) {
3178
+ return formatMessage(
3179
+ {
3180
+ id: index.getTranslation(`components.DynamicZone.missing-components`),
3181
+ defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
3182
+ },
3183
+ { number: min - dynamicDisplayedComponentsLength }
3184
+ );
3185
+ }
3186
+ return formatMessage(
3187
+ {
3188
+ id: index.getTranslation("components.DynamicZone.add-component"),
3189
+ defaultMessage: "Add a component to {componentName}"
3190
+ },
3191
+ { componentName: label || name2 }
3192
+ );
3193
+ };
3194
+ const level = Relations.useComponent("DynamicZone", (state) => state.level);
3195
+ const ariaDescriptionId = React__namespace.useId();
3196
+ return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3197
+ dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
3198
+ /* @__PURE__ */ jsxRuntime.jsx(
3199
+ DynamicZoneLabel,
3200
+ {
3201
+ hint,
3202
+ label,
3203
+ labelAction,
3204
+ name: name2,
3205
+ numberOfComponents: dynamicDisplayedComponentsLength,
3206
+ required
3207
+ }
3208
+ ),
3209
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
3210
+ id: index.getTranslation("dnd.instructions"),
3211
+ defaultMessage: `Press spacebar to grab and re-order`
3212
+ }) }),
3213
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
3214
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
3215
+ Relations.ComponentProvider,
3216
+ {
3217
+ level: level + 1,
3218
+ uid: field.__component,
3219
+ id: field.id,
3220
+ type: "dynamiczone",
3221
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3222
+ DynamicComponent,
3223
+ {
3224
+ disabled,
3225
+ name: name2,
3226
+ index: index2,
3227
+ componentUid: field.__component,
3228
+ onMoveComponent: handleMoveComponent,
3229
+ onRemoveComponentClick: handleRemoveComponent(name2, index2),
3230
+ onCancel: handleCancel,
3231
+ onDropItem: handleDropItem,
3232
+ onGrabItem: handleGrabItem,
3233
+ onAddComponent: handleAddComponent,
3234
+ dynamicComponentsByCategory,
3235
+ children
3236
+ }
3237
+ )
3238
+ },
3239
+ field.__temp_key__
3240
+ )) })
3241
+ ] }),
3242
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
3243
+ AddComponentButton,
3244
+ {
3245
+ hasError,
3246
+ isDisabled: disabled,
3247
+ isOpen: addComponentIsOpen,
3248
+ onClick: handleClickOpenPicker,
3249
+ children: renderButtonLabel()
3250
+ }
3251
+ ) }),
3252
+ /* @__PURE__ */ jsxRuntime.jsx(
3253
+ ComponentPicker,
3254
+ {
3255
+ dynamicComponentsByCategory,
3256
+ isOpen: addComponentIsOpen,
3257
+ onClickAddComponent: handleAddComponent
3258
+ }
3259
+ )
3260
+ ] }) });
3261
+ };
3043
3262
  const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
3044
3263
  const { formatMessage } = reactIntl.useIntl();
3045
3264
  const placeholder = formatMessage({
3046
3265
  id: "components.NotAllowedInput.text",
3047
3266
  defaultMessage: "No permissions to see this field"
3048
3267
  });
3049
- return /* @__PURE__ */ jsxRuntime.jsx(
3050
- designSystem.TextInput,
3051
- {
3052
- disabled: true,
3053
- label,
3054
- id: name2,
3055
- hint,
3056
- name: name2,
3057
- placeholder,
3058
- required,
3059
- startAction: /* @__PURE__ */ jsxRuntime.jsx(StyledIcon, {}),
3060
- type: "text",
3061
- value: ""
3062
- }
3063
- );
3268
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { id: name2, hint, name: name2, required, children: [
3269
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: label }),
3270
+ /* @__PURE__ */ jsxRuntime.jsx(
3271
+ designSystem.TextInput,
3272
+ {
3273
+ disabled: true,
3274
+ placeholder,
3275
+ startAction: /* @__PURE__ */ jsxRuntime.jsx(Icons.EyeStriked, { fill: "neutral600" }),
3276
+ type: "text",
3277
+ value: ""
3278
+ }
3279
+ ),
3280
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
3281
+ ] });
3064
3282
  };
3065
- const StyledIcon = styled__default.default(Icons.EyeStriked)`
3066
- & > path {
3067
- fill: ${({ theme }) => theme.colors.neutral600};
3068
- }
3069
- `;
3070
- function useDebounce(value, delay) {
3071
- const [debouncedValue, setDebouncedValue] = React.useState(value);
3072
- React.useEffect(() => {
3073
- const handler = setTimeout(() => {
3074
- setDebouncedValue(value);
3075
- }, delay);
3076
- return () => {
3077
- clearTimeout(handler);
3078
- };
3079
- }, [value, delay]);
3080
- return debouncedValue;
3081
- }
3082
3283
  const uidApi = index.contentManagerApi.injectEndpoints({
3083
3284
  endpoints: (builder) => ({
3084
3285
  getDefaultUID: builder.query({
@@ -3113,194 +3314,206 @@ const uidApi = index.contentManagerApi.injectEndpoints({
3113
3314
  config: {
3114
3315
  params
3115
3316
  }
3116
- })
3317
+ }),
3318
+ providesTags: (_res, _error, params) => [
3319
+ { type: "UidAvailability", id: params.contentTypeUID }
3320
+ ]
3117
3321
  })
3118
3322
  })
3119
3323
  });
3120
3324
  const { useGenerateUIDMutation, useGetDefaultUIDQuery, useGetAvailabilityQuery } = uidApi;
3121
3325
  const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
3122
- const UIDInput = React__namespace.forwardRef((props, ref) => {
3123
- const { model, id } = index.useDoc();
3124
- const allFormValues = strapiAdmin.useForm("InputUID", (form) => form.values);
3125
- const [availability, setAvailability] = React__namespace.useState();
3126
- const [showRegenerate, setShowRegenerate] = React__namespace.useState(false);
3127
- const field = strapiAdmin.useField(props.name);
3128
- const debouncedValue = useDebounce(field.value, 300);
3129
- const { toggleNotification } = strapiAdmin.useNotification();
3130
- const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
3131
- const { formatMessage } = reactIntl.useIntl();
3132
- const [{ query }] = strapiAdmin.useQueryParams();
3133
- const params = React__namespace.useMemo(() => index.buildValidParams(query), [query]);
3134
- const {
3135
- data: defaultGeneratedUID,
3136
- isLoading: isGeneratingDefaultUID,
3137
- error: apiError
3138
- } = useGetDefaultUIDQuery(
3139
- {
3140
- contentTypeUID: model,
3141
- field: props.name,
3142
- data: {
3143
- id: id ?? "",
3144
- ...allFormValues
3145
- },
3146
- params
3147
- },
3148
- {
3149
- skip: field.value || !props.required
3150
- }
3151
- );
3152
- React__namespace.useEffect(() => {
3153
- if (apiError) {
3154
- toggleNotification({
3155
- type: "warning",
3156
- message: formatAPIError(apiError)
3157
- });
3158
- }
3159
- }, [apiError, formatAPIError, toggleNotification]);
3160
- React__namespace.useEffect(() => {
3161
- if (defaultGeneratedUID && field.value === void 0) {
3162
- field.onChange(props.name, defaultGeneratedUID);
3163
- }
3164
- }, [defaultGeneratedUID, field, props.name]);
3165
- const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
3166
- const handleRegenerateClick = async () => {
3167
- try {
3168
- const res = await generateUID({
3326
+ const UIDInput = React__namespace.forwardRef(
3327
+ ({ hint, label, labelAction, name: name2, required, ...props }, ref) => {
3328
+ const { model, id } = index.useDoc();
3329
+ const allFormValues = strapiAdmin.useForm("InputUID", (form) => form.values);
3330
+ const [availability, setAvailability] = React__namespace.useState();
3331
+ const [showRegenerate, setShowRegenerate] = React__namespace.useState(false);
3332
+ const isCloning = reactRouterDom.useMatch(index.CLONE_PATH) !== null;
3333
+ const field = strapiAdmin.useField(name2);
3334
+ const debouncedValue = usePrev.useDebounce(field.value, 300);
3335
+ const hasChanged = debouncedValue !== field.initialValue;
3336
+ const { toggleNotification } = strapiAdmin.useNotification();
3337
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
3338
+ const { formatMessage } = reactIntl.useIntl();
3339
+ const [{ query }] = strapiAdmin.useQueryParams();
3340
+ const params = React__namespace.useMemo(() => index.buildValidParams(query), [query]);
3341
+ const {
3342
+ data: defaultGeneratedUID,
3343
+ isLoading: isGeneratingDefaultUID,
3344
+ error: apiError
3345
+ } = useGetDefaultUIDQuery(
3346
+ {
3169
3347
  contentTypeUID: model,
3170
- field: props.name,
3171
- data: { id: id ?? "", ...allFormValues },
3348
+ field: name2,
3349
+ data: {
3350
+ id: id ?? "",
3351
+ ...allFormValues
3352
+ },
3172
3353
  params
3173
- });
3174
- if ("data" in res) {
3175
- field.onChange(props.name, res.data);
3176
- } else {
3354
+ },
3355
+ {
3356
+ skip: field.value || !required
3357
+ }
3358
+ );
3359
+ React__namespace.useEffect(() => {
3360
+ if (apiError) {
3177
3361
  toggleNotification({
3178
- type: "danger",
3179
- message: formatAPIError(res.error)
3362
+ type: "warning",
3363
+ message: formatAPIError(apiError)
3180
3364
  });
3181
3365
  }
3182
- } catch (err) {
3183
- toggleNotification({
3184
- type: "danger",
3185
- message: formatMessage({
3186
- id: "notification.error",
3187
- defaultMessage: "An error occurred."
3188
- })
3189
- });
3190
- }
3191
- };
3192
- const {
3193
- data: availabilityData,
3194
- isLoading: isCheckingAvailability,
3195
- error: availabilityError
3196
- } = useGetAvailabilityQuery(
3197
- {
3198
- contentTypeUID: model,
3199
- field: props.name,
3200
- value: debouncedValue ? debouncedValue.trim() : "",
3201
- params
3202
- },
3203
- {
3204
- skip: !Boolean(
3205
- debouncedValue !== field.initialValue && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3206
- )
3207
- }
3208
- );
3209
- React__namespace.useEffect(() => {
3210
- if (availabilityError) {
3211
- toggleNotification({
3212
- type: "warning",
3213
- message: formatAPIError(availabilityError)
3214
- });
3215
- }
3216
- }, [availabilityError, formatAPIError, toggleNotification]);
3217
- React__namespace.useEffect(() => {
3218
- setAvailability(availabilityData);
3219
- let timer;
3220
- if (availabilityData?.isAvailable) {
3221
- timer = window.setTimeout(() => {
3222
- setAvailability(void 0);
3223
- }, 4e3);
3224
- }
3225
- return () => {
3226
- if (timer) {
3227
- clearTimeout(timer);
3366
+ }, [apiError, formatAPIError, toggleNotification]);
3367
+ React__namespace.useEffect(() => {
3368
+ if (defaultGeneratedUID && field.value === void 0) {
3369
+ field.onChange(name2, defaultGeneratedUID);
3370
+ }
3371
+ }, [defaultGeneratedUID, field, name2]);
3372
+ const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
3373
+ const handleRegenerateClick = async () => {
3374
+ try {
3375
+ const res = await generateUID({
3376
+ contentTypeUID: model,
3377
+ field: name2,
3378
+ data: { id: id ?? "", ...allFormValues },
3379
+ params
3380
+ });
3381
+ if ("data" in res) {
3382
+ field.onChange(name2, res.data);
3383
+ } else {
3384
+ toggleNotification({
3385
+ type: "danger",
3386
+ message: formatAPIError(res.error)
3387
+ });
3388
+ }
3389
+ } catch (err) {
3390
+ toggleNotification({
3391
+ type: "danger",
3392
+ message: formatMessage({
3393
+ id: "notification.error",
3394
+ defaultMessage: "An error occurred."
3395
+ })
3396
+ });
3228
3397
  }
3229
3398
  };
3230
- }, [availabilityData]);
3231
- const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
3232
- const fieldRef = strapiAdmin.useFocusInputField(props.name);
3233
- const composedRefs = designSystem.useComposedRefs(ref, fieldRef);
3234
- return (
3235
- // @ts-expect-error – label _could_ be a ReactNode since it's a child, this should be fixed in the DS.
3236
- /* @__PURE__ */ jsxRuntime.jsx(
3237
- designSystem.TextInput,
3399
+ const {
3400
+ data: availabilityData,
3401
+ isLoading: isCheckingAvailability,
3402
+ error: availabilityError
3403
+ } = useGetAvailabilityQuery(
3238
3404
  {
3239
- ref: composedRefs,
3240
- disabled: props.disabled,
3241
- error: field.error,
3242
- endAction: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { position: "relative", gap: 1, children: [
3243
- availability && !showRegenerate && /* @__PURE__ */ jsxRuntime.jsxs(
3244
- TextValidation,
3245
- {
3246
- alignItems: "center",
3247
- gap: 1,
3248
- justifyContent: "flex-end",
3249
- available: !!availability?.isAvailable,
3250
- "data-not-here-outer": true,
3251
- position: "absolute",
3252
- pointerEvents: "none",
3253
- right: 6,
3254
- width: "100px",
3255
- children: [
3256
- availability?.isAvailable ? /* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, {}),
3257
- /* @__PURE__ */ jsxRuntime.jsx(
3258
- designSystem.Typography,
3259
- {
3260
- textColor: availability.isAvailable ? "success600" : "danger600",
3261
- variant: "pi",
3262
- children: formatMessage(
3263
- availability.isAvailable ? {
3264
- id: "content-manager.components.uid.available",
3265
- defaultMessage: "Available"
3266
- } : {
3267
- id: "content-manager.components.uid.unavailable",
3268
- defaultMessage: "Unavailable"
3269
- }
3270
- )
3271
- }
3272
- )
3273
- ]
3274
- }
3275
- ),
3276
- !props.disabled && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3277
- showRegenerate && /* @__PURE__ */ jsxRuntime.jsx(TextValidation, { alignItems: "center", justifyContent: "flex-end", gap: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "primary600", variant: "pi", children: formatMessage({
3278
- id: "content-manager.components.uid.regenerate",
3279
- defaultMessage: "Regenerate"
3280
- }) }) }),
3281
- /* @__PURE__ */ jsxRuntime.jsx(
3282
- FieldActionWrapper,
3405
+ contentTypeUID: model,
3406
+ field: name2,
3407
+ value: debouncedValue ? debouncedValue.trim() : "",
3408
+ params
3409
+ },
3410
+ {
3411
+ // Don't check availability if the value is empty or wasn't changed
3412
+ skip: !Boolean(
3413
+ (hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3414
+ )
3415
+ }
3416
+ );
3417
+ React__namespace.useEffect(() => {
3418
+ if (availabilityError) {
3419
+ toggleNotification({
3420
+ type: "warning",
3421
+ message: formatAPIError(availabilityError)
3422
+ });
3423
+ }
3424
+ }, [availabilityError, formatAPIError, toggleNotification]);
3425
+ React__namespace.useEffect(() => {
3426
+ setAvailability(availabilityData);
3427
+ let timer;
3428
+ if (availabilityData?.isAvailable) {
3429
+ timer = window.setTimeout(() => {
3430
+ setAvailability(void 0);
3431
+ }, 4e3);
3432
+ }
3433
+ return () => {
3434
+ if (timer) {
3435
+ clearTimeout(timer);
3436
+ }
3437
+ };
3438
+ }, [availabilityData]);
3439
+ const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
3440
+ const fieldRef = strapiAdmin.useFocusInputField(name2);
3441
+ const composedRefs = designSystem.useComposedRefs(ref, fieldRef);
3442
+ const shouldShowAvailability = (hasChanged || isCloning) && debouncedValue != null && availability && !showRegenerate;
3443
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { hint, name: name2, error: field.error, required, children: [
3444
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
3445
+ /* @__PURE__ */ jsxRuntime.jsx(
3446
+ designSystem.TextInput,
3447
+ {
3448
+ ref: composedRefs,
3449
+ disabled: props.disabled,
3450
+ endAction: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { position: "relative", gap: 1, children: [
3451
+ shouldShowAvailability && /* @__PURE__ */ jsxRuntime.jsxs(
3452
+ TextValidation,
3283
3453
  {
3284
- onClick: handleRegenerateClick,
3285
- label: formatMessage({
3286
- id: "content-manager.components.uid.regenerate",
3287
- defaultMessage: "Regenerate"
3288
- }),
3289
- onMouseEnter: () => setShowRegenerate(true),
3290
- onMouseLeave: () => setShowRegenerate(false),
3291
- children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingWrapper, { "data-testid": "loading-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Loader, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowClockwise, {})
3454
+ alignItems: "center",
3455
+ gap: 1,
3456
+ justifyContent: "flex-end",
3457
+ $available: !!availability?.isAvailable,
3458
+ "data-not-here-outer": true,
3459
+ position: "absolute",
3460
+ pointerEvents: "none",
3461
+ right: 6,
3462
+ width: "100px",
3463
+ children: [
3464
+ availability?.isAvailable ? /* @__PURE__ */ jsxRuntime.jsx(Icons.CheckCircle, {}) : /* @__PURE__ */ jsxRuntime.jsx(Icons.WarningCircle, {}),
3465
+ /* @__PURE__ */ jsxRuntime.jsx(
3466
+ designSystem.Typography,
3467
+ {
3468
+ textColor: availability.isAvailable ? "success600" : "danger600",
3469
+ variant: "pi",
3470
+ children: formatMessage(
3471
+ availability.isAvailable ? {
3472
+ id: "content-manager.components.uid.available",
3473
+ defaultMessage: "Available"
3474
+ } : {
3475
+ id: "content-manager.components.uid.unavailable",
3476
+ defaultMessage: "Unavailable"
3477
+ }
3478
+ )
3479
+ }
3480
+ )
3481
+ ]
3292
3482
  }
3293
- )
3294
- ] })
3295
- ] }),
3296
- onChange: field.onChange,
3297
- value: field.value ?? "",
3298
- ...props
3299
- }
3300
- )
3301
- );
3302
- });
3303
- const FieldActionWrapper = styled__default.default(designSystem.FieldAction)`
3483
+ ),
3484
+ !props.disabled && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3485
+ showRegenerate && /* @__PURE__ */ jsxRuntime.jsx(TextValidation, { alignItems: "center", justifyContent: "flex-end", gap: 1, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "primary600", variant: "pi", children: formatMessage({
3486
+ id: "content-manager.components.uid.regenerate",
3487
+ defaultMessage: "Regenerate"
3488
+ }) }) }),
3489
+ /* @__PURE__ */ jsxRuntime.jsx(
3490
+ FieldActionWrapper,
3491
+ {
3492
+ onClick: handleRegenerateClick,
3493
+ label: formatMessage({
3494
+ id: "content-manager.components.uid.regenerate",
3495
+ defaultMessage: "Regenerate"
3496
+ }),
3497
+ onMouseEnter: () => setShowRegenerate(true),
3498
+ onMouseLeave: () => setShowRegenerate(false),
3499
+ children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingWrapper, { "data-testid": "loading-wrapper", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Loader, {}) }) : /* @__PURE__ */ jsxRuntime.jsx(Icons.ArrowClockwise, {})
3500
+ }
3501
+ )
3502
+ ] })
3503
+ ] }),
3504
+ onChange: field.onChange,
3505
+ value: field.value ?? "",
3506
+ ...props
3507
+ }
3508
+ ),
3509
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {}),
3510
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {})
3511
+ ] });
3512
+ }
3513
+ );
3514
+ const FieldActionWrapper = styledComponents.styled(designSystem.Field.Action)`
3515
+ width: 1.6rem;
3516
+
3304
3517
  svg {
3305
3518
  height: 1.6rem;
3306
3519
  width: 1.6rem;
@@ -3315,17 +3528,17 @@ const FieldActionWrapper = styled__default.default(designSystem.FieldAction)`
3315
3528
  }
3316
3529
  }
3317
3530
  `;
3318
- const TextValidation = styled__default.default(designSystem.Flex)`
3531
+ const TextValidation = styledComponents.styled(designSystem.Flex)`
3319
3532
  svg {
3320
3533
  height: 1.2rem;
3321
3534
  width: 1.2rem;
3322
3535
 
3323
3536
  path {
3324
- fill: ${({ theme, available }) => available ? theme.colors.success600 : theme.colors.danger600};
3537
+ fill: ${({ theme, $available }) => $available ? theme.colors.success600 : theme.colors.danger600};
3325
3538
  }
3326
3539
  }
3327
3540
  `;
3328
- const rotation = styled.keyframes`
3541
+ const rotation = styledComponents.keyframes`
3329
3542
  from {
3330
3543
  transform: rotate(0deg);
3331
3544
  }
@@ -3333,9 +3546,10 @@ const rotation = styled.keyframes`
3333
3546
  transform: rotate(359deg);
3334
3547
  }
3335
3548
  `;
3336
- const LoadingWrapper = styled__default.default(designSystem.Flex)`
3549
+ const LoadingWrapper = styledComponents.styled(designSystem.Flex)`
3337
3550
  animation: ${rotation} 2s infinite linear;
3338
3551
  `;
3552
+ const MemoizedUIDInput = React__namespace.memo(UIDInput);
3339
3553
  const md = new Markdown__default.default({
3340
3554
  html: true,
3341
3555
  // Enable HTML tags in source
@@ -3378,7 +3592,7 @@ const PreviewWysiwyg = ({ data = "" }) => {
3378
3592
  );
3379
3593
  return /* @__PURE__ */ jsxRuntime.jsx(Wrapper, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { dangerouslySetInnerHTML: { __html: html } }) });
3380
3594
  };
3381
- const Wrapper = styled__default.default.div`
3595
+ const Wrapper = styledComponents.styled.div`
3382
3596
  position: absolute;
3383
3597
  top: 0;
3384
3598
  width: 100%;
@@ -3523,8 +3737,7 @@ const Wrapper = styled__default.default.div`
3523
3737
  `;
3524
3738
  var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/;
3525
3739
  function newlineAndIndentContinueMarkdownList(cm) {
3526
- if (cm.getOption("disableInput"))
3527
- return CodeMirror__default.default.Pass;
3740
+ if (cm.getOption("disableInput")) return CodeMirror__default.default.Pass;
3528
3741
  var ranges = cm.listSelections(), replacements = [];
3529
3742
  for (var i = 0; i < ranges.length; i++) {
3530
3743
  var pos = ranges[i].head;
@@ -3558,8 +3771,7 @@ function newlineAndIndentContinueMarkdownList(cm) {
3558
3771
  var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
3559
3772
  var bullet = numbered ? parseInt(match[3], 10) + 1 + match[4] : match[2].replace("x", " ");
3560
3773
  replacements[i] = "\n" + indent + bullet + after;
3561
- if (numbered)
3562
- incrementRemainingMarkdownListNumbers(cm, pos);
3774
+ if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
3563
3775
  }
3564
3776
  }
3565
3777
  cm.replaceSelections(replacements);
@@ -3577,10 +3789,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3577
3789
  var newNumber = parseInt(startItem[3], 10) + lookAhead - skipCount;
3578
3790
  var nextNumber = parseInt(nextItem[3], 10), itemNumber = nextNumber;
3579
3791
  if (startIndent === nextIndent && !isNaN(nextNumber)) {
3580
- if (newNumber === nextNumber)
3581
- itemNumber = nextNumber + 1;
3582
- if (newNumber > nextNumber)
3583
- itemNumber = newNumber + 1;
3792
+ if (newNumber === nextNumber) itemNumber = nextNumber + 1;
3793
+ if (newNumber > nextNumber) itemNumber = newNumber + 1;
3584
3794
  cm.replaceRange(
3585
3795
  nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
3586
3796
  {
@@ -3593,10 +3803,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3593
3803
  }
3594
3804
  );
3595
3805
  } else {
3596
- if (startIndent.length > nextIndent.length)
3597
- return;
3598
- if (startIndent.length < nextIndent.length && lookAhead === 1)
3599
- return;
3806
+ if (startIndent.length > nextIndent.length) return;
3807
+ if (startIndent.length < nextIndent.length && lookAhead === 1) return;
3600
3808
  skipCount += 1;
3601
3809
  }
3602
3810
  }
@@ -3670,17 +3878,17 @@ const Editor = React__namespace.forwardRef(
3670
3878
  [editorRef]
3671
3879
  );
3672
3880
  return /* @__PURE__ */ jsxRuntime.jsxs(EditorAndPreviewWrapper, { children: [
3673
- /* @__PURE__ */ jsxRuntime.jsx(EditorStylesContainer, { isExpandMode, disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsxRuntime.jsx("textarea", { ref: textareaRef }) }),
3881
+ /* @__PURE__ */ jsxRuntime.jsx(EditorStylesContainer, { $isExpandMode: isExpandMode, $disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsxRuntime.jsx("textarea", { ref: textareaRef }) }),
3674
3882
  isPreviewMode && /* @__PURE__ */ jsxRuntime.jsx(PreviewWysiwyg, { data: value })
3675
3883
  ] });
3676
3884
  }
3677
3885
  );
3678
- const EditorAndPreviewWrapper = styled__default.default.div`
3886
+ const EditorAndPreviewWrapper = styledComponents.styled.div`
3679
3887
  position: relative;
3680
3888
  height: calc(100% - 48px);
3681
3889
  `;
3682
- const EditorStylesContainer = styled__default.default.div`
3683
- cursor: ${({ disabled }) => disabled ? "not-allowed !important" : "auto"};
3890
+ const EditorStylesContainer = styledComponents.styled.div`
3891
+ cursor: ${({ $disabled }) => $disabled ? "not-allowed !important" : "auto"};
3684
3892
  height: 100%;
3685
3893
  /* BASICS */
3686
3894
  .CodeMirror-placeholder {
@@ -3690,7 +3898,7 @@ const EditorStylesContainer = styled__default.default.div`
3690
3898
  .CodeMirror {
3691
3899
  /* Set height, width, borders, and global font properties here */
3692
3900
  font-size: 1.4rem;
3693
- height: ${({ isExpandMode }) => isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
3901
+ height: ${({ $isExpandMode }) => $isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
3694
3902
  color: ${({ theme }) => theme.colors.neutral800};
3695
3903
  direction: ltr;
3696
3904
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
@@ -4068,7 +4276,7 @@ const EditorLayout = ({
4068
4276
  justifyContent: "flex-end",
4069
4277
  shrink: 0,
4070
4278
  width: "100%",
4071
- children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton$1, { onClick: onCollapse, children: [
4279
+ children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton$1, { onClick: onCollapse, variant: "tertiary", size: "M", children: [
4072
4280
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
4073
4281
  id: "components.Wysiwyg.collapse",
4074
4282
  defaultMessage: "Collapse"
@@ -4086,27 +4294,37 @@ const EditorLayout = ({
4086
4294
  ) }) });
4087
4295
  }
4088
4296
  return /* @__PURE__ */ jsxRuntime.jsx(
4089
- designSystem.Box,
4297
+ designSystem.Flex,
4090
4298
  {
4091
4299
  borderColor: error ? "danger600" : "neutral200",
4092
4300
  borderStyle: "solid",
4093
4301
  borderWidth: "1px",
4094
4302
  hasRadius: true,
4303
+ direction: "column",
4304
+ alignItems: "stretch",
4095
4305
  children
4096
4306
  }
4097
4307
  );
4098
4308
  };
4099
- const ExpandWrapper = styled__default.default(designSystem.Flex)`
4309
+ const ExpandWrapper = styledComponents.styled(designSystem.Flex)`
4100
4310
  background: ${({ theme }) => `${theme.colors.neutral800}${Math.floor(0.2 * 255).toString(16).padStart(2, "0")}`};
4101
4311
  `;
4102
- const BoxWithBorder = styled__default.default(designSystem.Box)`
4312
+ const BoxWithBorder = styledComponents.styled(designSystem.Box)`
4103
4313
  border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
4104
4314
  `;
4105
- const ExpandButton$1 = styled__default.default(designSystem.BaseButton)`
4315
+ const ExpandButton$1 = styledComponents.styled(designSystem.Button)`
4106
4316
  background-color: transparent;
4107
4317
  border: none;
4108
4318
  align-items: center;
4109
4319
 
4320
+ & > span {
4321
+ display: flex;
4322
+ justify-content: space-between;
4323
+ align-items: center;
4324
+ width: 100%;
4325
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4326
+ }
4327
+
4110
4328
  svg {
4111
4329
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4112
4330
 
@@ -4373,42 +4591,28 @@ const quoteAndCodeHandler = (editor, markdownType) => {
4373
4591
  insertWithoutTextToEdit(editor, markdownType, line, contentLength);
4374
4592
  }
4375
4593
  };
4376
- const CustomIconButton = styled__default.default(designSystem.IconButton)`
4377
- padding: ${({ theme }) => theme.spaces[2]};
4378
- /* Trick to prevent the outline from overflowing because of the general outline-offset */
4379
- outline-offset: -2px !important;
4380
-
4381
- svg {
4382
- width: 1.8rem;
4383
- height: 1.8rem;
4384
- }
4385
- `;
4386
- const CustomLinkIconButton = styled__default.default(CustomIconButton)`
4387
- svg {
4388
- width: 0.8rem;
4389
- height: 0.8rem;
4390
- }
4391
- `;
4392
- const MainButtons = styled__default.default(designSystem.IconButtonGroup)`
4594
+ const MainButtons = styledComponents.styled(designSystem.IconButtonGroup)`
4393
4595
  margin-left: ${({ theme }) => theme.spaces[4]};
4394
4596
  `;
4395
- const MoreButton = styled__default.default(designSystem.IconButton)`
4597
+ const MoreButton = styledComponents.styled(designSystem.IconButton)`
4396
4598
  margin: ${({ theme }) => `0 ${theme.spaces[2]}`};
4397
- padding: ${({ theme }) => theme.spaces[2]};
4398
-
4399
- svg {
4400
- width: 1.8rem;
4401
- height: 1.8rem;
4402
- }
4403
4599
  `;
4404
- const IconButtonGroupMargin = styled__default.default(designSystem.IconButtonGroup)`
4600
+ const IconButtonGroupMargin = styledComponents.styled(designSystem.IconButtonGroup)`
4405
4601
  margin-right: ${({ theme }) => `${theme.spaces[2]}`};
4406
4602
  `;
4407
- const ExpandButton = styled__default.default(designSystem.BaseButton)`
4603
+ const ExpandButton = styledComponents.styled(designSystem.Button)`
4408
4604
  background-color: transparent;
4409
4605
  border: none;
4410
4606
  align-items: center;
4411
4607
 
4608
+ & > span {
4609
+ display: flex;
4610
+ justify-content: space-between;
4611
+ align-items: center;
4612
+ width: 100%;
4613
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4614
+ }
4615
+
4412
4616
  svg {
4413
4617
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4414
4618
  path {
@@ -4420,8 +4624,8 @@ const ExpandButton = styled__default.default(designSystem.BaseButton)`
4420
4624
  `;
4421
4625
  const WysiwygFooter = ({ onToggleExpand }) => {
4422
4626
  const { formatMessage } = reactIntl.useIntl();
4423
- 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: [
4424
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
4627
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, variant: "tertiary", size: "M", children: [
4628
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "neutral800", children: formatMessage({
4425
4629
  id: "components.WysiwygBottomControls.fullscreen",
4426
4630
  defaultMessage: "Expand"
4427
4631
  }) }),
@@ -4443,7 +4647,7 @@ const WysiwygNav = ({
4443
4647
  id: "components.Wysiwyg.selectOptions.title",
4444
4648
  defaultMessage: "Add a title"
4445
4649
  });
4446
- const buttonMoreRef = React__namespace.useRef(null);
4650
+ React__namespace.useRef(null);
4447
4651
  const handleTogglePopover = () => {
4448
4652
  setVisiblePopover((prev) => !prev);
4449
4653
  };
@@ -4456,21 +4660,30 @@ const WysiwygNav = ({
4456
4660
  justifyContent: "space-between",
4457
4661
  borderRadius: `0.4rem 0.4rem 0 0`,
4458
4662
  children: [
4459
- /* @__PURE__ */ jsxRuntime.jsxs(StyledFlex, { children: [
4460
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.SingleSelect, { disabled: true, placeholder: selectPlaceholder, size: "S", label: selectPlaceholder, children: [
4461
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4462
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
4463
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h3", children: "h3" }),
4464
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h4", children: "h4" }),
4465
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h5", children: "h5" }),
4466
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h6", children: "h6" })
4467
- ] }),
4663
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
4664
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4665
+ designSystem.SingleSelect,
4666
+ {
4667
+ disabled: true,
4668
+ placeholder: selectPlaceholder,
4669
+ "aria-label": selectPlaceholder,
4670
+ size: "S",
4671
+ children: [
4672
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4673
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
4674
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h3", children: "h3" }),
4675
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h4", children: "h4" }),
4676
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h5", children: "h5" }),
4677
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h6", children: "h6" })
4678
+ ]
4679
+ }
4680
+ ) }),
4468
4681
  /* @__PURE__ */ jsxRuntime.jsxs(MainButtons, { children: [
4469
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Bold", name: "Bold", icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4470
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Italic", name: "Italic", icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Italic, {}) }),
4471
- /* @__PURE__ */ jsxRuntime.jsx(CustomIconButton, { disabled: true, label: "Underline", name: "Underline", icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Underline, {}) })
4682
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4683
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Italic, {}) }),
4684
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Underline, {}) })
4472
4685
  ] }),
4473
- /* @__PURE__ */ jsxRuntime.jsx(MoreButton, { disabled: true, label: "More", icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, {}) })
4686
+ /* @__PURE__ */ jsxRuntime.jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, {}) })
4474
4687
  ] }),
4475
4688
  !isExpandMode && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
4476
4689
  id: "components.Wysiwyg.ToggleMode.markdown-mode",
@@ -4488,14 +4701,14 @@ const WysiwygNav = ({
4488
4701
  justifyContent: "space-between",
4489
4702
  borderRadius: `0.4rem 0.4rem 0 0`,
4490
4703
  children: [
4491
- /* @__PURE__ */ jsxRuntime.jsxs(StyledFlex, { children: [
4492
- /* @__PURE__ */ jsxRuntime.jsxs(
4704
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
4705
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(
4493
4706
  designSystem.SingleSelect,
4494
4707
  {
4495
4708
  placeholder: selectPlaceholder,
4496
- label: selectPlaceholder,
4497
- size: "S",
4709
+ "aria-label": selectPlaceholder,
4498
4710
  onChange: (value) => onActionClick(value, editorRef),
4711
+ size: "S",
4499
4712
  children: [
4500
4713
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h1", children: "h1" }),
4501
4714
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h2", children: "h2" }),
@@ -4505,117 +4718,103 @@ const WysiwygNav = ({
4505
4718
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "h6", children: "h6" })
4506
4719
  ]
4507
4720
  }
4508
- ),
4721
+ ) }),
4509
4722
  /* @__PURE__ */ jsxRuntime.jsxs(MainButtons, { children: [
4723
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.IconButton, { onClick: () => onActionClick("Bold", editorRef), label: "Bold", name: "Bold", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {}) }),
4510
4724
  /* @__PURE__ */ jsxRuntime.jsx(
4511
- CustomIconButton,
4512
- {
4513
- onClick: () => onActionClick("Bold", editorRef),
4514
- label: "Bold",
4515
- name: "Bold",
4516
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Bold, {})
4517
- }
4518
- ),
4519
- /* @__PURE__ */ jsxRuntime.jsx(
4520
- CustomIconButton,
4521
- {
4522
- onClick: () => onActionClick("Italic", editorRef),
4523
- label: "Italic",
4524
- name: "Italic",
4525
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Italic, {})
4526
- }
4527
- ),
4528
- /* @__PURE__ */ jsxRuntime.jsx(
4529
- CustomIconButton,
4530
- {
4531
- onClick: () => onActionClick("Underline", editorRef),
4532
- label: "Underline",
4533
- name: "Underline",
4534
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Underline, {})
4535
- }
4536
- )
4537
- ] }),
4538
- /* @__PURE__ */ jsxRuntime.jsx(
4539
- MoreButton,
4540
- {
4541
- ref: buttonMoreRef,
4542
- onClick: handleTogglePopover,
4543
- label: "More",
4544
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, {})
4545
- }
4546
- ),
4547
- visiblePopover && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover, { onDismiss: handleTogglePopover, centered: true, source: buttonMoreRef, spacing: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
4548
- /* @__PURE__ */ jsxRuntime.jsxs(IconButtonGroupMargin, { children: [
4549
- /* @__PURE__ */ jsxRuntime.jsx(
4550
- CustomIconButton,
4551
- {
4552
- onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4553
- label: "Strikethrough",
4554
- name: "Strikethrough",
4555
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.StrikeThrough, {})
4556
- }
4557
- ),
4558
- /* @__PURE__ */ jsxRuntime.jsx(
4559
- CustomIconButton,
4560
- {
4561
- onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4562
- label: "BulletList",
4563
- name: "BulletList",
4564
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.BulletList, {})
4565
- }
4566
- ),
4567
- /* @__PURE__ */ jsxRuntime.jsx(
4568
- CustomIconButton,
4569
- {
4570
- onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4571
- label: "NumberList",
4572
- name: "NumberList",
4573
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.NumberList, {})
4574
- }
4575
- )
4576
- ] }),
4577
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.IconButtonGroup, { children: [
4578
- /* @__PURE__ */ jsxRuntime.jsx(
4579
- CustomIconButton,
4580
- {
4581
- onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4582
- label: "Code",
4583
- name: "Code",
4584
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Code, {})
4585
- }
4586
- ),
4587
- /* @__PURE__ */ jsxRuntime.jsx(
4588
- CustomIconButton,
4589
- {
4590
- onClick: () => {
4591
- handleTogglePopover();
4592
- onToggleMediaLib();
4593
- },
4594
- label: "Image",
4595
- name: "Image",
4596
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Image, {})
4597
- }
4598
- ),
4599
- /* @__PURE__ */ jsxRuntime.jsx(
4600
- CustomLinkIconButton,
4601
- {
4602
- onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4603
- label: "Link",
4604
- name: "Link",
4605
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Link, {})
4606
- }
4607
- ),
4608
- /* @__PURE__ */ jsxRuntime.jsx(
4609
- CustomIconButton,
4610
- {
4611
- onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4612
- label: "Quote",
4613
- name: "Quote",
4614
- icon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Quotes, {})
4615
- }
4616
- )
4617
- ] })
4618
- ] }) })
4725
+ designSystem.IconButton,
4726
+ {
4727
+ onClick: () => onActionClick("Italic", editorRef),
4728
+ label: "Italic",
4729
+ name: "Italic",
4730
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Italic, {})
4731
+ }
4732
+ ),
4733
+ /* @__PURE__ */ jsxRuntime.jsx(
4734
+ designSystem.IconButton,
4735
+ {
4736
+ onClick: () => onActionClick("Underline", editorRef),
4737
+ label: "Underline",
4738
+ name: "Underline",
4739
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Underline, {})
4740
+ }
4741
+ )
4742
+ ] }),
4743
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { children: [
4744
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(MoreButton, { label: "More", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, {}) }) }),
4745
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { padding: 2, children: [
4746
+ /* @__PURE__ */ jsxRuntime.jsxs(IconButtonGroupMargin, { children: [
4747
+ /* @__PURE__ */ jsxRuntime.jsx(
4748
+ designSystem.IconButton,
4749
+ {
4750
+ onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4751
+ label: "Strikethrough",
4752
+ name: "Strikethrough",
4753
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.StrikeThrough, {})
4754
+ }
4755
+ ),
4756
+ /* @__PURE__ */ jsxRuntime.jsx(
4757
+ designSystem.IconButton,
4758
+ {
4759
+ onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4760
+ label: "BulletList",
4761
+ name: "BulletList",
4762
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.BulletList, {})
4763
+ }
4764
+ ),
4765
+ /* @__PURE__ */ jsxRuntime.jsx(
4766
+ designSystem.IconButton,
4767
+ {
4768
+ onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4769
+ label: "NumberList",
4770
+ name: "NumberList",
4771
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.NumberList, {})
4772
+ }
4773
+ )
4774
+ ] }),
4775
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.IconButtonGroup, { children: [
4776
+ /* @__PURE__ */ jsxRuntime.jsx(
4777
+ designSystem.IconButton,
4778
+ {
4779
+ onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4780
+ label: "Code",
4781
+ name: "Code",
4782
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Code, {})
4783
+ }
4784
+ ),
4785
+ /* @__PURE__ */ jsxRuntime.jsx(
4786
+ designSystem.IconButton,
4787
+ {
4788
+ onClick: () => {
4789
+ handleTogglePopover();
4790
+ onToggleMediaLib();
4791
+ },
4792
+ label: "Image",
4793
+ name: "Image",
4794
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Image, {})
4795
+ }
4796
+ ),
4797
+ /* @__PURE__ */ jsxRuntime.jsx(
4798
+ designSystem.IconButton,
4799
+ {
4800
+ onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4801
+ label: "Link",
4802
+ name: "Link",
4803
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Link, {})
4804
+ }
4805
+ ),
4806
+ /* @__PURE__ */ jsxRuntime.jsx(
4807
+ designSystem.IconButton,
4808
+ {
4809
+ onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4810
+ label: "Quote",
4811
+ name: "Quote",
4812
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Quotes, {})
4813
+ }
4814
+ )
4815
+ ] })
4816
+ ] }) })
4817
+ ] })
4619
4818
  ] }),
4620
4819
  onTogglePreviewMode && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
4621
4820
  id: "components.Wysiwyg.ToggleMode.preview-mode",
@@ -4625,19 +4824,6 @@ const WysiwygNav = ({
4625
4824
  }
4626
4825
  );
4627
4826
  };
4628
- const StyledFlex = styled__default.default(designSystem.Flex)`
4629
- /* Hide the label, every input needs a label. */
4630
- label {
4631
- border: 0;
4632
- clip: rect(0 0 0 0);
4633
- height: 1px;
4634
- margin: -1px;
4635
- overflow: hidden;
4636
- padding: 0;
4637
- position: absolute;
4638
- width: 1px;
4639
- }
4640
- `;
4641
4827
  const Wysiwyg = React__namespace.forwardRef(
4642
4828
  ({ hint, disabled, label, name: name2, placeholder, required, labelAction }, forwardedRef) => {
4643
4829
  const field = strapiAdmin.useField(name2);
@@ -4696,15 +4882,15 @@ const Wysiwyg = React__namespace.forwardRef(
4696
4882
  const handleSelectAssets = (files) => {
4697
4883
  const formattedFiles = files.map((f) => ({
4698
4884
  alt: f.alternativeText || f.name,
4699
- url: urls.prefixFileUrlWithBackendUrl(f.url),
4885
+ url: usePrev.prefixFileUrlWithBackendUrl(f.url),
4700
4886
  mime: f.mime
4701
4887
  }));
4702
4888
  insertFile(editorRef, formattedFiles);
4703
4889
  setMediaLibVisible(false);
4704
4890
  };
4705
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field, { name: name2, hint, error: field.error, required, children: [
4891
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { name: name2, hint, error: field.error, required, children: [
4706
4892
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
4707
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldLabel, { action: labelAction, children: label }),
4893
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { action: labelAction, children: label }),
4708
4894
  /* @__PURE__ */ jsxRuntime.jsxs(
4709
4895
  EditorLayout,
4710
4896
  {
@@ -4745,24 +4931,29 @@ const Wysiwyg = React__namespace.forwardRef(
4745
4931
  ]
4746
4932
  }
4747
4933
  ),
4748
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldHint, {}),
4749
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.FieldError, {})
4934
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
4935
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
4750
4936
  ] }),
4751
4937
  mediaLibVisible && // @ts-expect-error – TODO: fix this way of injecting because it's not really typeable without a registry.
4752
4938
  /* @__PURE__ */ jsxRuntime.jsx(MediaLibraryDialog, { onClose: handleToggleMediaLib, onSelectAssets: handleSelectAssets })
4753
4939
  ] });
4754
4940
  }
4755
4941
  );
4942
+ const MemoizedWysiwyg = React__namespace.memo(Wysiwyg);
4756
4943
  const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4757
- const { id } = index.useDoc();
4944
+ const { id, document: document2, collectionType } = index.useDoc();
4758
4945
  const isFormDisabled = strapiAdmin.useForm("InputRenderer", (state) => state.disabled);
4759
4946
  const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
4760
4947
  const canCreateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
4761
4948
  const canReadFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
4762
4949
  const canUpdateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
4763
4950
  const canUserAction = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
4764
- const editableFields = id ? canUpdateFields : canCreateFields;
4765
- const readableFields = id ? canReadFields : canCreateFields;
4951
+ let idToCheck = id;
4952
+ if (collectionType === index.SINGLE_TYPES) {
4953
+ idToCheck = document2?.documentId;
4954
+ }
4955
+ const editableFields = idToCheck ? canUpdateFields : canCreateFields;
4956
+ const readableFields = idToCheck ? canReadFields : canCreateFields;
4766
4957
  const canUserReadField = canUserAction(props.name, readableFields, props.type);
4767
4958
  const canUserEditField = canUserAction(props.name, editableFields, props.type);
4768
4959
  const fields = strapiAdmin.useStrapiApp("InputRenderer", (app) => app.fields);
@@ -4773,6 +4964,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4773
4964
  const {
4774
4965
  edit: { components }
4775
4966
  } = index.useDocLayout();
4967
+ const field = strapiAdmin.useField(props.name);
4776
4968
  if (!visible) {
4777
4969
  return null;
4778
4970
  }
@@ -4783,390 +4975,306 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4783
4975
  if (attributeHasCustomFieldProperty(props.attribute)) {
4784
4976
  const CustomInput = lazyComponentStore[props.attribute.customField];
4785
4977
  if (CustomInput) {
4786
- return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4978
+ return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
4787
4979
  }
4788
4980
  return /* @__PURE__ */ jsxRuntime.jsx(
4789
4981
  strapiAdmin.InputRenderer,
4790
4982
  {
4791
4983
  ...props,
4792
4984
  hint,
4793
- type: props.attribute.customField,
4794
- disabled: fieldIsDisabled
4795
- }
4796
- );
4797
- }
4798
- const addedInputTypes = Object.keys(fields);
4799
- if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4800
- const CustomInput = fields[props.type];
4801
- return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4802
- }
4803
- switch (props.type) {
4804
- case "blocks":
4805
- return /* @__PURE__ */ jsxRuntime.jsx(BlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4806
- case "component":
4807
- return /* @__PURE__ */ jsxRuntime.jsx(
4808
- ComponentInput,
4809
- {
4810
- ...props,
4811
- hint,
4812
- layout: components[props.attribute.component].layout,
4813
- disabled: fieldIsDisabled,
4814
- children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
4815
- }
4816
- );
4817
- case "dynamiczone":
4818
- return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
4819
- case "relation":
4820
- return /* @__PURE__ */ jsxRuntime.jsx(Relations.RelationsField, { ...props, hint, disabled: fieldIsDisabled });
4821
- case "richtext":
4822
- return /* @__PURE__ */ jsxRuntime.jsx(Wysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4823
- case "uid":
4824
- return /* @__PURE__ */ jsxRuntime.jsx(UIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4825
- case "enumeration":
4826
- return /* @__PURE__ */ jsxRuntime.jsx(
4827
- strapiAdmin.InputRenderer,
4828
- {
4829
- ...props,
4830
- hint,
4831
- options: props.attribute.enum.map((value) => ({ value })),
4832
- type: props.customField ? "custom-field" : props.type,
4833
- disabled: fieldIsDisabled
4834
- }
4835
- );
4836
- default:
4837
- const { unique: _unique, mainField: _mainField, ...restProps } = props;
4838
- return /* @__PURE__ */ jsxRuntime.jsx(
4839
- strapiAdmin.InputRenderer,
4840
- {
4841
- ...restProps,
4842
- hint,
4843
- type: props.customField ? "custom-field" : props.type,
4844
- disabled: fieldIsDisabled
4845
- }
4846
- );
4847
- }
4848
- };
4849
- const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
4850
- const useFieldHint = (hint = void 0, attribute) => {
4851
- const { formatMessage } = reactIntl.useIntl();
4852
- const { maximum, minimum } = getMinMax(attribute);
4853
- if (!maximum && !minimum) {
4854
- return hint;
4855
- }
4856
- const units = !["biginteger", "integer", "number"].includes(attribute.type) ? formatMessage(
4857
- {
4858
- id: "content-manager.form.Input.hint.character.unit",
4859
- defaultMessage: "{maxValue, plural, one { character} other { characters}}"
4860
- },
4861
- {
4862
- maxValue: Math.max(minimum || 0, maximum || 0)
4863
- }
4864
- ) : null;
4865
- const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
4866
- return formatMessage(
4867
- {
4868
- id: "content-manager.form.Input.hint.text",
4869
- defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
4870
- },
4871
- {
4872
- min: minimum,
4873
- max: maximum,
4874
- description: hint,
4875
- unit: units,
4876
- divider: hasMinAndMax ? formatMessage({
4877
- id: "content-manager.form.Input.hint.minMaxDivider",
4878
- defaultMessage: " / "
4879
- }) : null,
4880
- br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
4881
- }
4882
- );
4883
- };
4884
- const getMinMax = (attribute) => {
4885
- if ("min" in attribute || "max" in attribute) {
4886
- return {
4887
- maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
4888
- minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
4889
- };
4890
- } else if ("maxLength" in attribute || "minLength" in attribute) {
4891
- return { maximum: attribute.maxLength, minimum: attribute.minLength };
4892
- } else {
4893
- return { maximum: void 0, minimum: void 0 };
4894
- }
4895
- };
4896
- const DynamicComponent = ({
4897
- componentUid,
4898
- disabled,
4899
- index: index$1,
4900
- name: name2,
4901
- onRemoveComponentClick,
4902
- onMoveComponent,
4903
- onGrabItem,
4904
- onDropItem,
4905
- onCancel,
4906
- dynamicComponentsByCategory = {},
4907
- onAddComponent
4908
- }) => {
4909
- const [isOpen, setIsOpen] = React__namespace.useState(true);
4910
- const { formatMessage } = reactIntl.useIntl();
4911
- const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
4912
- const {
4913
- edit: { components }
4914
- } = index.useDocLayout();
4915
- const title = React__namespace.useMemo(() => {
4916
- const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
4917
- const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
4918
- const displayedValue = mainField === "id" ? "" : String(mainFieldValue).trim();
4919
- const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
4920
- return mainValue;
4921
- }, [componentUid, components, formValues, name2, index$1]);
4922
- const { icon, displayName } = React__namespace.useMemo(() => {
4923
- const [category] = componentUid.split(".");
4924
- const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
4925
- (component) => component.uid === componentUid
4926
- ) ?? { icon: null, displayName: null };
4927
- return { icon: icon2, displayName: displayName2 };
4928
- }, [componentUid, dynamicComponentsByCategory]);
4929
- const handleToggle = () => {
4930
- setIsOpen((s) => !s);
4931
- };
4932
- const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
4933
- type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
4934
- index: index$1,
4935
- item: {
4936
- index: index$1,
4937
- displayedValue: `${displayName} ${title}`,
4938
- icon
4939
- },
4940
- onMoveItem: onMoveComponent,
4941
- onDropItem,
4942
- onGrabItem,
4943
- onCancel
4944
- });
4945
- React__namespace.useEffect(() => {
4946
- dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
4947
- }, [dragPreviewRef, index$1]);
4948
- const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
4949
- const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(ActionsFlex, { gap: 0, children: [
4950
- /* @__PURE__ */ jsxRuntime.jsx(
4951
- IconButtonCustom,
4952
- {
4953
- borderWidth: 0,
4954
- label: formatMessage(
4955
- {
4956
- id: index.getTranslation("components.DynamicZone.delete-label"),
4957
- defaultMessage: "Delete {name}"
4958
- },
4959
- { name: title }
4960
- ),
4961
- onClick: onRemoveComponentClick,
4962
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
4963
- }
4964
- ),
4965
- /* @__PURE__ */ jsxRuntime.jsx(
4966
- designSystem.IconButton,
4967
- {
4968
- forwardedAs: "div",
4969
- role: "button",
4970
- borderWidth: 0,
4971
- tabIndex: 0,
4972
- onClick: (e) => e.stopPropagation(),
4973
- "data-handler-id": handlerId,
4974
- ref: dragRef,
4975
- label: formatMessage({
4976
- id: index.getTranslation("components.DragHandle-label"),
4977
- defaultMessage: "Drag"
4978
- }),
4979
- onKeyDown: handleKeyDown,
4980
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
4981
- }
4982
- ),
4983
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
4984
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
4985
- /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
4986
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { as: "span", children: formatMessage({
4987
- id: index.getTranslation("components.DynamicZone.more-actions"),
4988
- defaultMessage: "More actions"
4989
- }) })
4990
- ] }),
4991
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
4992
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
4993
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
4994
- id: index.getTranslation("components.DynamicZone.add-item-above"),
4995
- defaultMessage: "Add component above"
4996
- }) }),
4997
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
4998
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
4999
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
5000
- ] }, category)) })
5001
- ] }),
5002
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
5003
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
5004
- id: index.getTranslation("components.DynamicZone.add-item-below"),
5005
- defaultMessage: "Add component below"
5006
- }) }),
5007
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
5008
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
5009
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
5010
- ] }, category)) })
5011
- ] })
5012
- ] })
5013
- ] })
5014
- ] });
5015
- return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { as: "li", width: "100%", children: [
5016
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
5017
- /* @__PURE__ */ jsxRuntime.jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion, { expanded: isOpen, onToggle: handleToggle, size: "S", children: [
5018
- /* @__PURE__ */ jsxRuntime.jsx(
5019
- designSystem.AccordionToggle,
4985
+ type: props.attribute.customField,
4986
+ disabled: fieldIsDisabled
4987
+ }
4988
+ );
4989
+ }
4990
+ const addedInputTypes = Object.keys(fields);
4991
+ if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4992
+ const CustomInput = fields[props.type];
4993
+ return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4994
+ }
4995
+ switch (props.type) {
4996
+ case "blocks":
4997
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4998
+ case "component":
4999
+ return /* @__PURE__ */ jsxRuntime.jsx(
5000
+ MemoizedComponentInput,
5020
5001
  {
5021
- startIcon: /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { icon, showBackground: false, size: "S" }),
5022
- action: accordionActions,
5023
- title: `${displayName} ${title}`,
5024
- togglePosition: "left"
5002
+ ...props,
5003
+ hint,
5004
+ layout: components[props.attribute.component].layout,
5005
+ disabled: fieldIsDisabled,
5006
+ children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
5025
5007
  }
5026
- ),
5027
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.AccordionContent, { 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 }) => {
5028
- const fieldName = `${name2}.${index$1}.${field.name}`;
5029
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.GridItem, { col: size, s: 12, xs: 12, children: /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...field, name: fieldName }) }, fieldName);
5030
- }) }, rowInd)) }) }) })
5031
- ] }) })
5032
- ] });
5008
+ );
5009
+ case "dynamiczone":
5010
+ return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
5011
+ case "relation":
5012
+ return /* @__PURE__ */ jsxRuntime.jsx(Relations.MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
5013
+ case "richtext":
5014
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5015
+ case "uid":
5016
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5017
+ case "enumeration":
5018
+ return /* @__PURE__ */ jsxRuntime.jsx(
5019
+ strapiAdmin.InputRenderer,
5020
+ {
5021
+ ...props,
5022
+ hint,
5023
+ options: props.attribute.enum.map((value) => ({ value })),
5024
+ type: props.customField ? "custom-field" : props.type,
5025
+ disabled: fieldIsDisabled
5026
+ }
5027
+ );
5028
+ default:
5029
+ const { unique: _unique, mainField: _mainField, ...restProps } = props;
5030
+ return /* @__PURE__ */ jsxRuntime.jsx(
5031
+ strapiAdmin.InputRenderer,
5032
+ {
5033
+ ...restProps,
5034
+ hint,
5035
+ type: props.customField ? "custom-field" : props.type,
5036
+ disabled: fieldIsDisabled
5037
+ }
5038
+ );
5039
+ }
5033
5040
  };
5034
- const ActionsFlex = styled__default.default(designSystem.Flex)`
5035
- /*
5036
- we need to remove the background from the button but we can't
5037
- wrap the element in styled because it breaks the forwardedAs which
5038
- we need for drag handler to work on firefox
5039
- */
5040
- div[role='button'] {
5041
- background: transparent;
5041
+ const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
5042
+ const useFieldHint = (hint = void 0, attribute) => {
5043
+ const { formatMessage } = reactIntl.useIntl();
5044
+ const { maximum, minimum } = getMinMax(attribute);
5045
+ if (!maximum && !minimum) {
5046
+ return hint;
5042
5047
  }
5043
- `;
5044
- const IconButtonCustom = styled__default.default(designSystem.IconButton)`
5045
- background-color: transparent;
5046
-
5047
- svg path {
5048
- fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
5048
+ const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
5049
+ attribute.type
5050
+ ) ? formatMessage(
5051
+ {
5052
+ id: "content-manager.form.Input.hint.character.unit",
5053
+ defaultMessage: "{maxValue, plural, one { character} other { characters}}"
5054
+ },
5055
+ {
5056
+ maxValue: Math.max(minimum || 0, maximum || 0)
5057
+ }
5058
+ ) : null;
5059
+ const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
5060
+ return formatMessage(
5061
+ {
5062
+ id: "content-manager.form.Input.hint.text",
5063
+ defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
5064
+ },
5065
+ {
5066
+ min: minimum,
5067
+ max: maximum,
5068
+ description: hint,
5069
+ unit: units,
5070
+ divider: hasMinAndMax ? formatMessage({
5071
+ id: "content-manager.form.Input.hint.minMaxDivider",
5072
+ defaultMessage: " / "
5073
+ }) : null,
5074
+ br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
5075
+ }
5076
+ );
5077
+ };
5078
+ const getMinMax = (attribute) => {
5079
+ if ("min" in attribute || "max" in attribute) {
5080
+ return {
5081
+ maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
5082
+ minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
5083
+ };
5084
+ } else if ("maxLength" in attribute || "minLength" in attribute) {
5085
+ return { maximum: attribute.maxLength, minimum: attribute.minLength };
5086
+ } else {
5087
+ return { maximum: void 0, minimum: void 0 };
5049
5088
  }
5089
+ };
5090
+ const MemoizedInputRenderer = React.memo(InputRenderer);
5091
+ const RESPONSIVE_CONTAINER_BREAKPOINTS = {
5092
+ sm: "27.5rem"
5093
+ // 440px
5094
+ };
5095
+ const ResponsiveGridRoot = styledComponents.styled(designSystem.Grid.Root)`
5096
+ container-type: inline-size;
5050
5097
  `;
5051
- const StyledBox = styled__default.default(designSystem.Box)`
5052
- > div:first-child {
5053
- box-shadow: ${({ theme }) => theme.shadows.tableShadow};
5098
+ const ResponsiveGridItem = styledComponents.styled(designSystem.Grid.Item)`
5099
+ grid-column: span 12;
5100
+
5101
+ @container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
5102
+ ${({ col }) => col && `grid-column: span ${col};`}
5054
5103
  }
5055
5104
  `;
5056
- const AccordionContentRadius = styled__default.default(designSystem.Box)`
5057
- border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
5058
- `;
5059
- const Rectangle = styled__default.default(designSystem.Box)`
5060
- width: ${({ theme }) => theme.spaces[2]};
5061
- height: ${({ theme }) => theme.spaces[4]};
5062
- `;
5063
- const Preview = styled__default.default.span`
5064
- display: block;
5065
- background-color: ${({ theme }) => theme.colors.primary100};
5066
- outline: 1px dashed ${({ theme }) => theme.colors.primary500};
5067
- outline-offset: -1px;
5068
- padding: ${({ theme }) => theme.spaces[6]};
5069
- `;
5070
- const ComponentContainer = styled__default.default(designSystem.Box)`
5071
- list-style: none;
5072
- padding: 0;
5073
- margin: 0;
5074
- `;
5075
- const DynamicZoneLabel = ({
5076
- hint,
5077
- label,
5078
- labelAction,
5105
+ const FormLayout = ({ layout }) => {
5106
+ const { formatMessage } = reactIntl.useIntl();
5107
+ const { model } = index.useDoc();
5108
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index2) => {
5109
+ if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
5110
+ const [row] = panel;
5111
+ const [field] = row;
5112
+ const fieldWithTranslatedLabel = {
5113
+ ...field,
5114
+ label: formatMessage({
5115
+ id: `content-manager.content-types.${model}.${field.name}`,
5116
+ defaultMessage: field.label
5117
+ })
5118
+ };
5119
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, s: 12, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel }) }) }, field.name);
5120
+ }
5121
+ return /* @__PURE__ */ jsxRuntime.jsx(
5122
+ designSystem.Box,
5123
+ {
5124
+ hasRadius: true,
5125
+ background: "neutral0",
5126
+ shadow: "tableShadow",
5127
+ paddingLeft: 6,
5128
+ paddingRight: 6,
5129
+ paddingTop: 6,
5130
+ paddingBottom: 6,
5131
+ borderColor: "neutral150",
5132
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: panel.map((row, gridRowIndex) => /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5133
+ const fieldWithTranslatedLabel = {
5134
+ ...field,
5135
+ label: formatMessage({
5136
+ id: `content-manager.content-types.${model}.${field.name}`,
5137
+ defaultMessage: field.label
5138
+ })
5139
+ };
5140
+ return /* @__PURE__ */ jsxRuntime.jsx(
5141
+ ResponsiveGridItem,
5142
+ {
5143
+ col: size,
5144
+ s: 12,
5145
+ xs: 12,
5146
+ direction: "column",
5147
+ alignItems: "stretch",
5148
+ children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
5149
+ },
5150
+ field.name
5151
+ );
5152
+ }) }, gridRowIndex)) })
5153
+ },
5154
+ index2
5155
+ );
5156
+ }) });
5157
+ };
5158
+ const NonRepeatableComponent = ({
5159
+ attribute,
5079
5160
  name: name2,
5080
- numberOfComponents = 0,
5081
- required
5161
+ children,
5162
+ layout
5082
5163
  }) => {
5083
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
5164
+ const { formatMessage } = reactIntl.useIntl();
5165
+ const { value } = strapiAdmin.useField(name2);
5166
+ const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
5167
+ const isNested = level > 0;
5168
+ return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
5084
5169
  designSystem.Box,
5085
5170
  {
5086
- paddingTop: 3,
5087
- paddingBottom: 3,
5088
- paddingRight: 4,
5089
- paddingLeft: 4,
5090
- borderRadius: "26px",
5091
- background: "neutral0",
5092
- shadow: "filterShadow",
5093
- color: "neutral500",
5094
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
5095
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
5096
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
5097
- label || name2,
5098
- " "
5099
- ] }),
5100
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
5101
- "(",
5102
- numberOfComponents,
5103
- ")"
5104
- ] }),
5105
- required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
5106
- labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
5107
- ] }),
5108
- 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 }) })
5109
- ] })
5171
+ background: "neutral100",
5172
+ paddingLeft: 6,
5173
+ paddingRight: 6,
5174
+ paddingTop: 6,
5175
+ paddingBottom: 6,
5176
+ hasRadius: isNested,
5177
+ borderColor: isNested ? "neutral200" : void 0,
5178
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
5179
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5180
+ const completeFieldName = `${name2}.${field.name}`;
5181
+ const translatedLabel = formatMessage({
5182
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5183
+ defaultMessage: field.label
5184
+ });
5185
+ return /* @__PURE__ */ jsxRuntime.jsx(
5186
+ ResponsiveGridItem,
5187
+ {
5188
+ col: size,
5189
+ s: 12,
5190
+ xs: 12,
5191
+ direction: "column",
5192
+ alignItems: "stretch",
5193
+ children: children({ ...field, label: translatedLabel, name: completeFieldName })
5194
+ },
5195
+ completeFieldName
5196
+ );
5197
+ }) }, index2);
5198
+ }) })
5110
5199
  }
5111
5200
  ) });
5112
5201
  };
5113
- const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
5114
- "DynamicZone",
5115
- {
5116
- isInDynamicZone: false
5117
- }
5118
- );
5119
- const DynamicZone = ({
5202
+ const RepeatableComponent = ({
5120
5203
  attribute,
5121
5204
  disabled,
5122
- hint,
5123
- label,
5124
- labelAction,
5125
5205
  name: name2,
5126
- required = false
5206
+ mainField,
5207
+ children,
5208
+ layout
5127
5209
  }) => {
5128
- const { max = Infinity, min = -Infinity } = attribute ?? {};
5129
- const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
5130
- const [liveText, setLiveText] = React__namespace.useState("");
5210
+ const { toggleNotification } = strapiAdmin.useNotification();
5211
+ const { formatMessage } = reactIntl.useIntl();
5212
+ const { search: searchString } = reactRouterDom.useLocation();
5213
+ const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
5131
5214
  const { components } = index.useDoc();
5132
- const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
5133
- "DynamicZone",
5134
- ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
5135
- addFieldRow: addFieldRow2,
5136
- removeFieldRow: removeFieldRow2,
5137
- moveFieldRow: moveFieldRow2
5138
- })
5139
- );
5140
- const { value = [], error } = strapiAdmin.useField(name2);
5141
- const dynamicComponentsByCategory = React__namespace.useMemo(() => {
5142
- return attribute.components.reduce((acc, componentUid) => {
5143
- const { category, info } = components[componentUid] ?? { info: {} };
5144
- const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
5145
- if (!acc[category]) {
5146
- acc[category] = [];
5215
+ const {
5216
+ value = [],
5217
+ error,
5218
+ rawError
5219
+ } = strapiAdmin.useField(name2);
5220
+ const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
5221
+ const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
5222
+ const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
5223
+ const { max = Infinity } = attribute;
5224
+ const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
5225
+ const [liveText, setLiveText] = React__namespace.useState("");
5226
+ React__namespace.useEffect(() => {
5227
+ const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
5228
+ const hasNestedValue = value && Array.isArray(value) && value.length > 0;
5229
+ if (hasNestedErrors && hasNestedValue) {
5230
+ const errorOpenItems = rawError.map((_, idx) => {
5231
+ return value[idx] ? value[idx].__temp_key__ : null;
5232
+ }).filter((value2) => !!value2);
5233
+ if (errorOpenItems && errorOpenItems.length > 0) {
5234
+ setCollapseToOpen((collapseToOpen2) => {
5235
+ if (!errorOpenItems.includes(collapseToOpen2)) {
5236
+ return errorOpenItems[0];
5237
+ }
5238
+ return collapseToOpen2;
5239
+ });
5147
5240
  }
5148
- acc[category] = [...acc[category], component];
5149
- return acc;
5150
- }, {});
5151
- }, [attribute.components, components]);
5152
- const { formatMessage } = reactIntl.useIntl();
5153
- const { toggleNotification } = strapiAdmin.useNotification();
5154
- const dynamicDisplayedComponentsLength = value.length;
5155
- const handleAddComponent = (uid, position) => {
5156
- setAddComponentIsOpen(false);
5157
- const schema = components[uid];
5158
- const form = createDefaultForm(schema, components);
5159
- const transformations = pipe__default.default(transformDocument(schema, components), (data2) => ({
5160
- ...data2,
5161
- __component: uid
5162
- }));
5163
- const data = transformations(form);
5164
- addFieldRow(name2, data, position);
5241
+ }
5242
+ }, [rawError, value]);
5243
+ const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
5244
+ if (search.has("field")) {
5245
+ const fieldParam = search.get("field");
5246
+ if (!fieldParam) {
5247
+ return void 0;
5248
+ }
5249
+ const [, path] = fieldParam.split(`${name2}.`);
5250
+ if (objects.getIn(value, path, void 0) !== void 0) {
5251
+ const [subpath] = path.split(".");
5252
+ return objects.getIn(value, subpath, void 0)?.__temp_key__;
5253
+ }
5254
+ }
5255
+ return void 0;
5256
+ }, [search, name2, value]);
5257
+ const prevValue = usePrev.usePrev(value);
5258
+ React__namespace.useEffect(() => {
5259
+ if (prevValue && prevValue.length < value.length) {
5260
+ setCollapseToOpen(value[value.length - 1].__temp_key__);
5261
+ }
5262
+ }, [value, prevValue]);
5263
+ React__namespace.useEffect(() => {
5264
+ if (typeof componentTmpKeyWithFocussedField === "string") {
5265
+ setCollapseToOpen(componentTmpKeyWithFocussedField);
5266
+ }
5267
+ }, [componentTmpKeyWithFocussedField]);
5268
+ const toggleCollapses = () => {
5269
+ setCollapseToOpen("");
5165
5270
  };
5166
- const handleClickOpenPicker = () => {
5167
- if (dynamicDisplayedComponentsLength < max) {
5168
- setAddComponentIsOpen((prev) => !prev);
5169
- } else {
5271
+ const handleClick = () => {
5272
+ if (value.length < max) {
5273
+ const schema = components[attribute.component];
5274
+ const form = index.createDefaultForm(schema, components);
5275
+ const data = index.transformDocument(schema, components)(form);
5276
+ addFieldRow(name2, data);
5277
+ } else if (value.length >= max) {
5170
5278
  toggleNotification({
5171
5279
  type: "info",
5172
5280
  message: formatMessage({
@@ -5175,7 +5283,7 @@ const DynamicZone = ({
5175
5283
  });
5176
5284
  }
5177
5285
  };
5178
- const handleMoveComponent = (newIndex, currentIndex) => {
5286
+ const handleMoveComponentField = (newIndex, currentIndex) => {
5179
5287
  setLiveText(
5180
5288
  formatMessage(
5181
5289
  {
@@ -5190,6 +5298,9 @@ const DynamicZone = ({
5190
5298
  );
5191
5299
  moveFieldRow(name2, currentIndex, newIndex);
5192
5300
  };
5301
+ const handleValueChange = (key) => {
5302
+ setCollapseToOpen(key);
5303
+ };
5193
5304
  const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
5194
5305
  const handleCancel = (index$1) => {
5195
5306
  setLiveText(
@@ -5232,121 +5343,275 @@ const DynamicZone = ({
5232
5343
  )
5233
5344
  );
5234
5345
  };
5235
- const handleRemoveComponent = (name22, currentIndex) => () => {
5236
- removeFieldRow(name22, currentIndex);
5237
- };
5238
- const hasError = error !== void 0 || dynamicDisplayedComponentsLength < min || dynamicDisplayedComponentsLength > max;
5239
- const renderButtonLabel = () => {
5240
- if (addComponentIsOpen) {
5241
- return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
5242
- }
5243
- if (hasError && dynamicDisplayedComponentsLength > max) {
5244
- return formatMessage(
5245
- {
5246
- id: index.getTranslation(`components.DynamicZone.extra-components`),
5247
- defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
5248
- },
5249
- {
5250
- number: dynamicDisplayedComponentsLength - max
5251
- }
5252
- );
5253
- }
5254
- if (hasError && dynamicDisplayedComponentsLength < min) {
5255
- return formatMessage(
5256
- {
5257
- id: index.getTranslation(`components.DynamicZone.missing-components`),
5258
- defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
5259
- },
5260
- { number: min - dynamicDisplayedComponentsLength }
5261
- );
5262
- }
5263
- return formatMessage(
5264
- {
5265
- id: index.getTranslation("components.DynamicZone.add-component"),
5266
- defaultMessage: "Add a component to {componentName}"
5267
- },
5268
- { componentName: label || name2 }
5269
- );
5270
- };
5271
- const level = Relations.useComponent("DynamicZone", (state) => state.level);
5272
5346
  const ariaDescriptionId = React__namespace.useId();
5273
- return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
5274
- dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
5275
- /* @__PURE__ */ jsxRuntime.jsx(
5276
- DynamicZoneLabel,
5277
- {
5278
- hint,
5279
- label,
5280
- labelAction,
5281
- name: name2,
5282
- numberOfComponents: dynamicDisplayedComponentsLength,
5283
- required
5284
- }
5285
- ),
5286
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5287
- id: index.getTranslation("dnd.instructions"),
5288
- defaultMessage: `Press spacebar to grab and re-order`
5289
- }) }),
5290
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5291
- /* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
5292
- Relations.ComponentProvider,
5293
- {
5294
- level: level + 1,
5295
- uid: field.__component,
5296
- id: field.id,
5297
- type: "dynamiczone",
5298
- children: /* @__PURE__ */ jsxRuntime.jsx(
5299
- DynamicComponent,
5300
- {
5301
- disabled,
5302
- name: name2,
5303
- index: index2,
5304
- componentUid: field.__component,
5305
- onMoveComponent: handleMoveComponent,
5306
- onRemoveComponentClick: handleRemoveComponent(name2, index2),
5307
- onCancel: handleCancel,
5308
- onDropItem: handleDropItem,
5309
- onGrabItem: handleGrabItem,
5310
- onAddComponent: handleAddComponent,
5311
- dynamicComponentsByCategory
5312
- }
5313
- )
5314
- },
5315
- field.__temp_key__
5316
- )) })
5317
- ] }),
5318
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
5319
- AddComponentButton,
5347
+ const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
5348
+ if (value.length === 0) {
5349
+ return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
5350
+ }
5351
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
5352
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5353
+ id: index.getTranslation("dnd.instructions"),
5354
+ defaultMessage: `Press spacebar to grab and re-order`
5355
+ }) }),
5356
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5357
+ /* @__PURE__ */ jsxRuntime.jsxs(
5358
+ AccordionRoot,
5320
5359
  {
5321
- hasError,
5322
- isDisabled: disabled,
5323
- isOpen: addComponentIsOpen,
5324
- onClick: handleClickOpenPicker,
5325
- children: renderButtonLabel()
5360
+ $error: error,
5361
+ value: collapseToOpen,
5362
+ onValueChange: handleValueChange,
5363
+ "aria-describedby": ariaDescriptionId,
5364
+ children: [
5365
+ value.map(({ __temp_key__: key, id }, index2) => {
5366
+ const nameWithIndex = `${name2}.${index2}`;
5367
+ return /* @__PURE__ */ jsxRuntime.jsx(
5368
+ Relations.ComponentProvider,
5369
+ {
5370
+ id,
5371
+ uid: attribute.component,
5372
+ level: level + 1,
5373
+ type: "repeatable",
5374
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5375
+ Component,
5376
+ {
5377
+ disabled,
5378
+ name: nameWithIndex,
5379
+ attribute,
5380
+ index: index2,
5381
+ mainField,
5382
+ onMoveItem: handleMoveComponentField,
5383
+ onDeleteComponent: () => {
5384
+ removeFieldRow(name2, index2);
5385
+ toggleCollapses();
5386
+ },
5387
+ toggleCollapses,
5388
+ onCancel: handleCancel,
5389
+ onDropItem: handleDropItem,
5390
+ onGrabItem: handleGrabItem,
5391
+ __temp_key__: key,
5392
+ children: layout.map((row, index22) => {
5393
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5394
+ const completeFieldName = `${nameWithIndex}.${field.name}`;
5395
+ const translatedLabel = formatMessage({
5396
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5397
+ defaultMessage: field.label
5398
+ });
5399
+ return /* @__PURE__ */ jsxRuntime.jsx(
5400
+ ResponsiveGridItem,
5401
+ {
5402
+ col: size,
5403
+ s: 12,
5404
+ xs: 12,
5405
+ direction: "column",
5406
+ alignItems: "stretch",
5407
+ children: children({
5408
+ ...field,
5409
+ label: translatedLabel,
5410
+ name: completeFieldName
5411
+ })
5412
+ },
5413
+ completeFieldName
5414
+ );
5415
+ }) }, index22);
5416
+ })
5417
+ }
5418
+ )
5419
+ },
5420
+ key
5421
+ );
5422
+ }),
5423
+ /* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
5424
+ id: index.getTranslation("containers.EditView.add.new-entry"),
5425
+ defaultMessage: "Add an entry"
5426
+ }) })
5427
+ ]
5326
5428
  }
5327
- ) }),
5328
- /* @__PURE__ */ jsxRuntime.jsx(
5329
- ComponentPicker,
5429
+ )
5430
+ ] });
5431
+ };
5432
+ const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
5433
+ border: 1px solid
5434
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
5435
+ `;
5436
+ const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
5437
+ width: 100%;
5438
+ display: flex;
5439
+ justify-content: center;
5440
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
5441
+ padding-inline: ${(props) => props.theme.spaces[6]};
5442
+ padding-block: ${(props) => props.theme.spaces[3]};
5443
+
5444
+ &:not([disabled]) {
5445
+ cursor: pointer;
5446
+
5447
+ &:hover {
5448
+ background-color: ${(props) => props.theme.colors.primary100};
5449
+ }
5450
+ }
5451
+
5452
+ span {
5453
+ font-weight: 600;
5454
+ font-size: 1.4rem;
5455
+ line-height: 2.4rem;
5456
+ }
5457
+
5458
+ @media (prefers-reduced-motion: no-preference) {
5459
+ transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
5460
+ }
5461
+ `;
5462
+ const Component = ({
5463
+ disabled,
5464
+ index: index$1,
5465
+ name: name2,
5466
+ mainField = {
5467
+ name: "id",
5468
+ type: "integer"
5469
+ },
5470
+ children,
5471
+ onDeleteComponent,
5472
+ toggleCollapses,
5473
+ __temp_key__,
5474
+ ...dragProps
5475
+ }) => {
5476
+ const { formatMessage } = reactIntl.useIntl();
5477
+ const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
5478
+ return objects.getIn(state.values, [...name2.split("."), mainField.name]);
5479
+ });
5480
+ const accordionRef = React__namespace.useRef(null);
5481
+ const componentKey = name2.split(".").slice(0, -1).join(".");
5482
+ const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
5483
+ type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
5484
+ index: index$1,
5485
+ item: {
5486
+ index: index$1,
5487
+ displayedValue: displayValue
5488
+ },
5489
+ onStart() {
5490
+ toggleCollapses();
5491
+ },
5492
+ ...dragProps
5493
+ });
5494
+ React__namespace.useEffect(() => {
5495
+ dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
5496
+ }, [dragPreviewRef, index$1]);
5497
+ const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
5498
+ const composedBoxRefs = designSystem.useComposedRefs(
5499
+ boxRef,
5500
+ dropRef
5501
+ );
5502
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
5503
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
5504
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: displayValue }),
5505
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Actions, { children: [
5506
+ /* @__PURE__ */ jsxRuntime.jsx(
5507
+ designSystem.IconButton,
5508
+ {
5509
+ variant: "ghost",
5510
+ onClick: onDeleteComponent,
5511
+ label: formatMessage({
5512
+ id: index.getTranslation("containers.Edit.delete"),
5513
+ defaultMessage: "Delete"
5514
+ }),
5515
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5516
+ }
5517
+ ),
5518
+ /* @__PURE__ */ jsxRuntime.jsx(
5519
+ designSystem.IconButton,
5520
+ {
5521
+ ref: composedAccordionRefs,
5522
+ variant: "ghost",
5523
+ onClick: (e) => e.stopPropagation(),
5524
+ "data-handler-id": handlerId,
5525
+ label: formatMessage({
5526
+ id: index.getTranslation("components.DragHandle-label"),
5527
+ defaultMessage: "Drag"
5528
+ }),
5529
+ onKeyDown: handleKeyDown,
5530
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
5531
+ }
5532
+ )
5533
+ ] })
5534
+ ] }),
5535
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
5536
+ designSystem.Flex,
5330
5537
  {
5331
- dynamicComponentsByCategory,
5332
- isOpen: addComponentIsOpen,
5333
- onClickAddComponent: handleAddComponent
5538
+ direction: "column",
5539
+ alignItems: "stretch",
5540
+ background: "neutral100",
5541
+ padding: 6,
5542
+ gap: 6,
5543
+ children
5334
5544
  }
5335
- )
5545
+ ) })
5336
5546
  ] }) });
5337
5547
  };
5338
- exports.BlocksInput = BlocksInput;
5339
- exports.ComponentInput = ComponentInput;
5548
+ const Preview = () => {
5549
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
5550
+ };
5551
+ const StyledSpan = styledComponents.styled(designSystem.Box)`
5552
+ display: block;
5553
+ outline: 1px dashed ${({ theme }) => theme.colors.primary500};
5554
+ outline-offset: -1px;
5555
+ `;
5556
+ const ComponentInput = ({
5557
+ label,
5558
+ required,
5559
+ name: name2,
5560
+ attribute,
5561
+ disabled,
5562
+ labelAction,
5563
+ ...props
5564
+ }) => {
5565
+ const { formatMessage } = reactIntl.useIntl();
5566
+ const field = strapiAdmin.useField(name2);
5567
+ const showResetComponent = !attribute.repeatable && field.value && !disabled;
5568
+ const { components } = index.useDoc();
5569
+ const handleInitialisationClick = () => {
5570
+ const schema = components[attribute.component];
5571
+ const form = index.createDefaultForm(schema, components);
5572
+ const data = index.transformDocument(schema, components)(form);
5573
+ field.onChange(name2, data);
5574
+ };
5575
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
5576
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
5577
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
5578
+ label,
5579
+ attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5580
+ " (",
5581
+ Array.isArray(field.value) ? field.value.length : 0,
5582
+ ")"
5583
+ ] })
5584
+ ] }),
5585
+ showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
5586
+ designSystem.IconButton,
5587
+ {
5588
+ label: formatMessage({
5589
+ id: index.getTranslation("components.reset-entry"),
5590
+ defaultMessage: "Reset Entry"
5591
+ }),
5592
+ variant: "ghost",
5593
+ onClick: () => {
5594
+ field.onChange(name2, null);
5595
+ },
5596
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5597
+ }
5598
+ )
5599
+ ] }),
5600
+ !attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
5601
+ !attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
5602
+ attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
5603
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
5604
+ ] });
5605
+ };
5606
+ const MemoizedComponentInput = React__namespace.memo(ComponentInput);
5340
5607
  exports.DynamicZone = DynamicZone;
5341
- exports.InputRenderer = InputRenderer;
5608
+ exports.FormLayout = FormLayout;
5609
+ exports.MemoizedBlocksInput = MemoizedBlocksInput;
5610
+ exports.MemoizedComponentInput = MemoizedComponentInput;
5611
+ exports.MemoizedUIDInput = MemoizedUIDInput;
5612
+ exports.MemoizedWysiwyg = MemoizedWysiwyg;
5342
5613
  exports.NotAllowedInput = NotAllowedInput;
5343
- exports.UIDInput = UIDInput;
5344
- exports.Wysiwyg = Wysiwyg;
5345
- exports.createDefaultForm = createDefaultForm;
5346
- exports.prepareTempKeys = prepareTempKeys;
5347
- exports.removeFieldsThatDontExistOnSchema = removeFieldsThatDontExistOnSchema;
5348
- exports.transformDocument = transformDocument;
5349
5614
  exports.useDynamicZone = useDynamicZone;
5350
5615
  exports.useFieldHint = useFieldHint;
5351
5616
  exports.useLazyComponents = useLazyComponents;
5352
- //# sourceMappingURL=Field-kq1c2TF1.js.map
5617
+ //# sourceMappingURL=Input-yM6HnyQa.js.map