@strapi/content-manager 0.0.0-next.6ed779c066310248c506ce3d2cdae97f59f700ef → 0.0.0-next.7051057497777a23c7418e675330d2fb69c89fec

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 (171) hide show
  1. package/dist/_chunks/CardDragPreview-C0QyJgRA.js.map +1 -1
  2. package/dist/_chunks/CardDragPreview-DOxamsuj.mjs.map +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-B4Nft8f5.mjs → ComponentConfigurationPage-D4H-v0et.mjs} +3 -3
  4. package/dist/_chunks/{ComponentConfigurationPage-B4Nft8f5.mjs.map → ComponentConfigurationPage-D4H-v0et.mjs.map} +1 -1
  5. package/dist/_chunks/{ComponentConfigurationPage-6pw-DvAu.js → ComponentConfigurationPage-DdkVGfXC.js} +4 -5
  6. package/dist/_chunks/{ComponentConfigurationPage-6pw-DvAu.js.map → ComponentConfigurationPage-DdkVGfXC.js.map} +1 -1
  7. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js → ComponentIcon-CRbtQEUV.js} +2 -3
  8. package/dist/_chunks/{ComponentIcon-BXdiCGQp.js.map → ComponentIcon-CRbtQEUV.js.map} +1 -1
  9. package/dist/_chunks/ComponentIcon-u4bIXTFY.mjs.map +1 -1
  10. package/dist/_chunks/{EditConfigurationPage-BHOCGzAM.mjs → EditConfigurationPage-D1nvB7Br.mjs} +3 -3
  11. package/dist/_chunks/{EditConfigurationPage-BHOCGzAM.mjs.map → EditConfigurationPage-D1nvB7Br.mjs.map} +1 -1
  12. package/dist/_chunks/{EditConfigurationPage-DXBEGkOc.js → EditConfigurationPage-LYEvR4fW.js} +4 -5
  13. package/dist/_chunks/{EditConfigurationPage-DXBEGkOc.js.map → EditConfigurationPage-LYEvR4fW.js.map} +1 -1
  14. package/dist/_chunks/{EditViewPage-CdRxfy5B.mjs → EditViewPage-Bcnff6Vd.mjs} +21 -54
  15. package/dist/_chunks/EditViewPage-Bcnff6Vd.mjs.map +1 -0
  16. package/dist/_chunks/{EditViewPage-Ck6Duztu.js → EditViewPage-DqelJ9UK.js} +23 -57
  17. package/dist/_chunks/EditViewPage-DqelJ9UK.js.map +1 -0
  18. package/dist/_chunks/FieldTypeIcon-CMlNO8PE.mjs.map +1 -1
  19. package/dist/_chunks/FieldTypeIcon-Dnwq_IRF.js.map +1 -1
  20. package/dist/_chunks/{Form-C-wjP4UH.js → Form-CnHfBeiB.js} +5 -6
  21. package/dist/_chunks/{Form-C-wjP4UH.js.map → Form-CnHfBeiB.js.map} +1 -1
  22. package/dist/_chunks/{Form-DBXQL3w4.mjs → Form-CzPCJi3B.mjs} +3 -3
  23. package/dist/_chunks/{Form-DBXQL3w4.mjs.map → Form-CzPCJi3B.mjs.map} +1 -1
  24. package/dist/_chunks/{History-CynfBe3Q.mjs → History-CcmSn3Mj.mjs} +37 -67
  25. package/dist/_chunks/History-CcmSn3Mj.mjs.map +1 -0
  26. package/dist/_chunks/{History-DMFKKvIA.js → History-zArjENzj.js} +48 -79
  27. package/dist/_chunks/History-zArjENzj.js.map +1 -0
  28. package/dist/_chunks/{Field-T3F_jdGo.js → Input-CDHKQd7o.js} +1294 -1271
  29. package/dist/_chunks/Input-CDHKQd7o.js.map +1 -0
  30. package/dist/_chunks/{Field-DDSx-gBR.mjs → Input-aV8SSoTa.mjs} +1333 -1310
  31. package/dist/_chunks/Input-aV8SSoTa.mjs.map +1 -0
  32. package/dist/_chunks/{ListConfigurationPage-D2_aIJSH.mjs → ListConfigurationPage-BPvzENJJ.mjs} +6 -5
  33. package/dist/_chunks/ListConfigurationPage-BPvzENJJ.mjs.map +1 -0
  34. package/dist/_chunks/{ListConfigurationPage-BDV_ABiG.js → ListConfigurationPage-ByZAO_9H.js} +6 -6
  35. package/dist/_chunks/ListConfigurationPage-ByZAO_9H.js.map +1 -0
  36. package/dist/_chunks/{ListViewPage-Z3jPNVn2.js → ListViewPage-BVKBeQAA.js} +74 -60
  37. package/dist/_chunks/ListViewPage-BVKBeQAA.js.map +1 -0
  38. package/dist/_chunks/{ListViewPage-BJq_SQj8.mjs → ListViewPage-HljQVnFH.mjs} +68 -53
  39. package/dist/_chunks/ListViewPage-HljQVnFH.mjs.map +1 -0
  40. package/dist/_chunks/{NoContentTypePage-ZvbWHVfG.js → NoContentTypePage-BV5zfDxr.js} +2 -2
  41. package/dist/_chunks/{NoContentTypePage-ZvbWHVfG.js.map → NoContentTypePage-BV5zfDxr.js.map} +1 -1
  42. package/dist/_chunks/{NoContentTypePage-CEdKqCfY.mjs → NoContentTypePage-BfHaSM-K.mjs} +2 -2
  43. package/dist/_chunks/{NoContentTypePage-CEdKqCfY.mjs.map → NoContentTypePage-BfHaSM-K.mjs.map} +1 -1
  44. package/dist/_chunks/{NoPermissionsPage-BjzbHoxM.mjs → NoPermissionsPage-D6ze2nQL.mjs} +2 -2
  45. package/dist/_chunks/{NoPermissionsPage-BjzbHoxM.mjs.map → NoPermissionsPage-D6ze2nQL.mjs.map} +1 -1
  46. package/dist/_chunks/{NoPermissionsPage-D9hyWZPp.js → NoPermissionsPage-vdNpc6jb.js} +2 -2
  47. package/dist/_chunks/{NoPermissionsPage-D9hyWZPp.js.map → NoPermissionsPage-vdNpc6jb.js.map} +1 -1
  48. package/dist/_chunks/Preview-DEHdENT1.js +305 -0
  49. package/dist/_chunks/Preview-DEHdENT1.js.map +1 -0
  50. package/dist/_chunks/Preview-vfWOtPG5.mjs +287 -0
  51. package/dist/_chunks/Preview-vfWOtPG5.mjs.map +1 -0
  52. package/dist/_chunks/{Relations-ChkJKzz8.mjs → Relations-B7_hbF0w.mjs} +9 -10
  53. package/dist/_chunks/Relations-B7_hbF0w.mjs.map +1 -0
  54. package/dist/_chunks/{Relations-BlhtPLZk.js → Relations-DcoOBejP.js} +10 -12
  55. package/dist/_chunks/Relations-DcoOBejP.js.map +1 -0
  56. package/dist/_chunks/{en-Bdpa50w3.js → en-BR48D_RH.js} +18 -3
  57. package/dist/_chunks/{en-Bdpa50w3.js.map → en-BR48D_RH.js.map} +1 -1
  58. package/dist/_chunks/{en-CZw4xdPY.mjs → en-D65uIF6Y.mjs} +18 -3
  59. package/dist/_chunks/{en-CZw4xdPY.mjs.map → en-D65uIF6Y.mjs.map} +1 -1
  60. package/dist/_chunks/{fr-B2Kyv8Z9.js → fr-C43IbhA_.js} +4 -1
  61. package/dist/_chunks/{fr-B2Kyv8Z9.js.map → fr-C43IbhA_.js.map} +1 -1
  62. package/dist/_chunks/{fr--pg5jUbt.mjs → fr-DBseuRuB.mjs} +4 -1
  63. package/dist/_chunks/{fr--pg5jUbt.mjs.map → fr-DBseuRuB.mjs.map} +1 -1
  64. package/dist/_chunks/hooks-BAaaKPS_.js.map +1 -1
  65. package/dist/_chunks/{index-Bi51q_DG.js → index-CxLSGwnk.js} +564 -279
  66. package/dist/_chunks/index-CxLSGwnk.js.map +1 -0
  67. package/dist/_chunks/{index-C0PXR_tv.mjs → index-EH8ZtHd5.mjs} +582 -296
  68. package/dist/_chunks/index-EH8ZtHd5.mjs.map +1 -0
  69. package/dist/_chunks/{layout-B5XH5gpH.mjs → layout-CxDMdJ13.mjs} +4 -4
  70. package/dist/_chunks/{layout-B5XH5gpH.mjs.map → layout-CxDMdJ13.mjs.map} +1 -1
  71. package/dist/_chunks/{layout-MJxdu163.js → layout-DSeUTfMv.js} +5 -6
  72. package/dist/_chunks/{layout-MJxdu163.js.map → layout-DSeUTfMv.js.map} +1 -1
  73. package/dist/_chunks/objects-BcXOv6_9.js.map +1 -1
  74. package/dist/_chunks/objects-D6yBsdmx.mjs.map +1 -1
  75. package/dist/_chunks/{relations-D9fqpVRO.mjs → relations-B8_Uu38Q.mjs} +17 -3
  76. package/dist/_chunks/relations-B8_Uu38Q.mjs.map +1 -0
  77. package/dist/_chunks/{relations-lCDy3D3D.js → relations-S5nNKdN3.js} +16 -2
  78. package/dist/_chunks/relations-S5nNKdN3.js.map +1 -0
  79. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js → useDragAndDrop-BMtgCYzL.js} +5 -9
  80. package/dist/_chunks/{useDragAndDrop-J0TUUbR6.js.map → useDragAndDrop-BMtgCYzL.js.map} +1 -1
  81. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs → useDragAndDrop-DJ6jqvZN.mjs} +4 -7
  82. package/dist/_chunks/{useDragAndDrop-DdHgKsqq.mjs.map → useDragAndDrop-DJ6jqvZN.mjs.map} +1 -1
  83. package/dist/_chunks/{useDebounce-CtcjDB3L.js → usePrev-B9w_-eYc.js} +1 -14
  84. package/dist/_chunks/usePrev-B9w_-eYc.js.map +1 -0
  85. package/dist/_chunks/usePrev-DH6iah0A.mjs +16 -0
  86. package/dist/_chunks/usePrev-DH6iah0A.mjs.map +1 -0
  87. package/dist/admin/index.js +2 -1
  88. package/dist/admin/index.js.map +1 -1
  89. package/dist/admin/index.mjs +6 -5
  90. package/dist/admin/src/content-manager.d.ts +3 -2
  91. package/dist/admin/src/exports.d.ts +1 -0
  92. package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
  93. package/dist/admin/src/hooks/useDocument.d.ts +19 -2
  94. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  95. package/dist/admin/src/pages/EditView/components/DocumentActions.d.ts +1 -1
  96. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +3 -3
  97. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.d.ts +7 -0
  98. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/utils/prismLanguages.d.ts +49 -0
  99. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/constants.d.ts +1 -0
  100. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
  101. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
  102. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
  103. package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
  104. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  105. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  106. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  107. package/dist/admin/src/preview/routes.d.ts +3 -0
  108. package/dist/admin/src/preview/services/preview.d.ts +1 -1
  109. package/dist/admin/src/router.d.ts +1 -1
  110. package/dist/admin/src/services/api.d.ts +1 -1
  111. package/dist/admin/src/services/components.d.ts +2 -2
  112. package/dist/admin/src/services/contentTypes.d.ts +3 -3
  113. package/dist/admin/src/services/documents.d.ts +16 -19
  114. package/dist/admin/src/services/init.d.ts +1 -1
  115. package/dist/admin/src/services/relations.d.ts +2 -2
  116. package/dist/admin/src/services/uid.d.ts +3 -3
  117. package/dist/server/index.js +230 -187
  118. package/dist/server/index.js.map +1 -1
  119. package/dist/server/index.mjs +231 -187
  120. package/dist/server/index.mjs.map +1 -1
  121. package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
  122. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  123. package/dist/server/src/history/controllers/history-version.d.ts +1 -1
  124. package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
  125. package/dist/server/src/history/services/history.d.ts +3 -3
  126. package/dist/server/src/history/services/history.d.ts.map +1 -1
  127. package/dist/server/src/history/services/utils.d.ts +6 -10
  128. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  129. package/dist/server/src/index.d.ts +3 -2
  130. package/dist/server/src/index.d.ts.map +1 -1
  131. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -1
  132. package/dist/server/src/preview/index.d.ts.map +1 -1
  133. package/dist/server/src/preview/services/index.d.ts +1 -0
  134. package/dist/server/src/preview/services/index.d.ts.map +1 -1
  135. package/dist/server/src/preview/services/preview-config.d.ts +2 -0
  136. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -1
  137. package/dist/server/src/preview/utils.d.ts +1 -0
  138. package/dist/server/src/preview/utils.d.ts.map +1 -1
  139. package/dist/server/src/register.d.ts.map +1 -1
  140. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  141. package/dist/server/src/services/document-metadata.d.ts +4 -2
  142. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  143. package/dist/server/src/services/index.d.ts +3 -2
  144. package/dist/server/src/services/index.d.ts.map +1 -1
  145. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  146. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  147. package/dist/server/src/services/utils/populate.d.ts +2 -2
  148. package/dist/server/src/services/utils/populate.d.ts.map +1 -1
  149. package/package.json +12 -11
  150. package/dist/_chunks/EditViewPage-CdRxfy5B.mjs.map +0 -1
  151. package/dist/_chunks/EditViewPage-Ck6Duztu.js.map +0 -1
  152. package/dist/_chunks/Field-DDSx-gBR.mjs.map +0 -1
  153. package/dist/_chunks/Field-T3F_jdGo.js.map +0 -1
  154. package/dist/_chunks/History-CynfBe3Q.mjs.map +0 -1
  155. package/dist/_chunks/History-DMFKKvIA.js.map +0 -1
  156. package/dist/_chunks/ListConfigurationPage-BDV_ABiG.js.map +0 -1
  157. package/dist/_chunks/ListConfigurationPage-D2_aIJSH.mjs.map +0 -1
  158. package/dist/_chunks/ListViewPage-BJq_SQj8.mjs.map +0 -1
  159. package/dist/_chunks/ListViewPage-Z3jPNVn2.js.map +0 -1
  160. package/dist/_chunks/Relations-BlhtPLZk.js.map +0 -1
  161. package/dist/_chunks/Relations-ChkJKzz8.mjs.map +0 -1
  162. package/dist/_chunks/index-Bi51q_DG.js.map +0 -1
  163. package/dist/_chunks/index-C0PXR_tv.mjs.map +0 -1
  164. package/dist/_chunks/relations-D9fqpVRO.mjs.map +0 -1
  165. package/dist/_chunks/relations-lCDy3D3D.js.map +0 -1
  166. package/dist/_chunks/useDebounce-CtcjDB3L.js.map +0 -1
  167. package/dist/_chunks/useDebounce-DmuSJIF3.mjs +0 -29
  168. package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +0 -1
  169. package/dist/admin/src/preview/constants.d.ts +0 -1
  170. package/dist/server/src/preview/constants.d.ts +0 -2
  171. package/dist/server/src/preview/constants.d.ts.map +0 -1
@@ -3,23 +3,74 @@ const jsxRuntime = require("react/jsx-runtime");
3
3
  const React = require("react");
4
4
  const strapiAdmin = require("@strapi/admin/strapi-admin");
5
5
  const designSystem = require("@strapi/design-system");
6
- const pipe$1 = require("lodash/fp/pipe");
7
- const reactIntl = require("react-intl");
8
- const index = require("./index-Bi51q_DG.js");
9
- const fractionalIndexing = require("fractional-indexing");
10
- const Relations = require("./Relations-BlhtPLZk.js");
11
6
  const Icons = require("@strapi/icons");
