@strapi/content-manager 0.0.0-experimental.e60ec1829240dae21c1e1d29076681c322288813 → 0.0.0-experimental.f31889311d753b5f7d95198ae84d8fce1d156cd6

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 (175) 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-DjWJdz6Y.js → ComponentConfigurationPage-BNxtMIfV.js} +3 -3
  7. package/dist/_chunks/{ComponentConfigurationPage-DjWJdz6Y.js.map → ComponentConfigurationPage-BNxtMIfV.js.map} +1 -1
  8. package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs → ComponentConfigurationPage-BWOQWCv2.mjs} +3 -3
  9. package/dist/_chunks/{ComponentConfigurationPage-BPvzFjM7.mjs.map → ComponentConfigurationPage-BWOQWCv2.mjs.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-Dmv83RlS.js → EditConfigurationPage-D340bYlT.js} +3 -3
  15. package/dist/_chunks/{EditConfigurationPage-Dmv83RlS.js.map → EditConfigurationPage-D340bYlT.js.map} +1 -1
  16. package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs → EditConfigurationPage-GTp-Ucnw.mjs} +3 -3
  17. package/dist/_chunks/{EditConfigurationPage-DacbqQ_f.mjs.map → EditConfigurationPage-GTp-Ucnw.mjs.map} +1 -1
  18. package/dist/_chunks/{EditViewPage-DDS6H9HO.mjs → EditViewPage-BVMS5hT-.mjs} +47 -47
  19. package/dist/_chunks/EditViewPage-BVMS5hT-.mjs.map +1 -0
  20. package/dist/_chunks/{EditViewPage-DvNpQkam.js → EditViewPage-CXkmnAvI.js} +46 -48
  21. package/dist/_chunks/EditViewPage-CXkmnAvI.js.map +1 -0
  22. package/dist/_chunks/{Field-DmVKIAOo.js → Field-Ibi32diw.js} +953 -782
  23. package/dist/_chunks/Field-Ibi32diw.js.map +1 -0
  24. package/dist/_chunks/{Field-6gvGdPBV.mjs → Field-nNgv5bpd.mjs} +901 -729
  25. package/dist/_chunks/Field-nNgv5bpd.mjs.map +1 -0
  26. package/dist/_chunks/{Form-CPZC9vWa.js → Form-Dhnh34ym.js} +39 -38
  27. package/dist/_chunks/Form-Dhnh34ym.js.map +1 -0
  28. package/dist/_chunks/{Form-DW6K1IH-.mjs → Form-DodJsI2A.mjs} +39 -37
  29. package/dist/_chunks/Form-DodJsI2A.mjs.map +1 -0
  30. package/dist/_chunks/{History-DeAPlvtv.js → History-C9auUkDi.js} +149 -56
  31. package/dist/_chunks/History-C9auUkDi.js.map +1 -0
  32. package/dist/_chunks/{History-Dmr9fmUA.mjs → History-CKCSQXz_.mjs} +148 -54
  33. package/dist/_chunks/History-CKCSQXz_.mjs.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-DPCwW5Vr.js → ListConfigurationPage-Bg4rWUjX.js} +58 -59
  35. package/dist/_chunks/ListConfigurationPage-Bg4rWUjX.js.map +1 -0
  36. package/dist/_chunks/{ListConfigurationPage-DhwvYcNv.mjs → ListConfigurationPage-CKEC4ttG.mjs} +54 -54
  37. package/dist/_chunks/ListConfigurationPage-CKEC4ttG.mjs.map +1 -0
  38. package/dist/_chunks/{ListViewPage-BtAwuYLE.mjs → ListViewPage-B7_WJUjG.mjs} +93 -104
  39. package/dist/_chunks/ListViewPage-B7_WJUjG.mjs.map +1 -0
  40. package/dist/_chunks/{ListViewPage-5ySZ-VUs.js → ListViewPage-C2gIeYHG.js} +98 -109
  41. package/dist/_chunks/ListViewPage-C2gIeYHG.js.map +1 -0
  42. package/dist/_chunks/{NoContentTypePage-DSPxnxxp.mjs → NoContentTypePage-Ckem6Ll6.mjs} +3 -3
  43. package/dist/_chunks/NoContentTypePage-Ckem6Ll6.mjs.map +1 -0
  44. package/dist/_chunks/{NoContentTypePage-DOC_yWOf.js → NoContentTypePage-DqgdUfyn.js} +3 -3
  45. package/dist/_chunks/NoContentTypePage-DqgdUfyn.js.map +1 -0
  46. package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs → NoPermissionsPage-BO-GEjA4.mjs} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-UWDC-1Tw.mjs.map → NoPermissionsPage-BO-GEjA4.mjs.map} +1 -1
  48. package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js → NoPermissionsPage-CF29Q-sW.js} +2 -2
  49. package/dist/_chunks/{NoPermissionsPage-Dwu8rRJu.js.map → NoPermissionsPage-CF29Q-sW.js.map} +1 -1
  50. package/dist/_chunks/{Relations-CgWtgnPe.js → Relations-C0uC9J4f.js} +70 -61
  51. package/dist/_chunks/Relations-C0uC9J4f.js.map +1 -0
  52. package/dist/_chunks/{Relations-J8cscLlR.mjs → Relations-DItV5eow.mjs} +66 -56
  53. package/dist/_chunks/Relations-DItV5eow.mjs.map +1 -0
  54. package/dist/_chunks/{en-MBPul9Su.mjs → en-BrCTWlZv.mjs} +11 -4
  55. package/dist/_chunks/{en-MBPul9Su.mjs.map → en-BrCTWlZv.mjs.map} +1 -1
  56. package/dist/_chunks/{en-C-V1_90f.js → en-uOUIxfcQ.js} +11 -4
  57. package/dist/_chunks/{en-C-V1_90f.js.map → en-uOUIxfcQ.js.map} +1 -1
  58. package/dist/_chunks/{index-C6AH2hEl.js → index-Dd0nXyJF.js} +1649 -905
  59. package/dist/_chunks/index-Dd0nXyJF.js.map +1 -0
  60. package/dist/_chunks/{index-CwRRo1V9.mjs → index-DrNe6ctw.mjs} +1671 -926
  61. package/dist/_chunks/index-DrNe6ctw.mjs.map +1 -0
  62. package/dist/_chunks/{layout-jIDzX0Fp.mjs → layout-B3ez7kvr.mjs} +43 -26
  63. package/dist/_chunks/layout-B3ez7kvr.mjs.map +1 -0
  64. package/dist/_chunks/{layout-B_SXLhqf.js → layout-CLLtt_5O.js} +43 -28
  65. package/dist/_chunks/layout-CLLtt_5O.js.map +1 -0
  66. package/dist/_chunks/{relations-CuvIgCqI.mjs → relations-B0hlsUU_.mjs} +2 -2
  67. package/dist/_chunks/{relations-CuvIgCqI.mjs.map → relations-B0hlsUU_.mjs.map} +1 -1
  68. package/dist/_chunks/{relations-iBMa_OFG.js → relations-bRxcNv1q.js} +2 -2
  69. package/dist/_chunks/{relations-iBMa_OFG.js.map → relations-bRxcNv1q.js.map} +1 -1
  70. package/dist/_chunks/useDragAndDrop-DdHgKsqq.mjs.map +1 -1
  71. package/dist/_chunks/useDragAndDrop-J0TUUbR6.js.map +1 -1
  72. package/dist/_chunks/usePrev-B9w_-eYc.js +15 -0
  73. package/dist/_chunks/usePrev-B9w_-eYc.js.map +1 -0
  74. package/dist/_chunks/usePrev-DH6iah0A.mjs +16 -0
  75. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -0
  76. package/dist/admin/index.js +2 -1
  77. package/dist/admin/index.js.map +1 -1
  78. package/dist/admin/index.mjs +5 -4
  79. package/dist/admin/src/components/ComponentIcon.d.ts +6 -3
  80. package/dist/admin/src/content-manager.d.ts +3 -3
  81. package/dist/admin/src/exports.d.ts +1 -0
  82. package/dist/admin/src/history/components/VersionInputRenderer.d.ts +1 -1
  83. package/dist/admin/src/history/index.d.ts +3 -0
  84. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  85. package/dist/admin/src/hooks/useDocument.d.ts +5 -8
  86. package/dist/admin/src/hooks/useDocumentActions.d.ts +24 -3
  87. package/dist/admin/src/hooks/useDocumentLayout.d.ts +2 -2
  88. package/dist/admin/src/hooks/useDragAndDrop.d.ts +4 -4
  89. package/dist/admin/src/hooks/useKeyboardDragAndDrop.d.ts +1 -1
  90. package/dist/admin/src/index.d.ts +1 -0
  91. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +11 -4
  92. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +3 -3
  93. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +4 -0
  94. package/dist/admin/src/pages/EditView/components/FormInputs/Component/Input.d.ts +2 -2
  95. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.d.ts +3 -5
  96. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +1 -1
  97. package/dist/admin/src/pages/EditView/components/FormInputs/Relations.d.ts +30 -18
  98. package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +2 -2
  99. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +3 -49
  100. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Field.d.ts +2 -2
  101. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +59 -52
  102. package/dist/admin/src/pages/EditView/components/InputRenderer.d.ts +2 -10
  103. package/dist/admin/src/pages/ListView/components/BulkActions/Actions.d.ts +3 -30
  104. package/dist/admin/src/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.d.ts +2 -2
  105. package/dist/admin/src/pages/ListView/components/BulkActions/PublishAction.d.ts +9 -26
  106. package/dist/admin/src/services/api.d.ts +2 -3
  107. package/dist/admin/src/services/components.d.ts +2 -2
  108. package/dist/admin/src/services/contentTypes.d.ts +5 -5
  109. package/dist/admin/src/services/documents.d.ts +29 -17
  110. package/dist/admin/src/services/init.d.ts +2 -2
  111. package/dist/admin/src/services/relations.d.ts +3 -3
  112. package/dist/admin/src/services/uid.d.ts +3 -3
  113. package/dist/admin/src/utils/api.d.ts +4 -18
  114. package/dist/admin/src/utils/validation.d.ts +1 -6
  115. package/dist/server/index.js +392 -261
  116. package/dist/server/index.js.map +1 -1
  117. package/dist/server/index.mjs +400 -269
  118. package/dist/server/index.mjs.map +1 -1
  119. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  120. package/dist/server/src/controllers/single-types.d.ts.map +1 -1
  121. package/dist/server/src/controllers/uid.d.ts.map +1 -1
  122. package/dist/server/src/controllers/utils/metadata.d.ts +8 -0
  123. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -0
  124. package/dist/server/src/controllers/validation/dimensions.d.ts +11 -0
  125. package/dist/server/src/controllers/validation/dimensions.d.ts.map +1 -0
  126. package/dist/server/src/controllers/validation/index.d.ts +1 -1
  127. package/dist/server/src/history/services/history.d.ts.map +1 -1
  128. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  129. package/dist/server/src/history/services/utils.d.ts +1 -1
  130. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  131. package/dist/server/src/index.d.ts +18 -39
  132. package/dist/server/src/index.d.ts.map +1 -1
  133. package/dist/server/src/services/document-manager.d.ts +13 -12
  134. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  135. package/dist/server/src/services/document-metadata.d.ts +8 -29
  136. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  137. package/dist/server/src/services/index.d.ts +18 -39
  138. package/dist/server/src/services/index.d.ts.map +1 -1
  139. package/dist/server/src/services/utils/populate.d.ts +8 -1
  140. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  141. package/dist/shared/contracts/collection-types.d.ts +14 -6
  142. package/dist/shared/contracts/collection-types.d.ts.map +1 -1
  143. package/dist/shared/contracts/relations.d.ts +2 -2
  144. package/dist/shared/contracts/relations.d.ts.map +1 -1
  145. package/package.json +13 -14
  146. package/dist/_chunks/CardDragPreview-DSVYodBX.js.map +0 -1
  147. package/dist/_chunks/CardDragPreview-ikSG4M46.mjs.map +0 -1
  148. package/dist/_chunks/ComponentIcon-BBQsYCVn.js.map +0 -1
  149. package/dist/_chunks/ComponentIcon-BOFnK76n.mjs.map +0 -1
  150. package/dist/_chunks/EditViewPage-DDS6H9HO.mjs.map +0 -1
  151. package/dist/_chunks/EditViewPage-DvNpQkam.js.map +0 -1
  152. package/dist/_chunks/Field-6gvGdPBV.mjs.map +0 -1
  153. package/dist/_chunks/Field-DmVKIAOo.js.map +0 -1
  154. package/dist/_chunks/Form-CPZC9vWa.js.map +0 -1
  155. package/dist/_chunks/Form-DW6K1IH-.mjs.map +0 -1
  156. package/dist/_chunks/History-DeAPlvtv.js.map +0 -1
  157. package/dist/_chunks/History-Dmr9fmUA.mjs.map +0 -1
  158. package/dist/_chunks/ListConfigurationPage-DPCwW5Vr.js.map +0 -1
  159. package/dist/_chunks/ListConfigurationPage-DhwvYcNv.mjs.map +0 -1
  160. package/dist/_chunks/ListViewPage-5ySZ-VUs.js.map +0 -1
  161. package/dist/_chunks/ListViewPage-BtAwuYLE.mjs.map +0 -1
  162. package/dist/_chunks/NoContentTypePage-DOC_yWOf.js.map +0 -1
  163. package/dist/_chunks/NoContentTypePage-DSPxnxxp.mjs.map +0 -1
  164. package/dist/_chunks/Relations-CgWtgnPe.js.map +0 -1
  165. package/dist/_chunks/Relations-J8cscLlR.mjs.map +0 -1
  166. package/dist/_chunks/index-C6AH2hEl.js.map +0 -1
  167. package/dist/_chunks/index-CwRRo1V9.mjs.map +0 -1
  168. package/dist/_chunks/layout-B_SXLhqf.js.map +0 -1
  169. package/dist/_chunks/layout-jIDzX0Fp.mjs.map +0 -1
  170. package/dist/_chunks/urls-CbOsUOoW.mjs +0 -7
  171. package/dist/_chunks/urls-CbOsUOoW.mjs.map +0 -1
  172. package/dist/_chunks/urls-DzZya_gm.js +0 -6
  173. package/dist/_chunks/urls-DzZya_gm.js.map +0 -1
  174. package/dist/server/src/controllers/utils/dimensions.d.ts +0 -5
  175. package/dist/server/src/controllers/utils/dimensions.d.ts.map +0 -1
