@strapi/content-manager 0.0.0-experimental.826f263c58b6886b849d3f03b81f7a530bc51c91 → 0.0.0-experimental.82afe56cecefd0078d534e25909834ecf5fdd404

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 (231) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
  3. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
  4. package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js → ComponentConfigurationPage-DMxUlNOo.js} +5 -6
  5. package/dist/_chunks/{ComponentConfigurationPage-DJcn1DrO.js.map → ComponentConfigurationPage-DMxUlNOo.js.map} +1 -1
  6. package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs → ComponentConfigurationPage-baEkO-OV.mjs} +4 -4
  7. package/dist/_chunks/{ComponentConfigurationPage-CR5XdR33.mjs.map → ComponentConfigurationPage-baEkO-OV.mjs.map} +1 -1
  8. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
  9. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
  10. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
  11. package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js → EditConfigurationPage-CXxV7mKn.js} +5 -6
  12. package/dist/_chunks/{EditConfigurationPage-tDtWj7R2.js.map → EditConfigurationPage-CXxV7mKn.js.map} +1 -1
  13. package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs → EditConfigurationPage-YR8-4VCS.mjs} +4 -4
  14. package/dist/_chunks/{EditConfigurationPage-DmCIb4kD.mjs.map → EditConfigurationPage-YR8-4VCS.mjs.map} +1 -1
  15. package/dist/_chunks/{EditViewPage-CoQEnFlC.js → EditViewPage-BfR6jAR6.js} +71 -84
  16. package/dist/_chunks/EditViewPage-BfR6jAR6.js.map +1 -0
  17. package/dist/_chunks/EditViewPage-DFF7c27p.mjs +191 -0
  18. package/dist/_chunks/EditViewPage-DFF7c27p.mjs.map +1 -0
  19. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  20. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  21. package/dist/_chunks/{Form-Bpig5rch.js → Form-CjcMRP5A.js} +55 -38
  22. package/dist/_chunks/Form-CjcMRP5A.js.map +1 -0
  23. package/dist/_chunks/{Form-Dxmihyw8.mjs → Form-MSOSfGGN.mjs} +55 -37
  24. package/dist/_chunks/Form-MSOSfGGN.mjs.map +1 -0
  25. package/dist/_chunks/{History-BfX6XmZK.js → History-BgZ7gVuF.js} +208 -138
  26. package/dist/_chunks/History-BgZ7gVuF.js.map +1 -0
  27. package/dist/_chunks/{History-BZP8n7KT.mjs → History-WOQNVho-.mjs} +201 -130
  28. package/dist/_chunks/History-WOQNVho-.mjs.map +1 -0
  29. package/dist/_chunks/{Field-Cz_J9551.mjs → Input-BkKwZ6Qt.mjs} +1757 -1383
  30. package/dist/_chunks/Input-BkKwZ6Qt.mjs.map +1 -0
  31. package/dist/_chunks/{Field-ZdrmmQ4Y.js → Input-BwOibhc3.js} +1748 -1374
  32. package/dist/_chunks/Input-BwOibhc3.js.map +1 -0
  33. package/dist/_chunks/{ListConfigurationPage-DxKuVkKz.mjs → ListConfigurationPage-BeXfr6uW.mjs} +63 -52
  34. package/dist/_chunks/ListConfigurationPage-BeXfr6uW.mjs.map +1 -0
  35. package/dist/_chunks/{ListConfigurationPage-B3CXj8PY.js → ListConfigurationPage-DnJ3nbwL.js} +62 -51
  36. package/dist/_chunks/ListConfigurationPage-DnJ3nbwL.js.map +1 -0
  37. package/dist/_chunks/{ListViewPage-Bk9VO__I.js → ListViewPage-CJFDudKl.js} +155 -129
  38. package/dist/_chunks/ListViewPage-CJFDudKl.js.map +1 -0
  39. package/dist/_chunks/{ListViewPage-D5D3tVPq.mjs → ListViewPage-VK2v44Q1.mjs} +156 -129
  40. package/dist/_chunks/ListViewPage-VK2v44Q1.mjs.map +1 -0
  41. package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs → NoContentTypePage-T8ttty6K.mjs} +2 -2
  42. package/dist/_chunks/{NoContentTypePage-DnMeuQCj.mjs.map → NoContentTypePage-T8ttty6K.mjs.map} +1 -1
  43. package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js → NoContentTypePage-en2PwWgI.js} +2 -2
  44. package/dist/_chunks/{NoContentTypePage-DsB2F7Z1.js.map → NoContentTypePage-en2PwWgI.js.map} +1 -1
  45. package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js → NoPermissionsPage-CcjILry3.js} +2 -2
  46. package/dist/_chunks/{NoPermissionsPage-BQDM64_b.js.map → NoPermissionsPage-CcjILry3.js.map} +1 -1
  47. package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs → NoPermissionsPage-CokBHhhy.mjs} +2 -2
  48. package/dist/_chunks/{NoPermissionsPage-OyoME_Tf.mjs.map → NoPermissionsPage-CokBHhhy.mjs.map} +1 -1
  49. package/dist/_chunks/Preview-BF81YhRj.mjs +287 -0
  50. package/dist/_chunks/Preview-BF81YhRj.mjs.map +1 -0
  51. package/dist/_chunks/Preview-DgzAuzWQ.js +305 -0
  52. package/dist/_chunks/Preview-DgzAuzWQ.js.map +1 -0
  53. package/dist/_chunks/{Relations-B6B3A3mb.js → Relations-1O-JcM4t.js} +76 -43
  54. package/dist/_chunks/Relations-1O-JcM4t.js.map +1 -0
  55. package/dist/_chunks/{Relations-BOYZmuWy.mjs → Relations-BncdhGCd.mjs} +76 -42
  56. package/dist/_chunks/Relations-BncdhGCd.mjs.map +1 -0
  57. package/dist/_chunks/{en-Dzv55oQw.mjs → en-BZaUty0m.mjs} +41 -18
  58. package/dist/_chunks/{en-Dzv55oQw.mjs.map → en-BZaUty0m.mjs.map} +1 -1
  59. package/dist/_chunks/{en-BN1bvFK7.js → en-CzCnBk4S.js} +41 -18
  60. package/dist/_chunks/{en-BN1bvFK7.js.map → en-CzCnBk4S.js.map} +1 -1
  61. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  62. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  63. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  64. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  65. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  66. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  67. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  68. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  69. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  70. package/dist/_chunks/{index-VHviNMeW.mjs → index-DiluOUp6.mjs} +1469 -966
  71. package/dist/_chunks/index-DiluOUp6.mjs.map +1 -0
  72. package/dist/_chunks/{index-DzN3kBgx.js → index-EXJvmn4t.js} +1439 -936
  73. package/dist/_chunks/index-EXJvmn4t.js.map +1 -0
  74. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  75. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  76. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  77. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  78. package/dist/_chunks/{layout-b91XRlD2.js → layout-4TbKVax8.js} +41 -24
  79. package/dist/_chunks/layout-4TbKVax8.js.map +1 -0
  80. package/dist/_chunks/{layout-CPn1PM6x.mjs → layout-mSwsYzxv.mjs} +42 -24
  81. package/dist/_chunks/layout-mSwsYzxv.mjs.map +1 -0
  82. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  83. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  84. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  85. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  86. package/dist/_chunks/{relations-BsqxS6tR.mjs → relations--YOvQBqv.mjs} +6 -7
  87. package/dist/_chunks/relations--YOvQBqv.mjs.map +1 -0
  88. package/dist/_chunks/{relations-CA7IYmcP.js → relations-Ai6Izh7h.js} +6 -7
  89. package/dist/_chunks/relations-Ai6Izh7h.js.map +1 -0
  90. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  91. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  92. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  93. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  94. package/dist/_chunks/usePrev-CZGy2Vjf.mjs +29 -0
  95. package/dist/_chunks/usePrev-CZGy2Vjf.mjs.map +1 -0
  96. package/dist/_chunks/{usePrev-B9w_-eYc.js → usePrev-D5J_2fEu.js} +14 -1
  97. package/dist/_chunks/usePrev-D5J_2fEu.js.map +1 -0
  98. package/dist/admin/index.js +3 -1
  99. package/dist/admin/index.js.map +1 -1
  100. package/dist/admin/index.mjs +10 -8
  101. package/dist/admin/src/content-manager.d.ts +3 -2
  102. package/dist/admin/src/exports.d.ts +2 -1
  103. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  104. package/dist/admin/src/history/index.d.ts +3 -0
  105. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  106. package/dist/admin/src/hooks/useDocument.d.ts +49 -1
  107. package/dist/admin/src/index.d.ts +1 -0
  108. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  109. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +9 -4
  110. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
  111. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  112. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  113. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +5 -0
  114. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
  115. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
  116. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +20 -0
  117. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +2 -2
  118. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  119. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +6 -58
  120. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
  121. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  122. package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
  123. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  124. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  125. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  126. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  127. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  128. package/dist/admin/src/preview/index.d.ts +4 -0
  129. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  130. package/dist/admin/src/preview/routes.d.ts +3 -0
  131. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  132. package/dist/admin/src/router.d.ts +1 -1
  133. package/dist/admin/src/services/api.d.ts +1 -1
  134. package/dist/admin/src/services/components.d.ts +2 -2
  135. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  136. package/dist/admin/src/services/documents.d.ts +19 -20
  137. package/dist/admin/src/services/init.d.ts +1 -1
  138. package/dist/admin/src/services/relations.d.ts +2 -2
  139. package/dist/admin/src/services/uid.d.ts +3 -3
  140. package/dist/admin/src/utils/validation.d.ts +4 -1
  141. package/dist/server/index.js +765 -434
  142. package/dist/server/index.js.map +1 -1
  143. package/dist/server/index.mjs +766 -434
  144. package/dist/server/index.mjs.map +1 -1
  145. package/dist/server/src/bootstrap.d.ts.map +1 -1
  146. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  147. package/dist/server/src/controllers/index.d.ts.map +1 -1
  148. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  149. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  150. package/dist/server/src/controllers/utils/metadata.d.ts +16 -1
  151. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  152. package/dist/server/src/controllers/validation/dimensions.d.ts +4 -2
  153. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -1
  154. package/dist/server/src/history/controllers/history-version.d.ts +1 -1
  155. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  156. package/dist/server/src/history/services/history.d.ts +3 -3
  157. package/dist/server/src/history/services/history.d.ts.map +1 -1
  158. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  159. package/dist/server/src/history/services/utils.d.ts +8 -12
  160. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  161. package/dist/server/src/index.d.ts +7 -6
  162. package/dist/server/src/index.d.ts.map +1 -1
  163. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  164. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  165. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  166. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  167. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  168. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  169. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  170. package/dist/server/src/preview/index.d.ts +4 -0
  171. package/dist/server/src/preview/index.d.ts.map +1 -0
  172. package/dist/server/src/preview/routes/index.d.ts +8 -0
  173. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  174. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  175. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  176. package/dist/server/src/preview/services/index.d.ts +16 -0
  177. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  178. package/dist/server/src/preview/services/preview-config.d.ts +32 -0
  179. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  180. package/dist/server/src/preview/services/preview.d.ts +12 -0
  181. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  182. package/dist/server/src/preview/utils.d.ts +19 -0
  183. package/dist/server/src/preview/utils.d.ts.map +1 -0
  184. package/dist/server/src/register.d.ts.map +1 -1
  185. package/dist/server/src/routes/index.d.ts.map +1 -1
  186. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  187. package/dist/server/src/services/document-metadata.d.ts +12 -10
  188. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  189. package/dist/server/src/services/index.d.ts +7 -6
  190. package/dist/server/src/services/index.d.ts.map +1 -1
  191. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  192. package/dist/server/src/services/utils/populate.d.ts +2 -2
  193. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  194. package/dist/server/src/utils/index.d.ts +2 -0
  195. package/dist/server/src/utils/index.d.ts.map +1 -1
  196. package/dist/shared/contracts/collection-types.d.ts +3 -1
  197. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  198. package/dist/shared/contracts/index.d.ts +1 -0
  199. package/dist/shared/contracts/index.d.ts.map +1 -1
  200. package/dist/shared/contracts/preview.d.ts +27 -0
  201. package/dist/shared/contracts/preview.d.ts.map +1 -0
  202. package/dist/shared/index.js +4 -0
  203. package/dist/shared/index.js.map +1 -1
  204. package/dist/shared/index.mjs +4 -0
  205. package/dist/shared/index.mjs.map +1 -1
  206. package/package.json +17 -16
  207. package/dist/_chunks/EditViewPage-CoQEnFlC.js.map +0 -1
  208. package/dist/_chunks/EditViewPage-DvaV7U9b.mjs +0 -203
  209. package/dist/_chunks/EditViewPage-DvaV7U9b.mjs.map +0 -1
  210. package/dist/_chunks/Field-Cz_J9551.mjs.map +0 -1
  211. package/dist/_chunks/Field-ZdrmmQ4Y.js.map +0 -1
  212. package/dist/_chunks/Form-Bpig5rch.js.map +0 -1
  213. package/dist/_chunks/Form-Dxmihyw8.mjs.map +0 -1
  214. package/dist/_chunks/History-BZP8n7KT.mjs.map +0 -1
  215. package/dist/_chunks/History-BfX6XmZK.js.map +0 -1
  216. package/dist/_chunks/ListConfigurationPage-B3CXj8PY.js.map +0 -1
  217. package/dist/_chunks/ListConfigurationPage-DxKuVkKz.mjs.map +0 -1
  218. package/dist/_chunks/ListViewPage-Bk9VO__I.js.map +0 -1
  219. package/dist/_chunks/ListViewPage-D5D3tVPq.mjs.map +0 -1
  220. package/dist/_chunks/Relations-B6B3A3mb.js.map +0 -1
  221. package/dist/_chunks/Relations-BOYZmuWy.mjs.map +0 -1
  222. package/dist/_chunks/index-DzN3kBgx.js.map +0 -1
  223. package/dist/_chunks/index-VHviNMeW.mjs.map +0 -1
  224. package/dist/_chunks/layout-CPn1PM6x.mjs.map +0 -1
  225. package/dist/_chunks/layout-b91XRlD2.js.map +0 -1
  226. package/dist/_chunks/relations-BsqxS6tR.mjs.map +0 -1
  227. package/dist/_chunks/relations-CA7IYmcP.js.map +0 -1
  228. package/dist/_chunks/usePrev-B9w_-eYc.js.map +0 -1
  229. package/dist/_chunks/usePrev-DH6iah0A.mjs +0 -16
  230. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +0 -1
  231. package/strapi-server.js +0 -3
@@ -1,25 +1,75 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { useState, useEffect, useCallback, memo } from "react";
4
- import { useStrapiApp, createContext, useField, useNotification, useForm, useAPIErrorHandler, useQueryParams, useFocusInputField, InputRenderer as InputRenderer$1 } from "@strapi/admin/strapi-admin";
5
- import { Typography, Flex, Box, BaseLink, Button, useComposedRefs, Popover, Field, Tooltip, SingleSelect, SingleSelectOption, IconButton, Portal, FocusTrap, Divider, VisuallyHidden, Grid as Grid$1, GridItem, Accordion, TextButton, BaseButton, TextInput, IconButtonGroup, Menu, MenuItem } from "@strapi/design-system";
6
- import pipe$1 from "lodash/fp/pipe";
4
+ import { useStrapiApp, createContext, useField, useForm, useNotification, useAPIErrorHandler, useQueryParams, useFocusInputField, InputRenderer as InputRenderer$1 } from "@strapi/admin/strapi-admin";
5
+ import { Box, SingleSelect, SingleSelectOption, Typography, Flex, BaseLink, Button, Popover, Field, Tooltip, IconButton, useComposedRefs, Portal, FocusTrap, Divider, VisuallyHidden, Accordion, Menu, MenuItem, Grid as Grid$1, TextInput, IconButtonGroup, TextButton } from "@strapi/design-system";
6
+ import { CodeBlock as CodeBlock$1, HeadingOne, HeadingTwo, HeadingThree, HeadingFour, HeadingFive, HeadingSix, Image as Image$1, NumberList, BulletList, Paragraph, Quotes, Link as Link$1, Drag, Collapse, Bold, Italic, Underline, StrikeThrough, Code, Expand, PlusCircle, Trash, More, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, Plus } from "@strapi/icons";
7
7
  import { useIntl } from "react-intl";
8
- import { l as DOCUMENT_META_FIELDS, g as getTranslation, b as useDoc, d as contentManagerApi, c as buildValidParams, e as useDocumentRBAC, m as useDocLayout } from "./index-VHviNMeW.mjs";
9
- import { generateNKeysBetween } from "fractional-indexing";
10
- import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-BOYZmuWy.mjs";
11
- import { Code, HeadingOne, HeadingTwo, HeadingThree, HeadingFour, HeadingFive, HeadingSix, Image as Image$1, NumberList, BulletList, Paragraph, Quotes, Link as Link$1, Drag, Collapse, Bold, Italic, Underline, StrikeThrough, Expand, PlusCircle, Plus, Trash, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, More } from "@strapi/icons";
8
+ import { g as getTranslation, m as useDocLayout, c as useDoc, n as createDefaultForm, t as transformDocument, e as contentManagerApi, o as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, S as SINGLE_TYPES } from "./index-DiluOUp6.mjs";
12
9
  import { styled, css, keyframes } from "styled-components";
13
- import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
14
- import { getEmptyImage } from "react-dnd-html5-backend";
15
- import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DdHgKsqq.mjs";
16
- import { g as getIn } from "./objects-mKMAmfec.mjs";
17
10
  import { Editor as Editor$1, Transforms, Node, Element, Range, Path, Point, createEditor } from "slate";
18
11
  import { withHistory } from "slate-history";
19
12
  import { useFocused, useSelected, ReactEditor, Editable, useSlate, Slate, withReact } from "slate-react";
20
- import { p as prefixFileUrlWithBackendUrl, u as usePrev } from "./usePrev-DH6iah0A.mjs";
13
+ import * as Prism from "prismjs";
14
+ import "prismjs/themes/prism-solarizedlight.css";
15
+ import "prismjs/components/prism-asmatmel";
16
+ import "prismjs/components/prism-bash";
17
+ import "prismjs/components/prism-basic";
18
+ import "prismjs/components/prism-c";
19
+ import "prismjs/components/prism-clojure";
20
+ import "prismjs/components/prism-cobol";
21
+ import "prismjs/components/prism-cpp";
22
+ import "prismjs/components/prism-csharp";
23
+ import "prismjs/components/prism-dart";
24
+ import "prismjs/components/prism-docker";
25
+ import "prismjs/components/prism-elixir";
26
+ import "prismjs/components/prism-erlang";
27
+ import "prismjs/components/prism-fortran";
28
+ import "prismjs/components/prism-fsharp";
29
+ import "prismjs/components/prism-go";
30
+ import "prismjs/components/prism-graphql";
31
+ import "prismjs/components/prism-groovy";
32
+ import "prismjs/components/prism-haskell";
33
+ import "prismjs/components/prism-haxe";
34
+ import "prismjs/components/prism-ini";
35
+ import "prismjs/components/prism-java";
36
+ import "prismjs/components/prism-javascript";
37
+ import "prismjs/components/prism-jsx";
38
+ import "prismjs/components/prism-json";
39
+ import "prismjs/components/prism-julia";
40
+ import "prismjs/components/prism-kotlin";
41
+ import "prismjs/components/prism-latex";
42
+ import "prismjs/components/prism-lua";
43
+ import "prismjs/components/prism-markdown";
44
+ import "prismjs/components/prism-matlab";
45
+ import "prismjs/components/prism-makefile";
46
+ import "prismjs/components/prism-objectivec";
47
+ import "prismjs/components/prism-perl";
48
+ import "prismjs/components/prism-php";
49
+ import "prismjs/components/prism-powershell";
50
+ import "prismjs/components/prism-python";
51
+ import "prismjs/components/prism-r";
52
+ import "prismjs/components/prism-ruby";
53
+ import "prismjs/components/prism-rust";
54
+ import "prismjs/components/prism-sas";
55
+ import "prismjs/components/prism-scala";
56
+ import "prismjs/components/prism-scheme";
57
+ import "prismjs/components/prism-sql";
58
+ import "prismjs/components/prism-stata";
59
+ import "prismjs/components/prism-swift";
60
+ import "prismjs/components/prism-typescript";
61
+ import "prismjs/components/prism-tsx";
62
+ import "prismjs/components/prism-vbnet";
63
+ import "prismjs/components/prism-yaml";
64
+ import { p as prefixFileUrlWithBackendUrl, u as useDebounce, a as usePrev } from "./usePrev-CZGy2Vjf.mjs";
65
+ import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DJ6jqvZN.mjs";
21
66
  import * as Toolbar from "@radix-ui/react-toolbar";