7
+ const reactIntl = require("react-intl");
8
+ const index = require("./index-CxLSGwnk.js");
12
9
  const styledComponents = require("styled-components");
13
- const ComponentIcon = require("./ComponentIcon-BXdiCGQp.js");
14
- const reactDndHtml5Backend = require("react-dnd-html5-backend");
15
- const useDragAndDrop = require("./useDragAndDrop-J0TUUbR6.js");
16
- const objects = require("./objects-BcXOv6_9.js");
17
10
  const slate = require("slate");
18
11
  const slateHistory = require("slate-history");
19
12
  const slateReact = require("slate-react");
20
- const useDebounce = require("./useDebounce-CtcjDB3L.js");
13
+ const Prism = require("prismjs");
14
+ require("prismjs/themes/prism-solarizedlight.css");
15
+ require("prismjs/components/prism-asmatmel");
16
+ require("prismjs/components/prism-bash");
17
+ require("prismjs/components/prism-basic");
18
+ require("prismjs/components/prism-c");
19
+ require("prismjs/components/prism-clojure");
20
+ require("prismjs/components/prism-cobol");
21
+ require("prismjs/components/prism-cpp");
22
+ require("prismjs/components/prism-csharp");
23
+ require("prismjs/components/prism-dart");
24
+ require("prismjs/components/prism-docker");
25
+ require("prismjs/components/prism-elixir");
26
+ require("prismjs/components/prism-erlang");
27
+ require("prismjs/components/prism-fortran");
28
+ require("prismjs/components/prism-fsharp");
29
+ require("prismjs/components/prism-go");
30
+ require("prismjs/components/prism-graphql");
31
+ require("prismjs/components/prism-groovy");
32
+ require("prismjs/components/prism-haskell");
33
+ require("prismjs/components/prism-haxe");
34
+ require("prismjs/components/prism-ini");
35
+ require("prismjs/components/prism-java");
36
+ require("prismjs/components/prism-javascript");
37
+ require("prismjs/components/prism-jsx");
38
+ require("prismjs/components/prism-json");
39
+ require("prismjs/components/prism-julia");
40
+ require("prismjs/components/prism-kotlin");
41
+ require("prismjs/components/prism-latex");
42
+ require("prismjs/components/prism-lua");
43
+ require("prismjs/components/prism-markdown");
44
+ require("prismjs/components/prism-matlab");
45
+ require("prismjs/components/prism-makefile");
46
+ require("prismjs/components/prism-objectivec");
47
+ require("prismjs/components/prism-perl");
48
+ require("prismjs/components/prism-php");
49
+ require("prismjs/components/prism-powershell");
50
+ require("prismjs/components/prism-python");
51
+ require("prismjs/components/prism-r");
52
+ require("prismjs/components/prism-ruby");
53
+ require("prismjs/components/prism-rust");
54
+ require("prismjs/components/prism-sas");
55
+ require("prismjs/components/prism-scala");
56
+ require("prismjs/components/prism-scheme");
57
+ require("prismjs/components/prism-sql");
58
+ require("prismjs/components/prism-stata");
59
+ require("prismjs/components/prism-swift");
60
+ require("prismjs/components/prism-typescript");
61
+ require("prismjs/components/prism-tsx");
62
+ require("prismjs/components/prism-vbnet");
63
+ require("prismjs/components/prism-yaml");
64
+ const usePrev = require("./usePrev-B9w_-eYc.js");
65
+ const useDragAndDrop = require("./useDragAndDrop-BMtgCYzL.js");
21
66
  const Toolbar = require("@radix-ui/react-toolbar");
67
+ const reactDndHtml5Backend = require("react-dnd-html5-backend");
22
68
  const reactRouterDom = require("react-router-dom");
69
+ const objects = require("./objects-BcXOv6_9.js");
70
+ const Relations = require("./Relations-DcoOBejP.js");
71
+ const pipe$1 = require("lodash/fp/pipe");
72
+ const ComponentIcon = require("./ComponentIcon-CRbtQEUV.js");
73
+ const relations = require("./relations-S5nNKdN3.js");
23
74
  const CodeMirror = require("codemirror5");
24
75
  const sanitizeHtml = require("sanitize-html");
25
76
  const highlight_js = require("highlight.js");
@@ -37,8 +88,7 @@ require("highlight.js/styles/solarized-dark.css");
37
88
  require("codemirror5/addon/display/placeholder");
