@strapi/content-manager 0.0.0-experimental.17b4116f461a49b8ce5386f7c8d79c511d40fb3b → 0.0.0-experimental.1fc4b627b49f713b07ed9f7f2b37741dcf8cf736

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 (214) hide show
  1. package/LICENSE +18 -3
  2. package/dist/_chunks/{CardDragPreview-DSVYodBX.js → CardDragPreview-C0QyJgRA.js} +10 -14
  3. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -0
  4. package/dist/_chunks/{CardDragPreview-ikSG4M46.mjs → CardDragPreview-DOxamsuj.mjs} +7 -9
  5. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -0
  6. package/dist/_chunks/{ComponentConfigurationPage-DjQBdcKF.mjs → ComponentConfigurationPage-CIjXcRAB.mjs} +4 -4
  7. package/dist/_chunks/{ComponentConfigurationPage-DjQBdcKF.mjs.map → ComponentConfigurationPage-CIjXcRAB.mjs.map} +1 -1
  8. package/dist/_chunks/{ComponentConfigurationPage-2iOVVhqV.js → ComponentConfigurationPage-gsCd80MU.js} +4 -4
  9. package/dist/_chunks/{ComponentConfigurationPage-2iOVVhqV.js.map → ComponentConfigurationPage-gsCd80MU.js.map} +1 -1
  10. package/dist/_chunks/{ComponentIcon-BBQsYCVn.js → ComponentIcon-BXdiCGQp.js} +8 -2
  11. package/dist/_chunks/ComponentIcon-BXdiCGQp.js.map +1 -0
  12. package/dist/_chunks/{ComponentIcon-BOFnK76n.mjs → ComponentIcon-u4bIXTFY.mjs} +9 -3
  13. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -0
  14. package/dist/_chunks/{EditConfigurationPage-BoBb-DLH.mjs → EditConfigurationPage-BglmD_BF.mjs} +4 -4
  15. package/dist/_chunks/{EditConfigurationPage-BoBb-DLH.mjs.map → EditConfigurationPage-BglmD_BF.mjs.map} +1 -1
  16. package/dist/_chunks/{EditConfigurationPage-B7dw5_cS.js → EditConfigurationPage-DHDQKBzw.js} +4 -4
  17. package/dist/_chunks/{EditConfigurationPage-B7dw5_cS.js.map → EditConfigurationPage-DHDQKBzw.js.map} +1 -1
  18. package/dist/_chunks/{EditViewPage-KRG56aCq.js → EditViewPage-C4iTxUPU.js} +69 -50
  19. package/dist/_chunks/EditViewPage-C4iTxUPU.js.map +1 -0
  20. package/dist/_chunks/{EditViewPage-aUnqL-63.mjs → EditViewPage-CiwVPMaK.mjs} +70 -49
  21. package/dist/_chunks/EditViewPage-CiwVPMaK.mjs.map +1 -0
  22. package/dist/_chunks/{Field-kVFO4ZKB.mjs → Field-DIjL1b5d.mjs} +1046 -802
  23. package/dist/_chunks/Field-DIjL1b5d.mjs.map +1 -0
  24. package/dist/_chunks/{Field-kq1c2TF1.js → Field-DhXEK8y1.js} +1092 -849
  25. package/dist/_chunks/Field-DhXEK8y1.js.map +1 -0
  26. package/dist/_chunks/{Form-Jgh5hGTu.mjs → Form-CmNesrvR.mjs} +66 -45
  27. package/dist/_chunks/Form-CmNesrvR.mjs.map +1 -0
  28. package/dist/_chunks/{Form-CQ67ZifP.js → Form-CwmJ4sWe.js} +66 -46
  29. package/dist/_chunks/Form-CwmJ4sWe.js.map +1 -0
  30. package/dist/_chunks/{History-BLEnudTX.js → History-BLCCNgCt.js} +164 -54
  31. package/dist/_chunks/History-BLCCNgCt.js.map +1 -0
  32. package/dist/_chunks/{History-DKhZAPcK.mjs → History-D-99Wh30.mjs} +163 -52
  33. package/dist/_chunks/History-D-99Wh30.mjs.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-Zso_LUjn.js → ListConfigurationPage-DxWpeZrO.js} +68 -59
  35. package/dist/_chunks/ListConfigurationPage-DxWpeZrO.js.map +1 -0
  36. package/dist/_chunks/{ListConfigurationPage-nrXcxNYi.mjs → ListConfigurationPage-JPWZz7Kg.mjs} +64 -54
  37. package/dist/_chunks/ListConfigurationPage-JPWZz7Kg.mjs.map +1 -0
  38. package/dist/_chunks/{ListViewPage-DsaOakWQ.js → ListViewPage-CIQekSFz.js} +143 -139
  39. package/dist/_chunks/ListViewPage-CIQekSFz.js.map +1 -0
  40. package/dist/_chunks/{ListViewPage-ChhYmA-L.mjs → ListViewPage-DSK3f0ST.mjs} +140 -136
  41. package/dist/_chunks/ListViewPage-DSK3f0ST.mjs.map +1 -0
  42. package/dist/_chunks/{NoContentTypePage-DPCuS9Y1.js → NoContentTypePage-C5cxKvC2.js} +3 -3
  43. package/dist/_chunks/NoContentTypePage-C5cxKvC2.js.map +1 -0
  44. package/dist/_chunks/{NoContentTypePage-BrdFcN33.mjs → NoContentTypePage-D99LU1YP.mjs} +3 -3
  45. package/dist/_chunks/NoContentTypePage-D99LU1YP.mjs.map +1 -0
  46. package/dist/_chunks/{NoPermissionsPage-B9dqrtTy.mjs → NoPermissionsPage-DBrBw-0y.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-B9dqrtTy.mjs.map → NoPermissionsPage-DBrBw-0y.mjs.map} +1 -1
  48. package/dist/_chunks/{NoPermissionsPage-DdyOfdKb.js → NoPermissionsPage-Oy4tmUrW.js} +2 -2
  49. package/dist/_chunks/{NoPermissionsPage-DdyOfdKb.js.map → NoPermissionsPage-Oy4tmUrW.js.map} +1 -1
  50. package/dist/_chunks/{Relations-DjFiYd7-.mjs → Relations-BBmhcWFV.mjs} +132 -89
  51. package/dist/_chunks/Relations-BBmhcWFV.mjs.map +1 -0
  52. package/dist/_chunks/{Relations-CY8Isqdu.js → Relations-eG-9p_qS.js} +135 -93
  53. package/dist/_chunks/Relations-eG-9p_qS.js.map +1 -0
  54. package/dist/_chunks/{en-C-V1_90f.js → en-Bm0D0IWz.js} +23 -15
  55. package/dist/_chunks/{en-C-V1_90f.js.map → en-Bm0D0IWz.js.map} +1 -1
  56. package/dist/_chunks/{en-MBPul9Su.mjs → en-DKV44jRb.mjs} +23 -15
  57. package/dist/_chunks/{en-MBPul9Su.mjs.map → en-DKV44jRb.mjs.map} +1 -1
  58. package/dist/_chunks/{index-DNa1J4HE.js → index-BIWDoFLK.js} +1877 -939
  59. package/dist/_chunks/index-BIWDoFLK.js.map +1 -0
  60. package/dist/_chunks/{index-CAc9yTnx.mjs → index-BrUzbQ30.mjs} +1902 -964
  61. package/dist/_chunks/index-BrUzbQ30.mjs.map +1 -0
  62. package/dist/_chunks/{layout-CXsHbc3E.mjs → layout-_5-cXs34.mjs} +45 -27
  63. package/dist/_chunks/layout-_5-cXs34.mjs.map +1 -0
  64. package/dist/_chunks/{layout-BqtLA6Lb.js → layout-lMc9i1-Z.js} +45 -29
  65. package/dist/_chunks/layout-lMc9i1-Z.js.map +1 -0
  66. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  67. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  68. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  69. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  70. package/dist/_chunks/{relations-BHY_KDJ_.js → relations-BRHithi8.js} +3 -7
  71. package/dist/_chunks/relations-BRHithi8.js.map +1 -0
  72. package/dist/_chunks/{relations-mMFEcZRq.mjs → relations-B_VLk-DD.mjs} +3 -7
  73. package/dist/_chunks/relations-B_VLk-DD.mjs.map +1 -0
  74. package/dist/_chunks/useDebounce-CtcjDB3L.js +28 -0
  75. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +1 -0
  76. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +29 -0
  77. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +1 -0
  78. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -1
  79. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -1
  80. package/dist/admin/index.js +3 -1
  81. package/dist/admin/index.js.map +1 -1
  82. package/dist/admin/index.mjs +9 -7
  83. package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
  84. package/dist/admin/src/content-manager.d.ts +3 -3
  85. package/dist/admin/src/exports.d.ts +2 -1
  86. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  87. package/dist/admin/src/history/index.d.ts +3 -0
  88. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  89. package/dist/admin/src/hooks/useDocument.d.ts +37 -9
  90. package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
  91. package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
  92. package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
  93. package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
  94. package/dist/admin/src/index.d.ts +1 -0
  95. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +11 -4
  96. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
  97. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  98. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
  99. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
  100. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
  101. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +30 -18
  102. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
  103. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
  104. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +2 -2
  105. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygFooter.d.ts +2 -2
  106. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +16 -53
  107. package/dist/admin/src/pages/EditView/components/Header.d.ts +11 -11
  108. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
  109. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  110. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  111. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
  112. package/dist/admin/src/preview/constants.d.ts +1 -0
  113. package/dist/admin/src/preview/index.d.ts +4 -0
  114. package/dist/admin/src/services/api.d.ts +2 -3
  115. package/dist/admin/src/services/components.d.ts +2 -2
  116. package/dist/admin/src/services/contentTypes.d.ts +5 -5
  117. package/dist/admin/src/services/documents.d.ts +31 -17
  118. package/dist/admin/src/services/init.d.ts +2 -2
  119. package/dist/admin/src/services/relations.d.ts +3 -3
  120. package/dist/admin/src/services/uid.d.ts +3 -3
  121. package/dist/admin/src/utils/api.d.ts +4 -18
  122. package/dist/admin/src/utils/validation.d.ts +5 -7
  123. package/dist/server/index.js +571 -312
  124. package/dist/server/index.js.map +1 -1
  125. package/dist/server/index.mjs +573 -314
  126. package/dist/server/index.mjs.map +1 -1
  127. package/dist/server/src/bootstrap.d.ts.map +1 -1
  128. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  129. package/dist/server/src/controllers/index.d.ts.map +1 -1
  130. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  131. package/dist/server/src/controllers/single-types.d.ts.map +1 -1
  132. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  133. package/dist/server/src/controllers/utils/metadata.d.ts +22 -0
  134. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
  135. package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
  136. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
  137. package/dist/server/src/controllers/validation/index.d.ts +1 -1
  138. package/dist/server/src/history/services/history.d.ts.map +1 -1
  139. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  140. package/dist/server/src/history/services/utils.d.ts +2 -1
  141. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  142. package/dist/server/src/index.d.ts +20 -36
  143. package/dist/server/src/index.d.ts.map +1 -1
  144. package/dist/server/src/policies/hasPermissions.d.ts.map +1 -1
  145. package/dist/server/src/preview/constants.d.ts +2 -0
  146. package/dist/server/src/preview/constants.d.ts.map +1 -0
  147. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  148. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  149. package/dist/server/src/preview/controllers/preview.d.ts +9 -0
  150. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  151. package/dist/server/src/preview/index.d.ts +4 -0
  152. package/dist/server/src/preview/index.d.ts.map +1 -0
  153. package/dist/server/src/preview/routes/index.d.ts +8 -0
  154. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  155. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  156. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  157. package/dist/server/src/preview/services/index.d.ts +4 -0
  158. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  159. package/dist/server/src/preview/services/preview.d.ts +6 -0
  160. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  161. package/dist/server/src/preview/utils.d.ts +7 -0
  162. package/dist/server/src/preview/utils.d.ts.map +1 -0
  163. package/dist/server/src/routes/index.d.ts.map +1 -1
  164. package/dist/server/src/services/document-manager.d.ts +11 -6
  165. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  166. package/dist/server/src/services/document-metadata.d.ts +14 -35
  167. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  168. package/dist/server/src/services/index.d.ts +20 -36
  169. package/dist/server/src/services/index.d.ts.map +1 -1
  170. package/dist/server/src/services/permission-checker.d.ts.map +1 -1
  171. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  172. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  173. package/dist/server/src/services/utils/populate.d.ts +8 -1
  174. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  175. package/dist/server/src/utils/index.d.ts +2 -0
  176. package/dist/server/src/utils/index.d.ts.map +1 -1
  177. package/dist/shared/contracts/collection-types.d.ts +17 -7
  178. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  179. package/dist/shared/contracts/relations.d.ts +2 -2
  180. package/dist/shared/contracts/relations.d.ts.map +1 -1
  181. package/package.json +17 -18
  182. package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
  183. package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
  184. package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
  185. package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
  186. package/dist/_chunks/EditViewPage-KRG56aCq.js.map +0 -1
  187. package/dist/_chunks/EditViewPage-aUnqL-63.mjs.map +0 -1
  188. package/dist/_chunks/Field-kVFO4ZKB.mjs.map +0 -1
  189. package/dist/_chunks/Field-kq1c2TF1.js.map +0 -1
  190. package/dist/_chunks/Form-CQ67ZifP.js.map +0 -1
  191. package/dist/_chunks/Form-Jgh5hGTu.mjs.map +0 -1
  192. package/dist/_chunks/History-BLEnudTX.js.map +0 -1
  193. package/dist/_chunks/History-DKhZAPcK.mjs.map +0 -1
  194. package/dist/_chunks/ListConfigurationPage-Zso_LUjn.js.map +0 -1
  195. package/dist/_chunks/ListConfigurationPage-nrXcxNYi.mjs.map +0 -1
  196. package/dist/_chunks/ListViewPage-ChhYmA-L.mjs.map +0 -1
  197. package/dist/_chunks/ListViewPage-DsaOakWQ.js.map +0 -1
  198. package/dist/_chunks/NoContentTypePage-BrdFcN33.mjs.map +0 -1
  199. package/dist/_chunks/NoContentTypePage-DPCuS9Y1.js.map +0 -1
  200. package/dist/_chunks/Relations-CY8Isqdu.js.map +0 -1
  201. package/dist/_chunks/Relations-DjFiYd7-.mjs.map +0 -1
  202. package/dist/_chunks/index-CAc9yTnx.mjs.map +0 -1
  203. package/dist/_chunks/index-DNa1J4HE.js.map +0 -1
  204. package/dist/_chunks/layout-BqtLA6Lb.js.map +0 -1
  205. package/dist/_chunks/layout-CXsHbc3E.mjs.map +0 -1
  206. package/dist/_chunks/relations-BHY_KDJ_.js.map +0 -1
  207. package/dist/_chunks/relations-mMFEcZRq.mjs.map +0 -1
  208. package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
  209. package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
  210. package/dist/_chunks/urls-DzZya_gm.js +0 -6
  211. package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
  212. package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
  213. package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
  214. package/strapi-server.js +0 -3
@@ -1,25 +1,25 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
- import { useState, useEffect, useCallback } from "react";
3
+ import { useState, useEffect, useCallback, memo } from "react";
4
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, FieldLabel, FieldInput, Tooltip, SingleSelect, SingleSelectOption, IconButton, Portal, FocusTrap, InputWrapper, Divider, VisuallyHidden, FieldHint, FieldError, Grid as Grid$1, GridItem, TextButton, KeyboardNavigable, Accordion, AccordionToggle, AccordionContent as AccordionContent$1, BaseButton, TextInput, FieldAction, IconButtonGroup, Menu, MenuItem } from "@strapi/design-system";
5
+ import { Box, SingleSelect, SingleSelectOption, Typography, Flex, BaseLink, Button, Popover, Field, Tooltip, IconButton, useComposedRefs, Portal, FocusTrap, Divider, VisuallyHidden, Grid as Grid$1, Accordion, TextButton, TextInput, IconButtonGroup, Menu, MenuItem } from "@strapi/design-system";
6
6
  import pipe$1 from "lodash/fp/pipe";
7
7
  import { useIntl } from "react-intl";