@@ -1,23 +1,23 @@
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, BaseButton, 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-CwRRo1V9.mjs";
8
+ import { m as DOCUMENT_META_FIELDS, g as getTranslation, c as useDoc, e as contentManagerApi, d as buildValidParams, f as useDocumentRBAC, n as useDocLayout } from "./index-DrNe6ctw.mjs";
9
9
  import { generateNKeysBetween } from "fractional-indexing";
10
- import { u as useComponent, C as ComponentProvider, R as RelationsField } from "./Relations-J8cscLlR.mjs";
10
+ import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-DItV5eow.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
16
  import { g as getIn } from "./objects-mKMAmfec.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 } from "./usePrev-DH6iah0A.mjs";
21
21
  import * as Toolbar from "@radix-ui/react-toolbar";
22
22
  import { useLocation } from "react-router-dom";
23
23
  import CodeMirror from "codemirror5";
@@ -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,7 +1400,7 @@ 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",
@@ -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'] {
@@ -1477,7 +1758,7 @@ const DragIconButton = styled(IconButton)`
1477
1758
  visibility: hidden;
1478
1759
  cursor: grab;
1479
1760
  opacity: inherit;
1480
- margin-top: ${(props) => props.dragHandleTopMargin ?? 0};
1761
+ margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
1481
1762
 
1482
1763
  &:hover {
1483
1764
  background: ${({ theme }) => theme.colors.neutral200};
@@ -1491,7 +1772,7 @@ const DragIconButton = styled(IconButton)`
1491
1772
  }