38
89
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
39
90
  function _interopNamespace(e) {
40
- if (e && e.__esModule)
41
- return e;
91
+ if (e && e.__esModule) return e;
42
92
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
43
93
  if (e) {
44
94
  for (const k in e) {
@@ -55,8 +105,9 @@ function _interopNamespace(e) {
55
105
  return Object.freeze(n);
56
106
  }
57
107
  const React__namespace = /* @__PURE__ */ _interopNamespace(React);
58
- const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
108
+ const Prism__namespace = /* @__PURE__ */ _interopNamespace(Prism);
59
109
  const Toolbar__namespace = /* @__PURE__ */ _interopNamespace(Toolbar);
110
+ const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
60
111
  const CodeMirror__default = /* @__PURE__ */ _interopDefault(CodeMirror);
61
112
  const sanitizeHtml__default = /* @__PURE__ */ _interopDefault(sanitizeHtml);
62
113
  const Markdown__default = /* @__PURE__ */ _interopDefault(Markdown);
@@ -69,93 +120,6 @@ const ins__default = /* @__PURE__ */ _interopDefault(ins);
69
120
  const mark__default = /* @__PURE__ */ _interopDefault(mark);
70
121
  const sub__default = /* @__PURE__ */ _interopDefault(sub);
71
122
  const sup__default = /* @__PURE__ */ _interopDefault(sup);
72
- const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
73
- const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
74
- const traverse = (datum, attributes) => {
75
- return Object.entries(datum).reduce((acc, [key, value]) => {
76
- const attribute = attributes[key];
77
- if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
78
- acc[key] = value;
79
- return acc;
80
- }
81
- if (attribute.type === "component") {
82
- if (attribute.repeatable) {
83
- const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
84
- acc[key] = componentValue.map(
85
- (componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
86
- );
87
- } else {
88
- const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
89
- acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
90
- }
91
- } else if (attribute.type === "dynamiczone") {
92
- const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
93
- acc[key] = dynamicZoneValue.map(
94
- (componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
95
- );
96
- } else if (predicate(attribute, value)) {
97
- acc[key] = transform(value, attribute);
98
- } else {
99
- acc[key] = value;
100
- }
101
- return acc;
102
- }, {});
103
- };
104
- return traverse(data, schema.attributes);
105
- };
106
- const removeProhibitedFields = (prohibitedFields) => traverseData(
107
- (attribute) => prohibitedFields.includes(attribute.type),
108
- () => ""
109
- );
110
- const prepareRelations = traverseData(
111
- (attribute) => attribute.type === "relation",
112
- () => ({
113
- connect: [],
114
- disconnect: []
115
- })
116
- );
117
- const prepareTempKeys = traverseData(
118
- (attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
119
- (data) => {
120
- if (Array.isArray(data) && data.length > 0) {
121
- const keys = fractionalIndexing.generateNKeysBetween(void 0, void 0, data.length);
122
- return data.map((datum, index2) => ({
123
- ...datum,
124
- __temp_key__: keys[index2]
125
- }));
126
- }
127
- return data;
128
- }
129
- );
130
- const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
131
- const schemaKeys = Object.keys(schema.attributes);
132
- const dataKeys = Object.keys(data);
133
- const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
134
- const revisedData = [...keysToRemove, ...index.DOCUMENT_META_FIELDS].reduce((acc, key) => {
135
- delete acc[key];
136
- return acc;
137
- }, structuredClone(data));
138
- return revisedData;
139
- };
140
- const removeNullValues = (data) => {
141
- return Object.entries(data).reduce((acc, [key, value]) => {
142
- if (value === null) {
143
- return acc;
144
- }
145
- acc[key] = value;
146
- return acc;
147
- }, {});
148
- };
149
- const transformDocument = (schema, components = {}) => (document2) => {
150
- const transformations = pipe__default.default(
151
- removeFieldsThatDontExistOnSchema(schema),
152
- removeProhibitedFields(["password"])(schema, components),
153
- removeNullValues,
154
- prepareRelations(schema, components),
155
- prepareTempKeys(schema, components)
156
- );
157
- return transformations(document2);
158
- };
159
123
  const componentStore = /* @__PURE__ */ new Map();
160
124
  const useLazyComponents = (componentUids = []) => {
161
125
  const [lazyComponentStore, setLazyComponentStore] = React.useState(Object.fromEntries(componentStore));
@@ -197,7 +161,8 @@ const useLazyComponents = (componentUids = []) => {
197
161
  const codeLanguages = [
198
162
  {
199
163
  value: "asm",
200
- label: "Assembly"
164
+ label: "Assembly",
165
+ decorate: "asmatmel"
201
166
  },
202
167
  {
203
168
  value: "bash",
@@ -233,7 +198,8 @@ const codeLanguages = [
233
198
  },
234
199
  {
235
200
  value: "dockerfile",
236
- label: "Dockerfile"
201
+ label: "Dockerfile",
202
+ decorate: "docker"
237
203
  },
238
204
  {
239
205
  value: "elixir",
@@ -389,7 +355,8 @@ const codeLanguages = [
389
355
  },
390
356
  {
391
357
  value: "typescript",
392
- label: "TypeScript"
358
+ label: "TypeScript",
359
+ decorate: "ts"
393
360
  },
394
361
  {
395
362
  value: "tsx",
@@ -405,7 +372,8 @@ const codeLanguages = [
405
372
  },
406
373
  {
407
374
  value: "yaml",
408
- label: "YAML"
375
+ label: "YAML",
376
+ decorate: "yml"
409
377
  }
410
378
  ];
411
379
  const baseHandleConvert = (editor, attributesToSet) => {
@@ -471,6 +439,29 @@ const pressEnterTwiceToExit = (editor) => {
471
439
  });
472
440
  }
473
441
  };
442
+ const decorateCode = ([node, path]) => {
443
+ const ranges = [];
444
+ if (!slate.Element.isElement(node) || node.type !== "code") return ranges;
445
+ const text = slate.Node.string(node);
446
+ const language = codeLanguages.find((lang) => lang.value === node.language);
447
+ const decorateKey = language?.decorate ?? language?.value;
448
+ const selectedLanguage = Prism__namespace.languages[decorateKey || "plaintext"];
449
+ const tokens = Prism__namespace.tokenize(text, selectedLanguage);
450
+ let start = 0;
451
+ for (const token of tokens) {
452
+ const length = token.length;
453
+ const end = start + length;
454
+ if (typeof token !== "string") {
455
+ ranges.push({
456
+ anchor: { path, offset: start },
457
+ focus: { path, offset: end },
458
+ className: `token ${token.type}`
459
+ });
460
+ }
461
+ start = end;
462
+ }
463
+ return ranges;
464
+ };
474
465
  const CodeBlock = styledComponents.styled.pre`
475
466
  border-radius: ${({ theme }) => theme.borderRadius};
476
467
  background-color: ${({ theme }) => theme.colors.neutral100};
@@ -542,7 +533,7 @@ const CodeEditor = (props) => {
542
533
  const codeBlocks = {
543
534
  code: {
544
535
  renderElement: (props) => /* @__PURE__ */ jsxRuntime.jsx(CodeEditor, { ...props }),
545
- icon: Icons.Code,
536
+ icon: Icons.CodeBlock,
546
537
  label: {
547
538
  id: "components.Blocks.blocks.code",
548
539
  defaultMessage: "Code block"
@@ -555,8 +546,7 @@ const codeBlocks = {
555
546
  handleEnterKey(editor) {
556
547
  pressEnterTwiceToExit(editor);
557
548
  },
558
- snippets: ["```"],
559
- dragHandleTopMargin: "10px"
549
+ snippets: ["```"]
560
550
  }
561
551
  };
562
552
  const H1 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h1" })`
@@ -731,8 +721,7 @@ const ImageDialog = () => {
731
721
  const [isOpen, setIsOpen] = React__namespace.useState(true);
732
722
  const { editor } = useBlocksEditorContext("ImageDialog");
733
723
  const components = strapiAdmin.useStrapiApp("ImageDialog", (state) => state.components);
734
- if (!components || !isOpen)
735
- return null;
724
+ if (!components || !isOpen) return null;
736
725
  const MediaLibraryDialog = components["media-library"];
737
726
  const insertImages = (images) => {
738
727
  slate.Transforms.unwrapNodes(editor, {
@@ -741,14 +730,12 @@ const ImageDialog = () => {
741
730
  });
742
731
  const nodeEntryBeingReplaced = slate.Editor.above(editor, {
743
732
  match(node) {
744
- if (slate.Editor.isEditor(node))
745
- return false;
733
+ if (slate.Editor.isEditor(node)) return false;
746
734
  const isInlineNode = ["text", "link"].includes(node.type);
747
735
  return !isInlineNode;
748
736
  }
749
737
  });
750
- if (!nodeEntryBeingReplaced)
751
- return;
738
+ if (!nodeEntryBeingReplaced) return;
752
739
  const [, pathToInsert] = nodeEntryBeingReplaced;
753
740
  slate.Transforms.removeNodes(editor);
754
741
  const nodesToInsert = images.map((image) => {
@@ -768,7 +755,7 @@ const ImageDialog = () => {
768
755
  const nodeImage = {
769
756
  ...expectedImage,
770
757
  alternativeText: expectedImage.alternativeText || expectedImage.name,
771
- url: useDebounce.prefixFileUrlWithBackendUrl(image.url)
758
+ url: usePrev.prefixFileUrlWithBackendUrl(image.url)
772
759
  };
773
760
  return nodeImage;
774
761
  });
@@ -926,8 +913,7 @@ const LinkContent = React__namespace.forwardRef(
926
913
  slateReact.ReactEditor.focus(editor);
927
914
  };
928
915
  React__namespace.useEffect(() => {
929
- if (popoverOpen)
930
- linkInputRef.current?.focus();
916
+ if (popoverOpen) linkInputRef.current?.focus();
931
917
  }, [popoverOpen]);
932
918
  const inputNotDirty = !linkText || !linkUrl || link.url && link.url === linkUrl && elementText && elementText === linkText;
933
919
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Popover.Root, { open: popoverOpen, children: [
@@ -997,11 +983,11 @@ const LinkContent = React__namespace.forwardRef(
997
983
  ),
998
984
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
999
985
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: handleClose, children: formatMessage({
1000
- id: "components.Blocks.popover.cancel",
986
+ id: "global.cancel",
1001
987
  defaultMessage: "Cancel"
1002
988
  }) }),
1003
989
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { disabled: Boolean(inputNotDirty) || isSaveDisabled, onClick: handleSave, children: formatMessage({
1004
- id: "components.Blocks.popover.save",
990
+ id: "global.save",
1005
991
  defaultMessage: "Save"
1006
992
  }) })
1007
993
  ] })
@@ -1082,8 +1068,7 @@ const isText$1 = (node) => {
1082
1068
  return slate.Node.isNode(node) && !slate.Editor.isEditor(node) && node.type === "text";
1083
1069
  };
1084
1070
  const handleBackspaceKeyOnList = (editor, event) => {
1085
- if (!editor.selection)
1086
- return;
1071
+ if (!editor.selection) return;
1087
1072
  const [currentListItem, currentListItemPath] = slate.Editor.parent(editor, editor.selection.anchor);
1088
1073
  const [currentList, currentListPath] = slate.Editor.parent(editor, currentListItemPath);
1089
1074
  const isListEmpty = currentList.children.length === 1 && isText$1(currentListItem.children[0]) && currentListItem.children[0].text === "";
@@ -1192,8 +1177,7 @@ const handleEnterKeyOnList = (editor) => {
1192
1177
  };
1193
1178
  const handleConvertToList = (editor, format) => {
1194
1179
  const convertedPath = baseHandleConvert(editor, { type: "list-item" });
1195
- if (!convertedPath)
1196
- return;
1180
+ if (!convertedPath) return;
1197
1181
  slate.Transforms.wrapNodes(editor, { type: "list", format, children: [] }, { at: convertedPath });
1198
1182
  };
1199
1183
  const handleTabOnList = (editor) => {
@@ -1205,8 +1189,7 @@ const handleTabOnList = (editor) => {
1205
1189
  }
1206
1190
  const [currentListItem, currentListItemPath] = currentListItemEntry;
1207
1191
  const [currentList] = slate.Editor.parent(editor, currentListItemPath);
1208
- if (currentListItem === currentList.children[0])
1209
- return;
1192
+ if (currentListItem === currentList.children[0]) return;
1210
1193
  const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);
1211
1194
  const previousNode = currentList.children[currentListItemIndex - 1];
1212
1195
  if (previousNode.type === "list") {
@@ -1342,13 +1325,13 @@ const quoteBlocks = {
1342
1325
  handleEnterKey(editor) {
1343
1326
  pressEnterTwiceToExit(editor);
1344
1327
  },
1345
- snippets: [">"],
1346
- dragHandleTopMargin: "6px"
1328
+ snippets: [">"]
1347
1329
  }
1348
1330
  };
1349
1331
  const ToolbarWrapper = styledComponents.styled(designSystem.Flex)`
1350
1332
  &[aria-disabled='true'] {
1351
1333
  cursor: not-allowed;
1334
+ background: ${({ theme }) => theme.colors.neutral150};
1352
1335
  }
1353
1336
  `;
1354
1337
  const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
@@ -1359,7 +1342,7 @@ const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
1359
1342
  const FlexButton = styledComponents.styled(designSystem.Flex)`
1360
1343
  // Inherit the not-allowed cursor from ToolbarWrapper when disabled
1361
1344
  &[aria-disabled] {
1362
- cursor: inherit;
1345
+ cursor: not-allowed;
1363
1346
  }
1364
1347
 
1365
1348
  &[aria-disabled='false'] {
@@ -1573,8 +1556,7 @@ const isListNode = (node) => {
1573
1556
  const ListButton = ({ block, format }) => {
1574
1557
  const { editor, disabled, blocks } = useBlocksEditorContext("ListButton");
1575
1558
  const isListActive = () => {
1576
- if (!editor.selection)
1577
- return false;
1559
+ if (!editor.selection) return false;
1578
1560
  const currentListEntry = slate.Editor.above(editor, {
1579
1561
  match: (node) => !slate.Editor.isEditor(node) && node.type === "list",
1580
1562
  at: editor.selection.anchor
@@ -1648,8 +1630,7 @@ const LinkButton = ({ disabled }) => {
1648
1630
  const { editor } = useBlocksEditorContext("LinkButton");
1649
1631
  const isLinkActive = () => {
1650
1632
  const { selection } = editor;
1651
- if (!selection)
1652
- return false;
1633
+ if (!selection) return false;
1653
1634
  const [match] = Array.from(
1654
1635
  slate.Editor.nodes(editor, {
1655
1636
  at: slate.Editor.unhangRange(editor, selection),
@@ -1713,7 +1694,7 @@ const BlocksToolbar = () => {
1713
1694
  return false;
1714
1695
  };
1715
1696
  const isButtonDisabled = checkButtonDisabled();
1716
- return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, children: [
1697
+ return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, width: "100%", children: [
1717
1698
  /* @__PURE__ */ jsxRuntime.jsx(BlocksDropdown, {}),
1718
1699
  /* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
1719
1700
  /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.ToggleGroup, { type: "multiple", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, children: [
@@ -1787,30 +1768,32 @@ const DragIconButton = styledComponents.styled(designSystem.IconButton)`
1787
1768
  display: flex;
1788
1769
  align-items: center;
1789
1770
  justify-content: center;
1771
+ border: none;
1790
1772
  border-radius: ${({ theme }) => theme.borderRadius};
1791
- width: ${({ theme }) => theme.spaces[4]};
1792
- height: ${({ theme }) => theme.spaces[6]};
1773
+ padding-left: ${({ theme }) => theme.spaces[0]};
1774
+ padding-right: ${({ theme }) => theme.spaces[0]};
1775
+ padding-top: ${({ theme }) => theme.spaces[1]};
1776
+ padding-bottom: ${({ theme }) => theme.spaces[1]};
1793
1777
  visibility: hidden;
1794
1778
  cursor: grab;
1795
1779
  opacity: inherit;
1796
1780
  margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
1797
1781
 
1798
1782
  &:hover {
1799
- background: ${({ theme }) => theme.colors.neutral200};
1783
+ background: ${({ theme }) => theme.colors.neutral100};
1800
1784
  }
1801
1785
  &:active {
1802
1786
  cursor: grabbing;
1787
+ background: ${({ theme }) => theme.colors.neutral150};
1803
1788
  }
1804
1789
  &[aria-disabled='true'] {
1805
- cursor: not-allowed;
1806
- background: transparent;
1790
+ visibility: hidden;
1807
1791
  }
1808
1792
  svg {
1809
- height: auto;
1810
1793
  min-width: ${({ theme }) => theme.spaces[3]};
1811
1794
 
1812
1795
  path {
1813
- fill: ${({ theme }) => theme.colors.neutral700};
1796
+ fill: ${({ theme }) => theme.colors.neutral500};
1814
1797
  }
1815
1798
  }
1816
1799
  `;
@@ -1855,8 +1838,7 @@ const DragAndDropElement = ({
1855
1838
  displayedValue: children
1856
1839
  },
1857
1840
  onDropItem(currentIndex, newIndex) {
1858
- if (newIndex)
1859
- handleMoveBlock(newIndex, currentIndex);
1841
+ if (newIndex) handleMoveBlock(newIndex, currentIndex);
1860
1842
  }
1861
1843
  });
1862
1844
  const composedBoxRefs = designSystem.useComposedRefs(blockRef, dropRef);
@@ -1962,7 +1944,7 @@ const baseRenderLeaf = (props, modifiers2) => {
1962
1944
  }
1963
1945
  return currentChildren;
1964
1946
  }, props.children);
1965
- return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, children: wrappedChildren });
1947
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { ...props.attributes, className: props.leaf.className, children: wrappedChildren });
1966
1948
  };
1967
1949
  const baseRenderElement = ({
1968
1950
  props,
@@ -2000,8 +1982,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
2000
1982
  [modifiers2]
2001
1983
  );
2002
1984
  const handleMoveBlocks = (editor2, event) => {
2003
- if (!editor2.selection)
2004
- return;
1985
+ if (!editor2.selection) return;
2005
1986
  const start = slate.Range.start(editor2.selection);
2006
1987
  const currentIndex = [start.path[0]];
2007
1988
  let newIndexPosition = 0;
@@ -2138,8 +2119,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
2138
2119
  }
2139
2120
  };
2140
2121
  const handleScrollSelectionIntoView = () => {
2141
- if (!editor.selection)
2142
- return;
2122
+ if (!editor.selection) return;
2143
2123
  const domRange = slateReact.ReactEditor.toDOMRange(editor, editor.selection);
2144
2124
  const domRect = domRange.getBoundingClientRect();
2145
2125
  const blocksInput = blocksRef.current;
@@ -2166,7 +2146,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
2166
2146
  background: "neutral0",
2167
2147
  color: "neutral800",
2168
2148
  lineHeight: 6,
2169
- paddingRight: 4,
2149
+ paddingRight: 7,
2170
2150
  paddingTop: 6,
2171
2151
  paddingBottom: 3,
2172
2152
  children: [
@@ -2177,6 +2157,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
2177
2157
  readOnly: disabled,
2178
2158
  placeholder,
2179
2159
  isExpandedMode,
2160
+ decorate: decorateCode,
2180
2161
  renderElement,
2181
2162
  renderLeaf,
2182
2163
  onKeyDown: handleKeyDown,
@@ -2333,8 +2314,7 @@ const InlineCode = styledComponents.styled.code`
2333
2314
  `;
2334
2315
  const baseCheckIsActive = (editor, name2) => {
2335
2316
  const marks = slate.Editor.marks(editor);
2336
- if (!marks)
2337
- return false;
2317
+ if (!marks) return false;
2338
2318
  return Boolean(marks[name2]);
2339
2319
  };
2340
2320
  const baseHandleToggle = (editor, name2) => {
@@ -2500,6 +2480,7 @@ const ExpandIconButton = styledComponents.styled(designSystem.IconButton)`
2500
2480
  position: absolute;
2501
2481
  bottom: 1.2rem;
2502
2482
  right: 1.2rem;
2483
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2503
2484
  `;
2504
2485
  function useResetKey(value) {
2505
2486
  const slateUpdatesCount = React__namespace.useRef(0);
@@ -2631,26 +2612,6 @@ const BlocksInput = React__namespace.forwardRef(
2631
2612
  }
2632
2613
  );
2633
2614
  const MemoizedBlocksInput = React__namespace.memo(BlocksInput);
2634
- const createDefaultForm = (contentType, components = {}) => {
2635
- const traverseSchema = (attributes) => {
2636
- return Object.entries(attributes).reduce((acc, [key, attribute]) => {
2637
- if ("default" in attribute) {
2638
- acc[key] = attribute.default;
2639
- } else if (attribute.type === "component" && attribute.required) {
2640
- const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
2641
- if (attribute.repeatable) {
2642
- acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
2643
- } else {
2644
- acc[key] = defaultComponentForm;
2645
- }
2646
- } else if (attribute.type === "dynamiczone" && attribute.required) {
2647
- acc[key] = [];
2648
- }
2649
- return acc;
2650
- }, {});
2651
- };
2652
- return traverseSchema(contentType.attributes);
2653
- };
2654
2615
  const Initializer = ({ disabled, name: name2, onClick }) => {
2655
2616
  const { formatMessage } = reactIntl.useIntl();
2656
2617
  const field = strapiAdmin.useField(name2);
@@ -2658,7 +2619,7 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
2658
2619
  designSystem.Box,
2659
2620
  {
2660
2621
  tag: "button",
2661
- background: "neutral100",
2622
+ background: disabled ? "neutral150" : "neutral100",
2662
2623
  borderColor: field.error ? "danger600" : "neutral200",
2663
2624
  hasRadius: true,
2664
2625
  disabled,
@@ -2666,631 +2627,638 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
2666
2627
  paddingTop: 9,
2667
2628
  paddingBottom: 9,
2668
2629
  type: "button",
2630
+ style: { cursor: disabled ? "not-allowed" : "pointer" },
2669
2631
  children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
2670
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(CircleIcon, {}) }),
2671
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "primary600", variant: "pi", fontWeight: "bold", children: formatMessage({
2672
- id: index.getTranslation("components.empty-repeatable"),
2673
- defaultMessage: "No entry yet. Click to add one."
2674
- }) }) })
2632
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
2633
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
2634
+ designSystem.Typography,
2635
+ {
2636
+ textColor: disabled ? "neutral600" : "primary600",
2637
+ variant: "pi",
2638
+ fontWeight: "bold",
2639
+ children: formatMessage({
2640
+ id: index.getTranslation("components.empty-repeatable"),
2641
+ defaultMessage: "No entry yet. Click to add one."
2642
+ })
2643
+ }
2644
+ ) })
2675
2645
  ] })
2676
2646
  }
2677
2647
  ) });
2678
2648
  };
2679
- const CircleIcon = styledComponents.styled(Icons.PlusCircle)`
2680
- width: 2.4rem;
2681
- height: 2.4rem;
2649
+ const AddComponentButton = ({
2650
+ hasError,
2651
+ isDisabled,
2652
+ isOpen,
2653
+ children,
2654
+ onClick
2655
+ }) => {
2656
+ return /* @__PURE__ */ jsxRuntime.jsx(
2657
+ StyledButton,
2658
+ {
2659
+ type: "button",
2660
+ onClick,
2661
+ disabled: isDisabled,
2662
+ background: "neutral0",
2663
+ style: { cursor: isDisabled ? "not-allowed" : "pointer" },
2664
+ variant: "tertiary",
2665
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
2666
+ /* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
2667
+ /* @__PURE__ */ jsxRuntime.jsx(
2668
+ designSystem.Typography,
2669
+ {
2670
+ variant: "pi",
2671
+ fontWeight: "bold",
2672
+ textColor: hasError && !isOpen ? "danger600" : "neutral600",
2673
+ children
2674
+ }
2675
+ )
2676
+ ] })
2677
+ }
2678
+ );
2679
+ };
2680
+ const StyledAddIcon = styledComponents.styled(Icons.PlusCircle)`
2681
+ height: ${({ theme }) => theme.spaces[6]};
2682
+ width: ${({ theme }) => theme.spaces[6]};
2683
+ transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
2684
+
2682
2685
  > circle {
2683
- fill: ${({ theme }) => theme.colors.primary200};
2686
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
2684
2687
  }
2685
2688
  > path {
2686
- fill: ${({ theme }) => theme.colors.primary600};
2689
+ fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral500};
2687
2690
  }
2688
2691
  `;
2689
- const NonRepeatableComponent = ({
2690
- attribute,
2691
- name: name2,
2692
- children,
2693
- layout
2692
+ const StyledButton = styledComponents.styled(designSystem.Button)`
2693
+ padding-left: ${({ theme }) => theme.spaces[3]};
2694
+ border-radius: 26px;
2695
+ box-shadow: ${({ theme }) => theme.shadows.filterShadow};
2696
+ height: 5rem;
2697
+ `;
2698
+ const ComponentCategory = ({
2699
+ category,
2700
+ components = [],
2701
+ variant = "primary",
2702
+ onAddComponent
2694
2703
  }) => {
2695
- const { value } = strapiAdmin.useField(name2);
2696
- const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
2697
- const isNested = level > 0;
2698
- return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
2704
+ const { formatMessage } = reactIntl.useIntl();
2705
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: category, children: [
2706
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
2707
+ /* @__PURE__ */ jsxRuntime.jsx(ResponsiveAccordionContent, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
2708
+ ComponentBox,
2709
+ {
2710
+ tag: "button",
2711
+ type: "button",
2712
+ background: "neutral100",
2713
+ justifyContent: "center",
2714
+ onClick: onAddComponent(uid),
2715
+ hasRadius: true,
2716
+ height: "8.4rem",
2717
+ shrink: 0,
2718
+ borderColor: "neutral200",
2719
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
2720
+ /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
2721
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
2722
+ ] })
2723
+ },
2724
+ uid
2725
+ )) }) })
2726
+ ] });
2727
+ };
2728
+ const ResponsiveAccordionContent = styledComponents.styled(designSystem.Accordion.Content)`
2729
+ container-type: inline-size;
2730
+ `;
2731
+ const Grid = styledComponents.styled(designSystem.Box)`
2732
+ display: grid;
2733
+ grid-template-columns: repeat(auto-fill, 100%);
2734
+ grid-gap: ${({ theme }) => theme.spaces[1]};
2735
+
2736
+ @container (min-width: ${() => RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
2737
+ grid-template-columns: repeat(auto-fill, 14rem);
2738
+ }
2739
+ `;
2740
+ const ComponentBox = styledComponents.styled(designSystem.Flex)`
2741
+ color: ${({ theme }) => theme.colors.neutral600};
2742
+ cursor: pointer;
2743
+
2744
+ @media (prefers-reduced-motion: no-preference) {
2745
+ transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2746
+ }
2747
+
2748
+ &:focus,
2749
+ &:hover {
2750
+ border: 1px solid ${({ theme }) => theme.colors.primary200};
2751
+ background: ${({ theme }) => theme.colors.primary100};
2752
+ color: ${({ theme }) => theme.colors.primary600};
2753
+ }
2754
+ `;
2755
+ const ComponentPicker = ({
2756
+ dynamicComponentsByCategory = {},
2757
+ isOpen,
2758
+ onClickAddComponent
2759
+ }) => {
2760
+ const { formatMessage } = reactIntl.useIntl();
2761
+ const handleAddComponentToDz = (componentUid) => () => {
2762
+ onClickAddComponent(componentUid);
2763
+ };
2764
+ if (!isOpen) {
2765
+ return null;
2766
+ }
2767
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2699
2768
  designSystem.Box,
2700
2769
  {
2701
- background: "neutral100",
2702
- paddingLeft: 6,
2703
- paddingRight: 6,
2704
2770
  paddingTop: 6,
2705
2771
  paddingBottom: 6,
2706
- hasRadius: isNested,
2707
- borderColor: isNested ? "neutral200" : void 0,
2708
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
2709
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2710
- const completeFieldName = `${name2}.${field.name}`;
2711
- return /* @__PURE__ */ jsxRuntime.jsx(
2712
- designSystem.Grid.Item,
2713
- {
2714
- col: size,
2715
- s: 12,
2716
- xs: 12,
2717
- direction: "column",
2718
- alignItems: "stretch",
2719
- children: children({ ...field, name: completeFieldName })
2720
- },
2721
- completeFieldName
2722
- );
2723
- }) }, index2);
2724
- }) })
2772
+ paddingLeft: 5,
2773
+ paddingRight: 5,
2774
+ background: "neutral0",
2775
+ shadow: "tableShadow",
2776
+ borderColor: "neutral150",
2777
+ hasRadius: true,
2778
+ children: [
2779
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
2780
+ id: index.getTranslation("components.DynamicZone.ComponentPicker-label"),
2781
+ defaultMessage: "Pick one component"
2782
+ }) }) }),
2783
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index2) => /* @__PURE__ */ jsxRuntime.jsx(
2784
+ ComponentCategory,
2785
+ {
2786
+ category,
2787
+ components,
2788
+ onAddComponent: handleAddComponentToDz,
2789
+ variant: index2 % 2 === 1 ? "primary" : "secondary"
2790
+ },
2791
+ category
2792
+ )) }) })
2793
+ ]
2725
2794
  }