22
- import { useLocation } from "react-router-dom";
67
+ import { getEmptyImage } from "react-dnd-html5-backend";
68
+ import { useMatch, useLocation } from "react-router-dom";
69
+ import { g as getIn } from "./objects-D6yBsdmx.mjs";
70
+ import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-BncdhGCd.mjs";
71
+ import pipe$1 from "lodash/fp/pipe";
72
+ import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
23
73
  import CodeMirror from "codemirror5";
24
74
  import sanitizeHtml from "sanitize-html";
25
75
  import { getLanguage, highlight, highlightAuto } from "highlight.js";
@@ -35,93 +85,6 @@ import sub from "markdown-it-sub";
35
85
  import sup from "markdown-it-sup";
36
86
  import "highlight.js/styles/solarized-dark.css";
37
87
  import "codemirror5/addon/display/placeholder";
38
- const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
39
- const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
40
- const traverse = (datum, attributes) => {
41
- return Object.entries(datum).reduce((acc, [key, value]) => {
42
- const attribute = attributes[key];
43
- if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
44
- acc[key] = value;
45
- return acc;
46
- }
47
- if (attribute.type === "component") {
48
- if (attribute.repeatable) {
49
- const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
50
- acc[key] = componentValue.map(
51
- (componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
52
- );
53
- } else {
54
- const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
55
- acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
56
- }
57
- } else if (attribute.type === "dynamiczone") {
58
- const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
59
- acc[key] = dynamicZoneValue.map(
60
- (componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
61
- );
62
- } else if (predicate(attribute, value)) {
63
- acc[key] = transform(value, attribute);
64
- } else {
65
- acc[key] = value;
66
- }
67
- return acc;
68
- }, {});
69
- };
70
- return traverse(data, schema.attributes);
71
- };
72
- const removeProhibitedFields = (prohibitedFields) => traverseData(
73
- (attribute) => prohibitedFields.includes(attribute.type),
74
- () => ""
75
- );
76
- const prepareRelations = traverseData(
77
- (attribute) => attribute.type === "relation",
78
- () => ({
79
- connect: [],
80
- disconnect: []
81
- })
82
- );
83
- const prepareTempKeys = traverseData(
84
- (attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
85
- (data) => {
86
- if (Array.isArray(data) && data.length > 0) {
87
- const keys = generateNKeysBetween(void 0, void 0, data.length);
88
- return data.map((datum, index) => ({
89
- ...datum,
90
- __temp_key__: keys[index]
91
- }));
92
- }
93
- return data;
94
- }
95
- );
96
- const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
97
- const schemaKeys = Object.keys(schema.attributes);
98
- const dataKeys = Object.keys(data);
99
- const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
100
- const revisedData = [...keysToRemove, ...DOCUMENT_META_FIELDS].reduce((acc, key) => {
101
- delete acc[key];
102
- return acc;
103
- }, structuredClone(data));
104
- return revisedData;
105
- };
106
- const removeNullValues = (data) => {
107
- return Object.entries(data).reduce((acc, [key, value]) => {
108
- if (value === null) {
109
- return acc;
110
- }
111
- acc[key] = value;
112
- return acc;
113
- }, {});
114
- };
115
- const transformDocument = (schema, components = {}) => (document2) => {
116
- const transformations = pipe$1(
117
- removeFieldsThatDontExistOnSchema(schema),
118
- removeProhibitedFields(["password"])(schema, components),
119
- removeNullValues,
120
- prepareRelations(schema, components),
121
- prepareTempKeys(schema, components)
122
- );
123
- return transformations(document2);
124
- };
125
88
  const componentStore = /* @__PURE__ */ new Map();
126
89
  const useLazyComponents = (componentUids = []) => {
127
90
  const [lazyComponentStore, setLazyComponentStore] = useState(Object.fromEntries(componentStore));
@@ -160,6 +123,224 @@ const useLazyComponents = (componentUids = []) => {
160
123
  }, []);
161
124
  return { isLazyLoading: loading, lazyComponentStore, cleanup };
162
125
  };
126
+ const codeLanguages = [
127
+ {
128
+ value: "asm",
129
+ label: "Assembly",
130
+ decorate: "asmatmel"
131
+ },
132
+ {
133
+ value: "bash",
134
+ label: "Bash"
135
+ },
136
+ {
137
+ value: "c",
138
+ label: "C"
139
+ },
140
+ {
141
+ value: "clojure",
142
+ label: "Clojure"
143
+ },
144
+ {
145
+ value: "cobol",
146
+ label: "COBOL"
147
+ },
148
+ {
149
+ value: "cpp",
150
+ label: "C++"
151
+ },
152
+ {
153
+ value: "csharp",
154
+ label: "C#"
155
+ },
156
+ {
157
+ value: "css",
158
+ label: "CSS"
159
+ },
160
+ {
161
+ value: "dart",
162
+ label: "Dart"
163
+ },
164
+ {
165
+ value: "dockerfile",
166
+ label: "Dockerfile",
167
+ decorate: "docker"
168
+ },
169
+ {
170
+ value: "elixir",
171
+ label: "Elixir"
172
+ },
173
+ {
174
+ value: "erlang",
175
+ label: "Erlang"
176
+ },
177
+ {
178
+ value: "fortran",
179
+ label: "Fortran"
180
+ },
181
+ {
182
+ value: "fsharp",
183
+ label: "F#"
184
+ },
185
+ {
186
+ value: "go",
187
+ label: "Go"
188
+ },
189
+ {
190
+ value: "graphql",
191
+ label: "GraphQL"
192
+ },
193
+ {
194
+ value: "groovy",
195
+ label: "Groovy"
196
+ },
197
+ {
198
+ value: "haskell",
199
+ label: "Haskell"
200
+ },
201
+ {
202
+ value: "haxe",
203
+ label: "Haxe"
204
+ },
205
+ {
206
+ value: "html",
207
+ label: "HTML"
208
+ },
209
+ {
210
+ value: "ini",
211
+ label: "INI"
212
+ },
213
+ {
214
+ value: "java",
215
+ label: "Java"
216
+ },
217
+ {
218
+ value: "javascript",
219
+ label: "JavaScript"
220
+ },
221
+ {
222
+ value: "jsx",
223
+ label: "JavaScript (React)"
224
+ },
225
+ {
226
+ value: "json",
227
+ label: "JSON"
228
+ },
229
+ {
230
+ value: "julia",
231
+ label: "Julia"
232
+ },
233
+ {
234
+ value: "kotlin",
235
+ label: "Kotlin"
236
+ },
237
+ {
238
+ value: "latex",
239
+ label: "LaTeX"
240
+ },
241
+ {
242
+ value: "lua",
243
+ label: "Lua"
244
+ },
245
+ {
246
+ value: "markdown",
247
+ label: "Markdown"
248
+ },
249
+ {
250
+ value: "matlab",
251
+ label: "MATLAB"
252
+ },
253
+ {
254
+ value: "makefile",
255
+ label: "Makefile"
256
+ },
257
+ {
258
+ value: "objectivec",
259
+ label: "Objective-C"
260
+ },
261
+ {
262
+ value: "perl",
263
+ label: "Perl"
264
+ },
265
+ {
266
+ value: "php",
267
+ label: "PHP"
268
+ },
269
+ {
270
+ value: "plaintext",
271
+ label: "Plain text"
272
+ },
273
+ {
274
+ value: "powershell",
275
+ label: "PowerShell"
276
+ },
277
+ {
278
+ value: "python",
279
+ label: "Python"
280
+ },
281
+ {
282
+ value: "r",
283
+ label: "R"
284
+ },
285
+ {
286
+ value: "ruby",
287
+ label: "Ruby"
288
+ },
289
+ {
290
+ value: "rust",
291
+ label: "Rust"
292
+ },
293
+ {
294
+ value: "sas",
295
+ label: "SAS"
296
+ },
297
+ {
298
+ value: "scala",
299
+ label: "Scala"
300
+ },
301
+ {
302
+ value: "scheme",
303
+ label: "Scheme"
304
+ },
305
+ {
306
+ value: "shell",
307
+ label: "Shell"
308
+ },
309
+ {
310
+ value: "sql",
311
+ label: "SQL"
312
+ },
313
+ {
314
+ value: "stata",
315
+ label: "Stata"
316
+ },
317
+ {
318
+ value: "swift",
319
+ label: "Swift"
320
+ },
321
+ {
322
+ value: "typescript",
323
+ label: "TypeScript",
324
+ decorate: "ts"
325
+ },
326
+ {
327
+ value: "tsx",
328
+ label: "TypeScript (React)"
329
+ },
330
+ {
331
+ value: "vbnet",
332
+ label: "VB.NET"
333
+ },
334
+ {
335
+ value: "xml",
336
+ label: "XML"
337
+ },
338
+ {
339
+ value: "yaml",
340
+ label: "YAML",
341
+ decorate: "yml"
342
+ }
343
+ ];
163
344
  const baseHandleConvert = (editor, attributesToSet) => {
164
345
  const [_, lastNodePath] = Editor$1.last(editor, []);
165
346
  Transforms.unwrapNodes(editor, {
@@ -223,6 +404,29 @@ const pressEnterTwiceToExit = (editor) => {
223
404
  });
224
405
  }
225
406
  };
407
+ const decorateCode = ([node, path]) => {
408
+ const ranges = [];
409
+ if (!Element.isElement(node) || node.type !== "code") return ranges;
410
+ const text = Node.string(node);
411
+ const language = codeLanguages.find((lang) => lang.value === node.language);
412
+ const decorateKey = language?.decorate ?? language?.value;
413
+ const selectedLanguage = Prism.languages[decorateKey || "plaintext"];
414
+ const tokens = Prism.tokenize(text, selectedLanguage);
415
+ let start = 0;
416
+ for (const token of tokens) {
417
+ const length = token.length;
418
+ const end = start + length;
419
+ if (typeof token !== "string") {
420
+ ranges.push({
421
+ anchor: { path, offset: start },
422
+ focus: { path, offset: end },
423
+ className: `token ${token.type}`
424
+ });
425
+ }
426
+ start = end;
427
+ }
428
+ return ranges;
429
+ };
226
430
  const CodeBlock = styled.pre`
227
431
  border-radius: ${({ theme }) => theme.borderRadius};
228
432
  background-color: ${({ theme }) => theme.colors.neutral100};
@@ -230,6 +434,7 @@ const CodeBlock = styled.pre`
230
434
  overflow: auto;
231
435
  padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};
232
436
  flex-shrink: 1;
437
+
233
438
  & > code {
234
439
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,
235
440
  monospace;
@@ -238,10 +443,62 @@ const CodeBlock = styled.pre`
238
443
  max-width: 100%;
239
444
  }
240
445
  `;
446
+ const CodeEditor = (props) => {
447
+ const { editor } = useBlocksEditorContext("ImageDialog");
448
+ const editorIsFocused = useFocused();
449
+ const imageIsSelected = useSelected();
450
+ const { formatMessage } = useIntl();
451
+ const [isSelectOpen, setIsSelectOpen] = React.useState(false);
452
+ const shouldDisplayLanguageSelect = editorIsFocused && imageIsSelected || isSelectOpen;
453
+ return /* @__PURE__ */ jsxs(Box, { position: "relative", width: "100%", children: [
454
+ /* @__PURE__ */ jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsx("code", { children: props.children }) }),
455
+ shouldDisplayLanguageSelect && /* @__PURE__ */ jsx(
456
+ Box,
457
+ {
458
+ position: "absolute",
459
+ background: "neutral0",
460
+ borderColor: "neutral150",
461
+ borderStyle: "solid",
462
+ borderWidth: "0.5px",
463
+ shadow: "tableShadow",
464
+ top: "100%",
465
+ marginTop: 1,
466
+ right: 0,
467
+ padding: 1,
468
+ hasRadius: true,
469
+ children: /* @__PURE__ */ jsx(
470
+ SingleSelect,
471
+ {
472
+ onChange: (open) => {
473
+ Transforms.setNodes(
474
+ editor,
475
+ { language: open.toString() },
476
+ { match: (node) => !Editor$1.isEditor(node) && node.type === "code" }
477
+ );
478
+ },
479
+ value: props.element.type === "code" && props.element.language || "plaintext",
480
+ onOpenChange: (open) => {
481
+ setIsSelectOpen(open);
482
+ if (!open) {
483
+ ReactEditor.focus(editor);
484
+ }
485
+ },
486
+ onCloseAutoFocus: (e) => e.preventDefault(),
487
+ "aria-label": formatMessage({
488
+ id: "components.Blocks.blocks.code.languageLabel",
489
+ defaultMessage: "Select a language"
490
+ }),
491
+ children: codeLanguages.map(({ value, label }) => /* @__PURE__ */ jsx(SingleSelectOption, { value, children: label }, value))
492
+ }
493
+ )
494
+ }
495
+ )
496
+ ] });
497
+ };
241
498
  const codeBlocks = {
242
499
  code: {
243
- renderElement: (props) => /* @__PURE__ */ jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsx("code", { children: props.children }) }),
244
- icon: Code,
500
+ renderElement: (props) => /* @__PURE__ */ jsx(CodeEditor, { ...props }),
501
+ icon: CodeBlock$1,
245
502
  label: {
246
503
  id: "components.Blocks.blocks.code",
247
504
  defaultMessage: "Code block"
@@ -249,13 +506,12 @@ const codeBlocks = {
249
506
  matchNode: (node) => node.type === "code",
250
507
  isInBlocksSelector: true,
251
508
  handleConvert(editor) {
252
- baseHandleConvert(editor, { type: "code" });
509
+ baseHandleConvert(editor, { type: "code", language: "plaintext" });
253
510
  },
254
511
  handleEnterKey(editor) {
255
512
  pressEnterTwiceToExit(editor);
256
513
  },
257
- snippets: ["```"],
258
- dragHandleTopMargin: "10px"
514
+ snippets: ["```"]
259
515
  }
260
516
  };
261
517
  const H1 = styled(Typography).attrs({ tag: "h1" })`
@@ -430,8 +686,7 @@ const ImageDialog = () => {
430
686
  const [isOpen, setIsOpen] = React.useState(true);
431
687
  const { editor } = useBlocksEditorContext("ImageDialog");
432
688
  const components = useStrapiApp("ImageDialog", (state) => state.components);
433
- if (!components || !isOpen)
434
- return null;
689
+ if (!components || !isOpen) return null;
435
690
  const MediaLibraryDialog = components["media-library"];
436
691
  const insertImages = (images) => {
437
692
  Transforms.unwrapNodes(editor, {
@@ -440,14 +695,12 @@ const ImageDialog = () => {
440
695
  });
441
696
  const nodeEntryBeingReplaced = Editor$1.above(editor, {
442
697
  match(node) {
443
- if (Editor$1.isEditor(node))
444
- return false;
698
+ if (Editor$1.isEditor(node)) return false;
445
699
  const isInlineNode = ["text", "link"].includes(node.type);
446
700
  return !isInlineNode;
447
701
  }
448
702
  });
449
- if (!nodeEntryBeingReplaced)
450
- return;
703
+ if (!nodeEntryBeingReplaced) return;
451
704
  const [, pathToInsert] = nodeEntryBeingReplaced;
452
705
  Transforms.removeNodes(editor);
453
706
  const nodesToInsert = images.map((image) => {
@@ -589,18 +842,12 @@ const LinkContent = React.forwardRef(
589
842
  const [popoverOpen, setPopoverOpen] = React.useState(
590
843
  editor.lastInsertedLinkPath ? Path.equals(path, editor.lastInsertedLinkPath) : false
591
844
  );
592
- const linkRef = React.useRef(null);
593
845
  const elementText = link.children.map((child) => child.text).join("");
594
846
  const [linkText, setLinkText] = React.useState(elementText);
595
847
  const [linkUrl, setLinkUrl] = React.useState(link.url);
596
848
  const linkInputRef = React.useRef(null);
597
- const [showRemoveButton, setShowRemoveButton] = React.useState(false);
849
+ const isLastInsertedLink = editor.lastInsertedLinkPath ? !Path.equals(path, editor.lastInsertedLinkPath) : true;
598
850
  const [isSaveDisabled, setIsSaveDisabled] = React.useState(false);
599
- const handleOpenEditPopover = (e) => {
600
- e.preventDefault();
601
- setPopoverOpen(true);
602
- setShowRemoveButton(true);
603
- };
604
851
  const onLinkChange = (e) => {
605
852
  setIsSaveDisabled(false);
606
853
  setLinkUrl(e.target.value);
@@ -621,33 +868,32 @@ const LinkContent = React.forwardRef(
621
868
  editLink(editor, { url: linkUrl, text: linkText });
622
869
  setPopoverOpen(false);
623
870
  editor.lastInsertedLinkPath = null;
871
+ ReactEditor.focus(editor);
624
872
  };
625
- const handleDismiss = () => {
626
- setPopoverOpen(false);
873
+ const handleClose = () => {
627
874
  if (link.url === "") {
628
875
  removeLink(editor);
629
876
  }
877
+ setPopoverOpen(false);
630
878
  ReactEditor.focus(editor);
631
879
  };
632
- const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
633
- const composedRefs = useComposedRefs(linkRef, forwardedRef);
634
880
  React.useEffect(() => {
635
- if (popoverOpen)
636
- linkInputRef.current?.focus();
881
+ if (popoverOpen) linkInputRef.current?.focus();
637
882
  }, [popoverOpen]);
638
- return /* @__PURE__ */ jsxs(Fragment, { children: [
639
- /* @__PURE__ */ jsx(
883
+ const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
884
+ return /* @__PURE__ */ jsxs(Popover.Root, { open: popoverOpen, children: [
885
+ /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
640
886
  StyledBaseLink,
641
887
  {
642
888
  ...attributes,
643
- ref: composedRefs,
889
+ ref: forwardedRef,
644
890
  href: link.url,
645
- onClick: handleOpenEditPopover,
891
+ onClick: () => setPopoverOpen(true),
646
892
  color: "primary600",
647
893
  children
648
894
  }
649
- ),
650
- popoverOpen && /* @__PURE__ */ jsx(Popover, { source: linkRef, onDismiss: handleDismiss, padding: 4, contentEditable: false, children: /* @__PURE__ */ jsxs(Flex, { tag: "form", onSubmit: handleSave, direction: "column", gap: 4, children: [
895
+ ) }),
896
+ /* @__PURE__ */ jsx(Popover.Content, { onPointerDownOutside: handleClose, children: /* @__PURE__ */ jsxs(Flex, { padding: 4, direction: "column", gap: 4, children: [
651
897
  /* @__PURE__ */ jsx(Field.Root, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
652
898
  /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
653
899
  id: "components.Blocks.popover.text",
@@ -693,7 +939,7 @@ const LinkContent = React.forwardRef(
693
939
  {
694
940
  variant: "danger-light",
695
941
  onClick: () => removeLink(editor),
696
- $visible: showRemoveButton,
942
+ $visible: isLastInsertedLink,
697
943
  children: formatMessage({
698
944
  id: "components.Blocks.popover.remove",
699
945
  defaultMessage: "Remove"
@@ -701,12 +947,12 @@ const LinkContent = React.forwardRef(
701
947
  }
702
948
  ),
703
949
  /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
704
- /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: handleDismiss, children: formatMessage({
705
- id: "components.Blocks.popover.cancel",
950
+ /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
951
+ id: "global.cancel",
706
952
  defaultMessage: "Cancel"
707
953
  }) }),
708
- /* @__PURE__ */ jsx(Button, { type: "submit", disabled: Boolean(inputNotDirty) || isSaveDisabled, children: formatMessage({
709
- id: "components.Blocks.popover.save",
954
+ /* @__PURE__ */ jsx(Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
955
+ id: "global.save",
710
956
  defaultMessage: "Save"
711
957
  }) })
712
958
  ] })
@@ -787,8 +1033,7 @@ const isText$1 = (node) => {
787
1033
  return Node.isNode(node) && !Editor$1.isEditor(node) && node.type === "text";
788
1034
  };
789
1035
  const handleBackspaceKeyOnList = (editor, event) => {
790
- if (!editor.selection)
791
- return;
1036
+ if (!editor.selection) return;
792
1037
  const [currentListItem, currentListItemPath] = Editor$1.parent(editor, editor.selection.anchor);
793
1038
  const [currentList, currentListPath] = Editor$1.parent(editor, currentListItemPath);
794
1039
  const isListEmpty = currentList.children.length === 1 && isText$1(currentListItem.children[0]) && currentListItem.children[0].text === "";
@@ -897,8 +1142,7 @@ const handleEnterKeyOnList = (editor) => {
897
1142
  };
898
1143
  const handleConvertToList = (editor, format) => {
899
1144
  const convertedPath = baseHandleConvert(editor, { type: "list-item" });
900
- if (!convertedPath)
901
- return;
1145
+ if (!convertedPath) return;
902
1146
  Transforms.wrapNodes(editor, { type: "list", format, children: [] }, { at: convertedPath });
903
1147
  };
904
1148
  const handleTabOnList = (editor) => {
@@ -910,8 +1154,7 @@ const handleTabOnList = (editor) => {
910
1154
  }
911
1155
  const [currentListItem, currentListItemPath] = currentListItemEntry;
912
1156
  const [currentList] = Editor$1.parent(editor, currentListItemPath);
913
- if (currentListItem === currentList.children[0])
914
- return;
1157
+ if (currentListItem === currentList.children[0]) return;
915
1158
  const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);
916
1159
  const previousNode = currentList.children[currentListItemIndex - 1];
917
1160
  if (previousNode.type === "list") {
@@ -1047,13 +1290,13 @@ const quoteBlocks = {
1047
1290
  handleEnterKey(editor) {
1048
1291
  pressEnterTwiceToExit(editor);
1049
1292
  },
1050
- snippets: [">"],
1051
- dragHandleTopMargin: "6px"
1293
+ snippets: [">"]
1052
1294
  }
1053
1295
  };
1054
1296
  const ToolbarWrapper = styled(Flex)`