8
- import { l as DOCUMENT_META_FIELDS, g as getTranslation, b as useDoc, d as contentManagerApi, c as buildValidParams, e as useDocumentRBAC, m as useDocLayout } from "./index-CAc9yTnx.mjs";
8
+ import { m as DOCUMENT_META_FIELDS, g as getTranslation, c as useDoc, e as contentManagerApi, n as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, S as SINGLE_TYPES, o as useDocLayout } from "./index-BrUzbQ30.mjs";
9
9
  import { generateNKeysBetween } from "fractional-indexing";
10
- import { u as useComponent, C as ComponentProvider, R as RelationsField } from "./Relations-DjFiYd7-.mjs";
10
+ import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-BBmhcWFV.mjs";
11
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";
12
- import styled, { css, keyframes } from "styled-components";
13
- import { C as ComponentIcon } from "./ComponentIcon-BOFnK76n.mjs";
12
+ import { styled, css, keyframes } from "styled-components";
13
+ import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
14
14
  import { getEmptyImage } from "react-dnd-html5-backend";
15
15
  import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DdHgKsqq.mjs";
16
- import { g as getIn } from "./objects-mKMAmfec.mjs";
16
+ import { g as getIn } from "./objects-D6yBsdmx.mjs";
17
17
  import { Editor as Editor$1, Transforms, Node, Element, Range, Path, Point, createEditor } from "slate";
18
18
  import { withHistory } from "slate-history";
19
19
  import { useFocused, useSelected, ReactEditor, Editable, useSlate, Slate, withReact } from "slate-react";
20
- import { p as prefixFileUrlWithBackendUrl } from "./urls-CbOsUOoW.mjs";
20
+ import { p as prefixFileUrlWithBackendUrl, u as usePrev, a as useDebounce } from "./useDebounce-DmuSJIF3.mjs";
21
21
  import * as Toolbar from "@radix-ui/react-toolbar";
22
- import { useLocation } from "react-router-dom";
22
+ import { useLocation, useMatch } from "react-router-dom";
23
23
  import CodeMirror from "codemirror5";
24
24
  import sanitizeHtml from "sanitize-html";
25
25
  import { getLanguage, highlight, highlightAuto } from "highlight.js";
@@ -160,6 +160,220 @@ const useLazyComponents = (componentUids = []) => {
160
160
  }, []);
161
161
  return { isLazyLoading: loading, lazyComponentStore, cleanup };
162
162
  };
163
+ const codeLanguages = [
164
+ {
165
+ value: "asm",
166
+ label: "Assembly"
167
+ },
168
+ {
169
+ value: "bash",
170
+ label: "Bash"
171
+ },
172
+ {
173
+ value: "c",
174
+ label: "C"
175
+ },
176
+ {
177
+ value: "clojure",
178
+ label: "Clojure"
179
+ },
180
+ {
181
+ value: "cobol",
182
+ label: "COBOL"
183
+ },
184
+ {
185
+ value: "cpp",
186
+ label: "C++"
187
+ },
188
+ {
189
+ value: "csharp",
190
+ label: "C#"
191
+ },
192
+ {
193
+ value: "css",
194
+ label: "CSS"
195
+ },
196
+ {
197
+ value: "dart",
198
+ label: "Dart"
199
+ },
200
+ {
201
+ value: "dockerfile",
202
+ label: "Dockerfile"
203
+ },
204
+ {
205
+ value: "elixir",
206
+ label: "Elixir"
207
+ },
208
+ {
209
+ value: "erlang",
210
+ label: "Erlang"
211
+ },
212
+ {
213
+ value: "fortran",
214
+ label: "Fortran"
215
+ },
216
+ {
217
+ value: "fsharp",
218
+ label: "F#"
219
+ },
220
+ {
221
+ value: "go",
222
+ label: "Go"
223
+ },
224
+ {
225
+ value: "graphql",
226
+ label: "GraphQL"
227
+ },
228
+ {
229
+ value: "groovy",
230
+ label: "Groovy"
231
+ },
232
+ {
233
+ value: "haskell",
234
+ label: "Haskell"
235
+ },
236
+ {
237
+ value: "haxe",
238
+ label: "Haxe"
239
+ },
240
+ {
241
+ value: "html",
242
+ label: "HTML"
243
+ },
244
+ {
245
+ value: "ini",
246
+ label: "INI"
247
+ },
248
+ {
249
+ value: "java",
250
+ label: "Java"
251
+ },
252
+ {
253
+ value: "javascript",
254
+ label: "JavaScript"
255
+ },
256
+ {
257
+ value: "jsx",
258
+ label: "JavaScript (React)"
259
+ },
260
+ {
261
+ value: "json",
262
+ label: "JSON"
263
+ },
264
+ {
265
+ value: "julia",
266
+ label: "Julia"
267
+ },
268
+ {
269
+ value: "kotlin",
270
+ label: "Kotlin"
271
+ },
272
+ {
273
+ value: "latex",
274
+ label: "LaTeX"
275
+ },
276
+ {
277
+ value: "lua",
278
+ label: "Lua"
279
+ },
280
+ {
281
+ value: "markdown",
282
+ label: "Markdown"
283
+ },
284
+ {
285
+ value: "matlab",
286
+ label: "MATLAB"
287
+ },
288
+ {
289
+ value: "makefile",
290
+ label: "Makefile"
291
+ },
292
+ {
293
+ value: "objectivec",
294
+ label: "Objective-C"
295
+ },
296
+ {
297
+ value: "perl",
298
+ label: "Perl"
299
+ },
300
+ {
301
+ value: "php",
302
+ label: "PHP"
303
+ },
304
+ {
305
+ value: "plaintext",
306
+ label: "Plain text"
307
+ },
308
+ {
309
+ value: "powershell",
310
+ label: "PowerShell"
311
+ },
312
+ {
313
+ value: "python",
314
+ label: "Python"
315
+ },
316
+ {
317
+ value: "r",
318
+ label: "R"
319
+ },
320
+ {
321
+ value: "ruby",
322
+ label: "Ruby"
323
+ },
324
+ {
325
+ value: "rust",
326
+ label: "Rust"
327
+ },
328
+ {
329
+ value: "sas",
330
+ label: "SAS"
331
+ },
332
+ {
333
+ value: "scala",
334
+ label: "Scala"
335
+ },
336
+ {
337
+ value: "scheme",
338
+ label: "Scheme"
339
+ },
340
+ {
341
+ value: "shell",
342
+ label: "Shell"
343
+ },
344
+ {
345
+ value: "sql",
346
+ label: "SQL"
347
+ },
348
+ {
349
+ value: "stata",
350
+ label: "Stata"
351
+ },
352
+ {
353
+ value: "swift",
354
+ label: "Swift"
355
+ },
356
+ {
357
+ value: "typescript",
358
+ label: "TypeScript"
359
+ },
360
+ {
361
+ value: "tsx",
362
+ label: "TypeScript (React)"
363
+ },
364
+ {
365
+ value: "vbnet",
366
+ label: "VB.NET"
367
+ },
368
+ {
369
+ value: "xml",
370
+ label: "XML"
371
+ },
372
+ {
373
+ value: "yaml",
374
+ label: "YAML"
375
+ }
376
+ ];
163
377
  const baseHandleConvert = (editor, attributesToSet) => {
164
378
  const [_, lastNodePath] = Editor$1.last(editor, []);
165
379
  Transforms.unwrapNodes(editor, {
@@ -223,13 +437,14 @@ const pressEnterTwiceToExit = (editor) => {
223
437
  });
224
438
  }
225
439
  };
226
- const CodeBlock = styled.pre.attrs({ role: "code" })`
440
+ const CodeBlock = styled.pre`
227
441
  border-radius: ${({ theme }) => theme.borderRadius};
228
442
  background-color: ${({ theme }) => theme.colors.neutral100};
229
443
  max-width: 100%;
230
444
  overflow: auto;
231
445
  padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};
232
446
  flex-shrink: 1;