2726
- ) });
2795
+ );
2727
2796
  };
2728
- const RepeatableComponent = ({
2729
- attribute,
2797
+ const DynamicComponent = ({
2798
+ componentUid,
2730
2799
  disabled,
2800
+ index: index$1,
2731
2801
  name: name2,
2732
- mainField,
2733
- children,
2734
- layout
2802
+ onRemoveComponentClick,
2803
+ onMoveComponent,
2804
+ onGrabItem,
2805
+ onDropItem,
2806
+ onCancel,
2807
+ dynamicComponentsByCategory = {},
2808
+ onAddComponent,
2809
+ children
2735
2810
  }) => {
2736
- const { toggleNotification } = strapiAdmin.useNotification();
2737
2811
  const { formatMessage } = reactIntl.useIntl();
2738
- const { search: searchString } = reactRouterDom.useLocation();
2739
- const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
2740
- const { components } = index.useDoc();
2812
+ const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
2741
2813
  const {
2742
- value = [],
2743
- error,
2744
- rawError
2745
- } = strapiAdmin.useField(name2);
2746
- const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
2747
- const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
2748
- const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
2749
- const { max = Infinity } = attribute;
2814
+ edit: { components }
2815
+ } = index.useDocLayout();
2816
+ const title = React__namespace.useMemo(() => {
2817
+ const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
2818
+ const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
2819
+ const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
2820
+ const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
2821
+ return mainValue;
2822
+ }, [componentUid, components, formValues, name2, index$1]);
2823
+ const { icon, displayName } = React__namespace.useMemo(() => {
2824
+ const [category] = componentUid.split(".");
2825
+ const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
2826
+ (component) => component.uid === componentUid
2827
+ ) ?? { icon: null, displayName: null };
2828
+ return { icon: icon2, displayName: displayName2 };
2829
+ }, [componentUid, dynamicComponentsByCategory]);
2830
+ const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
2831
+ type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
2832
+ index: index$1,
2833
+ item: {
2834
+ index: index$1,
2835
+ displayedValue: `${displayName} ${title}`,
2836
+ icon
2837
+ },
2838
+ onMoveItem: onMoveComponent,
2839
+ onDropItem,
2840
+ onGrabItem,
2841
+ onCancel
2842
+ });
2843
+ React__namespace.useEffect(() => {
2844
+ dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
2845
+ }, [dragPreviewRef, index$1]);
2846
+ const accordionValue = React__namespace.useId();
2847
+ const { value = [], rawError } = strapiAdmin.useField(`${name2}.${index$1}`);
2750
2848
  const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
2751
- const [liveText, setLiveText] = React__namespace.useState("");
2752
2849
  React__namespace.useEffect(() => {
2753
- const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
2754
- const hasNestedValue = value && Array.isArray(value) && value.length > 0;
2755
- if (hasNestedErrors && hasNestedValue) {
2756
- const errorOpenItems = rawError.map((_, idx) => {
2757
- return value[idx] ? value[idx].__temp_key__ : null;
2758
- }).filter((value2) => !!value2);
2759
- if (errorOpenItems && errorOpenItems.length > 0) {
2760
- setCollapseToOpen((collapseToOpen2) => {
2761
- if (!errorOpenItems.includes(collapseToOpen2)) {
2762
- return errorOpenItems[0];
2763
- }
2764
- return collapseToOpen2;
2765
- });
2766
- }
2850
+ if (rawError && value) {
2851
+ setCollapseToOpen(accordionValue);
2767
2852
  }
2768
- }, [rawError, value]);
2769
- const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
2770
- if (search.has("field")) {
2771
- const fieldParam = search.get("field");
2772
- if (!fieldParam) {
2773
- return void 0;
2853
+ }, [rawError, value, accordionValue]);
2854
+ const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
2855
+ const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2856
+ /* @__PURE__ */ jsxRuntime.jsx(
2857
+ designSystem.IconButton,
2858
+ {
2859
+ variant: "ghost",
2860
+ label: formatMessage(
2861
+ {
2862
+ id: index.getTranslation("components.DynamicZone.delete-label"),
2863
+ defaultMessage: "Delete {name}"
2864
+ },
2865
+ { name: title }
2866
+ ),
2867
+ onClick: onRemoveComponentClick,
2868
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
2774
2869
  }
2775
- const [, path] = fieldParam.split(`${name2}.`);
2776
- if (objects.getIn(value, path, void 0) !== void 0) {
2777
- const [subpath] = path.split(".");
2778
- return objects.getIn(value, subpath, void 0)?.__temp_key__;
2870
+ ),
2871
+ /* @__PURE__ */ jsxRuntime.jsx(
2872
+ designSystem.IconButton,
2873
+ {
2874
+ variant: "ghost",
2875
+ onClick: (e) => e.stopPropagation(),
2876
+ "data-handler-id": handlerId,
2877
+ ref: dragRef,
2878
+ label: formatMessage({
2879
+ id: index.getTranslation("components.DragHandle-label"),
2880
+ defaultMessage: "Drag"
2881
+ }),
2882
+ onKeyDown: handleKeyDown,
2883
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
2779
2884
  }
2780
- }
2781
- return void 0;
2782
- }, [search, name2, value]);
2783
- const prevValue = useDebounce.usePrev(value);
2784
- React__namespace.useEffect(() => {
2785
- if (prevValue && prevValue.length < value.length) {
2786
- setCollapseToOpen(value[value.length - 1].__temp_key__);
2787
- }
2788
- }, [value, prevValue]);
2789
- React__namespace.useEffect(() => {
2790
- if (typeof componentTmpKeyWithFocussedField === "string") {
2791
- setCollapseToOpen(componentTmpKeyWithFocussedField);
2792
- }
2793
- }, [componentTmpKeyWithFocussedField]);
2794
- const toggleCollapses = () => {
2795
- setCollapseToOpen("");
2796
- };
2797
- const handleClick = () => {
2798
- if (value.length < max) {
2799
- const schema = components[attribute.component];
2800
- const form = createDefaultForm(schema, components);
2801
- const data = transformDocument(schema, components)(form);
2802
- addFieldRow(name2, data);
2803
- } else if (value.length >= max) {
2804
- toggleNotification({
2805
- type: "info",
2806
- message: formatMessage({
2807
- id: index.getTranslation("components.notification.info.maximum-requirement")
2808
- })
2809
- });
2810
- }
2811
- };
2812
- const handleMoveComponentField = (newIndex, currentIndex) => {
2813
- setLiveText(
2814
- formatMessage(
2815
- {
2816
- id: index.getTranslation("dnd.reorder"),
2817
- defaultMessage: "{item}, moved. New position in list: {position}."
2818
- },
2819
- {
2820
- item: `${name2}.${currentIndex}`,
2821
- position: getItemPos(newIndex)
2822
- }
2823
- )
2824
- );
2825
- moveFieldRow(name2, currentIndex, newIndex);
2826
- };
2827
- const handleValueChange = (key) => {
2828
- setCollapseToOpen(key);
2829
- };
2830
- const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
2831
- const handleCancel = (index$1) => {
2832
- setLiveText(
2833
- formatMessage(
2834
- {
2835
- id: index.getTranslation("dnd.cancel-item"),
2836
- defaultMessage: "{item}, dropped. Re-order cancelled."
2837
- },
2838
- {
2839
- item: `${name2}.${index$1}`
2840
- }
2841
- )
2842
- );
2843
- };
2844
- const handleGrabItem = (index$1) => {
2845
- setLiveText(
2846
- formatMessage(
2847
- {
2848
- id: index.getTranslation("dnd.grab-item"),
2849
- defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
2850
- },
2885
+ ),
2886
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
2887
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 0, paddingRight: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
2888
+ designSystem.IconButton,
2851
2889
  {
2852
- item: `${name2}.${index$1}`,
2853
- position: getItemPos(index$1)
2890
+ variant: "ghost",
2891
+ label: formatMessage({
2892
+ id: index.getTranslation("components.DynamicZone.more-actions"),
2893
+ defaultMessage: "More actions"
2894
+ }),
2895
+ tag: "span",
2896
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false })
2854
2897
  }
2855
- )
2856
- );
2857
- };
2858
- const handleDropItem = (index$1) => {
2859
- setLiveText(
2860
- formatMessage(
2861
- {
2862
- id: index.getTranslation("dnd.drop-item"),
2863
- defaultMessage: `{item}, dropped. Final position in list: {position}.`
2864
- },
2898
+ ) }),
2899
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
2900
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
2901
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
2902
+ id: index.getTranslation("components.DynamicZone.add-item-above"),
2903
+ defaultMessage: "Add component above"
2904
+ }) }),
2905
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2906
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
2907
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
2908
+ ] }, category)) })
2909
+ ] }),
2910
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
2911
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
2912
+ id: index.getTranslation("components.DynamicZone.add-item-below"),
2913
+ defaultMessage: "Add component below"
2914
+ }) }),
2915
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
2916
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
2917
+ components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
2918
+ ] }, category)) })
2919
+ ] })
2920
+ ] })
2921
+ ] })
2922
+ ] });
2923
+ const accordionTitle = title ? `${displayName} ${title}` : displayName;
2924
+ return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
2925
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
2926
+ /* @__PURE__ */ jsxRuntime.jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview$1, {}) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: accordionValue, children: [
2927
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
2928
+ /* @__PURE__ */ jsxRuntime.jsx(
2929
+ designSystem.Accordion.Trigger,
2930
+ {
2931
+ icon: icon && ComponentIcon.COMPONENT_ICONS[icon] ? ComponentIcon.COMPONENT_ICONS[icon] : ComponentIcon.COMPONENT_ICONS.dashboard,
2932
+ children: accordionTitle
2933
+ }
2934
+ ),
2935
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
2936
+ ] }),
2937
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsxRuntime.jsx(
2938
+ designSystem.Grid.Item,
2865
2939
  {
2866
- item: `${name2}.${index$1}`,
2867
- position: getItemPos(index$1)
2868
- }
2869
- )
2870
- );
2871
- };
2872
- const ariaDescriptionId = React__namespace.useId();
2873
- const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
2874
- if (value.length === 0) {
2875
- return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
2876
- }
2877
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
2878
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
2879
- id: index.getTranslation("dnd.instructions"),
2880
- defaultMessage: `Press spacebar to grab and re-order`
2881
- }) }),
2882
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
2883
- /* @__PURE__ */ jsxRuntime.jsxs(
2884
- AccordionRoot,
2885
- {
2886
- $error: error,
2887
- value: collapseToOpen,
2888
- onValueChange: handleValueChange,
2889
- "aria-describedby": ariaDescriptionId,
2890
- children: [
2891
- value.map(({ __temp_key__: key, id }, index2) => {
2892
- const nameWithIndex = `${name2}.${index2}`;
2940
+ col: 12,
2941
+ s: 12,
2942
+ xs: 12,
2943
+ direction: "column",
2944
+ alignItems: "stretch",
2945
+ children: /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
2946
+ const fieldName = `${name2}.${index$1}.${field.name}`;
2947
+ const fieldWithTranslatedLabel = {
2948
+ ...field,
2949
+ label: formatMessage({
2950
+ id: `content-manager.components.${componentUid}.${field.name}`,
2951
+ defaultMessage: field.label
2952
+ })
2953
+ };
2893
2954
  return /* @__PURE__ */ jsxRuntime.jsx(
2894
- Relations.ComponentProvider,
2955
+ ResponsiveGridItem,
2895
2956
  {
2896
- id,
2897
- uid: attribute.component,
2898
- level: level + 1,
2899
- type: "repeatable",
2900
- children: /* @__PURE__ */ jsxRuntime.jsx(
2901
- Component,
2902
- {
2903
- disabled,
2904
- name: nameWithIndex,
2905
- attribute,
2906
- index: index2,
2907
- mainField,
2908
- onMoveItem: handleMoveComponentField,
2909
- onDeleteComponent: () => {
2910
- removeFieldRow(name2, index2);
2911
- toggleCollapses();
2912
- },
2913
- toggleCollapses,
2914
- onCancel: handleCancel,
2915
- onDropItem: handleDropItem,
2916
- onGrabItem: handleGrabItem,
2917
- __temp_key__: key,
2918
- children: layout.map((row, index22) => {
2919
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2920
- const completeFieldName = `${nameWithIndex}.${field.name}`;
2921
- return /* @__PURE__ */ jsxRuntime.jsx(
2922
- designSystem.Grid.Item,
2923
- {
2924
- col: size,
2925
- s: 12,
2926
- xs: 12,
2927
- direction: "column",
2928
- alignItems: "stretch",
2929
- children: children({ ...field, name: completeFieldName })
2930
- },
2931
- completeFieldName
2932
- );
2933
- }) }, index22);
2934
- })
2935
- }
2936
- )
2957
+ col: size,
2958
+ s: 12,
2959
+ xs: 12,
2960
+ direction: "column",
2961
+ alignItems: "stretch",
2962
+ children: children ? children({ ...fieldWithTranslatedLabel, name: fieldName }) : /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
2937
2963
  },
2938
- key
2964
+ fieldName
2939
2965
  );
2940
- }),
2941
- /* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
2942
- id: index.getTranslation("containers.EditView.add.new-entry"),
2943
- defaultMessage: "Add an entry"
2944
2966
  }) })
2945
- ]
2946
- }
2947
- )
2967
+ },
2968
+ rowInd
2969
+ )) }) }) }) })
2970
+ ] }) }) })
2948
2971
  ] });
2949
2972
  };
2950
- const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
2951
- border: 1px solid
2952
- ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
2953
- `;
2954
- const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
2955
- width: 100%;
2956
- display: flex;
2957
- justify-content: center;
2958
- border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
2959
- padding-inline: ${(props) => props.theme.spaces[6]};
2960
- padding-block: ${(props) => props.theme.spaces[3]};
2961
-
2962
- &:not([disabled]) {
2963
- cursor: pointer;
2964
-
2965
- &:hover {
2966
- background-color: ${(props) => props.theme.colors.primary100};
2967
- }
2968
- }
2969
-
2970
- span {
2971
- font-weight: 600;
2972
- font-size: 1.4rem;
2973
- line-height: 2.4rem;
2974
- }
2975
-
2976
- @media (prefers-reduced-motion: no-preference) {
2977
- transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
2973
+ const StyledBox = styledComponents.styled(designSystem.Box)`
2974
+ > div:first-child {
2975
+ box-shadow: ${({ theme }) => theme.shadows.tableShadow};
2978
2976
  }
2979
2977
  `;
2980
- const Component = ({
2981
- disabled,
2982
- index: index$1,
2983
- name: name2,
2984
- mainField = {
2985
- name: "id",
2986
- type: "integer"
2987
- },
2988
- children,
2989
- onDeleteComponent,
2990
- toggleCollapses,
2991
- __temp_key__,
2992
- ...dragProps
2993
- }) => {
2994
- const { formatMessage } = reactIntl.useIntl();
2995
- const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
2996
- return objects.getIn(state.values, [...name2.split("."), mainField.name]);
2997
- });
2998
- const accordionRef = React__namespace.useRef(null);
2999
- const componentKey = name2.split(".").slice(0, -1).join(".");
3000
- const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
3001
- type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
3002
- index: index$1,
3003
- item: {
3004
- index: index$1,
3005
- displayedValue: displayValue
3006
- },
3007
- onStart() {
3008
- toggleCollapses();
3009
- },
3010
- ...dragProps
3011
- });
3012
- React__namespace.useEffect(() => {
3013
- dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
3014
- }, [dragPreviewRef, index$1]);
3015
- const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
3016
- const composedBoxRefs = designSystem.useComposedRefs(
3017
- boxRef,
3018
- dropRef
3019
- );
3020
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview$1, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
3021
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
3022
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: displayValue }),
3023
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Actions, { children: [
3024
- /* @__PURE__ */ jsxRuntime.jsx(
3025
- designSystem.IconButton,
3026
- {
3027
- variant: "ghost",
3028
- onClick: onDeleteComponent,
3029
- label: formatMessage({
3030
- id: index.getTranslation("containers.Edit.delete"),
3031
- defaultMessage: "Delete"
3032
- }),
3033
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
3034
- }
3035
- ),
3036
- /* @__PURE__ */ jsxRuntime.jsx(
3037
- designSystem.IconButton,
3038
- {
3039
- ref: composedAccordionRefs,
3040
- variant: "ghost",
3041
- onClick: (e) => e.stopPropagation(),
3042
- "data-handler-id": handlerId,
3043
- label: formatMessage({
3044
- id: index.getTranslation("components.DragHandle-label"),
3045
- defaultMessage: "Drag"
3046
- }),
3047
- onKeyDown: handleKeyDown,
3048
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
3049
- }
3050
- )
3051
- ] })
3052
- ] }),
3053
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
3054
- designSystem.Flex,
3055
- {
3056
- direction: "column",
3057
- alignItems: "stretch",
3058
- background: "neutral100",
3059
- padding: 6,
3060
- gap: 6,
3061
- children
3062
- }
3063
- ) })
3064
- ] }) });
3065
- };
3066
- const Preview$1 = () => {
3067
- return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
3068
- };
3069
- const StyledSpan = styledComponents.styled(designSystem.Box)`
2978
+ const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
2979
+ border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
2980
+ `;
2981
+ const Rectangle = styledComponents.styled(designSystem.Box)`
2982
+ width: ${({ theme }) => theme.spaces[2]};
2983
+ height: ${({ theme }) => theme.spaces[4]};
2984
+ `;
2985
+ const Preview$1 = styledComponents.styled.span`
3070
2986
  display: block;
2987
+ background-color: ${({ theme }) => theme.colors.primary100};
3071
2988
  outline: 1px dashed ${({ theme }) => theme.colors.primary500};
3072
2989
  outline-offset: -1px;
2990
+ padding: ${({ theme }) => theme.spaces[6]};
3073
2991
  `;