1055
1297
  &[aria-disabled='true'] {
1056
1298
  cursor: not-allowed;
1299
+ background: ${({ theme }) => theme.colors.neutral150};
1057
1300
  }
1058
1301
  `;
1059
1302
  const Separator = styled(Toolbar.Separator)`
@@ -1064,7 +1307,7 @@ const Separator = styled(Toolbar.Separator)`
1064
1307
  const FlexButton = styled(Flex)`
1065
1308
  // Inherit the not-allowed cursor from ToolbarWrapper when disabled
1066
1309
  &[aria-disabled] {
1067
- cursor: inherit;
1310
+ cursor: not-allowed;
1068
1311
  }
1069
1312
 
1070
1313
  &[aria-disabled='false'] {
@@ -1146,7 +1389,7 @@ const ToolbarButton = ({
1146
1389
  width: 7,
1147
1390
  height: 7,
1148
1391
  hasRadius: true,
1149
- children: /* @__PURE__ */ jsx(Icon, { width: "1.2rem", height: "1.2rem", fill: disabled ? "neutral300" : enabledColor })
1392
+ children: /* @__PURE__ */ jsx(Icon, { fill: disabled ? "neutral300" : enabledColor })
1150
1393
  }
1151
1394
  )
1152
1395
  }
@@ -1278,8 +1521,7 @@ const isListNode = (node) => {
1278
1521
  const ListButton = ({ block, format }) => {
1279
1522
  const { editor, disabled, blocks } = useBlocksEditorContext("ListButton");
1280
1523
  const isListActive = () => {
1281
- if (!editor.selection)
1282
- return false;
1524
+ if (!editor.selection) return false;
1283
1525
  const currentListEntry = Editor$1.above(editor, {
1284
1526
  match: (node) => !Editor$1.isEditor(node) && node.type === "list",
1285
1527
  at: editor.selection.anchor
@@ -1291,6 +1533,26 @@ const ListButton = ({ block, format }) => {
1291
1533
  }
1292
1534
  return false;
1293
1535
  };
1536
+ const isListDisabled = () => {
1537
+ if (disabled) {
1538
+ return true;
1539
+ }
1540
+ if (!editor.selection) {
1541
+ return false;
1542
+ }
1543
+ const anchorNodeEntry = Editor$1.above(editor, {
1544
+ at: editor.selection.anchor,
1545
+ match: (node) => !Editor$1.isEditor(node) && node.type !== "text"
1546
+ });
1547
+ const focusNodeEntry = Editor$1.above(editor, {
1548
+ at: editor.selection.focus,
1549
+ match: (node) => !Editor$1.isEditor(node) && node.type !== "text"
1550
+ });
1551
+ if (!anchorNodeEntry || !focusNodeEntry) {
1552
+ return false;
1553
+ }
1554
+ return anchorNodeEntry[0] !== focusNodeEntry[0];
1555
+ };
1294
1556
  const toggleList = (format2) => {
1295
1557
  let currentListEntry;
1296
1558
  if (editor.selection) {
@@ -1324,7 +1586,7 @@ const ListButton = ({ block, format }) => {
1324
1586
  name: format,
1325
1587
  label: block.label,
1326
1588
  isActive: isListActive(),
1327
- disabled,
1589
+ disabled: isListDisabled(),
1328
1590
  handleClick: () => toggleList(format)
1329
1591
  }
1330
1592
  );
@@ -1333,8 +1595,7 @@ const LinkButton = ({ disabled }) => {
1333
1595
  const { editor } = useBlocksEditorContext("LinkButton");
1334
1596
  const isLinkActive = () => {
1335
1597
  const { selection } = editor;
1336
- if (!selection)
1337
- return false;
1598
+ if (!selection) return false;
1338
1599
  const [match] = Array.from(
1339
1600
  Editor$1.nodes(editor, {
1340
1601
  at: Editor$1.unhangRange(editor, selection),
@@ -1398,7 +1659,7 @@ const BlocksToolbar = () => {
1398
1659
  return false;
1399
1660
  };
1400
1661
  const isButtonDisabled = checkButtonDisabled();
1401
- return /* @__PURE__ */ jsx(Toolbar.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxs(ToolbarWrapper, { gap: 2, padding: 2, children: [
1662
+ return /* @__PURE__ */ jsx(Toolbar.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxs(ToolbarWrapper, { gap: 2, padding: 2, width: "100%", children: [
1402
1663
  /* @__PURE__ */ jsx(BlocksDropdown, {}),
1403
1664
  /* @__PURE__ */ jsx(Separator, {}),
1404
1665
  /* @__PURE__ */ jsx(Toolbar.ToggleGroup, { type: "multiple", asChild: true, children: /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
@@ -1468,33 +1729,36 @@ const DragItem = styled(Flex)`
1468
1729
  }
1469
1730
  `;
1470
1731
  const DragIconButton = styled(IconButton)`
1732
+ user-select: none;
1471
1733
  display: flex;
1472
1734
  align-items: center;
1473
1735
  justify-content: center;
1736
+ border: none;
1474
1737
  border-radius: ${({ theme }) => theme.borderRadius};
1475
- width: ${({ theme }) => theme.spaces[4]};
1476
- height: ${({ theme }) => theme.spaces[6]};
1738
+ padding-left: ${({ theme }) => theme.spaces[0]};
1739
+ padding-right: ${({ theme }) => theme.spaces[0]};
1740
+ padding-top: ${({ theme }) => theme.spaces[1]};
1741
+ padding-bottom: ${({ theme }) => theme.spaces[1]};
1477
1742
  visibility: hidden;
1478
1743
  cursor: grab;
1479
1744
  opacity: inherit;
1480
1745
  margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
1481
1746
 
1482
1747
  &:hover {
1483
- background: ${({ theme }) => theme.colors.neutral200};
1748
+ background: ${({ theme }) => theme.colors.neutral100};
1484
1749
  }
1485
1750
  &:active {
1486
1751
  cursor: grabbing;
1752
+ background: ${({ theme }) => theme.colors.neutral150};
1487
1753
  }
1488
1754
  &[aria-disabled='true'] {
1489
- cursor: not-allowed;
1490
- background: transparent;
1755
+ visibility: hidden;
1491
1756
  }
1492
1757
  svg {
1493
- height: auto;
1494
- width: ${({ theme }) => theme.spaces[3]};
1758
+ min-width: ${({ theme }) => theme.spaces[3]};
1495
1759
 
1496
1760
  path {
1497
- fill: ${({ theme }) => theme.colors.neutral700};
1761
+ fill: ${({ theme }) => theme.colors.neutral500};
1498
1762
  }
1499
1763
  }
1500
1764
  `;
@@ -1539,8 +1803,7 @@ const DragAndDropElement = ({
1539
1803
  displayedValue: children
1540
1804
  },
1541
1805
  onDropItem(currentIndex, newIndex) {
1542
- if (newIndex)
1543
- handleMoveBlock(newIndex, currentIndex);
1806
+ if (newIndex) handleMoveBlock(newIndex, currentIndex);
1544
1807
  }
1545
1808
  });
1546
1809
  const composedBoxRefs = useComposedRefs(blockRef, dropRef);
@@ -1596,6 +1859,7 @@ const DragAndDropElement = ({
1596
1859
  DragIconButton,
1597
1860
  {
1598
1861
  tag: "div",
1862
+ contentEditable: false,
1599
1863
  role: "button",
1600
1864
  tabIndex: 0,
1601
1865
  withTooltip: false,
@@ -1608,7 +1872,7 @@ const DragAndDropElement = ({
1608
1872
  disabled,
1609
1873
  draggable: true,
1610
1874
  $dragHandleTopMargin: dragHandleTopMargin,
1611
- children: /* @__PURE__ */ jsx(Drag, { color: "neutral600" })
1875
+ children: /* @__PURE__ */ jsx(Drag, { color: "primary500" })
1612
1876
  }
1613
1877
  ),
1614
1878
  children
@@ -1645,7 +1909,7 @@ const baseRenderLeaf = (props, modifiers2) => {
1645
1909
  }
1646
1910
  return currentChildren;
1647
1911
  }, props.children);
1648
- return /* @__PURE__ */ jsx("span", { ...props.attributes, children: wrappedChildren });
1912
+ return /* @__PURE__ */ jsx("span", { ...props.attributes, className: props.leaf.className, children: wrappedChildren });
1649
1913
  };
1650
1914
  const baseRenderElement = ({
1651
1915
  props,
@@ -1683,8 +1947,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1683
1947
  [modifiers2]
1684
1948
  );
1685
1949
  const handleMoveBlocks = (editor2, event) => {
1686
- if (!editor2.selection)
1687
- return;
1950
+ if (!editor2.selection) return;
1688
1951
  const start = Range.start(editor2.selection);
1689
1952
  const currentIndex = [start.path[0]];
1690
1953
  let newIndexPosition = 0;
@@ -1821,8 +2084,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1821
2084
  }
1822
2085
  };
1823
2086
  const handleScrollSelectionIntoView = () => {
1824
- if (!editor.selection)
1825
- return;
2087
+ if (!editor.selection) return;
1826
2088
  const domRange = ReactEditor.toDOMRange(editor, editor.selection);
1827
2089
  const domRect = domRange.getBoundingClientRect();
1828
2090
  const blocksInput = blocksRef.current;
@@ -1849,7 +2111,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1849
2111
  background: "neutral0",
1850
2112
  color: "neutral800",
1851
2113
  lineHeight: 6,
1852
- paddingRight: 4,
2114
+ paddingRight: 7,
1853
2115
  paddingTop: 6,
1854
2116
  paddingBottom: 3,
1855
2117
  children: [
@@ -1860,6 +2122,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
1860
2122
  readOnly: disabled,
1861
2123
  placeholder,
1862
2124
  isExpandedMode,
2125
+ decorate: decorateCode,
1863
2126
  renderElement,
1864
2127
  renderLeaf,
1865
2128
  onKeyDown: handleKeyDown,
@@ -1932,7 +2195,7 @@ const EditorLayout$1 = ({
1932
2195
  /* @__PURE__ */ jsx(
1933
2196
  CollapseIconButton,
1934
2197
  {
1935
- "aria-label": formatMessage({
2198
+ label: formatMessage({
1936
2199
  id: getTranslation("components.Blocks.collapse"),
1937
2200
  defaultMessage: "Collapse"
1938
2201
  }),
@@ -2016,8 +2279,7 @@ const InlineCode = styled.code`
2016
2279
  `;
2017
2280
  const baseCheckIsActive = (editor, name2) => {
2018
2281
  const marks = Editor$1.marks(editor);
2019
- if (!marks)
2020
- return false;
2282
+ if (!marks) return false;
2021
2283
  return Boolean(marks[name2]);
2022
2284
  };
2023
2285
  const baseHandleToggle = (editor, name2) => {
@@ -2183,6 +2445,7 @@ const ExpandIconButton = styled(IconButton)`
2183
2445
  position: absolute;
2184
2446
  bottom: 1.2rem;
2185
2447
  right: 1.2rem;
2448
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2186
2449
  `;
2187
2450
  function useResetKey(value) {
2188
2451
  const slateUpdatesCount = React.useRef(0);
@@ -2271,7 +2534,7 @@ const BlocksEditor = React.forwardRef(
2271
2534
  !isExpandedMode && /* @__PURE__ */ jsx(
2272
2535
  ExpandIconButton,
2273
2536
  {
2274
- "aria-label": formatMessage({
2537
+ label: formatMessage({
2275
2538
  id: getTranslation("components.Blocks.expand"),
2276
2539
  defaultMessage: "Expand"
2277
2540
  }),
@@ -2314,628 +2577,653 @@ const BlocksInput = React.forwardRef(
2314
2577
  }
2315
2578
  );
2316
2579
  const MemoizedBlocksInput = React.memo(BlocksInput);
2317
- const createDefaultForm = (contentType, components = {}) => {
2318
- const traverseSchema = (attributes) => {
2319
- return Object.entries(attributes).reduce((acc, [key, attribute]) => {
2320
- if ("default" in attribute) {
2321
- acc[key] = attribute.default;
2322
- } else if (attribute.type === "component" && attribute.required) {
2323
- const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
2324
- if (attribute.repeatable) {
2325
- acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
2326
- } else {
2327
- acc[key] = defaultComponentForm;
2328
- }
2329
- } else if (attribute.type === "dynamiczone" && attribute.required) {
2330
- acc[key] = [];
2331
- }
2332
- return acc;
2333
- }, {});
2334
- };
2335
- return traverseSchema(contentType.attributes);
2336
- };
2337
2580
  const Initializer = ({ disabled, name: name2, onClick }) => {
2338
2581
  const { formatMessage } = useIntl();
2339
2582
  const field = useField(name2);
2340
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2341
- /* @__PURE__ */ jsx(
2342
- Box,
2343
- {
2344
- tag: "button",
2345
- background: "neutral100",
2346
- borderColor: field.error ? "danger600" : "neutral200",
2347
- hasRadius: true,
2348
- disabled,
2349
- onClick,
2350
- paddingTop: 9,
2351
- paddingBottom: 9,
2352
- type: "button",
2353
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
2354
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(CircleIcon, {}) }),
2355
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
2356
- id: getTranslation("components.empty-repeatable"),
2357
- defaultMessage: "No entry yet. Click on the button below to add one."
2358
- }) }) })
2359
- ] })
2360
- }
2361
- ),
2362
- field.error && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", variant: "pi", children: field.error })
2363
- ] });
2364
- };
2365
- const CircleIcon = styled(PlusCircle)`
2366
- width: 2.4rem;
2367
- height: 2.4rem;
2368
- > circle {
2369
- fill: ${({ theme }) => theme.colors.primary200};
2370
- }
2371
- > path {
2372
- fill: ${({ theme }) => theme.colors.primary600};
2373
- }
2374
- `;
2375
- const NonRepeatableComponent = ({
2376
- attribute,
2377
- name: name2,
2378
- children,
2379
- layout
2380
- }) => {
2381
- const { value } = useField(name2);
2382
- const level = useComponent("NonRepeatableComponent", (state) => state.level);
2383
- const isNested = level > 0;
2384
- return /* @__PURE__ */ jsx(ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsx(
2583
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2385
2584
  Box,
2386
2585
  {
2387
- background: "neutral100",
2388
- paddingLeft: 6,
2389
- paddingRight: 6,
2390
- paddingTop: 6,
2391
- paddingBottom: 6,
2392
- hasRadius: isNested,
2393
- borderColor: isNested ? "neutral200" : void 0,
2394
- children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index) => {
2395
- return /* @__PURE__ */ jsx(Grid$1, { gap: 4, children: row.map(({ size, ...field }) => {
2396
- const completeFieldName = `${name2}.${field.name}`;
2397
- return /* @__PURE__ */ jsx(GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2398
- }) }, index);
2399
- }) })
2586
+ tag: "button",
2587
+ background: disabled ? "neutral150" : "neutral100",
2588
+ borderColor: field.error ? "danger600" : "neutral200",
2589
+ hasRadius: true,
2590
+ disabled,
2591
+ onClick,
2592
+ paddingTop: 9,
2593
+ paddingBottom: 9,
2594
+ type: "button",
2595
+ style: { cursor: disabled ? "not-allowed" : "pointer" },
2596
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
2597
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsx(PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
2598
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
2599
+ Typography,
2600
+ {
2601
+ textColor: disabled ? "neutral600" : "primary600",
2602
+ variant: "pi",
2603
+ fontWeight: "bold",
2604
+ children: formatMessage({
2605
+ id: getTranslation("components.empty-repeatable"),
2606
+ defaultMessage: "No entry yet. Click to add one."
2607
+ })
2608
+ }
2609
+ ) })
2610
+ ] })
2400
2611
  }
2401
2612
  ) });
2402
2613
  };
2403
- const RepeatableComponent = ({
2404
- attribute,
2405
- disabled,
2406
- name: name2,
2407
- mainField,
2614
+ const AddComponentButton = ({
2615
+ hasError,
2616
+ isDisabled,
2617
+ isOpen,
2408
2618
  children,
2409
- layout
2619
+ onClick
2410
2620
  }) => {
2411
- const { toggleNotification } = useNotification();
2412
- const { formatMessage } = useIntl();
2413
- const { search: searchString } = useLocation();
2414
- const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
2415
- const { components } = useDoc();
2416
- const { value = [], error } = useField(name2);
2417
- const addFieldRow = useForm("RepeatableComponent", (state) => state.addFieldRow);
2418
- const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
2419
- const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
2420
- const { max = Infinity } = attribute;
2421
- const [collapseToOpen, setCollapseToOpen] = React.useState("");
2422
- const [liveText, setLiveText] = React.useState("");
2423
- const componentTmpKeyWithFocussedField = React.useMemo(() => {
2424
- if (search.has("field")) {
2425
- const fieldParam = search.get("field");
2426
- if (!fieldParam) {
2427
- return void 0;
2428
- }
2429
- const [, path] = fieldParam.split(`${name2}.`);
2430
- if (getIn(value, path, void 0) !== void 0) {
2431
- const [subpath] = path.split(".");
2432
- return getIn(value, subpath, void 0)?.__temp_key__;
2433
- }
2434
- }
2435
- return void 0;
2436
- }, [search, name2, value]);
2437
- const prevValue = usePrev(value);
2438
- React.useEffect(() => {
2439
- if (prevValue && prevValue.length < value.length) {
2440
- setCollapseToOpen(value[value.length - 1].__temp_key__);
2441
- }
2442
- }, [value, prevValue]);
2443
- React.useEffect(() => {
2444
- if (typeof componentTmpKeyWithFocussedField === "string") {
2445
- setCollapseToOpen(componentTmpKeyWithFocussedField);
2446
- }
2447
- }, [componentTmpKeyWithFocussedField]);
2448
- const toggleCollapses = () => {
2449
- setCollapseToOpen("");
2450
- };
2451
- const handleClick = () => {
2452
- if (value.length < max) {
2453
- const schema = components[attribute.component];
2454
- const form = createDefaultForm(schema, components);
2455
- const data = transformDocument(schema, components)(form);
2456
- addFieldRow(name2, data);
2457
- } else if (value.length >= max) {
2458
- toggleNotification({
2459
- type: "info",
2460
- message: formatMessage({
2461
- id: getTranslation("components.notification.info.maximum-requirement")
2462
- })
2463
- });
2621
+ return /* @__PURE__ */ jsx(
2622
+ StyledButton,
2623
+ {
2624
+ type: "button",
2625
+ onClick,
2626
+ disabled: isDisabled,
2627
+ background: "neutral0",
2628
+ style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2629
+ variant: "tertiary",
2630
+ children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
2631
+ /* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2632
+ /* @__PURE__ */ jsx(
2633
+ Typography,
2634
+ {
2635
+ variant: "pi",
2636
+ fontWeight: "bold",
2637
+ textColor: hasError && !isOpen ? "danger600" : "neutral600",
2638
+ children
2639
+ }
2640
+ )
2641
+ ] })
2464
2642
  }
2465
- };
2466
- const handleMoveComponentField = (newIndex, currentIndex) => {
2467
- setLiveText(
2468
- formatMessage(
2469
- {
2470
- id: getTranslation("dnd.reorder"),
2471
- defaultMessage: "{item}, moved. New position in list: {position}."
2472
- },
2473
- {
2474
- item: `${name2}.${currentIndex}`,
2475
- position: getItemPos(newIndex)
2476
- }
2477
- )
2478
- );
2479
- moveFieldRow(name2, currentIndex, newIndex);
2480
- };
2481
- const handleValueChange = (key) => {
2482
- setCollapseToOpen(key);
2483
- };
2484
- const getItemPos = (index) => `${index + 1} of ${value.length}`;
2485
- const handleCancel = (index) => {
2486
- setLiveText(
2487
- formatMessage(
2488
- {
2489
- id: getTranslation("dnd.cancel-item"),
2490
- defaultMessage: "{item}, dropped. Re-order cancelled."
2491
- },
2492
- {
2493
- item: `${name2}.${index}`
2494
- }
2495
- )
2496
- );
2497
- };
2498
- const handleGrabItem = (index) => {
2499
- setLiveText(
2500
- formatMessage(
2501
- {
2502
- id: getTranslation("dnd.grab-item"),
2503
- defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
2504
- },
2505
- {
2506
- item: `${name2}.${index}`,
2507
- position: getItemPos(index)
2508
- }
2509
- )
2510
- );
2511
- };
2512
- const handleDropItem = (index) => {
2513
- setLiveText(
2514
- formatMessage(
2515
- {
2516
- id: getTranslation("dnd.drop-item"),
2517
- defaultMessage: `{item}, dropped. Final position in list: {position}.`
2518
- },
2519
- {
2520
- item: `${name2}.${index}`,
2521
- position: getItemPos(index)
2522
- }
2523
- )
2524
- );
2525
- };
2526
- const ariaDescriptionId = React.useId();
2527
- const level = useComponent("RepeatableComponent", (state) => state.level);
2528
- if (value.length === 0) {
2529
- return /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleClick });
2643
+ );
2644
+ };
2645
+ const StyledAddIcon = styled(PlusCircle)`
2646
+ height: ${({ theme }) => theme.spaces[6]};
2647
+ width: ${({ theme }) => theme.spaces[6]};
2648
+ transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
2649
+
2650
+ > circle {
2651
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
2530
2652
  }
2531
- return /* @__PURE__ */ jsxs(Box, { hasRadius: true, children: [
2532
- /* @__PURE__ */ jsx(VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
2533
- id: getTranslation("dnd.instructions"),
2534
- defaultMessage: `Press spacebar to grab and re-order`
2535
- }) }),
2536
- /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
2537
- /* @__PURE__ */ jsxs(
2538
- AccordionRoot,
2653
+ > path {
2654
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral500};
2655
+ }
2656
+ `;
2657
+ const StyledButton = styled(Button)`
2658
+ padding-left: ${({ theme }) => theme.spaces[3]};
2659
+ border-radius: 26px;
2660
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2661
+ height: 5rem;
2662
+ `;
2663
+ const ComponentCategory = ({
2664
+ category,
2665
+ components = [],
2666
+ variant = "primary",
2667
+ onAddComponent
2668
+ }) => {
2669
+ const { formatMessage } = useIntl();
2670
+ return /* @__PURE__ */ jsxs(Accordion.Item, { value: category, children: [
2671
+ /* @__PURE__ */ jsx(Accordion.Header, { variant, children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
2672
+ /* @__PURE__ */ jsx(ResponsiveAccordionContent, { children: /* @__PURE__ */ jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
2673
+ ComponentBox,
2539
2674
  {
2540
- $error: error,
2541
- value: collapseToOpen,
2542
- onValueChange: handleValueChange,
2543
- "aria-describedby": ariaDescriptionId,
2544
- children: [
2545
- value.map(({ __temp_key__: key, id }, index) => {
2546
- const nameWithIndex = `${name2}.${index}`;
2547
- return /* @__PURE__ */ jsx(
2548
- ComponentProvider,
2549
- {
2550
- id,
2551
- uid: attribute.component,
2552
- level: level + 1,
2553
- type: "repeatable",
2554
- children: /* @__PURE__ */ jsx(
2555
- Component,
2556
- {
2557
- disabled,
2558
- name: nameWithIndex,
2559
- attribute,
2560
- index,
2561
- mainField,
2562
- onMoveItem: handleMoveComponentField,
2563
- onDeleteComponent: () => {
2564
- removeFieldRow(name2, index);
2565
- toggleCollapses();
2566
- },
2567
- toggleCollapses,
2568
- onCancel: handleCancel,
2569
- onDropItem: handleDropItem,
2570
- onGrabItem: handleGrabItem,
2571
- __temp_key__: key,
2572
- children: layout.map((row, index2) => {
2573
- return /* @__PURE__ */ jsx(Grid$1, { gap: 4, children: row.map(({ size, ...field }) => {
2574
- const completeFieldName = `${nameWithIndex}.${field.name}`;
2575
- return /* @__PURE__ */ jsx(GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2576
- }) }, index2);
2577
- })
2578
- }
2579
- )
2580
- },
2581
- key
2582
- );
2583
- }),
2584
- /* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
2585
- id: getTranslation("containers.EditView.add.new-entry"),
2586
- defaultMessage: "Add an entry"
2587
- }) })
2588
- ]
2589
- }
2590
- )
2675
+ tag: "button",
2676
+ type: "button",
2677
+ background: "neutral100",
2678
+ justifyContent: "center",
2679
+ onClick: onAddComponent(uid),
2680
+ hasRadius: true,
2681
+ height: "8.4rem",
2682
+ shrink: 0,
2683
+ borderColor: "neutral200",
2684
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2685
+ /* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
2686
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2687
+ ] })
2688
+ },
2689
+ uid
2690
+ )) }) })
2591
2691
  ] });
2592
2692
  };
2593
- const AccordionRoot = styled(Accordion.Root)`
2594
- border: 1px solid
2595
- ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
2693
+ const ResponsiveAccordionContent = styled(Accordion.Content)`
2694
+ container-type: inline-size;
2596
2695
  `;
2597
- const TextButtonCustom = styled(TextButton)`
2598
- width: 100%;
2599
- display: flex;
2600
- justify-content: center;
2601
- border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2602
- padding-inline: ${(props) => props.theme.spaces[6]};
2603
- padding-block: ${(props) => props.theme.spaces[3]};
2604
-
2605
- &:not([disabled]) {
2606
- cursor: pointer;
2696
+ const Grid = styled(Box)`
2697
+ display: grid;
2698
+ grid-template-columns: repeat(auto-fill, 100%);
2699
+ grid-gap: ${({ theme }) => theme.spaces[1]};
2607
2700
 
2608
- &:hover {
2609
- background-color: ${(props) => props.theme.colors.primary100};
2610
- }
2701
+ @container (min-width: ${() => RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
2702
+ grid-template-columns: repeat(auto-fill, 14rem);
2611
2703
  }
2704
+ `;
2705
+ const ComponentBox = styled(Flex)`
2706
+ color: ${({ theme }) => theme.colors.neutral600};
2707
+ cursor: pointer;
2612
2708
 
2613
- span {
2614
- font-weight: 600;
2615
- font-size: 1.4rem;
2616
- line-height: 2.4rem;
2709
+ @media (prefers-reduced-motion: no-preference) {
2710
+ transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2617
2711
  }
2618
2712
 
2619
- @media (prefers-reduced-motion: no-preference) {
2620
- transition: background-color 120ms ${(props) => props.theme.easings.easeOutQuad};
2713
+ &:focus,
2714
+ &:hover {
2715
+ border: 1px solid ${({ theme }) => theme.colors.primary200};
2716
+ background: ${({ theme }) => theme.colors.primary100};
2717
+ color: ${({ theme }) => theme.colors.primary600};
2621
2718
  }
2622
2719
  `;
2623
- const Component = ({
2720
+ const ComponentPicker = ({
2721
+ dynamicComponentsByCategory = {},
2722
+ isOpen,
2723
+ onClickAddComponent
2724
+ }) => {
2725
+ const { formatMessage } = useIntl();
2726
+ const handleAddComponentToDz = (componentUid) => () => {
2727
+ onClickAddComponent(componentUid);
2728
+ };
2729
+ if (!isOpen) {
2730
+ return null;
2731
+ }
2732
+ return /* @__PURE__ */ jsxs(
2733
+ Box,
2734
+ {
2735
+ paddingTop: 6,
2736
+ paddingBottom: 6,
2737
+ paddingLeft: 5,
2738
+ paddingRight: 5,
2739
+ background: "neutral0",
2740
+ shadow: "tableShadow",
2741
+ borderColor: "neutral150",
2742
+ hasRadius: true,
2743
+ children: [
2744
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
2745
+ id: getTranslation("components.DynamicZone.ComponentPicker-label"),
2746
+ defaultMessage: "Pick one component"
2747
+ }) }) }),
2748
+ /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index) => /* @__PURE__ */ jsx(
2749
+ ComponentCategory,
2750
+ {
2751
+ category,
2752
+ components,
2753
+ onAddComponent: handleAddComponentToDz,
2754
+ variant: index % 2 === 1 ? "primary" : "secondary"
2755
+ },
2756
+ category
2757
+ )) }) })
2758
+ ]
2759
+ }
2760
+ );
2761
+ };
2762
+ const DynamicComponent = ({
2763
+ componentUid,
2624
2764
  disabled,
2625
2765
  index,
2626
2766
  name: name2,
2627
- mainField = {
2628
- name: "id",
2629
- type: "integer"
2630
- },
2631
- children,
2632
- onDeleteComponent,
2633
- toggleCollapses,
2634
- __temp_key__,
2635
- ...dragProps
2767
+ onRemoveComponentClick,
2768
+ onMoveComponent,
2769
+ onGrabItem,
2770
+ onDropItem,
2771
+ onCancel,
2772
+ dynamicComponentsByCategory = {},
2773
+ onAddComponent,
2774
+ children
2636
2775
  }) => {
2637
2776
  const { formatMessage } = useIntl();
2638
- const displayValue = useForm("RepeatableComponent", (state) => {
2639
- return getIn(state.values, [...name2.split("."), mainField.name]);
2640
- });
2641
- const accordionRef = React.useRef(null);
2642
- const componentKey = name2.split(".").slice(0, -1).join(".");
2777
+ const formValues = useForm("DynamicComponent", (state) => state.values);
2778
+ const {
2779
+ edit: { components }
2780
+ } = useDocLayout();
2781
+ const title = React.useMemo(() => {
2782
+ const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
2783
+ const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
2784
+ const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
2785
+ const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
2786
+ return mainValue;
2787
+ }, [componentUid, components, formValues, name2, index]);
2788
+ const { icon, displayName } = React.useMemo(() => {
2789
+ const [category] = componentUid.split(".");
2790
+ const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
2791
+ (component) => component.uid === componentUid
2792
+ ) ?? { icon: null, displayName: null };
2793
+ return { icon: icon2, displayName: displayName2 };
2794
+ }, [componentUid, dynamicComponentsByCategory]);
2643
2795
  const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
2644
- type: `${ItemTypes.COMPONENT}_${componentKey}`,
2796
+ type: `${ItemTypes.DYNAMIC_ZONE}_${name2}`,
2645
2797
  index,
2646
2798
  item: {
2647
2799
  index,
2648
- displayedValue: displayValue
2649
- },
2650
- onStart() {
2651
- toggleCollapses();
2800
+ displayedValue: `${displayName} ${title}`,
2801
+ icon
2652
2802
  },
2653
- ...dragProps
2803
+ onMoveItem: onMoveComponent,
2804
+ onDropItem,
2805
+ onGrabItem,
2806
+ onCancel
2654
2807
  });
2655
2808
  React.useEffect(() => {
2656
2809
  dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
2657
2810
  }, [dragPreviewRef, index]);
2658
- const composedAccordionRefs = useComposedRefs(accordionRef, dragRef);
2659
- const composedBoxRefs = useComposedRefs(
2660
- boxRef,
2661
- dropRef
2662
- );
2663
- return /* @__PURE__ */ jsx(Fragment, { children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsxs(Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
2664
- /* @__PURE__ */ jsxs(Accordion.Header, { children: [
2665
- /* @__PURE__ */ jsx(Accordion.Trigger, { children: displayValue }),
2666
- /* @__PURE__ */ jsxs(Accordion.Actions, { children: [
2667
- /* @__PURE__ */ jsx(
2668
- IconButton,
2811
+ const accordionValue = React.useId();
2812
+ const { value = [], rawError } = useField(`${name2}.${index}`);
2813
+ const [collapseToOpen, setCollapseToOpen] = React.useState("");
2814
+ React.useEffect(() => {
2815
+ if (rawError && value) {
2816
+ setCollapseToOpen(accordionValue);
2817
+ }
2818
+ }, [rawError, value, accordionValue]);
2819
+ const composedBoxRefs = useComposedRefs(boxRef, dropRef);
2820
+ const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
2821
+ /* @__PURE__ */ jsx(
2822
+ IconButton,
2823
+ {
2824
+ variant: "ghost",
2825
+ label: formatMessage(
2669
2826
  {
2670
- borderWidth: 0,
2671
- onClick: onDeleteComponent,
2672
- label: formatMessage({
2673
- id: getTranslation("containers.Edit.delete"),
2674
- defaultMessage: "Delete"
2675
- }),
2676
- children: /* @__PURE__ */ jsx(Trash, {})
2677
- }
2827
+ id: getTranslation("components.DynamicZone.delete-label"),
2828
+ defaultMessage: "Delete {name}"
2829
+ },
2830
+ { name: title }
2678
2831
  ),
2832
+ onClick: onRemoveComponentClick,
2833
+ children: /* @__PURE__ */ jsx(Trash, {})
2834
+ }
2835
+ ),
2836
+ /* @__PURE__ */ jsx(
2837
+ IconButton,
2838
+ {
2839
+ variant: "ghost",
2840
+ onClick: (e) => e.stopPropagation(),
2841
+ "data-handler-id": handlerId,
2842
+ ref: dragRef,
2843
+ label: formatMessage({
2844
+ id: getTranslation("components.DragHandle-label"),
2845
+ defaultMessage: "Drag"
2846
+ }),
2847
+ onKeyDown: handleKeyDown,
2848
+ children: /* @__PURE__ */ jsx(Drag, {})
2849
+ }
2850
+ ),
2851
+ /* @__PURE__ */ jsxs(Menu.Root, { children: [
2852
+ /* @__PURE__ */ jsx(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 0, paddingRight: 0, children: /* @__PURE__ */ jsx(
2853
+ IconButton,
2854
+ {
2855
+ variant: "ghost",
2856
+ label: formatMessage({
2857
+ id: getTranslation("components.DynamicZone.more-actions"),
2858
+ defaultMessage: "More actions"
2859
+ }),
2860
+ tag: "span",
2861
+ children: /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false })
2862
+ }
2863
+ ) }),
2864
+ /* @__PURE__ */ jsxs(Menu.Content, { children: [
2865
+ /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
2866
+ /* @__PURE__ */ jsx(Menu.SubTrigger, { children: formatMessage({
2867
+ id: getTranslation("components.DynamicZone.add-item-above"),
2868
+ defaultMessage: "Add component above"
2869
+ }) }),
2870
+ /* @__PURE__ */ jsx(Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
2871
+ /* @__PURE__ */ jsx(Menu.Label, { children: category }),
2872
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsx(MenuItem, { onSelect: () => onAddComponent(uid, index), children: displayName2 }, componentUid))
2873
+ ] }, category)) })
2874
+ ] }),
2875
+ /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
2876
+ /* @__PURE__ */ jsx(Menu.SubTrigger, { children: formatMessage({
2877
+ id: getTranslation("components.DynamicZone.add-item-below"),
2878
+ defaultMessage: "Add component below"
2879
+ }) }),
2880
+ /* @__PURE__ */ jsx(Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
2881
+ /* @__PURE__ */ jsx(Menu.Label, { children: category }),
2882
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsx(MenuItem, { onSelect: () => onAddComponent(uid, index + 1), children: displayName2 }, componentUid))
2883
+ ] }, category)) })
2884
+ ] })
2885
+ ] })
2886
+ ] })
2887
+ ] });
2888
+ const accordionTitle = title ? `${displayName} ${title}` : displayName;
2889
+ return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
2890
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
2891
+ /* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsx(Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
2892
+ /* @__PURE__ */ jsxs(Accordion.Header, { children: [
2679
2893
  /* @__PURE__ */ jsx(
2680
- IconButton,
2894
+ Accordion.Trigger,
2681
2895
  {
2682
- ref: composedAccordionRefs,
2683
- borderWidth: 0,
2684
- onClick: (e) => e.stopPropagation(),
2685
- "data-handler-id": handlerId,
2686
- label: formatMessage({
2687
- id: getTranslation("components.DragHandle-label"),
2688
- defaultMessage: "Drag"
2689
- }),
2690
- onKeyDown: handleKeyDown,
2691
- children: /* @__PURE__ */ jsx(Drag, {})
2896
+ icon: icon && COMPONENT_ICONS[icon] ? COMPONENT_ICONS[icon] : COMPONENT_ICONS.dashboard,
2897
+ children: accordionTitle
2692
2898
  }
2693
- )
2694
- ] })
2695
- ] }),
2696
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(
2697
- Flex,
2698
- {
2699
- direction: "column",
2700
- alignItems: "stretch",
2701
- background: "neutral100",
2702
- padding: 6,
2703
- gap: 6,
2704
- children
2705
- }
2706
- ) })
2707
- ] }) });
2708
- };
2709
- const Preview$1 = () => {
2710
- return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
2899
+ ),
2900
+ /* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
2901
+ ] }),
2902
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsx(
2903
+ Grid$1.Item,
2904
+ {
2905
+ col: 12,
2906
+ s: 12,
2907
+ xs: 12,
2908
+ direction: "column",
2909
+ alignItems: "stretch",
2910
+ children: /* @__PURE__ */ jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
2911
+ const fieldName = `${name2}.${index}.${field.name}`;
2912
+ const fieldWithTranslatedLabel = {
2913
+ ...field,
2914
+ label: formatMessage({
2915
+ id: `content-manager.components.${componentUid}.${field.name}`,
2916
+ defaultMessage: field.label
2917
+ })
2918
+ };
2919
+ return /* @__PURE__ */ jsx(
2920
+ ResponsiveGridItem,
2921
+ {
2922
+ col: size,
2923
+ s: 12,
2924
+ xs: 12,
2925
+ direction: "column",
2926
+ alignItems: "stretch",
2927
+ children: children ? children({ ...fieldWithTranslatedLabel, name: fieldName }) : /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
2928
+ },
2929
+ fieldName
2930
+ );
2931
+ }) })
2932
+ },
2933
+ rowInd
2934
+ )) }) }) }) })
2935
+ ] }) }) })
2936
+ ] });
2711
2937
  };
