@strapi/content-manager 0.0.0-experimental.f2351bcfa3965c60f063a492da51faa2c636eee8 → 0.0.0-experimental.f49f46a1c17445a39e8af3f63124bcccf73842e6

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/{ComponentConfigurationPage-BlAzljQ6.js → ComponentConfigurationPage-ClKl_TA2.js} +4 -4
  2. package/dist/_chunks/{ComponentConfigurationPage-BlAzljQ6.js.map → ComponentConfigurationPage-ClKl_TA2.js.map} +1 -1
  3. package/dist/_chunks/{ComponentConfigurationPage-Ccwb19Qj.mjs → ComponentConfigurationPage-D3ZWDAHG.mjs} +4 -4
  4. package/dist/_chunks/{ComponentConfigurationPage-Ccwb19Qj.mjs.map → ComponentConfigurationPage-D3ZWDAHG.mjs.map} +1 -1
  5. package/dist/_chunks/{EditConfigurationPage-C19b_9RL.mjs → EditConfigurationPage-BYCBSJxP.mjs} +4 -4
  6. package/dist/_chunks/{EditConfigurationPage-C19b_9RL.mjs.map → EditConfigurationPage-BYCBSJxP.mjs.map} +1 -1
  7. package/dist/_chunks/{EditConfigurationPage-BPoOzhCM.js → EditConfigurationPage-OWez0Kxp.js} +4 -4
  8. package/dist/_chunks/{EditConfigurationPage-BPoOzhCM.js.map → EditConfigurationPage-OWez0Kxp.js.map} +1 -1
  9. package/dist/_chunks/{EditViewPage-nmrHNiJ9.mjs → EditViewPage-5pdbvsO_.mjs} +50 -10
  10. package/dist/_chunks/EditViewPage-5pdbvsO_.mjs.map +1 -0
  11. package/dist/_chunks/{EditViewPage-D9xH8HYD.js → EditViewPage-BEs5iGDi.js} +49 -9
  12. package/dist/_chunks/EditViewPage-BEs5iGDi.js.map +1 -0
  13. package/dist/_chunks/{Field-BB_pHo6D.js → Field-DNHm4wHx.js} +107 -44
  14. package/dist/_chunks/Field-DNHm4wHx.js.map +1 -0
  15. package/dist/_chunks/{Field--kmlJuSb.mjs → Field-DcKuFHYK.mjs} +107 -44
  16. package/dist/_chunks/Field-DcKuFHYK.mjs.map +1 -0
  17. package/dist/_chunks/{Form-CUtOiC4S.mjs → Form-CGwM_-5c.mjs} +3 -3
  18. package/dist/_chunks/Form-CGwM_-5c.mjs.map +1 -0
  19. package/dist/_chunks/{Form-iwbkoaAF.js → Form-CoRxWJOz.js} +3 -3
  20. package/dist/_chunks/Form-CoRxWJOz.js.map +1 -0
  21. package/dist/_chunks/{History-guuZF4lR.js → History-BcUTQrfG.js} +40 -97
  22. package/dist/_chunks/History-BcUTQrfG.js.map +1 -0
  23. package/dist/_chunks/{History-BKR3KyU3.mjs → History-DEvr3Q_V.mjs} +42 -99
  24. package/dist/_chunks/History-DEvr3Q_V.mjs.map +1 -0
  25. package/dist/_chunks/{ListConfigurationPage-Cu26t5sE.js → ListConfigurationPage-BE_Ho7tV.js} +5 -4
  26. package/dist/_chunks/ListConfigurationPage-BE_Ho7tV.js.map +1 -0
  27. package/dist/_chunks/{ListConfigurationPage-B_O3hiLT.mjs → ListConfigurationPage-BM4zZZcM.mjs} +6 -5
  28. package/dist/_chunks/ListConfigurationPage-BM4zZZcM.mjs.map +1 -0
  29. package/dist/_chunks/{ListViewPage-B4sTBfu6.mjs → ListViewPage-BK2mkrql.mjs} +29 -7
  30. package/dist/_chunks/{ListViewPage-B4sTBfu6.mjs.map → ListViewPage-BK2mkrql.mjs.map} +1 -1
  31. package/dist/_chunks/{ListViewPage-DWqqGno8.js → ListViewPage-BkT8Eao0.js} +29 -7
  32. package/dist/_chunks/ListViewPage-BkT8Eao0.js.map +1 -0
  33. package/dist/_chunks/{NoContentTypePage-Daktt4t9.mjs → NoContentTypePage-BvcAutu9.mjs} +2 -2
  34. package/dist/_chunks/{NoContentTypePage-Daktt4t9.mjs.map → NoContentTypePage-BvcAutu9.mjs.map} +1 -1
  35. package/dist/_chunks/{NoContentTypePage-TTkwA8uk.js → NoContentTypePage-C8mtyc4H.js} +2 -2
  36. package/dist/_chunks/{NoContentTypePage-TTkwA8uk.js.map → NoContentTypePage-C8mtyc4H.js.map} +1 -1
  37. package/dist/_chunks/{NoPermissionsPage-D8_k39Q0.js → NoPermissionsPage-B5Y9Y78B.js} +2 -2
  38. package/dist/_chunks/{NoPermissionsPage-D8_k39Q0.js.map → NoPermissionsPage-B5Y9Y78B.js.map} +1 -1
  39. package/dist/_chunks/{NoPermissionsPage-CBUXY2Pt.mjs → NoPermissionsPage-BmbRz7PR.mjs} +2 -2
  40. package/dist/_chunks/{NoPermissionsPage-CBUXY2Pt.mjs.map → NoPermissionsPage-BmbRz7PR.mjs.map} +1 -1
  41. package/dist/_chunks/Preview-BF8ZDYqS.js +286 -0
  42. package/dist/_chunks/Preview-BF8ZDYqS.js.map +1 -0
  43. package/dist/_chunks/Preview-DcexhKJE.mjs +267 -0
  44. package/dist/_chunks/Preview-DcexhKJE.mjs.map +1 -0
  45. package/dist/_chunks/{Relations-DjvmZ_XQ.js → Relations-BKnoK1R0.js} +71 -35
  46. package/dist/_chunks/Relations-BKnoK1R0.js.map +1 -0
  47. package/dist/_chunks/{Relations-HKmXF7eO.mjs → Relations-BjIzc4EK.mjs} +72 -36
  48. package/dist/_chunks/Relations-BjIzc4EK.mjs.map +1 -0
  49. package/dist/_chunks/{en-CPTj6CjC.mjs → en-CfIXaZf9.mjs} +21 -10
  50. package/dist/_chunks/{en-CPTj6CjC.mjs.map → en-CfIXaZf9.mjs.map} +1 -1
  51. package/dist/_chunks/{en-BVzUkPxZ.js → en-DTWPCdTS.js} +21 -10
  52. package/dist/_chunks/{en-BVzUkPxZ.js.map → en-DTWPCdTS.js.map} +1 -1
  53. package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
  54. package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
  55. package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
  56. package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
  57. package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
  58. package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
  59. package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
  60. package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
  61. package/dist/_chunks/{index-CB1AN26E.mjs → index-BW-rXkjn.mjs} +882 -721
  62. package/dist/_chunks/index-BW-rXkjn.mjs.map +1 -0
  63. package/dist/_chunks/{index-jDJgW_Lf.js → index-DOzAG2cq.js} +879 -717
  64. package/dist/_chunks/index-DOzAG2cq.js.map +1 -0
  65. package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
  66. package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
  67. package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
  68. package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
  69. package/dist/_chunks/{layout-BCzDsMgN.mjs → layout-DFVbgjp2.mjs} +3 -3
  70. package/dist/_chunks/{layout-BCzDsMgN.mjs.map → layout-DFVbgjp2.mjs.map} +1 -1
  71. package/dist/_chunks/{layout-D6A3K-ut.js → layout-RC3W2obV.js} +3 -3
  72. package/dist/_chunks/{layout-D6A3K-ut.js.map → layout-RC3W2obV.js.map} +1 -1
  73. package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
  74. package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
  75. package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
  76. package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
  77. package/dist/_chunks/{relations-B5Jnw32V.mjs → relations-Dogh8HWI.mjs} +6 -7
  78. package/dist/_chunks/relations-Dogh8HWI.mjs.map +1 -0
  79. package/dist/_chunks/{relations-C10QoukP.js → relations-zam7-5H7.js} +6 -7
  80. package/dist/_chunks/relations-zam7-5H7.js.map +1 -0
  81. package/dist/admin/index.js +2 -1
  82. package/dist/admin/index.js.map +1 -1
  83. package/dist/admin/index.mjs +4 -3
  84. package/dist/admin/src/exports.d.ts +1 -1
  85. package/dist/admin/src/hooks/useDocument.d.ts +32 -1
  86. package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
  87. package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
  88. package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
  89. package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
  90. package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
  91. package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
  92. package/dist/admin/src/preview/constants.d.ts +1 -0
  93. package/dist/admin/src/preview/index.d.ts +4 -0
  94. package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
  95. package/dist/admin/src/preview/routes.d.ts +3 -0
  96. package/dist/admin/src/preview/services/preview.d.ts +3 -0
  97. package/dist/admin/src/router.d.ts +1 -1
  98. package/dist/server/index.js +374 -160
  99. package/dist/server/index.js.map +1 -1
  100. package/dist/server/index.mjs +374 -160
  101. package/dist/server/index.mjs.map +1 -1
  102. package/dist/server/src/bootstrap.d.ts.map +1 -1
  103. package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
  104. package/dist/server/src/controllers/index.d.ts.map +1 -1
  105. package/dist/server/src/controllers/relations.d.ts.map +1 -1
  106. package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
  107. package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
  108. package/dist/server/src/history/services/history.d.ts.map +1 -1
  109. package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
  110. package/dist/server/src/history/services/utils.d.ts +2 -3
  111. package/dist/server/src/history/services/utils.d.ts.map +1 -1
  112. package/dist/server/src/index.d.ts +4 -4
  113. package/dist/server/src/preview/constants.d.ts +2 -0
  114. package/dist/server/src/preview/constants.d.ts.map +1 -0
  115. package/dist/server/src/preview/controllers/index.d.ts +2 -0
  116. package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
  117. package/dist/server/src/preview/controllers/preview.d.ts +13 -0
  118. package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
  119. package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
  120. package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
  121. package/dist/server/src/preview/index.d.ts +4 -0
  122. package/dist/server/src/preview/index.d.ts.map +1 -0
  123. package/dist/server/src/preview/routes/index.d.ts +8 -0
  124. package/dist/server/src/preview/routes/index.d.ts.map +1 -0
  125. package/dist/server/src/preview/routes/preview.d.ts +4 -0
  126. package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
  127. package/dist/server/src/preview/services/index.d.ts +15 -0
  128. package/dist/server/src/preview/services/index.d.ts.map +1 -0
  129. package/dist/server/src/preview/services/preview-config.d.ts +30 -0
  130. package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
  131. package/dist/server/src/preview/services/preview.d.ts +12 -0
  132. package/dist/server/src/preview/services/preview.d.ts.map +1 -0
  133. package/dist/server/src/preview/utils.d.ts +18 -0
  134. package/dist/server/src/preview/utils.d.ts.map +1 -0
  135. package/dist/server/src/routes/index.d.ts.map +1 -1
  136. package/dist/server/src/services/document-manager.d.ts.map +1 -1
  137. package/dist/server/src/services/document-metadata.d.ts +8 -8
  138. package/dist/server/src/services/document-metadata.d.ts.map +1 -1
  139. package/dist/server/src/services/index.d.ts +4 -4
  140. package/dist/server/src/services/index.d.ts.map +1 -1
  141. package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
  142. package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
  143. package/dist/server/src/utils/index.d.ts +2 -0
  144. package/dist/server/src/utils/index.d.ts.map +1 -1
  145. package/dist/shared/contracts/index.d.ts +1 -0
  146. package/dist/shared/contracts/index.d.ts.map +1 -1
  147. package/dist/shared/contracts/preview.d.ts +27 -0
  148. package/dist/shared/contracts/preview.d.ts.map +1 -0
  149. package/dist/shared/index.js +4 -0
  150. package/dist/shared/index.js.map +1 -1
  151. package/dist/shared/index.mjs +4 -0
  152. package/dist/shared/index.mjs.map +1 -1
  153. package/package.json +13 -13
  154. package/dist/_chunks/EditViewPage-D9xH8HYD.js.map +0 -1
  155. package/dist/_chunks/EditViewPage-nmrHNiJ9.mjs.map +0 -1
  156. package/dist/_chunks/Field--kmlJuSb.mjs.map +0 -1
  157. package/dist/_chunks/Field-BB_pHo6D.js.map +0 -1
  158. package/dist/_chunks/Form-CUtOiC4S.mjs.map +0 -1
  159. package/dist/_chunks/Form-iwbkoaAF.js.map +0 -1
  160. package/dist/_chunks/History-BKR3KyU3.mjs.map +0 -1
  161. package/dist/_chunks/History-guuZF4lR.js.map +0 -1
  162. package/dist/_chunks/ListConfigurationPage-B_O3hiLT.mjs.map +0 -1
  163. package/dist/_chunks/ListConfigurationPage-Cu26t5sE.js.map +0 -1
  164. package/dist/_chunks/ListViewPage-DWqqGno8.js.map +0 -1
  165. package/dist/_chunks/Relations-DjvmZ_XQ.js.map +0 -1
  166. package/dist/_chunks/Relations-HKmXF7eO.mjs.map +0 -1
  167. package/dist/_chunks/index-CB1AN26E.mjs.map +0 -1
  168. package/dist/_chunks/index-jDJgW_Lf.js.map +0 -1
  169. package/dist/_chunks/relations-B5Jnw32V.mjs.map +0 -1
  170. package/dist/_chunks/relations-C10QoukP.js.map +0 -1
  171. package/strapi-server.js +0 -3