3074
- const ComponentInput = ({
2992
+ const ComponentContainer = styledComponents.styled(designSystem.Box)`
2993
+ list-style: none;
2994
+ padding: 0;
2995
+ margin: 0;
2996
+ `;
2997
+ const DynamicZoneLabel = ({
2998
+ hint,
3075
2999
  label,
3076
- required,
3077
- name: name2,
3078
- attribute,
3079
- disabled,
3080
3000
  labelAction,
3081
- ...props
3082
- }) => {
3083
- const { formatMessage } = reactIntl.useIntl();
3084
- const field = strapiAdmin.useField(name2);
3085
- const showResetComponent = !attribute.repeatable && field.value && !disabled;
3086
- const { components } = index.useDoc();
3087
- const handleInitialisationClick = () => {
3088
- const schema = components[attribute.component];
3089
- const form = createDefaultForm(schema, components);
3090
- const data = transformDocument(schema, components)(form);
3091
- field.onChange(name2, data);
3092
- };
3093
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
3094
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
3095
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
3096
- label,
3097
- attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
3098
- " (",
3099
- Array.isArray(field.value) ? field.value.length : 0,
3100
- ")"
3101
- ] })
3102
- ] }),
3103
- showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
3104
- designSystem.IconButton,
3105
- {
3106
- label: formatMessage({
3107
- id: index.getTranslation("components.reset-entry"),
3108
- defaultMessage: "Reset Entry"
3109
- }),
3110
- variant: "ghost",
3111
- onClick: () => {
3112
- field.onChange(name2, null);
3113
- },
3114
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
3115
- }
3116
- )
3117
- ] }),
3118
- !attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
3119
- !attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
3120
- attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
3121
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
3122
- ] });
3123
- };
3124
- const MemoizedComponentInput = React__namespace.memo(ComponentInput);
3125
- const AddComponentButton = ({
3126
- hasError,
3127
- isDisabled,
3128
- isOpen,
3129
- children,
3130
- onClick
3001
+ name: name2,
3002
+ numberOfComponents = 0,
3003
+ required
3131
3004
  }) => {
3132
- return /* @__PURE__ */ jsxRuntime.jsx(
3133
- StyledButton,
3005
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
3006
+ designSystem.Box,
3134
3007
  {
3135
- type: "button",
3136
- onClick,
3137
- disabled: isDisabled,
3008
+ paddingTop: 3,
3009
+ paddingBottom: 3,
3010
+ paddingRight: 4,
3011
+ paddingLeft: 4,
3012
+ borderRadius: "26px",
3138
3013
  background: "neutral0",
3139
- style: { cursor: isDisabled ? "not-allowed" : "pointer" },
3140
- variant: "tertiary",
3141
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
3142
- /* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
3143
- /* @__PURE__ */ jsxRuntime.jsx(
3144
- AddComponentTitle,
3145
- {
3146
- variant: "pi",
3147
- fontWeight: "bold",
3148
- textColor: hasError && !isOpen ? "danger600" : "neutral500",
3149
- children
3150
- }
3151
- )
3014
+ shadow: "filterShadow",
3015
+ color: "neutral500",
3016
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
3017
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
3018
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
3019
+ label || name2,
3020
+ " "
3021
+ ] }),
3022
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
3023
+ "(",
3024
+ numberOfComponents,
3025
+ ")"
3026
+ ] }),
3027
+ required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
3028
+ labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
3029
+ ] }),
3030
+ hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
3152
3031
  ] })
3153
3032
  }
3154
- );
3033
+ ) });
3155
3034
  };
3156
- const StyledAddIcon = styledComponents.styled(Icons.PlusCircle)`
3157
- height: ${({ theme }) => theme.spaces[6]};
3158
- width: ${({ theme }) => theme.spaces[6]};
3159
- transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
3160
-
3161
- > circle {
3162
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
3163
- }
3164
- > path {
3165
- fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
3035
+ const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
3036
+ "DynamicZone",
3037
+ {
3038
+ isInDynamicZone: false
3166
3039
  }
3167
- `;
3168
- const AddComponentTitle = styledComponents.styled(designSystem.Typography)``;
3169
- const StyledButton = styledComponents.styled(designSystem.Button)`
3170
- border-radius: 26px;
3171
- border-color: ${({ theme }) => theme.colors.neutral150};
3172
- box-shadow: ${({ theme }) => theme.shadows.filterShadow};
3173
- height: 5rem;
3174
-
3175
- &:hover {
3176
- ${AddComponentTitle} {
3177
- color: ${({ theme }) => theme.colors.primary600};
3178
- }
3179
-
3180
- ${StyledAddIcon} {
3181
- > circle {
3182
- fill: ${({ theme }) => theme.colors.primary600};
3183
- }
3184
- > path {
3185
- fill: ${({ theme }) => theme.colors.primary600};
3040
+ );
3041
+ const DynamicZone = ({
3042
+ attribute,
3043
+ disabled: disabledProp,
3044
+ hint,
3045
+ label,
3046
+ labelAction,
3047
+ name: name2,
3048
+ required = false,
3049
+ children
3050
+ }) => {
3051
+ const { max = Infinity, min = -Infinity } = attribute ?? {};
3052
+ const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
3053
+ const [liveText, setLiveText] = React__namespace.useState("");
3054
+ const { components, isLoading } = index.useDoc();
3055
+ const disabled = disabledProp || isLoading;
3056
+ const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
3057
+ "DynamicZone",
3058
+ ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
3059
+ addFieldRow: addFieldRow2,
3060
+ removeFieldRow: removeFieldRow2,
3061
+ moveFieldRow: moveFieldRow2
3062
+ })
3063
+ );
3064
+ const { value = [], error } = strapiAdmin.useField(name2);
3065
+ const dynamicComponentsByCategory = React__namespace.useMemo(() => {
3066
+ return attribute.components.reduce((acc, componentUid) => {
3067
+ const { category, info } = components[componentUid] ?? { info: {} };
3068
+ const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
3069
+ if (!acc[category]) {
3070
+ acc[category] = [];
3186
3071
  }
3072
+ acc[category] = [...acc[category], component];
3073
+ return acc;
3074
+ }, {});
3075
+ }, [attribute.components, components]);
3076
+ const { formatMessage } = reactIntl.useIntl();
3077
+ const { toggleNotification } = strapiAdmin.useNotification();
3078
+ const dynamicDisplayedComponentsLength = value.length;
3079
+ const handleAddComponent = (uid, position) => {
3080
+ setAddComponentIsOpen(false);
3081
+ const schema = components[uid];
3082
+ const form = index.createDefaultForm(schema, components);
3083
+ const transformations = pipe__default.default(index.transformDocument(schema, components), (data2) => ({
3084
+ ...data2,
3085
+ __component: uid
3086
+ }));
3087
+ const data = transformations(form);
3088
+ addFieldRow(name2, data, position);
3089
+ };
3090
+ const handleClickOpenPicker = () => {
3091
+ if (dynamicDisplayedComponentsLength < max) {
3092
+ setAddComponentIsOpen((prev) => !prev);
3093
+ } else {
3094
+ toggleNotification({
3095
+ type: "info",
3096
+ message: formatMessage({
3097
+ id: index.getTranslation("components.notification.info.maximum-requirement")
3098
+ })
3099
+ });
3187
3100
  }
3188
- }
3189
- &:active {
3190
- ${AddComponentTitle} {
3191
- color: ${({ theme }) => theme.colors.primary600};
3101
+ };
3102
+ const handleMoveComponent = (newIndex, currentIndex) => {
3103
+ setLiveText(
3104
+ formatMessage(
3105
+ {
3106
+ id: index.getTranslation("dnd.reorder"),
3107
+ defaultMessage: "{item}, moved. New position in list: {position}."
3108
+ },
3109
+ {
3110
+ item: `${name2}.${currentIndex}`,
3111
+ position: getItemPos(newIndex)
3112
+ }
3113
+ )
3114
+ );
3115
+ moveFieldRow(name2, currentIndex, newIndex);
3116
+ };
3117
+ const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
3118
+ const handleCancel = (index$1) => {
3119
+ setLiveText(
3120
+ formatMessage(
3121
+ {
3122
+ id: index.getTranslation("dnd.cancel-item"),
3123
+ defaultMessage: "{item}, dropped. Re-order cancelled."
3124
+ },
3125
+ {
3126
+ item: `${name2}.${index$1}`
3127
+ }
3128
+ )
3129
+ );
3130
+ };
3131
+ const handleGrabItem = (index$1) => {
3132
+ setLiveText(
3133
+ formatMessage(
3134
+ {
3135
+ id: index.getTranslation("dnd.grab-item"),
3136
+ defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
3137
+ },
3138
+ {
3139
+ item: `${name2}.${index$1}`,
3140
+ position: getItemPos(index$1)
3141
+ }
3142
+ )
3143
+ );
3144
+ };
3145
+ const handleDropItem = (index$1) => {
3146
+ setLiveText(
3147
+ formatMessage(
3148
+ {
3149
+ id: index.getTranslation("dnd.drop-item"),
3150
+ defaultMessage: `{item}, dropped. Final position in list: {position}.`
3151
+ },
3152
+ {
3153
+ item: `${name2}.${index$1}`,
3154
+ position: getItemPos(index$1)
3155
+ }
3156
+ )
3157
+ );
3158
+ };
3159
+ const handleRemoveComponent = (name22, currentIndex) => () => {
3160
+ removeFieldRow(name22, currentIndex);
3161
+ };
3162
+ const hasError = error !== void 0;
3163
+ const renderButtonLabel = () => {
3164
+ if (addComponentIsOpen) {
3165
+ return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
3192
3166
  }
3193
- ${StyledAddIcon} {
3194
- > circle {
3195
- fill: ${({ theme }) => theme.colors.primary600};
3196
- }
3197
- > path {
3198
- fill: ${({ theme }) => theme.colors.neutral100};
3199
- }
3167
+ if (hasError && dynamicDisplayedComponentsLength > max) {
3168
+ return formatMessage(
3169
+ {
3170
+ id: index.getTranslation(`components.DynamicZone.extra-components`),
3171
+ defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
3172
+ },
3173
+ {
3174
+ number: dynamicDisplayedComponentsLength - max
3175
+ }
3176
+ );
3200
3177
  }
3201
- }
3202
- `;
3203
- const ComponentCategory = ({
3204
- category,
3205
- components = [],
3206
- variant = "primary",
3207
- onAddComponent
3208
- }) => {
3209
- const { formatMessage } = reactIntl.useIntl();
3210
- return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: category, children: [
3211
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
3212
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
3213
- ComponentBox,
3178
+ if (hasError && dynamicDisplayedComponentsLength < min) {
3179
+ return formatMessage(
3180
+ {
3181
+ id: index.getTranslation(`components.DynamicZone.missing-components`),
3182
+ defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
3183
+ },
3184
+ { number: min - dynamicDisplayedComponentsLength }
3185
+ );
3186
+ }
3187
+ return formatMessage(
3214
3188
  {
3215
- tag: "button",
3216
- type: "button",
3217
- background: "neutral100",
3218
- justifyContent: "center",
3219
- onClick: onAddComponent(uid),
3220
- hasRadius: true,
3221
- height: "8.4rem",
3222
- shrink: 0,
3223
- borderColor: "neutral200",
3224
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
3225
- /* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
3226
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
3227
- ] })
3189
+ id: index.getTranslation("components.DynamicZone.add-component"),
3190
+ defaultMessage: "Add a component to {componentName}"
3228
3191
  },
3229
- uid
3230
- )) }) })
3231
- ] });
3232
- };
3233
- const Grid = styledComponents.styled(designSystem.Box)`
3234
- display: grid;
3235
- grid-template-columns: repeat(auto-fit, 14rem);
3236
- grid-gap: ${({ theme }) => theme.spaces[1]};
3237
- `;
3238
- const ComponentBox = styledComponents.styled(designSystem.Flex)`
3239
- color: ${({ theme }) => theme.colors.neutral600};
3240
- cursor: pointer;
3241
-
3242
- @media (prefers-reduced-motion: no-preference) {
3243
- transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
3244
- }
3245
-
3246
- &:focus,
3247
- &:hover {
3248
- border: 1px solid ${({ theme }) => theme.colors.primary200};
3249
- background: ${({ theme }) => theme.colors.primary100};
3250
- color: ${({ theme }) => theme.colors.primary600};
3251
- }
3252
- `;
3253
- const ComponentPicker = ({
3254
- dynamicComponentsByCategory = {},
3255
- isOpen,
3256
- onClickAddComponent
3257
- }) => {
3258
- const { formatMessage } = reactIntl.useIntl();
3259
- const handleAddComponentToDz = (componentUid) => () => {
3260
- onClickAddComponent(componentUid);
3192
+ { componentName: label || name2 }
3193
+ );
3261
3194
  };
3262
- if (!isOpen) {
3263
- return null;
3264
- }
3265
- return /* @__PURE__ */ jsxRuntime.jsxs(
3266
- designSystem.Box,
3267
- {
3268
- paddingTop: 6,
3269
- paddingBottom: 6,
3270
- paddingLeft: 5,
3271
- paddingRight: 5,
3272
- background: "neutral0",
3273
- shadow: "tableShadow",
3274
- borderColor: "neutral150",
3275
- hasRadius: true,
3276
- children: [
3277
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
3278
- id: index.getTranslation("components.DynamicZone.ComponentPicker-label"),
3279
- defaultMessage: "Pick one component"
3280
- }) }) }),
3281
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index2) => /* @__PURE__ */ jsxRuntime.jsx(
3282
- ComponentCategory,
3283
- {
3284
- category,
3285
- components,
3286
- onAddComponent: handleAddComponentToDz,
3287
- variant: index2 % 2 === 1 ? "primary" : "secondary"
3288
- },
3289
- category
3290
- )) }) })
3291
- ]
3292
- }
3293
- );
3195
+ const level = Relations.useComponent("DynamicZone", (state) => state.level);
3196
+ const ariaDescriptionId = React__namespace.useId();
3197
+ return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3198
+ dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
3199
+ /* @__PURE__ */ jsxRuntime.jsx(
3200
+ DynamicZoneLabel,
3201
+ {
3202
+ hint,
3203
+ label,
3204
+ labelAction,
3205
+ name: name2,
3206
+ numberOfComponents: dynamicDisplayedComponentsLength,
3207
+ required
3208
+ }
3209
+ ),
3210
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
3211
+ id: index.getTranslation("dnd.instructions"),
3212
+ defaultMessage: `Press spacebar to grab and re-order`
3213
+ }) }),
3214
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
3215
+ /* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
3216
+ Relations.ComponentProvider,
3217
+ {
3218
+ level: level + 1,
3219
+ uid: field.__component,
3220
+ id: field.id,
3221
+ type: "dynamiczone",
3222
+ children: /* @__PURE__ */ jsxRuntime.jsx(
3223
+ DynamicComponent,
3224
+ {
3225
+ disabled,
3226
+ name: name2,
3227
+ index: index2,
3228
+ componentUid: field.__component,
3229
+ onMoveComponent: handleMoveComponent,
3230
+ onRemoveComponentClick: handleRemoveComponent(name2, index2),
3231
+ onCancel: handleCancel,
3232
+ onDropItem: handleDropItem,
3233
+ onGrabItem: handleGrabItem,
3234
+ onAddComponent: handleAddComponent,
3235
+ dynamicComponentsByCategory,
3236
+ children
3237
+ }
3238
+ )
3239
+ },
3240
+ field.__temp_key__
3241
+ )) })
3242
+ ] }),
3243
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
3244
+ AddComponentButton,
3245
+ {
3246
+ hasError,
3247
+ isDisabled: disabled,
3248
+ isOpen: addComponentIsOpen,
3249
+ onClick: handleClickOpenPicker,
3250
+ children: renderButtonLabel()
3251
+ }
3252
+ ) }),
3253
+ /* @__PURE__ */ jsxRuntime.jsx(
3254
+ ComponentPicker,
3255
+ {
3256
+ dynamicComponentsByCategory,
3257
+ isOpen: addComponentIsOpen,
3258
+ onClickAddComponent: handleAddComponent
3259
+ }
3260
+ )
3261
+ ] }) });
3294
3262
  };