2712
- const StyledSpan = styled(Box)`
2938
+ const StyledBox = styled(Box)`
2939
+ > div:first-child {
2940
+ box-shadow: ${({ theme }) => theme.shadows.tableShadow};
2941
+ }
2942
+ `;
2943
+ const AccordionContentRadius = styled(Box)`
2944
+ border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
2945
+ `;
2946
+ const Rectangle = styled(Box)`
2947
+ width: ${({ theme }) => theme.spaces[2]};
2948
+ height: ${({ theme }) => theme.spaces[4]};
2949
+ `;
2950
+ const Preview$1 = styled.span`
2713
2951
  display: block;
2952
+ background-color: ${({ theme }) => theme.colors.primary100};
2714
2953
  outline: 1px dashed ${({ theme }) => theme.colors.primary500};
2715
2954
  outline-offset: -1px;
2955
+ padding: ${({ theme }) => theme.spaces[6]};
2716
2956
  `;
2717
- const ComponentInput = ({
2957
+ const ComponentContainer = styled(Box)`
2958
+ list-style: none;
2959
+ padding: 0;
2960
+ margin: 0;
2961
+ `;
2962
+ const DynamicZoneLabel = ({
2963
+ hint,
2718
2964
  label,
2719
- required,
2720
- name: name2,
2721
- attribute,
2722
- disabled,
2723
2965
  labelAction,
2724
- ...props
2725
- }) => {
2726
- const { formatMessage } = useIntl();
2727
- const field = useField(name2);
2728
- const showResetComponent = !attribute.repeatable && field.value && !disabled;
2729
- const { components } = useDoc();
2730
- const handleInitialisationClick = () => {
2731
- const schema = components[attribute.component];
2732
- const form = createDefaultForm(schema, components);
2733
- const data = transformDocument(schema, components)(form);
2734
- field.onChange(name2, data);
2735
- };
2736
- return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
2737
- /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
2738
- /* @__PURE__ */ jsxs(Field.Label, { action: labelAction, children: [
2739
- label,
2740
- attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
2741
- " (",
2742
- Array.isArray(field.value) ? field.value.length : 0,
2743
- ")"
2744
- ] })
2745
- ] }),
2746
- showResetComponent && /* @__PURE__ */ jsx(
2747
- IconButton,
2748
- {
2749
- label: formatMessage({
2750
- id: getTranslation("components.reset-entry"),
2751
- defaultMessage: "Reset Entry"
2752
- }),
2753
- borderWidth: 0,
2754
- onClick: () => {
2755
- field.onChange(name2, null);
2756
- },
2757
- children: /* @__PURE__ */ jsx(Trash, {})
2758
- }
2759
- )
2760
- ] }),
2761
- !attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
2762
- !attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
2763
- attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
2764
- /* @__PURE__ */ jsx(Field.Error, {})
2765
- ] });
2766
- };
2767
- const MemoizedComponentInput = React.memo(ComponentInput);
2768
- const AddComponentButton = ({
2769
- hasError,
2770
- isDisabled,
2771
- isOpen,
2772
- children,
2773
- onClick
2966
+ name: name2,
2967
+ numberOfComponents = 0,
2968
+ required
2774
2969
  }) => {
2775
- return /* @__PURE__ */ jsx(
2776
- StyledButton,
2970
+ return /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
2971
+ Box,
2777
2972
  {
2778
- type: "button",
2779
- onClick,
2780
- disabled: isDisabled,
2781
- background: "neutral0",
2782
2973
  paddingTop: 3,
2783
2974
  paddingBottom: 3,
2784
- paddingLeft: 4,
2785
2975
  paddingRight: 4,
2786
- style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2787
- children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
2788
- /* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2789
- /* @__PURE__ */ jsx(
2790
- AddComponentTitle,
2791
- {
2792
- variant: "pi",
2793
- fontWeight: "bold",
2794
- textColor: hasError && !isOpen ? "danger600" : "neutral500",
2795
- children
2796
- }
2797
- )
2976
+ paddingLeft: 4,
2977
+ borderRadius: "26px",
2978
+ background: "neutral0",
2979
+ shadow: "filterShadow",
2980
+ color: "neutral500",
2981
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", justifyContent: "center", children: [
2982
+ /* @__PURE__ */ jsxs(Flex, { maxWidth: "35.6rem", children: [
2983
+ /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
2984
+ label || name2,
2985
+ " "
2986
+ ] }),
2987
+ /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
2988
+ "(",
2989
+ numberOfComponents,
2990
+ ")"
2991
+ ] }),
2992
+ required && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: "*" }),
2993
+ labelAction && /* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: labelAction })
2994
+ ] }),
2995
+ hint && /* @__PURE__ */ jsx(Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
2798
2996
  ] })
2799
2997
  }
2800
- );
2998
+ ) });
2801
2999
  };
2802
- const StyledAddIcon = styled(PlusCircle)`
2803
- height: ${({ theme }) => theme.spaces[6]};
2804
- width: ${({ theme }) => theme.spaces[6]};
2805
- transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
2806
-
2807
- > circle {
2808
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
2809
- }
2810
- > path {
2811
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
3000
+ const [DynamicZoneProvider, useDynamicZone] = createContext(
3001
+ "DynamicZone",
3002
+ {
3003
+ isInDynamicZone: false
2812
3004
  }
2813
- `;
2814
- const AddComponentTitle = styled(Typography)``;
2815
- const StyledButton = styled(BaseButton)`
2816
- border-radius: 26px;
2817
- border-color: ${({ theme }) => theme.colors.neutral150};
2818
- box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2819
-
2820
- &:hover {
2821
- ${AddComponentTitle} {
2822
- color: ${({ theme }) => theme.colors.primary600};
2823
- }
2824
-
2825
- ${StyledAddIcon} {
2826
- > circle {
2827
- fill: ${({ theme }) => theme.colors.primary600};
2828
- }
2829
- > path {
2830
- fill: ${({ theme }) => theme.colors.neutral100};
3005
+ );
3006
+ const DynamicZone = ({
3007
+ attribute,
3008
+ disabled: disabledProp,
3009
+ hint,
3010
+ label,
3011
+ labelAction,
3012
+ name: name2,
3013
+ required = false,
3014
+ children
3015
+ }) => {
3016
+ const { max = Infinity, min = -Infinity } = attribute ?? {};
3017
+ const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
3018
+ const [liveText, setLiveText] = React.useState("");
3019
+ const { components, isLoading } = useDoc();
3020
+ const disabled = disabledProp || isLoading;
3021
+ const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
3022
+ "DynamicZone",
3023
+ ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
3024
+ addFieldRow: addFieldRow2,
3025
+ removeFieldRow: removeFieldRow2,
3026
+ moveFieldRow: moveFieldRow2
3027
+ })
3028
+ );
3029
+ const { value = [], error } = useField(name2);
3030
+ const dynamicComponentsByCategory = React.useMemo(() => {
3031
+ return attribute.components.reduce((acc, componentUid) => {
3032
+ const { category, info } = components[componentUid] ?? { info: {} };
3033
+ const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
3034
+ if (!acc[category]) {
3035
+ acc[category] = [];
2831
3036
  }
3037
+ acc[category] = [...acc[category], component];
3038
+ return acc;
3039
+ }, {});
3040
+ }, [attribute.components, components]);
3041
+ const { formatMessage } = useIntl();
3042
+ const { toggleNotification } = useNotification();
3043
+ const dynamicDisplayedComponentsLength = value.length;
3044
+ const handleAddComponent = (uid, position) => {
3045
+ setAddComponentIsOpen(false);
3046
+ const schema = components[uid];
3047
+ const form = createDefaultForm(schema, components);
3048
+ const transformations = pipe$1(transformDocument(schema, components), (data2) => ({
3049
+ ...data2,
3050
+ __component: uid
3051
+ }));
3052
+ const data = transformations(form);
3053
+ addFieldRow(name2, data, position);
3054
+ };
3055
+ const handleClickOpenPicker = () => {
3056
+ if (dynamicDisplayedComponentsLength < max) {
3057
+ setAddComponentIsOpen((prev) => !prev);
3058
+ } else {
3059
+ toggleNotification({
3060
+ type: "info",
3061
+ message: formatMessage({
3062
+ id: getTranslation("components.notification.info.maximum-requirement")
3063
+ })
3064
+ });
3065
+ }
3066
+ };
3067
+ const handleMoveComponent = (newIndex, currentIndex) => {
3068
+ setLiveText(
3069
+ formatMessage(
3070
+ {
3071
+ id: getTranslation("dnd.reorder"),
3072
+ defaultMessage: "{item}, moved. New position in list: {position}."
3073
+ },
3074
+ {
3075
+ item: `${name2}.${currentIndex}`,
3076
+ position: getItemPos(newIndex)
3077
+ }
3078
+ )
3079
+ );
3080
+ moveFieldRow(name2, currentIndex, newIndex);
3081
+ };
3082
+ const getItemPos = (index) => `${index + 1} of ${value.length}`;
3083
+ const handleCancel = (index) => {
3084
+ setLiveText(
3085
+ formatMessage(
3086
+ {
3087
+ id: getTranslation("dnd.cancel-item"),
3088
+ defaultMessage: "{item}, dropped. Re-order cancelled."
3089
+ },
3090
+ {
3091
+ item: `${name2}.${index}`
3092
+ }
3093
+ )
3094
+ );
3095
+ };
3096
+ const handleGrabItem = (index) => {
3097
+ setLiveText(
3098
+ formatMessage(
3099
+ {
3100
+ id: getTranslation("dnd.grab-item"),
3101
+ defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
3102
+ },
3103
+ {
3104
+ item: `${name2}.${index}`,
3105
+ position: getItemPos(index)
3106
+ }
3107
+ )
3108
+ );
3109
+ };
3110
+ const handleDropItem = (index) => {
3111
+ setLiveText(
3112
+ formatMessage(
3113
+ {
3114
+ id: getTranslation("dnd.drop-item"),
3115
+ defaultMessage: `{item}, dropped. Final position in list: {position}.`
3116
+ },
3117
+ {
3118
+ item: `${name2}.${index}`,
3119
+ position: getItemPos(index)
3120
+ }
3121
+ )
3122
+ );
3123
+ };
3124
+ const handleRemoveComponent = (name22, currentIndex) => () => {
3125
+ removeFieldRow(name22, currentIndex);
3126
+ };
3127
+ const hasError = error !== void 0;
3128
+ const renderButtonLabel = () => {
3129
+ if (addComponentIsOpen) {
3130
+ return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
2832
3131
  }
2833
- }
2834
- &:active {
2835
- ${AddComponentTitle} {
2836
- color: ${({ theme }) => theme.colors.primary600};
3132
+ if (hasError && dynamicDisplayedComponentsLength > max) {
3133
+ return formatMessage(
3134
+ {
3135
+ id: getTranslation(`components.DynamicZone.extra-components`),
3136
+ defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
3137
+ },
3138
+ {
3139
+ number: dynamicDisplayedComponentsLength - max
3140
+ }
3141
+ );
2837
3142
  }
2838
- ${StyledAddIcon} {
2839
- > circle {
2840
- fill: ${({ theme }) => theme.colors.primary600};
2841
- }
2842
- > path {
2843
- fill: ${({ theme }) => theme.colors.neutral100};
2844
- }
3143
+ if (hasError && dynamicDisplayedComponentsLength < min) {
3144
+ return formatMessage(
3145
+ {
3146
+ id: getTranslation(`components.DynamicZone.missing-components`),
3147
+ defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
3148
+ },
3149
+ { number: min - dynamicDisplayedComponentsLength }
3150
+ );
2845
3151
  }
2846
- }
2847
- `;
2848
- const ComponentCategory = ({
2849
- category,
2850
- components = [],
2851
- variant = "primary",
2852
- onAddComponent
2853
- }) => {
2854
- const { formatMessage } = useIntl();
2855
- return /* @__PURE__ */ jsxs(Accordion.Item, { value: category, children: [
2856
- /* @__PURE__ */ jsx(Accordion.Header, { variant, children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
2857
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
2858
- ComponentBox,
3152
+ return formatMessage(
2859
3153
  {
2860
- tag: "button",
2861
- type: "button",
2862
- background: "neutral100",
2863
- justifyContent: "center",
2864
- onClick: onAddComponent(uid),
2865
- hasRadius: true,
2866
- height: "8.4rem",
2867
- shrink: 0,
2868
- borderColor: "neutral200",
2869
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2870
- /* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
2871
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2872
- ] })
3154
+ id: getTranslation("components.DynamicZone.add-component"),
3155
+ defaultMessage: "Add a component to {componentName}"
2873
3156
  },
2874
- uid
2875
- )) }) })
2876
- ] });
2877
- };
2878
- const Grid = styled(Box)`
2879
- display: grid;
2880
- grid-template-columns: repeat(auto-fit, 14rem);
2881
- grid-gap: ${({ theme }) => theme.spaces[1]};
2882
- `;
2883
- const ComponentBox = styled(Flex)`
2884
- color: ${({ theme }) => theme.colors.neutral600};
2885
- cursor: pointer;
2886
-
2887
- @media (prefers-reduced-motion: no-preference) {
2888
- transition: color 120ms ${(props) => props.theme.easings.easeOutQuad};
2889
- }
2890
-
2891
- &:focus,
2892
- &:hover {
2893
- border: 1px solid ${({ theme }) => theme.colors.primary200};
2894
- background: ${({ theme }) => theme.colors.primary100};
2895
- color: ${({ theme }) => theme.colors.primary600};
2896
- }
2897
- `;
2898
- const ComponentPicker = ({
2899
- dynamicComponentsByCategory = {},
2900
- isOpen,
2901
- onClickAddComponent
2902
- }) => {
2903
- const { formatMessage } = useIntl();
2904
- const handleAddComponentToDz = (componentUid) => () => {
2905
- onClickAddComponent(componentUid);
3157
+ { componentName: label || name2 }
3158
+ );
2906
3159
  };
2907
- if (!isOpen) {
2908
- return null;
2909
- }
2910
- return /* @__PURE__ */ jsxs(
2911
- Box,
2912
- {
2913
- paddingTop: 6,
2914
- paddingBottom: 6,
2915
- paddingLeft: 5,
2916
- paddingRight: 5,
2917
- background: "neutral0",
2918
- shadow: "tableShadow",
2919
- borderColor: "neutral150",
2920
- hasRadius: true,
2921
- children: [
2922
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
2923
- id: getTranslation("components.DynamicZone.ComponentPicker-label"),
2924
- defaultMessage: "Pick one component"
2925
- }) }) }),
2926
- /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index) => /* @__PURE__ */ jsx(
2927
- ComponentCategory,
2928
- {
2929
- category,
2930
- components,
2931
- onAddComponent: handleAddComponentToDz,
2932
- variant: index % 2 === 1 ? "primary" : "secondary"
2933
- },
2934
- category
2935
- )) }) })
2936
- ]
2937
- }
2938
- );
3160
+ const level = useComponent("DynamicZone", (state) => state.level);
3161
+ const ariaDescriptionId = React.useId();
3162
+ return /* @__PURE__ */ jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3163
+ dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxs(Box, { children: [
3164
+ /* @__PURE__ */ jsx(
3165
+ DynamicZoneLabel,
3166
+ {
3167
+ hint,
3168
+ label,
3169
+ labelAction,
3170
+ name: name2,
3171
+ numberOfComponents: dynamicDisplayedComponentsLength,
3172
+ required
3173
+ }
3174
+ ),
3175
+ /* @__PURE__ */ jsx(VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
3176
+ id: getTranslation("dnd.instructions"),
3177
+ defaultMessage: `Press spacebar to grab and re-order`
3178
+ }) }),
3179
+ /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
3180
+ /* @__PURE__ */ jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index) => /* @__PURE__ */ jsx(
3181
+ ComponentProvider,
3182
+ {
3183
+ level: level + 1,
3184
+ uid: field.__component,
3185
+ id: field.id,
3186
+ type: "dynamiczone",
3187
+ children: /* @__PURE__ */ jsx(
3188
+ DynamicComponent,
3189
+ {
3190
+ disabled,
3191
+ name: name2,
3192
+ index,
3193
+ componentUid: field.__component,
3194
+ onMoveComponent: handleMoveComponent,
3195
+ onRemoveComponentClick: handleRemoveComponent(name2, index),
3196
+ onCancel: handleCancel,
3197
+ onDropItem: handleDropItem,
3198
+ onGrabItem: handleGrabItem,
3199
+ onAddComponent: handleAddComponent,
3200
+ dynamicComponentsByCategory,
3201
+ children
3202
+ }
3203
+ )
3204
+ },
3205
+ field.__temp_key__
3206
+ )) })
3207
+ ] }),
3208
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
3209
+ AddComponentButton,
3210
+ {
3211
+ hasError,
3212
+ isDisabled: disabled,
3213
+ isOpen: addComponentIsOpen,
3214
+ onClick: handleClickOpenPicker,
3215
+ children: renderButtonLabel()
3216
+ }
3217
+ ) }),
3218
+ /* @__PURE__ */ jsx(
3219
+ ComponentPicker,
3220
+ {
3221
+ dynamicComponentsByCategory,
3222
+ isOpen: addComponentIsOpen,
3223
+ onClickAddComponent: handleAddComponent
3224
+ }
3225
+ )
3226
+ ] }) });
2939
3227
  };
2940
3228
  const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
2941
3229
  const { formatMessage } = useIntl();
@@ -2958,18 +3246,6 @@ const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
2958
3246
  /* @__PURE__ */ jsx(Field.Hint, {})
2959
3247
  ] });
2960
3248
  };
2961
- function useDebounce(value, delay) {
2962
- const [debouncedValue, setDebouncedValue] = useState(value);
2963
- useEffect(() => {
2964
- const handler = setTimeout(() => {
2965
- setDebouncedValue(value);
2966
- }, delay);
2967
- return () => {
2968
- clearTimeout(handler);
2969
- };
2970
- }, [value, delay]);
2971
- return debouncedValue;
2972
- }
2973
3249
  const uidApi = contentManagerApi.injectEndpoints({
2974
3250
  endpoints: (builder) => ({
2975
3251
  getDefaultUID: builder.query({
@@ -3004,7 +3280,10 @@ const uidApi = contentManagerApi.injectEndpoints({
3004
3280
  config: {
3005
3281
  params
3006
3282
  }
3007
- })
3283
+ }),
3284
+ providesTags: (_res, _error, params) => [
3285
+ { type: "UidAvailability", id: params.contentTypeUID }
3286
+ ]
3008
3287
  })
3009
3288
  })
3010
3289
  });
@@ -3016,8 +3295,10 @@ const UIDInput = React.forwardRef(
3016
3295
  const allFormValues = useForm("InputUID", (form) => form.values);
3017
3296
  const [availability, setAvailability] = React.useState();
3018
3297
  const [showRegenerate, setShowRegenerate] = React.useState(false);
3298
+ const isCloning = useMatch(CLONE_PATH) !== null;
3019
3299
  const field = useField(name2);
3020
3300
  const debouncedValue = useDebounce(field.value, 300);
3301
+ const hasChanged = debouncedValue !== field.initialValue;
3021
3302
  const { toggleNotification } = useNotification();
3022
3303
  const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
3023
3304
  const { formatMessage } = useIntl();
@@ -3093,8 +3374,9 @@ const UIDInput = React.forwardRef(
3093
3374
  params
3094
3375
  },
3095
3376
  {
3377
+ // Don't check availability if the value is empty or wasn't changed
3096
3378
  skip: !Boolean(
3097
- debouncedValue !== field.initialValue && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3379
+ (hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3098
3380
  )
3099
3381
  }
3100
3382
  );
@@ -3123,6 +3405,7 @@ const UIDInput = React.forwardRef(
3123
3405
  const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
3124
3406
  const fieldRef = useFocusInputField(name2);
3125
3407
  const composedRefs = useComposedRefs(ref, fieldRef);
3408
+ const shouldShowAvailability = (hasChanged || isCloning) && debouncedValue != null && availability && !showRegenerate;
3126
3409
  return /* @__PURE__ */ jsxs(Field.Root, { hint, name: name2, error: field.error, required, children: [
3127
3410
  /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
3128
3411
  /* @__PURE__ */ jsx(
@@ -3131,7 +3414,7 @@ const UIDInput = React.forwardRef(
3131
3414
  ref: composedRefs,
3132
3415
  disabled: props.disabled,
3133
3416
  endAction: /* @__PURE__ */ jsxs(Flex, { position: "relative", gap: 1, children: [
3134
- availability && !showRegenerate && /* @__PURE__ */ jsxs(
3417
+ shouldShowAvailability && /* @__PURE__ */ jsxs(
3135
3418
  TextValidation,
3136
3419
  {
3137
3420
  alignItems: "center",
@@ -3420,8 +3703,7 @@ const Wrapper = styled.div`
3420
3703
  `;
3421
3704
  var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/;
3422
3705
  function newlineAndIndentContinueMarkdownList(cm) {
3423
- if (cm.getOption("disableInput"))
3424
- return CodeMirror.Pass;
3706
+ if (cm.getOption("disableInput")) return CodeMirror.Pass;
3425
3707
  var ranges = cm.listSelections(), replacements = [];
3426
3708
  for (var i = 0; i < ranges.length; i++) {
3427
3709
  var pos = ranges[i].head;
@@ -3455,8 +3737,7 @@ function newlineAndIndentContinueMarkdownList(cm) {
3455
3737
  var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
3456
3738
  var bullet = numbered ? parseInt(match[3], 10) + 1 + match[4] : match[2].replace("x", " ");
3457
3739
  replacements[i] = "\n" + indent + bullet + after;
3458
- if (numbered)
3459
- incrementRemainingMarkdownListNumbers(cm, pos);
3740
+ if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
3460
3741
  }
3461
3742
  }
3462
3743
  cm.replaceSelections(replacements);
@@ -3474,10 +3755,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3474
3755
  var newNumber = parseInt(startItem[3], 10) + lookAhead - skipCount;
3475
3756
  var nextNumber = parseInt(nextItem[3], 10), itemNumber = nextNumber;
3476
3757
  if (startIndent === nextIndent && !isNaN(nextNumber)) {
3477
- if (newNumber === nextNumber)
3478
- itemNumber = nextNumber + 1;
3479
- if (newNumber > nextNumber)
3480
- itemNumber = newNumber + 1;
3758
+ if (newNumber === nextNumber) itemNumber = nextNumber + 1;
3759
+ if (newNumber > nextNumber) itemNumber = newNumber + 1;
3481
3760
  cm.replaceRange(
3482
3761
  nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
3483
3762
  {
@@ -3490,10 +3769,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3490
3769
  }
3491
3770
  );
3492
3771
  } else {
3493
- if (startIndent.length > nextIndent.length)
3494
- return;
3495
- if (startIndent.length < nextIndent.length && lookAhead === 1)
3496
- return;
3772
+ if (startIndent.length > nextIndent.length) return;
3773
+ if (startIndent.length < nextIndent.length && lookAhead === 1) return;
3497
3774
  skipCount += 1;
3498
3775
  }
3499
3776
  }
@@ -3965,7 +4242,7 @@ const EditorLayout = ({
3965
4242
  justifyContent: "flex-end",
3966
4243
  shrink: 0,
3967
4244
  width: "100%",
3968
- children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, children: [
4245
+ children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, variant: "tertiary", size: "M", children: [
3969
4246
  /* @__PURE__ */ jsx(Typography, { children: formatMessage({
3970
4247
  id: "components.Wysiwyg.collapse",
3971
4248
  defaultMessage: "Collapse"
@@ -3983,12 +4260,14 @@ const EditorLayout = ({
3983
4260
  ) }) });
3984
4261
  }
3985
4262
  return /* @__PURE__ */ jsx(
3986
- Box,
4263
+ Flex,
3987
4264
  {
3988
4265
  borderColor: error ? "danger600" : "neutral200",
3989
4266
  borderStyle: "solid",
3990
4267
  borderWidth: "1px",
3991
4268
  hasRadius: true,
4269
+ direction: "column",
4270
+ alignItems: "stretch",
3992
4271
  children
3993
4272
  }
3994
4273
  );
@@ -3999,11 +4278,19 @@ const ExpandWrapper = styled(Flex)`
3999
4278
  const BoxWithBorder = styled(Box)`
4000
4279
  border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
4001
4280
  `;
4002
- const ExpandButton$1 = styled(BaseButton)`
4281
+ const ExpandButton$1 = styled(Button)`
4003
4282
  background-color: transparent;
4004
4283
  border: none;
4005
4284
  align-items: center;
4006
4285
 
4286
+ & > span {
4287
+ display: flex;
4288
+ justify-content: space-between;
4289
+ align-items: center;
4290
+ width: 100%;
4291
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4292
+ }
4293
+
4007
4294
  svg {
4008
4295
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4009
4296
 
@@ -4270,42 +4557,28 @@ const quoteAndCodeHandler = (editor, markdownType) => {
4270
4557
  insertWithoutTextToEdit(editor, markdownType, line, contentLength);
4271
4558
  }
4272
4559
  };
4273
- const CustomIconButton = styled(IconButton)`
4274
- padding: ${({ theme }) => theme.spaces[2]};
4275
- /* Trick to prevent the outline from overflowing because of the general outline-offset */
4276
- outline-offset: -2px !important;
4277
-
4278
- svg {
4279
- width: 1.8rem;
4280
- height: 1.8rem;
4281
- }
4282
- `;
4283
- const CustomLinkIconButton = styled(CustomIconButton)`
4284
- svg {
4285
- width: 0.8rem;
4286
- height: 0.8rem;
4287
- }
4288
- `;
4289
4560
  const MainButtons = styled(IconButtonGroup)`
4290
4561
  margin-left: ${({ theme }) => theme.spaces[4]};
4291
4562
  `;
4292
- const MoreButton = styled(IconButton)`
4293
- margin: ${({ theme }) => `0 ${theme.spaces[2]}`};
4294
- padding: ${({ theme }) => theme.spaces[2]};
4295
-
4296
- svg {
4297
- width: 1.8rem;
4298
- height: 1.8rem;
4299
- }
4563
+ const MoreButton = styled(IconButton)`
4564
+ margin: ${({ theme }) => `0 ${theme.spaces[2]}`};
4300
4565
  `;
4301
4566
  const IconButtonGroupMargin = styled(IconButtonGroup)`
4302
4567
  margin-right: ${({ theme }) => `${theme.spaces[2]}`};
4303
4568
  `;
4304
- const ExpandButton = styled(BaseButton)`
4569
+ const ExpandButton = styled(Button)`
4305
4570
  background-color: transparent;
4306
4571
  border: none;
4307
4572
  align-items: center;
4308
4573
 
4574
+ & > span {
4575
+ display: flex;
4576
+ justify-content: space-between;
4577
+ align-items: center;
4578
+ width: 100%;
4579
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4580
+ }
4581
+
4309
4582
  svg {
4310
4583
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4311
4584
  path {
@@ -4317,8 +4590,8 @@ const ExpandButton = styled(BaseButton)`
4317
4590
  `;
4318
4591
  const WysiwygFooter = ({ onToggleExpand }) => {
4319
4592
  const { formatMessage } = useIntl();
4320
- return /* @__PURE__ */ jsx(Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, children: [
4321
- /* @__PURE__ */ jsx(Typography, { children: formatMessage({
4593
+ return /* @__PURE__ */ jsx(Box, { padding: 2, background: "neutral100", borderRadius: `0 0 0.4rem 0.4rem`, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "flex-end", alignItems: "flex-end", children: /* @__PURE__ */ jsxs(ExpandButton, { id: "expand", onClick: onToggleExpand, variant: "tertiary", size: "M", children: [
4594
+ /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
4322
4595
  id: "components.WysiwygBottomControls.fullscreen",
4323
4596
  defaultMessage: "Expand"
4324
4597
  }) }),
@@ -4340,7 +4613,7 @@ const WysiwygNav = ({
4340
4613
  id: "components.Wysiwyg.selectOptions.title",
4341
4614
  defaultMessage: "Add a title"
4342
4615
  });
4343
- const buttonMoreRef = React.useRef(null);
4616
+ React.useRef(null);
4344
4617
  const handleTogglePopover = () => {
4345
4618
  setVisiblePopover((prev) => !prev);
4346
4619
  };
@@ -4354,18 +4627,27 @@ const WysiwygNav = ({
4354
4627
  borderRadius: `0.4rem 0.4rem 0 0`,
4355
4628
  children: [
4356
4629
  /* @__PURE__ */ jsxs(Flex, { children: [
4357
- /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(SingleSelect, { disabled: true, placeholder: selectPlaceholder, "aria-label": selectPlaceholder, children: [
4358
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
4359
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
4360
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h3", children: "h3" }),
4361
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h4", children: "h4" }),
4362
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h5", children: "h5" }),
4363
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
4364
- ] }) }),
4630
+ /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
4631
+ SingleSelect,
4632
+ {
4633
+ disabled: true,
4634
+ placeholder: selectPlaceholder,
4635
+ "aria-label": selectPlaceholder,
4636
+ size: "S",
4637
+ children: [
4638
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
4639
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
4640
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h3", children: "h3" }),
4641
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h4", children: "h4" }),
4642
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h5", children: "h5" }),
4643
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
4644
+ ]
4645
+ }
4646
+ ) }),
4365
4647
  /* @__PURE__ */ jsxs(MainButtons, { children: [
4366
- /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
4367
- /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsx(Italic, {}) }),
4368
- /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsx(Underline, {}) })
4648
+ /* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
4649
+ /* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsx(Italic, {}) }),
4650
+ /* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsx(Underline, {}) })
4369
4651
  ] }),
4370
4652
  /* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsx(More, {}) })
4371
4653
  ] }),
@@ -4392,6 +4674,7 @@ const WysiwygNav = ({
4392
4674
  placeholder: selectPlaceholder,
4393
4675
  "aria-label": selectPlaceholder,
4394
4676
  onChange: (value) => onActionClick(value, editorRef),
4677
+ size: "S",
4395
4678
  children: [
4396
4679
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
4397
4680
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
@@ -4403,17 +4686,9 @@ const WysiwygNav = ({
4403
4686
  }
4404
4687
  ) }),
4405
4688
  /* @__PURE__ */ jsxs(MainButtons, { children: [
4689
+ /* @__PURE__ */ jsx(IconButton, { onClick: () => onActionClick("Bold", editorRef), label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
4406
4690
  /* @__PURE__ */ jsx(
4407
- CustomIconButton,
4408
- {
4409
- onClick: () => onActionClick("Bold", editorRef),
4410
- label: "Bold",
4411
- name: "Bold",
4412
- children: /* @__PURE__ */ jsx(Bold, {})
4413
- }
4414
- ),
4415
- /* @__PURE__ */ jsx(
4416
- CustomIconButton,
4691
+ IconButton,
4417
4692
  {
4418
4693
  onClick: () => onActionClick("Italic", editorRef),
4419
4694
  label: "Italic",
@@ -4422,7 +4697,7 @@ const WysiwygNav = ({
4422
4697
  }
4423
4698
  ),
4424
4699
  /* @__PURE__ */ jsx(
4425
- CustomIconButton,
4700
+ IconButton,
4426
4701
  {
4427
4702
  onClick: () => onActionClick("Underline", editorRef),
4428
4703
  label: "Underline",
@@ -4431,79 +4706,81 @@ const WysiwygNav = ({
4431
4706
  }
4432
4707
  )
4433
4708
  ] }),
4434
- /* @__PURE__ */ jsx(MoreButton, { ref: buttonMoreRef, onClick: handleTogglePopover, label: "More", children: /* @__PURE__ */ jsx(More, {}) }),
4435
- visiblePopover && /* @__PURE__ */ jsx(Popover, { onDismiss: handleTogglePopover, centered: true, source: buttonMoreRef, spacing: 4, children: /* @__PURE__ */ jsxs(Flex, { children: [
4436
- /* @__PURE__ */ jsxs(IconButtonGroupMargin, { children: [
4437
- /* @__PURE__ */ jsx(
4438
- CustomIconButton,
4439
- {
4440
- onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4441
- label: "Strikethrough",
4442
- name: "Strikethrough",
4443
- children: /* @__PURE__ */ jsx(StrikeThrough, {})
4444
- }
4445
- ),
4446
- /* @__PURE__ */ jsx(
4447
- CustomIconButton,
4448
- {
4449
- onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4450
- label: "BulletList",
4451
- name: "BulletList",
4452
- children: /* @__PURE__ */ jsx(BulletList, {})
4453
- }
4454
- ),
4455
- /* @__PURE__ */ jsx(
4456
- CustomIconButton,
4457
- {
4458
- onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4459
- label: "NumberList",
4460
- name: "NumberList",
4461
- children: /* @__PURE__ */ jsx(NumberList, {})
4462
- }
4463
- )
4464
- ] }),
4465
- /* @__PURE__ */ jsxs(IconButtonGroup, { children: [
4466
- /* @__PURE__ */ jsx(
4467
- CustomIconButton,
4468
- {
4469
- onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4470
- label: "Code",
4471
- name: "Code",
4472
- children: /* @__PURE__ */ jsx(Code, {})
4473
- }
4474
- ),
4475
- /* @__PURE__ */ jsx(
4476
- CustomIconButton,
4477
- {
4478
- onClick: () => {
4479
- handleTogglePopover();
4480
- onToggleMediaLib();
4481
- },
4482
- label: "Image",
4483
- name: "Image",
4484
- children: /* @__PURE__ */ jsx(Image$1, {})
4485
- }
4486
- ),
4487
- /* @__PURE__ */ jsx(
4488
- CustomLinkIconButton,
4489
- {
4490
- onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4491
- label: "Link",
4492
- name: "Link",
4493
- children: /* @__PURE__ */ jsx(Link$1, {})
4494
- }
4495
- ),
4496
- /* @__PURE__ */ jsx(
4497
- CustomIconButton,
4498
- {
4499
- onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4500
- label: "Quote",
4501
- name: "Quote",
4502
- children: /* @__PURE__ */ jsx(Quotes, {})
4503
- }
4504
- )
4505
- ] })
4506
- ] }) })
4709
+ /* @__PURE__ */ jsxs(Popover.Root, { children: [
4710
+ /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(MoreButton, { label: "More", children: /* @__PURE__ */ jsx(More, {}) }) }),
4711
+ /* @__PURE__ */ jsx(Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxs(Flex, { padding: 2, children: [
4712
+ /* @__PURE__ */ jsxs(IconButtonGroupMargin, { children: [
4713
+ /* @__PURE__ */ jsx(
4714
+ IconButton,
4715
+ {
4716
+ onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4717
+ label: "Strikethrough",
4718
+ name: "Strikethrough",
4719
+ children: /* @__PURE__ */ jsx(StrikeThrough, {})
4720
+ }
4721
+ ),
4722
+ /* @__PURE__ */ jsx(
4723
+ IconButton,
4724
+ {
4725
+ onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4726
+ label: "BulletList",
4727
+ name: "BulletList",
4728
+ children: /* @__PURE__ */ jsx(BulletList, {})
4729
+ }
4730
+ ),
4731
+ /* @__PURE__ */ jsx(
4732
+ IconButton,
4733
+ {
4734
+ onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4735
+ label: "NumberList",
4736
+ name: "NumberList",
4737
+ children: /* @__PURE__ */ jsx(NumberList, {})
4738
+ }
4739
+ )
4740
+ ] }),
4741
+ /* @__PURE__ */ jsxs(IconButtonGroup, { children: [
4742
+ /* @__PURE__ */ jsx(
4743
+ IconButton,
4744
+ {
4745
+ onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4746
+ label: "Code",
4747
+ name: "Code",
4748
+ children: /* @__PURE__ */ jsx(Code, {})
4749
+ }
4750
+ ),
4751
+ /* @__PURE__ */ jsx(
4752
+ IconButton,
4753
+ {
4754
+ onClick: () => {
4755
+ handleTogglePopover();
4756
+ onToggleMediaLib();
4757
+ },
4758
+ label: "Image",
4759
+ name: "Image",
4760
+ children: /* @__PURE__ */ jsx(Image$1, {})
4761
+ }
4762
+ ),
4763
+ /* @__PURE__ */ jsx(
4764
+ IconButton,
4765
+ {
4766
+ onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4767
+ label: "Link",
4768
+ name: "Link",
4769
+ children: /* @__PURE__ */ jsx(Link$1, {})
4770
+ }
4771
+ ),
4772
+ /* @__PURE__ */ jsx(
4773
+ IconButton,
4774
+ {
4775
+ onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4776
+ label: "Quote",
4777
+ name: "Quote",
4778
+ children: /* @__PURE__ */ jsx(Quotes, {})
4779
+ }
4780
+ )
4781
+ ] })
4782
+ ] }) })
4783
+ ] })
4507
4784
  ] }),
4508
4785
  onTogglePreviewMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
4509
4786
  id: "components.Wysiwyg.ToggleMode.preview-mode",
@@ -4630,15 +4907,19 @@ const Wysiwyg = React.forwardRef(
4630
4907
  );
4631
4908
  const MemoizedWysiwyg = React.memo(Wysiwyg);
4632
4909
  const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4633
- const { id } = useDoc();
4910
+ const { id, document: document2, collectionType } = useDoc();
4634
4911
  const isFormDisabled = useForm("InputRenderer", (state) => state.disabled);
4635
4912
  const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
4636
4913
  const canCreateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
4637
4914
  const canReadFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
4638
4915
  const canUpdateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
4639
4916
  const canUserAction = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
4640
- const editableFields = id ? canUpdateFields : canCreateFields;
4641
- const readableFields = id ? canReadFields : canCreateFields;
4917
+ let idToCheck = id;
4918
+ if (collectionType === SINGLE_TYPES) {
4919
+ idToCheck = document2?.documentId;
4920
+ }
4921
+ const editableFields = idToCheck ? canUpdateFields : canCreateFields;
4922
+ const readableFields = idToCheck ? canReadFields : canCreateFields;
4642
4923
  const canUserReadField = canUserAction(props.name, readableFields, props.type);
4643
4924
  const canUserEditField = canUserAction(props.name, editableFields, props.type);
4644
4925
  const fields = useStrapiApp("InputRenderer", (app) => app.fields);
@@ -4649,6 +4930,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4649
4930
  const {
4650
4931
  edit: { components }
4651
4932
  } = useDocLayout();
4933
+ const field = useField(props.name);
4652
4934
  if (!visible) {
4653
4935
  return null;
4654
4936
  }
@@ -4659,553 +4941,645 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4659
4941
  if (attributeHasCustomFieldProperty(props.attribute)) {
4660
4942
  const CustomInput = lazyComponentStore[props.attribute.customField];
4661
4943
  if (CustomInput) {
4662
- return /* @__PURE__ */ jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4944
+ return /* @__PURE__ */ jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
4945
+ }
4946
+ return /* @__PURE__ */ jsx(
4947
+ InputRenderer$1,
4948
+ {
4949
+ ...props,
4950
+ hint,
4951
+ type: props.attribute.customField,
4952
+ disabled: fieldIsDisabled
4953
+ }
4954
+ );
4955
+ }
4956
+ const addedInputTypes = Object.keys(fields);
4957
+ if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4958
+ const CustomInput = fields[props.type];
4959
+ return /* @__PURE__ */ jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4960
+ }
4961
+ switch (props.type) {
4962
+ case "blocks":
4963
+ return /* @__PURE__ */ jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4964
+ case "component":
4965
+ return /* @__PURE__ */ jsx(
4966
+ MemoizedComponentInput,
4967
+ {
4968
+ ...props,
4969
+ hint,
4970
+ layout: components[props.attribute.component].layout,
4971
+ disabled: fieldIsDisabled,
4972
+ children: (inputProps) => /* @__PURE__ */ jsx(InputRenderer, { ...inputProps })
4973
+ }
4974
+ );
4975
+ case "dynamiczone":
4976
+ return /* @__PURE__ */ jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
4977
+ case "relation":
4978
+ return /* @__PURE__ */ jsx(MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
4979
+ case "richtext":
4980
+ return /* @__PURE__ */ jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4981
+ case "uid":
4982
+ return /* @__PURE__ */ jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4983
+ case "enumeration":
4984
+ return /* @__PURE__ */ jsx(
4985
+ InputRenderer$1,
4986
+ {
4987
+ ...props,
4988
+ hint,
4989
+ options: props.attribute.enum.map((value) => ({ value })),
4990
+ type: props.customField ? "custom-field" : props.type,
4991
+ disabled: fieldIsDisabled
4992
+ }
4993
+ );
4994
+ default:
4995
+ const { unique: _unique, mainField: _mainField, ...restProps } = props;
4996
+ return /* @__PURE__ */ jsx(
4997
+ InputRenderer$1,
4998
+ {
4999
+ ...restProps,
5000
+ hint,
5001
+ type: props.customField ? "custom-field" : props.type,
5002
+ disabled: fieldIsDisabled
5003
+ }
5004
+ );
5005
+ }
5006
+ };
5007
+ const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
5008
+ const useFieldHint = (hint = void 0, attribute) => {
5009
+ const { formatMessage } = useIntl();
5010
+ const { maximum, minimum } = getMinMax(attribute);
5011
+ if (!maximum && !minimum) {
5012
+ return hint;
5013
+ }
5014
+ const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
5015
+ attribute.type
5016
+ ) ? formatMessage(
5017
+ {
5018
+ id: "content-manager.form.Input.hint.character.unit",
5019
+ defaultMessage: "{maxValue, plural, one { character} other { characters}}"
5020
+ },
5021
+ {
5022
+ maxValue: Math.max(minimum || 0, maximum || 0)
5023
+ }
5024
+ ) : null;
5025
+ const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
5026
+ return formatMessage(
5027
+ {
5028
+ id: "content-manager.form.Input.hint.text",
5029
+ defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
5030
+ },
5031
+ {
5032
+ min: minimum,
5033
+ max: maximum,
5034
+ description: hint,
5035
+ unit: units,
5036
+ divider: hasMinAndMax ? formatMessage({
5037
+ id: "content-manager.form.Input.hint.minMaxDivider",
5038
+ defaultMessage: " / "
5039
+ }) : null,
5040
+ br: /* @__PURE__ */ jsx("br", {})
5041
+ }
5042
+ );
5043
+ };
5044
+ const getMinMax = (attribute) => {
5045
+ if ("min" in attribute || "max" in attribute) {
5046
+ return {
5047
+ maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
5048
+ minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
5049
+ };
5050
+ } else if ("maxLength" in attribute || "minLength" in attribute) {
5051
+ return { maximum: attribute.maxLength, minimum: attribute.minLength };
5052
+ } else {
5053
+ return { maximum: void 0, minimum: void 0 };
5054
+ }
5055
+ };
5056
+ const MemoizedInputRenderer = memo(InputRenderer);
5057
+ const RESPONSIVE_CONTAINER_BREAKPOINTS = {
5058
+ sm: "27.5rem"
5059
+ // 440px
5060
+ };
5061
+ const ResponsiveGridRoot = styled(Grid$1.Root)`
5062
+ container-type: inline-size;
5063
+ `;
5064
+ const ResponsiveGridItem = styled(Grid$1.Item)`
5065
+ grid-column: span 12;
5066
+
5067
+ @container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
5068
+ ${({ col }) => col && `grid-column: span ${col};`}
5069
+ }
5070
+ `;
5071
+ const FormLayout = ({ layout }) => {
5072
+ const { formatMessage } = useIntl();
5073
+ const { model } = useDoc();
5074
+ return /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index) => {
5075
+ if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
5076
+ const [row] = panel;
5077
+ const [field] = row;
5078
+ const fieldWithTranslatedLabel = {
5079
+ ...field,
5080
+ label: formatMessage({
5081
+ id: `content-manager.content-types.${model}.${field.name}`,
5082
+ defaultMessage: field.label
5083
+ })
5084
+ };
5085
+ return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: /* @__PURE__ */ jsx(Grid$1.Item, { col: 12, s: 12, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel }) }) }, field.name);
5086
+ }
5087
+ return /* @__PURE__ */ jsx(
5088
+ Box,
5089
+ {
5090
+ hasRadius: true,
5091
+ background: "neutral0",
5092
+ shadow: "tableShadow",
5093
+ paddingLeft: 6,
5094
+ paddingRight: 6,
5095
+ paddingTop: 6,
5096
+ paddingBottom: 6,
5097
+ borderColor: "neutral150",
5098
+ children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: panel.map((row, gridRowIndex) => /* @__PURE__ */ jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5099
+ const fieldWithTranslatedLabel = {
5100
+ ...field,
5101
+ label: formatMessage({
5102
+ id: `content-manager.content-types.${model}.${field.name}`,
5103
+ defaultMessage: field.label
5104
+ })
5105
+ };
5106
+ return /* @__PURE__ */ jsx(
5107
+ ResponsiveGridItem,
5108
+ {
5109
+ col: size,
5110
+ s: 12,
5111
+ xs: 12,
5112
+ direction: "column",
5113
+ alignItems: "stretch",
5114
+ children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
5115
+ },
5116
+ field.name
5117
+ );
5118
+ }) }, gridRowIndex)) })
5119
+ },
5120
+ index
5121
+ );
5122
+ }) });
5123
+ };
5124
+ const NonRepeatableComponent = ({
5125
+ attribute,
5126
+ name: name2,
5127
+ children,
5128
+ layout
5129
+ }) => {
5130
+ const { formatMessage } = useIntl();
5131
+ const { value } = useField(name2);
5132
+ const level = useComponent("NonRepeatableComponent", (state) => state.level);
5133
+ const isNested = level > 0;
5134
+ return /* @__PURE__ */ jsx(ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsx(
5135
+ Box,
5136
+ {
5137
+ background: "neutral100",
5138
+ paddingLeft: 6,
5139
+ paddingRight: 6,
5140
+ paddingTop: 6,
5141
+ paddingBottom: 6,
5142
+ hasRadius: isNested,
5143
+ borderColor: isNested ? "neutral200" : void 0,
5144
+ children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index) => {
5145
+ return /* @__PURE__ */ jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5146
+ const completeFieldName = `${name2}.${field.name}`;
5147
+ const translatedLabel = formatMessage({
5148
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5149
+ defaultMessage: field.label
5150
+ });
5151
+ return /* @__PURE__ */ jsx(
5152
+ ResponsiveGridItem,
5153
+ {
5154
+ col: size,
5155
+ s: 12,
5156
+ xs: 12,
5157
+ direction: "column",
5158
+ alignItems: "stretch",
5159
+ children: children({ ...field, label: translatedLabel, name: completeFieldName })
5160
+ },
5161
+ completeFieldName
5162
+ );
5163
+ }) }, index);
5164
+ }) })
5165
+ }
5166
+ ) });
5167
+ };
5168
+ const RepeatableComponent = ({
5169
+ attribute,
5170
+ disabled,
5171
+ name: name2,
5172
+ mainField,
5173
+ children,
5174
+ layout
5175
+ }) => {
5176
+ const { toggleNotification } = useNotification();
5177
+ const { formatMessage } = useIntl();
5178
+ const { search: searchString } = useLocation();
5179
+ const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
5180
+ const { components } = useDoc();
5181
+ const {
5182
+ value = [],
5183
+ error,
5184
+ rawError
5185
+ } = useField(name2);
5186
+ const addFieldRow = useForm("RepeatableComponent", (state) => state.addFieldRow);
5187
+ const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
5188
+ const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
5189
+ const { max = Infinity } = attribute;
5190
+ const [collapseToOpen, setCollapseToOpen] = React.useState("");
5191
+ const [liveText, setLiveText] = React.useState("");
5192
+ React.useEffect(() => {
5193
+ const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
5194
+ const hasNestedValue = value && Array.isArray(value) && value.length > 0;
5195
+ if (hasNestedErrors && hasNestedValue) {
5196
+ const errorOpenItems = rawError.map((_, idx) => {
5197
+ return value[idx] ? value[idx].__temp_key__ : null;
5198
+ }).filter((value2) => !!value2);
5199
+ if (errorOpenItems && errorOpenItems.length > 0) {
5200
+ setCollapseToOpen((collapseToOpen2) => {
5201
+ if (!errorOpenItems.includes(collapseToOpen2)) {
5202
+ return errorOpenItems[0];
5203
+ }
5204
+ return collapseToOpen2;
5205
+ });
5206
+ }
4663
5207
  }
4664
- return /* @__PURE__ */ jsx(
4665
- InputRenderer$1,
4666
- {
4667
- ...props,
4668
- hint,
4669
- type: props.attribute.customField,
4670
- disabled: fieldIsDisabled
5208
+ }, [rawError, value]);
5209
+ const componentTmpKeyWithFocussedField = React.useMemo(() => {
5210
+ if (search.has("field")) {
5211
+ const fieldParam = search.get("field");
5212
+ if (!fieldParam) {
5213
+ return void 0;
5214
+ }
5215
+ const [, path] = fieldParam.split(`${name2}.`);
5216
+ if (getIn(value, path, void 0) !== void 0) {
5217
+ const [subpath] = path.split(".");
5218
+ return getIn(value, subpath, void 0)?.__temp_key__;
4671
5219
  }
5220
+ }
5221
+ return void 0;
5222
+ }, [search, name2, value]);
5223
+ const prevValue = usePrev(value);
5224
+ React.useEffect(() => {
5225
+ if (prevValue && prevValue.length < value.length) {
5226
+ setCollapseToOpen(value[value.length - 1].__temp_key__);
5227
+ }
5228
+ }, [value, prevValue]);
5229
+ React.useEffect(() => {
5230
+ if (typeof componentTmpKeyWithFocussedField === "string") {
5231
+ setCollapseToOpen(componentTmpKeyWithFocussedField);
5232
+ }
5233
+ }, [componentTmpKeyWithFocussedField]);
5234
+ const toggleCollapses = () => {
5235
+ setCollapseToOpen("");
5236
+ };
5237
+ const handleClick = () => {
5238
+ if (value.length < max) {
5239
+ const schema = components[attribute.component];
5240
+ const form = createDefaultForm(schema, components);
5241
+ const data = transformDocument(schema, components)(form);
5242
+ addFieldRow(name2, data);
5243
+ } else if (value.length >= max) {
5244
+ toggleNotification({
5245
+ type: "info",
5246
+ message: formatMessage({
5247
+ id: getTranslation("components.notification.info.maximum-requirement")
5248
+ })
5249
+ });
5250
+ }
5251
+ };
5252
+ const handleMoveComponentField = (newIndex, currentIndex) => {
5253
+ setLiveText(
5254
+ formatMessage(
5255
+ {
5256
+ id: getTranslation("dnd.reorder"),
5257
+ defaultMessage: "{item}, moved. New position in list: {position}."
5258
+ },
5259
+ {
5260
+ item: `${name2}.${currentIndex}`,
5261
+ position: getItemPos(newIndex)
5262
+ }
5263
+ )
4672
5264
  );
4673
- }
4674
- const addedInputTypes = Object.keys(fields);
4675
- if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4676
- const CustomInput = fields[props.type];
4677
- return /* @__PURE__ */ jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4678
- }
4679
- switch (props.type) {
4680
- case "blocks":
4681
- return /* @__PURE__ */ jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4682
- case "component":
4683
- return /* @__PURE__ */ jsx(
4684
- MemoizedComponentInput,
5265
+ moveFieldRow(name2, currentIndex, newIndex);
5266
+ };
5267
+ const handleValueChange = (key) => {
5268
+ setCollapseToOpen(key);
5269
+ };
5270
+ const getItemPos = (index) => `${index + 1} of ${value.length}`;
5271
+ const handleCancel = (index) => {
5272
+ setLiveText(
5273
+ formatMessage(
4685
5274
  {
4686
- ...props,
4687
- hint,
4688
- layout: components[props.attribute.component].layout,
4689
- disabled: fieldIsDisabled,
4690
- children: (inputProps) => /* @__PURE__ */ jsx(InputRenderer, { ...inputProps })
5275
+ id: getTranslation("dnd.cancel-item"),
5276
+ defaultMessage: "{item}, dropped. Re-order cancelled."
5277
+ },
5278
+ {
5279
+ item: `${name2}.${index}`
4691
5280
  }
4692
- );
4693
- case "dynamiczone":
4694
- return /* @__PURE__ */ jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
4695
- case "relation":
4696
- return /* @__PURE__ */ jsx(MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
4697
- case "richtext":
4698
- return /* @__PURE__ */ jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4699
- case "uid":
4700
- return /* @__PURE__ */ jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4701
- case "enumeration":
4702
- return /* @__PURE__ */ jsx(
4703
- InputRenderer$1,
5281
+ )
5282
+ );
5283
+ };
5284
+ const handleGrabItem = (index) => {
5285
+ setLiveText(
5286
+ formatMessage(
4704
5287
  {
4705
- ...props,
4706
- hint,
4707
- options: props.attribute.enum.map((value) => ({ value })),
4708
- type: props.customField ? "custom-field" : props.type,
4709
- disabled: fieldIsDisabled
5288
+ id: getTranslation("dnd.grab-item"),
5289
+ defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
5290
+ },
5291
+ {
5292
+ item: `${name2}.${index}`,
5293
+ position: getItemPos(index)
4710
5294
  }
4711
- );
4712
- default:
4713
- const { unique: _unique, mainField: _mainField, ...restProps } = props;
4714
- return /* @__PURE__ */ jsx(
4715
- InputRenderer$1,
5295
+ )
5296
+ );
5297
+ };
5298
+ const handleDropItem = (index) => {
5299
+ setLiveText(
5300
+ formatMessage(
4716
5301
  {
4717
- ...restProps,
4718
- hint,
4719
- type: props.customField ? "custom-field" : props.type,
4720
- disabled: fieldIsDisabled
5302
+ id: getTranslation("dnd.drop-item"),
5303
+ defaultMessage: `{item}, dropped. Final position in list: {position}.`
5304
+ },
5305
+ {
5306
+ item: `${name2}.${index}`,
5307
+ position: getItemPos(index)
4721
5308
  }
4722
- );
5309
+ )
5310
+ );
5311
+ };
5312
+ const ariaDescriptionId = React.useId();
5313
+ const level = useComponent("RepeatableComponent", (state) => state.level);
5314
+ if (value.length === 0) {
5315
+ return /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleClick });
4723
5316
  }
5317
+ return /* @__PURE__ */ jsxs(Box, { hasRadius: true, children: [
5318
+ /* @__PURE__ */ jsx(VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5319
+ id: getTranslation("dnd.instructions"),
5320
+ defaultMessage: `Press spacebar to grab and re-order`
5321
+ }) }),
5322
+ /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5323
+ /* @__PURE__ */ jsxs(
5324
+ AccordionRoot,
5325
+ {
5326
+ $error: error,
5327
+ value: collapseToOpen,
5328
+ onValueChange: handleValueChange,
5329
+ "aria-describedby": ariaDescriptionId,
5330
+ children: [
5331
+ value.map(({ __temp_key__: key, id }, index) => {
5332
+ const nameWithIndex = `${name2}.${index}`;
5333
+ return /* @__PURE__ */ jsx(
5334
+ ComponentProvider,
5335
+ {
5336
+ id,
5337
+ uid: attribute.component,
5338
+ level: level + 1,
5339
+ type: "repeatable",
5340
+ children: /* @__PURE__ */ jsx(
5341
+ Component,
5342
+ {
5343
+ disabled,
5344
+ name: nameWithIndex,
5345
+ attribute,
5346
+ index,
5347
+ mainField,
5348
+ onMoveItem: handleMoveComponentField,
5349
+ onDeleteComponent: () => {
5350
+ removeFieldRow(name2, index);
5351
+ toggleCollapses();
5352
+ },
5353
+ toggleCollapses,
5354
+ onCancel: handleCancel,
5355
+ onDropItem: handleDropItem,
5356
+ onGrabItem: handleGrabItem,
5357
+ __temp_key__: key,
5358
+ children: layout.map((row, index2) => {
5359
+ return /* @__PURE__ */ jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5360
+ const completeFieldName = `${nameWithIndex}.${field.name}`;
5361
+ const translatedLabel = formatMessage({
5362
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5363
+ defaultMessage: field.label
5364
+ });
5365
+ return /* @__PURE__ */ jsx(
5366
+ ResponsiveGridItem,
5367
+ {
5368
+ col: size,
5369
+ s: 12,
5370
+ xs: 12,
5371
+ direction: "column",
5372
+ alignItems: "stretch",
5373
+ children: children({
5374
+ ...field,
5375
+ label: translatedLabel,
5376
+ name: completeFieldName
5377
+ })
5378
+ },
5379
+ completeFieldName
5380
+ );
5381
+ }) }, index2);
5382
+ })
5383
+ }
5384
+ )
5385
+ },
5386
+ key
5387
+ );
5388
+ }),
5389
+ /* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
5390
+ id: getTranslation("containers.EditView.add.new-entry"),
5391
+ defaultMessage: "Add an entry"
5392
+ }) })
5393
+ ]
5394
+ }
5395
+ )
5396
+ ] });
4724
5397
  };
4725
- const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
4726
- const useFieldHint = (hint = void 0, attribute) => {
4727
- const { formatMessage } = useIntl();
4728
- const { maximum, minimum } = getMinMax(attribute);
4729
- if (!maximum && !minimum) {
4730
- return hint;
4731
- }
4732
- const units = !["biginteger", "integer", "number"].includes(attribute.type) ? formatMessage(
4733
- {
4734
- id: "content-manager.form.Input.hint.character.unit",
4735
- defaultMessage: "{maxValue, plural, one { character} other { characters}}"
4736
- },
4737
- {
4738
- maxValue: Math.max(minimum || 0, maximum || 0)
4739
- }
4740
- ) : null;
4741
- const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
4742
- return formatMessage(
4743
- {
4744
- id: "content-manager.form.Input.hint.text",
4745
- defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
4746
- },
4747
- {
4748
- min: minimum,
4749
- max: maximum,
4750
- description: hint,
4751
- unit: units,
4752
- divider: hasMinAndMax ? formatMessage({
4753
- id: "content-manager.form.Input.hint.minMaxDivider",
4754
- defaultMessage: " / "
4755
- }) : null,
4756
- br: /* @__PURE__ */ jsx("br", {})
5398
+ const AccordionRoot = styled(Accordion.Root)`
5399
+ border: 1px solid
5400
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
5401
+ `;
5402
+ const TextButtonCustom = styled(TextButton)`
5403
+ width: 100%;
5404
+ display: flex;
5405
+ justify-content: center;
5406
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
5407
+ padding-inline: ${(props) => props.theme.spaces[6]};
5408
+ padding-block: ${(props) => props.theme.spaces[3]};
5409
+
5410
+ &:not([disabled]) {
5411
+ cursor: pointer;
5412
+
5413
+ &:hover {
5414
+ background-color: ${(props) => props.theme.colors.primary100};
4757
5415
  }
4758
- );
4759
- };
4760
- const getMinMax = (attribute) => {
4761
- if ("min" in attribute || "max" in attribute) {
4762
- return {
4763
- maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
4764
- minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
4765
- };
4766
- } else if ("maxLength" in attribute || "minLength" in attribute) {
4767
- return { maximum: attribute.maxLength, minimum: attribute.minLength };
4768
- } else {
4769
- return { maximum: void 0, minimum: void 0 };
4770
5416
  }
4771
- };
4772
- const MemoizedInputRenderer = memo(InputRenderer);
4773
- const DynamicComponent = ({
4774
- componentUid,
5417
+
5418
+ span {
5419
+ font-weight: 600;
5420
+ font-size: 1.4rem;
5421
+ line-height: 2.4rem;
5422
+ }
5423
+
5424
+ @media (prefers-reduced-motion: no-preference) {
5425
+ transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
5426
+ }
5427
+ `;
5428
+ const Component = ({
4775
5429
  disabled,
4776
5430
  index,
4777
5431
  name: name2,
4778
- onRemoveComponentClick,
4779
- onMoveComponent,
4780
- onGrabItem,
4781
- onDropItem,
4782
- onCancel,
4783
- dynamicComponentsByCategory = {},
4784
- onAddComponent
5432
+ mainField = {
5433
+ name: "id",
5434
+ type: "integer"
5435
+ },
5436
+ children,
5437
+ onDeleteComponent,
5438
+ toggleCollapses,
5439
+ __temp_key__,
5440
+ ...dragProps
4785
5441
  }) => {
4786
5442
  const { formatMessage } = useIntl();
4787
- const formValues = useForm("DynamicComponent", (state) => state.values);
4788
- const {
4789
- edit: { components }
4790
- } = useDocLayout();
4791
- const title = React.useMemo(() => {
4792
- const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
4793
- const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
4794
- const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
4795
- const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
4796
- return mainValue;
4797
- }, [componentUid, components, formValues, name2, index]);
4798
- const { icon, displayName } = React.useMemo(() => {
4799
- const [category] = componentUid.split(".");
4800
- const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
4801
- (component) => component.uid === componentUid
4802
- ) ?? { icon: null, displayName: null };
4803
- return { icon: icon2, displayName: displayName2 };
4804
- }, [componentUid, dynamicComponentsByCategory]);
5443
+ const displayValue = useForm("RepeatableComponent", (state) => {
5444
+ return getIn(state.values, [...name2.split("."), mainField.name]);
5445
+ });
5446
+ const accordionRef = React.useRef(null);
5447
+ const componentKey = name2.split(".").slice(0, -1).join(".");
4805
5448
  const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
4806
- type: `${ItemTypes.DYNAMIC_ZONE}_${name2}`,
5449
+ type: `${ItemTypes.COMPONENT}_${componentKey}`,
4807
5450
  index,
4808
5451
  item: {
4809
5452
  index,
4810
- displayedValue: `${displayName} ${title}`,
4811
- icon
5453
+ displayedValue: displayValue
4812
5454
  },
4813
- onMoveItem: onMoveComponent,
4814
- onDropItem,
4815
- onGrabItem,
4816
- onCancel
5455
+ onStart() {
5456
+ toggleCollapses();
5457
+ },
5458
+ ...dragProps
4817
5459
  });
4818
5460
  React.useEffect(() => {
4819
5461
  dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
4820
5462
  }, [dragPreviewRef, index]);
4821
- const composedBoxRefs = useComposedRefs(boxRef, dropRef);
4822
- const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
4823
- /* @__PURE__ */ jsx(
4824
- IconButton,
4825
- {
4826
- borderWidth: 0,
4827
- label: formatMessage(
5463
+ const composedAccordionRefs = useComposedRefs(accordionRef, dragRef);
5464
+ const composedBoxRefs = useComposedRefs(
5465
+ boxRef,
5466
+ dropRef
5467
+ );
5468
+ return /* @__PURE__ */ jsx(Fragment, { children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsxs(Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
5469
+ /* @__PURE__ */ jsxs(Accordion.Header, { children: [
5470
+ /* @__PURE__ */ jsx(Accordion.Trigger, { children: displayValue }),
5471
+ /* @__PURE__ */ jsxs(Accordion.Actions, { children: [
5472
+ /* @__PURE__ */ jsx(
5473
+ IconButton,
4828
5474
  {
4829
- id: getTranslation("components.DynamicZone.delete-label"),
4830
- defaultMessage: "Delete {name}"
4831
- },
4832
- { name: title }
5475
+ variant: "ghost",
5476
+ onClick: onDeleteComponent,
5477
+ label: formatMessage({
5478
+ id: getTranslation("containers.Edit.delete"),
5479
+ defaultMessage: "Delete"
5480
+ }),
5481
+ children: /* @__PURE__ */ jsx(Trash, {})
5482
+ }
4833
5483
  ),
4834
- onClick: onRemoveComponentClick,
4835
- children: /* @__PURE__ */ jsx(Trash, {})
4836
- }
4837
- ),
4838
- /* @__PURE__ */ jsx(
4839
- IconButton,
4840
- {
4841
- borderWidth: 0,
4842
- onClick: (e) => e.stopPropagation(),
4843
- "data-handler-id": handlerId,
4844
- ref: dragRef,
4845
- label: formatMessage({
4846
- id: getTranslation("components.DragHandle-label"),
4847
- defaultMessage: "Drag"
4848
- }),
4849
- onKeyDown: handleKeyDown,
4850
- children: /* @__PURE__ */ jsx(Drag, {})
4851
- }
4852
- ),
4853
- /* @__PURE__ */ jsxs(Menu.Root, { children: [
4854
- /* @__PURE__ */ jsxs(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
4855
- /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
4856
- /* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
4857
- id: getTranslation("components.DynamicZone.more-actions"),
4858
- defaultMessage: "More actions"
4859
- }) })
4860
- ] }),
4861
- /* @__PURE__ */ jsxs(Menu.Content, { children: [
4862
- /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
4863
- /* @__PURE__ */ jsx(Menu.SubTrigger, { children: formatMessage({
4864
- id: getTranslation("components.DynamicZone.add-item-above"),
4865
- defaultMessage: "Add component above"
4866
- }) }),
4867
- /* @__PURE__ */ jsx(Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
4868
- /* @__PURE__ */ jsx(Menu.Label, { children: category }),
4869
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsx(MenuItem, { onSelect: () => onAddComponent(uid, index), children: displayName2 }, componentUid))
4870
- ] }, category)) })
4871
- ] }),
4872
- /* @__PURE__ */ jsxs(Menu.SubRoot, { children: [
4873
- /* @__PURE__ */ jsx(Menu.SubTrigger, { children: formatMessage({
4874
- id: getTranslation("components.DynamicZone.add-item-below"),
4875
- defaultMessage: "Add component below"
4876
- }) }),
4877
- /* @__PURE__ */ jsx(Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
4878
- /* @__PURE__ */ jsx(Menu.Label, { children: category }),
4879
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsx(MenuItem, { onSelect: () => onAddComponent(uid, index + 1), children: displayName2 }, componentUid))
4880
- ] }, category)) })
4881
- ] })
4882
- ] })
4883
- ] })
4884
- ] });
4885
- const accordionTitle = title ? `${displayName} ${title}` : displayName;
4886
- const accordionValue = React.useId();
4887
- return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
4888
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
4889
- /* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
4890
- /* @__PURE__ */ jsxs(Accordion.Header, { children: [
4891
5484
  /* @__PURE__ */ jsx(
4892
- Accordion.Trigger,
5485
+ IconButton,
4893
5486
  {
4894
- icon: icon && COMPONENT_ICONS[icon] ? COMPONENT_ICONS[icon] : COMPONENT_ICONS.dashboard,
4895
- children: accordionTitle
5487
+ ref: composedAccordionRefs,
5488
+ variant: "ghost",
5489
+ onClick: (e) => e.stopPropagation(),
5490
+ "data-handler-id": handlerId,
5491
+ label: formatMessage({
5492
+ id: getTranslation("components.DragHandle-label"),
5493
+ defaultMessage: "Drag"
5494
+ }),
5495
+ onKeyDown: handleKeyDown,
5496
+ children: /* @__PURE__ */ jsx(Drag, {})
4896
5497
  }
4897
- ),
4898
- /* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
4899
- ] }),
4900
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsx(Grid$1, { gap: 4, children: row.map(({ size, ...field }) => {
4901
- const fieldName = `${name2}.${index}.${field.name}`;
4902
- return /* @__PURE__ */ jsx(GridItem, { col: size, s: 12, xs: 12, children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...field, name: fieldName }) }, fieldName);
4903
- }) }, rowInd)) }) }) })
4904
- ] }) }) })
4905
- ] });
4906
- };
4907
- const StyledBox = styled(Box)`
4908
- > div:first-child {
4909
- box-shadow: ${({ theme }) => theme.shadows.tableShadow};
4910
- }
4911
- `;
4912
- const AccordionContentRadius = styled(Box)`
4913
- border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
4914
- `;
4915
- const Rectangle = styled(Box)`
4916
- width: ${({ theme }) => theme.spaces[2]};
4917
- height: ${({ theme }) => theme.spaces[4]};
4918
- `;
4919
- const Preview = styled.span`
4920
- display: block;
4921
- background-color: ${({ theme }) => theme.colors.primary100};
4922
- outline: 1px dashed ${({ theme }) => theme.colors.primary500};
4923
- outline-offset: -1px;
4924
- padding: ${({ theme }) => theme.spaces[6]};
4925
- `;
4926
- const ComponentContainer = styled(Box)`
4927
- list-style: none;
4928
- padding: 0;
4929
- margin: 0;
4930
- `;
4931
- const DynamicZoneLabel = ({
4932
- hint,
4933
- label,
4934
- labelAction,
4935
- name: name2,
4936
- numberOfComponents = 0,
4937
- required
4938
- }) => {
4939
- return /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
4940
- Box,
4941
- {
4942
- paddingTop: 3,
4943
- paddingBottom: 3,
4944
- paddingRight: 4,
4945
- paddingLeft: 4,
4946
- borderRadius: "26px",
4947
- background: "neutral0",
4948
- shadow: "filterShadow",
4949
- color: "neutral500",
4950
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", justifyContent: "center", children: [
4951
- /* @__PURE__ */ jsxs(Flex, { maxWidth: "35.6rem", children: [
4952
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
4953
- label || name2,
4954
- " "
4955
- ] }),
4956
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
4957
- "(",
4958
- numberOfComponents,
4959
- ")"
4960
- ] }),
4961
- required && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: "*" }),
4962
- labelAction && /* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: labelAction })
4963
- ] }),
4964
- hint && /* @__PURE__ */ jsx(Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
5498
+ )
4965
5499
  ] })
4966
- }
4967
- ) });
5500
+ ] }),
5501
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(
5502
+ Flex,
5503
+ {
5504
+ direction: "column",
5505
+ alignItems: "stretch",
5506
+ background: "neutral100",
5507
+ padding: 6,
5508
+ gap: 6,
5509
+ children
5510
+ }
5511
+ ) })
5512
+ ] }) });
5513
+ };
5514
+ const Preview = () => {
5515
+ return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
4968
5516
  };
4969
- const [DynamicZoneProvider, useDynamicZone] = createContext(
4970
- "DynamicZone",
4971
- {
4972
- isInDynamicZone: false
4973
- }
4974
- );
4975
- const DynamicZone = ({
4976
- attribute,
4977
- disabled: disabledProp,
4978
- hint,
5517
+ const StyledSpan = styled(Box)`
5518
+ display: block;
5519
+ outline: 1px dashed ${({ theme }) => theme.colors.primary500};
5520
+ outline-offset: -1px;
5521
+ `;
5522
+ const ComponentInput = ({
4979
5523
  label,
4980
- labelAction,
5524
+ required,
4981
5525
  name: name2,
4982
- required = false
5526
+ attribute,
5527
+ disabled,
5528
+ labelAction,
5529
+ ...props
4983
5530
  }) => {
4984
- const { max = Infinity, min = -Infinity } = attribute ?? {};
4985
- const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
4986
- const [liveText, setLiveText] = React.useState("");
4987
- const { components, isLoading } = useDoc();
4988
- const disabled = disabledProp || isLoading;
4989
- const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
4990
- "DynamicZone",
4991
- ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
4992
- addFieldRow: addFieldRow2,
4993
- removeFieldRow: removeFieldRow2,
4994
- moveFieldRow: moveFieldRow2
4995
- })
4996
- );
4997
- const { value = [], error } = useField(name2);
4998
- const dynamicComponentsByCategory = React.useMemo(() => {
4999
- return attribute.components.reduce((acc, componentUid) => {
5000
- const { category, info } = components[componentUid] ?? { info: {} };
5001
- const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
5002
- if (!acc[category]) {
5003
- acc[category] = [];
5004
- }
5005
- acc[category] = [...acc[category], component];
5006
- return acc;
5007
- }, {});
5008
- }, [attribute.components, components]);
5009
5531
  const { formatMessage } = useIntl();
5010
- const { toggleNotification } = useNotification();
5011
- const dynamicDisplayedComponentsLength = value.length;
5012
- const handleAddComponent = (uid, position) => {
5013
- setAddComponentIsOpen(false);
5014
- const schema = components[uid];
5532
+ const field = useField(name2);
5533
+ const showResetComponent = !attribute.repeatable && field.value && !disabled;
5534
+ const { components } = useDoc();
5535
+ const handleInitialisationClick = () => {
5536
+ const schema = components[attribute.component];
5015
5537
  const form = createDefaultForm(schema, components);
5016
- const transformations = pipe$1(transformDocument(schema, components), (data2) => ({
5017
- ...data2,
5018
- __component: uid
5019
- }));
5020
- const data = transformations(form);
5021
- addFieldRow(name2, data, position);
5022
- };
5023
- const handleClickOpenPicker = () => {
5024
- if (dynamicDisplayedComponentsLength < max) {
5025
- setAddComponentIsOpen((prev) => !prev);
5026
- } else {
5027
- toggleNotification({
5028
- type: "info",
5029
- message: formatMessage({
5030
- id: getTranslation("components.notification.info.maximum-requirement")
5031
- })
5032
- });
5033
- }
5034
- };
5035
- const handleMoveComponent = (newIndex, currentIndex) => {
5036
- setLiveText(
5037
- formatMessage(
5038
- {
5039
- id: getTranslation("dnd.reorder"),
5040
- defaultMessage: "{item}, moved. New position in list: {position}."
5041
- },
5042
- {
5043
- item: `${name2}.${currentIndex}`,
5044
- position: getItemPos(newIndex)
5045
- }
5046
- )
5047
- );
5048
- moveFieldRow(name2, currentIndex, newIndex);
5049
- };
5050
- const getItemPos = (index) => `${index + 1} of ${value.length}`;
5051
- const handleCancel = (index) => {
5052
- setLiveText(
5053
- formatMessage(
5054
- {
5055
- id: getTranslation("dnd.cancel-item"),
5056
- defaultMessage: "{item}, dropped. Re-order cancelled."
5057
- },
5058
- {
5059
- item: `${name2}.${index}`
5060
- }
5061
- )
5062
- );
5063
- };
5064
- const handleGrabItem = (index) => {
5065
- setLiveText(
5066
- formatMessage(
5067
- {
5068
- id: getTranslation("dnd.grab-item"),
5069
- defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
5070
- },
5071
- {
5072
- item: `${name2}.${index}`,
5073
- position: getItemPos(index)
5074
- }
5075
- )
5076
- );
5538
+ const data = transformDocument(schema, components)(form);
5539
+ field.onChange(name2, data);
5077
5540
  };
5078
- const handleDropItem = (index) => {
5079
- setLiveText(
5080
- formatMessage(
5081
- {
5082
- id: getTranslation("dnd.drop-item"),
5083
- defaultMessage: `{item}, dropped. Final position in list: {position}.`
5084
- },
5541
+ return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
5542
+ /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
5543
+ /* @__PURE__ */ jsxs(Field.Label, { action: labelAction, children: [
5544
+ label,
5545
+ attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
5546
+ " (",
5547
+ Array.isArray(field.value) ? field.value.length : 0,
5548
+ ")"
5549
+ ] })
5550
+ ] }),
5551
+ showResetComponent && /* @__PURE__ */ jsx(
5552
+ IconButton,
5085
5553
  {
5086
- item: `${name2}.${index}`,
5087
- position: getItemPos(index)
5554
+ label: formatMessage({
5555
+ id: getTranslation("components.reset-entry"),
5556
+ defaultMessage: "Reset Entry"
5557
+ }),
5558
+ variant: "ghost",
5559
+ onClick: () => {
5560
+ field.onChange(name2, null);
5561
+ },
5562
+ children: /* @__PURE__ */ jsx(Trash, {})
5088
5563
  }
5089
5564
  )
5090
- );
5091
- };
5092
- const handleRemoveComponent = (name22, currentIndex) => () => {
5093
- removeFieldRow(name22, currentIndex);
5094
- };
5095
- const hasError = error !== void 0 || dynamicDisplayedComponentsLength < min || dynamicDisplayedComponentsLength > max;
5096
- const renderButtonLabel = () => {
5097
- if (addComponentIsOpen) {
5098
- return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
5099
- }
5100
- if (hasError && dynamicDisplayedComponentsLength > max) {
5101
- return formatMessage(
5102
- {
5103
- id: getTranslation(`components.DynamicZone.extra-components`),
5104
- defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
5105
- },
5106
- {
5107
- number: dynamicDisplayedComponentsLength - max
5108
- }
5109
- );
5110
- }
5111
- if (hasError && dynamicDisplayedComponentsLength < min) {
5112
- return formatMessage(
5113
- {
5114
- id: getTranslation(`components.DynamicZone.missing-components`),
5115
- defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
5116
- },
5117
- { number: min - dynamicDisplayedComponentsLength }
5118
- );
5119
- }
5120
- return formatMessage(
5121
- {
5122
- id: getTranslation("components.DynamicZone.add-component"),
5123
- defaultMessage: "Add a component to {componentName}"
5124
- },
5125
- { componentName: label || name2 }
5126
- );
5127
- };
5128
- const level = useComponent("DynamicZone", (state) => state.level);
5129
- const ariaDescriptionId = React.useId();
5130
- return /* @__PURE__ */ jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
5131
- dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxs(Box, { children: [
5132
- /* @__PURE__ */ jsx(
5133
- DynamicZoneLabel,
5134
- {
5135
- hint,
5136
- label,
5137
- labelAction,
5138
- name: name2,
5139
- numberOfComponents: dynamicDisplayedComponentsLength,
5140
- required
5141
- }
5142
- ),
5143
- /* @__PURE__ */ jsx(VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5144
- id: getTranslation("dnd.instructions"),
5145
- defaultMessage: `Press spacebar to grab and re-order`
5146
- }) }),
5147
- /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5148
- /* @__PURE__ */ jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index) => /* @__PURE__ */ jsx(
5149
- ComponentProvider,
5150
- {
5151
- level: level + 1,
5152
- uid: field.__component,
5153
- id: field.id,
5154
- type: "dynamiczone",
5155
- children: /* @__PURE__ */ jsx(
5156
- DynamicComponent,
5157
- {
5158
- disabled,
5159
- name: name2,
5160
- index,
5161
- componentUid: field.__component,
5162
- onMoveComponent: handleMoveComponent,
5163
- onRemoveComponentClick: handleRemoveComponent(name2, index),
5164
- onCancel: handleCancel,
5165
- onDropItem: handleDropItem,
5166
- onGrabItem: handleGrabItem,
5167
- onAddComponent: handleAddComponent,
5168
- dynamicComponentsByCategory
5169
- }
5170
- )
5171
- },
5172
- field.__temp_key__
5173
- )) })
5174
5565
  ] }),
5175
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
5176
- AddComponentButton,
5177
- {
5178
- hasError,
5179
- isDisabled: disabled,
5180
- isOpen: addComponentIsOpen,
5181
- onClick: handleClickOpenPicker,
5182
- children: renderButtonLabel()
5183
- }
5184
- ) }),
5185
- /* @__PURE__ */ jsx(
5186
- ComponentPicker,
5187
- {
5188
- dynamicComponentsByCategory,
5189
- isOpen: addComponentIsOpen,
5190
- onClickAddComponent: handleAddComponent
5191
- }
5192
- )
5193
- ] }) });
5566
+ !attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
5567
+ !attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
5568
+ attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
5569
+ /* @__PURE__ */ jsx(Field.Error, {})
5570
+ ] });
5194
5571
  };
5572
+ const MemoizedComponentInput = React.memo(ComponentInput);
5195
5573
  export {
5196
5574
  DynamicZone as D,
5197
- MemoizedInputRenderer as M,
5575
+ FormLayout as F,
5576
+ MemoizedUIDInput as M,
5198
5577
  NotAllowedInput as N,
5199
5578
  useDynamicZone as a,
5200
5579
  useFieldHint as b,
5201
- createDefaultForm as c,
5202
- MemoizedUIDInput as d,
5203
- MemoizedWysiwyg as e,
5204
- MemoizedComponentInput as f,
5205
- MemoizedBlocksInput as g,
5206
- prepareTempKeys as p,
5207
- removeFieldsThatDontExistOnSchema as r,
5208
- transformDocument as t,
5580
+ MemoizedWysiwyg as c,
5581
+ MemoizedComponentInput as d,
5582
+ MemoizedBlocksInput as e,
5209
5583
  useLazyComponents as u
5210
5584
  };
5211
- //# sourceMappingURL=Field-Cz_J9551.mjs.map
5585
+ //# sourceMappingURL=Input-BkKwZ6Qt.mjs.map