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

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