1492
1773
  svg {
1493
1774
  height: auto;
1494
- width: ${({ theme }) => theme.spaces[3]};
1775
+ min-width: ${({ theme }) => theme.spaces[3]};
1495
1776
 
1496
1777
  path {
1497
1778
  fill: ${({ theme }) => theme.colors.neutral700};
@@ -1552,7 +1833,7 @@ const DragAndDropElement = ({
1552
1833
  React.useEffect(() => {
1553
1834
  setDragVisibility("hidden");
1554
1835
  }, [editor.selection]);
1555
- return /* @__PURE__ */ jsxs(Wrapper$1, { ref: (ref) => composedBoxRefs(ref), isOverDropTarget, children: [
1836
+ return /* @__PURE__ */ jsxs(Wrapper$1, { ref: composedBoxRefs, isOverDropTarget, children: [
1556
1837
  isOverDropTarget && /* @__PURE__ */ jsx(
1557
1838
  DropPlaceholder,
1558
1839
  {
@@ -1590,15 +1871,16 @@ const DragAndDropElement = ({
1590
1871
  onSelect: () => setDragVisibility("visible"),
1591
1872
  onMouseLeave: () => setDragVisibility("hidden"),
1592
1873
  "aria-disabled": disabled,
1593
- dragVisibility,
1874
+ $dragVisibility: dragVisibility,
1594
1875
  children: [
1595
1876
  /* @__PURE__ */ jsx(
1596
1877
  DragIconButton,
1597
1878
  {
1598
- forwardedAs: "div",
1879
+ tag: "div",
1599
1880
  role: "button",
1600
1881
  tabIndex: 0,
1601
- "aria-label": formatMessage({
1882
+ withTooltip: false,
1883
+ label: formatMessage({
1602
1884
  id: getTranslation("components.DragHandle-label"),
1603
1885
  defaultMessage: "Drag"
1604
1886
  }),
@@ -1606,8 +1888,8 @@ const DragAndDropElement = ({
1606
1888
  "aria-disabled": disabled,
1607
1889
  disabled,
1608
1890
  draggable: true,
1609
- dragHandleTopMargin,
1610
- children: /* @__PURE__ */ jsx(Drag, { color: "neutral600" })
1891
+ $dragHandleTopMargin: dragHandleTopMargin,
1892
+ children: /* @__PURE__ */ jsx(Drag, { color: "primary500" })
1611
1893
  }
1612
1894
  ),
1613
1895
  children
@@ -1618,17 +1900,18 @@ const DragAndDropElement = ({
1618
1900
  };
1619
1901
  const CloneDragItem = ({ children, dragHandleTopMargin }) => {
1620
1902
  const { formatMessage } = useIntl();
1621
- return /* @__PURE__ */ jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", dragVisibility: "visible", children: [
1903
+ return /* @__PURE__ */ jsxs(DragItem, { gap: 2, paddingLeft: 2, alignItems: "start", $dragVisibility: "visible", children: [
1622
1904
  /* @__PURE__ */ jsx(
1623
1905
  DragIconButton,
1624
1906
  {
1625
- forwardedAs: "div",
1907
+ tag: "div",
1626
1908
  role: "button",
1627
- "aria-label": formatMessage({
1909
+ withTooltip: false,
1910
+ label: formatMessage({
1628
1911
  id: getTranslation("components.DragHandle-label"),
1629
1912
  defaultMessage: "Drag"
1630
1913
  }),
1631
- dragHandleTopMargin,
1914
+ $dragHandleTopMargin: dragHandleTopMargin,
1632
1915
  children: /* @__PURE__ */ jsx(Drag, { color: "neutral600" })
1633
1916
  }
1634
1917
  ),
@@ -1930,7 +2213,7 @@ const EditorLayout$1 = ({
1930
2213
  /* @__PURE__ */ jsx(
1931
2214
  CollapseIconButton,
1932
2215
  {
1933
- "aria-label": formatMessage({
2216
+ label: formatMessage({
1934
2217
  id: getTranslation("components.Blocks.collapse"),
1935
2218
  defaultMessage: "Collapse"
1936
2219
  }),
@@ -1950,8 +2233,8 @@ const EditorLayout$1 = ({
1950
2233
  direction: "column",
1951
2234
  alignItems: "flex-start",
1952
2235
  height: "512px",
1953
- disabled,
1954
- hasError: Boolean(error),
2236
+ $disabled: disabled,
2237
+ $hasError: Boolean(error),
1955
2238
  style: { overflow: "hidden" },
1956
2239
  "aria-describedby": ariaDescriptionId,
1957
2240
  position: "relative",
@@ -1959,6 +2242,29 @@ const EditorLayout$1 = ({
1959
2242
  }
1960
2243
  );
1961
2244
  };
2245
+ const InputWrapper = styled(Flex)`
2246
+ border: 1px solid
2247
+ ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral200};
2248
+ border-radius: ${({ theme }) => theme.borderRadius};
2249
+ background: ${({ theme }) => theme.colors.neutral0};
2250
+
2251
+ ${({ theme, $hasError = false }) => css`
2252
+ outline: none;
2253
+ box-shadow: 0;
2254
+ transition-property: border-color, box-shadow, fill;
2255
+ transition-duration: 0.2s;
2256
+
2257
+ &:focus-within {
2258
+ border: 1px solid ${$hasError ? theme.colors.danger600 : theme.colors.primary600};
2259
+ box-shadow: ${$hasError ? theme.colors.danger600 : theme.colors.primary600} 0px 0px 0px 2px;
2260
+ }
2261
+ `}
2262
+
2263
+ ${({ theme, $disabled }) => $disabled ? css`
2264
+ color: ${theme.colors.neutral600};
2265
+ background: ${theme.colors.neutral150};
2266
+ ` : void 0}
2267
+ `;
1962
2268
  const stylesToInherit = css`
1963
2269
  font-size: inherit;
1964
2270
  color: inherit;
@@ -1971,10 +2277,14 @@ const ItalicText = styled(Typography)`
1971
2277
  font-style: italic;
1972
2278
  ${stylesToInherit}
1973
2279
  `;
1974
- const UnderlineText = styled(Typography).attrs({ textDecoration: "underline" })`
2280
+ const UnderlineText = styled(Typography).attrs({
2281
+ textDecoration: "underline"
2282
+ })`
1975
2283
  ${stylesToInherit}
1976
2284
  `;
1977
- const StrikeThroughText = styled(Typography).attrs({ textDecoration: "line-through" })`
2285
+ const StrikeThroughText = styled(Typography).attrs({
2286
+ textDecoration: "line-through"
2287
+ })`
1978
2288
  ${stylesToInherit}
1979
2289
  `;
1980
2290
  const InlineCode = styled.code`
@@ -2242,7 +2552,7 @@ const BlocksEditor = React.forwardRef(
2242
2552
  !isExpandedMode && /* @__PURE__ */ jsx(
2243
2553
  ExpandIconButton,
2244
2554
  {
2245
- "aria-label": formatMessage({
2555
+ label: formatMessage({
2246
2556
  id: getTranslation("components.Blocks.expand"),
2247
2557
  defaultMessage: "Expand"
2248
2558
  }),
@@ -2265,8 +2575,8 @@ const BlocksInput = React.forwardRef(
2265
2575
  ({ label, name: name2, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {
2266
2576
  const id = React.useId();
2267
2577
  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 }),
2578
+ return /* @__PURE__ */ jsx(Field.Root, { id, name: name2, hint, error: field.error, required, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
2579
+ /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
2270
2580
  /* @__PURE__ */ jsx(
2271
2581
  BlocksEditor,
2272
2582
  {
@@ -2279,11 +2589,12 @@ const BlocksInput = React.forwardRef(
2279
2589
  ...editorProps
2280
2590
  }
2281
2591
  ),
2282
- /* @__PURE__ */ jsx(FieldHint, {}),
2283
- /* @__PURE__ */ jsx(FieldError, {})
2592
+ /* @__PURE__ */ jsx(Field.Hint, {}),
2593
+ /* @__PURE__ */ jsx(Field.Error, {})
2284
2594
  ] }) });
2285
2595
  }
2286
2596
  );
2597
+ const MemoizedBlocksInput = React.memo(BlocksInput);
2287
2598
  const createDefaultForm = (contentType, components = {}) => {
2288
2599
  const traverseSchema = (attributes) => {
2289
2600
  return Object.entries(attributes).reduce((acc, [key, attribute]) => {
@@ -2307,30 +2618,27 @@ const createDefaultForm = (contentType, components = {}) => {
2307
2618
  const Initializer = ({ disabled, name: name2, onClick }) => {
2308
2619
  const { formatMessage } = useIntl();
2309
2620
  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
- ] });
2621
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
2622
+ Box,
2623
+ {
2624
+ tag: "button",
2625
+ background: "neutral100",
2626
+ borderColor: field.error ? "danger600" : "neutral200",
2627
+ hasRadius: true,
2628
+ disabled,
2629
+ onClick,
2630
+ paddingTop: 9,
2631
+ paddingBottom: 9,
2632
+ type: "button",
2633
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
2634
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(CircleIcon, {}) }),
2635
+ /* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
2636
+ id: getTranslation("components.empty-repeatable"),
2637
+ defaultMessage: "No entry yet. Click on the button below to add one."
2638
+ }) }) })
2639
+ ] })
2640
+ }
2641
+ ) });
2334
2642
  };
2335
2643
  const CircleIcon = styled(PlusCircle)`
2336
2644
  width: 2.4rem;
@@ -2362,9 +2670,9 @@ const NonRepeatableComponent = ({
2362
2670
  hasRadius: isNested,
2363
2671
  borderColor: isNested ? "neutral200" : void 0,
2364
2672
  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 }) => {
2673
+ return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2366
2674
  const completeFieldName = `${name2}.${field.name}`;
2367
- return /* @__PURE__ */ jsx(GridItem, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2675
+ return /* @__PURE__ */ jsx(Grid$1.Item, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2368
2676
  }) }, index);
2369
2677
  }) })
2370
2678
  }
@@ -2388,7 +2696,7 @@ const RepeatableComponent = ({
2388
2696
  const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
2389
2697
  const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
2390
2698
  const { max = Infinity } = attribute;
2391
- const [collapseToOpen, setCollapseToOpen] = React.useState(null);
2699
+ const [collapseToOpen, setCollapseToOpen] = React.useState("");
2392
2700
  const [liveText, setLiveText] = React.useState("");
2393
2701
  const componentTmpKeyWithFocussedField = React.useMemo(() => {
2394
2702
  if (search.has("field")) {
@@ -2404,13 +2712,19 @@ const RepeatableComponent = ({
2404
2712
  }
2405
2713
  return void 0;
2406
2714
  }, [search, name2, value]);
2715
+ const prevValue = usePrev(value);
2716
+ React.useEffect(() => {
2717
+ if (prevValue && prevValue.length < value.length) {
2718
+ setCollapseToOpen(value[value.length - 1].__temp_key__);
2719
+ }
2720
+ }, [value, prevValue]);
2407
2721
  React.useEffect(() => {
2408
- if (typeof componentTmpKeyWithFocussedField === "number") {
2722
+ if (typeof componentTmpKeyWithFocussedField === "string") {
2409
2723
  setCollapseToOpen(componentTmpKeyWithFocussedField);
2410
2724
  }
2411
2725
  }, [componentTmpKeyWithFocussedField]);
2412
2726
  const toggleCollapses = () => {
2413
- setCollapseToOpen(null);
2727
+ setCollapseToOpen("");
2414
2728
  };
2415
2729
  const handleClick = () => {
2416
2730
  if (value.length < max) {
@@ -2442,12 +2756,8 @@ const RepeatableComponent = ({
2442
2756
  );
2443
2757
  moveFieldRow(name2, currentIndex, newIndex);
2444
2758
  };
2445
- const handleToggle = (key) => () => {
2446
- if (collapseToOpen === key) {
2447
- setCollapseToOpen(null);
2448
- } else {
2449
- setCollapseToOpen(key);
2450
- }
2759
+ const handleValueChange = (key) => {
2760
+ setCollapseToOpen(key);
2451
2761
  };
2452
2762
  const getItemPos = (index) => `${index + 1} of ${value.length}`;
2453
2763
  const handleCancel = (index) => {
@@ -2502,158 +2812,104 @@ const RepeatableComponent = ({
2502
2812
  defaultMessage: `Press spacebar to grab and re-order`
2503
2813
  }) }),
2504
2814
  /* @__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,
2815
+ /* @__PURE__ */ jsxs(
2816
+ AccordionRoot,
2817
+ {
2818
+ $error: error,
2819
+ value: collapseToOpen,
2820
+ onValueChange: handleValueChange,
2821
+ "aria-describedby": ariaDescriptionId,
2822
+ children: [
2823
+ value.map(({ __temp_key__: key, id }, index) => {
2824
+ const nameWithIndex = `${name2}.${index}`;
2825
+ return /* @__PURE__ */ jsx(
2826
+ ComponentProvider,
2517
2827
  {
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
- ] })
2828
+ id,
2829
+ uid: attribute.component,
2830
+ level: level + 1,
2831
+ type: "repeatable",
2832
+ children: /* @__PURE__ */ jsx(
2833
+ Component,
2834
+ {
2835
+ disabled,
2836
+ name: nameWithIndex,
2837
+ attribute,
2838
+ index,
2839
+ mainField,
2840
+ onMoveItem: handleMoveComponentField,
2841
+ onDeleteComponent: () => {
2842
+ removeFieldRow(name2, index);
2843
+ toggleCollapses();
2844
+ },
2845
+ toggleCollapses,
2846
+ onCancel: handleCancel,
2847
+ onDropItem: handleDropItem,
2848
+ onGrabItem: handleGrabItem,
2849
+ __temp_key__: key,
2850
+ children: layout.map((row, index2) => {
2851
+ return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2852
+ const completeFieldName = `${nameWithIndex}.${field.name}`;
2853
+ return /* @__PURE__ */ jsx(Grid$1.Item, { col: size, s: 12, xs: 12, children: children({ ...field, name: completeFieldName }) }, completeFieldName);
2854
+ }) }, index2);
2855
+ })
2856
+ }
2857
+ )
2858
+ },
2859
+ key
2860
+ );
2861
+ }),
2862
+ /* @__PURE__ */ jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsx(Plus, {}), children: formatMessage({
2863
+ id: getTranslation("containers.EditView.add.new-entry"),
2864
+ defaultMessage: "Add an entry"
2865
+ }) })
2866
+ ]
2867
+ }
2868
+ )
2551
2869
  ] });
2552
2870
  };
2871
+ const AccordionRoot = styled(Accordion.Root)`
2872
+ border: 1px solid
2873
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
2874
+ `;
2553
2875
  const TextButtonCustom = styled(TextButton)`
2554
- height: 100%;
2555
2876
  width: 100%;
2556
- border-radius: 0 0 4px 4px;
2557
2877
  display: flex;
2558
2878
  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
- }
2579
-
2580
- /* the top accordion _does_ need a border though */
2581
- & > div:first-child > div {
2582
- border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2583
- }
2584
-
2585
- /* Reset all the border-radius' */
2586
- & > div > div,
2587
- & > div > div > div {
2588
- border-radius: unset;
2589
- }
2590
-
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;
2595
- }
2879
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2880
+ padding-inline: ${(props) => props.theme.spaces[6]};
2881
+ padding-block: ${(props) => props.theme.spaces[3]};
2596
2882
 
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;
2883
+ &:not([disabled]) {
2884
+ cursor: pointer;
2609
2885
 
2610
- svg {
2611
- path {
2612
- fill: ${({ theme, expanded }) => expanded ? theme.colors.primary600 : theme.colors.neutral600};
2886
+ &:hover {
2887
+ background-color: ${(props) => props.theme.colors.primary100};
2613
2888
  }
2614
2889
  }
2615
2890
 
2616
- &:hover {
2617
- svg {
2618
- path {
2619
- fill: ${({ theme }) => theme.colors.primary600};
2620
- }
2621
- }
2891
+ span {
2892
+ font-weight: 600;
2893
+ font-size: 1.4rem;
2894
+ line-height: 2.4rem;
2622
2895
  }
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
2896
 
2634
- &:hover {
2635
- svg {
2636
- path {
2637
- /* keeps the hover style of the accordion */
2638
- fill: ${({ theme }) => theme.colors.primary600};
2639
- }
2640
- }
2641
- }
2897
+ @media (prefers-reduced-motion: no-preference) {
2898
+ transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2642
2899
  }
2643
2900
  `;
2644
2901
  const Component = ({
2645
2902
  disabled,
2646
2903
  index,
2647
- isOpen,
2648
2904
  name: name2,
2649
2905
  mainField = {
2650
2906
  name: "id",
2651
2907
  type: "integer"
2652
2908
  },
2653
2909
  children,
2654
- onClickToggle,
2655
2910
  onDeleteComponent,
2656
2911
  toggleCollapses,
2912
+ __temp_key__,
2657
2913
  ...dragProps
2658
2914
  }) => {
2659
2915
  const { formatMessage } = useIntl();
@@ -2678,50 +2934,44 @@ const Component = ({
2678
2934
  dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
2679
2935
  }, [dragPreviewRef, index]);
2680
2936
  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(
2937
+ const composedBoxRefs = useComposedRefs(
2938
+ boxRef,
2939
+ dropRef
2940
+ );
2941
+ return /* @__PURE__ */ jsx(Fragment, { children: isDragging ? /* @__PURE__ */ jsx(Preview$1, {}) : /* @__PURE__ */ jsxs(Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
2942
+ /* @__PURE__ */ jsxs(Accordion.Header, { children: [
2943
+ /* @__PURE__ */ jsx(Accordion.Trigger, { children: displayValue }),
2944
+ /* @__PURE__ */ jsxs(Accordion.Actions, { children: [
2945
+ /* @__PURE__ */ jsx(
2946
+ IconButton,
2947
+ {
2948
+ borderWidth: 0,
2949
+ onClick: onDeleteComponent,
2950
+ label: formatMessage({
2951
+ id: getTranslation("containers.Edit.delete"),
2952
+ defaultMessage: "Delete"
2953
+ }),
2954
+ children: /* @__PURE__ */ jsx(Trash, {})
2955
+ }
2956
+ ),
2957
+ /* @__PURE__ */ jsx(
2958
+ IconButton,
2959
+ {
2960
+ ref: composedAccordionRefs,
2961
+ borderWidth: 0,
2962
+ onClick: (e) => e.stopPropagation(),
2963
+ "data-handler-id": handlerId,
2964
+ label: formatMessage({
2965
+ id: getTranslation("components.DragHandle-label"),
2966
+ defaultMessage: "Drag"
2967
+ }),
2968
+ onKeyDown: handleKeyDown,
2969
+ children: /* @__PURE__ */ jsx(Drag, {})
2970
+ }
2971
+ )
2972
+ ] })
2973
+ ] }),
2974
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(
2725
2975
  Flex,
2726
2976
  {
2727
2977
  direction: "column",
@@ -2735,7 +2985,7 @@ const Component = ({
2735
2985
  ] }) });
2736
2986
  };
2737
2987
  const Preview$1 = () => {
2738
- return /* @__PURE__ */ jsx(StyledSpan, { as: "span", padding: 6, background: "primary100" });
2988
+ return /* @__PURE__ */ jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
2739
2989
  };
2740
2990
  const StyledSpan = styled(Box)`
2741
2991
  display: block;
@@ -2761,29 +3011,15 @@ const ComponentInput = ({
2761
3011
  const data = transformDocument(schema, components)(form);
2762
3012
  field.onChange(name2, data);
2763
3013
  };
2764
- return /* @__PURE__ */ jsxs(Box, { children: [
3014
+ return /* @__PURE__ */ jsxs(Field.Root, { error: field.error, required, children: [
2765
3015
  /* @__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 })
3016
+ /* @__PURE__ */ jsxs(Field.Label, { action: labelAction, children: [
3017
+ label,
3018
+ attribute.repeatable && /* @__PURE__ */ jsxs(Fragment, { children: [
3019
+ " (",
3020
+ Array.isArray(field.value) ? field.value.length : 0,
3021
+ ")"
3022
+ ] })
2787
3023
  ] }),
2788
3024
  showResetComponent && /* @__PURE__ */ jsx(
2789
3025
  IconButton,
@@ -2792,21 +3028,21 @@ const ComponentInput = ({
2792
3028
  id: getTranslation("components.reset-entry"),
2793
3029
  defaultMessage: "Reset Entry"
2794
3030
  }),
2795
- icon: /* @__PURE__ */ jsx(Trash, {}),
2796
3031
  borderWidth: 0,
2797
3032
  onClick: () => {
2798
3033
  field.onChange(name2, null);
2799
- }
3034
+ },
3035
+ children: /* @__PURE__ */ jsx(Trash, {})
2800
3036
  }
2801
3037
  )
2802
3038
  ] }),
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
- ] })
3039
+ !attribute.repeatable && !field.value && /* @__PURE__ */ jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
3040
+ !attribute.repeatable && field.value ? /* @__PURE__ */ jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
3041
+ attribute.repeatable && /* @__PURE__ */ jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
3042
+ /* @__PURE__ */ jsx(Field.Error, {})
2808
3043
  ] });
2809
3044
  };
3045
+ const MemoizedComponentInput = React.memo(ComponentInput);
2810
3046
  const AddComponentButton = ({
2811
3047
  hasError,
2812
3048
  isDisabled,
@@ -2826,10 +3062,10 @@ const AddComponentButton = ({
2826
3062
  paddingLeft: 4,
2827
3063
  paddingRight: 4,
2828
3064
  style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2829
- children: /* @__PURE__ */ jsxs(Flex, { as: "span", gap: 2, children: [
3065
+ children: /* @__PURE__ */ jsxs(Flex, { tag: "span", gap: 2, children: [
2830
3066
  /* @__PURE__ */ jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2831
3067
  /* @__PURE__ */ jsx(
2832
- Typography,
3068
+ AddComponentTitle,
2833
3069
  {
2834
3070
  variant: "pi",
2835
3071
  fontWeight: "bold",
@@ -2853,13 +3089,14 @@ const StyledAddIcon = styled(PlusCircle)`
2853
3089
  fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
2854
3090
  }
2855
3091
  `;
3092
+ const AddComponentTitle = styled(Typography)``;
2856
3093
  const StyledButton = styled(BaseButton)`
2857
3094
  border-radius: 26px;
2858
3095
  border-color: ${({ theme }) => theme.colors.neutral150};
2859
3096
  box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2860
3097
 
2861
3098
  &:hover {
2862
- ${Typography} {
3099
+ ${AddComponentTitle} {
2863
3100
  color: ${({ theme }) => theme.colors.primary600};
2864
3101
  }
2865
3102
 
@@ -2873,7 +3110,7 @@ const StyledButton = styled(BaseButton)`
2873
3110
  }
2874
3111
  }
2875
3112
  &:active {
2876
- ${Typography} {
3113
+ ${AddComponentTitle} {
2877
3114
  color: ${({ theme }) => theme.colors.primary600};
2878
3115
  }
2879
3116
  ${StyledAddIcon} {
@@ -2890,27 +3127,15 @@ const ComponentCategory = ({
2890
3127
  category,
2891
3128
  components = [],
2892
3129
  variant = "primary",
2893
- isOpen,
2894
- onAddComponent,
2895
- onToggle
3130
+ onAddComponent
2896
3131
  }) => {
2897
3132
  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(
3133
+ return /* @__PURE__ */ jsxs(Accordion.Item, { value: category, children: [
3134
+ /* @__PURE__ */ jsx(Accordion.Header, { variant, children: /* @__PURE__ */ jsx(Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
3135
+ /* @__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
3136
  ComponentBox,
2912
3137
  {
2913
- as: "button",
3138
+ tag: "button",
2914
3139
  type: "button",
2915
3140
  background: "neutral100",
2916
3141
  justifyContent: "center",
@@ -2920,34 +3145,32 @@ const ComponentCategory = ({
2920
3145
  shrink: 0,
2921
3146
  borderColor: "neutral200",
2922
3147
  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 })
3148
+ /* @__PURE__ */ jsx(ComponentIcon, { color: "currentColor", background: "primary200", icon }),
3149
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2925
3150
  ] })
2926
3151
  },
2927
3152
  uid
2928
- )) }) }) })
3153
+ )) }) })
2929
3154
  ] });
2930
3155
  };
2931
- const Grid = styled.div`
3156
+ const Grid = styled(Box)`
2932
3157
  display: grid;
2933
3158
  grid-template-columns: repeat(auto-fit, 14rem);
2934
3159
  grid-gap: ${({ theme }) => theme.spaces[1]};
2935
3160
  `;
2936
3161
  const ComponentBox = styled(Flex)`
3162
+ color: ${({ theme }) => theme.colors.neutral600};
3163
+ cursor: pointer;
3164
+
3165
+ @media (prefers-reduced-motion: no-preference) {
3166
+ transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
3167
+ }
3168
+
2937
3169
  &:focus,
2938
3170
  &:hover {
2939
3171
  border: 1px solid ${({ theme }) => theme.colors.primary200};
2940
3172
  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
- }
3173
+ color: ${({ theme }) => theme.colors.primary600};
2951
3174
  }
2952
3175
  `;
2953
3176
  const ComponentPicker = ({
@@ -2956,19 +3179,8 @@ const ComponentPicker = ({
2956
3179
  onClickAddComponent
2957
3180
  }) => {
2958
3181
  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
3182
  const handleAddComponentToDz = (componentUid) => () => {
2967
3183
  onClickAddComponent(componentUid);
2968
- setCategoryToOpen("");
2969
- };
2970
- const handleClickToggle = (categoryName) => {
2971
- setCategoryToOpen((currentCat) => currentCat === categoryName ? "" : categoryName);
2972
3184
  };
2973
3185
  if (!isOpen) {
2974
3186
  return null;
@@ -2989,14 +3201,12 @@ const ComponentPicker = ({
2989
3201
  id: getTranslation("components.DynamicZone.ComponentPicker-label"),
2990
3202
  defaultMessage: "Pick one component"
2991
3203
  }) }) }),
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(
3204
+ /* @__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
3205
  ComponentCategory,
2994
3206
  {
2995
3207
  category,
2996
3208
  components,
2997
3209
  onAddComponent: handleAddComponentToDz,
2998
- isOpen: category === categoryToOpen,
2999
- onToggle: handleClickToggle,
3000
3210
  variant: index % 2 === 1 ? "primary" : "secondary"
3001
3211
  },
3002
3212
  category
@@ -3011,27 +3221,21 @@ const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
3011
3221
  id: "components.NotAllowedInput.text",
3012
3222
  defaultMessage: "No permissions to see this field"
3013
3223
  });
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
- );
3224
+ return /* @__PURE__ */ jsxs(Field.Root, { id: name2, hint, name: name2, required, children: [
3225
+ /* @__PURE__ */ jsx(Field.Label, { children: label }),
3226
+ /* @__PURE__ */ jsx(
3227
+ TextInput,
3228
+ {
3229
+ disabled: true,
3230
+ placeholder,
3231
+ startAction: /* @__PURE__ */ jsx(EyeStriked, { fill: "neutral600" }),
3232
+ type: "text",
3233
+ value: ""
3234
+ }
3235
+ ),
3236
+ /* @__PURE__ */ jsx(Field.Hint, {})
3237
+ ] });
3029
3238
  };
3030
- const StyledIcon = styled(EyeStriked)`
3031
- & > path {
3032
- fill: ${({ theme }) => theme.colors.neutral600};
3033
- }
3034
- `;
3035
3239
  function useDebounce(value, delay) {
3036
3240
  const [debouncedValue, setDebouncedValue] = useState(value);
3037
3241
  useEffect(() => {
@@ -3084,188 +3288,193 @@ const uidApi = contentManagerApi.injectEndpoints({
3084
3288
  });
3085
3289
  const { useGenerateUIDMutation, useGetDefaultUIDQuery, useGetAvailabilityQuery } = uidApi;
3086
3290
  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({
3291
+ const UIDInput = React.forwardRef(
3292
+ ({ hint, label, labelAction, name: name2, required, ...props }, ref) => {
3293
+ const { model, id } = useDoc();
3294
+ const allFormValues = useForm("InputUID", (form) => form.values);
3295
+ const [availability, setAvailability] = React.useState();
3296
+ const [showRegenerate, setShowRegenerate] = React.useState(false);
3297
+ const field = useField(name2);
3298
+ const debouncedValue = useDebounce(field.value, 300);
3299
+ const { toggleNotification } = useNotification();
3300
+ const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();
3301
+ const { formatMessage } = useIntl();
3302
+ const [{ query }] = useQueryParams();
3303
+ const params = React.useMemo(() => buildValidParams(query), [query]);
3304
+ const {
3305
+ data: defaultGeneratedUID,
3306
+ isLoading: isGeneratingDefaultUID,
3307
+ error: apiError
3308
+ } = useGetDefaultUIDQuery(
3309
+ {
3134
3310
  contentTypeUID: model,
3135
- field: props.name,
3136
- data: { id: id ?? "", ...allFormValues },
3311
+ field: name2,
3312
+ data: {
3313
+ id: id ?? "",
3314
+ ...allFormValues
3315
+ },
3137
3316
  params
3138
- });
3139
- if ("data" in res) {
3140
- field.onChange(props.name, res.data);
3141
- } else {
3317
+ },
3318
+ {
3319
+ skip: field.value || !required
3320
+ }
3321
+ );
3322
+ React.useEffect(() => {
3323
+ if (apiError) {
3142
3324
  toggleNotification({
3143
- type: "danger",
3144
- message: formatAPIError(res.error)
3325
+ type: "warning",
3326
+ message: formatAPIError(apiError)
3145
3327
  });
3146
3328
  }
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);
3329
+ }, [apiError, formatAPIError, toggleNotification]);
3330
+ React.useEffect(() => {
3331
+ if (defaultGeneratedUID && field.value === void 0) {
3332
+ field.onChange(name2, defaultGeneratedUID);
3333
+ }
3334
+ }, [defaultGeneratedUID, field, name2]);
3335
+ const [generateUID, { isLoading: isGeneratingUID }] = useGenerateUIDMutation();
3336
+ const handleRegenerateClick = async () => {
3337
+ try {
3338
+ const res = await generateUID({
3339
+ contentTypeUID: model,
3340
+ field: name2,
3341
+ data: { id: id ?? "", ...allFormValues },
3342
+ params
3343
+ });
3344
+ if ("data" in res) {
3345
+ field.onChange(name2, res.data);
3346
+ } else {
3347
+ toggleNotification({
3348
+ type: "danger",
3349
+ message: formatAPIError(res.error)
3350
+ });
3351
+ }
3352
+ } catch (err) {
3353
+ toggleNotification({
3354
+ type: "danger",
3355
+ message: formatMessage({
3356
+ id: "notification.error",
3357
+ defaultMessage: "An error occurred."
3358
+ })
3359
+ });
3193
3360
  }
3194
3361
  };
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,
3362
+ const {
3363
+ data: availabilityData,
3364
+ isLoading: isCheckingAvailability,
3365
+ error: availabilityError
3366
+ } = useGetAvailabilityQuery(
3203
3367
  {
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,
3368
+ contentTypeUID: model,
3369
+ field: name2,
3370
+ value: debouncedValue ? debouncedValue.trim() : "",
3371
+ params
3372
+ },
3373
+ {
3374
+ skip: !Boolean(
3375
+ debouncedValue !== field.initialValue && debouncedValue && UID_REGEX.test(debouncedValue.trim())
3376
+ )
3377
+ }
3378
+ );
3379
+ React.useEffect(() => {
3380
+ if (availabilityError) {
3381
+ toggleNotification({
3382
+ type: "warning",
3383
+ message: formatAPIError(availabilityError)
3384
+ });
3385
+ }
3386
+ }, [availabilityError, formatAPIError, toggleNotification]);
3387
+ React.useEffect(() => {
3388
+ setAvailability(availabilityData);
3389
+ let timer;
3390
+ if (availabilityData?.isAvailable) {
3391
+ timer = window.setTimeout(() => {
3392
+ setAvailability(void 0);
3393
+ }, 4e3);
3394
+ }
3395
+ return () => {
3396
+ if (timer) {
3397
+ clearTimeout(timer);
3398
+ }
3399
+ };
3400
+ }, [availabilityData]);
3401
+ const isLoading = isGeneratingDefaultUID || isGeneratingUID || isCheckingAvailability;
3402
+ const fieldRef = useFocusInputField(name2);
3403
+ const composedRefs = useComposedRefs(ref, fieldRef);
3404
+ return /* @__PURE__ */ jsxs(Field.Root, { hint, name: name2, error: field.error, required, children: [
3405
+ /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
3406
+ /* @__PURE__ */ jsx(
3407
+ TextInput,
3408
+ {
3409
+ ref: composedRefs,
3410
+ disabled: props.disabled,
3411
+ endAction: /* @__PURE__ */ jsxs(Flex, { position: "relative", gap: 1, children: [
3412
+ availability && !showRegenerate && /* @__PURE__ */ jsxs(
3413
+ TextValidation,
3248
3414
  {
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, {})
3415
+ alignItems: "center",
3416
+ gap: 1,
3417
+ justifyContent: "flex-end",
3418
+ $available: !!availability?.isAvailable,
3419
+ "data-not-here-outer": true,
3420
+ position: "absolute",
3421
+ pointerEvents: "none",
3422
+ right: 6,
3423
+ width: "100px",
3424
+ children: [
3425
+ availability?.isAvailable ? /* @__PURE__ */ jsx(CheckCircle, {}) : /* @__PURE__ */ jsx(WarningCircle, {}),
3426
+ /* @__PURE__ */ jsx(
3427
+ Typography,
3428
+ {
3429
+ textColor: availability.isAvailable ? "success600" : "danger600",
3430
+ variant: "pi",
3431
+ children: formatMessage(
3432
+ availability.isAvailable ? {
3433
+ id: "content-manager.components.uid.available",
3434
+ defaultMessage: "Available"
3435
+ } : {
3436
+ id: "content-manager.components.uid.unavailable",
3437
+ defaultMessage: "Unavailable"
3438
+ }
3439
+ )
3440
+ }
3441
+ )
3442
+ ]
3257
3443
  }
3258
- )
3259
- ] })
3260
- ] }),
3261
- onChange: field.onChange,
3262
- value: field.value ?? "",
3263
- ...props
3264
- }
3265
- )
3266
- );
3267
- });
3268
- const FieldActionWrapper = styled(FieldAction)`
3444
+ ),
3445
+ !props.disabled && /* @__PURE__ */ jsxs(Fragment, { children: [
3446
+ showRegenerate && /* @__PURE__ */ jsx(TextValidation, { alignItems: "center", justifyContent: "flex-end", gap: 1, children: /* @__PURE__ */ jsx(Typography, { textColor: "primary600", variant: "pi", children: formatMessage({
3447
+ id: "content-manager.components.uid.regenerate",
3448
+ defaultMessage: "Regenerate"
3449
+ }) }) }),
3450
+ /* @__PURE__ */ jsx(
3451
+ FieldActionWrapper,
3452
+ {
3453
+ onClick: handleRegenerateClick,
3454
+ label: formatMessage({
3455
+ id: "content-manager.components.uid.regenerate",
3456
+ defaultMessage: "Regenerate"
3457
+ }),
3458
+ onMouseEnter: () => setShowRegenerate(true),
3459
+ onMouseLeave: () => setShowRegenerate(false),
3460
+ children: isLoading ? /* @__PURE__ */ jsx(LoadingWrapper, { "data-testid": "loading-wrapper", children: /* @__PURE__ */ jsx(Loader, {}) }) : /* @__PURE__ */ jsx(ArrowClockwise, {})
3461
+ }
3462
+ )
3463
+ ] })
3464
+ ] }),
3465
+ onChange: field.onChange,
3466
+ value: field.value ?? "",
3467
+ ...props
3468
+ }
3469
+ ),
3470
+ /* @__PURE__ */ jsx(Field.Error, {}),
3471
+ /* @__PURE__ */ jsx(Field.Hint, {})
3472
+ ] });
3473
+ }
3474
+ );
3475
+ const FieldActionWrapper = styled(Field.Action)`
3476
+ width: 1.6rem;
3477
+
3269
3478
  svg {
3270
3479
  height: 1.6rem;
3271
3480
  width: 1.6rem;
@@ -3286,7 +3495,7 @@ const TextValidation = styled(Flex)`
3286
3495
  width: 1.2rem;
3287
3496
 
3288
3497
  path {
3289
- fill: ${({ theme, available }) => available ? theme.colors.success600 : theme.colors.danger600};
3498
+ fill: ${({ theme, $available }) => $available ? theme.colors.success600 : theme.colors.danger600};
3290
3499
  }
3291
3500
  }
3292
3501
  `;
@@ -3301,6 +3510,7 @@ const rotation = keyframes`
3301
3510
  const LoadingWrapper = styled(Flex)`
3302
3511
  animation: ${rotation} 2s infinite linear;
3303
3512
  `;
3513
+ const MemoizedUIDInput = React.memo(UIDInput);
3304
3514
  const md = new Markdown({
3305
3515
  html: true,
3306
3516
  // Enable HTML tags in source
@@ -3635,7 +3845,7 @@ const Editor = React.forwardRef(
3635
3845
  [editorRef]
3636
3846
  );
3637
3847
  return /* @__PURE__ */ jsxs(EditorAndPreviewWrapper, { children: [
3638
- /* @__PURE__ */ jsx(EditorStylesContainer, { isExpandMode, disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
3848
+ /* @__PURE__ */ jsx(EditorStylesContainer, { $isExpandMode: isExpandMode, $disabled: disabled || isPreviewMode, children: /* @__PURE__ */ jsx("textarea", { ref: textareaRef }) }),
3639
3849
  isPreviewMode && /* @__PURE__ */ jsx(PreviewWysiwyg, { data: value })
3640
3850
  ] });
3641
3851
  }
@@ -3645,7 +3855,7 @@ const EditorAndPreviewWrapper = styled.div`
3645
3855
  height: calc(100% - 48px);
3646
3856
  `;
3647
3857
  const EditorStylesContainer = styled.div`
3648
- cursor: ${({ disabled }) => disabled ? "not-allowed !important" : "auto"};
3858
+ cursor: ${({ $disabled }) => $disabled ? "not-allowed !important" : "auto"};
3649
3859
  height: 100%;
3650
3860
  /* BASICS */
3651
3861
  .CodeMirror-placeholder {
@@ -3655,7 +3865,7 @@ const EditorStylesContainer = styled.div`
3655
3865
  .CodeMirror {
3656
3866
  /* Set height, width, borders, and global font properties here */
3657
3867
  font-size: 1.4rem;
3658
- height: ${({ isExpandMode }) => isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
3868
+ height: ${({ $isExpandMode }) => $isExpandMode ? "100%" : "410px"}; // 512px(total height) - 48px (header) - 52px(footer) - 2px border
3659
3869
  color: ${({ theme }) => theme.colors.neutral800};
3660
3870
  direction: ltr;
3661
3871
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
@@ -4340,8 +4550,6 @@ const quoteAndCodeHandler = (editor, markdownType) => {
4340
4550
  };
4341
4551
  const CustomIconButton = styled(IconButton)`
4342
4552
  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
4553
 
4346
4554
  svg {
4347
4555
  width: 1.8rem;
@@ -4386,7 +4594,7 @@ const ExpandButton = styled(BaseButton)`
4386
4594
  const WysiwygFooter = ({ onToggleExpand }) => {
4387
4595
  const { formatMessage } = useIntl();
4388
4596
  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({
4597
+ /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", children: formatMessage({
4390
4598
  id: "components.WysiwygBottomControls.fullscreen",
4391
4599
  defaultMessage: "Expand"
4392
4600
  }) }),
@@ -4408,7 +4616,7 @@ const WysiwygNav = ({
4408
4616
  id: "components.Wysiwyg.selectOptions.title",
4409
4617
  defaultMessage: "Add a title"
4410
4618
  });
4411
- const buttonMoreRef = React.useRef(null);
4619
+ React.useRef(null);
4412
4620
  const handleTogglePopover = () => {
4413
4621
  setVisiblePopover((prev) => !prev);
4414
4622
  };
@@ -4421,21 +4629,21 @@ const WysiwygNav = ({
4421
4629
  justifyContent: "space-between",
4422
4630
  borderRadius: `0.4rem 0.4rem 0 0`,
4423
4631
  children: [
4424
- /* @__PURE__ */ jsxs(StyledFlex, { children: [
4425
- /* @__PURE__ */ jsxs(SingleSelect, { disabled: true, placeholder: selectPlaceholder, size: "S", label: selectPlaceholder, children: [
4632
+ /* @__PURE__ */ jsxs(Flex, { children: [
4633
+ /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(SingleSelect, { disabled: true, placeholder: selectPlaceholder, "aria-label": selectPlaceholder, children: [
4426
4634
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
4427
4635
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h2", children: "h2" }),
4428
4636
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h3", children: "h3" }),
4429
4637
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h4", children: "h4" }),
4430
4638
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h5", children: "h5" }),
4431
4639
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
4432
- ] }),
4640
+ ] }) }),
4433
4641
  /* @__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, {}) })
4642
+ /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Bold", name: "Bold", children: /* @__PURE__ */ jsx(Bold, {}) }),
4643
+ /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Italic", name: "Italic", children: /* @__PURE__ */ jsx(Italic, {}) }),
4644
+ /* @__PURE__ */ jsx(CustomIconButton, { disabled: true, label: "Underline", name: "Underline", children: /* @__PURE__ */ jsx(Underline, {}) })
4437
4645
  ] }),
4438
- /* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More", icon: /* @__PURE__ */ jsx(More, {}) })
4646
+ /* @__PURE__ */ jsx(MoreButton, { disabled: true, label: "More", children: /* @__PURE__ */ jsx(More, {}) })
4439
4647
  ] }),
4440
4648
  !isExpandMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
4441
4649
  id: "components.Wysiwyg.ToggleMode.markdown-mode",
@@ -4453,13 +4661,12 @@ const WysiwygNav = ({
4453
4661
  justifyContent: "space-between",
4454
4662
  borderRadius: `0.4rem 0.4rem 0 0`,
4455
4663
  children: [
4456
- /* @__PURE__ */ jsxs(StyledFlex, { children: [
4457
- /* @__PURE__ */ jsxs(
4664
+ /* @__PURE__ */ jsxs(Flex, { children: [
4665
+ /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsxs(
4458
4666
  SingleSelect,
4459
4667
  {
4460
4668
  placeholder: selectPlaceholder,
4461
- label: selectPlaceholder,
4462
- size: "S",
4669
+ "aria-label": selectPlaceholder,
4463
4670
  onChange: (value) => onActionClick(value, editorRef),
4464
4671
  children: [
4465
4672
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h1", children: "h1" }),
@@ -4470,7 +4677,7 @@ const WysiwygNav = ({
4470
4677
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "h6", children: "h6" })
4471
4678
  ]
4472
4679
  }
4473
- ),
4680
+ ) }),
4474
4681
  /* @__PURE__ */ jsxs(MainButtons, { children: [
4475
4682
  /* @__PURE__ */ jsx(
4476
4683
  CustomIconButton,
@@ -4478,7 +4685,7 @@ const WysiwygNav = ({
4478
4685
  onClick: () => onActionClick("Bold", editorRef),
4479
4686
  label: "Bold",
4480
4687
  name: "Bold",
4481
- icon: /* @__PURE__ */ jsx(Bold, {})
4688
+ children: /* @__PURE__ */ jsx(Bold, {})
4482
4689
  }
4483
4690
  ),
4484
4691
  /* @__PURE__ */ jsx(
@@ -4487,7 +4694,7 @@ const WysiwygNav = ({
4487
4694
  onClick: () => onActionClick("Italic", editorRef),
4488
4695
  label: "Italic",
4489
4696
  name: "Italic",
4490
- icon: /* @__PURE__ */ jsx(Italic, {})
4697
+ children: /* @__PURE__ */ jsx(Italic, {})
4491
4698
  }
4492
4699
  ),
4493
4700
  /* @__PURE__ */ jsx(
@@ -4496,91 +4703,85 @@ const WysiwygNav = ({
4496
4703
  onClick: () => onActionClick("Underline", editorRef),
4497
4704
  label: "Underline",
4498
4705
  name: "Underline",
4499
- icon: /* @__PURE__ */ jsx(Underline, {})
4706
+ children: /* @__PURE__ */ jsx(Underline, {})
4500
4707
  }
4501
4708
  )
4502
4709
  ] }),
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
- ] }) })
4710
+ /* @__PURE__ */ jsxs(Popover.Root, { children: [
4711
+ /* @__PURE__ */ jsx(Popover.Trigger, { children: /* @__PURE__ */ jsx(MoreButton, { label: "More", children: /* @__PURE__ */ jsx(More, {}) }) }),
4712
+ /* @__PURE__ */ jsx(Popover.Content, { sideOffset: 12, children: /* @__PURE__ */ jsxs(Flex, { padding: 2, children: [
4713
+ /* @__PURE__ */ jsxs(IconButtonGroupMargin, { children: [
4714
+ /* @__PURE__ */ jsx(
4715
+ CustomIconButton,
4716
+ {
4717
+ onClick: () => onActionClick("Strikethrough", editorRef, handleTogglePopover),
4718
+ label: "Strikethrough",
4719
+ name: "Strikethrough",
4720
+ children: /* @__PURE__ */ jsx(StrikeThrough, {})
4721
+ }
4722
+ ),
4723
+ /* @__PURE__ */ jsx(
4724
+ CustomIconButton,
4725
+ {
4726
+ onClick: () => onActionClick("BulletList", editorRef, handleTogglePopover),
4727
+ label: "BulletList",
4728
+ name: "BulletList",
4729
+ children: /* @__PURE__ */ jsx(BulletList, {})
4730
+ }
4731
+ ),
4732
+ /* @__PURE__ */ jsx(
4733
+ CustomIconButton,
4734
+ {
4735
+ onClick: () => onActionClick("NumberList", editorRef, handleTogglePopover),
4736
+ label: "NumberList",
4737
+ name: "NumberList",
4738
+ children: /* @__PURE__ */ jsx(NumberList, {})
4739
+ }
4740
+ )
4741
+ ] }),
4742
+ /* @__PURE__ */ jsxs(IconButtonGroup, { children: [
4743
+ /* @__PURE__ */ jsx(
4744
+ CustomIconButton,
4745
+ {
4746
+ onClick: () => onActionClick("Code", editorRef, handleTogglePopover),
4747
+ label: "Code",
4748
+ name: "Code",
4749
+ children: /* @__PURE__ */ jsx(Code, {})
4750
+ }
4751
+ ),
4752
+ /* @__PURE__ */ jsx(
4753
+ CustomIconButton,
4754
+ {
4755
+ onClick: () => {
4756
+ handleTogglePopover();
4757
+ onToggleMediaLib();
4758
+ },
4759
+ label: "Image",
4760
+ name: "Image",
4761
+ children: /* @__PURE__ */ jsx(Image$1, {})
4762
+ }
4763
+ ),
4764
+ /* @__PURE__ */ jsx(
4765
+ CustomLinkIconButton,
4766
+ {
4767
+ onClick: () => onActionClick("Link", editorRef, handleTogglePopover),
4768
+ label: "Link",
4769
+ name: "Link",
4770
+ children: /* @__PURE__ */ jsx(Link$1, {})
4771
+ }
4772
+ ),
4773
+ /* @__PURE__ */ jsx(
4774
+ CustomIconButton,
4775
+ {
4776
+ onClick: () => onActionClick("Quote", editorRef, handleTogglePopover),
4777
+ label: "Quote",
4778
+ name: "Quote",
4779
+ children: /* @__PURE__ */ jsx(Quotes, {})
4780
+ }
4781
+ )
4782
+ ] })
4783
+ ] }) })
4784
+ ] })
4584
4785
  ] }),
4585
4786
  onTogglePreviewMode && /* @__PURE__ */ jsx(Button, { onClick: onTogglePreviewMode, variant: "tertiary", children: formatMessage({
4586
4787
  id: "components.Wysiwyg.ToggleMode.preview-mode",
@@ -4590,19 +4791,6 @@ const WysiwygNav = ({
4590
4791
  }
4591
4792
  );
4592
4793
  };
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
4794
  const Wysiwyg = React.forwardRef(
4607
4795
  ({ hint, disabled, label, name: name2, placeholder, required, labelAction }, forwardedRef) => {
4608
4796
  const field = useField(name2);
@@ -4667,9 +4855,9 @@ const Wysiwyg = React.forwardRef(
4667
4855
  insertFile(editorRef, formattedFiles);
4668
4856
  setMediaLibVisible(false);
4669
4857
  };
4670
- return /* @__PURE__ */ jsxs(Field, { name: name2, hint, error: field.error, required, children: [
4858
+ return /* @__PURE__ */ jsxs(Field.Root, { name: name2, hint, error: field.error, required, children: [
4671
4859
  /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
4672
- /* @__PURE__ */ jsx(FieldLabel, { action: labelAction, children: label }),
4860
+ /* @__PURE__ */ jsx(Field.Label, { action: labelAction, children: label }),
4673
4861
  /* @__PURE__ */ jsxs(
4674
4862
  EditorLayout,
4675
4863
  {
@@ -4710,14 +4898,15 @@ const Wysiwyg = React.forwardRef(
4710
4898
  ]
4711
4899
  }
4712
4900
  ),
4713
- /* @__PURE__ */ jsx(FieldHint, {}),
4714
- /* @__PURE__ */ jsx(FieldError, {})
4901
+ /* @__PURE__ */ jsx(Field.Hint, {}),
4902
+ /* @__PURE__ */ jsx(Field.Error, {})
4715
4903
  ] }),
4716
4904
  mediaLibVisible && // @ts-expect-error – TODO: fix this way of injecting because it's not really typeable without a registry.
4717
4905
  /* @__PURE__ */ jsx(MediaLibraryDialog, { onClose: handleToggleMediaLib, onSelectAssets: handleSelectAssets })
4718
4906
  ] });
4719
4907
  }
4720
4908
  );
4909
+ const MemoizedWysiwyg = React.memo(Wysiwyg);
4721
4910
  const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4722
4911
  const { id } = useDoc();
4723
4912
  const isFormDisabled = useForm("InputRenderer", (state) => state.disabled);
@@ -4767,10 +4956,10 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4767
4956
  }
4768
4957
  switch (props.type) {
4769
4958
  case "blocks":
4770
- return /* @__PURE__ */ jsx(BlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4959
+ return /* @__PURE__ */ jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4771
4960
  case "component":
4772
4961
  return /* @__PURE__ */ jsx(
4773
- ComponentInput,
4962
+ MemoizedComponentInput,
4774
4963
  {
4775
4964
  ...props,
4776
4965
  hint,
@@ -4782,11 +4971,11 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4782
4971
  case "dynamiczone":
4783
4972
  return /* @__PURE__ */ jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
4784
4973
  case "relation":
4785
- return /* @__PURE__ */ jsx(RelationsField, { ...props, hint, disabled: fieldIsDisabled });
4974
+ return /* @__PURE__ */ jsx(MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
4786
4975
  case "richtext":
4787
- return /* @__PURE__ */ jsx(Wysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4976
+ return /* @__PURE__ */ jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4788
4977
  case "uid":
4789
- return /* @__PURE__ */ jsx(UIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4978
+ return /* @__PURE__ */ jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4790
4979
  case "enumeration":
4791
4980
  return /* @__PURE__ */ jsx(
4792
4981
  InputRenderer$1,
@@ -4818,7 +5007,9 @@ const useFieldHint = (hint = void 0, attribute) => {
4818
5007
  if (!maximum && !minimum) {
4819
5008
  return hint;
4820
5009
  }
4821
- const units = !["biginteger", "integer", "number"].includes(attribute.type) ? formatMessage(
5010
+ const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
5011
+ attribute.type
5012
+ ) ? formatMessage(
4822
5013
  {
4823
5014
  id: "content-manager.form.Input.hint.character.unit",
4824
5015
  defaultMessage: "{maxValue, plural, one { character} other { characters}}"
@@ -4858,6 +5049,7 @@ const getMinMax = (attribute) => {
4858
5049
  return { maximum: void 0, minimum: void 0 };
4859
5050
  }
4860
5051
  };
5052
+ const MemoizedInputRenderer = memo(InputRenderer);
4861
5053
  const DynamicComponent = ({
4862
5054
  componentUid,
4863
5055
  disabled,
@@ -4871,7 +5063,6 @@ const DynamicComponent = ({
4871
5063
  dynamicComponentsByCategory = {},
4872
5064
  onAddComponent
4873
5065
  }) => {
4874
- const [isOpen, setIsOpen] = React.useState(true);
4875
5066
  const { formatMessage } = useIntl();
4876
5067
  const formValues = useForm("DynamicComponent", (state) => state.values);
4877
5068
  const {
@@ -4880,7 +5071,7 @@ const DynamicComponent = ({
4880
5071
  const title = React.useMemo(() => {
4881
5072
  const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
4882
5073
  const mainFieldValue = getIn(formValues, `${name2}.${index}.${mainField}`);
4883
- const displayedValue = mainField === "id" ? "" : String(mainFieldValue).trim();
5074
+ const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
4884
5075
  const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
4885
5076
  return mainValue;
4886
5077
  }, [componentUid, components, formValues, name2, index]);
@@ -4891,9 +5082,6 @@ const DynamicComponent = ({
4891
5082
  ) ?? { icon: null, displayName: null };
4892
5083
  return { icon: icon2, displayName: displayName2 };
4893
5084
  }, [componentUid, dynamicComponentsByCategory]);
4894
- const handleToggle = () => {
4895
- setIsOpen((s) => !s);
4896
- };
4897
5085
  const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop(!disabled, {
4898
5086
  type: `${ItemTypes.DYNAMIC_ZONE}_${name2}`,
4899
5087
  index,
@@ -4911,9 +5099,9 @@ const DynamicComponent = ({
4911
5099
  dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
4912
5100
  }, [dragPreviewRef, index]);
4913
5101
  const composedBoxRefs = useComposedRefs(boxRef, dropRef);
4914
- const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(ActionsFlex, { gap: 0, children: [
5102
+ const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
4915
5103
  /* @__PURE__ */ jsx(
4916
- IconButtonCustom,
5104
+ IconButton,
4917
5105
  {
4918
5106
  borderWidth: 0,
4919
5107
  label: formatMessage(
@@ -4930,10 +5118,7 @@ const DynamicComponent = ({
4930
5118
  /* @__PURE__ */ jsx(
4931
5119
  IconButton,
4932
5120
  {
4933
- forwardedAs: "div",
4934
- role: "button",
4935
5121
  borderWidth: 0,
4936
- tabIndex: 0,
4937
5122
  onClick: (e) => e.stopPropagation(),
4938
5123
  "data-handler-id": handlerId,
4939
5124
  ref: dragRef,
@@ -4948,7 +5133,7 @@ const DynamicComponent = ({
4948
5133
  /* @__PURE__ */ jsxs(Menu.Root, { children: [
4949
5134
  /* @__PURE__ */ jsxs(Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
4950
5135
  /* @__PURE__ */ jsx(More, { "aria-hidden": true, focusable: false }),
4951
- /* @__PURE__ */ jsx(VisuallyHidden, { as: "span", children: formatMessage({
5136
+ /* @__PURE__ */ jsx(VisuallyHidden, { tag: "span", children: formatMessage({
4952
5137
  id: getTranslation("components.DynamicZone.more-actions"),
4953
5138
  defaultMessage: "More actions"
4954
5139
  }) })
@@ -4977,42 +5162,28 @@ const DynamicComponent = ({
4977
5162
  ] })
4978
5163
  ] })
4979
5164
  ] });
4980
- return /* @__PURE__ */ jsxs(ComponentContainer, { as: "li", width: "100%", children: [
5165
+ const accordionTitle = title ? `${displayName} ${title}` : displayName;
5166
+ const accordionValue = React.useId();
5167
+ return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
4981
5168
  /* @__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,
4985
- {
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 }) => {
5169
+ /* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
5170
+ /* @__PURE__ */ jsxs(Accordion.Header, { children: [
5171
+ /* @__PURE__ */ jsx(
5172
+ Accordion.Trigger,
5173
+ {
5174
+ icon: icon && COMPONENT_ICONS[icon] ? COMPONENT_ICONS[icon] : COMPONENT_ICONS.dashboard,
5175
+ children: accordionTitle
5176
+ }
5177
+ ),
5178
+ /* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
5179
+ ] }),
5180
+ /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
4993
5181
  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);
5182
+ return /* @__PURE__ */ jsx(Grid$1.Item, { col: size, s: 12, xs: 12, children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...field, name: fieldName }) }, fieldName);
4995
5183
  }) }, rowInd)) }) }) })
4996
- ] }) })
5184
+ ] }) }) })
4997
5185
  ] });
4998
5186
  };
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
5187
  const StyledBox = styled(Box)`
5017
5188
  > div:first-child {
5018
5189
  box-shadow: ${({ theme }) => theme.shadows.tableShadow};
@@ -5083,7 +5254,7 @@ const [DynamicZoneProvider, useDynamicZone] = createContext(
5083
5254
  );
5084
5255
  const DynamicZone = ({
5085
5256
  attribute,
5086
- disabled,
5257
+ disabled: disabledProp,
5087
5258
  hint,
5088
5259
  label,
5089
5260
  labelAction,
@@ -5093,7 +5264,8 @@ const DynamicZone = ({
5093
5264
  const { max = Infinity, min = -Infinity } = attribute ?? {};
5094
5265
  const [addComponentIsOpen, setAddComponentIsOpen] = React.useState(false);
5095
5266
  const [liveText, setLiveText] = React.useState("");
5096
- const { components } = useDoc();
5267
+ const { components, isLoading } = useDoc();
5268
+ const disabled = disabledProp || isLoading;
5097
5269
  const { addFieldRow, removeFieldRow, moveFieldRow } = useForm(
5098
5270
  "DynamicZone",
5099
5271
  ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
@@ -5200,7 +5372,7 @@ const DynamicZone = ({
5200
5372
  const handleRemoveComponent = (name22, currentIndex) => () => {
5201
5373
  removeFieldRow(name22, currentIndex);
5202
5374
  };
5203
- const hasError = error !== void 0 || dynamicDisplayedComponentsLength < min || dynamicDisplayedComponentsLength > max;
5375
+ const hasError = error !== void 0;
5204
5376
  const renderButtonLabel = () => {
5205
5377
  if (addComponentIsOpen) {
5206
5378
  return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
@@ -5301,19 +5473,19 @@ const DynamicZone = ({
5301
5473
  ] }) });
5302
5474
  };
5303
5475
  export {
5304
- BlocksInput as B,
5305
- ComponentInput as C,
5306
5476
  DynamicZone as D,
5307
- InputRenderer as I,
5477
+ MemoizedInputRenderer as M,
5308
5478
  NotAllowedInput as N,
5309
- UIDInput as U,
5310
- Wysiwyg as W,
5311
5479
  useDynamicZone as a,
5312
5480
  useFieldHint as b,
5313
5481
  createDefaultForm as c,
5482
+ MemoizedUIDInput as d,
5483
+ MemoizedWysiwyg as e,
5484
+ MemoizedComponentInput as f,
5485
+ MemoizedBlocksInput as g,
5314
5486
  prepareTempKeys as p,
5315
5487
  removeFieldsThatDontExistOnSchema as r,
5316
5488
  transformDocument as t,
5317
5489
  useLazyComponents as u
5318
5490
  };
5319
- //# sourceMappingURL=Field-6gvGdPBV.mjs.map
5491
+ //# sourceMappingURL=Field-nNgv5bpd.mjs.map