@@ -7,8 +7,8 @@ const designSystem = require("@strapi/design-system");
7
7
  const reactIntl = require("react-intl");
8
8
  const reactRouterDom = require("react-router-dom");
9
9
  const styledComponents = require("styled-components");
10
- const index = require("./index-jDJgW_Lf.js");
11
- const Field = require("./Field-BB_pHo6D.js");
10
+ const index = require("./index-DOzAG2cq.js");
11
+ const Field = require("./Field-DNHm4wHx.js");
12
12
  function _interopNamespace(e) {
13
13
  if (e && e.__esModule)
14
14
  return e;
@@ -31,11 +31,20 @@ const React__namespace = /* @__PURE__ */ _interopNamespace(React);
31
31
  const useOnce = (effect) => React__namespace.useEffect(effect, emptyDeps);
32
32
  const emptyDeps = [];
33
33
  const FormLayout = ({ layout }) => {
34
+ const { formatMessage } = reactIntl.useIntl();
35
+ const { model } = index.useDoc();
34
36
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index2) => {
35
37
  if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
36
38
  const [row] = panel;
37
39
  const [field] = row;
38
- 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(Field.MemoizedInputRenderer, { ...field }) }) }, field.name);
40
+ const fieldWithTranslatedLabel = {
41
+ ...field,
42
+ label: formatMessage({
43
+ id: `content-manager.content-types.${model}.${field.name}`,
44
+ defaultMessage: field.label
45
+ })
46
+ };
47
+ 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(Field.MemoizedInputRenderer, { ...fieldWithTranslatedLabel }) }) }, field.name);
39
48
  }