3295
3263
  const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
3296
3264
  const { formatMessage } = reactIntl.useIntl();
@@ -3364,7 +3332,7 @@ const UIDInput = React__namespace.forwardRef(
3364
3332
  const [showRegenerate, setShowRegenerate] = React__namespace.useState(false);
3365
3333
  const isCloning = reactRouterDom.useMatch(index.CLONE_PATH) !== null;
3366
3334
  const field = strapiAdmin.useField(name2);
3367
- const debouncedValue = useDebounce.useDebounce(field.value, 300);
3335
+ const debouncedValue = relations.useDebounce(field.value, 300);
3368
3336
  const hasChanged = debouncedValue !== field.initialValue;
3369
3337
  const { toggleNotification } = strapiAdmin.useNotification();
3370
3338
  const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
@@ -3770,8 +3738,7 @@ const Wrapper = styledComponents.styled.div`
3770
3738
  `;
3771
3739
  var listRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, emptyListRE = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, unorderedListRE = /[*+-]\s/;
3772
3740
  function newlineAndIndentContinueMarkdownList(cm) {
3773
- if (cm.getOption("disableInput"))
3774
- return CodeMirror__default.default.Pass;
3741
+ if (cm.getOption("disableInput")) return CodeMirror__default.default.Pass;
3775
3742
  var ranges = cm.listSelections(), replacements = [];
3776
3743
  for (var i = 0; i < ranges.length; i++) {
3777
3744
  var pos = ranges[i].head;
@@ -3805,8 +3772,7 @@ function newlineAndIndentContinueMarkdownList(cm) {
3805
3772
  var numbered = !(unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0);
3806
3773
  var bullet = numbered ? parseInt(match[3], 10) + 1 + match[4] : match[2].replace("x", " ");
3807
3774
  replacements[i] = "\n" + indent + bullet + after;
3808
- if (numbered)
3809
- incrementRemainingMarkdownListNumbers(cm, pos);
3775
+ if (numbered) incrementRemainingMarkdownListNumbers(cm, pos);
3810
3776
  }
3811
3777
  }
3812
3778
  cm.replaceSelections(replacements);
@@ -3824,10 +3790,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3824
3790
  var newNumber = parseInt(startItem[3], 10) + lookAhead - skipCount;
3825
3791
  var nextNumber = parseInt(nextItem[3], 10), itemNumber = nextNumber;
3826
3792
  if (startIndent === nextIndent && !isNaN(nextNumber)) {
3827
- if (newNumber === nextNumber)
3828
- itemNumber = nextNumber + 1;
3829
- if (newNumber > nextNumber)
3830
- itemNumber = newNumber + 1;
3793
+ if (newNumber === nextNumber) itemNumber = nextNumber + 1;
3794
+ if (newNumber > nextNumber) itemNumber = newNumber + 1;
3831
3795
  cm.replaceRange(
3832
3796
  nextLine.replace(listRE, nextIndent + itemNumber + nextItem[4] + nextItem[5]),
3833
3797
  {
@@ -3840,10 +3804,8 @@ function incrementRemainingMarkdownListNumbers(cm, pos) {
3840
3804
  }
3841
3805
  );
3842
3806
  } else {
3843
- if (startIndent.length > nextIndent.length)
3844
- return;
3845
- if (startIndent.length < nextIndent.length && lookAhead === 1)
3846
- return;
3807
+ if (startIndent.length > nextIndent.length) return;
3808
+ if (startIndent.length < nextIndent.length && lookAhead === 1) return;
3847
3809
  skipCount += 1;
3848
3810
  }
3849
3811
  }
@@ -4921,7 +4883,7 @@ const Wysiwyg = React__namespace.forwardRef(
4921
4883
  const handleSelectAssets = (files) => {
4922
4884
  const formattedFiles = files.map((f) => ({
4923
4885
  alt: f.alternativeText || f.name,
4924
- url: useDebounce.prefixFileUrlWithBackendUrl(f.url),
4886
+ url: usePrev.prefixFileUrlWithBackendUrl(f.url),
4925
4887
  mime: f.mime
4926
4888
  }));
4927
4889
  insertFile(editorRef, formattedFiles);
@@ -5025,571 +4987,632 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
5025
4987
  disabled: fieldIsDisabled
5026
4988
  }
5027
4989
  );
5028
- }
5029
- const addedInputTypes = Object.keys(fields);
5030
- if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
5031
- const CustomInput = fields[props.type];
5032
- return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
5033
- }
5034
- switch (props.type) {
5035
- case "blocks":
5036
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5037
- case "component":
5038
- return /* @__PURE__ */ jsxRuntime.jsx(
5039
- MemoizedComponentInput,
4990
+ }
4991
+ const addedInputTypes = Object.keys(fields);
4992
+ if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
4993
+ const CustomInput = fields[props.type];
4994
+ return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
4995
+ }
4996
+ switch (props.type) {
4997
+ case "blocks":
4998
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
4999
+ case "component":
5000
+ return /* @__PURE__ */ jsxRuntime.jsx(
5001
+ MemoizedComponentInput,
5002
+ {
5003
+ ...props,
5004
+ hint,
5005
+ layout: components[props.attribute.component].layout,
5006
+ disabled: fieldIsDisabled,
5007
+ children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
5008
+ }
5009
+ );
5010
+ case "dynamiczone":
5011
+ return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
5012
+ case "relation":
5013
+ return /* @__PURE__ */ jsxRuntime.jsx(Relations.MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
5014
+ case "richtext":
5015
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5016
+ case "uid":
5017
+ return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5018
+ case "enumeration":
5019
+ return /* @__PURE__ */ jsxRuntime.jsx(
5020
+ strapiAdmin.InputRenderer,
5021
+ {
5022
+ ...props,
5023
+ hint,
5024
+ options: props.attribute.enum.map((value) => ({ value })),
5025
+ type: props.customField ? "custom-field" : props.type,
5026
+ disabled: fieldIsDisabled
5027
+ }
5028
+ );
5029
+ default:
5030
+ const { unique: _unique, mainField: _mainField, ...restProps } = props;
5031
+ return /* @__PURE__ */ jsxRuntime.jsx(
5032
+ strapiAdmin.InputRenderer,
5033
+ {
5034
+ ...restProps,
5035
+ hint,
5036
+ type: props.customField ? "custom-field" : props.type,
5037
+ disabled: fieldIsDisabled
5038
+ }
5039
+ );
5040
+ }
5041
+ };
5042
+ const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
5043
+ const useFieldHint = (hint = void 0, attribute) => {
5044
+ const { formatMessage } = reactIntl.useIntl();
5045
+ const { maximum, minimum } = getMinMax(attribute);
5046
+ if (!maximum && !minimum) {
5047
+ return hint;
5048
+ }
5049
+ const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
5050
+ attribute.type
5051
+ ) ? formatMessage(
5052
+ {
5053
+ id: "content-manager.form.Input.hint.character.unit",
5054
+ defaultMessage: "{maxValue, plural, one { character} other { characters}}"
5055
+ },
5056
+ {
5057
+ maxValue: Math.max(minimum || 0, maximum || 0)
5058
+ }
5059
+ ) : null;
5060
+ const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
5061
+ return formatMessage(
5062
+ {
5063
+ id: "content-manager.form.Input.hint.text",
5064
+ defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
5065
+ },
5066
+ {
5067
+ min: minimum,
5068
+ max: maximum,
5069
+ description: hint,
5070
+ unit: units,
5071
+ divider: hasMinAndMax ? formatMessage({
5072
+ id: "content-manager.form.Input.hint.minMaxDivider",
5073
+ defaultMessage: " / "
5074
+ }) : null,
5075
+ br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
5076
+ }
5077
+ );
5078
+ };
5079
+ const getMinMax = (attribute) => {
5080
+ if ("min" in attribute || "max" in attribute) {
5081
+ return {
5082
+ maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
5083
+ minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
5084
+ };
5085
+ } else if ("maxLength" in attribute || "minLength" in attribute) {
5086
+ return { maximum: attribute.maxLength, minimum: attribute.minLength };
5087
+ } else {
5088
+ return { maximum: void 0, minimum: void 0 };
5089
+ }
5090
+ };
5091
+ const MemoizedInputRenderer = React.memo(InputRenderer);
5092
+ const RESPONSIVE_CONTAINER_BREAKPOINTS = {
5093
+ sm: "27.5rem"
5094
+ // 440px
5095
+ };
5096
+ const ResponsiveGridRoot = styledComponents.styled(designSystem.Grid.Root)`
5097
+ container-type: inline-size;
5098
+ `;
5099
+ const ResponsiveGridItem = styledComponents.styled(designSystem.Grid.Item)`
5100
+ grid-column: span 12;
5101
+
5102
+ @container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
5103
+ ${({ col }) => col && `grid-column: span ${col};`}
5104
+ }
5105
+ `;
5106
+ const FormLayout = ({ layout }) => {
5107
+ const { formatMessage } = reactIntl.useIntl();
5108
+ const { model } = index.useDoc();
5109
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index2) => {
5110
+ if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
5111
+ const [row] = panel;
5112
+ const [field] = row;
5113
+ const fieldWithTranslatedLabel = {
5114
+ ...field,
5115
+ label: formatMessage({
5116
+ id: `content-manager.content-types.${model}.${field.name}`,
5117
+ defaultMessage: field.label
5118
+ })
5119
+ };
5120
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, s: 12, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel }) }) }, field.name);
5121
+ }
5122
+ return /* @__PURE__ */ jsxRuntime.jsx(
5123
+ designSystem.Box,
5124
+ {
5125
+ hasRadius: true,
5126
+ background: "neutral0",
5127
+ shadow: "tableShadow",
5128
+ paddingLeft: 6,
5129
+ paddingRight: 6,
5130
+ paddingTop: 6,
5131
+ paddingBottom: 6,
5132
+ borderColor: "neutral150",
5133
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: panel.map((row, gridRowIndex) => /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5134
+ const fieldWithTranslatedLabel = {
5135
+ ...field,
5136
+ label: formatMessage({
5137
+ id: `content-manager.content-types.${model}.${field.name}`,
5138
+ defaultMessage: field.label
5139
+ })
5140
+ };
5141
+ return /* @__PURE__ */ jsxRuntime.jsx(
5142
+ ResponsiveGridItem,
5143
+ {
5144
+ col: size,
5145
+ s: 12,
5146
+ xs: 12,
5147
+ direction: "column",
5148
+ alignItems: "stretch",
5149
+ children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
5150
+ },
5151
+ field.name
5152
+ );
5153
+ }) }, gridRowIndex)) })
5154
+ },
5155
+ index2
5156
+ );
5157
+ }) });
5158
+ };
5159
+ const NonRepeatableComponent = ({
5160
+ attribute,
5161
+ name: name2,
5162
+ children,
5163
+ layout
5164
+ }) => {
5165
+ const { formatMessage } = reactIntl.useIntl();
5166
+ const { value } = strapiAdmin.useField(name2);
5167
+ const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
5168
+ const isNested = level > 0;
5169
+ return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
5170
+ designSystem.Box,
5171
+ {
5172
+ background: "neutral100",
5173
+ paddingLeft: 6,
5174
+ paddingRight: 6,
5175
+ paddingTop: 6,
5176
+ paddingBottom: 6,
5177
+ hasRadius: isNested,
5178
+ borderColor: isNested ? "neutral200" : void 0,
5179
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
5180
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5181
+ const completeFieldName = `${name2}.${field.name}`;
5182
+ const translatedLabel = formatMessage({
5183
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5184
+ defaultMessage: field.label
5185
+ });
5186
+ return /* @__PURE__ */ jsxRuntime.jsx(
5187
+ ResponsiveGridItem,
5188
+ {
5189
+ col: size,
5190
+ s: 12,
5191
+ xs: 12,
5192
+ direction: "column",
5193
+ alignItems: "stretch",
5194
+ children: children({ ...field, label: translatedLabel, name: completeFieldName })
5195
+ },
5196
+ completeFieldName
5197
+ );
5198
+ }) }, index2);
5199
+ }) })
5200
+ }
5201
+ ) });
5202
+ };
5203
+ const RepeatableComponent = ({
5204
+ attribute,
5205
+ disabled,
5206
+ name: name2,
5207
+ mainField,
5208
+ children,
5209
+ layout
5210
+ }) => {
5211
+ const { toggleNotification } = strapiAdmin.useNotification();
5212
+ const { formatMessage } = reactIntl.useIntl();
5213
+ const { search: searchString } = reactRouterDom.useLocation();
5214
+ const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
5215
+ const { components } = index.useDoc();
5216
+ const {
5217
+ value = [],
5218
+ error,
5219
+ rawError
5220
+ } = strapiAdmin.useField(name2);
5221
+ const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
5222
+ const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
5223
+ const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
5224
+ const { max = Infinity } = attribute;
5225
+ const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
5226
+ const [liveText, setLiveText] = React__namespace.useState("");
5227
+ React__namespace.useEffect(() => {
5228
+ const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
5229
+ const hasNestedValue = value && Array.isArray(value) && value.length > 0;
5230
+ if (hasNestedErrors && hasNestedValue) {
5231
+ const errorOpenItems = rawError.map((_, idx) => {
5232
+ return value[idx] ? value[idx].__temp_key__ : null;
5233
+ }).filter((value2) => !!value2);
5234
+ if (errorOpenItems && errorOpenItems.length > 0) {
5235
+ setCollapseToOpen((collapseToOpen2) => {
5236
+ if (!errorOpenItems.includes(collapseToOpen2)) {
5237
+ return errorOpenItems[0];
5238
+ }
5239
+ return collapseToOpen2;
5240
+ });
5241
+ }
5242
+ }
5243
+ }, [rawError, value]);
5244
+ const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
5245
+ if (search.has("field")) {
5246
+ const fieldParam = search.get("field");
5247
+ if (!fieldParam) {
5248
+ return void 0;
5249
+ }
5250
+ const [, path] = fieldParam.split(`${name2}.`);
5251
+ if (objects.getIn(value, path, void 0) !== void 0) {
5252
+ const [subpath] = path.split(".");
5253
+ return objects.getIn(value, subpath, void 0)?.__temp_key__;
5254
+ }
5255
+ }
5256
+ return void 0;
5257
+ }, [search, name2, value]);
5258
+ const prevValue = usePrev.usePrev(value);
5259
+ React__namespace.useEffect(() => {
5260
+ if (prevValue && prevValue.length < value.length) {
5261
+ setCollapseToOpen(value[value.length - 1].__temp_key__);
5262
+ }
5263
+ }, [value, prevValue]);
5264
+ React__namespace.useEffect(() => {
5265
+ if (typeof componentTmpKeyWithFocussedField === "string") {
5266
+ setCollapseToOpen(componentTmpKeyWithFocussedField);
5267
+ }
5268
+ }, [componentTmpKeyWithFocussedField]);
5269
+ const toggleCollapses = () => {
5270
+ setCollapseToOpen("");
5271
+ };
5272
+ const handleClick = () => {
5273
+ if (value.length < max) {
5274
+ const schema = components[attribute.component];
5275
+ const form = index.createDefaultForm(schema, components);
5276
+ const data = index.transformDocument(schema, components)(form);
5277
+ addFieldRow(name2, data);
5278
+ } else if (value.length >= max) {
5279
+ toggleNotification({
5280
+ type: "info",
5281
+ message: formatMessage({
5282
+ id: index.getTranslation("components.notification.info.maximum-requirement")
5283
+ })
5284
+ });
5285
+ }
5286
+ };
5287
+ const handleMoveComponentField = (newIndex, currentIndex) => {
5288
+ setLiveText(
5289
+ formatMessage(
5290
+ {
5291
+ id: index.getTranslation("dnd.reorder"),
5292
+ defaultMessage: "{item}, moved. New position in list: {position}."
5293
+ },
5294
+ {
5295
+ item: `${name2}.${currentIndex}`,
5296
+ position: getItemPos(newIndex)
5297
+ }
5298
+ )
5299
+ );
5300
+ moveFieldRow(name2, currentIndex, newIndex);
5301
+ };
5302
+ const handleValueChange = (key) => {
5303
+ setCollapseToOpen(key);
5304
+ };
5305
+ const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
5306
+ const handleCancel = (index$1) => {
5307
+ setLiveText(
5308
+ formatMessage(
5040
5309
  {
5041
- ...props,
5042
- hint,
5043
- layout: components[props.attribute.component].layout,
5044
- disabled: fieldIsDisabled,
5045
- children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
5310
+ id: index.getTranslation("dnd.cancel-item"),
5311
+ defaultMessage: "{item}, dropped. Re-order cancelled."
5312
+ },
5313
+ {
5314
+ item: `${name2}.${index$1}`
5046
5315
  }
5047
- );
5048
- case "dynamiczone":
5049
- return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
5050
- case "relation":
5051
- return /* @__PURE__ */ jsxRuntime.jsx(Relations.MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
5052
- case "richtext":
5053
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5054
- case "uid":
5055
- return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
5056
- case "enumeration":
5057
- return /* @__PURE__ */ jsxRuntime.jsx(
5058
- strapiAdmin.InputRenderer,
5316
+ )
5317
+ );
5318
+ };
5319
+ const handleGrabItem = (index$1) => {
5320
+ setLiveText(
5321
+ formatMessage(
5059
5322
  {
5060
- ...props,
5061
- hint,
5062
- options: props.attribute.enum.map((value) => ({ value })),
5063
- type: props.customField ? "custom-field" : props.type,
5064
- disabled: fieldIsDisabled
5323
+ id: index.getTranslation("dnd.grab-item"),
5324
+ defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
5325
+ },
5326
+ {
5327
+ item: `${name2}.${index$1}`,
5328
+ position: getItemPos(index$1)
5065
5329
  }
5066
- );
5067
- default:
5068
- const { unique: _unique, mainField: _mainField, ...restProps } = props;
5069
- return /* @__PURE__ */ jsxRuntime.jsx(
5070
- strapiAdmin.InputRenderer,
5330
+ )
5331
+ );
5332
+ };
5333
+ const handleDropItem = (index$1) => {
5334
+ setLiveText(
5335
+ formatMessage(
5071
5336
  {
5072
- ...restProps,
5073
- hint,
5074
- type: props.customField ? "custom-field" : props.type,
5075
- disabled: fieldIsDisabled
5337
+ id: index.getTranslation("dnd.drop-item"),
5338
+ defaultMessage: `{item}, dropped. Final position in list: {position}.`
5339
+ },
5340
+ {
5341
+ item: `${name2}.${index$1}`,
5342
+ position: getItemPos(index$1)
5076
5343
  }
5077
- );
5344
+ )
5345
+ );
5346
+ };
5347
+ const ariaDescriptionId = React__namespace.useId();
5348
+ const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
5349
+ if (value.length === 0) {
5350
+ return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
5078
5351
  }