447
+
233
448
  & > code {
234
449
  font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,
235
450
  monospace;
@@ -238,9 +453,61 @@ const CodeBlock = styled.pre.attrs({ role: "code" })`
238
453
  max-width: 100%;
239
454
  }
240
455
  `;
456
+ const CodeEditor = (props) => {
457
+ const { editor } = useBlocksEditorContext("ImageDialog");
458
+ const editorIsFocused = useFocused();
459
+ const imageIsSelected = useSelected();
460
+ const { formatMessage } = useIntl();
461
+ const [isSelectOpen, setIsSelectOpen] = React.useState(false);
462
+ const shouldDisplayLanguageSelect = editorIsFocused && imageIsSelected || isSelectOpen;
463
+ return /* @__PURE__ */ jsxs(Box, { position: "relative", width: "100%", children: [
464
+ /* @__PURE__ */ jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsx("code", { children: props.children }) }),
465
+ shouldDisplayLanguageSelect && /* @__PURE__ */ jsx(
466
+ Box,
467
+ {
468
+ position: "absolute",
469
+ background: "neutral0",
470
+ borderColor: "neutral150",
471
+ borderStyle: "solid",
472
+ borderWidth: "0.5px",
473
+ shadow: "tableShadow",
474
+ top: "100%",
475
+ marginTop: 1,
476
+ right: 0,
477
+ padding: 1,
478
+ hasRadius: true,
479
+ children: /* @__PURE__ */ jsx(
480
+ SingleSelect,
481
+ {
482
+ onChange: (open) => {
483
+ Transforms.setNodes(
484
+ editor,
485
+ { language: open.toString() },
486
+ { match: (node) => !Editor$1.isEditor(node) && node.type === "code" }
487
+ );
488
+ },
489
+ value: props.element.type === "code" && props.element.language || "plaintext",
490
+ onOpenChange: (open) => {
491
+ setIsSelectOpen(open);
492
+ if (!open) {
493
+ ReactEditor.focus(editor);
494
+ }
495
+ },
496
+ onCloseAutoFocus: (e) => e.preventDefault(),
497
+ "aria-label": formatMessage({
498
+ id: "components.Blocks.blocks.code.languageLabel",
499
+ defaultMessage: "Select a language"
500
+ }),
501
+ children: codeLanguages.map(({ value, label }) => /* @__PURE__ */ jsx(SingleSelectOption, { value, children: label }, value))
502
+ }
503
+ )
504
+ }
505
+ )
506
+ ] });
507
+ };
241
508
  const codeBlocks = {
242
509
  code: {
243
- renderElement: (props) => /* @__PURE__ */ jsx(CodeBlock, { ...props.attributes, children: /* @__PURE__ */ jsx("code", { children: props.children }) }),
510
+ renderElement: (props) => /* @__PURE__ */ jsx(CodeEditor, { ...props }),
244
511
  icon: Code,
245
512
  label: {
246
513
  id: "components.Blocks.blocks.code",
@@ -249,7 +516,7 @@ const codeBlocks = {
249
516
  matchNode: (node) => node.type === "code",
250
517
  isInBlocksSelector: true,
251
518
  handleConvert(editor) {
252
- baseHandleConvert(editor, { type: "code" });
519
+ baseHandleConvert(editor, { type: "code", language: "plaintext" });
253
520
  },
254
521
  handleEnterKey(editor) {
255
522
  pressEnterTwiceToExit(editor);
@@ -258,27 +525,27 @@ const codeBlocks = {
258
525
  dragHandleTopMargin: "10px"
259
526
  }
260
527
  };
261
- const H1 = styled(Typography).attrs({ as: "h1" })`
528
+ const H1 = styled(Typography).attrs({ tag: "h1" })`
262
529
  font-size: 4.2rem;
263
530
  line-height: ${({ theme }) => theme.lineHeights[1]};
264
531
  `;
265
- const H2 = styled(Typography).attrs({ as: "h2" })`
532
+ const H2 = styled(Typography).attrs({ tag: "h2" })`
266
533
  font-size: 3.5rem;
267
534
  line-height: ${({ theme }) => theme.lineHeights[1]};
268
535
  `;
269
- const H3 = styled(Typography).attrs({ as: "h3" })`
536
+ const H3 = styled(Typography).attrs({ tag: "h3" })`
270
537
  font-size: 2.9rem;
271
538
  line-height: ${({ theme }) => theme.lineHeights[1]};
272
539
  `;
273
- const H4 = styled(Typography).attrs({ as: "h4" })`
540
+ const H4 = styled(Typography).attrs({ tag: "h4" })`
274
541
  font-size: 2.4rem;
275
542
  line-height: ${({ theme }) => theme.lineHeights[1]};
276
543
  `;
277
- const H5 = styled(Typography).attrs({ as: "h5" })`
544
+ const H5 = styled(Typography).attrs({ tag: "h5" })`
278
545
  font-size: 2rem;
279
546
  line-height: ${({ theme }) => theme.lineHeights[1]};
280
547
  `;
281
- const H6 = styled(Typography).attrs({ as: "h6" })`
548
+ const H6 = styled(Typography).attrs({ tag: "h6" })`
282
549
  font-size: 1.6rem;
283
550
  line-height: ${({ theme }) => theme.lineHeights[1]};
284
551
  `;
@@ -367,7 +634,7 @@ const headingBlocks = {
367
634
  const ImageWrapper = styled(Flex)`
368
635
  transition-property: box-shadow;
369
636
  transition-duration: 0.2s;
370
- ${(props) => props.isFocused && css`
637
+ ${(props) => props.$isFocused && css`
371
638
  box-shadow: ${props.theme.colors.primary600} 0px 0px 0px 3px;
372
639
  `}
373
640
 
@@ -419,7 +686,7 @@ const Image = ({ attributes, children, element }) => {
419
686
  background: "neutral100",
420
687
  contentEditable: false,
421
688
  justifyContent: "center",
422
- isFocused: editorIsFocused && imageIsSelected,
689
+ $isFocused: editorIsFocused && imageIsSelected,
423
690
  hasRadius: true,
424
691
  children: /* @__PURE__ */ jsx("img", { src: url, alt: alternativeText, width, height })
425
692
  }
@@ -579,7 +846,7 @@ const StyledBaseLink = styled(BaseLink)`
579
846
  text-decoration: none;
580
847
  `;
581
848
  const RemoveButton = styled(Button)`
582
- visibility: ${(props) => props.visible ? "visible" : "hidden"};
849
+ visibility: ${(props) => props.$visible ? "visible" : "hidden"};
583
850
  `;
584
851
  const LinkContent = React.forwardRef(
585
852
  ({ link, children, attributes }, forwardedRef) => {
@@ -589,18 +856,12 @@ const LinkContent = React.forwardRef(
589
856
  const [popoverOpen, setPopoverOpen] = React.useState(
590
857
  editor.lastInsertedLinkPath ? Path.equals(path, editor.lastInsertedLinkPath) : false
591
858
  );
592
- const linkRef = React.useRef(null);
593
859
  const elementText = link.children.map((child) => child.text).join("");
594
860
  const [linkText, setLinkText] = React.useState(elementText);
595
861
  const [linkUrl, setLinkUrl] = React.useState(link.url);
596
862
  const linkInputRef = React.useRef(null);
597
- const [showRemoveButton, setShowRemoveButton] = React.useState(false);
863
+ const isLastInsertedLink = editor.lastInsertedLinkPath ? !Path.equals(path, editor.lastInsertedLinkPath) : true;
598
864
  const [isSaveDisabled, setIsSaveDisabled] = React.useState(false);
599
- const handleOpenEditPopover = (e) => {
600
- e.preventDefault();
601
- setPopoverOpen(true);
602
- setShowRemoveButton(true);
603
- };
604
865
  const onLinkChange = (e) => {
605
866
  setIsSaveDisabled(false);
606
867
  setLinkUrl(e.target.value);
@@ -621,40 +882,40 @@ const LinkContent = React.forwardRef(
621
882
  editLink(editor, { url: linkUrl, text: linkText });
622
883
  setPopoverOpen(false);
623
884
  editor.lastInsertedLinkPath = null;
885
+ ReactEditor.focus(editor);
624
886
  };
625
- const handleDismiss = () => {
626
- setPopoverOpen(false);
887
+ const handleClose = () => {
627
888
  if (link.url === "") {
628
889
  removeLink(editor);
629
890
  }
891
+ setPopoverOpen(false);
630
892
  ReactEditor.focus(editor);
631
893
  };
632
- const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
633
- const composedRefs = useComposedRefs(linkRef, forwardedRef);
634
894
  React.useEffect(() => {
635
895
  if (popoverOpen)
636
896
  linkInputRef.current?.focus();
637
897
  }, [popoverOpen]);
638
- return /* @__PURE__ */ jsxs(Fragment, { children: [
639
- /* @__PURE__ */ jsx(
898
+ const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
899
+ return /* @__PURE__ */ jsxs(Popover.Root, { open: popoverOpen, children: [
900
+ /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(
640
901
  StyledBaseLink,
641
902
  {
642
903
  ...attributes,
643
- ref: composedRefs,
904
+ ref: forwardedRef,
644
905
  href: link.url,
645
- onClick: handleOpenEditPopover,
906
+ onClick: () => setPopoverOpen(true),
646
907
  color: "primary600",
647
908
  children
648
909
  }
649
- ),
650
- popoverOpen && /* @__PURE__ */ jsx(Popover, { source: linkRef, onDismiss: handleDismiss, padding: 4, contentEditable: false, children: /* @__PURE__ */ jsxs(Flex, { as: "form", onSubmit: handleSave, direction: "column", gap: 4, children: [
651
- /* @__PURE__ */ jsx(Field, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
652
- /* @__PURE__ */ jsx(FieldLabel, { children: formatMessage({
910
+ ) }),
911
+ /* @__PURE__ */ jsx(Popover.Content, { onPointerDownOutside: handleClose, children: /* @__PURE__ */ jsxs(Flex, { padding: 4, direction: "column", gap: 4, children: [
912
+ /* @__PURE__ */ jsx(Field.Root, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
913
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
653
914
  id: "components.Blocks.popover.text",
654
915
  defaultMessage: "Text"
655
916
  }) }),
656
917
  /* @__PURE__ */ jsx(
657
- FieldInput,
918
+ Field.Input,
658
919
  {
659
920
  name: "text",
660
921
  placeholder: formatMessage({
@@ -668,13 +929,13 @@ const LinkContent = React.forwardRef(
668
929
  }
669
930
  )
670
931
  ] }) }),
671
- /* @__PURE__ */ jsx(Field, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
672
- /* @__PURE__ */ jsx(FieldLabel, { children: formatMessage({
932
+ /* @__PURE__ */ jsx(Field.Root, { width: "368px", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "stretch", children: [
933
+ /* @__PURE__ */ jsx(Field.Label, { children: formatMessage({
673
934
  id: "components.Blocks.popover.link",
674
935
  defaultMessage: "Link"
675
936
  }) }),
676
937
  /* @__PURE__ */ jsx(
677
- FieldInput,
938
+ Field.Input,
678
939
  {
679
940
  ref: linkInputRef,
680
941
  name: "url",
@@ -693,7 +954,7 @@ const LinkContent = React.forwardRef(
693
954
  {
694
955
  variant: "danger-light",
695
956
  onClick: () => removeLink(editor),
696
- visible: showRemoveButton,
957
+ $visible: isLastInsertedLink,
697
958
  children: formatMessage({
698
959
  id: "components.Blocks.popover.remove",
699
960
  defaultMessage: "Remove"
@@ -701,11 +962,11 @@ const LinkContent = React.forwardRef(
701
962
  }
702
963
  ),
703
964
  /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
704
- /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: handleDismiss, children: formatMessage({
965
+ /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
705
966
  id: "components.Blocks.popover.cancel",
706
967
  defaultMessage: "Cancel"
707
968
  }) }),
708
- /* @__PURE__ */ jsx(Button, { type: "submit", disabled: Boolean(inputNotDirty) || isSaveDisabled, children: formatMessage({
969
+ /* @__PURE__ */ jsx(Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
709
970
  id: "components.Blocks.popover.save",
710
971
  defaultMessage: "Save"
711
972
  }) })
@@ -748,11 +1009,11 @@ const listStyle = css`
748
1009
  }
749
1010
  `;
750
1011
  const Orderedlist = styled.ol`
751
- list-style-type: ${(props) => props.listStyleType};
1012
+ list-style-type: ${(props) => props.$listStyleType};
752
1013
  ${listStyle}
753
1014
  `;
754
1015
  const Unorderedlist = styled.ul`
755
- list-style-type: ${(props) => props.listStyleType};
1016
+ list-style-type: ${(props) => props.$listStyleType};
756
1017
  ${listStyle}
757
1018
  `;
758
1019
  const orderedStyles = ["decimal", "lower-alpha", "upper-roman"];
@@ -765,9 +1026,9 @@ const List = ({ attributes, children, element }) => {
765
1026
  const nextIndex = (element.indentLevel || 0) % listStyles.length;
766
1027
  const listStyleType = listStyles[nextIndex];
767
1028
  if (element.format === "ordered") {
768
- return /* @__PURE__ */ jsx(Orderedlist, { listStyleType, ...attributes, children });
1029
+ return /* @__PURE__ */ jsx(Orderedlist, { $listStyleType: listStyleType, ...attributes, children });
769
1030
  }
770
- return /* @__PURE__ */ jsx(Unorderedlist, { listStyleType, ...attributes, children });
1031
+ return /* @__PURE__ */ jsx(Unorderedlist, { $listStyleType: listStyleType, ...attributes, children });
771
1032
  };
772
1033
  const replaceListWithEmptyBlock = (editor, currentListPath) => {
773
1034
  Transforms.removeNodes(editor, { at: currentListPath });
@@ -964,7 +1225,7 @@ const listBlocks = {
964
1225
  snippets: ["-", "*", "+"]
965
1226
  },
966
1227
  "list-item": {
967
- renderElement: (props) => /* @__PURE__ */ jsx(Typography, { as: "li", ...props.attributes, children: props.children }),
1228
+ renderElement: (props) => /* @__PURE__ */ jsx(Typography, { tag: "li", ...props.attributes, children: props.children }),
968
1229
  // No handleConvert, list items are created when converting to the parent list
969
1230
  matchNode: (node) => node.type === "list-item",
970
1231
  isInBlocksSelector: false,
@@ -973,7 +1234,7 @@ const listBlocks = {
973
1234
  };
974
1235
  const paragraphBlocks = {
975
1236
  paragraph: {
976
- renderElement: (props) => /* @__PURE__ */ jsx(Typography, { as: "p", variant: "omega", ...props.attributes, children: props.children }),
1237
+ renderElement: (props) => /* @__PURE__ */ jsx(Typography, { tag: "p", variant: "omega", ...props.attributes, children: props.children }),
977
1238
  icon: Paragraph,
978
1239
  label: {
979
1240
  id: "components.Blocks.blocks.text",
@@ -1139,14 +1400,14 @@ const ToolbarButton = ({
1139
1400
  children: /* @__PURE__ */ jsx(
1140
1401
  FlexButton,
1141
1402
  {
1142
- as: "button",
1403
+ tag: "button",
1143
1404
  background: isActive ? "primary100" : "",
1144
1405
  alignItems: "center",
1145
1406
  justifyContent: "center",
1146
1407
  width: 7,
1147
1408
  height: 7,
1148
1409
  hasRadius: true,
1149
- children: /* @__PURE__ */ jsx(Icon, { width: "1.2rem", height: "1.2rem", fill: disabled ? "neutral300" : enabledColor })
1410
+ children: /* @__PURE__ */ jsx(Icon, { fill: disabled ? "neutral300" : enabledColor })
1150
1411
  }
1151
1412
  )
1152
1413
  }
@@ -1291,6 +1552,26 @@ const ListButton = ({ block, format }) => {
1291
1552
  }
1292
1553
  return false;
1293
1554
  };
1555
+ const isListDisabled = () => {
1556
+ if (disabled) {
1557
+ return true;
1558
+ }
1559
+ if (!editor.selection) {
1560
+ return false;
1561
+ }
1562
+ const anchorNodeEntry = Editor$1.above(editor, {
1563
+ at: editor.selection.anchor,
1564
+ match: (node) => !Editor$1.isEditor(node) && node.type !== "text"
1565
+ });
1566
+ const focusNodeEntry = Editor$1.above(editor, {
1567
+ at: editor.selection.focus,
1568
+ match: (node) => !Editor$1.isEditor(node) && node.type !== "text"
1569
+ });
1570
+ if (!anchorNodeEntry || !focusNodeEntry) {
1571
+ return false;
1572
+ }
1573
+ return anchorNodeEntry[0] !== focusNodeEntry[0];
1574
+ };
1294
1575
  const toggleList = (format2) => {
1295
1576
  let currentListEntry;
1296
1577
  if (editor.selection) {
@@ -1324,7 +1605,7 @@ const ListButton = ({ block, format }) => {
1324
1605
  name: format,
1325
1606
  label: block.label,
1326
1607
  isActive: isListActive(),
1327
- disabled,
1608
+ disabled: isListDisabled(),
1328
1609
  handleClick: () => toggleList(format)
1329
1610
  }
1330
1611
  );
@@ -1460,7 +1741,7 @@ const DragItem = styled(Flex)`
1460
1741
 
1461
1742
  // Set the visibility of drag button
1462
1743
  [role='button'] {
1463
- visibility: ${(props) => props.dragVisibility};
1744
+ visibility: ${(props) => props.$dragVisibility};
1464
1745
  opacity: inherit;
1465
1746
  }
1466
1747
  &[aria-disabled='true'] {
@@ -1468,6 +1749,7 @@ const DragItem = styled(Flex)`
1468
1749
  }
1469
1750
  `;
1470
1751
  const DragIconButton = styled(IconButton)`
1752
+ user-select: none;
1471
1753
  display: flex;
1472
1754
  align-items: center;
1473
1755
  justify-content: center;
@@ -1477,7 +1759,7 @@ const DragIconButton = styled(IconButton)`
1477
1759
  visibility: hidden;
1478
1760
  cursor: grab;
1479
1761
  opacity: inherit;
1480
- margin-top: ${(props) => props.dragHandleTopMargin ?? 0};
1762
+ margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
1481
1763
 
1482
1764
  &:hover {
1483
1765
  background: ${({ theme }) => theme.colors.neutral200};
@@ -1491,7 +1773,7 @@ const DragIconButton = styled(IconButton)`
1491
1773
  }
1492
1774
  svg {
1493
1775
  height: auto;
1494
- width: ${({ theme }) => theme.spaces[3]};
1776
+ min-width: ${({ theme }) => theme.spaces[3]};
1495
1777
 
1496
1778
  path {
1497
1779
  fill: ${({ theme }) => theme.colors.neutral700};
@@ -1552,7 +1834,7 @@ const DragAndDropElement = ({
1552
1834
  React.useEffect(() => {
1553
1835
  setDragVisibility("hidden");
1554
1836
  }, [editor.selection]);
1555
- return /* @__PURE__ */ jsxs(Wrapper$1, { ref: (ref) => composedBoxRefs(ref), isOverDropTarget, children: [
1837
+ return /* @__PURE__ */ jsxs(Wrapper$1, { ref: composedBoxRefs, isOverDropTarget, children: [
1556
1838
  isOverDropTarget && /* @__PURE__ */ jsx(
1557
1839
  DropPlaceholder,
1558
1840
  {
@@ -1590,15 +1872,17 @@ const DragAndDropElement = ({
1590
1872
  onSelect: () => setDragVisibility("visible"),
1591
1873
  onMouseLeave: () => setDragVisibility("hidden"),
1592
1874
  "aria-disabled": disabled,
1593
- dragVisibility,
1875
+ $dragVisibility: dragVisibility,
1594
1876
  children: [
1595
1877
  /* @__PURE__ */ jsx(
1596
1878
  DragIconButton,
1597
1879
  {
1598
- forwardedAs: "div",
1880
+ tag: "div",
1881
+ contentEditable: false,
1599
1882
  role: "button",
1600
1883
  tabIndex: 0,
1601
- "aria-label": formatMessage({
1884
+ withTooltip: false,
1885
+ label: formatMessage({
1602
1886
  id: getTranslation("components.DragHandle-label"),
1603
1887
  defaultMessage: "Drag"
1604
1888
  }),
@@ -1606,8 +1890,8 @@ const DragAndDropElement = ({
1606
1890
  "aria-disabled": disabled,
1607
1891
  disabled,
1608
1892
  draggable: true,
1609
- dragHandleTopMargin,
1610
- children: /* @__PURE__ */ jsx(Drag, { color: "neutral600" })
1893
+ $dragHandleTopMargin: dragHandleTopMargin,
1894
+ children: /* @__PURE__ */ jsx(Drag, { color: "primary500" })
1611
1895
  }
1612
1896
  ),
1613
1897
  children
@@ -1618,17 +1902,18 @@ const DragAndDropElement = ({
1618
1902
  };
1619
1903
  const CloneDragItem = ({ children, dragHandleTopMargin }) => {
1620
1904
  const { formatMessage } = useIntl();
1621
- return /* @__PURE__ */ jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", dragVisibility: "visible", children: [
1905
+ return /* @__PURE__ */ jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", $dragVisibility: "visible", children: [
1622
1906
  /* @__PURE__ */ jsx(
1623
1907
  DragIconButton,
1624
1908
  {
1625
- forwardedAs: "div",
1909
+ tag: "div",
1626
1910
  role: "button",
1627
- "aria-label": formatMessage({
1911
+ withTooltip: false,
1912
+ label: formatMessage({
1628
1913
  id: getTranslation("components.DragHandle-label"),
1629
1914
  defaultMessage: "Drag"
1630
1915
  }),
1631
- dragHandleTopMargin,
1916
+ $dragHandleTopMargin: dragHandleTopMargin,
1632
1917
  children: /* @__PURE__ */ jsx(Drag, { color: "neutral600" })
1633
1918
  }
1634
1919
  ),
@@ -1930,7 +2215,7 @@ const EditorLayout$1 = ({
1930
2215
  /* @__PURE__ */ jsx(
1931
2216
  CollapseIconButton,
1932
2217
  {
1933
- "aria-label": formatMessage({
2218
+ label: formatMessage({
1934
2219
  id: getTranslation("components.Blocks.collapse"),
1935
2220
  defaultMessage: "Collapse"
1936
2221
  }),
@@ -1950,8 +2235,8 @@ const EditorLayout$1 = ({
1950
2235
  direction: "column",
1951
2236
  alignItems: "flex-start",
1952
2237
  height: "512px",
1953
- disabled,
1954
- hasError: Boolean(error),
2238
+ $disabled: disabled,
2239
+ $hasError: Boolean(error),
1955
2240
  style: { overflow: "hidden" },
1956
2241
  "aria-describedby": ariaDescriptionId,
1957
2242
  position: "relative",
@@ -1959,6 +2244,29 @@ const EditorLayout$1 = ({
1959
2244
  }
1960
2245
  );
1961
2246
  };
2247
+ const InputWrapper = styled(Flex)`
2248
+ border: 1px solid
2249
+ ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral200};
2250
+ border-radius: ${({ theme }) => theme.borderRadius};
2251
+ background: ${({ theme }) => theme.colors.neutral0};
2252
+
2253
+ ${({ theme, $hasError = false }) => css`
2254
+ outline: none;
2255
+ box-shadow: 0;
2256
+ transition-property: border-color, box-shadow, fill;
2257
+ transition-duration: 0.2s;
2258
+
2259
+ &:focus-within {
2260
+ border: 1px solid ${$hasError ? theme.colors.danger600 : theme.colors.primary600};
2261
+ box-shadow: ${$hasError ? theme.colors.danger600 : theme.colors.primary600} 0px 0px 0px 2px;
2262
+ }
2263
+ `}
2264
+
2265
+ ${({ theme, $disabled }) => $disabled ? css`
2266
+ color: ${theme.colors.neutral600};
2267
+ background: ${theme.colors.neutral150};
2268
+ ` : void 0}
2269
+ `;
1962
2270
  const stylesToInherit = css`
1963
2271
  font-size: inherit;
1964
2272
  color: inherit;
@@ -1971,10 +2279,14 @@ const ItalicText = styled(Typography)`
1971
2279
  font-style: italic;
1972
2280
  ${stylesToInherit}
1973
2281
  `;
1974
- const UnderlineText = styled(Typography).attrs({ textDecoration: "underline" })`
2282
+ const UnderlineText = styled(Typography).attrs({
2283
+ textDecoration: "underline"
2284
+ })`
1975
2285
  ${stylesToInherit}
1976
2286
  `;
1977
- const StrikeThroughText = styled(Typography).attrs({ textDecoration: "line-through" })`
2287
+ const StrikeThroughText = styled(Typography).attrs({
2288
+ textDecoration: "line-through"
2289
+ })`
1978
2290
  ${stylesToInherit}
1979
2291
  `;
1980
2292
  const InlineCode = styled.code`
@@ -2242,7 +2554,7 @@ const BlocksEditor = React.forwardRef(
2242
2554
  !isExpandedMode && /* @__PURE__ */ jsx(
2243
2555
  ExpandIconButton,
2244
2556
  {
2245
- "aria-label": formatMessage({
2557
+ label: formatMessage({
2246
2558
  id: getTranslation("components.Blocks.expand"),
2247
2559
  defaultMessage: "Expand"
2248
2560
  }),
@@ -2265,8 +2577,8 @@ const BlocksInput = React.forwardRef(
2265
2577
  ({ label, name: name2, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {
2266
2578
  const id = React.useId();
2267
2579
  const field = useField(name2);
2268
- return /* @__PURE__ */ jsx(Field, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
2269
- /* @__PURE__ */ jsx(FieldLabel, { action: labelAction, children: label }),
2580
+ return /* @__PURE__ */ jsx(Field.Root, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
2581
+ /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
2270
2582
  /* @__PURE__ */ jsx(
2271
2583
  BlocksEditor,
2272
2584
  {
@@ -2279,11 +2591,12 @@ const BlocksInput = React.forwardRef(
2279
2591
  ...editorProps
2280
2592
  }
2281
2593
  ),
2282
- /* @__PURE__ */ jsx(FieldHint, {}),
2283
- /* @__PURE__ */ jsx(FieldError, {})
2594
+ /* @__PURE__ */ jsx(Field.Hint, {}),
2595
+ /* @__PURE__ */ jsx(Field.Error, {})
2284
2596
  ] }) });
2285
2597
  }
2286
2598
  );
2599
+ const MemoizedBlocksInput = React.memo(BlocksInput);
2287
2600
  const createDefaultForm = (contentType, components = {}) => {
2288
2601
  const traverseSchema = (attributes) => {
2289
2602
  return Object.entries(attributes).reduce((acc, [key, attribute]) => {
@@ -2307,30 +2620,27 @@ const createDefaultForm = (contentType, components = {}) => {
2307
2620
  const Initializer = ({ disabled, name: name2, onClick }) => {
2308
2621
  const { formatMessage } = useIntl();
2309
2622
  const field = useField(name2);
2310
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2311
- /* @__PURE__ */ jsx(
2312
- Box,
2313
- {
2314
- as: "button",
2315
- background: "neutral100",
2316
- borderColor: field.error ? "danger600" : "neutral200",
2317
- hasRadius: true,
2318
- disabled,
2319
- onClick,
2320
- paddingTop: 9,
2321
- paddingBottom: 9,
2322
- type: "button",
2323
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
2324
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(CircleIcon, {}) }),
2325
- /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
2326
- id: getTranslation("components.empty-repeatable"),
2327
- defaultMessage: "No entry yet. Click on the button below to add one."
2328
- }) }) })
2329
- ] })
2330
- }
2331
- ),
2332
- field.error && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", variant: "pi", children: field.error })
2333
- ] });
2623
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2624
+ Box,
2625
+ {
2626
+ tag: "button",
2627
+ background: "neutral100",
2628
+ borderColor: field.error ? "danger600" : "neutral200",
2629
+ hasRadius: true,
2630
+ disabled,
2631
+ onClick,
2632
+ paddingTop: 9,
2633
+ paddingBottom: 9,
2634
+ type: "button",
2635
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
2636
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(CircleIcon, {}) }),
2637
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
2638
+ id: getTranslation("components.empty-repeatable"),
2639
+ defaultMessage: "No entry yet. Click on the button below to add one."
2640
+ }) }) })
2641
+ ] })
2642
+ }
2643
+ ) });
2334
2644
  };
2335
2645
  const CircleIcon = styled(PlusCircle)`
2336
2646
  width: 2.4rem;
@@ -2362,9 +2672,20 @@ const NonRepeatableComponent = ({
2362
2672
  hasRadius: isNested,
2363
2673
  borderColor: isNested ? "neutral200" : void 0,
2364
2674
  children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index) => {
2365
- return /* @__PURE__ */ jsx(Grid$1, { gap: 4, children: row.map(({ size, ...field }) => {
2675
+ return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2366
2676
  const completeFieldName = `${name2}.${field.name}`;
2367
- return /* @__PURE__ */ jsx(GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2677
+ return /* @__PURE__ */ jsx(
2678
+ Grid$1.Item,
2679
+ {
2680
+ col: size,
2681
+ s: 12,
2682
+ xs: 12,
2683
+ direction: "column",
2684
+ alignItems: "stretch",
2685
+ children: children({ ...field, name: completeFieldName })
2686
+ },
2687
+ completeFieldName
2688
+ );
2368
2689
  }) }, index);
2369
2690
  }) })
2370
2691
  }
@@ -2383,13 +2704,34 @@ const RepeatableComponent = ({
2383
2704
  const { search: searchString } = useLocation();
2384
2705
  const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
2385
2706
  const { components } = useDoc();
2386
- const { value = [], error } = useField(name2);
2707
+ const {
2708
+ value = [],
2709
+ error,
2710
+ rawError
2711
+ } = useField(name2);
2387
2712
  const addFieldRow = useForm("RepeatableComponent", (state) => state.addFieldRow);
2388
2713
  const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
2389
2714
  const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
2390
2715
  const { max = Infinity } = attribute;
2391
- const [collapseToOpen, setCollapseToOpen] = React.useState(null);
2716
+ const [collapseToOpen, setCollapseToOpen] = React.useState("");
2392
2717
  const [liveText, setLiveText] = React.useState("");
2718
+ React.useEffect(() => {
2719
+ const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
2720
+ const hasNestedValue = value && Array.isArray(value) && value.length > 0;
2721
+ if (hasNestedErrors && hasNestedValue) {
2722
+ const errorOpenItems = rawError.map((_, idx) => {
2723
+ return value[idx] ? value[idx].__temp_key__ : null;
2724
+ }).filter((value2) => !!value2);
2725
+ if (errorOpenItems && errorOpenItems.length > 0) {
2726
+ setCollapseToOpen((collapseToOpen2) => {
2727
+ if (!errorOpenItems.includes(collapseToOpen2)) {
2728
+ return errorOpenItems[0];
2729
+ }
2730
+ return collapseToOpen2;
2731
+ });
2732
+ }
2733
+ }
2734
+ }, [rawError, value]);
2393
2735
  const componentTmpKeyWithFocussedField = React.useMemo(() => {
2394
2736
  if (search.has("field")) {
2395
2737
  const fieldParam = search.get("field");
@@ -2404,13 +2746,19 @@ const RepeatableComponent = ({
2404
2746
  }
2405
2747
  return void 0;
2406
2748
  }, [search, name2, value]);
2749
+ const prevValue = usePrev(value);
2407
2750
  React.useEffect(() => {
2408
- if (typeof componentTmpKeyWithFocussedField === "number") {
2751
+ if (prevValue && prevValue.length < value.length) {
2752
+ setCollapseToOpen(value[value.length - 1].__temp_key__);
2753
+ }
2754
+ }, [value, prevValue]);
2755
+ React.useEffect(() => {
2756
+ if (typeof componentTmpKeyWithFocussedField === "string") {
2409
2757
  setCollapseToOpen(componentTmpKeyWithFocussedField);
2410
2758
  }
2411
2759
  }, [componentTmpKeyWithFocussedField]);
2412
2760
  const toggleCollapses = () => {
2413
- setCollapseToOpen(null);
2761
+ setCollapseToOpen("");
2414
2762
  };
2415
2763
  const handleClick = () => {
2416
2764
  if (value.length < max) {
@@ -2442,12 +2790,8 @@ const RepeatableComponent = ({
2442
2790
  );
2443
2791
  moveFieldRow(name2, currentIndex, newIndex);
2444
2792
  };
2445
- const handleToggle = (key) => () => {
2446
- if (collapseToOpen === key) {
2447
- setCollapseToOpen(null);
2448
- } else {
2449
- setCollapseToOpen(key);
2450
- }
2793
+ const handleValueChange = (key) => {
2794
+ setCollapseToOpen(key);
2451
2795
  };
2452
2796
  const getItemPos = (index) => `${index + 1} of ${value.length}`;
2453
2797
  const handleCancel = (index) => {
@@ -2502,158 +2846,115 @@ const RepeatableComponent = ({
2502
2846
  defaultMessage: `Press spacebar to grab and re-order`
2503
2847
  }) }),
2504
2848
  /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "assertive", children: liveText }),
2505
- /* @__PURE__ */ jsxs(AccordionGroup, { error, children: [
2506
- /* @__PURE__ */ jsx(AccordionContent, { "aria-describedby": ariaDescriptionId, children: value.map(({ __temp_key__: key, id }, index) => {
2507
- const nameWithIndex = `${name2}.${index}`;
2508
- return /* @__PURE__ */ jsx(
2509
- ComponentProvider,
2510
- {
2511
- id,
2512
- uid: attribute.component,
2513
- level: level + 1,
2514
- type: "repeatable",
2515
- children: /* @__PURE__ */ jsx(
2516
- Component,
2849
+ /* @__PURE__ */ jsxs(
2850
+ AccordionRoot,
2851
+ {
2852
+ $error: error,
2853
+ value: collapseToOpen,
2854
+ onValueChange: handleValueChange,
2855
+ "aria-describedby": ariaDescriptionId,
2856
+ children: [
2857
+ value.map(({ __temp_key__: key, id }, index) => {
2858
+ const nameWithIndex = `${name2}.${index}`;
2859
+ return /* @__PURE__ */ jsx(
2860
+ ComponentProvider,
2517
2861
  {
2518
- disabled,
2519
- name: nameWithIndex,
2520
- attribute,
2521
- index,
2522
- isOpen: collapseToOpen === key,
2523
- mainField,
2524
- onMoveItem: handleMoveComponentField,
2525
- onClickToggle: handleToggle(key),
2526
- onDeleteComponent: () => {
2527
- removeFieldRow(name2, index);
2528
- toggleCollapses();
2529
- },
2530
- toggleCollapses,
2531
- onCancel: handleCancel,
2532
- onDropItem: handleDropItem,
2533
- onGrabItem: handleGrabItem,
2534
- children: layout.map((row, index2) => {
2535
- return /* @__PURE__ */ jsx(Grid$1, { gap: 4, children: row.map(({ size, ...field }) => {
2536
- const completeFieldName = `${nameWithIndex}.${field.name}`;
2537
- return /* @__PURE__ */ jsx(GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2538
- }) }, index2);
2539
- })
2540
- }
2541
- )
2542
- },
2543
- key
2544
- );
2545
- }) }),
2546
- /* @__PURE__ */ jsx(AccordionFooter, { children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", height: "48px", background: "neutral0", children: /* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
2547
- id: getTranslation("containers.EditView.add.new-entry"),
2548
- defaultMessage: "Add an entry"
2549
- }) }) }) })
2550
- ] })
2862
+ id,
2863
+ uid: attribute.component,
2864
+ level: level + 1,
2865
+ type: "repeatable",
2866
+ children: /* @__PURE__ */ jsx(
2867
+ Component,
2868
+ {
2869
+ disabled,
2870
+ name: nameWithIndex,
2871
+ attribute,
2872
+ index,
2873
+ mainField,
2874
+ onMoveItem: handleMoveComponentField,
2875
+ onDeleteComponent: () => {
2876
+ removeFieldRow(name2, index);
2877
+ toggleCollapses();
2878
+ },
2879
+ toggleCollapses,
2880
+ onCancel: handleCancel,
2881
+ onDropItem: handleDropItem,
2882
+ onGrabItem: handleGrabItem,
2883
+ __temp_key__: key,
2884
+ children: layout.map((row, index2) => {
2885
+ return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2886
+ const completeFieldName = `${nameWithIndex}.${field.name}`;
2887
+ return /* @__PURE__ */ jsx(
2888
+ Grid$1.Item,
2889
+ {
2890
+ col: size,
2891
+ s: 12,
2892
+ xs: 12,
2893
+ direction: "column",
2894
+ alignItems: "stretch",
2895
+ children: children({ ...field, name: completeFieldName })
2896
+ },
2897
+ completeFieldName
2898
+ );
2899
+ }) }, index2);
2900
+ })
2901
+ }
2902
+ )
2903
+ },
2904
+ key
2905
+ );
2906
+ }),
2907
+ /* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
2908
+ id: getTranslation("containers.EditView.add.new-entry"),
2909
+ defaultMessage: "Add an entry"
2910
+ }) })
2911
+ ]
2912
+ }
2913
+ )
2551
2914
  ] });
2552
2915
  };
2916
+ const AccordionRoot = styled(Accordion.Root)`
2917
+ border: 1px solid
2918
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
2919
+ `;
2553
2920
  const TextButtonCustom = styled(TextButton)`
2554
- height: 100%;
2555
2921
  width: 100%;
2556
- border-radius: 0 0 4px 4px;
2557
2922
  display: flex;
2558
2923
  justify-content: center;
2559
- span {
2560
- font-weight: 600;
2561
- font-size: 14px;
2562
- }
2563
- `;
2564
- const AccordionFooter = styled(Box)`
2565
- overflow: hidden;
2566
- border-bottom: 1px solid ${({ theme }) => theme.colors.neutral200};
2567
- border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
2568
- border-left: 1px solid ${({ theme }) => theme.colors.neutral200};
2569
- border-radius: 0 0 ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius};
2570
- `;
2571
- const AccordionContent = styled(Box)`
2572
- border-bottom: none;
2573
-
2574
- /* add the borders and make sure the top is transparent to avoid jumping with the hover effect */
2575
- & > div > div {
2576
- border: 1px solid ${({ theme }) => theme.colors.neutral200};
2577
- border-top-color: transparent;
2578
- }
2924
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2925
+ padding-inline: ${(props) => props.theme.spaces[6]};
2926
+ padding-block: ${(props) => props.theme.spaces[3]};
2579
2927
 
2580
- /* the top accordion _does_ need a border though */
2581
- & > div:first-child > div {
2582
- border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2583
- }
2928
+ &:not([disabled]) {
2929
+ cursor: pointer;
2584
2930
 
2585
- /* Reset all the border-radius' */
2586
- & > div > div,
2587
- & > div > div > div {
2588
- border-radius: unset;
2931
+ &:hover {
2932
+ background-color: ${(props) => props.theme.colors.primary100};
2933
+ }
2589
2934
  }
2590
2935
 
2591
- /* Give the border radius back to the first accordion */
2592
- & > div:first-child > div,
2593
- & > div:first-child > div > div {
2594
- border-radius: ${({ theme }) => theme.borderRadius} ${({ theme }) => theme.borderRadius} 0 0;
2936
+ span {
2937
+ font-weight: 600;
2938
+ font-size: 1.4rem;
2939
+ line-height: 2.4rem;
2595
2940
  }
2596
2941
 
2597
- & > div > div[data-strapi-expanded='true'] {
2598
- border: 1px solid ${({ theme }) => theme.colors.primary600};
2599
- }
2600
- `;
2601
- const AccordionGroup = ({ children, error }) => {
2602
- return /* @__PURE__ */ jsxs(KeyboardNavigable, { attributeName: "data-strapi-accordion-toggle", children: [
2603
- children,
2604
- error && /* @__PURE__ */ jsx(Box, { paddingTop: 1, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", children: error }) })
2605
- ] });
2606
- };
2607
- const CustomIconButton$1 = styled(IconButton)`
2608
- background-color: transparent;
2609
-
2610
- svg {
2611
- path {
2612
- fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
2613
- }
2614
- }
2615
-
2616
- &:hover {
2617
- svg {
2618
- path {
2619
- fill: ${({ theme }) => theme.colors.primary600};
2620
- }
2621
- }
2622
- }
2623
- `;
2624
- const ActionsFlex$1 = styled(Flex)`
2625
- & .drag-handle {
2626
- background: unset;
2627
-
2628
- svg {
2629
- path {
2630
- fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : void 0};
2631
- }
2632
- }
2633
-
2634
- &:hover {
2635
- svg {
2636
- path {
2637
- /* keeps the hover style of the accordion */
2638
- fill: ${({ theme }) => theme.colors.primary600};
2639
- }
2640
- }
2641
- }
2942
+ @media (prefers-reduced-motion: no-preference) {
2943
+ transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2642
2944
  }
2643
2945
  `;
2644
2946
  const Component = ({
2645
2947
  disabled,
2646
2948
  index,
2647
- isOpen,
2648
2949
  name: name2,
2649
2950
  mainField = {
2650
2951
  name: "id",
2651
2952
  type: "integer"
2652
2953
  },
2653
2954
  children,
2654
- onClickToggle,
2655
2955
  onDeleteComponent,
2656
2956
  toggleCollapses,
2957
+ __temp_key__,
2657
2958
  ...dragProps
2658
2959
  }) => {
2659
2960
  const { formatMessage } = useIntl();
@@ -2678,50 +2979,44 @@ const Component = ({
2678
2979
  dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
2679
2980
  }, [dragPreviewRef, index]);
2680
2981
  const composedAccordionRefs = useComposedRefs(accordionRef, dragRef);
2681
- const composedBoxRefs = useComposedRefs(boxRef, dropRef);
2682
- return /* @__PURE__ */ jsx(Box, { ref: (ref) => composedBoxRefs(ref), children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsxs(Accordion, { expanded: isOpen, onToggle: onClickToggle, id: name2, size: "S", children: [
2683
- /* @__PURE__ */ jsx(
2684
- AccordionToggle,
2685
- {
2686
- action: disabled ? null : /* @__PURE__ */ jsxs(ActionsFlex$1, { gap: 0, expanded: isOpen, children: [
2687
- /* @__PURE__ */ jsx(
2688
- CustomIconButton$1,
2689
- {
2690
- expanded: isOpen,
2691
- borderWidth: 0,
2692
- onClick: onDeleteComponent,
2693
- label: formatMessage({
2694
- id: getTranslation("containers.Edit.delete"),
2695
- defaultMessage: "Delete"
2696
- }),
2697
- icon: /* @__PURE__ */ jsx(Trash, {})
2698
- }
2699
- ),
2700
- /* @__PURE__ */ jsx(
2701
- IconButton,
2702
- {
2703
- className: "drag-handle",
2704
- ref: composedAccordionRefs,
2705
- forwardedAs: "div",
2706
- role: "button",
2707
- borderWidth: 0,
2708
- tabIndex: 0,
2709
- onClick: (e) => e.stopPropagation(),
2710
- "data-handler-id": handlerId,
2711
- label: formatMessage({
2712
- id: getTranslation("components.DragHandle-label"),
2713
- defaultMessage: "Drag"
2714
- }),
2715
- onKeyDown: handleKeyDown,
2716
- children: /* @__PURE__ */ jsx(Drag, {})
2717
- }
2718
- )
2719
- ] }),
2720
- title: displayValue,
2721
- togglePosition: "left"
2722
- }
2723
- ),
2724
- /* @__PURE__ */ jsx(AccordionContent$1, { children: /* @__PURE__ */ jsx(
2982
+ const composedBoxRefs = useComposedRefs(
2983
+ boxRef,
2984
+ dropRef
2985
+ );
2986
+ return /* @__PURE__ */ jsx(Fragment, { children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsxs(Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
2987
+ /* @__PURE__ */ jsxs(Accordion.Header, { children: [
2988
+ /* @__PURE__ */ jsx(Accordion.Trigger, { children: displayValue }),
2989
+ /* @__PURE__ */ jsxs(Accordion.Actions, { children: [
2990
+ /* @__PURE__ */ jsx(
2991
+ IconButton,
2992
+ {
2993
+ variant: "ghost",
2994
+ onClick: onDeleteComponent,
2995
+ label: formatMessage({
2996
+ id: getTranslation("containers.Edit.delete"),
2997
+ defaultMessage: "Delete"
2998
+ }),
2999
+ children: /* @__PURE__ */ jsx(Trash, {})
3000
+ }
3001
+ ),
3002
+ /* @__PURE__ */ jsx(
3003
+ IconButton,
3004
+ {
3005
+ ref: composedAccordionRefs,
3006
+ variant: "ghost",
3007
+ onClick: (e) => e.stopPropagation(),
3008
+ "data-handler-id": handlerId,
3009
+ label: formatMessage({
3010
+ id: getTranslation("components.DragHandle-label"),
3011
+ defaultMessage: "Drag"
3012
+ }),
3013
+ onKeyDown: handleKeyDown,
3014
+ children: /* @__PURE__ */ jsx(Drag, {})
3015
+ }
3016
+ )
3017
+ ] })
3018
+ ] }),
3019
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(
2725
3020
  Flex,
2726
3021
  {
2727
3022
  direction: "column",
@@ -2735,7 +3030,7 @@ const Component = ({
2735
3030
  ] }) });
2736
3031
  };
2737
3032
  const Preview$1 = () => {
2738
- return /* @__PURE__ */ jsx(StyledSpan, { as: "span", padding: 6, background: "primary100" });
3033
+ return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
2739
3034
  };
2740
3035
  const StyledSpan = styled(Box)`
2741
3036
  display: block;
@@ -2761,29 +3056,15 @@ const ComponentInput = ({
2761
3056
  const data = transformDocument(schema, components)(form);
2762
3057
  field.onChange(name2, data);
2763
3058
  };
2764
- return /* @__PURE__ */ jsxs(Box, { children: [
3059
+ return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
2765
3060
  /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", children: [
2766
- /* @__PURE__ */ jsxs(Flex, { paddingBottom: 1, children: [
2767
- /* @__PURE__ */ jsxs(
2768
- Typography,
2769
- {
2770
- textColor: "neutral800",
2771
- htmlFor: name2,
2772
- variant: "pi",
2773
- fontWeight: "bold",
2774
- as: "label",
2775
- children: [
2776
- label,
2777
- attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
2778
- " (",
2779
- Array.isArray(field.value) ? field.value.length : 0,
2780
- ")"
2781
- ] }),
2782
- required && /* @__PURE__ */ jsx(Typography, { textColor: "danger600", children: "*" })
2783
- ]
2784
- }
2785
- ),
2786
- labelAction && /* @__PURE__ */ jsx(Box, { paddingLeft: 1, children: labelAction })
3061
+ /* @__PURE__ */ jsxs(Field.Label, { action: labelAction, children: [
3062
+ label,
3063
+ attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
3064
+ " (",
3065
+ Array.isArray(field.value) ? field.value.length : 0,
3066
+ ")"
3067
+ ] })
2787
3068
  ] }),
2788
3069
  showResetComponent && /* @__PURE__ */ jsx(
2789
3070
  IconButton,
@@ -2792,21 +3073,21 @@ const ComponentInput = ({
2792
3073
  id: getTranslation("components.reset-entry"),
2793
3074
  defaultMessage: "Reset Entry"
2794
3075
  }),
2795
- icon: /* @__PURE__ */ jsx(Trash, {}),
2796
- borderWidth: 0,
3076
+ variant: "ghost",
2797
3077
  onClick: () => {
2798
3078
  field.onChange(name2, null);
2799
- }
3079
+ },
3080
+ children: /* @__PURE__ */ jsx(Trash, {})
2800
3081
  }
2801
3082
  )
2802
3083
  ] }),
2803
- /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
2804
- !attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
2805
- !attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
2806
- attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children })
2807
- ] })
3084
+ !attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
3085
+ !attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
3086
+ attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
3087
+ /* @__PURE__ */ jsx(Field.Error, {})
2808
3088
  ] });
2809
3089
  };
3090
+ const MemoizedComponentInput = React.memo(ComponentInput);
2810
3091
  const AddComponentButton = ({
2811
3092
  hasError,
2812
3093
  isDisabled,
@@ -2821,15 +3102,12 @@ const AddComponentButton = ({
2821
3102
  onClick,
2822
3103
  disabled: isDisabled,
2823
3104
  background: "neutral0",
2824
- paddingTop: 3,
2825
- paddingBottom: 3,
2826
- paddingLeft: 4,
2827
- paddingRight: 4,
2828
3105
  style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2829
- children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: 2, children: [
3106
+ variant: "tertiary",
3107
+ children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
2830
3108
  /* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2831
3109
  /* @__PURE__ */ jsx(
2832
- Typography,
3110
+ AddComponentTitle,
2833
3111
  {
2834
3112
  variant: "pi",
2835
3113
  fontWeight: "bold",
@@ -2853,13 +3131,15 @@ const StyledAddIcon = styled(PlusCircle)`
2853
3131
  fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
2854
3132
  }
2855
3133
  `;
2856
- const StyledButton = styled(BaseButton)`
3134
+ const AddComponentTitle = styled(Typography)``;
3135
+ const StyledButton = styled(Button)`
2857
3136
  border-radius: 26px;
2858
3137
  border-color: ${({ theme }) => theme.colors.neutral150};
2859
3138
  box-shadow: ${({ theme }) => theme.shadows.filterShadow};
3139
+ height: 5rem;
2860
3140
 
2861
3141
  &:hover {
2862
- ${Typography} {
3142
+ ${AddComponentTitle} {
2863
3143
  color: ${({ theme }) => theme.colors.primary600};
2864
3144
  }
2865
3145
 
@@ -2868,12 +3148,12 @@ const StyledButton = styled(BaseButton)`
2868
3148
  fill: ${({ theme }) => theme.colors.primary600};
2869
3149
  }
2870
3150
  > path {
2871
- fill: ${({ theme }) => theme.colors.neutral100};
3151
+ fill: ${({ theme }) => theme.colors.primary600};
2872
3152
  }
2873
3153
  }
2874
3154
  }
2875
3155
  &:active {
2876
- ${Typography} {
3156
+ ${AddComponentTitle} {
2877
3157
  color: ${({ theme }) => theme.colors.primary600};
2878
3158
  }
2879
3159
  ${StyledAddIcon} {
@@ -2890,27 +3170,15 @@ const ComponentCategory = ({
2890
3170
  category,
2891
3171
  components = [],
2892
3172
  variant = "primary",
2893
- isOpen,
2894
- onAddComponent,
2895
- onToggle
3173
+ onAddComponent
2896
3174
  }) => {
2897
3175
  const { formatMessage } = useIntl();
2898
- const handleToggle = () => {
2899
- onToggle(category);
2900
- };
2901
- return /* @__PURE__ */ jsxs(Accordion, { expanded: isOpen, onToggle: handleToggle, size: "S", children: [
2902
- /* @__PURE__ */ jsx(
2903
- AccordionToggle,
2904
- {
2905
- variant,
2906
- title: formatMessage({ id: category, defaultMessage: category }),
2907
- togglePosition: "left"
2908
- }
2909
- ),
2910
- /* @__PURE__ */ jsx(AccordionContent$1, { children: /* @__PURE__ */ jsx(Box, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: /* @__PURE__ */ jsx(Grid, { children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
3176
+ return /* @__PURE__ */ jsxs(Accordion.Item, { value: category, children: [
3177
+ /* @__PURE__ */ jsx(Accordion.Header, { variant, children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
3178
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsx(
2911
3179
  ComponentBox,
2912
3180
  {
2913
- as: "button",
3181
+ tag: "button",
2914
3182
  type: "button",
2915
3183
  background: "neutral100",
2916
3184
  justifyContent: "center",
@@ -2920,34 +3188,32 @@ const ComponentCategory = ({
2920
3188
  shrink: 0,
2921
3189
  borderColor: "neutral200",
2922
3190
  children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2923
- /* @__PURE__ */ jsx(ComponentIcon, { icon }),
2924
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", textColor: "neutral600", children: displayName })
3191
+ /* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
3192
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2925
3193
  ] })
2926
3194
  },
2927
3195
  uid
2928
- )) }) }) })
3196
+ )) }) })
2929
3197
  ] });
2930
3198
  };
2931
- const Grid = styled.div`
3199
+ const Grid = styled(Box)`
2932
3200
  display: grid;
2933
3201
  grid-template-columns: repeat(auto-fit, 14rem);
2934
3202
  grid-gap: ${({ theme }) => theme.spaces[1]};
2935
3203
  `;
2936
3204
  const ComponentBox = styled(Flex)`
3205
+ color: ${({ theme }) => theme.colors.neutral600};
3206
+ cursor: pointer;
3207
+
3208
+ @media (prefers-reduced-motion: no-preference) {
3209
+ transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
3210
+ }
3211
+
2937
3212
  &:focus,
2938
3213
  &:hover {
2939
3214
  border: 1px solid ${({ theme }) => theme.colors.primary200};
2940
3215
  background: ${({ theme }) => theme.colors.primary100};
2941
-
2942
- ${Typography} {
2943
- color: ${({ theme }) => theme.colors.primary600};
2944
- }
2945
-
2946
- /* > Flex > ComponentIcon */
2947
- > div > div:first-child {
2948
- background: ${({ theme }) => theme.colors.primary200};
2949
- color: ${({ theme }) => theme.colors.primary600};
2950
- }
3216
+ color: ${({ theme }) => theme.colors.primary600};
2951
3217
  }
2952
3218
  `;
2953
3219
  const ComponentPicker = ({
@@ -2956,19 +3222,8 @@ const ComponentPicker = ({
2956
3222
  onClickAddComponent
2957
3223
  }) => {
2958
3224
  const { formatMessage } = useIntl();
2959
- const [categoryToOpen, setCategoryToOpen] = React.useState("");
2960
- React.useEffect(() => {
2961
- const categoryKeys = Object.keys(dynamicComponentsByCategory);
2962
- if (isOpen && categoryKeys.length > 0) {
2963
- setCategoryToOpen(categoryKeys[0]);
2964
- }
2965
- }, [isOpen, dynamicComponentsByCategory]);
2966
3225
  const handleAddComponentToDz = (componentUid) => () => {
2967
3226
  onClickAddComponent(componentUid);
2968
- setCategoryToOpen("");
2969
- };
2970
- const handleClickToggle = (categoryName) => {
2971
- setCategoryToOpen((currentCat) => currentCat === categoryName ? "" : categoryName);
2972
3227
  };
2973
3228
  if (!isOpen) {
2974
3229
  return null;
@@ -2989,14 +3244,12 @@ const ComponentPicker = ({
2989
3244
  id: getTranslation("components.DynamicZone.ComponentPicker-label"),
2990
3245
  defaultMessage: "Pick one component"
2991
3246
  }) }) }),
2992
- /* @__PURE__ */ jsx(Box, { paddingTop: 2, children: /* @__PURE__ */ jsx(KeyboardNavigable, { attributeName: "data-strapi-accordion-toggle", children: Object.entries(dynamicComponentsByCategory).map(([category, components], index) => /* @__PURE__ */ jsx(
3247
+ /* @__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(
2993
3248
  ComponentCategory,
2994
3249
  {
2995
3250
  category,
2996
3251
  components,
2997
3252
  onAddComponent: handleAddComponentToDz,
2998
- isOpen: category === categoryToOpen,
2999
- onToggle: handleClickToggle,
3000
3253
  variant: index % 2 === 1 ? "primary" : "secondary"
3001
3254
  },
3002
3255
  category
@@ -3011,39 +3264,21 @@ const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
3011
3264
  id: "components.NotAllowedInput.text",
3012
3265
  defaultMessage: "No permissions to see this field"
3013
3266
  });
3014
- return /* @__PURE__ */ jsx(
3015
- TextInput,
3016
- {
3017
- disabled: true,
3018
- label,
3019
- id: name2,
3020
- hint,
3021
- name: name2,
3022
- placeholder,
3023
- required,
3024
- startAction: /* @__PURE__ */ jsx(StyledIcon, {}),
3025
- type: "text",
3026
- value: ""
3027
- }
3028
- );
3267
+ return /* @__PURE__ */ jsxs(Field.Root, { id: name2, hint, name: name2, required, children: [
3268
+ /* @__PURE__ */ jsx(Field.Label, { children: label }),
3269
+ /* @__PURE__ */ jsx(
3270
+ TextInput,
3271
+ {
3272
+ disabled: true,
3273
+ placeholder,
3274
+ startAction: /* @__PURE__ */ jsx(EyeStriked, { fill: "neutral600" }),
3275
+ type: "text",
3276
+ value: ""
3277
+ }
3278
+ ),
3279
+ /* @__PURE__ */ jsx(Field.Hint, {})
3280
+ ] });
3029
3281
  };
3030
- const StyledIcon = styled(EyeStriked)`
3031
- & > path {
3032
- fill: ${({ theme }) => theme.colors.neutral600};
3033
- }
3034
- `;
3035
- function useDebounce(value, delay) {
3036
- const [debouncedValue, setDebouncedValue] = useState(value);
3037
- useEffect(() => {
3038
- const handler = setTimeout(() => {
3039
- setDebouncedValue(value);
3040
- }, delay);
3041
- return () => {
3042
- clearTimeout(handler);
3043
- };
3044
- }, [value, delay]);
3045
- return debouncedValue;
3046
- }
3047
3282
  const uidApi = contentManagerApi.injectEndpoints({
3048
3283
  endpoints: (builder) => ({
3049
3284
  getDefaultUID: builder.query({
@@ -3078,194 +3313,206 @@ const uidApi = contentManagerApi.injectEndpoints({
3078
3313
  config: {
3079
3314
  params
3080
3315
  }
3081
- })
3316
+ }),
3317
+ providesTags: (_res, _error, params) => [
3318
+ { type: "UidAvailability", id: params.contentTypeUID }
3319
+ ]
3082
3320
  })
3083
3321
  })
3084
3322
  });
3085
3323
  const { useGenerateUIDMutation, useGetDefaultUIDQuery, useGetAvailabilityQuery } = uidApi;
3086
3324
  const UID_REGEX = /^[A-Za-z0-9-_.~]*$/;
3087
- const UIDInput = React.forwardRef((props, ref) => {
3088
- const { model, id } = useDoc();
3089
- const allFormValues = useForm("InputUID", (form) => form.values);
3090
- const [availability, setAvailability] = React.useState();
3091
- const [showRegenerate, setShowRegenerate] = React.useState(false);
3092
- const field = useField(props.name);
3093
- const debouncedValue = useDebounce(field.value, 300);
3094
- const { toggleNotification } = useNotification();
3095
- const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
3096
- const { formatMessage } = useIntl();
3097
- const [{ query }] = useQueryParams();
3098
- const params = React.useMemo(() => buildValidParams(query), [query]);
3099
- const {
3100
- data: defaultGeneratedUID,
3101
- isLoading: isGeneratingDefaultUID,
3102
- error: apiError
3103
- } = useGetDefaultUIDQuery(
3104
- {
3105
- contentTypeUID: model,
3106
- field: props.name,
3107
- data: {
3108
- id: id ?? "",
3109
- ...allFormValues
3110
- },
3111
- params
3112
- },
3113
- {
3114
- skip: field.value || !props.required
3115
- }
3116
- );
3117
- React.useEffect(() => {
3118
- if (apiError) {
3119
- toggleNotification({
3120
- type: "warning",
3121
- message: formatAPIError(apiError)
3122
- });
3123
- }
3124
- }, [apiError, formatAPIError, toggleNotification]);
3125
- React.useEffect(() => {
3126
- if (defaultGeneratedUID && field.value === void 0) {
3127
- field.onChange(props.name, defaultGeneratedUID);
3128
- }
3129
- }, [defaultGeneratedUID, field, props.name]);
3130
- const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
3131
- const handleRegenerateClick = async () => {
3132
- try {
3133
- const res = await generateUID({
3325
+ const UIDInput = React.forwardRef(
3326
+ ({ hint, label, labelAction, name: name2, required, ...props }, ref) => {
3327
+ const { model, id } = useDoc();
3328
+ const allFormValues = useForm("InputUID", (form) => form.values);
3329
+ const [availability, setAvailability] = React.useState();
3330
+ const [showRegenerate, setShowRegenerate] = React.useState(false);
3331
+ const isCloning = useMatch(CLONE_PATH) !== null;
3332
+ const field = useField(name2);
3333
+ const debouncedValue = useDebounce(field.value, 300);
3334
+ const hasChanged = debouncedValue !== field.initialValue;
3335
+ const { toggleNotification } = useNotification();
3336
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
3337
+ const { formatMessage } = useIntl();
3338
+ const [{ query }] = useQueryParams();
3339
+ const params = React.useMemo(() => buildValidParams(query), [query]);
3340
+ const {
3341
+ data: defaultGeneratedUID,
3342
+ isLoading: isGeneratingDefaultUID,
3343
+ error: apiError
3344
+ } = useGetDefaultUIDQuery(
3345
+ {
3134
3346
  contentTypeUID: model,
3135
- field: props.name,
3136
- data: { id: id ?? "", ...allFormValues },
3347
+ field: name2,
3348
+ data: {
3349
+ id: id ?? "",
3350
+ ...allFormValues
3351
+ },
3137
3352
  params
3138
- });
3139
- if ("data" in res) {
3140
- field.onChange(props.name, res.data);
3141
- } else {
3353
+ },
3354
+ {
3355
+ skip: field.value || !required
3356
+ }
3357
+ );
3358
+ React.useEffect(() => {
3359
+ if (apiError) {
3142
3360
  toggleNotification({
3143
- type: "danger",
3144
- message: formatAPIError(res.error)
3361
+ type: "warning",
3362
+ message: formatAPIError(apiError)
3145
3363
  });
3146
3364
  }
3147
- } catch (err) {
3148
- toggleNotification({
3149
- type: "danger",
3150
- message: formatMessage({
3151
- id: "notification.error",
3152
- defaultMessage: "An error occurred."
3153
- })
3154
- });
3155
- }
3156
- };
3157
- const {
3158
- data: availabilityData,
3159
- isLoading: isCheckingAvailability,
3160
- error: availabilityError
3161
- } = useGetAvailabilityQuery(
3162
- {
3163
- contentTypeUID: model,
3164
- field: props.name,
3165
- value: debouncedValue ? debouncedValue.trim() : "",
3166
- params
3167
- },
3168
- {
3169
- skip: !Boolean(
3170
- debouncedValue !== field.initialValue && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3171
- )
3172
- }
3173
- );
3174
- React.useEffect(() => {
3175
- if (availabilityError) {
3176
- toggleNotification({
3177
- type: "warning",
3178
- message: formatAPIError(availabilityError)
3179
- });
3180
- }
3181
- }, [availabilityError, formatAPIError, toggleNotification]);
3182
- React.useEffect(() => {
3183
- setAvailability(availabilityData);
3184
- let timer;
3185
- if (availabilityData?.isAvailable) {
3186
- timer = window.setTimeout(() => {
3187
- setAvailability(void 0);
3188
- }, 4e3);
3189
- }
3190
- return () => {
3191
- if (timer) {
3192
- clearTimeout(timer);
3365
+ }, [apiError, formatAPIError, toggleNotification]);
3366
+ React.useEffect(() => {
3367
+ if (defaultGeneratedUID && field.value === void 0) {
3368
+ field.onChange(name2, defaultGeneratedUID);
3369
+ }
3370
+ }, [defaultGeneratedUID, field, name2]);
3371
+ const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
3372
+ const handleRegenerateClick = async () => {
3373
+ try {
3374
+ const res = await generateUID({
3375
+ contentTypeUID: model,
3376
+ field: name2,
3377
+ data: { id: id ?? "", ...allFormValues },
3378
+ params
3379
+ });
3380
+ if ("data" in res) {
3381
+ field.onChange(name2, res.data);
3382
+ } else {
3383
+ toggleNotification({
3384
+ type: "danger",
3385
+ message: formatAPIError(res.error)
3386
+ });
3387
+ }
3388
+ } catch (err) {
3389
+ toggleNotification({
3390
+ type: "danger",
3391
+ message: formatMessage({
3392
+ id: "notification.error",
3393
+ defaultMessage: "An error occurred."
3394
+ })
3395
+ });
3193
3396
  }
3194
3397
  };
3195
- }, [availabilityData]);
3196
- const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
3197
- const fieldRef = useFocusInputField(props.name);
3198
- const composedRefs = useComposedRefs(ref, fieldRef);
3199
- return (
3200
- // @ts-expect-error – label _could_ be a ReactNode since it's a child, this should be fixed in the DS.
3201
- /* @__PURE__ */ jsx(
3202
- TextInput,
3398
+ const {
3399
+ data: availabilityData,
3400
+ isLoading: isCheckingAvailability,
3401
+ error: availabilityError
3402
+ } = useGetAvailabilityQuery(
3203
3403
  {
3204
- ref: composedRefs,
3205
- disabled: props.disabled,
3206
- error: field.error,
3207
- endAction: /* @__PURE__ */ jsxs(Flex, { position: "relative", gap: 1, children: [
3208
- availability && !showRegenerate && /* @__PURE__ */ jsxs(
3209
- TextValidation,
3210
- {
3211
- alignItems: "center",
3212
- gap: 1,
3213
- justifyContent: "flex-end",
3214
- available: !!availability?.isAvailable,
3215
- "data-not-here-outer": true,
3216
- position: "absolute",
3217
- pointerEvents: "none",
3218
- right: 6,
3219
- width: "100px",
3220
- children: [
3221
- availability?.isAvailable ? /* @__PURE__ */ jsx(CheckCircle, {}) : /* @__PURE__ */ jsx(WarningCircle, {}),
3222
- /* @__PURE__ */ jsx(
3223
- Typography,
3224
- {
3225
- textColor: availability.isAvailable ? "success600" : "danger600",
3226
- variant: "pi",
3227
- children: formatMessage(
3228
- availability.isAvailable ? {
3229
- id: "content-manager.components.uid.available",
3230
- defaultMessage: "Available"
3231
- } : {
3232
- id: "content-manager.components.uid.unavailable",
3233
- defaultMessage: "Unavailable"
3234
- }
3235
- )
3236
- }
3237
- )
3238
- ]
3239
- }
3240
- ),
3241
- !props.disabled && /* @__PURE__ */ jsxs(Fragment, { children: [
3242
- showRegenerate && /* @__PURE__ */ jsx(TextValidation, { alignItems: "center", justifyContent: "flex-end", gap: 1, children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", children: formatMessage({
3243
- id: "content-manager.components.uid.regenerate",
3244
- defaultMessage: "Regenerate"
3245
- }) }) }),
3246
- /* @__PURE__ */ jsx(
3247
- FieldActionWrapper,
3404
+ contentTypeUID: model,
3405
+ field: name2,
3406
+ value: debouncedValue ? debouncedValue.trim() : "",
3407
+ params
3408
+ },
3409
+ {
3410
+ // Don't check availability if the value is empty or wasn't changed
3411
+ skip: !Boolean(
3412
+ (hasChanged || isCloning) && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3413
+ )
3414
+ }
3415
+ );
3416
+ React.useEffect(() => {
3417
+ if (availabilityError) {
3418
+ toggleNotification({
3419
+ type: "warning",
3420
+ message: formatAPIError(availabilityError)
3421
+ });
3422
+ }
3423
+ }, [availabilityError, formatAPIError, toggleNotification]);
3424
+ React.useEffect(() => {
3425
+ setAvailability(availabilityData);
3426
+ let timer;
3427
+ if (availabilityData?.isAvailable) {
3428
+ timer = window.setTimeout(() => {
3429
+ setAvailability(void 0);
3430
+ }, 4e3);
3431
+ }
3432
+ return () => {
3433
+ if (timer) {
3434
+ clearTimeout(timer);
3435
+ }
3436
+ };
3437
+ }, [availabilityData]);
3438
+ const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
3439
+ const fieldRef = useFocusInputField(name2);
3440
+ const composedRefs = useComposedRefs(ref, fieldRef);
3441
+ const shouldShowAvailability = (hasChanged || isCloning) && debouncedValue != null && availability && !showRegenerate;
3442
+ return /* @__PURE__ */ jsxs(Field.Root, { hint, name: name2, error: field.error, required, children: [
3443
+ /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
3444
+ /* @__PURE__ */ jsx(
3445
+ TextInput,
3446
+ {
3447
+ ref: composedRefs,
3448
+ disabled: props.disabled,
3449
+ endAction: /* @__PURE__ */ jsxs(Flex, { position: "relative", gap: 1, children: [
3450
+ shouldShowAvailability && /* @__PURE__ */ jsxs(
3451
+ TextValidation,
3248
3452
  {
3249
- onClick: handleRegenerateClick,
3250
- label: formatMessage({
3251
- id: "content-manager.components.uid.regenerate",
3252
- defaultMessage: "Regenerate"
3253
- }),
3254
- onMouseEnter: () => setShowRegenerate(true),
3255
- onMouseLeave: () => setShowRegenerate(false),
3256
- children: isLoading ? /* @__PURE__ */ jsx(LoadingWrapper, { "data-testid": "loading-wrapper", children: /* @__PURE__ */ jsx(Loader, {}) }) : /* @__PURE__ */ jsx(ArrowClockwise, {})
3453
+ alignItems: "center",
3454
+ gap: 1,
3455
+ justifyContent: "flex-end",
3456
+ $available: !!availability?.isAvailable,
3457
+ "data-not-here-outer": true,
3458
+ position: "absolute",
3459
+ pointerEvents: "none",
3460
+ right: 6,
3461
+ width: "100px",
3462
+ children: [
3463
+ availability?.isAvailable ? /* @__PURE__ */ jsx(CheckCircle, {}) : /* @__PURE__ */ jsx(WarningCircle, {}),
3464
+ /* @__PURE__ */ jsx(
3465
+ Typography,
3466
+ {
3467
+ textColor: availability.isAvailable ? "success600" : "danger600",
3468
+ variant: "pi",
3469
+ children: formatMessage(
3470
+ availability.isAvailable ? {
3471
+ id: "content-manager.components.uid.available",
3472
+ defaultMessage: "Available"
3473
+ } : {
3474
+ id: "content-manager.components.uid.unavailable",
3475
+ defaultMessage: "Unavailable"
3476
+ }
3477
+ )
3478
+ }
3479
+ )
3480
+ ]
3257
3481
  }
3258
- )
3259
- ] })
3260
- ] }),
3261
- onChange: field.onChange,
3262
- value: field.value ?? "",
3263
- ...props
3264
- }
3265
- )
3266
- );
3267
- });
3268
- const FieldActionWrapper = styled(FieldAction)`
3482
+ ),
3483
+ !props.disabled && /* @__PURE__ */ jsxs(Fragment, { children: [
3484
+ showRegenerate && /* @__PURE__ */ jsx(TextValidation, { alignItems: "center", justifyContent: "flex-end", gap: 1, children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", children: formatMessage({
3485
+ id: "content-manager.components.uid.regenerate",
3486
+ defaultMessage: "Regenerate"
3487
+ }) }) }),
3488
+ /* @__PURE__ */ jsx(
3489
+ FieldActionWrapper,
3490
+ {
3491
+ onClick: handleRegenerateClick,
3492
+ label: formatMessage({
3493
+ id: "content-manager.components.uid.regenerate",
3494
+ defaultMessage: "Regenerate"
3495
+ }),
3496
+ onMouseEnter: () => setShowRegenerate(true),
3497
+ onMouseLeave: () => setShowRegenerate(false),
3498
+ children: isLoading ? /* @__PURE__ */ jsx(LoadingWrapper, { "data-testid": "loading-wrapper", children: /* @__PURE__ */ jsx(Loader, {}) }) : /* @__PURE__ */ jsx(ArrowClockwise, {})
3499
+ }
3500
+ )
3501
+ ] })
3502
+ ] }),
3503
+ onChange: field.onChange,
3504
+ value: field.value ?? "",
3505
+ ...props
3506
+ }
3507
+ ),
3508
+ /* @__PURE__ */ jsx(Field.Error, {}),
3509
+ /* @__PURE__ */ jsx(Field.Hint, {})
3510
+ ] });
3511
+ }
3512
+ );
3513
+ const FieldActionWrapper = styled(Field.Action)`
3514
+ width: 1.6rem;
3515
+
3269
3516
  svg {
3270
3517
  height: 1.6rem;
3271
3518
  width: 1.6rem;
@@ -3286,7 +3533,7 @@ const TextValidation = styled(Flex)`
3286
3533
  width: 1.2rem;
3287
3534
 
3288
3535
  path {
3289
- fill: ${({ theme, available }) => available ? theme.colors.success600 : theme.colors.danger600};
3536
+ fill: ${({ theme, $available }) => $available ? theme.colors.success600 : theme.colors.danger600};
3290
3537
  }
3291
3538
  }
3292
3539
  `;
@@ -3301,6 +3548,7 @@ const rotation = keyframes`
3301
3548
  const LoadingWrapper = styled(Flex)`
3302
3549
  animation: ${rotation} 2s infinite linear;
3303
3550
  `;
3551
+ const MemoizedUIDInput = React.memo(UIDInput);
3304
3552
  const md = new Markdown({
3305
3553
  html: true,
3306
3554
  // Enable HTML tags in source
@@ -3635,7 +3883,7 @@ const Editor = React.forwardRef(
3635
3883
  [editorRef]
3636
3884
  );
3637
3885
  return /* @__PURE__ */ jsxs(EditorAndPreviewWrapper, { children: [
3638
- /* @__PURE__ */ jsx(EditorStylesContainer, { isExpandMode, disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
3886
+ /* @__PURE__ */ jsx(EditorStylesContainer, { $isExpandMode: isExpandMode, $disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
3639
3887
  isPreviewMode && /* @__PURE__ */ jsx(PreviewWysiwyg, { data: value })
3640
3888
  ] });
3641
3889
  }
@@ -3645,7 +3893,7 @@ const EditorAndPreviewWrapper = styled.div`
3645
3893
  height: calc(100% - 48px);
3646
3894
  `;
3647
3895
  const EditorStylesContainer = styled.div`
3648
- cursor: ${({ disabled }) => disabled ? "not-allowed !important" : "auto"};
3896
+ cursor: ${({ $disabled }) => $disabled ? "not-allowed !important" : "auto"};
3649
3897
  height: 100%;
3650
3898
  /* BASICS */
3651
3899
  .CodeMirror-placeholder {
@@ -3655,7 +3903,7 @@ const EditorStylesContainer = styled.div`
3655
3903
  .CodeMirror {
3656
3904
  /* Set height, width, borders, and global font properties here */
3657
3905
  font-size: 1.4rem;
3658
- height: ${({ isExpandMode }) => isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
3906
+ height: ${({ $isExpandMode }) => $isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
3659
3907
  color: ${({ theme }) => theme.colors.neutral800};
3660
3908
  direction: ltr;
3661
3909
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
@@ -4033,7 +4281,7 @@ const EditorLayout = ({
4033
4281
  justifyContent: "flex-end",
4034
4282
  shrink: 0,
4035
4283
  width: "100%",
4036
- children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, children: [
4284
+ children: /* @__PURE__ */ jsxs(ExpandButton$1, { onClick: onCollapse, variant: "tertiary", size: "M", children: [
4037
4285
  /* @__PURE__ */ jsx(Typography, { children: formatMessage({
4038
4286
  id: "components.Wysiwyg.collapse",
4039
4287
  defaultMessage: "Collapse"
@@ -4051,12 +4299,14 @@ const EditorLayout = ({
4051
4299
  ) }) });
4052
4300
  }
4053
4301
  return /* @__PURE__ */ jsx(
4054
- Box,
4302
+ Flex,
4055
4303
  {
4056
4304
  borderColor: error ? "danger600" : "neutral200",
4057
4305
  borderStyle: "solid",
4058
4306
  borderWidth: "1px",
4059
4307
  hasRadius: true,
4308
+ direction: "column",
4309
+ alignItems: "stretch",
4060
4310
  children
4061
4311
  }
4062
4312
  );
@@ -4067,11 +4317,19 @@ const ExpandWrapper = styled(Flex)`
4067
4317
  const BoxWithBorder = styled(Box)`
4068
4318
  border-right: 1px solid ${({ theme }) => theme.colors.neutral200};
4069
4319
  `;
4070
- const ExpandButton$1 = styled(BaseButton)`
4320
+ const ExpandButton$1 = styled(Button)`
4071
4321
  background-color: transparent;
4072
4322
  border: none;
4073
4323
  align-items: center;
4074
4324
 
4325
+ & > span {
4326
+ display: flex;
4327
+ justify-content: space-between;
4328
+ align-items: center;
4329
+ width: 100%;
4330
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4331
+ }
4332
+
4075
4333
  svg {
4076
4334
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4077
4335
 
@@ -4338,42 +4596,28 @@ const quoteAndCodeHandler = (editor, markdownType) => {
4338
4596
  insertWithoutTextToEdit(editor, markdownType, line, contentLength);
4339
4597
  }
4340
4598
  };
4341
- const CustomIconButton = styled(IconButton)`
4342
- padding: ${({ theme }) => theme.spaces[2]};
4343
- /* Trick to prevent the outline from overflowing because of the general outline-offset */
4344
- outline-offset: -2px !important;
4345
-
4346
- svg {
4347
- width: 1.8rem;
4348
- height: 1.8rem;
4349
- }
4350
- `;
4351
- const CustomLinkIconButton = styled(CustomIconButton)`
4352
- svg {
4353
- width: 0.8rem;
4354
- height: 0.8rem;
4355
- }
4356
- `;
4357
4599
  const MainButtons = styled(IconButtonGroup)`
4358
4600
  margin-left: ${({ theme }) => theme.spaces[4]};
4359
4601
  `;
4360
4602
  const MoreButton = styled(IconButton)`
4361
4603
  margin: ${({ theme }) => `0 ${theme.spaces[2]}`};
4362
- padding: ${({ theme }) => theme.spaces[2]};
4363
-
4364
- svg {
4365
- width: 1.8rem;
4366
- height: 1.8rem;
4367
- }
4368
4604
  `;
4369
4605
  const IconButtonGroupMargin = styled(IconButtonGroup)`
4370
4606
  margin-right: ${({ theme }) => `${theme.spaces[2]}`};
4371
4607
  `;
4372
- const ExpandButton = styled(BaseButton)`
4608
+ const ExpandButton = styled(Button)`
4373
4609
  background-color: transparent;
4374
4610
  border: none;
4375
4611
  align-items: center;
4376
4612
 
4613
+ & > span {
4614
+ display: flex;
4615
+ justify-content: space-between;
4616
+ align-items: center;
4617
+ width: 100%;
4618
+ font-weight: ${({ theme }) => theme.fontWeights.regular};
4619
+ }
4620
+
4377
4621
  svg {
4378
4622
  margin-left: ${({ theme }) => `${theme.spaces[2]}`};
4379
4623
  path {
@@ -4385,8 +4629,8 @@ const ExpandButton = styled(BaseButton)`
4385
4629
  `;
4386
4630
  const WysiwygFooter = ({ onToggleExpand }) => {
4387
4631
  const { formatMessage } = useIntl();
4388
- 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: [
4389
- /* @__PURE__ */ jsx(Typography, { children: formatMessage({
4632
+ 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: [
4633
+ /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
4390
4634
  id: "components.WysiwygBottomControls.fullscreen",
4391
4635
  defaultMessage: "Expand"
4392
4636
  }) }),
@@ -4408,7 +4652,7 @@ const WysiwygNav = ({
4408
4652
  id: "components.Wysiwyg.selectOptions.title",
4409
4653
  defaultMessage: "Add a title"
4410
4654
  });
4411
- const buttonMoreRef = React.useRef(null);
4655
+ React.useRef(null);
4412
4656
  const handleTogglePopover = () => {
4413
4657
  setVisiblePopover((prev) => !prev);
4414
4658
  };
@@ -4421,21 +4665,30 @@ const WysiwygNav = ({
4421
4665
  justifyContent: "space-between",
4422
4666
  borderRadius: `0.4rem 0.4rem 0 0`,
4423
4667
  children: [
4424
- /* @__PURE__ */ jsxs(StyledFlex, { children: [
4425
- /* @__PURE__ */ jsxs(SingleSelect, { disabled: true, placeholder: selectPlaceholder, size: "S", label: selectPlaceholder, children: [
4426
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
4427
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
4428
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h3", children: "h3" }),
4429
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h4", children: "h4" }),
4430
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h5", children: "h5" }),
4431
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
4432
- ] }),
4668
+ /* @__PURE__ */ jsxs(Flex, { children: [
4669
+ /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
4670
+ SingleSelect,
4671
+ {
4672
+ disabled: true,
4673
+ placeholder: selectPlaceholder,
4674
+ "aria-label": selectPlaceholder,
4675
+ size: "S",
4676
+ children: [
4677
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
4678
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
4679
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h3", children: "h3" }),
4680
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h4", children: "h4" }),
4681
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h5", children: "h5" }),
4682
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
4683
+ ]
4684
+ }
4685
+ ) }),
4433
4686
  /* @__PURE__ */ jsxs(MainButtons, { children: [
4434
- /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Bold", name: "Bold", icon: /* @__PURE__ */ jsx(Bold, {}) }),
4435
- /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Italic", name: "Italic", icon: /* @__PURE__ */ jsx(Italic, {}) }),
4436
- /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Underline", name: "Underline", icon: /* @__PURE__ */ jsx(Underline, {}) })
4687
+ /* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
4688
+ /* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsx(Italic, {}) }),
4689
+ /* @__PURE__ */ jsx(IconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsx(Underline, {}) })
4437
4690
  ] }),
4438
- /* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More", icon: /* @__PURE__ */ jsx(More, {}) })
4691
+ /* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsx(More, {}) })
4439
4692
  ] }),
4440
4693
  !isExpandMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
4441
4694
  id: "components.Wysiwyg.ToggleMode.markdown-mode",
@@ -4453,14 +4706,14 @@ const WysiwygNav = ({
4453
4706
  justifyContent: "space-between",
4454
4707
  borderRadius: `0.4rem 0.4rem 0 0`,
4455
4708
  children: [
4456
- /* @__PURE__ */ jsxs(StyledFlex, { children: [
4457
- /* @__PURE__ */ jsxs(
4709
+ /* @__PURE__ */ jsxs(Flex, { children: [
4710
+ /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
4458
4711
  SingleSelect,
4459
4712
  {
4460
4713
  placeholder: selectPlaceholder,
4461
- label: selectPlaceholder,
4462
- size: "S",
4714
+ "aria-label": selectPlaceholder,
4463
4715
  onChange: (value) => onActionClick(value, editorRef),
4716
+ size: "S",
4464
4717
  children: [
4465
4718
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
4466
4719
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
@@ -4470,117 +4723,103 @@ const WysiwygNav = ({
4470
4723
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
4471
4724
  ]
4472
4725
  }
4473
- ),
4726
+ ) }),
4474
4727
  /* @__PURE__ */ jsxs(MainButtons, { children: [
4728
+ /* @__PURE__ */ jsx(IconButton, { onClick: () => onActionClick("Bold", editorRef), label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
4475
4729
  /* @__PURE__ */ jsx(
4476
- CustomIconButton,
4477
- {
4478
- onClick: () => onActionClick("Bold", editorRef),
4479
- label: "Bold",
4480
- name: "Bold",
4481
- icon: /* @__PURE__ */ jsx(Bold, {})
4482
- }
4483
- ),
4484
- /* @__PURE__ */ jsx(
4485
- CustomIconButton,
4730
+ IconButton,
4486
4731
  {
4487
4732
  onClick: () => onActionClick("Italic", editorRef),
4488
4733
  label: "Italic",
4489
4734
  name: "Italic",
4490
- icon: /* @__PURE__ */ jsx(Italic, {})
4735
+ children: /* @__PURE__ */ jsx(Italic, {})
4491
4736
  }
4492
4737
  ),
4493
4738
  /* @__PURE__ */ jsx(
4494
- CustomIconButton,
4739
+ IconButton,
4495
4740
  {
4496
4741
  onClick: () => onActionClick("Underline", editorRef),
4497
4742
  label: "Underline",
4498
4743
  name: "Underline",
4499
- icon: /* @__PURE__ */ jsx(Underline, {})
4744
+ children: /* @__PURE__ */ jsx(Underline, {})
4500
4745
  }
4501
4746
  )
4502
4747
  ] }),
4503
- /* @__PURE__ */ jsx(
4504
- MoreButton,
4505
- {
4506
- ref: buttonMoreRef,
4507
- onClick: handleTogglePopover,
4508
- label: "More",
4509
- icon: /* @__PURE__ */ jsx(More, {})
4510
- }
4511
- ),
4512
- visiblePopover && /* @__PURE__ */ jsx(Popover, { onDismiss: handleTogglePopover, centered: true, source: buttonMoreRef, spacing: 4, children: /* @__PURE__ */ jsxs(Flex, { children: [
4513
- /* @__PURE__ */ jsxs(IconButtonGroupMargin, { children: [
4514
- /* @__PURE__ */ jsx(
4515
- CustomIconButton,
4516
- {
4517
- onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4518
- label: "Strikethrough",
4519
- name: "Strikethrough",
4520
- icon: /* @__PURE__ */ jsx(StrikeThrough, {})
4521
- }
4522
- ),
4523
- /* @__PURE__ */ jsx(
4524
- CustomIconButton,
4525
- {
4526
- onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4527
- label: "BulletList",
4528
- name: "BulletList",
4529
- icon: /* @__PURE__ */ jsx(BulletList, {})
4530
- }
4531
- ),
4532
- /* @__PURE__ */ jsx(
4533
- CustomIconButton,
4534
- {
4535
- onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4536
- label: "NumberList",
4537
- name: "NumberList",
4538
- icon: /* @__PURE__ */ jsx(NumberList, {})
4539
- }
4540
- )
4541
- ] }),
4542
- /* @__PURE__ */ jsxs(IconButtonGroup, { children: [
4543
- /* @__PURE__ */ jsx(
4544
- CustomIconButton,
4545
- {
4546
- onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4547
- label: "Code",
4548
- name: "Code",
4549
- icon: /* @__PURE__ */ jsx(Code, {})
4550
- }
4551
- ),
4552
- /* @__PURE__ */ jsx(
4553
- CustomIconButton,
4554
- {
4555
- onClick: () => {
4556
- handleTogglePopover();
4557
- onToggleMediaLib();
4558
- },
4559
- label: "Image",
4560
- name: "Image",
4561
- icon: /* @__PURE__ */ jsx(Image$1, {})
4562
- }
4563
- ),
4564
- /* @__PURE__ */ jsx(
4565
- CustomLinkIconButton,
4566
- {
4567
- onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4568
- label: "Link",
4569
- name: "Link",
4570
- icon: /* @__PURE__ */ jsx(Link$1, {})
4571
- }
4572
- ),
4573
- /* @__PURE__ */ jsx(
4574
- CustomIconButton,
4575
- {
4576
- onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4577
- label: "Quote",
4578
- name: "Quote",
4579
- icon: /* @__PURE__ */ jsx(Quotes, {})
4580
- }
4581
- )
4582
- ] })
4583
- ] }) })
4748
+ /* @__PURE__ */ jsxs(Popover.Root, { children: [
4749
+ /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(MoreButton, { label: "More", children: /* @__PURE__ */ jsx(More, {}) }) }),
4750
+ /* @__PURE__ */ jsx(Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxs(Flex, { padding: 2, children: [
4751
+ /* @__PURE__ */ jsxs(IconButtonGroupMargin, { children: [
4752
+ /* @__PURE__ */ jsx(
4753
+ IconButton,
4754
+ {
4755
+ onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4756
+ label: "Strikethrough",
4757
+ name: "Strikethrough",
4758
+ children: /* @__PURE__ */ jsx(StrikeThrough, {})
4759
+ }
4760
+ ),
4761
+ /* @__PURE__ */ jsx(
4762
+ IconButton,
4763
+ {
4764
+ onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4765
+ label: "BulletList",
4766
+ name: "BulletList",
4767
+ children: /* @__PURE__ */ jsx(BulletList, {})
4768
+ }
4769
+ ),
4770
+ /* @__PURE__ */ jsx(
4771
+ IconButton,
4772
+ {
4773
+ onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4774
+ label: "NumberList",
4775
+ name: "NumberList",
4776
+ children: /* @__PURE__ */ jsx(NumberList, {})
4777
+ }
4778
+ )
4779
+ ] }),
4780
+ /* @__PURE__ */ jsxs(IconButtonGroup, { children: [
4781
+ /* @__PURE__ */ jsx(
4782
+ IconButton,
4783
+ {
4784
+ onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4785
+ label: "Code",
4786
+ name: "Code",
4787
+ children: /* @__PURE__ */ jsx(Code, {})
4788
+ }
4789
+ ),
4790
+ /* @__PURE__ */ jsx(
4791
+ IconButton,
4792
+ {
4793
+ onClick: () => {
4794
+ handleTogglePopover();
4795
+ onToggleMediaLib();
4796
+ },
4797
+ label: "Image",
4798
+ name: "Image",
4799
+ children: /* @__PURE__ */ jsx(Image$1, {})
4800
+ }
4801
+ ),
4802
+ /* @__PURE__ */ jsx(
4803
+ IconButton,
4804
+ {
4805
+ onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4806
+ label: "Link",
4807
+ name: "Link",
4808
+ children: /* @__PURE__ */ jsx(Link$1, {})
4809
+ }
4810
+ ),
4811
+ /* @__PURE__ */ jsx(
4812
+ IconButton,
4813
+ {
4814
+ onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4815
+ label: "Quote",
4816
+ name: "Quote",
4817
+ children: /* @__PURE__ */ jsx(Quotes, {})
4818
+ }
4819
+ )
4820
+ ] })
4821
+ ] }) })
4822
+ ] })
4584
4823
  ] }),
4585
4824
  onTogglePreviewMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
4586
4825
  id: "components.Wysiwyg.ToggleMode.preview-mode",
@@ -4590,19 +4829,6 @@ const WysiwygNav = ({
4590
4829
  }
4591
4830
  );
4592
4831
  };
4593
- const StyledFlex = styled(Flex)`
4594
- /* Hide the label, every input needs a label. */
4595
- label {
4596
- border: 0;
4597
- clip: rect(0 0 0 0);
4598
- height: 1px;
4599
- margin: -1px;
4600
- overflow: hidden;
4601
- padding: 0;
4602
- position: absolute;
4603
- width: 1px;
4604
- }
4605
- `;
4606
4832
  const Wysiwyg = React.forwardRef(
4607
4833
  ({ hint, disabled, label, name: name2, placeholder, required, labelAction }, forwardedRef) => {
4608
4834
  const field = useField(name2);
@@ -4667,9 +4893,9 @@ const Wysiwyg = React.forwardRef(
4667
4893
  insertFile(editorRef, formattedFiles);
4668
4894
  setMediaLibVisible(false);
4669
4895
  };
4670
- return /* @__PURE__ */ jsxs(Field, { name: name2, hint, error: field.error, required, children: [
4896
+ return /* @__PURE__ */ jsxs(Field.Root, { name: name2, hint, error: field.error, required, children: [
4671
4897
  /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
4672
- /* @__PURE__ */ jsx(FieldLabel, { action: labelAction, children: label }),
4898
+ /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
4673
4899
  /* @__PURE__ */ jsxs(
4674
4900
  EditorLayout,
4675
4901
  {
@@ -4710,24 +4936,29 @@ const Wysiwyg = React.forwardRef(
4710
4936
  ]
4711
4937
  }
4712
4938
  ),
4713
- /* @__PURE__ */ jsx(FieldHint, {}),
4714
- /* @__PURE__ */ jsx(FieldError, {})
4939
+ /* @__PURE__ */ jsx(Field.Hint, {}),
4940
+ /* @__PURE__ */ jsx(Field.Error, {})
4715
4941
  ] }),
4716
4942
  mediaLibVisible && // @ts-expect-error – TODO: fix this way of injecting because it's not really typeable without a registry.
4717
4943
  /* @__PURE__ */ jsx(MediaLibraryDialog, { onClose: handleToggleMediaLib, onSelectAssets: handleSelectAssets })
4718
4944
  ] });
4719
4945
  }
4720
4946
  );
4947
+ const MemoizedWysiwyg = React.memo(Wysiwyg);
4721
4948
  const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4722
- const { id } = useDoc();
4949
+ const { id, document: document2, collectionType } = useDoc();
4723
4950
  const isFormDisabled = useForm("InputRenderer", (state) => state.disabled);
4724
4951
  const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
4725
4952
  const canCreateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
4726
4953
  const canReadFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
4727
4954
  const canUpdateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
4728
4955
  const canUserAction = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
4729
- const editableFields = id ? canUpdateFields : canCreateFields;
4730
- const readableFields = id ? canReadFields : canCreateFields;
4956
+ let idToCheck = id;
4957
+ if (collectionType === SINGLE_TYPES) {
4958
+ idToCheck = document2?.documentId;
4959
+ }
4960
+ const editableFields = idToCheck ? canUpdateFields : canCreateFields;
4961
+ const readableFields = idToCheck ? canReadFields : canCreateFields;
4731
4962
  const canUserReadField = canUserAction(props.name, readableFields, props.type);
4732
4963
  const canUserEditField = canUserAction(props.name, editableFields, props.type);
4733
4964
  const fields = useStrapiApp("InputRenderer", (app) => app.fields);
@@ -4738,6 +4969,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4738
4969
  const {
4739
4970
  edit: { components }
4740
4971
  } = useDocLayout();
4972
+ const field = useField(props.name);
4741
4973
  if (!visible) {
4742
4974
  return null;
4743
4975
  }
@@ -4748,7 +4980,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4748
4980
  if (attributeHasCustomFieldProperty(props.attribute)) {
4749
4981
  const CustomInput = lazyComponentStore[props.attribute.customField];
4750
4982
  if (CustomInput) {
4751
- return /* @__PURE__ */ jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4983
+ return /* @__PURE__ */ jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
4752
4984
  }
4753
4985
  return /* @__PURE__ */ jsx(
4754
4986
  InputRenderer$1,
@@ -4767,10 +4999,10 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4767
4999
  }
4768
5000
  switch (props.type) {
4769
5001
  case "blocks":
4770
- return /* @__PURE__ */ jsx(BlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5002
+ return /* @__PURE__ */ jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4771
5003
  case "component":
4772
5004
  return /* @__PURE__ */ jsx(
4773
- ComponentInput,
5005
+ MemoizedComponentInput,
4774
5006
  {
4775
5007
  ...props,
4776
5008
  hint,
@@ -4782,11 +5014,11 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4782
5014
  case "dynamiczone":
4783
5015
  return /* @__PURE__ */ jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
4784
5016
  case "relation":
4785
- return /* @__PURE__ */ jsx(RelationsField, { ...props, hint, disabled: fieldIsDisabled });
5017
+ return /* @__PURE__ */ jsx(MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
4786
5018
  case "richtext":
4787
- return /* @__PURE__ */ jsx(Wysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5019
+ return /* @__PURE__ */ jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4788
5020
  case "uid":
4789
- return /* @__PURE__ */ jsx(UIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5021
+ return /* @__PURE__ */ jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4790
5022
  case "enumeration":
4791
5023
  return /* @__PURE__ */ jsx(
4792
5024
  InputRenderer$1,
@@ -4818,7 +5050,9 @@ const useFieldHint = (hint = void 0, attribute) => {
4818
5050
  if (!maximum && !minimum) {
4819
5051
  return hint;
4820
5052
  }
4821
- const units = !["biginteger", "integer", "number"].includes(attribute.type) ? formatMessage(
5053
+ const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
5054
+ attribute.type
5055
+ ) ? formatMessage(
4822
5056
  {
4823
5057
  id: "content-manager.form.Input.hint.character.unit",
4824
5058
  defaultMessage: "{maxValue, plural, one { character} other { characters}}"
@@ -4858,6 +5092,7 @@ const getMinMax = (attribute) => {
4858
5092
  return { maximum: void 0, minimum: void 0 };
4859
5093
  }
4860
5094
  };
5095
+ const MemoizedInputRenderer = memo(InputRenderer);
4861
5096
  const DynamicComponent = ({
4862
5097
  componentUid,
4863
5098
  disabled,
@@ -4871,7 +5106,6 @@ const DynamicComponent = ({
4871
5106
  dynamicComponentsByCategory = {},
4872
5107
  onAddComponent
4873
5108
  }) => {
4874
- const [isOpen, setIsOpen] = React.useState(true);
4875
5109
  const { formatMessage } = useIntl();
4876
5110
  const formValues = useForm("DynamicComponent", (state) => state.values);
4877
5111
  const {
@@ -4880,7 +5114,7 @@ const DynamicComponent = ({
4880
5114
  const title = React.useMemo(() => {
4881
5115
  const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
4882
5116
  const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
4883
- const displayedValue = mainField === "id" ? "" : String(mainFieldValue).trim();
5117
+ const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
4884
5118
  const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
4885
5119
  return mainValue;
4886
5120
  }, [componentUid, components, formValues, name2, index]);
@@ -4891,9 +5125,6 @@ const DynamicComponent = ({
4891
5125
  ) ?? { icon: null, displayName: null };
4892
5126
  return { icon: icon2, displayName: displayName2 };
4893
5127
  }, [componentUid, dynamicComponentsByCategory]);
4894
- const handleToggle = () => {
4895
- setIsOpen((s) => !s);
4896
- };
4897
5128
  const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
4898
5129
  type: `${ItemTypes.DYNAMIC_ZONE}_${name2}`,
4899
5130
  index,
@@ -4910,12 +5141,20 @@ const DynamicComponent = ({
4910
5141
  React.useEffect(() => {
4911
5142
  dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
4912
5143
  }, [dragPreviewRef, index]);
5144
+ const accordionValue = React.useId();
5145
+ const { value = [], rawError } = useField(`${name2}.${index}`);
5146
+ const [collapseToOpen, setCollapseToOpen] = React.useState("");
5147
+ React.useEffect(() => {
5148
+ if (rawError && value) {
5149
+ setCollapseToOpen(accordionValue);
5150
+ }
5151
+ }, [rawError, value, accordionValue]);
4913
5152
  const composedBoxRefs = useComposedRefs(boxRef, dropRef);
4914
- const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(ActionsFlex, { gap: 0, children: [
5153
+ const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
4915
5154
  /* @__PURE__ */ jsx(
4916
- IconButtonCustom,
5155
+ IconButton,
4917
5156
  {
4918
- borderWidth: 0,
5157
+ variant: "ghost",
4919
5158
  label: formatMessage(
4920
5159
  {
4921
5160
  id: getTranslation("components.DynamicZone.delete-label"),
@@ -4930,10 +5169,7 @@ const DynamicComponent = ({
4930
5169
  /* @__PURE__ */ jsx(
4931
5170
  IconButton,
4932
5171
  {
4933
- forwardedAs: "div",
4934
- role: "button",
4935
- borderWidth: 0,
4936
- tabIndex: 0,
5172
+ variant: "ghost",
4937
5173
  onClick: (e) => e.stopPropagation(),
4938
5174
  "data-handler-id": handlerId,
4939
5175
  ref: dragRef,
@@ -4948,7 +5184,7 @@ const DynamicComponent = ({
4948
5184
  /* @__PURE__ */ jsxs(Menu.Root, { children: [
4949
5185
  /* @__PURE__ */ jsxs(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
4950
5186
  /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
4951
- /* @__PURE__ */ jsx(VisuallyHidden, { as: "span", children: formatMessage({
5187
+ /* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
4952
5188
  id: getTranslation("components.DynamicZone.more-actions"),
4953
5189
  defaultMessage: "More actions"
4954
5190
  }) })
@@ -4977,42 +5213,49 @@ const DynamicComponent = ({
4977
5213
  ] })
4978
5214
  ] })
4979
5215
  ] });
4980
- return /* @__PURE__ */ jsxs(ComponentContainer, { as: "li", width: "100%", children: [
5216
+ const accordionTitle = title ? `${displayName} ${title}` : displayName;
5217
+ return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
4981
5218
  /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
4982
- /* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsxs(Accordion, { expanded: isOpen, onToggle: handleToggle, size: "S", children: [
4983
- /* @__PURE__ */ jsx(
4984
- AccordionToggle,
5219
+ /* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
5220
+ /* @__PURE__ */ jsxs(Accordion.Header, { children: [
5221
+ /* @__PURE__ */ jsx(
5222
+ Accordion.Trigger,
5223
+ {
5224
+ icon: icon && COMPONENT_ICONS[icon] ? COMPONENT_ICONS[icon] : COMPONENT_ICONS.dashboard,
5225
+ children: accordionTitle
5226
+ }
5227
+ ),
5228
+ /* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
5229
+ ] }),
5230
+ /* @__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(
5231
+ Grid$1.Item,
4985
5232
  {
4986
- startIcon: /* @__PURE__ */ jsx(ComponentIcon, { icon, showBackground: false, size: "S" }),
4987
- action: accordionActions,
4988
- title: `${displayName} ${title}`,
4989
- togglePosition: "left"
4990
- }
4991
- ),
4992
- /* @__PURE__ */ jsx(AccordionContent$1, { 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 }) => {
4993
- const fieldName = `${name2}.${index}.${field.name}`;
4994
- return /* @__PURE__ */ jsx(GridItem, { col: size, s: 12, xs: 12, children: /* @__PURE__ */ jsx(InputRenderer, { ...field, name: fieldName }) }, fieldName);
4995
- }) }, rowInd)) }) }) })
4996
- ] }) })
5233
+ col: 12,
5234
+ s: 12,
5235
+ xs: 12,
5236
+ direction: "column",
5237
+ alignItems: "stretch",
5238
+ children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
5239
+ const fieldName = `${name2}.${index}.${field.name}`;
5240
+ return /* @__PURE__ */ jsx(
5241
+ Grid$1.Item,
5242
+ {
5243
+ col: size,
5244
+ s: 12,
5245
+ xs: 12,
5246
+ direction: "column",
5247
+ alignItems: "stretch",
5248
+ children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...field, name: fieldName })
5249
+ },
5250
+ fieldName
5251
+ );
5252
+ }) })
5253
+ },
5254
+ rowInd
5255
+ )) }) }) }) })
5256
+ ] }) }) })
4997
5257
  ] });
4998
5258
  };
4999
- const ActionsFlex = styled(Flex)`
5000
- /*
5001
- we need to remove the background from the button but we can't
5002
- wrap the element in styled because it breaks the forwardedAs which
5003
- we need for drag handler to work on firefox
5004
- */
5005
- div[role='button'] {
5006
- background: transparent;
5007
- }
5008
- `;
5009
- const IconButtonCustom = styled(IconButton)`
5010
- background-color: transparent;
5011
-
5012
- svg path {
5013
- fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
5014
- }
5015
- `;
5016
5259
  const StyledBox = styled(Box)`
5017
5260
  > div:first-child {
5018
5261
  box-shadow: ${({ theme }) => theme.shadows.tableShadow};
@@ -5083,7 +5326,7 @@ const [DynamicZoneProvider, useDynamicZone] = createContext(
5083
5326
  );
5084
5327
  const DynamicZone = ({
5085
5328
  attribute,
5086
- disabled,
5329
+ disabled: disabledProp,
5087
5330
  hint,
5088
5331
  label,
5089
5332
  labelAction,
@@ -5093,7 +5336,8 @@ const DynamicZone = ({
5093
5336
  const { max = Infinity, min = -Infinity } = attribute ?? {};
5094
5337
  const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
5095
5338
  const [liveText, setLiveText] = React.useState("");
5096
- const { components } = useDoc();
5339
+ const { components, isLoading } = useDoc();
5340
+ const disabled = disabledProp || isLoading;
5097
5341
  const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
5098
5342
  "DynamicZone",
5099
5343
  ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
@@ -5200,7 +5444,7 @@ const DynamicZone = ({
5200
5444
  const handleRemoveComponent = (name22, currentIndex) => () => {
5201
5445
  removeFieldRow(name22, currentIndex);
5202
5446
  };
5203
- const hasError = error !== void 0 || dynamicDisplayedComponentsLength < min || dynamicDisplayedComponentsLength > max;
5447
+ const hasError = error !== void 0;
5204
5448
  const renderButtonLabel = () => {
5205
5449
  if (addComponentIsOpen) {
5206
5450
  return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
@@ -5301,19 +5545,19 @@ const DynamicZone = ({
5301
5545
  ] }) });
5302
5546
  };
5303
5547
  export {
5304
- BlocksInput as B,
5305
- ComponentInput as C,
5306
5548
  DynamicZone as D,
5307
- InputRenderer as I,
5549
+ MemoizedInputRenderer as M,
5308
5550
  NotAllowedInput as N,
5309
- UIDInput as U,
5310
- Wysiwyg as W,
5311
5551
  useDynamicZone as a,
5312
5552
  useFieldHint as b,
5313
5553
  createDefaultForm as c,
5554
+ MemoizedUIDInput as d,
5555
+ MemoizedWysiwyg as e,
5556
+ MemoizedComponentInput as f,
5557
+ MemoizedBlocksInput as g,
5314
5558
  prepareTempKeys as p,
5315
5559
  removeFieldsThatDontExistOnSchema as r,
5316
5560
  transformDocument as t,
5317
5561
  useLazyComponents as u
5318
5562
  };
5319
- //# sourceMappingURL=Field-kVFO4ZKB.mjs.map
5563
+ //# sourceMappingURL=Field-DIjL1b5d.mjs.map