@strapi/content-manager 0.0.0-experimental.e9122b401c96877b6707775c4f893660eab93ae3 → 0.0.0-experimental.eba25ec571b091c6bde1104eb6c753debdf15462
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.
- package/dist/_chunks/{ComponentConfigurationPage-CpBFh6_r.mjs → ComponentConfigurationPage-BaJMOQyq.mjs} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-CpBFh6_r.mjs.map → ComponentConfigurationPage-BaJMOQyq.mjs.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-_zF8p6CY.js → ComponentConfigurationPage-N-CTtgQa.js} +4 -4
- package/dist/_chunks/{ComponentConfigurationPage-_zF8p6CY.js.map → ComponentConfigurationPage-N-CTtgQa.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-_aG2DJSU.js → EditConfigurationPage-BHkjAbxH.js} +4 -4
- package/dist/_chunks/{EditConfigurationPage-_aG2DJSU.js.map → EditConfigurationPage-BHkjAbxH.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-CE_yavTi.mjs → EditConfigurationPage-CKK-5LfX.mjs} +4 -4
- package/dist/_chunks/{EditConfigurationPage-CE_yavTi.mjs.map → EditConfigurationPage-CKK-5LfX.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-DeTn7rAF.mjs → EditViewPage-B11aeMcf.mjs} +50 -10
- package/dist/_chunks/EditViewPage-B11aeMcf.mjs.map +1 -0
- package/dist/_chunks/{EditViewPage-G9uNzwYL.js → EditViewPage-QPUftxUd.js} +49 -9
- package/dist/_chunks/EditViewPage-QPUftxUd.js.map +1 -0
- package/dist/_chunks/{Field-CnCKhI1R.mjs → Field-Bj_RgtGo.mjs} +109 -46
- package/dist/_chunks/Field-Bj_RgtGo.mjs.map +1 -0
- package/dist/_chunks/{Field-DDHUWEfV.js → Field-DUK83cfh.js} +108 -45
- package/dist/_chunks/Field-DUK83cfh.js.map +1 -0
- package/dist/_chunks/{Form-DYETaKUX.js → Form-DHmBRlHd.js} +3 -3
- package/dist/_chunks/Form-DHmBRlHd.js.map +1 -0
- package/dist/_chunks/{Form-IvVVwqRL.mjs → Form-DLMSoXV7.mjs} +3 -3
- package/dist/_chunks/Form-DLMSoXV7.mjs.map +1 -0
- package/dist/_chunks/{History-BMunT-do.mjs → History-CfCSNlG9.mjs} +43 -100
- package/dist/_chunks/History-CfCSNlG9.mjs.map +1 -0
- package/dist/_chunks/{History-CnZDctSO.js → History-Di3zm4HT.js} +41 -98
- package/dist/_chunks/History-Di3zm4HT.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-CDqkCxgV.mjs → ListConfigurationPage-0mtv_iqk.mjs} +6 -5
- package/dist/_chunks/ListConfigurationPage-0mtv_iqk.mjs.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BynalOp8.js → ListConfigurationPage-Cq361KIt.js} +5 -4
- package/dist/_chunks/ListConfigurationPage-Cq361KIt.js.map +1 -0
- package/dist/_chunks/{ListViewPage-_5gS-DOF.mjs → ListViewPage-BxLVROX8.mjs} +69 -42
- package/dist/_chunks/ListViewPage-BxLVROX8.mjs.map +1 -0
- package/dist/_chunks/{ListViewPage-I88Ouzoq.js → ListViewPage-DFDcG8gM.js} +69 -42
- package/dist/_chunks/ListViewPage-DFDcG8gM.js.map +1 -0
- package/dist/_chunks/{NoContentTypePage-Dht-55hr.mjs → NoContentTypePage-BRfDd67_.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-Dht-55hr.mjs.map → NoContentTypePage-BRfDd67_.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-BaWQ7HsA.js → NoContentTypePage-BSyvnDZZ.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-BaWQ7HsA.js.map → NoContentTypePage-BSyvnDZZ.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-Bs8D5W_v.mjs → NoPermissionsPage-CV9V8KWa.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-Bs8D5W_v.mjs.map → NoPermissionsPage-CV9V8KWa.mjs.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DCVUh5at.js → NoPermissionsPage-DyLphsn_.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DCVUh5at.js.map → NoPermissionsPage-DyLphsn_.js.map} +1 -1
- package/dist/_chunks/Preview-C_B1nx3g.mjs +272 -0
- package/dist/_chunks/Preview-C_B1nx3g.mjs.map +1 -0
- package/dist/_chunks/Preview-D_3aO6Ly.js +291 -0
- package/dist/_chunks/Preview-D_3aO6Ly.js.map +1 -0
- package/dist/_chunks/{Relations-Chdt5qWc.mjs → Relations-C6pwmDXh.mjs} +72 -36
- package/dist/_chunks/Relations-C6pwmDXh.mjs.map +1 -0
- package/dist/_chunks/{Relations-BPgFQeGj.js → Relations-Cne2AlrL.js} +71 -35
- package/dist/_chunks/Relations-Cne2AlrL.js.map +1 -0
- package/dist/_chunks/{en-CPTj6CjC.mjs → en-DhFUjrNW.mjs} +22 -11
- package/dist/_chunks/{en-CPTj6CjC.mjs.map → en-DhFUjrNW.mjs.map} +1 -1
- package/dist/_chunks/{en-BVzUkPxZ.js → en-Ic0kXjxB.js} +22 -11
- package/dist/_chunks/{en-BVzUkPxZ.js.map → en-Ic0kXjxB.js.map} +1 -1
- package/dist/_chunks/{es-EUonQTon.js → es-9K52xZIr.js} +2 -2
- package/dist/_chunks/{ja-CcFe8diO.js.map → es-9K52xZIr.js.map} +1 -1
- package/dist/_chunks/{es-CeXiYflN.mjs → es-D34tqjMw.mjs} +2 -2
- package/dist/_chunks/{es-CeXiYflN.mjs.map → es-D34tqjMw.mjs.map} +1 -1
- package/dist/_chunks/{fr-CD9VFbPM.mjs → fr--pg5jUbt.mjs} +13 -3
- package/dist/_chunks/{fr-CD9VFbPM.mjs.map → fr--pg5jUbt.mjs.map} +1 -1
- package/dist/_chunks/{fr-B7kGGg3E.js → fr-B2Kyv8Z9.js} +13 -3
- package/dist/_chunks/{fr-B7kGGg3E.js.map → fr-B2Kyv8Z9.js.map} +1 -1
- package/dist/_chunks/{index-D4UGPFZC.mjs → index-BpxR3En4.mjs} +887 -726
- package/dist/_chunks/index-BpxR3En4.mjs.map +1 -0
- package/dist/_chunks/{index-BhbLFX4l.js → index-T-aWjbj2.js} +884 -722
- package/dist/_chunks/index-T-aWjbj2.js.map +1 -0
- package/dist/_chunks/{ja-CcFe8diO.js → ja-7sfIbjxE.js} +2 -2
- package/dist/_chunks/{es-EUonQTon.js.map → ja-7sfIbjxE.js.map} +1 -1
- package/dist/_chunks/{ja-CtsUxOvk.mjs → ja-BHqhDq4V.mjs} +2 -2
- package/dist/_chunks/{ja-CtsUxOvk.mjs.map → ja-BHqhDq4V.mjs.map} +1 -1
- package/dist/_chunks/{layout-CYA7s0qO.js → layout-BEuNwv-F.js} +3 -3
- package/dist/_chunks/{layout-CYA7s0qO.js.map → layout-BEuNwv-F.js.map} +1 -1
- package/dist/_chunks/{layout-D4HI4_PS.mjs → layout-DhMZ_lDx.mjs} +3 -3
- package/dist/_chunks/{layout-D4HI4_PS.mjs.map → layout-DhMZ_lDx.mjs.map} +1 -1
- package/dist/_chunks/{objects-gigeqt7s.js → objects-BcXOv6_9.js} +2 -4
- package/dist/_chunks/{objects-gigeqt7s.js.map → objects-BcXOv6_9.js.map} +1 -1
- package/dist/_chunks/{objects-mKMAmfec.mjs → objects-D6yBsdmx.mjs} +2 -4
- package/dist/_chunks/{objects-mKMAmfec.mjs.map → objects-D6yBsdmx.mjs.map} +1 -1
- package/dist/_chunks/{relations-1pXaYpBK.mjs → relations-BdnxoX6f.mjs} +6 -7
- package/dist/_chunks/relations-BdnxoX6f.mjs.map +1 -0
- package/dist/_chunks/{relations-DDZ9OxNo.js → relations-kLcuobLk.js} +6 -7
- package/dist/_chunks/relations-kLcuobLk.js.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +4 -3
- package/dist/admin/src/exports.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +32 -1
- package/dist/admin/src/pages/EditView/EditViewPage.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +2 -2
- package/dist/admin/src/pages/EditView/components/Header.d.ts +1 -0
- package/dist/admin/src/preview/components/PreviewContent.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewHeader.d.ts +2 -0
- package/dist/admin/src/preview/components/PreviewSidePanel.d.ts +3 -0
- package/dist/admin/src/preview/constants.d.ts +1 -0
- package/dist/admin/src/preview/index.d.ts +4 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +11 -0
- package/dist/admin/src/preview/routes.d.ts +3 -0
- package/dist/admin/src/preview/services/preview.d.ts +3 -0
- package/dist/admin/src/router.d.ts +1 -1
- package/dist/admin/src/services/documents.d.ts +0 -3
- package/dist/server/index.js +421 -160
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +422 -161
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/bootstrap.d.ts.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/index.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +15 -1
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/lifecycles.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +2 -3
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +4 -4
- package/dist/server/src/preview/constants.d.ts +2 -0
- package/dist/server/src/preview/constants.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/index.d.ts +2 -0
- package/dist/server/src/preview/controllers/index.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/preview.d.ts +13 -0
- package/dist/server/src/preview/controllers/preview.d.ts.map +1 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts +6 -0
- package/dist/server/src/preview/controllers/validation/preview.d.ts.map +1 -0
- package/dist/server/src/preview/index.d.ts +4 -0
- package/dist/server/src/preview/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/index.d.ts +8 -0
- package/dist/server/src/preview/routes/index.d.ts.map +1 -0
- package/dist/server/src/preview/routes/preview.d.ts +4 -0
- package/dist/server/src/preview/routes/preview.d.ts.map +1 -0
- package/dist/server/src/preview/services/index.d.ts +16 -0
- package/dist/server/src/preview/services/index.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview-config.d.ts +32 -0
- package/dist/server/src/preview/services/preview-config.d.ts.map +1 -0
- package/dist/server/src/preview/services/preview.d.ts +12 -0
- package/dist/server/src/preview/services/preview.d.ts.map +1 -0
- package/dist/server/src/preview/utils.d.ts +19 -0
- package/dist/server/src/preview/utils.d.ts.map +1 -0
- package/dist/server/src/register.d.ts.map +1 -1
- package/dist/server/src/routes/index.d.ts.map +1 -1
- package/dist/server/src/services/document-manager.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +8 -8
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +4 -4
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/services/utils/configuration/index.d.ts +2 -2
- package/dist/server/src/services/utils/configuration/layouts.d.ts +2 -2
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/shared/contracts/index.d.ts +1 -0
- package/dist/shared/contracts/index.d.ts.map +1 -1
- package/dist/shared/contracts/preview.d.ts +27 -0
- package/dist/shared/contracts/preview.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.mjs +4 -0
- package/dist/shared/index.mjs.map +1 -1
- package/package.json +13 -13
- package/dist/_chunks/EditViewPage-DeTn7rAF.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-G9uNzwYL.js.map +0 -1
- package/dist/_chunks/Field-CnCKhI1R.mjs.map +0 -1
- package/dist/_chunks/Field-DDHUWEfV.js.map +0 -1
- package/dist/_chunks/Form-DYETaKUX.js.map +0 -1
- package/dist/_chunks/Form-IvVVwqRL.mjs.map +0 -1
- package/dist/_chunks/History-BMunT-do.mjs.map +0 -1
- package/dist/_chunks/History-CnZDctSO.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-BynalOp8.js.map +0 -1
- package/dist/_chunks/ListConfigurationPage-CDqkCxgV.mjs.map +0 -1
- package/dist/_chunks/ListViewPage-I88Ouzoq.js.map +0 -1
- package/dist/_chunks/ListViewPage-_5gS-DOF.mjs.map +0 -1
- package/dist/_chunks/Relations-BPgFQeGj.js.map +0 -1
- package/dist/_chunks/Relations-Chdt5qWc.mjs.map +0 -1
- package/dist/_chunks/index-BhbLFX4l.js.map +0 -1
- package/dist/_chunks/index-D4UGPFZC.mjs.map +0 -1
- package/dist/_chunks/relations-1pXaYpBK.mjs.map +0 -1
- package/dist/_chunks/relations-DDZ9OxNo.js.map +0 -1
- 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-
|
11
|
-
const Field = require("./Field-
|
10
|
+
const index = require("./index-T-aWjbj2.js");
|
11
|
+
const Field = require("./Field-DUK83cfh.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
|
-
|
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, { ...
|
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
|
-
|
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:
|
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
|
-
|
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
|
-
|
272
|
+
exports.getDocumentStatus = getDocumentStatus;
|
273
|
+
//# sourceMappingURL=EditViewPage-QPUftxUd.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"EditViewPage-QPUftxUd.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,kBAAkBC,UAAAA;AACpB,QAAA,EAAE,UAAUC,MAAAA;AAElB,SACGC,2BAAAA,IAAAC,aAAAA,MAAA,EAAK,WAAU,UAAS,YAAW,WAAU,KAAK,GAChD,UAAO,OAAA,IAAI,CAAC,OAAOC,WAAU;AAC5B,QAAI,MAAM,KAAK,CAAC,QAAQ,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;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 @@ import { useStrapiApp, createContext, useField, useNotification, useForm, useAPI
|
|
5
5
|
import { Box, SingleSelect, SingleSelectOption, Typography, Flex, BaseLink, Button, Popover, Field, Tooltip, IconButton, useComposedRefs, Portal, FocusTrap, Divider, VisuallyHidden, Grid as Grid$1, Accordion, TextButton, TextInput, IconButtonGroup, Menu, MenuItem } from "@strapi/design-system";
|
6
6
|
import pipe$1 from "lodash/fp/pipe";
|
7
7
|
import { useIntl } from "react-intl";
|
8
|
-
import { m as DOCUMENT_META_FIELDS, g as getTranslation, c as useDoc, e as contentManagerApi, n as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, o as useDocLayout } from "./index-
|
8
|
+
import { m as DOCUMENT_META_FIELDS, g as getTranslation, c as useDoc, e as contentManagerApi, n as CLONE_PATH, d as buildValidParams, f as useDocumentRBAC, S as SINGLE_TYPES, o as useDocLayout } from "./index-BpxR3En4.mjs";
|
9
9
|
import { generateNKeysBetween } from "fractional-indexing";
|
10
|
-
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-
|
11
|
-
import {
|
10
|
+
import { u as useComponent, C as ComponentProvider, M as MemoizedRelationsField } from "./Relations-C6pwmDXh.mjs";
|
11
|
+
import { CodeBlock as CodeBlock$1, HeadingOne, HeadingTwo, HeadingThree, HeadingFour, HeadingFive, HeadingSix, Image as Image$1, NumberList, BulletList, Paragraph, Quotes, Link as Link$1, Drag, Collapse, Bold, Italic, Underline, StrikeThrough, Code, Expand, PlusCircle, Plus, Trash, EyeStriked, CheckCircle, WarningCircle, Loader, ArrowClockwise, More } from "@strapi/icons";
|
12
12
|
import { styled, css, keyframes } from "styled-components";
|
13
13
|
import { C as ComponentIcon, a as COMPONENT_ICONS } from "./ComponentIcon-u4bIXTFY.mjs";
|
14
14
|
import { getEmptyImage } from "react-dnd-html5-backend";
|
15
15
|
import { a as DIRECTIONS, u as useDragAndDrop, I as ItemTypes } from "./useDragAndDrop-DdHgKsqq.mjs";
|
16
|
-
import { g as getIn } from "./objects-
|
16
|
+
import { g as getIn } from "./objects-D6yBsdmx.mjs";
|
17
17
|
import { Editor as Editor$1, Transforms, Node, Element, Range, Path, Point, createEditor } from "slate";
|
18
18
|
import { withHistory } from "slate-history";
|
19
19
|
import { useFocused, useSelected, ReactEditor, Editable, useSlate, Slate, withReact } from "slate-react";
|
@@ -508,7 +508,7 @@ const CodeEditor = (props) => {
|
|
508
508
|
const codeBlocks = {
|
509
509
|
code: {
|
510
510
|
renderElement: (props) => /* @__PURE__ */ jsx(CodeEditor, { ...props }),
|
511
|
-
icon:
|
511
|
+
icon: CodeBlock$1,
|
512
512
|
label: {
|
513
513
|
id: "components.Blocks.blocks.code",
|
514
514
|
defaultMessage: "Code block"
|
@@ -2624,7 +2624,7 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
|
|
2624
2624
|
Box,
|
2625
2625
|
{
|
2626
2626
|
tag: "button",
|
2627
|
-
background: "neutral100",
|
2627
|
+
background: disabled ? "neutral150" : "neutral100",
|
2628
2628
|
borderColor: field.error ? "danger600" : "neutral200",
|
2629
2629
|
hasRadius: true,
|
2630
2630
|
disabled,
|
@@ -2632,32 +2632,32 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
|
|
2632
2632
|
paddingTop: 9,
|
2633
2633
|
paddingBottom: 9,
|
2634
2634
|
type: "button",
|
2635
|
+
style: { cursor: disabled ? "not-allowed" : "pointer" },
|
2635
2636
|
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
|
2636
|
-
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2637
|
-
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2638
|
-
|
2639
|
-
|
2640
|
-
|
2637
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", color: disabled ? "neutral500" : "primary600", children: /* @__PURE__ */ jsx(PlusCircle, { width: "3.2rem", height: "3.2rem" }) }),
|
2638
|
+
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(
|
2639
|
+
Typography,
|
2640
|
+
{
|
2641
|
+
textColor: disabled ? "neutral600" : "primary600",
|
2642
|
+
variant: "pi",
|
2643
|
+
fontWeight: "bold",
|
2644
|
+
children: formatMessage({
|
2645
|
+
id: getTranslation("components.empty-repeatable"),
|
2646
|
+
defaultMessage: "No entry yet. Click to add one."
|
2647
|
+
})
|
2648
|
+
}
|
2649
|
+
) })
|
2641
2650
|
] })
|
2642
2651
|
}
|
2643
2652
|
) });
|
2644
2653
|
};
|
2645
|
-
const CircleIcon = styled(PlusCircle)`
|
2646
|
-
width: 2.4rem;
|
2647
|
-
height: 2.4rem;
|
2648
|
-
> circle {
|
2649
|
-
fill: ${({ theme }) => theme.colors.primary200};
|
2650
|
-
}
|
2651
|
-
> path {
|
2652
|
-
fill: ${({ theme }) => theme.colors.primary600};
|
2653
|
-
}
|
2654
|
-
`;
|
2655
2654
|
const NonRepeatableComponent = ({
|
2656
2655
|
attribute,
|
2657
2656
|
name: name2,
|
2658
2657
|
children,
|
2659
2658
|
layout
|
2660
2659
|
}) => {
|
2660
|
+
const { formatMessage } = useIntl();
|
2661
2661
|
const { value } = useField(name2);
|
2662
2662
|
const level = useComponent("NonRepeatableComponent", (state) => state.level);
|
2663
2663
|
const isNested = level > 0;
|
@@ -2674,6 +2674,10 @@ const NonRepeatableComponent = ({
|
|
2674
2674
|
children: /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index) => {
|
2675
2675
|
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2676
2676
|
const completeFieldName = `${name2}.${field.name}`;
|
2677
|
+
const translatedLabel = formatMessage({
|
2678
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2679
|
+
defaultMessage: field.label
|
2680
|
+
});
|
2677
2681
|
return /* @__PURE__ */ jsx(
|
2678
2682
|
Grid$1.Item,
|
2679
2683
|
{
|
@@ -2682,7 +2686,7 @@ const NonRepeatableComponent = ({
|
|
2682
2686
|
xs: 12,
|
2683
2687
|
direction: "column",
|
2684
2688
|
alignItems: "stretch",
|
2685
|
-
children: children({ ...field, name: completeFieldName })
|
2689
|
+
children: children({ ...field, label: translatedLabel, name: completeFieldName })
|
2686
2690
|
},
|
2687
2691
|
completeFieldName
|
2688
2692
|
);
|
@@ -2704,13 +2708,34 @@ const RepeatableComponent = ({
|
|
2704
2708
|
const { search: searchString } = useLocation();
|
2705
2709
|
const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);
|
2706
2710
|
const { components } = useDoc();
|
2707
|
-
const {
|
2711
|
+
const {
|
2712
|
+
value = [],
|
2713
|
+
error,
|
2714
|
+
rawError
|
2715
|
+
} = useField(name2);
|
2708
2716
|
const addFieldRow = useForm("RepeatableComponent", (state) => state.addFieldRow);
|
2709
2717
|
const moveFieldRow = useForm("RepeatableComponent", (state) => state.moveFieldRow);
|
2710
2718
|
const removeFieldRow = useForm("RepeatableComponent", (state) => state.removeFieldRow);
|
2711
2719
|
const { max = Infinity } = attribute;
|
2712
2720
|
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
2713
2721
|
const [liveText, setLiveText] = React.useState("");
|
2722
|
+
React.useEffect(() => {
|
2723
|
+
const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
|
2724
|
+
const hasNestedValue = value && Array.isArray(value) && value.length > 0;
|
2725
|
+
if (hasNestedErrors && hasNestedValue) {
|
2726
|
+
const errorOpenItems = rawError.map((_, idx) => {
|
2727
|
+
return value[idx] ? value[idx].__temp_key__ : null;
|
2728
|
+
}).filter((value2) => !!value2);
|
2729
|
+
if (errorOpenItems && errorOpenItems.length > 0) {
|
2730
|
+
setCollapseToOpen((collapseToOpen2) => {
|
2731
|
+
if (!errorOpenItems.includes(collapseToOpen2)) {
|
2732
|
+
return errorOpenItems[0];
|
2733
|
+
}
|
2734
|
+
return collapseToOpen2;
|
2735
|
+
});
|
2736
|
+
}
|
2737
|
+
}
|
2738
|
+
}, [rawError, value]);
|
2714
2739
|
const componentTmpKeyWithFocussedField = React.useMemo(() => {
|
2715
2740
|
if (search.has("field")) {
|
2716
2741
|
const fieldParam = search.get("field");
|
@@ -2863,6 +2888,10 @@ const RepeatableComponent = ({
|
|
2863
2888
|
children: layout.map((row, index2) => {
|
2864
2889
|
return /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2865
2890
|
const completeFieldName = `${nameWithIndex}.${field.name}`;
|
2891
|
+
const translatedLabel = formatMessage({
|
2892
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2893
|
+
defaultMessage: field.label
|
2894
|
+
});
|
2866
2895
|
return /* @__PURE__ */ jsx(
|
2867
2896
|
Grid$1.Item,
|
2868
2897
|
{
|
@@ -2871,7 +2900,11 @@ const RepeatableComponent = ({
|
|
2871
2900
|
xs: 12,
|
2872
2901
|
direction: "column",
|
2873
2902
|
alignItems: "stretch",
|
2874
|
-
children: children({
|
2903
|
+
children: children({
|
2904
|
+
...field,
|
2905
|
+
label: translatedLabel,
|
2906
|
+
name: completeFieldName
|
2907
|
+
})
|
2875
2908
|
},
|
2876
2909
|
completeFieldName
|
2877
2910
|
);
|
@@ -4925,15 +4958,19 @@ const Wysiwyg = React.forwardRef(
|
|
4925
4958
|
);
|
4926
4959
|
const MemoizedWysiwyg = React.memo(Wysiwyg);
|
4927
4960
|
const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
4928
|
-
const { id } = useDoc();
|
4961
|
+
const { id, document: document2, collectionType } = useDoc();
|
4929
4962
|
const isFormDisabled = useForm("InputRenderer", (state) => state.disabled);
|
4930
4963
|
const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
|
4931
4964
|
const canCreateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
|
4932
4965
|
const canReadFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
|
4933
4966
|
const canUpdateFields = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
|
4934
4967
|
const canUserAction = useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
|
4935
|
-
|
4936
|
-
|
4968
|
+
let idToCheck = id;
|
4969
|
+
if (collectionType === SINGLE_TYPES) {
|
4970
|
+
idToCheck = document2?.documentId;
|
4971
|
+
}
|
4972
|
+
const editableFields = idToCheck ? canUpdateFields : canCreateFields;
|
4973
|
+
const readableFields = idToCheck ? canReadFields : canCreateFields;
|
4937
4974
|
const canUserReadField = canUserAction(props.name, readableFields, props.type);
|
4938
4975
|
const canUserEditField = canUserAction(props.name, editableFields, props.type);
|
4939
4976
|
const fields = useStrapiApp("InputRenderer", (app) => app.fields);
|
@@ -4944,6 +4981,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4944
4981
|
const {
|
4945
4982
|
edit: { components }
|
4946
4983
|
} = useDocLayout();
|
4984
|
+
const field = useField(props.name);
|
4947
4985
|
if (!visible) {
|
4948
4986
|
return null;
|
4949
4987
|
}
|
@@ -4954,7 +4992,7 @@ const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
|
4954
4992
|
if (attributeHasCustomFieldProperty(props.attribute)) {
|
4955
4993
|
const CustomInput = lazyComponentStore[props.attribute.customField];
|
4956
4994
|
if (CustomInput) {
|
4957
|
-
return /* @__PURE__ */ jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
|
4995
|
+
return /* @__PURE__ */ jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
|
4958
4996
|
}
|
4959
4997
|
return /* @__PURE__ */ jsx(
|
4960
4998
|
InputRenderer$1,
|
@@ -5115,6 +5153,14 @@ const DynamicComponent = ({
|
|
5115
5153
|
React.useEffect(() => {
|
5116
5154
|
dragPreviewRef(getEmptyImage(), { captureDraggingState: false });
|
5117
5155
|
}, [dragPreviewRef, index]);
|
5156
|
+
const accordionValue = React.useId();
|
5157
|
+
const { value = [], rawError } = useField(`${name2}.${index}`);
|
5158
|
+
const [collapseToOpen, setCollapseToOpen] = React.useState("");
|
5159
|
+
React.useEffect(() => {
|
5160
|
+
if (rawError && value) {
|
5161
|
+
setCollapseToOpen(accordionValue);
|
5162
|
+
}
|
5163
|
+
}, [rawError, value, accordionValue]);
|
5118
5164
|
const composedBoxRefs = useComposedRefs(boxRef, dropRef);
|
5119
5165
|
const accordionActions = disabled ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
5120
5166
|
/* @__PURE__ */ jsx(
|
@@ -5180,10 +5226,9 @@ const DynamicComponent = ({
|
|
5180
5226
|
] })
|
5181
5227
|
] });
|
5182
5228
|
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
5183
|
-
const accordionValue = React.useId();
|
5184
5229
|
return /* @__PURE__ */ jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
5185
5230
|
/* @__PURE__ */ jsx(Flex, { justifyContent: "center", children: /* @__PURE__ */ jsx(Rectangle, { background: "neutral200" }) }),
|
5186
|
-
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
|
5231
|
+
/* @__PURE__ */ jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsx(Preview, {}) : /* @__PURE__ */ jsx(Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxs(Accordion.Item, { value: accordionValue, children: [
|
5187
5232
|
/* @__PURE__ */ jsxs(Accordion.Header, { children: [
|
5188
5233
|
/* @__PURE__ */ jsx(
|
5189
5234
|
Accordion.Trigger,
|
@@ -5194,21 +5239,39 @@ const DynamicComponent = ({
|
|
5194
5239
|
),
|
5195
5240
|
/* @__PURE__ */ jsx(Accordion.Actions, { children: accordionActions })
|
5196
5241
|
] }),
|
5197
|
-
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children:
|
5198
|
-
|
5199
|
-
|
5200
|
-
|
5201
|
-
|
5202
|
-
|
5203
|
-
|
5204
|
-
|
5205
|
-
|
5206
|
-
|
5207
|
-
|
5208
|
-
|
5209
|
-
|
5210
|
-
|
5211
|
-
|
5242
|
+
/* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(AccordionContentRadius, { background: "neutral0", children: /* @__PURE__ */ jsx(Box, { paddingLeft: 6, paddingRight: 6, paddingTop: 6, paddingBottom: 6, children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: components[componentUid]?.layout?.map((row, rowInd) => /* @__PURE__ */ jsx(
|
5243
|
+
Grid$1.Item,
|
5244
|
+
{
|
5245
|
+
col: 12,
|
5246
|
+
s: 12,
|
5247
|
+
xs: 12,
|
5248
|
+
direction: "column",
|
5249
|
+
alignItems: "stretch",
|
5250
|
+
children: /* @__PURE__ */ jsx(Grid$1.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
5251
|
+
const fieldName = `${name2}.${index}.${field.name}`;
|
5252
|
+
const fieldWithTranslatedLabel = {
|
5253
|
+
...field,
|
5254
|
+
label: formatMessage({
|
5255
|
+
id: `content-manager.components.${componentUid}.${field.name}`,
|
5256
|
+
defaultMessage: field.label
|
5257
|
+
})
|
5258
|
+
};
|
5259
|
+
return /* @__PURE__ */ jsx(
|
5260
|
+
Grid$1.Item,
|
5261
|
+
{
|
5262
|
+
col: size,
|
5263
|
+
s: 12,
|
5264
|
+
xs: 12,
|
5265
|
+
direction: "column",
|
5266
|
+
alignItems: "stretch",
|
5267
|
+
children: /* @__PURE__ */ jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
|
5268
|
+
},
|
5269
|
+
fieldName
|
5270
|
+
);
|
5271
|
+
}) })
|
5272
|
+
},
|
5273
|
+
rowInd
|
5274
|
+
)) }) }) }) })
|
5212
5275
|
] }) }) })
|
5213
5276
|
] });
|
5214
5277
|
};
|
@@ -5516,4 +5579,4 @@ export {
|
|
5516
5579
|
transformDocument as t,
|
5517
5580
|
useLazyComponents as u
|
5518
5581
|
};
|
5519
|
-
//# sourceMappingURL=Field-
|
5582
|
+
//# sourceMappingURL=Field-Bj_RgtGo.mjs.map
|