40
49
  return /* @__PURE__ */ jsxRuntime.jsx(
41
50
  designSystem.Box,
@@ -49,6 +58,13 @@ const FormLayout = ({ layout }) => {
49
58
  paddingBottom: 6,
50
59
  borderColor: "neutral150",
51
60
  children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: panel.map((row, gridRowIndex) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
61
+ const fieldWithTranslatedLabel = {
62
+ ...field,
63
+ label: formatMessage({
64
+ id: `content-manager.content-types.${model}.${field.name}`,
65
+ defaultMessage: field.label
66
+ })
67
+ };
52
68
  return /* @__PURE__ */ jsxRuntime.jsx(
53
69
  designSystem.Grid.Item,
54
70
  {
@@ -57,7 +73,7 @@ const FormLayout = ({ layout }) => {
57
73
  xs: 12,
58
74
  direction: "column",
59
75
  alignItems: "stretch",
60
- children: /* @__PURE__ */ jsxRuntime.jsx(Field.MemoizedInputRenderer, { ...field })
76
+ children: /* @__PURE__ */ jsxRuntime.jsx(Field.MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
61
77
  },
62
78
  field.name
63
79
  );
@@ -87,7 +103,8 @@ const EditViewPage = () => {
87
103
  components,
88
104
  collectionType,
89
105
  id,
90
- model
106
+ model,
107
+ hasError
91
108
  } = index.useDoc();
92
109
  const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;
93
110
  useOnce(() => {
@@ -118,6 +135,9 @@ const EditViewPage = () => {
118
135
  const form = document?.id ? document : Field.createDefaultForm(schema, components);
119
136
  return Field.transformDocument(schema, components)(form);
120
137
  }, [document, isCreatingDocument, isSingleType, schema, components]);
138
+ if (hasError) {
139
+ return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Error, {});
140
+ }
121
141
  if (isLoading && !document?.documentId) {
122
142
  return /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Loading, {});
123
143
  }
@@ -129,16 +149,35 @@ const EditViewPage = () => {
129
149
  setQuery({ status: status2 }, "push", true);
130
150
  }
131
151
  };
132
- const documentTitle = mainField !== "id" && document?.[mainField] ? document[mainField] : "Untitled";
152
+ let documentTitle = "Untitled";
153
+ if (mainField !== "id" && document?.[mainField]) {
154
+ documentTitle = document[mainField];
155
+ } else if (isSingleType && schema?.info.displayName) {
156
+ documentTitle = schema.info.displayName;
157
+ }
158
+ const validateSync = (values, options) => {
159
+ const yupSchema = index.createYupSchema(schema?.attributes, components, {
160
+ status,
161
+ ...options
162
+ });
163
+ return yupSchema.validateSync(values, { abortEarly: false });
164
+ };
133
165
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { paddingLeft: 10, paddingRight: 10, children: [
134
- /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Title, { children: `${documentTitle}` }),
166
+ /* @__PURE__ */ jsxRuntime.jsx(strapiAdmin.Page.Title, { children: documentTitle }),
135
167
  /* @__PURE__ */ jsxRuntime.jsx(
136
168
  strapiAdmin.Form,
137
169
  {
138
170
  disabled: hasDraftAndPublished && status === "published",
139
171
  initialValues,
140
172
  method: isCreatingDocument ? "POST" : "PUT",
141
- validationSchema: index.createYupSchema(schema?.attributes, components, { status }),
173
+ validate: (values, options) => {
174
+ const yupSchema = index.createYupSchema(schema?.attributes, components, {
175
+ status,
176
+ ...options
177
+ });
178
+ return yupSchema.validate(values, { abortEarly: false });
179
+ },
180
+ initialErrors: location?.state?.forceValidation ? validateSync(initialValues, {}) : {},
142
181
  children: ({ resetForm }) => /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
143
182
  /* @__PURE__ */ jsxRuntime.jsx(
144
183
  index.Header,
@@ -230,4 +269,5 @@ const ProtectedEditViewPage = () => {
230
269
  };
231
270
  exports.EditViewPage = EditViewPage;
232
271
  exports.ProtectedEditViewPage = ProtectedEditViewPage;
233
- //# sourceMappingURL=EditViewPage-D9xH8HYD.js.map
272
+ exports.getDocumentStatus = getDocumentStatus;
273
+ //# sourceMappingURL=EditViewPage-BEs5iGDi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditViewPage-BEs5iGDi.js","sources":["../../admin/src/hooks/useOnce.ts","../../admin/src/pages/EditView/components/FormLayout.tsx","../../admin/src/pages/EditView/EditViewPage.tsx"],"sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport * as React from 'react';\n\nexport const useOnce = (effect: React.EffectCallback) => React.useEffect(effect, emptyDeps);\n\nconst emptyDeps: React.DependencyList = [];\n","import { Box, Flex, Grid } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useDoc } from '../../../hooks/useDocument';\nimport { EditLayout } from '../../../hooks/useDocumentLayout';\n\nimport { InputRenderer } from './InputRenderer';\n\ninterface FormLayoutProps extends Pick<EditLayout, 'layout'> {}\n\nconst FormLayout = ({ layout }: FormLayoutProps) => {\n const { formatMessage } = useIntl();\n const { model } = useDoc();\n\n return (\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((panel, index) => {\n if (panel.some((row) => row.some((field) => field.type === 'dynamiczone'))) {\n const [row] = panel;\n const [field] = row;\n\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.content-types.${model}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n\n return (\n <Grid.Root key={field.name} gap={4}>\n <Grid.Item col={12} s={12} xs={12} direction=\"column\" alignItems=\"stretch\">\n <InputRenderer {...fieldWithTranslatedLabel} />\n </Grid.Item>\n </Grid.Root>\n );\n }\n\n return (\n <Box\n key={index}\n hasRadius\n background=\"neutral0\"\n shadow=\"tableShadow\"\n paddingLeft={6}\n paddingRight={6}\n paddingTop={6}\n paddingBottom={6}\n borderColor=\"neutral150\"\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {panel.map((row, gridRowIndex) => (\n <Grid.Root key={gridRowIndex} gap={4}>\n {row.map(({ size, ...field }) => {\n const fieldWithTranslatedLabel = {\n ...field,\n label: formatMessage({\n id: `content-manager.content-types.${model}.${field.name}`,\n defaultMessage: field.label,\n }),\n };\n return (\n <Grid.Item\n col={size}\n key={field.name}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n <InputRenderer {...fieldWithTranslatedLabel} />\n </Grid.Item>\n );\n })}\n </Grid.Root>\n ))}\n </Flex>\n </Box>\n );\n })}\n </Flex>\n );\n};\n\nexport { FormLayout, FormLayoutProps };\n","import * as React from 'react';\n\nimport {\n Page,\n Blocker,\n Form,\n useRBAC,\n useNotification,\n useQueryParams,\n} from '@strapi/admin/strapi-admin';\nimport { Grid, Main, Tabs } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\nimport { useLocation, useParams } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { SINGLE_TYPES } from '../../constants/collections';\nimport { PERMISSIONS } from '../../constants/plugin';\nimport { DocumentRBAC, useDocumentRBAC } from '../../features/DocumentRBAC';\nimport { type UseDocument, useDoc } from '../../hooks/useDocument';\nimport { useDocumentLayout } from '../../hooks/useDocumentLayout';\nimport { useLazyComponents } from '../../hooks/useLazyComponents';\nimport { useOnce } from '../../hooks/useOnce';\nimport { getTranslation } from '../../utils/translations';\nimport { createYupSchema } from '../../utils/validation';\n\nimport { FormLayout } from './components/FormLayout';\nimport { Header } from './components/Header';\nimport { Panels } from './components/Panels';\nimport { transformDocument } from './utils/data';\nimport { createDefaultForm } from './utils/forms';\n\n/* -------------------------------------------------------------------------------------------------\n * EditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditViewPage = () => {\n const location = useLocation();\n const [\n {\n query: { status },\n },\n setQuery,\n ] = useQueryParams<{ status: 'draft' | 'published' }>({\n status: 'draft',\n });\n const { formatMessage } = useIntl();\n const { toggleNotification } = useNotification();\n\n const {\n document,\n meta,\n isLoading: isLoadingDocument,\n schema,\n components,\n collectionType,\n id,\n model,\n hasError,\n } = useDoc();\n\n const hasDraftAndPublished = schema?.options?.draftAndPublish ?? false;\n\n useOnce(() => {\n /**\n * We only ever want to fire the notification once otherwise\n * whenever the app re-renders it'll pop up regardless of\n * what we do because the state comes from react-router-dom\n */\n if (location?.state && 'error' in location.state) {\n toggleNotification({\n type: 'danger',\n message: location.state.error,\n timeout: 5000,\n });\n }\n });\n\n const isLoadingActionsRBAC = useDocumentRBAC('EditViewPage', (state) => state.isLoading);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n\n /**\n * single-types don't current have an id, but because they're a singleton\n * we can simply use the update operation to continuously update the same\n * document with varying params.\n */\n const isCreatingDocument = !id && !isSingleType;\n\n const {\n isLoading: isLoadingLayout,\n edit: {\n layout,\n settings: { mainField },\n },\n } = useDocumentLayout(model);\n\n const { isLazyLoading } = useLazyComponents([]);\n\n const isLoading = isLoadingActionsRBAC || isLoadingDocument || isLoadingLayout || isLazyLoading;\n\n /**\n * Here we prepare the form for editing, we need to:\n * - remove prohibited fields from the document (passwords | ADD YOURS WHEN THERES A NEW ONE)\n * - swap out count objects on relations for empty arrays\n * - set __temp_key__ on array objects for drag & drop\n *\n * We also prepare the form for new documents, so we need to:\n * - set default values on fields\n */\n const initialValues = React.useMemo(() => {\n if ((!document && !isCreatingDocument && !isSingleType) || !schema) {\n return undefined;\n }\n\n /**\n * Check that we have an ID so we know the\n * document has been created in some way.\n */\n const form = document?.id ? document : createDefaultForm(schema, components);\n\n return transformDocument(schema, components)(form);\n }, [document, isCreatingDocument, isSingleType, schema, components]);\n\n if (hasError) {\n return <Page.Error />;\n }\n\n if (isLoading && !document?.documentId) {\n return <Page.Loading />;\n }\n\n if (!initialValues) {\n return <Page.Error />;\n }\n\n const handleTabChange = (status: string) => {\n if (status === 'published' || status === 'draft') {\n setQuery({ status }, 'push', true);\n }\n };\n\n /**\n * We look to see what the mainField is from the configuration, if it's an id\n * we don't use it because it's a uuid format and not very user friendly.\n * Instead, we display the schema name for single-type documents\n * or \"Untitled\".\n */\n let documentTitle = 'Untitled';\n if (mainField !== 'id' && document?.[mainField]) {\n documentTitle = document[mainField];\n } else if (isSingleType && schema?.info.displayName) {\n documentTitle = schema.info.displayName;\n }\n\n const validateSync = (values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validateSync(values, { abortEarly: false });\n };\n\n return (\n <Main paddingLeft={10} paddingRight={10}>\n <Page.Title>{documentTitle}</Page.Title>\n <Form\n disabled={hasDraftAndPublished && status === 'published'}\n initialValues={initialValues}\n method={isCreatingDocument ? 'POST' : 'PUT'}\n validate={(values: Record<string, unknown>, options: Record<string, string>) => {\n const yupSchema = createYupSchema(schema?.attributes, components, {\n status,\n ...options,\n });\n\n return yupSchema.validate(values, { abortEarly: false });\n }}\n initialErrors={location?.state?.forceValidation ? validateSync(initialValues, {}) : {}}\n >\n {({ resetForm }) => (\n <>\n <Header\n isCreating={isCreatingDocument}\n status={hasDraftAndPublished ? getDocumentStatus(document, meta) : undefined}\n title={documentTitle}\n />\n <Tabs.Root variant=\"simple\" value={status} onValueChange={handleTabChange}>\n <Tabs.List\n aria-label={formatMessage({\n id: getTranslation('containers.edit.tabs.label'),\n defaultMessage: 'Document status',\n })}\n >\n {hasDraftAndPublished ? (\n <>\n <StatusTab value=\"draft\">\n {formatMessage({\n id: getTranslation('containers.edit.tabs.draft'),\n defaultMessage: 'draft',\n })}\n </StatusTab>\n <StatusTab\n disabled={!meta || meta.availableStatus.length === 0}\n value=\"published\"\n >\n {formatMessage({\n id: getTranslation('containers.edit.tabs.published'),\n defaultMessage: 'published',\n })}\n </StatusTab>\n </>\n ) : null}\n </Tabs.List>\n <Grid.Root paddingTop={8} gap={4}>\n <Grid.Item col={9} s={12} direction=\"column\" alignItems=\"stretch\">\n <Tabs.Content value=\"draft\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n <Tabs.Content value=\"published\">\n <FormLayout layout={layout} />\n </Tabs.Content>\n </Grid.Item>\n <Grid.Item col={3} s={12} direction=\"column\" alignItems=\"stretch\">\n <Panels />\n </Grid.Item>\n </Grid.Root>\n </Tabs.Root>\n <Blocker\n // We reset the form to the published version to avoid errors like – https://strapi-inc.atlassian.net/browse/CONTENT-2284\n onProceed={resetForm}\n />\n </>\n )}\n </Form>\n </Main>\n );\n};\n\nconst StatusTab = styled(Tabs.Trigger)`\n text-transform: uppercase;\n`;\n\n/**\n * @internal\n * @description Returns the status of the document where its latest state takes priority,\n * this typically will be \"published\" unless a user has edited their draft in which we should\n * display \"modified\".\n */\nconst getDocumentStatus = (\n document: ReturnType<UseDocument>['document'],\n meta: ReturnType<UseDocument>['meta']\n): 'draft' | 'published' | 'modified' => {\n const docStatus = document?.status;\n const statuses = meta?.availableStatus ?? [];\n\n /**\n * Creating an entry\n */\n if (!docStatus) {\n return 'draft';\n }\n\n /**\n * We're viewing a draft, but the document could have a published version\n */\n if (docStatus === 'draft' && statuses.find((doc) => doc.publishedAt !== null)) {\n return 'published';\n }\n\n return docStatus;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * ProtectedEditViewPage\n * -----------------------------------------------------------------------------------------------*/\n\nconst ProtectedEditViewPage = () => {\n const { slug = '' } = useParams<{\n slug: string;\n }>();\n const {\n permissions = [],\n isLoading,\n error,\n } = useRBAC(\n PERMISSIONS.map((action) => ({\n action,\n subject: slug,\n }))\n );\n\n if (isLoading) {\n return <Page.Loading />;\n }\n\n if (error || !slug) {\n return <Page.Error />;\n }\n\n return (\n <Page.Protect permissions={permissions}>\n {({ permissions }) => (\n <DocumentRBAC permissions={permissions}>\n <EditViewPage />\n </DocumentRBAC>\n )}\n </Page.Protect>\n );\n};\n\nexport { EditViewPage, ProtectedEditViewPage, getDocumentStatus };\n"],"names":["React","useIntl","useDoc","jsx","Flex","index","Grid","InputRenderer","Box","useLocation","useQueryParams","useNotification","useDocumentRBAC","SINGLE_TYPES","useDocumentLayout","useLazyComponents","createDefaultForm","transformDocument","Page","status","createYupSchema","jsxs","Main","Form","Fragment","Header","Tabs","getTranslation","Panels","Blocker","styled","useParams","useRBAC","PERMISSIONS","permissions","DocumentRBAC"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,UAAU,CAAC,WAAiCA,iBAAM,UAAU,QAAQ,SAAS;AAE1F,MAAM,YAAkC,CAAC;ACKzC,MAAM,aAAa,CAAC,EAAE,aAA8B;AAC5C,QAAA,EAAE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AAAA,EACF,EAAA,CAAA;AAEJ;AAEA,MAAM,YAAYC,iBAAO,OAAAJ,kBAAK,OAAO;AAAA;AAAA;AAU/B,MAAA,oBAAoB,CACxB,UACA,SACuC;AACvC,QAAM,YAAY,UAAU;AACtB,QAAA,WAAW,MAAM,mBAAmB;AAK1C,MAAI,CAAC,WAAW;AACP,WAAA;AAAA,EACT;AAKI,MAAA,cAAc,WAAW,SAAS,KAAK,CAAC,QAAQ,IAAI,gBAAgB,IAAI,GAAG;AACtE,WAAA;AAAA,EACT;AAEO,SAAA;AACT;AAMA,MAAM,wBAAwB,MAAM;AAClC,QAAM,EAAE,OAAO,GAAG,IAAIK,eAEnB,UAAA;AACG,QAAA;AAAA,IACJ,cAAc,CAAC;AAAA,IACf;AAAA,IACA;AAAA,EAAA,IACEC,YAAA;AAAA,IACFC,kBAAY,IAAI,CAAC,YAAY;AAAA,MAC3B;AAAA,MACA,SAAS;AAAA,IAAA,EACT;AAAA,EAAA;AAGJ,MAAI,WAAW;AACN,WAAA9B,+BAACe,YAAAA,KAAK,SAAL,CAAa,CAAA;AAAA,EACvB;AAEI,MAAA,SAAS,CAAC,MAAM;AACX,WAAAf,+BAACe,YAAAA,KAAK,OAAL,CAAW,CAAA;AAAA,EACrB;AAEA,wCACGA,iBAAK,SAAL,EAAa,aACX,WAAC,EAAE,aAAAgB,kDACDC,MAAAA,cAAa,EAAA,aAAaD,cACzB,UAAC/B,2BAAAA,IAAA,cAAA,CAAa,CAAA,GAChB,EAEJ,CAAA;AAEJ;;;;"}
@@ -5,15 +5,15 @@ const strapiAdmin = require("@strapi/admin/strapi-admin");
5
5
  const designSystem = require("@strapi/design-system");
6
6
  const pipe$1 = require("lodash/fp/pipe");
7
7
  const reactIntl = require("react-intl");
8
- const index = require("./index-jDJgW_Lf.js");
8
+ const index = require("./index-DOzAG2cq.js");
9
9
  const fractionalIndexing = require("fractional-indexing");
10
- const Relations = require("./Relations-DjvmZ_XQ.js");
10
+ const Relations = require("./Relations-BKnoK1R0.js");
11
11
  const Icons = require("@strapi/icons");
12
12
  const styledComponents = require("styled-components");
13
13
  const ComponentIcon = require("./ComponentIcon-BXdiCGQp.js");
14
14
  const reactDndHtml5Backend = require("react-dnd-html5-backend");
15
15
  const useDragAndDrop = require("./useDragAndDrop-J0TUUbR6.js");
16
- const objects = require("./objects-gigeqt7s.js");
16
+ const objects = require("./objects-BcXOv6_9.js");
17
17
  const slate = require("slate");
18
18
  const slateHistory = require("slate-history");
19
19
  const slateReact = require("slate-react");
@@ -2658,7 +2658,7 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
2658
2658
  designSystem.Box,
2659
2659
  {
2660
2660
  tag: "button",
2661
- background: "neutral100",
2661
+ background: disabled ? "neutral150" : "neutral100",
2662
2662
  borderColor: field.error ? "danger600" : "neutral200",
2663
2663
  hasRadius: true,
2664
2664
  disabled,
@@ -2666,32 +2666,32 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
2666
2666
  paddingTop: 9,
2667
2667
  paddingBottom: 9,
2668
2668
  type: "button",
2669
+ style: { cursor: disabled ? "not-allowed" : "pointer" },
2669
2670
  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 on the button below to add one."
2674
- }) }) })
2671
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsxRuntime.jsx(Icons.PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
2672
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
2673
+ designSystem.Typography,
2674
+ {
2675
+ textColor: disabled ? "neutral600" : "primary600",
2676
+ variant: "pi",
2677
+ fontWeight: "bold",
2678
+ children: formatMessage({
2679
+ id: index.getTranslation("components.empty-repeatable"),
2680
+ defaultMessage: "No entry yet. Click to add one."
2681
+ })
2682
+ }
2683
+ ) })
2675
2684
  ] })