5352
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
5353
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5354
+ id: index.getTranslation("dnd.instructions"),
5355
+ defaultMessage: `Press spacebar to grab and re-order`
5356
+ }) }),
5357
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5358
+ /* @__PURE__ */ jsxRuntime.jsxs(
5359
+ AccordionRoot,
5360
+ {
5361
+ $error: error,
5362
+ value: collapseToOpen,
5363
+ onValueChange: handleValueChange,
5364
+ "aria-describedby": ariaDescriptionId,
5365
+ children: [
5366
+ value.map(({ __temp_key__: key, id }, index2) => {
5367
+ const nameWithIndex = `${name2}.${index2}`;
5368
+ return /* @__PURE__ */ jsxRuntime.jsx(
5369
+ Relations.ComponentProvider,
5370
+ {
5371
+ id,
5372
+ uid: attribute.component,
5373
+ level: level + 1,
5374
+ type: "repeatable",
5375
+ children: /* @__PURE__ */ jsxRuntime.jsx(
5376
+ Component,
5377
+ {
5378
+ disabled,
5379
+ name: nameWithIndex,
5380
+ attribute,
5381
+ index: index2,
5382
+ mainField,
5383
+ onMoveItem: handleMoveComponentField,
5384
+ onDeleteComponent: () => {
5385
+ removeFieldRow(name2, index2);
5386
+ toggleCollapses();
5387
+ },
5388
+ toggleCollapses,
5389
+ onCancel: handleCancel,
5390
+ onDropItem: handleDropItem,
5391
+ onGrabItem: handleGrabItem,
5392
+ __temp_key__: key,
5393
+ children: layout.map((row, index22) => {
5394
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
5395
+ const completeFieldName = `${nameWithIndex}.${field.name}`;
5396
+ const translatedLabel = formatMessage({
5397
+ id: `content-manager.components.${attribute.component}.${field.name}`,
5398
+ defaultMessage: field.label
5399
+ });
5400
+ return /* @__PURE__ */ jsxRuntime.jsx(
5401
+ ResponsiveGridItem,
5402
+ {
5403
+ col: size,
5404
+ s: 12,
5405
+ xs: 12,
5406
+ direction: "column",
5407
+ alignItems: "stretch",
5408
+ children: children({
5409
+ ...field,
5410
+ label: translatedLabel,
5411
+ name: completeFieldName
5412
+ })
5413
+ },
5414
+ completeFieldName
5415
+ );
5416
+ }) }, index22);
5417
+ })
5418
+ }
5419
+ )
5420
+ },
5421
+ key
5422
+ );
5423
+ }),
5424
+ /* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
5425
+ id: index.getTranslation("containers.EditView.add.new-entry"),
5426
+ defaultMessage: "Add an entry"
5427
+ }) })
5428
+ ]
5429
+ }
5430
+ )
5431
+ ] });
5079
5432
  };
5080
- const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
5081
- const useFieldHint = (hint = void 0, attribute) => {
5082
- const { formatMessage } = reactIntl.useIntl();
5083
- const { maximum, minimum } = getMinMax(attribute);
5084
- if (!maximum && !minimum) {
5085
- return hint;
5086
- }
5087
- const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
5088
- attribute.type
5089
- ) ? formatMessage(
5090
- {
5091
- id: "content-manager.form.Input.hint.character.unit",
5092
- defaultMessage: "{maxValue, plural, one { character} other { characters}}"
5093
- },
5094
- {
5095
- maxValue: Math.max(minimum || 0, maximum || 0)
5096
- }
5097
- ) : null;
5098
- const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
5099
- return formatMessage(
5100
- {
5101
- id: "content-manager.form.Input.hint.text",
5102
- defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
5103
- },
5104
- {
5105
- min: minimum,
5106
- max: maximum,
5107
- description: hint,
5108
- unit: units,
5109
- divider: hasMinAndMax ? formatMessage({
5110
- id: "content-manager.form.Input.hint.minMaxDivider",
5111
- defaultMessage: " / "
5112
- }) : null,
5113
- br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
5433
+ const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
5434
+ border: 1px solid
5435
+ ${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
5436
+ `;
5437
+ const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
5438
+ width: 100%;
5439
+ display: flex;
5440
+ justify-content: center;
5441
+ border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
5442
+ padding-inline: ${(props) => props.theme.spaces[6]};
5443
+ padding-block: ${(props) => props.theme.spaces[3]};
5444
+
5445
+ &:not([disabled]) {
5446
+ cursor: pointer;
5447
+
5448
+ &:hover {
5449
+ background-color: ${(props) => props.theme.colors.primary100};
5114
5450
  }
5115
- );
5116
- };
5117
- const getMinMax = (attribute) => {
5118
- if ("min" in attribute || "max" in attribute) {
5119
- return {
5120
- maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
5121
- minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
5122
- };
5123
- } else if ("maxLength" in attribute || "minLength" in attribute) {
5124
- return { maximum: attribute.maxLength, minimum: attribute.minLength };
5125
- } else {
5126
- return { maximum: void 0, minimum: void 0 };
5127
5451
  }
5128
- };
5129
- const MemoizedInputRenderer = React.memo(InputRenderer);
5130
- const DynamicComponent = ({
5131
- componentUid,
5132
- disabled,
5133
- index: index$1,
5134
- name: name2,
5135
- onRemoveComponentClick,
5136
- onMoveComponent,
5137
- onGrabItem,
5138
- onDropItem,
5139
- onCancel,
5140
- dynamicComponentsByCategory = {},
5141
- onAddComponent
5452
+
5453
+ span {
5454
+ font-weight: 600;
5455
+ font-size: 1.4rem;
5456
+ line-height: 2.4rem;
5457
+ }
5458
+
5459
+ @media (prefers-reduced-motion: no-preference) {
5460
+ transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
5461
+ }
5462
+ `;
5463
+ const Component = ({
5464
+ disabled,
5465
+ index: index$1,
5466
+ name: name2,
5467
+ mainField = {
5468
+ name: "id",
5469
+ type: "integer"
5470
+ },
5471
+ children,
5472
+ onDeleteComponent,
5473
+ toggleCollapses,
5474
+ __temp_key__,
5475
+ ...dragProps
5142
5476
  }) => {
5143
5477
  const { formatMessage } = reactIntl.useIntl();
5144
- const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
5145
- const {
5146
- edit: { components }
5147
- } = index.useDocLayout();
5148
- const title = React__namespace.useMemo(() => {
5149
- const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
5150
- const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
5151
- const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
5152
- const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
5153
- return mainValue;
5154
- }, [componentUid, components, formValues, name2, index$1]);
5155
- const { icon, displayName } = React__namespace.useMemo(() => {
5156
- const [category] = componentUid.split(".");
5157
- const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
5158
- (component) => component.uid === componentUid
5159
- ) ?? { icon: null, displayName: null };
5160
- return { icon: icon2, displayName: displayName2 };
5161
- }, [componentUid, dynamicComponentsByCategory]);
5478
+ const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
5479
+ return objects.getIn(state.values, [...name2.split("."), mainField.name]);
5480
+ });
5481
+ const accordionRef = React__namespace.useRef(null);
5482
+ const componentKey = name2.split(".").slice(0, -1).join(".");
5162
5483
  const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
5163
- type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
5484
+ type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
5164
5485
  index: index$1,
5165
5486
  item: {
5166
5487
  index: index$1,
5167
- displayedValue: `${displayName} ${title}`,
5168
- icon
5488
+ displayedValue: displayValue
5169
5489
  },
5170
- onMoveItem: onMoveComponent,
5171
- onDropItem,
5172
- onGrabItem,
5173
- onCancel
5490
+ onStart() {
5491
+ toggleCollapses();
5492
+ },
5493
+ ...dragProps
5174
5494
  });
5175
5495
  React__namespace.useEffect(() => {
5176
5496
  dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
5177
5497
  }, [dragPreviewRef, index$1]);
5178
- const accordionValue = React__namespace.useId();
5179
- const { value = [], rawError } = strapiAdmin.useField(`${name2}.${index$1}`);
5180
- const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
5181
- React__namespace.useEffect(() => {
5182
- if (rawError && value) {
5183
- setCollapseToOpen(accordionValue);
5184
- }
5185
- }, [rawError, value, accordionValue]);
5186
- const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
5187
- const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5188
- /* @__PURE__ */ jsxRuntime.jsx(
5189
- designSystem.IconButton,
5190
- {
5191
- variant: "ghost",
5192
- label: formatMessage(
5498
+ const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
5499
+ const composedBoxRefs = designSystem.useComposedRefs(
5500
+ boxRef,
5501
+ dropRef
5502
+ );
5503
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
5504
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
5505
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: displayValue }),
5506
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Actions, { children: [
5507
+ /* @__PURE__ */ jsxRuntime.jsx(
5508
+ designSystem.IconButton,
5193
5509
  {
5194
- id: index.getTranslation("components.DynamicZone.delete-label"),
5195
- defaultMessage: "Delete {name}"
5196
- },
5197
- { name: title }
5510
+ variant: "ghost",
5511
+ onClick: onDeleteComponent,
5512
+ label: formatMessage({
5513
+ id: index.getTranslation("containers.Edit.delete"),
5514
+ defaultMessage: "Delete"
5515
+ }),
5516
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5517
+ }
5198
5518
  ),
5199
- onClick: onRemoveComponentClick,
5200
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5201
- }
5202
- ),
5203
- /* @__PURE__ */ jsxRuntime.jsx(
5204
- designSystem.IconButton,
5205
- {
5206
- variant: "ghost",
5207
- onClick: (e) => e.stopPropagation(),
5208
- "data-handler-id": handlerId,
5209
- ref: dragRef,
5210
- label: formatMessage({
5211
- id: index.getTranslation("components.DragHandle-label"),
5212
- defaultMessage: "Drag"
5213
- }),
5214
- onKeyDown: handleKeyDown,
5215
- children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
5216
- }
5217
- ),
5218
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
5219
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
5220
- /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
5221
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: formatMessage({
5222
- id: index.getTranslation("components.DynamicZone.more-actions"),
5223
- defaultMessage: "More actions"
5224
- }) })
5225
- ] }),
5226
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
5227
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
5228
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
5229
- id: index.getTranslation("components.DynamicZone.add-item-above"),
5230
- defaultMessage: "Add component above"
5231
- }) }),
5232
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
5233
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
5234
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
5235
- ] }, category)) })
5236
- ] }),
5237
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
5238
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
5239
- id: index.getTranslation("components.DynamicZone.add-item-below"),
5240
- defaultMessage: "Add component below"
5241
- }) }),
5242
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
5243
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
5244
- components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
5245
- ] }, category)) })
5246
- ] })
5247
- ] })
5248
- ] })
5249
- ] });
5250
- const accordionTitle = title ? `${displayName} ${title}` : displayName;
5251
- return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
5252
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
5253
- /* @__PURE__ */ jsxRuntime.jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: accordionValue, children: [
5254
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
5255
5519
  /* @__PURE__ */ jsxRuntime.jsx(
5256
- designSystem.Accordion.Trigger,
5520
+ designSystem.IconButton,
5257
5521
  {
5258
- icon: icon && ComponentIcon.COMPONENT_ICONS[icon] ? ComponentIcon.COMPONENT_ICONS[icon] : ComponentIcon.COMPONENT_ICONS.dashboard,
5259
- children: accordionTitle
5522
+ ref: composedAccordionRefs,
5523
+ variant: "ghost",
5524
+ onClick: (e) => e.stopPropagation(),
5525
+ "data-handler-id": handlerId,
5526
+ label: formatMessage({
5527
+ id: index.getTranslation("components.DragHandle-label"),
5528
+ defaultMessage: "Drag"
5529
+ }),
5530
+ onKeyDown: handleKeyDown,
5531
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
5260
5532
  }
5261
- ),
5262
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
5263
- ] }),
5264
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsxRuntime.jsx(
5265
- designSystem.Grid.Item,
5266
- {
5267
- col: 12,
5268
- s: 12,
5269
- xs: 12,
5270
- direction: "column",
5271
- alignItems: "stretch",
5272
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
5273
- const fieldName = `${name2}.${index$1}.${field.name}`;
5274
- return /* @__PURE__ */ jsxRuntime.jsx(
5275
- designSystem.Grid.Item,
5276
- {
5277
- col: size,
5278
- s: 12,
5279
- xs: 12,
5280
- direction: "column",
5281
- alignItems: "stretch",
5282
- children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...field, name: fieldName })
5283
- },
5284
- fieldName
5285
- );
5286
- }) })
5287
- },
5288
- rowInd
5289
- )) }) }) }) })
5290
- ] }) }) })
5291
- ] });
5292
- };
5293
- const StyledBox = styledComponents.styled(designSystem.Box)`
5294
- > div:first-child {
5295
- box-shadow: ${({ theme }) => theme.shadows.tableShadow};
5296
- }
5297
- `;
5298
- const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
5299
- border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
5300
- `;
5301
- const Rectangle = styledComponents.styled(designSystem.Box)`
5302
- width: ${({ theme }) => theme.spaces[2]};
5303
- height: ${({ theme }) => theme.spaces[4]};
5304
- `;
5305
- const Preview = styledComponents.styled.span`
5306
- display: block;
5307
- background-color: ${({ theme }) => theme.colors.primary100};
5308
- outline: 1px dashed ${({ theme }) => theme.colors.primary500};
5309
- outline-offset: -1px;
5310
- padding: ${({ theme }) => theme.spaces[6]};
5311
- `;
5312
- const ComponentContainer = styledComponents.styled(designSystem.Box)`
5313
- list-style: none;
5314
- padding: 0;
5315
- margin: 0;
5316
- `;
5317
- const DynamicZoneLabel = ({
5318
- hint,
5319
- label,
5320
- labelAction,
5321
- name: name2,
5322
- numberOfComponents = 0,
5323
- required
5324
- }) => {
5325
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
5326
- designSystem.Box,
5327
- {
5328
- paddingTop: 3,
5329
- paddingBottom: 3,
5330
- paddingRight: 4,
5331
- paddingLeft: 4,
5332
- borderRadius: "26px",
5333
- background: "neutral0",
5334
- shadow: "filterShadow",
5335
- color: "neutral500",
5336
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
5337
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
5338
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
5339
- label || name2,
5340
- " "
5341
- ] }),
5342
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
5343
- "(",
5344
- numberOfComponents,
5345
- ")"
5346
- ] }),
5347
- required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
5348
- labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
5349
- ] }),
5350
- hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
5533
+ )
5351
5534
  ] })
5352
- }
5353
- ) });
5535
+ ] }),
5536
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
5537
+ designSystem.Flex,
5538
+ {
5539
+ direction: "column",
5540
+ alignItems: "stretch",
5541
+ background: "neutral100",
5542
+ padding: 6,
5543
+ gap: 6,
5544
+ children
5545
+ }
5546
+ ) })
5547
+ ] }) });
5548
+ };
5549
+ const Preview = () => {
5550
+ return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
5354
5551
  };
5355
- const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
5356
- "DynamicZone",
5357
- {
5358
- isInDynamicZone: false
5359
- }
5360
- );
5361
- const DynamicZone = ({
5362
- attribute,
5363
- disabled: disabledProp,
5364
- hint,
5552
+ const StyledSpan = styledComponents.styled(designSystem.Box)`
5553
+ display: block;
5554
+ outline: 1px dashed ${({ theme }) => theme.colors.primary500};
5555
+ outline-offset: -1px;
5556
+ `;
5557
+ const ComponentInput = ({
5365
5558
  label,
5366
- labelAction,
5559
+ required,
5367
5560
  name: name2,
5368
- required = false
5561
+ attribute,
5562
+ disabled,
5563
+ labelAction,
5564
+ ...props
5369
5565
  }) => {
5370
- const { max = Infinity, min = -Infinity } = attribute ?? {};
5371
- const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
5372
- const [liveText, setLiveText] = React__namespace.useState("");
5373
- const { components, isLoading } = index.useDoc();
5374
- const disabled = disabledProp || isLoading;
5375
- const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
5376
- "DynamicZone",
5377
- ({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
5378
- addFieldRow: addFieldRow2,
5379
- removeFieldRow: removeFieldRow2,
5380
- moveFieldRow: moveFieldRow2
5381
- })
5382
- );
5383
- const { value = [], error } = strapiAdmin.useField(name2);
5384
- const dynamicComponentsByCategory = React__namespace.useMemo(() => {
5385
- return attribute.components.reduce((acc, componentUid) => {
5386
- const { category, info } = components[componentUid] ?? { info: {} };
5387
- const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
5388
- if (!acc[category]) {
5389
- acc[category] = [];
5390
- }
5391
- acc[category] = [...acc[category], component];
5392
- return acc;
5393
- }, {});
5394
- }, [attribute.components, components]);
5395
5566
  const { formatMessage } = reactIntl.useIntl();
5396
- const { toggleNotification } = strapiAdmin.useNotification();
5397
- const dynamicDisplayedComponentsLength = value.length;
5398
- const handleAddComponent = (uid, position) => {
5399
- setAddComponentIsOpen(false);
5400
- const schema = components[uid];
5401
- const form = createDefaultForm(schema, components);
5402
- const transformations = pipe__default.default(transformDocument(schema, components), (data2) => ({
5403
- ...data2,
5404
- __component: uid
5405
- }));
5406
- const data = transformations(form);
5407
- addFieldRow(name2, data, position);
5408
- };
5409
- const handleClickOpenPicker = () => {
5410
- if (dynamicDisplayedComponentsLength < max) {
5411
- setAddComponentIsOpen((prev) => !prev);
5412
- } else {
5413
- toggleNotification({
5414
- type: "info",
5415
- message: formatMessage({
5416
- id: index.getTranslation("components.notification.info.maximum-requirement")
5417
- })
5418
- });
5419
- }
5420
- };
5421
- const handleMoveComponent = (newIndex, currentIndex) => {
5422
- setLiveText(
5423
- formatMessage(
5424
- {
5425
- id: index.getTranslation("dnd.reorder"),
5426
- defaultMessage: "{item}, moved. New position in list: {position}."
5427
- },
5428
- {
5429
- item: `${name2}.${currentIndex}`,
5430
- position: getItemPos(newIndex)
5431
- }
5432
- )
5433
- );
5434
- moveFieldRow(name2, currentIndex, newIndex);
5435
- };
5436
- const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
5437
- const handleCancel = (index$1) => {
5438
- setLiveText(
5439
- formatMessage(
5440
- {
5441
- id: index.getTranslation("dnd.cancel-item"),
5442
- defaultMessage: "{item}, dropped. Re-order cancelled."
5443
- },
5444
- {
5445
- item: `${name2}.${index$1}`
5446
- }
5447
- )
5448
- );
5449
- };
5450
- const handleGrabItem = (index$1) => {
5451
- setLiveText(
5452
- formatMessage(
5453
- {
5454
- id: index.getTranslation("dnd.grab-item"),
5455
- defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
5456
- },
5457
- {
5458
- item: `${name2}.${index$1}`,
5459
- position: getItemPos(index$1)
5460
- }
5461
- )
5462
- );
5567
+ const field = strapiAdmin.useField(name2);
5568
+ const showResetComponent = !attribute.repeatable && field.value && !disabled;
5569
+ const { components } = index.useDoc();
5570
+ const handleInitialisationClick = () => {
5571
+ const schema = components[attribute.component];
5572
+ const form = index.createDefaultForm(schema, components);
5573
+ const data = index.transformDocument(schema, components)(form);
5574
+ field.onChange(name2, data);
5463
5575
  };
5464
- const handleDropItem = (index$1) => {
5465
- setLiveText(
5466
- formatMessage(
5467
- {
5468
- id: index.getTranslation("dnd.drop-item"),
5469
- defaultMessage: `{item}, dropped. Final position in list: {position}.`
5470
- },
5576
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
5577
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
5578
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
5579
+ label,
5580
+ attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5581
+ " (",
5582
+ Array.isArray(field.value) ? field.value.length : 0,
5583
+ ")"
5584
+ ] })
5585
+ ] }),
5586
+ showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
5587
+ designSystem.IconButton,
5471
5588
  {
5472
- item: `${name2}.${index$1}`,
5473
- position: getItemPos(index$1)
5589
+ label: formatMessage({
5590
+ id: index.getTranslation("components.reset-entry"),
5591
+ defaultMessage: "Reset Entry"
5592
+ }),
5593
+ variant: "ghost",
5594
+ onClick: () => {
5595
+ field.onChange(name2, null);
5596
+ },
5597
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
5474
5598
  }
5475
5599
  )
5476
- );
5477
- };
5478
- const handleRemoveComponent = (name22, currentIndex) => () => {
5479
- removeFieldRow(name22, currentIndex);
5480
- };
5481
- const hasError = error !== void 0;
5482
- const renderButtonLabel = () => {
5483
- if (addComponentIsOpen) {
5484
- return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
5485
- }
5486
- if (hasError && dynamicDisplayedComponentsLength > max) {
5487
- return formatMessage(
5488
- {
5489
- id: index.getTranslation(`components.DynamicZone.extra-components`),
5490
- defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
5491
- },
5492
- {
5493
- number: dynamicDisplayedComponentsLength - max
5494
- }
5495
- );
5496
- }
5497
- if (hasError && dynamicDisplayedComponentsLength < min) {
5498
- return formatMessage(
5499
- {
5500
- id: index.getTranslation(`components.DynamicZone.missing-components`),
5501
- defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
5502
- },
5503
- { number: min - dynamicDisplayedComponentsLength }
5504
- );
5505
- }
5506
- return formatMessage(
5507
- {
5508
- id: index.getTranslation("components.DynamicZone.add-component"),
5509
- defaultMessage: "Add a component to {componentName}"
5510
- },
5511
- { componentName: label || name2 }
5512
- );
5513
- };
5514
- const level = Relations.useComponent("DynamicZone", (state) => state.level);
5515
- const ariaDescriptionId = React__namespace.useId();
5516
- return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
5517
- dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
5518
- /* @__PURE__ */ jsxRuntime.jsx(
5519
- DynamicZoneLabel,
5520
- {
5521
- hint,
5522
- label,
5523
- labelAction,
5524
- name: name2,
5525
- numberOfComponents: dynamicDisplayedComponentsLength,
5526
- required
5527
- }
5528
- ),
5529
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
5530
- id: index.getTranslation("dnd.instructions"),
5531
- defaultMessage: `Press spacebar to grab and re-order`
5532
- }) }),
5533
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
5534
- /* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
5535
- Relations.ComponentProvider,
5536
- {
5537
- level: level + 1,
5538
- uid: field.__component,
5539
- id: field.id,
5540
- type: "dynamiczone",
5541
- children: /* @__PURE__ */ jsxRuntime.jsx(
5542
- DynamicComponent,
5543
- {
5544
- disabled,
5545
- name: name2,
5546
- index: index2,
5547
- componentUid: field.__component,
5548
- onMoveComponent: handleMoveComponent,
5549
- onRemoveComponentClick: handleRemoveComponent(name2, index2),
5550
- onCancel: handleCancel,
5551
- onDropItem: handleDropItem,
5552
- onGrabItem: handleGrabItem,
5553
- onAddComponent: handleAddComponent,
5554
- dynamicComponentsByCategory
5555
- }
5556
- )
5557
- },
5558
- field.__temp_key__
5559
- )) })
5560
5600
  ] }),
5561
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
5562
- AddComponentButton,
5563
- {
5564
- hasError,
5565
- isDisabled: disabled,
5566
- isOpen: addComponentIsOpen,
5567
- onClick: handleClickOpenPicker,
5568
- children: renderButtonLabel()
5569
- }
5570
- ) }),
5571
- /* @__PURE__ */ jsxRuntime.jsx(
5572
- ComponentPicker,
5573
- {
5574
- dynamicComponentsByCategory,
5575
- isOpen: addComponentIsOpen,
5576
- onClickAddComponent: handleAddComponent
5577
- }
5578
- )
5579
- ] }) });
5601
+ !attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
5602
+ !attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
5603
+ attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
5604
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
5605
+ ] });
5580
5606
  };
5607
+ const MemoizedComponentInput = React__namespace.memo(ComponentInput);
5581
5608
  exports.DynamicZone = DynamicZone;
5609
+ exports.FormLayout = FormLayout;
5582
5610
  exports.MemoizedBlocksInput = MemoizedBlocksInput;
5583
5611
  exports.MemoizedComponentInput = MemoizedComponentInput;
5584
- exports.MemoizedInputRenderer = MemoizedInputRenderer;
5585
5612
  exports.MemoizedUIDInput = MemoizedUIDInput;
5586
5613
  exports.MemoizedWysiwyg = MemoizedWysiwyg;
5587
5614
  exports.NotAllowedInput = NotAllowedInput;
5588
- exports.createDefaultForm = createDefaultForm;
5589
- exports.prepareTempKeys = prepareTempKeys;
5590
- exports.removeFieldsThatDontExistOnSchema = removeFieldsThatDontExistOnSchema;
5591
- exports.transformDocument = transformDocument;
5592
5615
  exports.useDynamicZone = useDynamicZone;
5593
5616
  exports.useFieldHint = useFieldHint;
5594
5617
  exports.useLazyComponents = useLazyComponents;
5595
- //# sourceMappingURL=Field-T3F_jdGo.js.map
5618
+ //# sourceMappingURL=Input-CDHKQd7o.js.map