@strapi/content-manager 0.0.0-next.8414b837972392b1d362ae53b86b5da1eb2ad05c → 0.0.0-next.926e9af9369b89a571145e3c8fa1ce6bfd6cc0ab
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-BTR_hQow.js → ComponentConfigurationPage-DMxUlNOo.js} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-BTR_hQow.js.map → ComponentConfigurationPage-DMxUlNOo.js.map} +1 -1
- package/dist/_chunks/{ComponentConfigurationPage-bLQr82ce.mjs → ComponentConfigurationPage-baEkO-OV.mjs} +3 -3
- package/dist/_chunks/{ComponentConfigurationPage-bLQr82ce.mjs.map → ComponentConfigurationPage-baEkO-OV.mjs.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-z39Wv3E6.js → EditConfigurationPage-CXxV7mKn.js} +3 -3
- package/dist/_chunks/{EditConfigurationPage-z39Wv3E6.js.map → EditConfigurationPage-CXxV7mKn.js.map} +1 -1
- package/dist/_chunks/{EditConfigurationPage-BhRSnUsL.mjs → EditConfigurationPage-YR8-4VCS.mjs} +3 -3
- package/dist/_chunks/{EditConfigurationPage-BhRSnUsL.mjs.map → EditConfigurationPage-YR8-4VCS.mjs.map} +1 -1
- package/dist/_chunks/{EditViewPage-wujOq90c.js → EditViewPage-BfR6jAR6.js} +13 -76
- package/dist/_chunks/EditViewPage-BfR6jAR6.js.map +1 -0
- package/dist/_chunks/{EditViewPage-BCjNxNlY.mjs → EditViewPage-DFF7c27p.mjs} +11 -74
- package/dist/_chunks/EditViewPage-DFF7c27p.mjs.map +1 -0
- package/dist/_chunks/{Form-D7mexvm3.js → Form-CjcMRP5A.js} +2 -2
- package/dist/_chunks/{Form-D7mexvm3.js.map → Form-CjcMRP5A.js.map} +1 -1
- package/dist/_chunks/{Form-BZgvE8C8.mjs → Form-MSOSfGGN.mjs} +2 -2
- package/dist/_chunks/{Form-BZgvE8C8.mjs.map → Form-MSOSfGGN.mjs.map} +1 -1
- package/dist/_chunks/{History-DYl2A8Z_.js → History-BgZ7gVuF.js} +43 -19
- package/dist/_chunks/History-BgZ7gVuF.js.map +1 -0
- package/dist/_chunks/{History-CqNgxkqK.mjs → History-WOQNVho-.mjs} +32 -8
- package/dist/_chunks/History-WOQNVho-.mjs.map +1 -0
- package/dist/_chunks/{Field-Byr3mPTl.mjs → Input-BkKwZ6Qt.mjs} +1131 -1188
- package/dist/_chunks/Input-BkKwZ6Qt.mjs.map +1 -0
- package/dist/_chunks/{Field-B5QXnctJ.js → Input-BwOibhc3.js} +1212 -1269
- package/dist/_chunks/Input-BwOibhc3.js.map +1 -0
- package/dist/_chunks/{ListConfigurationPage-BbQjzKkQ.mjs → ListConfigurationPage-BeXfr6uW.mjs} +2 -2
- package/dist/_chunks/{ListConfigurationPage-BbQjzKkQ.mjs.map → ListConfigurationPage-BeXfr6uW.mjs.map} +1 -1
- package/dist/_chunks/{ListConfigurationPage-BXnu_OoY.js → ListConfigurationPage-DnJ3nbwL.js} +2 -2
- package/dist/_chunks/{ListConfigurationPage-BXnu_OoY.js.map → ListConfigurationPage-DnJ3nbwL.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-BtSi8C1l.js → ListViewPage-CJFDudKl.js} +13 -10
- package/dist/_chunks/{ListViewPage-BtSi8C1l.js.map → ListViewPage-CJFDudKl.js.map} +1 -1
- package/dist/_chunks/{ListViewPage-D4ofkbjR.mjs → ListViewPage-VK2v44Q1.mjs} +8 -5
- package/dist/_chunks/{ListViewPage-D4ofkbjR.mjs.map → ListViewPage-VK2v44Q1.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-DyUx5mXh.mjs → NoContentTypePage-T8ttty6K.mjs} +2 -2
- package/dist/_chunks/{NoContentTypePage-DyUx5mXh.mjs.map → NoContentTypePage-T8ttty6K.mjs.map} +1 -1
- package/dist/_chunks/{NoContentTypePage-CitJeOq4.js → NoContentTypePage-en2PwWgI.js} +2 -2
- package/dist/_chunks/{NoContentTypePage-CitJeOq4.js.map → NoContentTypePage-en2PwWgI.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DzgWz0M-.js → NoPermissionsPage-CcjILry3.js} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DzgWz0M-.js.map → NoPermissionsPage-CcjILry3.js.map} +1 -1
- package/dist/_chunks/{NoPermissionsPage-DhIiyWkk.mjs → NoPermissionsPage-CokBHhhy.mjs} +2 -2
- package/dist/_chunks/{NoPermissionsPage-DhIiyWkk.mjs.map → NoPermissionsPage-CokBHhhy.mjs.map} +1 -1
- package/dist/_chunks/{Preview-BaYGJ0nb.mjs → Preview-BF81YhRj.mjs} +10 -16
- package/dist/_chunks/Preview-BF81YhRj.mjs.map +1 -0
- package/dist/_chunks/{Preview-DfNx8Ke-.js → Preview-DgzAuzWQ.js} +10 -16
- package/dist/_chunks/Preview-DgzAuzWQ.js.map +1 -0
- package/dist/_chunks/{Relations-DuKCaXrv.js → Relations-1O-JcM4t.js} +3 -3
- package/dist/_chunks/{Relations-DuKCaXrv.js.map → Relations-1O-JcM4t.js.map} +1 -1
- package/dist/_chunks/{Relations-DM2yUTST.mjs → Relations-BncdhGCd.mjs} +3 -3
- package/dist/_chunks/{Relations-DM2yUTST.mjs.map → Relations-BncdhGCd.mjs.map} +1 -1
- package/dist/_chunks/{en-Dtk_ot79.mjs → en-BZaUty0m.mjs} +8 -2
- package/dist/_chunks/{en-Dtk_ot79.mjs.map → en-BZaUty0m.mjs.map} +1 -1
- package/dist/_chunks/{en-BK8Xyl5I.js → en-CzCnBk4S.js} +8 -2
- package/dist/_chunks/{en-BK8Xyl5I.js.map → en-CzCnBk4S.js.map} +1 -1
- package/dist/_chunks/{index-DVAIIsOs.mjs → index-DiluOUp6.mjs} +214 -48
- package/dist/_chunks/index-DiluOUp6.mjs.map +1 -0
- package/dist/_chunks/{index-BUWEmX8m.js → index-EXJvmn4t.js} +197 -31
- package/dist/_chunks/index-EXJvmn4t.js.map +1 -0
- package/dist/_chunks/{layout-C3fN7Ejz.js → layout-4TbKVax8.js} +3 -3
- package/dist/_chunks/{layout-C3fN7Ejz.js.map → layout-4TbKVax8.js.map} +1 -1
- package/dist/_chunks/{layout-Bxsv5mP7.mjs → layout-mSwsYzxv.mjs} +3 -3
- package/dist/_chunks/{layout-Bxsv5mP7.mjs.map → layout-mSwsYzxv.mjs.map} +1 -1
- package/dist/_chunks/{relations-o3pPhzY4.mjs → relations--YOvQBqv.mjs} +2 -2
- package/dist/_chunks/{relations-o3pPhzY4.mjs.map → relations--YOvQBqv.mjs.map} +1 -1
- package/dist/_chunks/{relations-BPZKAoEY.js → relations-Ai6Izh7h.js} +2 -2
- package/dist/_chunks/{relations-BPZKAoEY.js.map → relations-Ai6Izh7h.js.map} +1 -1
- package/dist/_chunks/{useDebounce-DmuSJIF3.mjs → usePrev-CZGy2Vjf.mjs} +11 -11
- package/dist/_chunks/usePrev-CZGy2Vjf.mjs.map +1 -0
- package/dist/_chunks/{useDebounce-CtcjDB3L.js → usePrev-D5J_2fEu.js} +8 -8
- package/dist/_chunks/usePrev-D5J_2fEu.js.map +1 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +6 -5
- package/dist/admin/src/exports.d.ts +1 -0
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocument.d.ts +19 -2
- package/dist/admin/src/pages/EditView/components/DocumentStatus.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/Field.d.ts +4 -1
- package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -0
- package/dist/admin/src/pages/EditView/utils/data.d.ts +1 -0
- package/dist/admin/src/preview/pages/Preview.d.ts +1 -1
- package/dist/admin/src/preview/services/preview.d.ts +1 -1
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +16 -16
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/server/index.js +156 -138
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +157 -139
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/src/controllers/utils/metadata.d.ts +1 -0
- package/dist/server/src/controllers/utils/metadata.d.ts.map +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts +1 -1
- package/dist/server/src/history/controllers/history-version.d.ts.map +1 -1
- package/dist/server/src/history/services/history.d.ts +3 -3
- package/dist/server/src/history/services/history.d.ts.map +1 -1
- package/dist/server/src/history/services/utils.d.ts +6 -10
- package/dist/server/src/history/services/utils.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +3 -2
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/document-metadata.d.ts +4 -2
- package/dist/server/src/services/document-metadata.d.ts.map +1 -1
- package/dist/server/src/services/index.d.ts +3 -2
- 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/services/utils/populate.d.ts +2 -2
- package/dist/server/src/services/utils/populate.d.ts.map +1 -1
- package/package.json +6 -7
- package/dist/_chunks/EditViewPage-BCjNxNlY.mjs.map +0 -1
- package/dist/_chunks/EditViewPage-wujOq90c.js.map +0 -1
- package/dist/_chunks/Field-B5QXnctJ.js.map +0 -1
- package/dist/_chunks/Field-Byr3mPTl.mjs.map +0 -1
- package/dist/_chunks/History-CqNgxkqK.mjs.map +0 -1
- package/dist/_chunks/History-DYl2A8Z_.js.map +0 -1
- package/dist/_chunks/Preview-BaYGJ0nb.mjs.map +0 -1
- package/dist/_chunks/Preview-DfNx8Ke-.js.map +0 -1
- package/dist/_chunks/index-BUWEmX8m.js.map +0 -1
- package/dist/_chunks/index-DVAIIsOs.mjs.map +0 -1
- package/dist/_chunks/useDebounce-CtcjDB3L.js.map +0 -1
- package/dist/_chunks/useDebounce-DmuSJIF3.mjs.map +0 -1
@@ -3,17 +3,10 @@ const jsxRuntime = require("react/jsx-runtime");
|
|
3
3
|
const React = require("react");
|
4
4
|
const strapiAdmin = require("@strapi/admin/strapi-admin");
|
5
5
|
const designSystem = require("@strapi/design-system");
|
6
|
-
const pipe$1 = require("lodash/fp/pipe");
|
7
|
-
const reactIntl = require("react-intl");
|
8
|
-
const index = require("./index-BUWEmX8m.js");
|
9
|
-
const fractionalIndexing = require("fractional-indexing");
|
10
|
-
const Relations = require("./Relations-DuKCaXrv.js");
|
11
6
|
const Icons = require("@strapi/icons");
|
7
|
+
const reactIntl = require("react-intl");
|
8
|
+
const index = require("./index-EXJvmn4t.js");
|
12
9
|
const styledComponents = require("styled-components");
|
13
|
-
const ComponentIcon = require("./ComponentIcon-CRbtQEUV.js");
|
14
|
-
const reactDndHtml5Backend = require("react-dnd-html5-backend");
|
15
|
-
const useDragAndDrop = require("./useDragAndDrop-BMtgCYzL.js");
|
16
|
-
const objects = require("./objects-BcXOv6_9.js");
|
17
10
|
const slate = require("slate");
|
18
11
|
const slateHistory = require("slate-history");
|
19
12
|
const slateReact = require("slate-react");
|
@@ -68,9 +61,15 @@ require("prismjs/components/prism-typescript");
|
|
68
61
|
require("prismjs/components/prism-tsx");
|
69
62
|
require("prismjs/components/prism-vbnet");
|
70
63
|
require("prismjs/components/prism-yaml");
|
71
|
-
const
|
64
|
+
const usePrev = require("./usePrev-D5J_2fEu.js");
|
65
|
+
const useDragAndDrop = require("./useDragAndDrop-BMtgCYzL.js");
|
72
66
|
const Toolbar = require("@radix-ui/react-toolbar");
|
67
|
+
const reactDndHtml5Backend = require("react-dnd-html5-backend");
|
73
68
|
const reactRouterDom = require("react-router-dom");
|
69
|
+
const objects = require("./objects-BcXOv6_9.js");
|
70
|
+
const Relations = require("./Relations-1O-JcM4t.js");
|
71
|
+
const pipe$1 = require("lodash/fp/pipe");
|
72
|
+
const ComponentIcon = require("./ComponentIcon-CRbtQEUV.js");
|
74
73
|
const CodeMirror = require("codemirror5");
|
75
74
|
const sanitizeHtml = require("sanitize-html");
|
76
75
|
const highlight_js = require("highlight.js");
|
@@ -105,9 +104,9 @@ function _interopNamespace(e) {
|
|
105
104
|
return Object.freeze(n);
|
106
105
|
}
|
107
106
|
const React__namespace = /* @__PURE__ */ _interopNamespace(React);
|
108
|
-
const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
|
109
107
|
const Prism__namespace = /* @__PURE__ */ _interopNamespace(Prism);
|
110
108
|
const Toolbar__namespace = /* @__PURE__ */ _interopNamespace(Toolbar);
|
109
|
+
const pipe__default = /* @__PURE__ */ _interopDefault(pipe$1);
|
111
110
|
const CodeMirror__default = /* @__PURE__ */ _interopDefault(CodeMirror);
|
112
111
|
const sanitizeHtml__default = /* @__PURE__ */ _interopDefault(sanitizeHtml);
|
113
112
|
const Markdown__default = /* @__PURE__ */ _interopDefault(Markdown);
|
@@ -120,93 +119,6 @@ const ins__default = /* @__PURE__ */ _interopDefault(ins);
|
|
120
119
|
const mark__default = /* @__PURE__ */ _interopDefault(mark);
|
121
120
|
const sub__default = /* @__PURE__ */ _interopDefault(sub);
|
122
121
|
const sup__default = /* @__PURE__ */ _interopDefault(sup);
|
123
|
-
const BLOCK_LIST_ATTRIBUTE_KEYS = ["__component", "__temp_key__"];
|
124
|
-
const traverseData = (predicate, transform) => (schema, components = {}) => (data = {}) => {
|
125
|
-
const traverse = (datum, attributes) => {
|
126
|
-
return Object.entries(datum).reduce((acc, [key, value]) => {
|
127
|
-
const attribute = attributes[key];
|
128
|
-
if (BLOCK_LIST_ATTRIBUTE_KEYS.includes(key) || value === null || value === void 0) {
|
129
|
-
acc[key] = value;
|
130
|
-
return acc;
|
131
|
-
}
|
132
|
-
if (attribute.type === "component") {
|
133
|
-
if (attribute.repeatable) {
|
134
|
-
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
135
|
-
acc[key] = componentValue.map(
|
136
|
-
(componentData) => traverse(componentData, components[attribute.component]?.attributes ?? {})
|
137
|
-
);
|
138
|
-
} else {
|
139
|
-
const componentValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
140
|
-
acc[key] = traverse(componentValue, components[attribute.component]?.attributes ?? {});
|
141
|
-
}
|
142
|
-
} else if (attribute.type === "dynamiczone") {
|
143
|
-
const dynamicZoneValue = predicate(attribute, value) ? transform(value, attribute) : value;
|
144
|
-
acc[key] = dynamicZoneValue.map(
|
145
|
-
(componentData) => traverse(componentData, components[componentData.__component]?.attributes ?? {})
|
146
|
-
);
|
147
|
-
} else if (predicate(attribute, value)) {
|
148
|
-
acc[key] = transform(value, attribute);
|
149
|
-
} else {
|
150
|
-
acc[key] = value;
|
151
|
-
}
|
152
|
-
return acc;
|
153
|
-
}, {});
|
154
|
-
};
|
155
|
-
return traverse(data, schema.attributes);
|
156
|
-
};
|
157
|
-
const removeProhibitedFields = (prohibitedFields) => traverseData(
|
158
|
-
(attribute) => prohibitedFields.includes(attribute.type),
|
159
|
-
() => ""
|
160
|
-
);
|
161
|
-
const prepareRelations = traverseData(
|
162
|
-
(attribute) => attribute.type === "relation",
|
163
|
-
() => ({
|
164
|
-
connect: [],
|
165
|
-
disconnect: []
|
166
|
-
})
|
167
|
-
);
|
168
|
-
const prepareTempKeys = traverseData(
|
169
|
-
(attribute) => attribute.type === "component" && attribute.repeatable || attribute.type === "dynamiczone",
|
170
|
-
(data) => {
|
171
|
-
if (Array.isArray(data) && data.length > 0) {
|
172
|
-
const keys = fractionalIndexing.generateNKeysBetween(void 0, void 0, data.length);
|
173
|
-
return data.map((datum, index2) => ({
|
174
|
-
...datum,
|
175
|
-
__temp_key__: keys[index2]
|
176
|
-
}));
|
177
|
-
}
|
178
|
-
return data;
|
179
|
-
}
|
180
|
-
);
|
181
|
-
const removeFieldsThatDontExistOnSchema = (schema) => (data) => {
|
182
|
-
const schemaKeys = Object.keys(schema.attributes);
|
183
|
-
const dataKeys = Object.keys(data);
|
184
|
-
const keysToRemove = dataKeys.filter((key) => !schemaKeys.includes(key));
|
185
|
-
const revisedData = [...keysToRemove, ...index.DOCUMENT_META_FIELDS].reduce((acc, key) => {
|
186
|
-
delete acc[key];
|
187
|
-
return acc;
|
188
|
-
}, structuredClone(data));
|
189
|
-
return revisedData;
|
190
|
-
};
|
191
|
-
const removeNullValues = (data) => {
|
192
|
-
return Object.entries(data).reduce((acc, [key, value]) => {
|
193
|
-
if (value === null) {
|
194
|
-
return acc;
|
195
|
-
}
|
196
|
-
acc[key] = value;
|
197
|
-
return acc;
|
198
|
-
}, {});
|
199
|
-
};
|
200
|
-
const transformDocument = (schema, components = {}) => (document2) => {
|
201
|
-
const transformations = pipe__default.default(
|
202
|
-
removeFieldsThatDontExistOnSchema(schema),
|
203
|
-
removeProhibitedFields(["password"])(schema, components),
|
204
|
-
removeNullValues,
|
205
|
-
prepareRelations(schema, components),
|
206
|
-
prepareTempKeys(schema, components)
|
207
|
-
);
|
208
|
-
return transformations(document2);
|
209
|
-
};
|
210
122
|
const componentStore = /* @__PURE__ */ new Map();
|
211
123
|
const useLazyComponents = (componentUids = []) => {
|
212
124
|
const [lazyComponentStore, setLazyComponentStore] = React.useState(Object.fromEntries(componentStore));
|
@@ -633,8 +545,7 @@ const codeBlocks = {
|
|
633
545
|
handleEnterKey(editor) {
|
634
546
|
pressEnterTwiceToExit(editor);
|
635
547
|
},
|
636
|
-
snippets: ["```"]
|
637
|
-
dragHandleTopMargin: "10px"
|
548
|
+
snippets: ["```"]
|
638
549
|
}
|
639
550
|
};
|
640
551
|
const H1 = styledComponents.styled(designSystem.Typography).attrs({ tag: "h1" })`
|
@@ -843,7 +754,7 @@ const ImageDialog = () => {
|
|
843
754
|
const nodeImage = {
|
844
755
|
...expectedImage,
|
845
756
|
alternativeText: expectedImage.alternativeText || expectedImage.name,
|
846
|
-
url:
|
757
|
+
url: usePrev.prefixFileUrlWithBackendUrl(image.url)
|
847
758
|
};
|
848
759
|
return nodeImage;
|
849
760
|
});
|
@@ -1413,13 +1324,13 @@ const quoteBlocks = {
|
|
1413
1324
|
handleEnterKey(editor) {
|
1414
1325
|
pressEnterTwiceToExit(editor);
|
1415
1326
|
},
|
1416
|
-
snippets: [">"]
|
1417
|
-
dragHandleTopMargin: "6px"
|
1327
|
+
snippets: [">"]
|
1418
1328
|
}
|
1419
1329
|
};
|
1420
1330
|
const ToolbarWrapper = styledComponents.styled(designSystem.Flex)`
|
1421
1331
|
&[aria-disabled='true'] {
|
1422
1332
|
cursor: not-allowed;
|
1333
|
+
background: ${({ theme }) => theme.colors.neutral150};
|
1423
1334
|
}
|
1424
1335
|
`;
|
1425
1336
|
const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
|
@@ -1430,7 +1341,7 @@ const Separator = styledComponents.styled(Toolbar__namespace.Separator)`
|
|
1430
1341
|
const FlexButton = styledComponents.styled(designSystem.Flex)`
|
1431
1342
|
// Inherit the not-allowed cursor from ToolbarWrapper when disabled
|
1432
1343
|
&[aria-disabled] {
|
1433
|
-
cursor:
|
1344
|
+
cursor: not-allowed;
|
1434
1345
|
}
|
1435
1346
|
|
1436
1347
|
&[aria-disabled='false'] {
|
@@ -1782,7 +1693,7 @@ const BlocksToolbar = () => {
|
|
1782
1693
|
return false;
|
1783
1694
|
};
|
1784
1695
|
const isButtonDisabled = checkButtonDisabled();
|
1785
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, children: [
|
1696
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.Root, { "aria-disabled": disabled, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(ToolbarWrapper, { gap: 2, padding: 2, width: "100%", children: [
|
1786
1697
|
/* @__PURE__ */ jsxRuntime.jsx(BlocksDropdown, {}),
|
1787
1698
|
/* @__PURE__ */ jsxRuntime.jsx(Separator, {}),
|
1788
1699
|
/* @__PURE__ */ jsxRuntime.jsx(Toolbar__namespace.ToggleGroup, { type: "multiple", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 1, children: [
|
@@ -1856,30 +1767,32 @@ const DragIconButton = styledComponents.styled(designSystem.IconButton)`
|
|
1856
1767
|
display: flex;
|
1857
1768
|
align-items: center;
|
1858
1769
|
justify-content: center;
|
1770
|
+
border: none;
|
1859
1771
|
border-radius: ${({ theme }) => theme.borderRadius};
|
1860
|
-
|
1861
|
-
|
1772
|
+
padding-left: ${({ theme }) => theme.spaces[0]};
|
1773
|
+
padding-right: ${({ theme }) => theme.spaces[0]};
|
1774
|
+
padding-top: ${({ theme }) => theme.spaces[1]};
|
1775
|
+
padding-bottom: ${({ theme }) => theme.spaces[1]};
|
1862
1776
|
visibility: hidden;
|
1863
1777
|
cursor: grab;
|
1864
1778
|
opacity: inherit;
|
1865
1779
|
margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};
|
1866
1780
|
|
1867
1781
|
&:hover {
|
1868
|
-
background: ${({ theme }) => theme.colors.
|
1782
|
+
background: ${({ theme }) => theme.colors.neutral100};
|
1869
1783
|
}
|
1870
1784
|
&:active {
|
1871
1785
|
cursor: grabbing;
|
1786
|
+
background: ${({ theme }) => theme.colors.neutral150};
|
1872
1787
|
}
|
1873
1788
|
&[aria-disabled='true'] {
|
1874
|
-
|
1875
|
-
background: transparent;
|
1789
|
+
visibility: hidden;
|
1876
1790
|
}
|
1877
1791
|
svg {
|
1878
|
-
height: auto;
|
1879
1792
|
min-width: ${({ theme }) => theme.spaces[3]};
|
1880
1793
|
|
1881
1794
|
path {
|
1882
|
-
fill: ${({ theme }) => theme.colors.
|
1795
|
+
fill: ${({ theme }) => theme.colors.neutral500};
|
1883
1796
|
}
|
1884
1797
|
}
|
1885
1798
|
`;
|
@@ -2232,7 +2145,7 @@ const BlocksContent = ({ placeholder, ariaLabelId }) => {
|
|
2232
2145
|
background: "neutral0",
|
2233
2146
|
color: "neutral800",
|
2234
2147
|
lineHeight: 6,
|
2235
|
-
paddingRight:
|
2148
|
+
paddingRight: 7,
|
2236
2149
|
paddingTop: 6,
|
2237
2150
|
paddingBottom: 3,
|
2238
2151
|
children: [
|
@@ -2566,6 +2479,7 @@ const ExpandIconButton = styledComponents.styled(designSystem.IconButton)`
|
|
2566
2479
|
position: absolute;
|
2567
2480
|
bottom: 1.2rem;
|
2568
2481
|
right: 1.2rem;
|
2482
|
+
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
2569
2483
|
`;
|
2570
2484
|
function useResetKey(value) {
|
2571
2485
|
const slateUpdatesCount = React__namespace.useRef(0);
|
@@ -2697,26 +2611,6 @@ const BlocksInput = React__namespace.forwardRef(
|
|
2697
2611
|
}
|
2698
2612
|
);
|
2699
2613
|
const MemoizedBlocksInput = React__namespace.memo(BlocksInput);
|
2700
|
-
const createDefaultForm = (contentType, components = {}) => {
|
2701
|
-
const traverseSchema = (attributes) => {
|
2702
|
-
return Object.entries(attributes).reduce((acc, [key, attribute]) => {
|
2703
|
-
if ("default" in attribute) {
|
2704
|
-
acc[key] = attribute.default;
|
2705
|
-
} else if (attribute.type === "component" && attribute.required) {
|
2706
|
-
const defaultComponentForm = traverseSchema(components[attribute.component].attributes);
|
2707
|
-
if (attribute.repeatable) {
|
2708
|
-
acc[key] = attribute.min ? [...Array(attribute.min).fill(defaultComponentForm)] : [];
|
2709
|
-
} else {
|
2710
|
-
acc[key] = defaultComponentForm;
|
2711
|
-
}
|
2712
|
-
} else if (attribute.type === "dynamiczone" && attribute.required) {
|
2713
|
-
acc[key] = [];
|
2714
|
-
}
|
2715
|
-
return acc;
|
2716
|
-
}, {});
|
2717
|
-
};
|
2718
|
-
return traverseSchema(contentType.attributes);
|
2719
|
-
};
|
2720
2614
|
const Initializer = ({ disabled, name: name2, onClick }) => {
|
2721
2615
|
const { formatMessage } = reactIntl.useIntl();
|
2722
2616
|
const field = strapiAdmin.useField(name2);
|
@@ -2751,624 +2645,619 @@ const Initializer = ({ disabled, name: name2, onClick }) => {
|
|
2751
2645
|
}
|
2752
2646
|
) });
|
2753
2647
|
};
|
2754
|
-
const
|
2755
|
-
|
2756
|
-
|
2648
|
+
const AddComponentButton = ({
|
2649
|
+
hasError,
|
2650
|
+
isDisabled,
|
2651
|
+
isOpen,
|
2757
2652
|
children,
|
2758
|
-
|
2653
|
+
onClick
|
2654
|
+
}) => {
|
2655
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
2656
|
+
StyledButton,
|
2657
|
+
{
|
2658
|
+
type: "button",
|
2659
|
+
onClick,
|
2660
|
+
disabled: isDisabled,
|
2661
|
+
background: "neutral0",
|
2662
|
+
style: { cursor: isDisabled ? "not-allowed" : "pointer" },
|
2663
|
+
variant: "tertiary",
|
2664
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { tag: "span", gap: 2, children: [
|
2665
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledAddIcon, { "aria-hidden": true, $isOpen: isOpen, $hasError: hasError && !isOpen }),
|
2666
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2667
|
+
designSystem.Typography,
|
2668
|
+
{
|
2669
|
+
variant: "pi",
|
2670
|
+
fontWeight: "bold",
|
2671
|
+
textColor: hasError && !isOpen ? "danger600" : "neutral600",
|
2672
|
+
children
|
2673
|
+
}
|
2674
|
+
)
|
2675
|
+
] })
|
2676
|
+
}
|
2677
|
+
);
|
2678
|
+
};
|
2679
|
+
const StyledAddIcon = styledComponents.styled(Icons.PlusCircle)`
|
2680
|
+
height: ${({ theme }) => theme.spaces[6]};
|
2681
|
+
width: ${({ theme }) => theme.spaces[6]};
|
2682
|
+
transform: ${({ $isOpen }) => $isOpen ? "rotate(45deg)" : "rotate(0deg)"};
|
2683
|
+
|
2684
|
+
> circle {
|
2685
|
+
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
|
2686
|
+
}
|
2687
|
+
> path {
|
2688
|
+
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral500};
|
2689
|
+
}
|
2690
|
+
`;
|
2691
|
+
const StyledButton = styledComponents.styled(designSystem.Button)`
|
2692
|
+
padding-left: ${({ theme }) => theme.spaces[3]};
|
2693
|
+
border-radius: 26px;
|
2694
|
+
box-shadow: ${({ theme }) => theme.shadows.filterShadow};
|
2695
|
+
height: 5rem;
|
2696
|
+
`;
|
2697
|
+
const ComponentCategory = ({
|
2698
|
+
category,
|
2699
|
+
components = [],
|
2700
|
+
variant = "primary",
|
2701
|
+
onAddComponent
|
2759
2702
|
}) => {
|
2760
2703
|
const { formatMessage } = reactIntl.useIntl();
|
2761
|
-
|
2762
|
-
|
2763
|
-
|
2764
|
-
|
2704
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: category, children: [
|
2705
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
|
2706
|
+
/* @__PURE__ */ jsxRuntime.jsx(ResponsiveAccordionContent, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
|
2707
|
+
ComponentBox,
|
2708
|
+
{
|
2709
|
+
tag: "button",
|
2710
|
+
type: "button",
|
2711
|
+
background: "neutral100",
|
2712
|
+
justifyContent: "center",
|
2713
|
+
onClick: onAddComponent(uid),
|
2714
|
+
hasRadius: true,
|
2715
|
+
height: "8.4rem",
|
2716
|
+
shrink: 0,
|
2717
|
+
borderColor: "neutral200",
|
2718
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
|
2719
|
+
/* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
|
2720
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
|
2721
|
+
] })
|
2722
|
+
},
|
2723
|
+
uid
|
2724
|
+
)) }) })
|
2725
|
+
] });
|
2726
|
+
};
|
2727
|
+
const ResponsiveAccordionContent = styledComponents.styled(designSystem.Accordion.Content)`
|
2728
|
+
container-type: inline-size;
|
2729
|
+
`;
|
2730
|
+
const Grid = styledComponents.styled(designSystem.Box)`
|
2731
|
+
display: grid;
|
2732
|
+
grid-template-columns: repeat(auto-fill, 100%);
|
2733
|
+
grid-gap: ${({ theme }) => theme.spaces[1]};
|
2734
|
+
|
2735
|
+
@container (min-width: ${() => RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
|
2736
|
+
grid-template-columns: repeat(auto-fill, 14rem);
|
2737
|
+
}
|
2738
|
+
`;
|
2739
|
+
const ComponentBox = styledComponents.styled(designSystem.Flex)`
|
2740
|
+
color: ${({ theme }) => theme.colors.neutral600};
|
2741
|
+
cursor: pointer;
|
2742
|
+
|
2743
|
+
@media (prefers-reduced-motion: no-preference) {
|
2744
|
+
transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
2745
|
+
}
|
2746
|
+
|
2747
|
+
&:focus,
|
2748
|
+
&:hover {
|
2749
|
+
border: 1px solid ${({ theme }) => theme.colors.primary200};
|
2750
|
+
background: ${({ theme }) => theme.colors.primary100};
|
2751
|
+
color: ${({ theme }) => theme.colors.primary600};
|
2752
|
+
}
|
2753
|
+
`;
|
2754
|
+
const ComponentPicker = ({
|
2755
|
+
dynamicComponentsByCategory = {},
|
2756
|
+
isOpen,
|
2757
|
+
onClickAddComponent
|
2758
|
+
}) => {
|
2759
|
+
const { formatMessage } = reactIntl.useIntl();
|
2760
|
+
const handleAddComponentToDz = (componentUid) => () => {
|
2761
|
+
onClickAddComponent(componentUid);
|
2762
|
+
};
|
2763
|
+
if (!isOpen) {
|
2764
|
+
return null;
|
2765
|
+
}
|
2766
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
2765
2767
|
designSystem.Box,
|
2766
2768
|
{
|
2767
|
-
background: "neutral100",
|
2768
|
-
paddingLeft: 6,
|
2769
|
-
paddingRight: 6,
|
2770
2769
|
paddingTop: 6,
|
2771
2770
|
paddingBottom: 6,
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
}) })
|
2771
|
+
paddingLeft: 5,
|
2772
|
+
paddingRight: 5,
|
2773
|
+
background: "neutral0",
|
2774
|
+
shadow: "tableShadow",
|
2775
|
+
borderColor: "neutral150",
|
2776
|
+
hasRadius: true,
|
2777
|
+
children: [
|
2778
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral600", children: formatMessage({
|
2779
|
+
id: index.getTranslation("components.DynamicZone.ComponentPicker-label"),
|
2780
|
+
defaultMessage: "Pick one component"
|
2781
|
+
}) }) }),
|
2782
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { defaultValue: Object.keys(dynamicComponentsByCategory)[0], children: Object.entries(dynamicComponentsByCategory).map(([category, components], index2) => /* @__PURE__ */ jsxRuntime.jsx(
|
2783
|
+
ComponentCategory,
|
2784
|
+
{
|
2785
|
+
category,
|
2786
|
+
components,
|
2787
|
+
onAddComponent: handleAddComponentToDz,
|
2788
|
+
variant: index2 % 2 === 1 ? "primary" : "secondary"
|
2789
|
+
},
|
2790
|
+
category
|
2791
|
+
)) }) })
|
2792
|
+
]
|
2795
2793
|
}
|
2796
|
-
)
|
2794
|
+
);
|
2797
2795
|
};
|
2798
|
-
const
|
2799
|
-
|
2796
|
+
const DynamicComponent = ({
|
2797
|
+
componentUid,
|
2800
2798
|
disabled,
|
2799
|
+
index: index$1,
|
2801
2800
|
name: name2,
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2801
|
+
onRemoveComponentClick,
|
2802
|
+
onMoveComponent,
|
2803
|
+
onGrabItem,
|
2804
|
+
onDropItem,
|
2805
|
+
onCancel,
|
2806
|
+
dynamicComponentsByCategory = {},
|
2807
|
+
onAddComponent,
|
2808
|
+
children
|
2805
2809
|
}) => {
|
2806
|
-
const { toggleNotification } = strapiAdmin.useNotification();
|
2807
2810
|
const { formatMessage } = reactIntl.useIntl();
|
2808
|
-
const
|
2809
|
-
const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
|
2810
|
-
const { components } = index.useDoc();
|
2811
|
+
const formValues = strapiAdmin.useForm("DynamicComponent", (state) => state.values);
|
2811
2812
|
const {
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
const
|
2822
|
-
|
2823
|
-
const
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2827
|
-
|
2828
|
-
}).filter((value2) => !!value2);
|
2829
|
-
if (errorOpenItems && errorOpenItems.length > 0) {
|
2830
|
-
setCollapseToOpen((collapseToOpen2) => {
|
2831
|
-
if (!errorOpenItems.includes(collapseToOpen2)) {
|
2832
|
-
return errorOpenItems[0];
|
2833
|
-
}
|
2834
|
-
return collapseToOpen2;
|
2835
|
-
});
|
2836
|
-
}
|
2837
|
-
}
|
2838
|
-
}, [rawError, value]);
|
2839
|
-
const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
|
2840
|
-
if (search.has("field")) {
|
2841
|
-
const fieldParam = search.get("field");
|
2842
|
-
if (!fieldParam) {
|
2843
|
-
return void 0;
|
2844
|
-
}
|
2845
|
-
const [, path] = fieldParam.split(`${name2}.`);
|
2846
|
-
if (objects.getIn(value, path, void 0) !== void 0) {
|
2847
|
-
const [subpath] = path.split(".");
|
2848
|
-
return objects.getIn(value, subpath, void 0)?.__temp_key__;
|
2849
|
-
}
|
2850
|
-
}
|
2851
|
-
return void 0;
|
2852
|
-
}, [search, name2, value]);
|
2853
|
-
const prevValue = useDebounce.usePrev(value);
|
2854
|
-
React__namespace.useEffect(() => {
|
2855
|
-
if (prevValue && prevValue.length < value.length) {
|
2856
|
-
setCollapseToOpen(value[value.length - 1].__temp_key__);
|
2857
|
-
}
|
2858
|
-
}, [value, prevValue]);
|
2859
|
-
React__namespace.useEffect(() => {
|
2860
|
-
if (typeof componentTmpKeyWithFocussedField === "string") {
|
2861
|
-
setCollapseToOpen(componentTmpKeyWithFocussedField);
|
2862
|
-
}
|
2863
|
-
}, [componentTmpKeyWithFocussedField]);
|
2864
|
-
const toggleCollapses = () => {
|
2865
|
-
setCollapseToOpen("");
|
2866
|
-
};
|
2867
|
-
const handleClick = () => {
|
2868
|
-
if (value.length < max) {
|
2869
|
-
const schema = components[attribute.component];
|
2870
|
-
const form = createDefaultForm(schema, components);
|
2871
|
-
const data = transformDocument(schema, components)(form);
|
2872
|
-
addFieldRow(name2, data);
|
2873
|
-
} else if (value.length >= max) {
|
2874
|
-
toggleNotification({
|
2875
|
-
type: "info",
|
2876
|
-
message: formatMessage({
|
2877
|
-
id: index.getTranslation("components.notification.info.maximum-requirement")
|
2878
|
-
})
|
2879
|
-
});
|
2880
|
-
}
|
2881
|
-
};
|
2882
|
-
const handleMoveComponentField = (newIndex, currentIndex) => {
|
2883
|
-
setLiveText(
|
2884
|
-
formatMessage(
|
2885
|
-
{
|
2886
|
-
id: index.getTranslation("dnd.reorder"),
|
2887
|
-
defaultMessage: "{item}, moved. New position in list: {position}."
|
2888
|
-
},
|
2889
|
-
{
|
2890
|
-
item: `${name2}.${currentIndex}`,
|
2891
|
-
position: getItemPos(newIndex)
|
2892
|
-
}
|
2893
|
-
)
|
2894
|
-
);
|
2895
|
-
moveFieldRow(name2, currentIndex, newIndex);
|
2896
|
-
};
|
2897
|
-
const handleValueChange = (key) => {
|
2898
|
-
setCollapseToOpen(key);
|
2899
|
-
};
|
2900
|
-
const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
|
2901
|
-
const handleCancel = (index$1) => {
|
2902
|
-
setLiveText(
|
2903
|
-
formatMessage(
|
2904
|
-
{
|
2905
|
-
id: index.getTranslation("dnd.cancel-item"),
|
2906
|
-
defaultMessage: "{item}, dropped. Re-order cancelled."
|
2907
|
-
},
|
2908
|
-
{
|
2909
|
-
item: `${name2}.${index$1}`
|
2910
|
-
}
|
2911
|
-
)
|
2912
|
-
);
|
2913
|
-
};
|
2914
|
-
const handleGrabItem = (index$1) => {
|
2915
|
-
setLiveText(
|
2916
|
-
formatMessage(
|
2917
|
-
{
|
2918
|
-
id: index.getTranslation("dnd.grab-item"),
|
2919
|
-
defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
|
2920
|
-
},
|
2921
|
-
{
|
2922
|
-
item: `${name2}.${index$1}`,
|
2923
|
-
position: getItemPos(index$1)
|
2924
|
-
}
|
2925
|
-
)
|
2926
|
-
);
|
2927
|
-
};
|
2928
|
-
const handleDropItem = (index$1) => {
|
2929
|
-
setLiveText(
|
2930
|
-
formatMessage(
|
2931
|
-
{
|
2932
|
-
id: index.getTranslation("dnd.drop-item"),
|
2933
|
-
defaultMessage: `{item}, dropped. Final position in list: {position}.`
|
2934
|
-
},
|
2935
|
-
{
|
2936
|
-
item: `${name2}.${index$1}`,
|
2937
|
-
position: getItemPos(index$1)
|
2938
|
-
}
|
2939
|
-
)
|
2940
|
-
);
|
2941
|
-
};
|
2942
|
-
const ariaDescriptionId = React__namespace.useId();
|
2943
|
-
const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
|
2944
|
-
if (value.length === 0) {
|
2945
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
|
2946
|
-
}
|
2947
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
|
2948
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
|
2949
|
-
id: index.getTranslation("dnd.instructions"),
|
2950
|
-
defaultMessage: `Press spacebar to grab and re-order`
|
2951
|
-
}) }),
|
2952
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
2953
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
2954
|
-
AccordionRoot,
|
2955
|
-
{
|
2956
|
-
$error: error,
|
2957
|
-
value: collapseToOpen,
|
2958
|
-
onValueChange: handleValueChange,
|
2959
|
-
"aria-describedby": ariaDescriptionId,
|
2960
|
-
children: [
|
2961
|
-
value.map(({ __temp_key__: key, id }, index2) => {
|
2962
|
-
const nameWithIndex = `${name2}.${index2}`;
|
2963
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
2964
|
-
Relations.ComponentProvider,
|
2965
|
-
{
|
2966
|
-
id,
|
2967
|
-
uid: attribute.component,
|
2968
|
-
level: level + 1,
|
2969
|
-
type: "repeatable",
|
2970
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
2971
|
-
Component,
|
2972
|
-
{
|
2973
|
-
disabled,
|
2974
|
-
name: nameWithIndex,
|
2975
|
-
attribute,
|
2976
|
-
index: index2,
|
2977
|
-
mainField,
|
2978
|
-
onMoveItem: handleMoveComponentField,
|
2979
|
-
onDeleteComponent: () => {
|
2980
|
-
removeFieldRow(name2, index2);
|
2981
|
-
toggleCollapses();
|
2982
|
-
},
|
2983
|
-
toggleCollapses,
|
2984
|
-
onCancel: handleCancel,
|
2985
|
-
onDropItem: handleDropItem,
|
2986
|
-
onGrabItem: handleGrabItem,
|
2987
|
-
__temp_key__: key,
|
2988
|
-
children: layout.map((row, index22) => {
|
2989
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
2990
|
-
const completeFieldName = `${nameWithIndex}.${field.name}`;
|
2991
|
-
const translatedLabel = formatMessage({
|
2992
|
-
id: `content-manager.components.${attribute.component}.${field.name}`,
|
2993
|
-
defaultMessage: field.label
|
2994
|
-
});
|
2995
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
2996
|
-
designSystem.Grid.Item,
|
2997
|
-
{
|
2998
|
-
col: size,
|
2999
|
-
s: 12,
|
3000
|
-
xs: 12,
|
3001
|
-
direction: "column",
|
3002
|
-
alignItems: "stretch",
|
3003
|
-
children: children({
|
3004
|
-
...field,
|
3005
|
-
label: translatedLabel,
|
3006
|
-
name: completeFieldName
|
3007
|
-
})
|
3008
|
-
},
|
3009
|
-
completeFieldName
|
3010
|
-
);
|
3011
|
-
}) }, index22);
|
3012
|
-
})
|
3013
|
-
}
|
3014
|
-
)
|
3015
|
-
},
|
3016
|
-
key
|
3017
|
-
);
|
3018
|
-
}),
|
3019
|
-
/* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
|
3020
|
-
id: index.getTranslation("containers.EditView.add.new-entry"),
|
3021
|
-
defaultMessage: "Add an entry"
|
3022
|
-
}) })
|
3023
|
-
]
|
3024
|
-
}
|
3025
|
-
)
|
3026
|
-
] });
|
3027
|
-
};
|
3028
|
-
const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
|
3029
|
-
border: 1px solid
|
3030
|
-
${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
|
3031
|
-
`;
|
3032
|
-
const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
|
3033
|
-
width: 100%;
|
3034
|
-
display: flex;
|
3035
|
-
justify-content: center;
|
3036
|
-
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
3037
|
-
padding-inline: ${(props) => props.theme.spaces[6]};
|
3038
|
-
padding-block: ${(props) => props.theme.spaces[3]};
|
3039
|
-
|
3040
|
-
&:not([disabled]) {
|
3041
|
-
cursor: pointer;
|
3042
|
-
|
3043
|
-
&:hover {
|
3044
|
-
background-color: ${(props) => props.theme.colors.primary100};
|
3045
|
-
}
|
3046
|
-
}
|
3047
|
-
|
3048
|
-
span {
|
3049
|
-
font-weight: 600;
|
3050
|
-
font-size: 1.4rem;
|
3051
|
-
line-height: 2.4rem;
|
3052
|
-
}
|
3053
|
-
|
3054
|
-
@media (prefers-reduced-motion: no-preference) {
|
3055
|
-
transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
3056
|
-
}
|
3057
|
-
`;
|
3058
|
-
const Component = ({
|
3059
|
-
disabled,
|
3060
|
-
index: index$1,
|
3061
|
-
name: name2,
|
3062
|
-
mainField = {
|
3063
|
-
name: "id",
|
3064
|
-
type: "integer"
|
3065
|
-
},
|
3066
|
-
children,
|
3067
|
-
onDeleteComponent,
|
3068
|
-
toggleCollapses,
|
3069
|
-
__temp_key__,
|
3070
|
-
...dragProps
|
3071
|
-
}) => {
|
3072
|
-
const { formatMessage } = reactIntl.useIntl();
|
3073
|
-
const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
|
3074
|
-
return objects.getIn(state.values, [...name2.split("."), mainField.name]);
|
3075
|
-
});
|
3076
|
-
const accordionRef = React__namespace.useRef(null);
|
3077
|
-
const componentKey = name2.split(".").slice(0, -1).join(".");
|
2813
|
+
edit: { components }
|
2814
|
+
} = index.useDocLayout();
|
2815
|
+
const title = React__namespace.useMemo(() => {
|
2816
|
+
const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
|
2817
|
+
const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
|
2818
|
+
const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
|
2819
|
+
const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
2820
|
+
return mainValue;
|
2821
|
+
}, [componentUid, components, formValues, name2, index$1]);
|
2822
|
+
const { icon, displayName } = React__namespace.useMemo(() => {
|
2823
|
+
const [category] = componentUid.split(".");
|
2824
|
+
const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
|
2825
|
+
(component) => component.uid === componentUid
|
2826
|
+
) ?? { icon: null, displayName: null };
|
2827
|
+
return { icon: icon2, displayName: displayName2 };
|
2828
|
+
}, [componentUid, dynamicComponentsByCategory]);
|
3078
2829
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
|
3079
|
-
type: `${useDragAndDrop.ItemTypes.
|
2830
|
+
type: `${useDragAndDrop.ItemTypes.DYNAMIC_ZONE}_${name2}`,
|
3080
2831
|
index: index$1,
|
3081
2832
|
item: {
|
3082
2833
|
index: index$1,
|
3083
|
-
displayedValue:
|
3084
|
-
|
3085
|
-
onStart() {
|
3086
|
-
toggleCollapses();
|
2834
|
+
displayedValue: `${displayName} ${title}`,
|
2835
|
+
icon
|
3087
2836
|
},
|
3088
|
-
|
2837
|
+
onMoveItem: onMoveComponent,
|
2838
|
+
onDropItem,
|
2839
|
+
onGrabItem,
|
2840
|
+
onCancel
|
3089
2841
|
});
|
3090
2842
|
React__namespace.useEffect(() => {
|
3091
2843
|
dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
|
3092
2844
|
}, [dragPreviewRef, index$1]);
|
3093
|
-
const
|
3094
|
-
const
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
2845
|
+
const accordionValue = React__namespace.useId();
|
2846
|
+
const { value = [], rawError } = strapiAdmin.useField(`${name2}.${index$1}`);
|
2847
|
+
const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
|
2848
|
+
React__namespace.useEffect(() => {
|
2849
|
+
if (rawError && value) {
|
2850
|
+
setCollapseToOpen(accordionValue);
|
2851
|
+
}
|
2852
|
+
}, [rawError, value, accordionValue]);
|
2853
|
+
const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
|
2854
|
+
const accordionActions = disabled ? null : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
2855
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2856
|
+
designSystem.IconButton,
|
2857
|
+
{
|
2858
|
+
variant: "ghost",
|
2859
|
+
label: formatMessage(
|
3104
2860
|
{
|
3105
|
-
|
3106
|
-
|
3107
|
-
|
3108
|
-
|
3109
|
-
defaultMessage: "Delete"
|
3110
|
-
}),
|
3111
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
|
3112
|
-
}
|
2861
|
+
id: index.getTranslation("components.DynamicZone.delete-label"),
|
2862
|
+
defaultMessage: "Delete {name}"
|
2863
|
+
},
|
2864
|
+
{ name: title }
|
3113
2865
|
),
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
|
3120
|
-
"data-handler-id": handlerId,
|
3121
|
-
label: formatMessage({
|
3122
|
-
id: index.getTranslation("components.DragHandle-label"),
|
3123
|
-
defaultMessage: "Drag"
|
3124
|
-
}),
|
3125
|
-
onKeyDown: handleKeyDown,
|
3126
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
|
3127
|
-
}
|
3128
|
-
)
|
3129
|
-
] })
|
3130
|
-
] }),
|
3131
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
3132
|
-
designSystem.Flex,
|
2866
|
+
onClick: onRemoveComponentClick,
|
2867
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
|
2868
|
+
}
|
2869
|
+
),
|
2870
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2871
|
+
designSystem.IconButton,
|
3133
2872
|
{
|
3134
|
-
|
3135
|
-
|
3136
|
-
|
3137
|
-
|
3138
|
-
|
3139
|
-
|
2873
|
+
variant: "ghost",
|
2874
|
+
onClick: (e) => e.stopPropagation(),
|
2875
|
+
"data-handler-id": handlerId,
|
2876
|
+
ref: dragRef,
|
2877
|
+
label: formatMessage({
|
2878
|
+
id: index.getTranslation("components.DragHandle-label"),
|
2879
|
+
defaultMessage: "Drag"
|
2880
|
+
}),
|
2881
|
+
onKeyDown: handleKeyDown,
|
2882
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
|
3140
2883
|
}
|
3141
|
-
)
|
3142
|
-
|
3143
|
-
|
3144
|
-
const Preview$1 = () => {
|
3145
|
-
return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
|
3146
|
-
};
|
3147
|
-
const StyledSpan = styledComponents.styled(designSystem.Box)`
|
3148
|
-
display: block;
|
3149
|
-
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
3150
|
-
outline-offset: -1px;
|
3151
|
-
`;
|
3152
|
-
const ComponentInput = ({
|
3153
|
-
label,
|
3154
|
-
required,
|
3155
|
-
name: name2,
|
3156
|
-
attribute,
|
3157
|
-
disabled,
|
3158
|
-
labelAction,
|
3159
|
-
...props
|
3160
|
-
}) => {
|
3161
|
-
const { formatMessage } = reactIntl.useIntl();
|
3162
|
-
const field = strapiAdmin.useField(name2);
|
3163
|
-
const showResetComponent = !attribute.repeatable && field.value && !disabled;
|
3164
|
-
const { components } = index.useDoc();
|
3165
|
-
const handleInitialisationClick = () => {
|
3166
|
-
const schema = components[attribute.component];
|
3167
|
-
const form = createDefaultForm(schema, components);
|
3168
|
-
const data = transformDocument(schema, components)(form);
|
3169
|
-
field.onChange(name2, data);
|
3170
|
-
};
|
3171
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
|
3172
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
|
3173
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
|
3174
|
-
label,
|
3175
|
-
attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
3176
|
-
" (",
|
3177
|
-
Array.isArray(field.value) ? field.value.length : 0,
|
3178
|
-
")"
|
3179
|
-
] })
|
3180
|
-
] }),
|
3181
|
-
showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
|
2884
|
+
),
|
2885
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
|
2886
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 0, paddingRight: 0, children: /* @__PURE__ */ jsxRuntime.jsx(
|
3182
2887
|
designSystem.IconButton,
|
3183
2888
|
{
|
2889
|
+
variant: "ghost",
|
3184
2890
|
label: formatMessage({
|
3185
|
-
id: index.getTranslation("components.
|
3186
|
-
defaultMessage: "
|
2891
|
+
id: index.getTranslation("components.DynamicZone.more-actions"),
|
2892
|
+
defaultMessage: "More actions"
|
3187
2893
|
}),
|
3188
|
-
|
3189
|
-
|
3190
|
-
field.onChange(name2, null);
|
3191
|
-
},
|
3192
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
|
2894
|
+
tag: "span",
|
2895
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false })
|
3193
2896
|
}
|
3194
|
-
)
|
3195
|
-
|
3196
|
-
|
3197
|
-
|
3198
|
-
|
3199
|
-
|
2897
|
+
) }),
|
2898
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
|
2899
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
|
2900
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
|
2901
|
+
id: index.getTranslation("components.DynamicZone.add-item-above"),
|
2902
|
+
defaultMessage: "Add component above"
|
2903
|
+
}) }),
|
2904
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
2905
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
|
2906
|
+
components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
|
2907
|
+
] }, category)) })
|
2908
|
+
] }),
|
2909
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
|
2910
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
|
2911
|
+
id: index.getTranslation("components.DynamicZone.add-item-below"),
|
2912
|
+
defaultMessage: "Add component below"
|
2913
|
+
}) }),
|
2914
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
2915
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
|
2916
|
+
components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
|
2917
|
+
] }, category)) })
|
2918
|
+
] })
|
2919
|
+
] })
|
2920
|
+
] })
|
2921
|
+
] });
|
2922
|
+
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
2923
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
2924
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
|
2925
|
+
/* @__PURE__ */ jsxRuntime.jsx(StyledBox, { ref: composedBoxRefs, hasRadius: true, children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview$1, {}) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Root, { value: collapseToOpen, onValueChange: setCollapseToOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: accordionValue, children: [
|
2926
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
|
2927
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
2928
|
+
designSystem.Accordion.Trigger,
|
2929
|
+
{
|
2930
|
+
icon: icon && ComponentIcon.COMPONENT_ICONS[icon] ? ComponentIcon.COMPONENT_ICONS[icon] : ComponentIcon.COMPONENT_ICONS.dashboard,
|
2931
|
+
children: accordionTitle
|
2932
|
+
}
|
2933
|
+
),
|
2934
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
|
2935
|
+
] }),
|
2936
|
+
/* @__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(
|
2937
|
+
designSystem.Grid.Item,
|
2938
|
+
{
|
2939
|
+
col: 12,
|
2940
|
+
s: 12,
|
2941
|
+
xs: 12,
|
2942
|
+
direction: "column",
|
2943
|
+
alignItems: "stretch",
|
2944
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
|
2945
|
+
const fieldName = `${name2}.${index$1}.${field.name}`;
|
2946
|
+
const fieldWithTranslatedLabel = {
|
2947
|
+
...field,
|
2948
|
+
label: formatMessage({
|
2949
|
+
id: `content-manager.components.${componentUid}.${field.name}`,
|
2950
|
+
defaultMessage: field.label
|
2951
|
+
})
|
2952
|
+
};
|
2953
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
2954
|
+
ResponsiveGridItem,
|
2955
|
+
{
|
2956
|
+
col: size,
|
2957
|
+
s: 12,
|
2958
|
+
xs: 12,
|
2959
|
+
direction: "column",
|
2960
|
+
alignItems: "stretch",
|
2961
|
+
children: children ? children({ ...fieldWithTranslatedLabel, name: fieldName }) : /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
|
2962
|
+
},
|
2963
|
+
fieldName
|
2964
|
+
);
|
2965
|
+
}) })
|
2966
|
+
},
|
2967
|
+
rowInd
|
2968
|
+
)) }) }) }) })
|
2969
|
+
] }) }) })
|
3200
2970
|
] });
|
3201
2971
|
};
|
3202
|
-
const
|
3203
|
-
|
3204
|
-
|
3205
|
-
|
3206
|
-
|
3207
|
-
|
3208
|
-
|
2972
|
+
const StyledBox = styledComponents.styled(designSystem.Box)`
|
2973
|
+
> div:first-child {
|
2974
|
+
box-shadow: ${({ theme }) => theme.shadows.tableShadow};
|
2975
|
+
}
|
2976
|
+
`;
|
2977
|
+
const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
|
2978
|
+
border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
|
2979
|
+
`;
|
2980
|
+
const Rectangle = styledComponents.styled(designSystem.Box)`
|
2981
|
+
width: ${({ theme }) => theme.spaces[2]};
|
2982
|
+
height: ${({ theme }) => theme.spaces[4]};
|
2983
|
+
`;
|
2984
|
+
const Preview$1 = styledComponents.styled.span`
|
2985
|
+
display: block;
|
2986
|
+
background-color: ${({ theme }) => theme.colors.primary100};
|
2987
|
+
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
2988
|
+
outline-offset: -1px;
|
2989
|
+
padding: ${({ theme }) => theme.spaces[6]};
|
2990
|
+
`;
|
2991
|
+
const ComponentContainer = styledComponents.styled(designSystem.Box)`
|
2992
|
+
list-style: none;
|
2993
|
+
padding: 0;
|
2994
|
+
margin: 0;
|
2995
|
+
`;
|
2996
|
+
const DynamicZoneLabel = ({
|
2997
|
+
hint,
|
2998
|
+
label,
|
2999
|
+
labelAction,
|
3000
|
+
name: name2,
|
3001
|
+
numberOfComponents = 0,
|
3002
|
+
required
|
3209
3003
|
}) => {
|
3210
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
3211
|
-
|
3004
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
3005
|
+
designSystem.Box,
|
3212
3006
|
{
|
3213
|
-
|
3214
|
-
|
3215
|
-
|
3007
|
+
paddingTop: 3,
|
3008
|
+
paddingBottom: 3,
|
3009
|
+
paddingRight: 4,
|
3010
|
+
paddingLeft: 4,
|
3011
|
+
borderRadius: "26px",
|
3216
3012
|
background: "neutral0",
|
3217
|
-
|
3218
|
-
|
3219
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, {
|
3220
|
-
/* @__PURE__ */ jsxRuntime.
|
3221
|
-
|
3222
|
-
|
3223
|
-
|
3224
|
-
|
3225
|
-
|
3226
|
-
|
3227
|
-
|
3228
|
-
|
3229
|
-
|
3013
|
+
shadow: "filterShadow",
|
3014
|
+
color: "neutral500",
|
3015
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
|
3016
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
|
3017
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
|
3018
|
+
label || name2,
|
3019
|
+
" "
|
3020
|
+
] }),
|
3021
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
|
3022
|
+
"(",
|
3023
|
+
numberOfComponents,
|
3024
|
+
")"
|
3025
|
+
] }),
|
3026
|
+
required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
|
3027
|
+
labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
|
3028
|
+
] }),
|
3029
|
+
hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
|
3230
3030
|
] })
|
3231
3031
|
}
|
3232
|
-
);
|
3032
|
+
) });
|
3233
3033
|
};
|
3234
|
-
const
|
3235
|
-
|
3236
|
-
|
3237
|
-
|
3238
|
-
|
3239
|
-
> circle {
|
3240
|
-
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger200 : theme.colors.neutral150};
|
3241
|
-
}
|
3242
|
-
> path {
|
3243
|
-
fill: ${({ theme, $hasError }) => $hasError ? theme.colors.danger600 : theme.colors.neutral600};
|
3034
|
+
const [DynamicZoneProvider, useDynamicZone] = strapiAdmin.createContext(
|
3035
|
+
"DynamicZone",
|
3036
|
+
{
|
3037
|
+
isInDynamicZone: false
|
3244
3038
|
}
|
3245
|
-
|
3246
|
-
const
|
3247
|
-
|
3248
|
-
|
3249
|
-
|
3250
|
-
|
3251
|
-
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3257
|
-
|
3258
|
-
|
3259
|
-
|
3260
|
-
|
3261
|
-
|
3262
|
-
|
3263
|
-
|
3039
|
+
);
|
3040
|
+
const DynamicZone = ({
|
3041
|
+
attribute,
|
3042
|
+
disabled: disabledProp,
|
3043
|
+
hint,
|
3044
|
+
label,
|
3045
|
+
labelAction,
|
3046
|
+
name: name2,
|
3047
|
+
required = false,
|
3048
|
+
children
|
3049
|
+
}) => {
|
3050
|
+
const { max = Infinity, min = -Infinity } = attribute ?? {};
|
3051
|
+
const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
|
3052
|
+
const [liveText, setLiveText] = React__namespace.useState("");
|
3053
|
+
const { components, isLoading } = index.useDoc();
|
3054
|
+
const disabled = disabledProp || isLoading;
|
3055
|
+
const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
|
3056
|
+
"DynamicZone",
|
3057
|
+
({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
|
3058
|
+
addFieldRow: addFieldRow2,
|
3059
|
+
removeFieldRow: removeFieldRow2,
|
3060
|
+
moveFieldRow: moveFieldRow2
|
3061
|
+
})
|
3062
|
+
);
|
3063
|
+
const { value = [], error } = strapiAdmin.useField(name2);
|
3064
|
+
const dynamicComponentsByCategory = React__namespace.useMemo(() => {
|
3065
|
+
return attribute.components.reduce((acc, componentUid) => {
|
3066
|
+
const { category, info } = components[componentUid] ?? { info: {} };
|
3067
|
+
const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
|
3068
|
+
if (!acc[category]) {
|
3069
|
+
acc[category] = [];
|
3264
3070
|
}
|
3071
|
+
acc[category] = [...acc[category], component];
|
3072
|
+
return acc;
|
3073
|
+
}, {});
|
3074
|
+
}, [attribute.components, components]);
|
3075
|
+
const { formatMessage } = reactIntl.useIntl();
|
3076
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
3077
|
+
const dynamicDisplayedComponentsLength = value.length;
|
3078
|
+
const handleAddComponent = (uid, position) => {
|
3079
|
+
setAddComponentIsOpen(false);
|
3080
|
+
const schema = components[uid];
|
3081
|
+
const form = index.createDefaultForm(schema, components);
|
3082
|
+
const transformations = pipe__default.default(index.transformDocument(schema, components), (data2) => ({
|
3083
|
+
...data2,
|
3084
|
+
__component: uid
|
3085
|
+
}));
|
3086
|
+
const data = transformations(form);
|
3087
|
+
addFieldRow(name2, data, position);
|
3088
|
+
};
|
3089
|
+
const handleClickOpenPicker = () => {
|
3090
|
+
if (dynamicDisplayedComponentsLength < max) {
|
3091
|
+
setAddComponentIsOpen((prev) => !prev);
|
3092
|
+
} else {
|
3093
|
+
toggleNotification({
|
3094
|
+
type: "info",
|
3095
|
+
message: formatMessage({
|
3096
|
+
id: index.getTranslation("components.notification.info.maximum-requirement")
|
3097
|
+
})
|
3098
|
+
});
|
3265
3099
|
}
|
3266
|
-
}
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3100
|
+
};
|
3101
|
+
const handleMoveComponent = (newIndex, currentIndex) => {
|
3102
|
+
setLiveText(
|
3103
|
+
formatMessage(
|
3104
|
+
{
|
3105
|
+
id: index.getTranslation("dnd.reorder"),
|
3106
|
+
defaultMessage: "{item}, moved. New position in list: {position}."
|
3107
|
+
},
|
3108
|
+
{
|
3109
|
+
item: `${name2}.${currentIndex}`,
|
3110
|
+
position: getItemPos(newIndex)
|
3111
|
+
}
|
3112
|
+
)
|
3113
|
+
);
|
3114
|
+
moveFieldRow(name2, currentIndex, newIndex);
|
3115
|
+
};
|
3116
|
+
const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
|
3117
|
+
const handleCancel = (index$1) => {
|
3118
|
+
setLiveText(
|
3119
|
+
formatMessage(
|
3120
|
+
{
|
3121
|
+
id: index.getTranslation("dnd.cancel-item"),
|
3122
|
+
defaultMessage: "{item}, dropped. Re-order cancelled."
|
3123
|
+
},
|
3124
|
+
{
|
3125
|
+
item: `${name2}.${index$1}`
|
3126
|
+
}
|
3127
|
+
)
|
3128
|
+
);
|
3129
|
+
};
|
3130
|
+
const handleGrabItem = (index$1) => {
|
3131
|
+
setLiveText(
|
3132
|
+
formatMessage(
|
3133
|
+
{
|
3134
|
+
id: index.getTranslation("dnd.grab-item"),
|
3135
|
+
defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
|
3136
|
+
},
|
3137
|
+
{
|
3138
|
+
item: `${name2}.${index$1}`,
|
3139
|
+
position: getItemPos(index$1)
|
3140
|
+
}
|
3141
|
+
)
|
3142
|
+
);
|
3143
|
+
};
|
3144
|
+
const handleDropItem = (index$1) => {
|
3145
|
+
setLiveText(
|
3146
|
+
formatMessage(
|
3147
|
+
{
|
3148
|
+
id: index.getTranslation("dnd.drop-item"),
|
3149
|
+
defaultMessage: `{item}, dropped. Final position in list: {position}.`
|
3150
|
+
},
|
3151
|
+
{
|
3152
|
+
item: `${name2}.${index$1}`,
|
3153
|
+
position: getItemPos(index$1)
|
3154
|
+
}
|
3155
|
+
)
|
3156
|
+
);
|
3157
|
+
};
|
3158
|
+
const handleRemoveComponent = (name22, currentIndex) => () => {
|
3159
|
+
removeFieldRow(name22, currentIndex);
|
3160
|
+
};
|
3161
|
+
const hasError = error !== void 0;
|
3162
|
+
const renderButtonLabel = () => {
|
3163
|
+
if (addComponentIsOpen) {
|
3164
|
+
return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
|
3270
3165
|
}
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3277
|
-
|
3166
|
+
if (hasError && dynamicDisplayedComponentsLength > max) {
|
3167
|
+
return formatMessage(
|
3168
|
+
{
|
3169
|
+
id: index.getTranslation(`components.DynamicZone.extra-components`),
|
3170
|
+
defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
|
3171
|
+
},
|
3172
|
+
{
|
3173
|
+
number: dynamicDisplayedComponentsLength - max
|
3174
|
+
}
|
3175
|
+
);
|
3278
3176
|
}
|
3279
|
-
|
3280
|
-
|
3281
|
-
|
3282
|
-
|
3283
|
-
|
3284
|
-
|
3285
|
-
|
3286
|
-
|
3287
|
-
|
3288
|
-
|
3289
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { variant, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: formatMessage({ id: category, defaultMessage: category }) }) }),
|
3290
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(Grid, { paddingTop: 4, paddingBottom: 4, paddingLeft: 3, paddingRight: 3, children: components.map(({ uid, displayName, icon }) => /* @__PURE__ */ jsxRuntime.jsx(
|
3291
|
-
ComponentBox,
|
3177
|
+
if (hasError && dynamicDisplayedComponentsLength < min) {
|
3178
|
+
return formatMessage(
|
3179
|
+
{
|
3180
|
+
id: index.getTranslation(`components.DynamicZone.missing-components`),
|
3181
|
+
defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
|
3182
|
+
},
|
3183
|
+
{ number: min - dynamicDisplayedComponentsLength }
|
3184
|
+
);
|
3185
|
+
}
|
3186
|
+
return formatMessage(
|
3292
3187
|
{
|
3293
|
-
|
3294
|
-
|
3295
|
-
background: "neutral100",
|
3296
|
-
justifyContent: "center",
|
3297
|
-
onClick: onAddComponent(uid),
|
3298
|
-
hasRadius: true,
|
3299
|
-
height: "8.4rem",
|
3300
|
-
shrink: 0,
|
3301
|
-
borderColor: "neutral200",
|
3302
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "center", justifyContent: "center", children: [
|
3303
|
-
/* @__PURE__ */ jsxRuntime.jsx(ComponentIcon.ComponentIcon, { color: "currentColor", background: "primary200", icon }),
|
3304
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", children: displayName })
|
3305
|
-
] })
|
3188
|
+
id: index.getTranslation("components.DynamicZone.add-component"),
|
3189
|
+
defaultMessage: "Add a component to {componentName}"
|
3306
3190
|
},
|
3307
|
-
|
3308
|
-
)
|
3309
|
-
] });
|
3310
|
-
};
|
3311
|
-
const Grid = styledComponents.styled(designSystem.Box)`
|
3312
|
-
display: grid;
|
3313
|
-
grid-template-columns: repeat(auto-fit, 14rem);
|
3314
|
-
grid-gap: ${({ theme }) => theme.spaces[1]};
|
3315
|
-
`;
|
3316
|
-
const ComponentBox = styledComponents.styled(designSystem.Flex)`
|
3317
|
-
color: ${({ theme }) => theme.colors.neutral600};
|
3318
|
-
cursor: pointer;
|
3319
|
-
|
3320
|
-
@media (prefers-reduced-motion: no-preference) {
|
3321
|
-
transition: color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
3322
|
-
}
|
3323
|
-
|
3324
|
-
&:focus,
|
3325
|
-
&:hover {
|
3326
|
-
border: 1px solid ${({ theme }) => theme.colors.primary200};
|
3327
|
-
background: ${({ theme }) => theme.colors.primary100};
|
3328
|
-
color: ${({ theme }) => theme.colors.primary600};
|
3329
|
-
}
|
3330
|
-
`;
|
3331
|
-
const ComponentPicker = ({
|
3332
|
-
dynamicComponentsByCategory = {},
|
3333
|
-
isOpen,
|
3334
|
-
onClickAddComponent
|
3335
|
-
}) => {
|
3336
|
-
const { formatMessage } = reactIntl.useIntl();
|
3337
|
-
const handleAddComponentToDz = (componentUid) => () => {
|
3338
|
-
onClickAddComponent(componentUid);
|
3191
|
+
{ componentName: label || name2 }
|
3192
|
+
);
|
3339
3193
|
};
|
3340
|
-
|
3341
|
-
|
3342
|
-
|
3343
|
-
|
3344
|
-
|
3345
|
-
|
3346
|
-
|
3347
|
-
|
3348
|
-
|
3349
|
-
|
3350
|
-
|
3351
|
-
|
3352
|
-
|
3353
|
-
|
3354
|
-
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3359
|
-
|
3360
|
-
|
3361
|
-
|
3362
|
-
|
3363
|
-
|
3364
|
-
|
3365
|
-
|
3366
|
-
|
3367
|
-
|
3368
|
-
|
3369
|
-
|
3370
|
-
|
3371
|
-
|
3194
|
+
const level = Relations.useComponent("DynamicZone", (state) => state.level);
|
3195
|
+
const ariaDescriptionId = React__namespace.useId();
|
3196
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
3197
|
+
dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
|
3198
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3199
|
+
DynamicZoneLabel,
|
3200
|
+
{
|
3201
|
+
hint,
|
3202
|
+
label,
|
3203
|
+
labelAction,
|
3204
|
+
name: name2,
|
3205
|
+
numberOfComponents: dynamicDisplayedComponentsLength,
|
3206
|
+
required
|
3207
|
+
}
|
3208
|
+
),
|
3209
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
|
3210
|
+
id: index.getTranslation("dnd.instructions"),
|
3211
|
+
defaultMessage: `Press spacebar to grab and re-order`
|
3212
|
+
}) }),
|
3213
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
3214
|
+
/* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
|
3215
|
+
Relations.ComponentProvider,
|
3216
|
+
{
|
3217
|
+
level: level + 1,
|
3218
|
+
uid: field.__component,
|
3219
|
+
id: field.id,
|
3220
|
+
type: "dynamiczone",
|
3221
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
3222
|
+
DynamicComponent,
|
3223
|
+
{
|
3224
|
+
disabled,
|
3225
|
+
name: name2,
|
3226
|
+
index: index2,
|
3227
|
+
componentUid: field.__component,
|
3228
|
+
onMoveComponent: handleMoveComponent,
|
3229
|
+
onRemoveComponentClick: handleRemoveComponent(name2, index2),
|
3230
|
+
onCancel: handleCancel,
|
3231
|
+
onDropItem: handleDropItem,
|
3232
|
+
onGrabItem: handleGrabItem,
|
3233
|
+
onAddComponent: handleAddComponent,
|
3234
|
+
dynamicComponentsByCategory,
|
3235
|
+
children
|
3236
|
+
}
|
3237
|
+
)
|
3238
|
+
},
|
3239
|
+
field.__temp_key__
|
3240
|
+
)) })
|
3241
|
+
] }),
|
3242
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
3243
|
+
AddComponentButton,
|
3244
|
+
{
|
3245
|
+
hasError,
|
3246
|
+
isDisabled: disabled,
|
3247
|
+
isOpen: addComponentIsOpen,
|
3248
|
+
onClick: handleClickOpenPicker,
|
3249
|
+
children: renderButtonLabel()
|
3250
|
+
}
|
3251
|
+
) }),
|
3252
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
3253
|
+
ComponentPicker,
|
3254
|
+
{
|
3255
|
+
dynamicComponentsByCategory,
|
3256
|
+
isOpen: addComponentIsOpen,
|
3257
|
+
onClickAddComponent: handleAddComponent
|
3258
|
+
}
|
3259
|
+
)
|
3260
|
+
] }) });
|
3372
3261
|
};
|
3373
3262
|
const NotAllowedInput = ({ hint, label, required, name: name2 }) => {
|
3374
3263
|
const { formatMessage } = reactIntl.useIntl();
|
@@ -3442,7 +3331,7 @@ const UIDInput = React__namespace.forwardRef(
|
|
3442
3331
|
const [showRegenerate, setShowRegenerate] = React__namespace.useState(false);
|
3443
3332
|
const isCloning = reactRouterDom.useMatch(index.CLONE_PATH) !== null;
|
3444
3333
|
const field = strapiAdmin.useField(name2);
|
3445
|
-
const debouncedValue =
|
3334
|
+
const debouncedValue = usePrev.useDebounce(field.value, 300);
|
3446
3335
|
const hasChanged = debouncedValue !== field.initialValue;
|
3447
3336
|
const { toggleNotification } = strapiAdmin.useNotification();
|
3448
3337
|
const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
|
@@ -4993,7 +4882,7 @@ const Wysiwyg = React__namespace.forwardRef(
|
|
4993
4882
|
const handleSelectAssets = (files) => {
|
4994
4883
|
const formattedFiles = files.map((f) => ({
|
4995
4884
|
alt: f.alternativeText || f.name,
|
4996
|
-
url:
|
4885
|
+
url: usePrev.prefixFileUrlWithBackendUrl(f.url),
|
4997
4886
|
mime: f.mime
|
4998
4887
|
}));
|
4999
4888
|
insertFile(editorRef, formattedFiles);
|
@@ -5049,626 +4938,680 @@ const Wysiwyg = React__namespace.forwardRef(
|
|
5049
4938
|
/* @__PURE__ */ jsxRuntime.jsx(MediaLibraryDialog, { onClose: handleToggleMediaLib, onSelectAssets: handleSelectAssets })
|
5050
4939
|
] });
|
5051
4940
|
}
|
5052
|
-
);
|
5053
|
-
const MemoizedWysiwyg = React__namespace.memo(Wysiwyg);
|
5054
|
-
const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
5055
|
-
const { id, document: document2, collectionType } = index.useDoc();
|
5056
|
-
const isFormDisabled = strapiAdmin.useForm("InputRenderer", (state) => state.disabled);
|
5057
|
-
const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
|
5058
|
-
const canCreateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
|
5059
|
-
const canReadFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
|
5060
|
-
const canUpdateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
|
5061
|
-
const canUserAction = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
|
5062
|
-
let idToCheck = id;
|
5063
|
-
if (collectionType === index.SINGLE_TYPES) {
|
5064
|
-
idToCheck = document2?.documentId;
|
4941
|
+
);
|
4942
|
+
const MemoizedWysiwyg = React__namespace.memo(Wysiwyg);
|
4943
|
+
const InputRenderer = ({ visible, hint: providedHint, ...props }) => {
|
4944
|
+
const { id, document: document2, collectionType } = index.useDoc();
|
4945
|
+
const isFormDisabled = strapiAdmin.useForm("InputRenderer", (state) => state.disabled);
|
4946
|
+
const isInDynamicZone = useDynamicZone("isInDynamicZone", (state) => state.isInDynamicZone);
|
4947
|
+
const canCreateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canCreateFields);
|
4948
|
+
const canReadFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canReadFields);
|
4949
|
+
const canUpdateFields = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUpdateFields);
|
4950
|
+
const canUserAction = index.useDocumentRBAC("InputRenderer", (rbac) => rbac.canUserAction);
|
4951
|
+
let idToCheck = id;
|
4952
|
+
if (collectionType === index.SINGLE_TYPES) {
|
4953
|
+
idToCheck = document2?.documentId;
|
4954
|
+
}
|
4955
|
+
const editableFields = idToCheck ? canUpdateFields : canCreateFields;
|
4956
|
+
const readableFields = idToCheck ? canReadFields : canCreateFields;
|
4957
|
+
const canUserReadField = canUserAction(props.name, readableFields, props.type);
|
4958
|
+
const canUserEditField = canUserAction(props.name, editableFields, props.type);
|
4959
|
+
const fields = strapiAdmin.useStrapiApp("InputRenderer", (app) => app.fields);
|
4960
|
+
const { lazyComponentStore } = useLazyComponents(
|
4961
|
+
attributeHasCustomFieldProperty(props.attribute) ? [props.attribute.customField] : void 0
|
4962
|
+
);
|
4963
|
+
const hint = useFieldHint(providedHint, props.attribute);
|
4964
|
+
const {
|
4965
|
+
edit: { components }
|
4966
|
+
} = index.useDocLayout();
|
4967
|
+
const field = strapiAdmin.useField(props.name);
|
4968
|
+
if (!visible) {
|
4969
|
+
return null;
|
4970
|
+
}
|
4971
|
+
if (!canUserReadField && !isInDynamicZone) {
|
4972
|
+
return /* @__PURE__ */ jsxRuntime.jsx(NotAllowedInput, { hint, ...props });
|
4973
|
+
}
|
4974
|
+
const fieldIsDisabled = !canUserEditField && !isInDynamicZone || props.disabled || isFormDisabled;
|
4975
|
+
if (attributeHasCustomFieldProperty(props.attribute)) {
|
4976
|
+
const CustomInput = lazyComponentStore[props.attribute.customField];
|
4977
|
+
if (CustomInput) {
|
4978
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, ...field, hint, disabled: fieldIsDisabled });
|
4979
|
+
}
|
4980
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
4981
|
+
strapiAdmin.InputRenderer,
|
4982
|
+
{
|
4983
|
+
...props,
|
4984
|
+
hint,
|
4985
|
+
type: props.attribute.customField,
|
4986
|
+
disabled: fieldIsDisabled
|
4987
|
+
}
|
4988
|
+
);
|
4989
|
+
}
|
4990
|
+
const addedInputTypes = Object.keys(fields);
|
4991
|
+
if (!attributeHasCustomFieldProperty(props.attribute) && addedInputTypes.includes(props.type)) {
|
4992
|
+
const CustomInput = fields[props.type];
|
4993
|
+
return /* @__PURE__ */ jsxRuntime.jsx(CustomInput, { ...props, hint, disabled: fieldIsDisabled });
|
4994
|
+
}
|
4995
|
+
switch (props.type) {
|
4996
|
+
case "blocks":
|
4997
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlocksInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
4998
|
+
case "component":
|
4999
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5000
|
+
MemoizedComponentInput,
|
5001
|
+
{
|
5002
|
+
...props,
|
5003
|
+
hint,
|
5004
|
+
layout: components[props.attribute.component].layout,
|
5005
|
+
disabled: fieldIsDisabled,
|
5006
|
+
children: (inputProps) => /* @__PURE__ */ jsxRuntime.jsx(InputRenderer, { ...inputProps })
|
5007
|
+
}
|
5008
|
+
);
|
5009
|
+
case "dynamiczone":
|
5010
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DynamicZone, { ...props, hint, disabled: fieldIsDisabled });
|
5011
|
+
case "relation":
|
5012
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Relations.MemoizedRelationsField, { ...props, hint, disabled: fieldIsDisabled });
|
5013
|
+
case "richtext":
|
5014
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
5015
|
+
case "uid":
|
5016
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
5017
|
+
case "enumeration":
|
5018
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5019
|
+
strapiAdmin.InputRenderer,
|
5020
|
+
{
|
5021
|
+
...props,
|
5022
|
+
hint,
|
5023
|
+
options: props.attribute.enum.map((value) => ({ value })),
|
5024
|
+
type: props.customField ? "custom-field" : props.type,
|
5025
|
+
disabled: fieldIsDisabled
|
5026
|
+
}
|
5027
|
+
);
|
5028
|
+
default:
|
5029
|
+
const { unique: _unique, mainField: _mainField, ...restProps } = props;
|
5030
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5031
|
+
strapiAdmin.InputRenderer,
|
5032
|
+
{
|
5033
|
+
...restProps,
|
5034
|
+
hint,
|
5035
|
+
type: props.customField ? "custom-field" : props.type,
|
5036
|
+
disabled: fieldIsDisabled
|
5037
|
+
}
|
5038
|
+
);
|
5039
|
+
}
|
5040
|
+
};
|
5041
|
+
const attributeHasCustomFieldProperty = (attribute) => "customField" in attribute && typeof attribute.customField === "string";
|
5042
|
+
const useFieldHint = (hint = void 0, attribute) => {
|
5043
|
+
const { formatMessage } = reactIntl.useIntl();
|
5044
|
+
const { maximum, minimum } = getMinMax(attribute);
|
5045
|
+
if (!maximum && !minimum) {
|
5046
|
+
return hint;
|
5065
5047
|
}
|
5066
|
-
const
|
5067
|
-
|
5068
|
-
|
5069
|
-
|
5070
|
-
|
5071
|
-
|
5072
|
-
|
5048
|
+
const units = !["biginteger", "integer", "number", "dynamiczone", "component"].includes(
|
5049
|
+
attribute.type
|
5050
|
+
) ? formatMessage(
|
5051
|
+
{
|
5052
|
+
id: "content-manager.form.Input.hint.character.unit",
|
5053
|
+
defaultMessage: "{maxValue, plural, one { character} other { characters}}"
|
5054
|
+
},
|
5055
|
+
{
|
5056
|
+
maxValue: Math.max(minimum || 0, maximum || 0)
|
5057
|
+
}
|
5058
|
+
) : null;
|
5059
|
+
const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
|
5060
|
+
return formatMessage(
|
5061
|
+
{
|
5062
|
+
id: "content-manager.form.Input.hint.text",
|
5063
|
+
defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
|
5064
|
+
},
|
5065
|
+
{
|
5066
|
+
min: minimum,
|
5067
|
+
max: maximum,
|
5068
|
+
description: hint,
|
5069
|
+
unit: units,
|
5070
|
+
divider: hasMinAndMax ? formatMessage({
|
5071
|
+
id: "content-manager.form.Input.hint.minMaxDivider",
|
5072
|
+
defaultMessage: " / "
|
5073
|
+
}) : null,
|
5074
|
+
br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
|
5075
|
+
}
|
5073
5076
|
);
|
5074
|
-
|
5075
|
-
|
5076
|
-
|
5077
|
-
|
5078
|
-
|
5079
|
-
|
5080
|
-
|
5077
|
+
};
|
5078
|
+
const getMinMax = (attribute) => {
|
5079
|
+
if ("min" in attribute || "max" in attribute) {
|
5080
|
+
return {
|
5081
|
+
maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
|
5082
|
+
minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
|
5083
|
+
};
|
5084
|
+
} else if ("maxLength" in attribute || "minLength" in attribute) {
|
5085
|
+
return { maximum: attribute.maxLength, minimum: attribute.minLength };
|
5086
|
+
} else {
|
5087
|
+
return { maximum: void 0, minimum: void 0 };
|
5081
5088
|
}
|
5082
|
-
|
5083
|
-
|
5089
|
+
};
|
5090
|
+
const MemoizedInputRenderer = React.memo(InputRenderer);
|
5091
|
+
const RESPONSIVE_CONTAINER_BREAKPOINTS = {
|
5092
|
+
sm: "27.5rem"
|
5093
|
+
// 440px
|
5094
|
+
};
|
5095
|
+
const ResponsiveGridRoot = styledComponents.styled(designSystem.Grid.Root)`
|
5096
|
+
container-type: inline-size;
|
5097
|
+
`;
|
5098
|
+
const ResponsiveGridItem = styledComponents.styled(designSystem.Grid.Item)`
|
5099
|
+
grid-column: span 12;
|
5100
|
+
|
5101
|
+
@container (min-width: ${RESPONSIVE_CONTAINER_BREAKPOINTS.sm}) {
|
5102
|
+
${({ col }) => col && `grid-column: span ${col};`}
|
5084
5103
|
}
|
5085
|
-
|
5086
|
-
|
5087
|
-
|
5088
|
-
|
5089
|
-
|
5104
|
+
`;
|
5105
|
+
const FormLayout = ({ layout }) => {
|
5106
|
+
const { formatMessage } = reactIntl.useIntl();
|
5107
|
+
const { model } = index.useDoc();
|
5108
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((panel, index2) => {
|
5109
|
+
if (panel.some((row) => row.some((field) => field.type === "dynamiczone"))) {
|
5110
|
+
const [row] = panel;
|
5111
|
+
const [field] = row;
|
5112
|
+
const fieldWithTranslatedLabel = {
|
5113
|
+
...field,
|
5114
|
+
label: formatMessage({
|
5115
|
+
id: `content-manager.content-types.${model}.${field.name}`,
|
5116
|
+
defaultMessage: field.label
|
5117
|
+
})
|
5118
|
+
};
|
5119
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, s: 12, xs: 12, direction: "column", alignItems: "stretch", children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel }) }) }, field.name);
|
5090
5120
|
}
|
5091
5121
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
5092
|
-
|
5122
|
+
designSystem.Box,
|
5093
5123
|
{
|
5094
|
-
|
5095
|
-
|
5096
|
-
|
5097
|
-
|
5124
|
+
hasRadius: true,
|
5125
|
+
background: "neutral0",
|
5126
|
+
shadow: "tableShadow",
|
5127
|
+
paddingLeft: 6,
|
5128
|
+
paddingRight: 6,
|
5129
|
+
paddingTop: 6,
|
5130
|
+
paddingBottom: 6,
|
5131
|
+
borderColor: "neutral150",
|
5132
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: panel.map((row, gridRowIndex) => /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
|
5133
|
+
const fieldWithTranslatedLabel = {
|
5134
|
+
...field,
|
5135
|
+
label: formatMessage({
|
5136
|
+
id: `content-manager.content-types.${model}.${field.name}`,
|
5137
|
+
defaultMessage: field.label
|
5138
|
+
})
|
5139
|
+
};
|
5140
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5141
|
+
ResponsiveGridItem,
|
5142
|
+
{
|
5143
|
+
col: size,
|
5144
|
+
s: 12,
|
5145
|
+
xs: 12,
|
5146
|
+
direction: "column",
|
5147
|
+
alignItems: "stretch",
|
5148
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel })
|
5149
|
+
},
|
5150
|
+
field.name
|
5151
|
+
);
|
5152
|
+
}) }, gridRowIndex)) })
|
5153
|
+
},
|
5154
|
+
index2
|
5155
|
+
);
|
5156
|
+
}) });
|
5157
|
+
};
|
5158
|
+
const NonRepeatableComponent = ({
|
5159
|
+
attribute,
|
5160
|
+
name: name2,
|
5161
|
+
children,
|
5162
|
+
layout
|
5163
|
+
}) => {
|
5164
|
+
const { formatMessage } = reactIntl.useIntl();
|
5165
|
+
const { value } = strapiAdmin.useField(name2);
|
5166
|
+
const level = Relations.useComponent("NonRepeatableComponent", (state) => state.level);
|
5167
|
+
const isNested = level > 0;
|
5168
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Relations.ComponentProvider, { id: value?.id, uid: attribute.component, level: level + 1, type: "component", children: /* @__PURE__ */ jsxRuntime.jsx(
|
5169
|
+
designSystem.Box,
|
5170
|
+
{
|
5171
|
+
background: "neutral100",
|
5172
|
+
paddingLeft: 6,
|
5173
|
+
paddingRight: 6,
|
5174
|
+
paddingTop: 6,
|
5175
|
+
paddingBottom: 6,
|
5176
|
+
hasRadius: isNested,
|
5177
|
+
borderColor: isNested ? "neutral200" : void 0,
|
5178
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: layout.map((row, index2) => {
|
5179
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
|
5180
|
+
const completeFieldName = `${name2}.${field.name}`;
|
5181
|
+
const translatedLabel = formatMessage({
|
5182
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
5183
|
+
defaultMessage: field.label
|
5184
|
+
});
|
5185
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5186
|
+
ResponsiveGridItem,
|
5187
|
+
{
|
5188
|
+
col: size,
|
5189
|
+
s: 12,
|
5190
|
+
xs: 12,
|
5191
|
+
direction: "column",
|
5192
|
+
alignItems: "stretch",
|
5193
|
+
children: children({ ...field, label: translatedLabel, name: completeFieldName })
|
5194
|
+
},
|
5195
|
+
completeFieldName
|
5196
|
+
);
|
5197
|
+
}) }, index2);
|
5198
|
+
}) })
|
5199
|
+
}
|
5200
|
+
) });
|
5201
|
+
};
|
5202
|
+
const RepeatableComponent = ({
|
5203
|
+
attribute,
|
5204
|
+
disabled,
|
5205
|
+
name: name2,
|
5206
|
+
mainField,
|
5207
|
+
children,
|
5208
|
+
layout
|
5209
|
+
}) => {
|
5210
|
+
const { toggleNotification } = strapiAdmin.useNotification();
|
5211
|
+
const { formatMessage } = reactIntl.useIntl();
|
5212
|
+
const { search: searchString } = reactRouterDom.useLocation();
|
5213
|
+
const search = React__namespace.useMemo(() => new URLSearchParams(searchString), [searchString]);
|
5214
|
+
const { components } = index.useDoc();
|
5215
|
+
const {
|
5216
|
+
value = [],
|
5217
|
+
error,
|
5218
|
+
rawError
|
5219
|
+
} = strapiAdmin.useField(name2);
|
5220
|
+
const addFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.addFieldRow);
|
5221
|
+
const moveFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.moveFieldRow);
|
5222
|
+
const removeFieldRow = strapiAdmin.useForm("RepeatableComponent", (state) => state.removeFieldRow);
|
5223
|
+
const { max = Infinity } = attribute;
|
5224
|
+
const [collapseToOpen, setCollapseToOpen] = React__namespace.useState("");
|
5225
|
+
const [liveText, setLiveText] = React__namespace.useState("");
|
5226
|
+
React__namespace.useEffect(() => {
|
5227
|
+
const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;
|
5228
|
+
const hasNestedValue = value && Array.isArray(value) && value.length > 0;
|
5229
|
+
if (hasNestedErrors && hasNestedValue) {
|
5230
|
+
const errorOpenItems = rawError.map((_, idx) => {
|
5231
|
+
return value[idx] ? value[idx].__temp_key__ : null;
|
5232
|
+
}).filter((value2) => !!value2);
|
5233
|
+
if (errorOpenItems && errorOpenItems.length > 0) {
|
5234
|
+
setCollapseToOpen((collapseToOpen2) => {
|
5235
|
+
if (!errorOpenItems.includes(collapseToOpen2)) {
|
5236
|
+
return errorOpenItems[0];
|
5237
|
+
}
|
5238
|
+
return collapseToOpen2;
|
5239
|
+
});
|
5240
|
+
}
|
5241
|
+
}
|
5242
|
+
}, [rawError, value]);
|
5243
|
+
const componentTmpKeyWithFocussedField = React__namespace.useMemo(() => {
|
5244
|
+
if (search.has("field")) {
|
5245
|
+
const fieldParam = search.get("field");
|
5246
|
+
if (!fieldParam) {
|
5247
|
+
return void 0;
|
5248
|
+
}
|
5249
|
+
const [, path] = fieldParam.split(`${name2}.`);
|
5250
|
+
if (objects.getIn(value, path, void 0) !== void 0) {
|
5251
|
+
const [subpath] = path.split(".");
|
5252
|
+
return objects.getIn(value, subpath, void 0)?.__temp_key__;
|
5098
5253
|
}
|
5254
|
+
}
|
5255
|
+
return void 0;
|
5256
|
+
}, [search, name2, value]);
|
5257
|
+
const prevValue = usePrev.usePrev(value);
|
5258
|
+
React__namespace.useEffect(() => {
|
5259
|
+
if (prevValue && prevValue.length < value.length) {
|
5260
|
+
setCollapseToOpen(value[value.length - 1].__temp_key__);
|
5261
|
+
}
|
5262
|
+
}, [value, prevValue]);
|
5263
|
+
React__namespace.useEffect(() => {
|
5264
|
+
if (typeof componentTmpKeyWithFocussedField === "string") {
|
5265
|
+
setCollapseToOpen(componentTmpKeyWithFocussedField);
|
5266
|
+
}
|
5267
|
+
}, [componentTmpKeyWithFocussedField]);
|
5268
|
+
const toggleCollapses = () => {
|
5269
|
+
setCollapseToOpen("");
|
5270
|
+
};
|
5271
|
+
const handleClick = () => {
|
5272
|
+
if (value.length < max) {
|
5273
|
+
const schema = components[attribute.component];
|
5274
|
+
const form = index.createDefaultForm(schema, components);
|
5275
|
+
const data = index.transformDocument(schema, components)(form);
|
5276
|
+
addFieldRow(name2, data);
|
5277
|
+
} else if (value.length >= max) {
|
5278
|
+
toggleNotification({
|
5279
|
+
type: "info",
|
5280
|
+
message: formatMessage({
|
5281
|
+
id: index.getTranslation("components.notification.info.maximum-requirement")
|
5282
|
+
})
|
5283
|
+
});
|
5284
|
+
}
|
5285
|
+
};
|
5286
|
+
const handleMoveComponentField = (newIndex, currentIndex) => {
|
5287
|
+
setLiveText(
|
5288
|
+
formatMessage(
|
5289
|
+
{
|
5290
|
+
id: index.getTranslation("dnd.reorder"),
|
5291
|
+
defaultMessage: "{item}, moved. New position in list: {position}."
|
5292
|
+
},
|
5293
|
+
{
|
5294
|
+
item: `${name2}.${currentIndex}`,
|
5295
|
+
position: getItemPos(newIndex)
|
5296
|
+
}
|
5297
|
+
)
|
5099
5298
|
);
|
5100
|
-
|
5101
|
-
|
5102
|
-
|
5103
|
-
|
5104
|
-
|
5105
|
-
}
|
5106
|
-
|
5107
|
-
|
5108
|
-
|
5109
|
-
case "component":
|
5110
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
5111
|
-
MemoizedComponentInput,
|
5299
|
+
moveFieldRow(name2, currentIndex, newIndex);
|
5300
|
+
};
|
5301
|
+
const handleValueChange = (key) => {
|
5302
|
+
setCollapseToOpen(key);
|
5303
|
+
};
|
5304
|
+
const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
|
5305
|
+
const handleCancel = (index$1) => {
|
5306
|
+
setLiveText(
|
5307
|
+
formatMessage(
|
5112
5308
|
{
|
5113
|
-
|
5114
|
-
|
5115
|
-
|
5116
|
-
|
5117
|
-
|
5309
|
+
id: index.getTranslation("dnd.cancel-item"),
|
5310
|
+
defaultMessage: "{item}, dropped. Re-order cancelled."
|
5311
|
+
},
|
5312
|
+
{
|
5313
|
+
item: `${name2}.${index$1}`
|
5118
5314
|
}
|
5119
|
-
)
|
5120
|
-
|
5121
|
-
|
5122
|
-
|
5123
|
-
|
5124
|
-
|
5125
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MemoizedWysiwyg, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
5126
|
-
case "uid":
|
5127
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MemoizedUIDInput, { ...props, hint, type: props.type, disabled: fieldIsDisabled });
|
5128
|
-
case "enumeration":
|
5129
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
5130
|
-
strapiAdmin.InputRenderer,
|
5315
|
+
)
|
5316
|
+
);
|
5317
|
+
};
|
5318
|
+
const handleGrabItem = (index$1) => {
|
5319
|
+
setLiveText(
|
5320
|
+
formatMessage(
|
5131
5321
|
{
|
5132
|
-
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5322
|
+
id: index.getTranslation("dnd.grab-item"),
|
5323
|
+
defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
|
5324
|
+
},
|
5325
|
+
{
|
5326
|
+
item: `${name2}.${index$1}`,
|
5327
|
+
position: getItemPos(index$1)
|
5137
5328
|
}
|
5138
|
-
)
|
5139
|
-
|
5140
|
-
|
5141
|
-
|
5142
|
-
|
5329
|
+
)
|
5330
|
+
);
|
5331
|
+
};
|
5332
|
+
const handleDropItem = (index$1) => {
|
5333
|
+
setLiveText(
|
5334
|
+
formatMessage(
|
5143
5335
|
{
|
5144
|
-
|
5145
|
-
|
5146
|
-
|
5147
|
-
|
5336
|
+
id: index.getTranslation("dnd.drop-item"),
|
5337
|
+
defaultMessage: `{item}, dropped. Final position in list: {position}.`
|
5338
|
+
},
|
5339
|
+
{
|
5340
|
+
item: `${name2}.${index$1}`,
|
5341
|
+
position: getItemPos(index$1)
|
5148
5342
|
}
|
5149
|
-
)
|
5343
|
+
)
|
5344
|
+
);
|
5345
|
+
};
|
5346
|
+
const ariaDescriptionId = React__namespace.useId();
|
5347
|
+
const level = Relations.useComponent("RepeatableComponent", (state) => state.level);
|
5348
|
+
if (value.length === 0) {
|
5349
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleClick });
|
5150
5350
|
}
|
5351
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { hasRadius: true, children: [
|
5352
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
|
5353
|
+
id: index.getTranslation("dnd.instructions"),
|
5354
|
+
defaultMessage: `Press spacebar to grab and re-order`
|
5355
|
+
}) }),
|
5356
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
5357
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
5358
|
+
AccordionRoot,
|
5359
|
+
{
|
5360
|
+
$error: error,
|
5361
|
+
value: collapseToOpen,
|
5362
|
+
onValueChange: handleValueChange,
|
5363
|
+
"aria-describedby": ariaDescriptionId,
|
5364
|
+
children: [
|
5365
|
+
value.map(({ __temp_key__: key, id }, index2) => {
|
5366
|
+
const nameWithIndex = `${name2}.${index2}`;
|
5367
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5368
|
+
Relations.ComponentProvider,
|
5369
|
+
{
|
5370
|
+
id,
|
5371
|
+
uid: attribute.component,
|
5372
|
+
level: level + 1,
|
5373
|
+
type: "repeatable",
|
5374
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
5375
|
+
Component,
|
5376
|
+
{
|
5377
|
+
disabled,
|
5378
|
+
name: nameWithIndex,
|
5379
|
+
attribute,
|
5380
|
+
index: index2,
|
5381
|
+
mainField,
|
5382
|
+
onMoveItem: handleMoveComponentField,
|
5383
|
+
onDeleteComponent: () => {
|
5384
|
+
removeFieldRow(name2, index2);
|
5385
|
+
toggleCollapses();
|
5386
|
+
},
|
5387
|
+
toggleCollapses,
|
5388
|
+
onCancel: handleCancel,
|
5389
|
+
onDropItem: handleDropItem,
|
5390
|
+
onGrabItem: handleGrabItem,
|
5391
|
+
__temp_key__: key,
|
5392
|
+
children: layout.map((row, index22) => {
|
5393
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveGridRoot, { gap: 4, children: row.map(({ size, ...field }) => {
|
5394
|
+
const completeFieldName = `${nameWithIndex}.${field.name}`;
|
5395
|
+
const translatedLabel = formatMessage({
|
5396
|
+
id: `content-manager.components.${attribute.component}.${field.name}`,
|
5397
|
+
defaultMessage: field.label
|
5398
|
+
});
|
5399
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
5400
|
+
ResponsiveGridItem,
|
5401
|
+
{
|
5402
|
+
col: size,
|
5403
|
+
s: 12,
|
5404
|
+
xs: 12,
|
5405
|
+
direction: "column",
|
5406
|
+
alignItems: "stretch",
|
5407
|
+
children: children({
|
5408
|
+
...field,
|
5409
|
+
label: translatedLabel,
|
5410
|
+
name: completeFieldName
|
5411
|
+
})
|
5412
|
+
},
|
5413
|
+
completeFieldName
|
5414
|
+
);
|
5415
|
+
}) }, index22);
|
5416
|
+
})
|
5417
|
+
}
|
5418
|
+
)
|
5419
|
+
},
|
5420
|
+
key
|
5421
|
+
);
|
5422
|
+
}),
|
5423
|
+
/* @__PURE__ */ jsxRuntime.jsx(TextButtonCustom, { disabled, onClick: handleClick, startIcon: /* @__PURE__ */ jsxRuntime.jsx(Icons.Plus, {}), children: formatMessage({
|
5424
|
+
id: index.getTranslation("containers.EditView.add.new-entry"),
|
5425
|
+
defaultMessage: "Add an entry"
|
5426
|
+
}) })
|
5427
|
+
]
|
5428
|
+
}
|
5429
|
+
)
|
5430
|
+
] });
|
5151
5431
|
};
|
5152
|
-
const
|
5153
|
-
|
5154
|
-
|
5155
|
-
|
5156
|
-
|
5157
|
-
|
5158
|
-
|
5159
|
-
|
5160
|
-
|
5161
|
-
)
|
5162
|
-
|
5163
|
-
|
5164
|
-
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
|
5169
|
-
) : null;
|
5170
|
-
const hasMinAndMax = typeof minimum === "number" && typeof maximum === "number";
|
5171
|
-
return formatMessage(
|
5172
|
-
{
|
5173
|
-
id: "content-manager.form.Input.hint.text",
|
5174
|
-
defaultMessage: "{min, select, undefined {} other {min. {min}}}{divider}{max, select, undefined {} other {max. {max}}}{unit}{br}{description}"
|
5175
|
-
},
|
5176
|
-
{
|
5177
|
-
min: minimum,
|
5178
|
-
max: maximum,
|
5179
|
-
description: hint,
|
5180
|
-
unit: units,
|
5181
|
-
divider: hasMinAndMax ? formatMessage({
|
5182
|
-
id: "content-manager.form.Input.hint.minMaxDivider",
|
5183
|
-
defaultMessage: " / "
|
5184
|
-
}) : null,
|
5185
|
-
br: /* @__PURE__ */ jsxRuntime.jsx("br", {})
|
5432
|
+
const AccordionRoot = styledComponents.styled(designSystem.Accordion.Root)`
|
5433
|
+
border: 1px solid
|
5434
|
+
${({ theme, $error }) => $error ? theme.colors.danger600 : theme.colors.neutral200};
|
5435
|
+
`;
|
5436
|
+
const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
|
5437
|
+
width: 100%;
|
5438
|
+
display: flex;
|
5439
|
+
justify-content: center;
|
5440
|
+
border-top: 1px solid ${({ theme }) => theme.colors.neutral200};
|
5441
|
+
padding-inline: ${(props) => props.theme.spaces[6]};
|
5442
|
+
padding-block: ${(props) => props.theme.spaces[3]};
|
5443
|
+
|
5444
|
+
&:not([disabled]) {
|
5445
|
+
cursor: pointer;
|
5446
|
+
|
5447
|
+
&:hover {
|
5448
|
+
background-color: ${(props) => props.theme.colors.primary100};
|
5186
5449
|
}
|
5187
|
-
);
|
5188
|
-
};
|
5189
|
-
const getMinMax = (attribute) => {
|
5190
|
-
if ("min" in attribute || "max" in attribute) {
|
5191
|
-
return {
|
5192
|
-
maximum: !Number.isNaN(Number(attribute.max)) ? Number(attribute.max) : void 0,
|
5193
|
-
minimum: !Number.isNaN(Number(attribute.min)) ? Number(attribute.min) : void 0
|
5194
|
-
};
|
5195
|
-
} else if ("maxLength" in attribute || "minLength" in attribute) {
|
5196
|
-
return { maximum: attribute.maxLength, minimum: attribute.minLength };
|
5197
|
-
} else {
|
5198
|
-
return { maximum: void 0, minimum: void 0 };
|
5199
5450
|
}
|
5200
|
-
|
5201
|
-
|
5202
|
-
|
5203
|
-
|
5451
|
+
|
5452
|
+
span {
|
5453
|
+
font-weight: 600;
|
5454
|
+
font-size: 1.4rem;
|
5455
|
+
line-height: 2.4rem;
|
5456
|
+
}
|
5457
|
+
|
5458
|
+
@media (prefers-reduced-motion: no-preference) {
|
5459
|
+
transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};
|
5460
|
+
}
|
5461
|
+
`;
|
5462
|
+
const Component = ({
|
5204
5463
|
disabled,
|
5205
5464
|
index: index$1,
|
5206
5465
|
name: name2,
|
5207
|
-
|
5208
|
-
|
5209
|
-
|
5210
|
-
|
5211
|
-
|
5212
|
-
|
5213
|
-
|
5466
|
+
mainField = {
|
5467
|
+
name: "id",
|
5468
|
+
type: "integer"
|
5469
|
+
},
|
5470
|
+
children,
|
5471
|
+
onDeleteComponent,
|
5472
|
+
toggleCollapses,
|
5473
|
+
__temp_key__,
|
5474
|
+
...dragProps
|
5214
5475
|
}) => {
|
5215
5476
|
const { formatMessage } = reactIntl.useIntl();
|
5216
|
-
const
|
5217
|
-
|
5218
|
-
|
5219
|
-
|
5220
|
-
const
|
5221
|
-
const { mainField } = components[componentUid]?.settings ?? { mainField: "id" };
|
5222
|
-
const mainFieldValue = objects.getIn(formValues, `${name2}.${index$1}.${mainField}`);
|
5223
|
-
const displayedValue = mainField === "id" || !mainFieldValue ? "" : String(mainFieldValue).trim();
|
5224
|
-
const mainValue = displayedValue.length > 0 ? `- ${displayedValue}` : displayedValue;
|
5225
|
-
return mainValue;
|
5226
|
-
}, [componentUid, components, formValues, name2, index$1]);
|
5227
|
-
const { icon, displayName } = React__namespace.useMemo(() => {
|
5228
|
-
const [category] = componentUid.split(".");
|
5229
|
-
const { icon: icon2, displayName: displayName2 } = (dynamicComponentsByCategory[category] ?? []).find(
|
5230
|
-
(component) => component.uid === componentUid
|
5231
|
-
) ?? { icon: null, displayName: null };
|
5232
|
-
return { icon: icon2, displayName: displayName2 };
|
5233
|
-
}, [componentUid, dynamicComponentsByCategory]);
|
5477
|
+
const displayValue = strapiAdmin.useForm("RepeatableComponent", (state) => {
|
5478
|
+
return objects.getIn(state.values, [...name2.split("."), mainField.name]);
|
5479
|
+
});
|
5480
|
+
const accordionRef = React__namespace.useRef(null);
|
5481
|
+
const componentKey = name2.split(".").slice(0, -1).join(".");
|
5234
5482
|
const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] = useDragAndDrop.useDragAndDrop(!disabled, {
|
5235
|
-
type: `${useDragAndDrop.ItemTypes.
|
5483
|
+
type: `${useDragAndDrop.ItemTypes.COMPONENT}_${componentKey}`,
|
5236
5484
|
index: index$1,
|
5237
5485
|
item: {
|
5238
5486
|
index: index$1,
|
5239
|
-
displayedValue:
|
5240
|
-
icon
|
5487
|
+
displayedValue: displayValue
|
5241
5488
|
},
|
5242
|
-
|
5243
|
-
|
5244
|
-
|
5245
|
-
|
5489
|
+
onStart() {
|
5490
|
+
toggleCollapses();
|
5491
|
+
},
|
5492
|
+
...dragProps
|
5246
5493
|
});
|
5247
5494
|
React__namespace.useEffect(() => {
|
5248
5495
|
dragPreviewRef(reactDndHtml5Backend.getEmptyImage(), { captureDraggingState: false });
|
5249
5496
|
}, [dragPreviewRef, index$1]);
|
5250
|
-
const
|
5251
|
-
const
|
5252
|
-
|
5253
|
-
|
5254
|
-
|
5255
|
-
|
5256
|
-
|
5257
|
-
|
5258
|
-
|
5259
|
-
|
5260
|
-
|
5261
|
-
designSystem.IconButton,
|
5262
|
-
{
|
5263
|
-
variant: "ghost",
|
5264
|
-
label: formatMessage(
|
5497
|
+
const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
|
5498
|
+
const composedBoxRefs = designSystem.useComposedRefs(
|
5499
|
+
boxRef,
|
5500
|
+
dropRef
|
5501
|
+
);
|
5502
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: isDragging ? /* @__PURE__ */ jsxRuntime.jsx(Preview, {}) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { ref: composedBoxRefs, value: __temp_key__, children: [
|
5503
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
|
5504
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Trigger, { children: displayValue }),
|
5505
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Actions, { children: [
|
5506
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
5507
|
+
designSystem.IconButton,
|
5265
5508
|
{
|
5266
|
-
|
5267
|
-
|
5268
|
-
|
5269
|
-
|
5509
|
+
variant: "ghost",
|
5510
|
+
onClick: onDeleteComponent,
|
5511
|
+
label: formatMessage({
|
5512
|
+
id: index.getTranslation("containers.Edit.delete"),
|
5513
|
+
defaultMessage: "Delete"
|
5514
|
+
}),
|
5515
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
|
5516
|
+
}
|
5270
5517
|
),
|
5271
|
-
onClick: onRemoveComponentClick,
|
5272
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
|
5273
|
-
}
|
5274
|
-
),
|
5275
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
5276
|
-
designSystem.IconButton,
|
5277
|
-
{
|
5278
|
-
variant: "ghost",
|
5279
|
-
onClick: (e) => e.stopPropagation(),
|
5280
|
-
"data-handler-id": handlerId,
|
5281
|
-
ref: dragRef,
|
5282
|
-
label: formatMessage({
|
5283
|
-
id: index.getTranslation("components.DragHandle-label"),
|
5284
|
-
defaultMessage: "Drag"
|
5285
|
-
}),
|
5286
|
-
onKeyDown: handleKeyDown,
|
5287
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
|
5288
|
-
}
|
5289
|
-
),
|
5290
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Root, { children: [
|
5291
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Trigger, { size: "S", endIcon: null, paddingLeft: 2, paddingRight: 2, children: [
|
5292
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icons.More, { "aria-hidden": true, focusable: false }),
|
5293
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { tag: "span", children: formatMessage({
|
5294
|
-
id: index.getTranslation("components.DynamicZone.more-actions"),
|
5295
|
-
defaultMessage: "More actions"
|
5296
|
-
}) })
|
5297
|
-
] }),
|
5298
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.Content, { children: [
|
5299
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
|
5300
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
|
5301
|
-
id: index.getTranslation("components.DynamicZone.add-item-above"),
|
5302
|
-
defaultMessage: "Add component above"
|
5303
|
-
}) }),
|
5304
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
5305
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
|
5306
|
-
components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1), children: displayName2 }, componentUid))
|
5307
|
-
] }, category)) })
|
5308
|
-
] }),
|
5309
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Menu.SubRoot, { children: [
|
5310
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubTrigger, { children: formatMessage({
|
5311
|
-
id: index.getTranslation("components.DynamicZone.add-item-below"),
|
5312
|
-
defaultMessage: "Add component below"
|
5313
|
-
}) }),
|
5314
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.SubContent, { children: Object.entries(dynamicComponentsByCategory).map(([category, components2]) => /* @__PURE__ */ jsxRuntime.jsxs(React__namespace.Fragment, { children: [
|
5315
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Menu.Label, { children: category }),
|
5316
|
-
components2.map(({ displayName: displayName2, uid }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.MenuItem, { onSelect: () => onAddComponent(uid, index$1 + 1), children: displayName2 }, componentUid))
|
5317
|
-
] }, category)) })
|
5318
|
-
] })
|
5319
|
-
] })
|
5320
|
-
] })
|
5321
|
-
] });
|
5322
|
-
const accordionTitle = title ? `${displayName} ${title}` : displayName;
|
5323
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ComponentContainer, { tag: "li", width: "100%", children: [
|
5324
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(Rectangle, { background: "neutral200" }) }),
|
5325
|
-
/* @__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: [
|
5326
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Header, { children: [
|
5327
5518
|
/* @__PURE__ */ jsxRuntime.jsx(
|
5328
|
-
designSystem.
|
5519
|
+
designSystem.IconButton,
|
5329
5520
|
{
|
5330
|
-
|
5331
|
-
|
5521
|
+
ref: composedAccordionRefs,
|
5522
|
+
variant: "ghost",
|
5523
|
+
onClick: (e) => e.stopPropagation(),
|
5524
|
+
"data-handler-id": handlerId,
|
5525
|
+
label: formatMessage({
|
5526
|
+
id: index.getTranslation("components.DragHandle-label"),
|
5527
|
+
defaultMessage: "Drag"
|
5528
|
+
}),
|
5529
|
+
onKeyDown: handleKeyDown,
|
5530
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Drag, {})
|
5332
5531
|
}
|
5333
|
-
)
|
5334
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Actions, { children: accordionActions })
|
5335
|
-
] }),
|
5336
|
-
/* @__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(
|
5337
|
-
designSystem.Grid.Item,
|
5338
|
-
{
|
5339
|
-
col: 12,
|
5340
|
-
s: 12,
|
5341
|
-
xs: 12,
|
5342
|
-
direction: "column",
|
5343
|
-
alignItems: "stretch",
|
5344
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 4, children: row.map(({ size, ...field }) => {
|
5345
|
-
const fieldName = `${name2}.${index$1}.${field.name}`;
|
5346
|
-
const fieldWithTranslatedLabel = {
|
5347
|
-
...field,
|
5348
|
-
label: formatMessage({
|
5349
|
-
id: `content-manager.components.${componentUid}.${field.name}`,
|
5350
|
-
defaultMessage: field.label
|
5351
|
-
})
|
5352
|
-
};
|
5353
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
5354
|
-
designSystem.Grid.Item,
|
5355
|
-
{
|
5356
|
-
col: size,
|
5357
|
-
s: 12,
|
5358
|
-
xs: 12,
|
5359
|
-
direction: "column",
|
5360
|
-
alignItems: "stretch",
|
5361
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(MemoizedInputRenderer, { ...fieldWithTranslatedLabel, name: fieldName })
|
5362
|
-
},
|
5363
|
-
fieldName
|
5364
|
-
);
|
5365
|
-
}) })
|
5366
|
-
},
|
5367
|
-
rowInd
|
5368
|
-
)) }) }) }) })
|
5369
|
-
] }) }) })
|
5370
|
-
] });
|
5371
|
-
};
|
5372
|
-
const StyledBox = styledComponents.styled(designSystem.Box)`
|
5373
|
-
> div:first-child {
|
5374
|
-
box-shadow: ${({ theme }) => theme.shadows.tableShadow};
|
5375
|
-
}
|
5376
|
-
`;
|
5377
|
-
const AccordionContentRadius = styledComponents.styled(designSystem.Box)`
|
5378
|
-
border-radius: 0 0 ${({ theme }) => theme.spaces[1]} ${({ theme }) => theme.spaces[1]};
|
5379
|
-
`;
|
5380
|
-
const Rectangle = styledComponents.styled(designSystem.Box)`
|
5381
|
-
width: ${({ theme }) => theme.spaces[2]};
|
5382
|
-
height: ${({ theme }) => theme.spaces[4]};
|
5383
|
-
`;
|
5384
|
-
const Preview = styledComponents.styled.span`
|
5385
|
-
display: block;
|
5386
|
-
background-color: ${({ theme }) => theme.colors.primary100};
|
5387
|
-
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
5388
|
-
outline-offset: -1px;
|
5389
|
-
padding: ${({ theme }) => theme.spaces[6]};
|
5390
|
-
`;
|
5391
|
-
const ComponentContainer = styledComponents.styled(designSystem.Box)`
|
5392
|
-
list-style: none;
|
5393
|
-
padding: 0;
|
5394
|
-
margin: 0;
|
5395
|
-
`;
|
5396
|
-
const DynamicZoneLabel = ({
|
5397
|
-
hint,
|
5398
|
-
label,
|
5399
|
-
labelAction,
|
5400
|
-
name: name2,
|
5401
|
-
numberOfComponents = 0,
|
5402
|
-
required
|
5403
|
-
}) => {
|
5404
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
5405
|
-
designSystem.Box,
|
5406
|
-
{
|
5407
|
-
paddingTop: 3,
|
5408
|
-
paddingBottom: 3,
|
5409
|
-
paddingRight: 4,
|
5410
|
-
paddingLeft: 4,
|
5411
|
-
borderRadius: "26px",
|
5412
|
-
background: "neutral0",
|
5413
|
-
shadow: "filterShadow",
|
5414
|
-
color: "neutral500",
|
5415
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", justifyContent: "center", children: [
|
5416
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { maxWidth: "35.6rem", children: [
|
5417
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", ellipsis: true, children: [
|
5418
|
-
label || name2,
|
5419
|
-
" "
|
5420
|
-
] }),
|
5421
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", fontWeight: "bold", children: [
|
5422
|
-
"(",
|
5423
|
-
numberOfComponents,
|
5424
|
-
")"
|
5425
|
-
] }),
|
5426
|
-
required && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { textColor: "danger600", children: "*" }),
|
5427
|
-
labelAction && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingLeft: 1, children: labelAction })
|
5428
|
-
] }),
|
5429
|
-
hint && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingTop: 1, maxWidth: "35.6rem", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", ellipsis: true, children: hint }) })
|
5532
|
+
)
|
5430
5533
|
] })
|
5431
|
-
}
|
5432
|
-
|
5534
|
+
] }),
|
5535
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
5536
|
+
designSystem.Flex,
|
5537
|
+
{
|
5538
|
+
direction: "column",
|
5539
|
+
alignItems: "stretch",
|
5540
|
+
background: "neutral100",
|
5541
|
+
padding: 6,
|
5542
|
+
gap: 6,
|
5543
|
+
children
|
5544
|
+
}
|
5545
|
+
) })
|
5546
|
+
] }) });
|
5547
|
+
};
|
5548
|
+
const Preview = () => {
|
5549
|
+
return /* @__PURE__ */ jsxRuntime.jsx(StyledSpan, { tag: "span", padding: 6, background: "primary100" });
|
5433
5550
|
};
|
5434
|
-
const
|
5435
|
-
|
5436
|
-
{
|
5437
|
-
|
5438
|
-
|
5439
|
-
|
5440
|
-
const DynamicZone = ({
|
5441
|
-
attribute,
|
5442
|
-
disabled: disabledProp,
|
5443
|
-
hint,
|
5551
|
+
const StyledSpan = styledComponents.styled(designSystem.Box)`
|
5552
|
+
display: block;
|
5553
|
+
outline: 1px dashed ${({ theme }) => theme.colors.primary500};
|
5554
|
+
outline-offset: -1px;
|
5555
|
+
`;
|
5556
|
+
const ComponentInput = ({
|
5444
5557
|
label,
|
5445
|
-
|
5558
|
+
required,
|
5446
5559
|
name: name2,
|
5447
|
-
|
5560
|
+
attribute,
|
5561
|
+
disabled,
|
5562
|
+
labelAction,
|
5563
|
+
...props
|
5448
5564
|
}) => {
|
5449
|
-
const { max = Infinity, min = -Infinity } = attribute ?? {};
|
5450
|
-
const [addComponentIsOpen, setAddComponentIsOpen] = React__namespace.useState(false);
|
5451
|
-
const [liveText, setLiveText] = React__namespace.useState("");
|
5452
|
-
const { components, isLoading } = index.useDoc();
|
5453
|
-
const disabled = disabledProp || isLoading;
|
5454
|
-
const { addFieldRow, removeFieldRow, moveFieldRow } = strapiAdmin.useForm(
|
5455
|
-
"DynamicZone",
|
5456
|
-
({ addFieldRow: addFieldRow2, removeFieldRow: removeFieldRow2, moveFieldRow: moveFieldRow2 }) => ({
|
5457
|
-
addFieldRow: addFieldRow2,
|
5458
|
-
removeFieldRow: removeFieldRow2,
|
5459
|
-
moveFieldRow: moveFieldRow2
|
5460
|
-
})
|
5461
|
-
);
|
5462
|
-
const { value = [], error } = strapiAdmin.useField(name2);
|
5463
|
-
const dynamicComponentsByCategory = React__namespace.useMemo(() => {
|
5464
|
-
return attribute.components.reduce((acc, componentUid) => {
|
5465
|
-
const { category, info } = components[componentUid] ?? { info: {} };
|
5466
|
-
const component = { uid: componentUid, displayName: info.displayName, icon: info.icon };
|
5467
|
-
if (!acc[category]) {
|
5468
|
-
acc[category] = [];
|
5469
|
-
}
|
5470
|
-
acc[category] = [...acc[category], component];
|
5471
|
-
return acc;
|
5472
|
-
}, {});
|
5473
|
-
}, [attribute.components, components]);
|
5474
5565
|
const { formatMessage } = reactIntl.useIntl();
|
5475
|
-
const
|
5476
|
-
const
|
5477
|
-
const
|
5478
|
-
|
5479
|
-
const schema = components[
|
5480
|
-
const form = createDefaultForm(schema, components);
|
5481
|
-
const
|
5482
|
-
|
5483
|
-
__component: uid
|
5484
|
-
}));
|
5485
|
-
const data = transformations(form);
|
5486
|
-
addFieldRow(name2, data, position);
|
5487
|
-
};
|
5488
|
-
const handleClickOpenPicker = () => {
|
5489
|
-
if (dynamicDisplayedComponentsLength < max) {
|
5490
|
-
setAddComponentIsOpen((prev) => !prev);
|
5491
|
-
} else {
|
5492
|
-
toggleNotification({
|
5493
|
-
type: "info",
|
5494
|
-
message: formatMessage({
|
5495
|
-
id: index.getTranslation("components.notification.info.maximum-requirement")
|
5496
|
-
})
|
5497
|
-
});
|
5498
|
-
}
|
5499
|
-
};
|
5500
|
-
const handleMoveComponent = (newIndex, currentIndex) => {
|
5501
|
-
setLiveText(
|
5502
|
-
formatMessage(
|
5503
|
-
{
|
5504
|
-
id: index.getTranslation("dnd.reorder"),
|
5505
|
-
defaultMessage: "{item}, moved. New position in list: {position}."
|
5506
|
-
},
|
5507
|
-
{
|
5508
|
-
item: `${name2}.${currentIndex}`,
|
5509
|
-
position: getItemPos(newIndex)
|
5510
|
-
}
|
5511
|
-
)
|
5512
|
-
);
|
5513
|
-
moveFieldRow(name2, currentIndex, newIndex);
|
5514
|
-
};
|
5515
|
-
const getItemPos = (index2) => `${index2 + 1} of ${value.length}`;
|
5516
|
-
const handleCancel = (index$1) => {
|
5517
|
-
setLiveText(
|
5518
|
-
formatMessage(
|
5519
|
-
{
|
5520
|
-
id: index.getTranslation("dnd.cancel-item"),
|
5521
|
-
defaultMessage: "{item}, dropped. Re-order cancelled."
|
5522
|
-
},
|
5523
|
-
{
|
5524
|
-
item: `${name2}.${index$1}`
|
5525
|
-
}
|
5526
|
-
)
|
5527
|
-
);
|
5528
|
-
};
|
5529
|
-
const handleGrabItem = (index$1) => {
|
5530
|
-
setLiveText(
|
5531
|
-
formatMessage(
|
5532
|
-
{
|
5533
|
-
id: index.getTranslation("dnd.grab-item"),
|
5534
|
-
defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`
|
5535
|
-
},
|
5536
|
-
{
|
5537
|
-
item: `${name2}.${index$1}`,
|
5538
|
-
position: getItemPos(index$1)
|
5539
|
-
}
|
5540
|
-
)
|
5541
|
-
);
|
5566
|
+
const field = strapiAdmin.useField(name2);
|
5567
|
+
const showResetComponent = !attribute.repeatable && field.value && !disabled;
|
5568
|
+
const { components } = index.useDoc();
|
5569
|
+
const handleInitialisationClick = () => {
|
5570
|
+
const schema = components[attribute.component];
|
5571
|
+
const form = index.createDefaultForm(schema, components);
|
5572
|
+
const data = index.transformDocument(schema, components)(form);
|
5573
|
+
field.onChange(name2, data);
|
5542
5574
|
};
|
5543
|
-
|
5544
|
-
|
5545
|
-
|
5546
|
-
|
5547
|
-
|
5548
|
-
|
5549
|
-
|
5575
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Root, { error: field.error, required, children: [
|
5576
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", children: [
|
5577
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Field.Label, { action: labelAction, children: [
|
5578
|
+
label,
|
5579
|
+
attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
5580
|
+
" (",
|
5581
|
+
Array.isArray(field.value) ? field.value.length : 0,
|
5582
|
+
")"
|
5583
|
+
] })
|
5584
|
+
] }),
|
5585
|
+
showResetComponent && /* @__PURE__ */ jsxRuntime.jsx(
|
5586
|
+
designSystem.IconButton,
|
5550
5587
|
{
|
5551
|
-
|
5552
|
-
|
5588
|
+
label: formatMessage({
|
5589
|
+
id: index.getTranslation("components.reset-entry"),
|
5590
|
+
defaultMessage: "Reset Entry"
|
5591
|
+
}),
|
5592
|
+
variant: "ghost",
|
5593
|
+
onClick: () => {
|
5594
|
+
field.onChange(name2, null);
|
5595
|
+
},
|
5596
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icons.Trash, {})
|
5553
5597
|
}
|
5554
5598
|
)
|
5555
|
-
);
|
5556
|
-
};
|
5557
|
-
const handleRemoveComponent = (name22, currentIndex) => () => {
|
5558
|
-
removeFieldRow(name22, currentIndex);
|
5559
|
-
};
|
5560
|
-
const hasError = error !== void 0;
|
5561
|
-
const renderButtonLabel = () => {
|
5562
|
-
if (addComponentIsOpen) {
|
5563
|
-
return formatMessage({ id: "app.utils.close-label", defaultMessage: "Close" });
|
5564
|
-
}
|
5565
|
-
if (hasError && dynamicDisplayedComponentsLength > max) {
|
5566
|
-
return formatMessage(
|
5567
|
-
{
|
5568
|
-
id: index.getTranslation(`components.DynamicZone.extra-components`),
|
5569
|
-
defaultMessage: "There {number, plural, =0 {are # extra components} one {is # extra component} other {are # extra components}}"
|
5570
|
-
},
|
5571
|
-
{
|
5572
|
-
number: dynamicDisplayedComponentsLength - max
|
5573
|
-
}
|
5574
|
-
);
|
5575
|
-
}
|
5576
|
-
if (hasError && dynamicDisplayedComponentsLength < min) {
|
5577
|
-
return formatMessage(
|
5578
|
-
{
|
5579
|
-
id: index.getTranslation(`components.DynamicZone.missing-components`),
|
5580
|
-
defaultMessage: "There {number, plural, =0 {are # missing components} one {is # missing component} other {are # missing components}}"
|
5581
|
-
},
|
5582
|
-
{ number: min - dynamicDisplayedComponentsLength }
|
5583
|
-
);
|
5584
|
-
}
|
5585
|
-
return formatMessage(
|
5586
|
-
{
|
5587
|
-
id: index.getTranslation("components.DynamicZone.add-component"),
|
5588
|
-
defaultMessage: "Add a component to {componentName}"
|
5589
|
-
},
|
5590
|
-
{ componentName: label || name2 }
|
5591
|
-
);
|
5592
|
-
};
|
5593
|
-
const level = Relations.useComponent("DynamicZone", (state) => state.level);
|
5594
|
-
const ariaDescriptionId = React__namespace.useId();
|
5595
|
-
return /* @__PURE__ */ jsxRuntime.jsx(DynamicZoneProvider, { isInDynamicZone: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
5596
|
-
dynamicDisplayedComponentsLength > 0 && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
|
5597
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
5598
|
-
DynamicZoneLabel,
|
5599
|
-
{
|
5600
|
-
hint,
|
5601
|
-
label,
|
5602
|
-
labelAction,
|
5603
|
-
name: name2,
|
5604
|
-
numberOfComponents: dynamicDisplayedComponentsLength,
|
5605
|
-
required
|
5606
|
-
}
|
5607
|
-
),
|
5608
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { id: ariaDescriptionId, children: formatMessage({
|
5609
|
-
id: index.getTranslation("dnd.instructions"),
|
5610
|
-
defaultMessage: `Press spacebar to grab and re-order`
|
5611
|
-
}) }),
|
5612
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { "aria-live": "assertive", children: liveText }),
|
5613
|
-
/* @__PURE__ */ jsxRuntime.jsx("ol", { "aria-describedby": ariaDescriptionId, children: value.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(
|
5614
|
-
Relations.ComponentProvider,
|
5615
|
-
{
|
5616
|
-
level: level + 1,
|
5617
|
-
uid: field.__component,
|
5618
|
-
id: field.id,
|
5619
|
-
type: "dynamiczone",
|
5620
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
5621
|
-
DynamicComponent,
|
5622
|
-
{
|
5623
|
-
disabled,
|
5624
|
-
name: name2,
|
5625
|
-
index: index2,
|
5626
|
-
componentUid: field.__component,
|
5627
|
-
onMoveComponent: handleMoveComponent,
|
5628
|
-
onRemoveComponentClick: handleRemoveComponent(name2, index2),
|
5629
|
-
onCancel: handleCancel,
|
5630
|
-
onDropItem: handleDropItem,
|
5631
|
-
onGrabItem: handleGrabItem,
|
5632
|
-
onAddComponent: handleAddComponent,
|
5633
|
-
dynamicComponentsByCategory
|
5634
|
-
}
|
5635
|
-
)
|
5636
|
-
},
|
5637
|
-
field.__temp_key__
|
5638
|
-
)) })
|
5639
5599
|
] }),
|
5640
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
5641
|
-
|
5642
|
-
|
5643
|
-
|
5644
|
-
|
5645
|
-
isOpen: addComponentIsOpen,
|
5646
|
-
onClick: handleClickOpenPicker,
|
5647
|
-
children: renderButtonLabel()
|
5648
|
-
}
|
5649
|
-
) }),
|
5650
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
5651
|
-
ComponentPicker,
|
5652
|
-
{
|
5653
|
-
dynamicComponentsByCategory,
|
5654
|
-
isOpen: addComponentIsOpen,
|
5655
|
-
onClickAddComponent: handleAddComponent
|
5656
|
-
}
|
5657
|
-
)
|
5658
|
-
] }) });
|
5600
|
+
!attribute.repeatable && !field.value && /* @__PURE__ */ jsxRuntime.jsx(Initializer, { disabled, name: name2, onClick: handleInitialisationClick }),
|
5601
|
+
!attribute.repeatable && field.value ? /* @__PURE__ */ jsxRuntime.jsx(NonRepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }) : null,
|
5602
|
+
attribute.repeatable && /* @__PURE__ */ jsxRuntime.jsx(RepeatableComponent, { attribute, name: name2, disabled, ...props, children: props.children }),
|
5603
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
5604
|
+
] });
|
5659
5605
|
};
|
5606
|
+
const MemoizedComponentInput = React__namespace.memo(ComponentInput);
|
5660
5607
|
exports.DynamicZone = DynamicZone;
|
5608
|
+
exports.FormLayout = FormLayout;
|
5661
5609
|
exports.MemoizedBlocksInput = MemoizedBlocksInput;
|
5662
5610
|
exports.MemoizedComponentInput = MemoizedComponentInput;
|
5663
|
-
exports.MemoizedInputRenderer = MemoizedInputRenderer;
|
5664
5611
|
exports.MemoizedUIDInput = MemoizedUIDInput;
|
5665
5612
|
exports.MemoizedWysiwyg = MemoizedWysiwyg;
|
5666
5613
|
exports.NotAllowedInput = NotAllowedInput;
|
5667
|
-
exports.createDefaultForm = createDefaultForm;
|
5668
|
-
exports.prepareTempKeys = prepareTempKeys;
|
5669
|
-
exports.removeFieldsThatDontExistOnSchema = removeFieldsThatDontExistOnSchema;
|
5670
|
-
exports.transformDocument = transformDocument;
|
5671
5614
|
exports.useDynamicZone = useDynamicZone;
|
5672
5615
|
exports.useFieldHint = useFieldHint;
|
5673
5616
|
exports.useLazyComponents = useLazyComponents;
|
5674
|
-
//# sourceMappingURL=
|
5617
|
+
//# sourceMappingURL=Input-BwOibhc3.js.map
|