2676
2685
  }
2677
2686
  ) });
2678
2687
  };
2679
- const CircleIcon = styledComponents.styled(Icons.PlusCircle)`
2680
- width: 2.4rem;
2681
- height: 2.4rem;
2682
- > circle {
2683
- fill: ${({ theme }) => theme.colors.primary200};
2684
- }
2685
- > path {
2686
- fill: ${({ theme }) => theme.colors.primary600};
2687
- }
2688
- `;
2689
2688
  const NonRepeatableComponent = ({
2690
2689
  attribute,
2691
2690
  name: name2,
2692
2691
  children,
2693
2692
  layout
2694
2693
  }) => {
2694
+ const { formatMessage } = reactIntl.useIntl();
2695
2695
  const { value } = strapiAdmin.useField(name2);
2696
2696
  const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
2697
2697
  const isNested = level > 0;
@@ -2708,6 +2708,10 @@ const NonRepeatableComponent = ({
2708
2708
  children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
2709
2709
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2710
2710
  const completeFieldName = `${name2}.${field.name}`;
2711
+ const translatedLabel = formatMessage({
2712
+ id: `content-manager.components.${attribute.component}.${field.name}`,
2713
+ defaultMessage: field.label
2714
+ });
2711
2715
  return /* @__PURE__ */ jsxRuntime.jsx(
2712
2716
  designSystem.Grid.Item,
2713
2717
  {
@@ -2716,7 +2720,7 @@ const NonRepeatableComponent = ({
2716
2720
  xs: 12,
2717
2721
  direction: "column",
2718
2722
  alignItems: "stretch",
2719
- children: children({ ...field, name: completeFieldName })
2723
+ children: children({ ...field, label: translatedLabel, name: completeFieldName })
2720
2724
  },
2721
2725
  completeFieldName
2722
2726
  );
@@ -2738,13 +2742,34 @@ const RepeatableComponent = ({
2738
2742
  const { search: searchString } = reactRouterDom.useLocation();
2739
2743
  const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
2740
2744
  const { components } = index.useDoc();
2741
- const { value = [], error } = strapiAdmin.useField(name2);
2745
+ const {
2746
+ value = [],
2747
+ error,
2748
+ rawError
2749
+ } = strapiAdmin.useField(name2);
2742
2750
  const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
2743
2751
  const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
2744
2752
  const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
2745
2753
  const { max = Infinity } = attribute;
2746
2754
  const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
2747
2755
  const [liveText, setLiveText] = React__namespace.useState("");
2756
+ React__namespace.useEffect(() => {
2757
+ const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
2758
+ const hasNestedValue = value && Array.isArray(value) && value.length > 0;
2759
+ if (hasNestedErrors && hasNestedValue) {
2760
+ const errorOpenItems = rawError.map((_, idx) => {
2761
+ return value[idx] ? value[idx].__temp_key__ : null;
2762
+ }).filter((value2) => !!value2);
2763
+ if (errorOpenItems && errorOpenItems.length > 0) {
2764
+ setCollapseToOpen((collapseToOpen2) => {
2765
+ if (!errorOpenItems.includes(collapseToOpen2)) {
2766
+ return errorOpenItems[0];
2767
+ }
2768
+ return collapseToOpen2;
2769
+ });
2770
+ }
2771
+ }
2772
+ }, [rawError, value]);
2748
2773
  const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
2749
2774
  if (search.has("field")) {
2750
2775
  const fieldParam = search.get("field");
@@ -2897,6 +2922,10 @@ const RepeatableComponent = ({
2897
2922
  children: layout.map((row, index22) => {
2898
2923
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
2899
2924
  const completeFieldName = `${nameWithIndex}.${field.name}`;
2925
+ const translatedLabel = formatMessage({
2926
+ id: `content-manager.components.${attribute.component}.${field.name}`,
2927
+ defaultMessage: field.label
2928
+ });
2900
2929
  return /* @__PURE__ */ jsxRuntime.jsx(
2901
2930
  designSystem.Grid.Item,
2902
2931
  {
@@ -2905,7 +2934,11 @@ const RepeatableComponent = ({
2905
2934
  xs: 12,
2906
2935
  direction: "column",
2907
2936
  alignItems: "stretch",
2908
- children: children({ ...field, name: completeFieldName })
2937
+ children: children({
2938
+ ...field,
2939
+ label: translatedLabel,
2940
+ name: completeFieldName
2941
+ })
2909
2942
  },
2910
2943
  completeFieldName
2911
2944
  );
@@ -4959,15 +4992,19 @@ const Wysiwyg = React__namespace.forwardRef(
4959
4992
  );
4960
4993
  const MemoizedWysiwyg = React__namespace.memo(Wysiwyg);
4961
4994
  const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4962
- const { id } = index.useDoc();
4995
+ const { id, document: document2, collectionType } = index.useDoc();
4963
4996
  const isFormDisabled = strapiAdmin.useForm("InputRenderer", (state) => state.disabled);
4964
4997
  const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
4965
4998
  const canCreateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
4966
4999
  const canReadFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
4967
5000
  const canUpdateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
4968
5001
  const canUserAction = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
4969
- const editableFields = id ? canUpdateFields : canCreateFields;
4970
- const readableFields = id ? canReadFields : canCreateFields;
5002
+ let idToCheck = id;
5003
+ if (collectionType === index.SINGLE_TYPES) {
5004
+ idToCheck = document2?.documentId;
5005
+ }
5006
+ const editableFields = idToCheck ? canUpdateFields : canCreateFields;
5007
+ const readableFields = idToCheck ? canReadFields : canCreateFields;
4971
5008
  const canUserReadField = canUserAction(props.name, readableFields, props.type);
4972
5009
  const canUserEditField = canUserAction(props.name, editableFields, props.type);
4973
5010
  const fields = strapiAdmin.useStrapiApp("InputRenderer", (app) => app.fields);
@@ -4978,6 +5015,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4978
5015
  const {
4979
5016
  edit: { components }
4980
5017
  } = index.useDocLayout();
5018
+ const field = strapiAdmin.useField(props.name);
4981
5019
  if (!visible) {
4982
5020
  return null;
4983
5021
  }
@@ -4988,7 +5026,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
4988
5026
  if (attributeHasCustomFieldProperty(props.attribute)) {
4989
5027
  const CustomInput = lazyComponentStore[props.attribute.customField];
4990
5028
  if (CustomInput) {
4991
- return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
5029
+ return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
4992
5030
  }
4993
5031
  return /* @__PURE__ */ jsxRuntime.jsx(
4994
5032
  strapiAdmin.InputRenderer,
@@ -5149,6 +5187,14 @@ const DynamicComponent = ({
5149
5187
  React__namespace.useEffect(() => {
5150
5188
  dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
5151
5189
  }, [dragPreviewRef, index$1]);
5190
+ const accordionValue = React__namespace.useId();
5191
+ const { value = [], rawError } = strapiAdmin.useField(`${name2}.${index$1}`);
5192
+ const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
5193
+ React__namespace.useEffect(() => {
5194
+ if (rawError && value) {
5195
+ setCollapseToOpen(accordionValue);
5196
+ }
5197
+ }, [rawError, value, accordionValue]);
5152
5198
  const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
5153
5199
  const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5154
5200
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -5214,10 +5260,9 @@ const DynamicComponent = ({
5214
5260
  ] })
5215
5261
  ] });
5216
5262
  const accordionTitle = title ? `${displayName} ${title}` : displayName;
5217
- const accordionValue = React__namespace.useId();
5218
5263
  return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
5219
5264
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
5220
- /* @__PURE__ */ jsxRuntime.jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: accordionValue, children: [
5265
+ /* @__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: [
5221
5266
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
5222
5267
  /* @__PURE__ */ jsxRuntime.jsx(
5223
5268
  designSystem.Accordion.Trigger,
@@ -5228,21 +5273,39 @@ const DynamicComponent = ({
5228
5273
  ),
5229
5274
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
5230
5275
  ] }),
5231
- /* @__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: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
5232
- const fieldName = `${name2}.${index$1}.${field.name}`;
5233
- return /* @__PURE__ */ jsxRuntime.jsx(
5234
- designSystem.Grid.Item,
5235
- {
5236
- col: size,
5237
- s: 12,
5238
- xs: 12,
5239
- direction: "column",
5240
- alignItems: "stretch",
5241
- children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...field, name: fieldName })
5242
- },
5243
- fieldName
5244
- );
5245
- }) }, rowInd)) }) }) })
5276
+ /* @__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(
5277
+ designSystem.Grid.Item,
5278
+ {
5279
+ col: 12,
5280
+ s: 12,
5281
+ xs: 12,
5282
+ direction: "column",
5283
+ alignItems: "stretch",
5284
+ children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
5285
+ const fieldName = `${name2}.${index$1}.${field.name}`;
5286
+ const fieldWithTranslatedLabel = {
5287
+ ...field,
5288
+ label: formatMessage({
5289
+ id: `content-manager.components.${componentUid}.${field.name}`,
5290
+ defaultMessage: field.label
5291
+ })
5292
+ };
5293
+ return /* @__PURE__ */ jsxRuntime.jsx(
5294
+ designSystem.Grid.Item,
5295
+ {
5296
+ col: size,
5297
+ s: 12,
5298
+ xs: 12,
5299
+ direction: "column",
5300
+ alignItems: "stretch",
5301
+ children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
5302
+ },
5303
+ fieldName
5304
+ );
5305
+ }) })
5306
+ },
5307
+ rowInd
5308
+ )) }) }) }) })
5246
5309
  ] }) }) })
5247
5310
  ] });
5248
5311
  };
@@ -5548,4 +5611,4 @@ exports.transformDocument = transformDocument;
5548
5611
  exports.useDynamicZone = useDynamicZone;
5549
5612
  exports.useFieldHint = useFieldHint;
5550
5613
  exports.useLazyComponents = useLazyComponents;
5551
- //# sourceMappingURL=Field-BB_pHo6D.js.map
5614
+ //# sourceMappingURL=Field-DNHm4wHx.js.map