@strapi/content-manager 5.33.2 → 5.33.4
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/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.js +23 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.mjs +23 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js +14 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs +14 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Image.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.js +157 -7
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.mjs +154 -5
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js +28 -20
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs +25 -17
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +6 -3
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +7 -4
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +12 -12
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +13 -13
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.js +4 -8
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.mjs +4 -7
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/types.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js +2 -12
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs +2 -12
- package/dist/admin/pages/EditView/components/FormInputs/Component/NonRepeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +48 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +49 -2
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +47 -13
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +49 -15
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +1 -0
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +10 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +10 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js +5 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs +5 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +6 -2
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +6 -2
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/pages/EditView/utils/data.js +22 -0
- package/dist/admin/pages/EditView/utils/data.js.map +1 -1
- package/dist/admin/pages/EditView/utils/data.mjs +22 -1
- package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +9 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withStrapiSchema.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.d.ts +2 -4
- package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +2 -1
- package/dist/admin/src/pages/EditView/utils/data.d.ts +6 -1
- package/package.json +9 -9
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.js +0 -17
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.js.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.mjs +0 -15
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.mjs.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.js +0 -75
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.js.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.mjs +0 -73
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.mjs.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.js +0 -88
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.js.map +0 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.mjs +0 -84
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/utils/links.mjs.map +0 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withImages.d.ts +0 -11
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/plugins/withLinks.d.ts +0 -9
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/links.d.ts +0 -12
|
@@ -4,15 +4,11 @@
|
|
|
4
4
|
const getEntries = (object)=>Object.entries(object);
|
|
5
5
|
// Wrap Object.keys to get the correct types
|
|
6
6
|
const getKeys = (object)=>Object.keys(object);
|
|
7
|
-
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
const isListNode = (element)=>{
|
|
11
|
-
return element.type === 'list';
|
|
12
|
-
};
|
|
7
|
+
function isNonNullable(value) {
|
|
8
|
+
return value !== null && value !== undefined;
|
|
9
|
+
}
|
|
13
10
|
|
|
14
11
|
exports.getEntries = getEntries;
|
|
15
12
|
exports.getKeys = getKeys;
|
|
16
|
-
exports.
|
|
17
|
-
exports.isListNode = isListNode;
|
|
13
|
+
exports.isNonNullable = isNonNullable;
|
|
18
14
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.ts"],"sourcesContent":["import type { Element, Node } from 'slate';\n\ntype Block<T extends Element['type']> = Extract<Node, { type: T }>;\n\n// Wrap Object.entries to get the correct types\nconst getEntries = <T extends object>(object: T) =>\n Object.entries(object) as [keyof T, T[keyof T]][];\n\n// Wrap Object.keys to get the correct types\nconst getKeys = <T extends object>(object: T) => Object.keys(object) as (keyof T)[];\n\nfunction isNonNullable<T>(value: T): value is NonNullable<T> {\n return value !== null && value !== undefined;\n}\n\nexport { type Block, getEntries, getKeys, isNonNullable };\n"],"names":["getEntries","object","Object","entries","getKeys","keys","isNonNullable","value","undefined"],"mappings":";;AAIA;AACA,MAAMA,UAAa,GAAA,CAAmBC,MACpCC,GAAAA,MAAAA,CAAOC,OAAO,CAACF,MAAAA;AAEjB;AACA,MAAMG,OAAU,GAAA,CAAmBH,MAAcC,GAAAA,MAAAA,CAAOG,IAAI,CAACJ,MAAAA;AAE7D,SAASK,cAAiBC,KAAQ,EAAA;IAChC,OAAOA,KAAAA,KAAU,QAAQA,KAAUC,KAAAA,SAAAA;AACrC;;;;;;"}
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
const getEntries = (object)=>Object.entries(object);
|
|
3
3
|
// Wrap Object.keys to get the correct types
|
|
4
4
|
const getKeys = (object)=>Object.keys(object);
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
const isListNode = (element)=>{
|
|
9
|
-
return element.type === 'list';
|
|
10
|
-
};
|
|
5
|
+
function isNonNullable(value) {
|
|
6
|
+
return value !== null && value !== undefined;
|
|
7
|
+
}
|
|
11
8
|
|
|
12
|
-
export { getEntries, getKeys,
|
|
9
|
+
export { getEntries, getKeys, isNonNullable };
|
|
13
10
|
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"types.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/utils/types.ts"],"sourcesContent":["import type { Element, Node } from 'slate';\n\ntype Block<T extends Element['type']> = Extract<Node, { type: T }>;\n\n// Wrap Object.entries to get the correct types\nconst getEntries = <T extends object>(object: T) =>\n Object.entries(object) as [keyof T, T[keyof T]][];\n\n// Wrap Object.keys to get the correct types\nconst getKeys = <T extends object>(object: T) => Object.keys(object) as (keyof T)[];\n\nfunction isNonNullable<T>(value: T): value is NonNullable<T> {\n return value !== null && value !== undefined;\n}\n\nexport { type Block, getEntries, getKeys, isNonNullable };\n"],"names":["getEntries","object","Object","entries","getKeys","keys","isNonNullable","value","undefined"],"mappings":"AAIA;AACA,MAAMA,UAAa,GAAA,CAAmBC,MACpCC,GAAAA,MAAAA,CAAOC,OAAO,CAACF,MAAAA;AAEjB;AACA,MAAMG,OAAU,GAAA,CAAmBH,MAAcC,GAAAA,MAAAA,CAAOG,IAAI,CAACJ,MAAAA;AAE7D,SAASK,cAAiBC,KAAQ,EAAA;IAChC,OAAOA,KAAAA,KAAU,QAAQA,KAAUC,KAAAA,SAAAA;AACrC;;;;"}
|
|
@@ -14,7 +14,7 @@ const NonRepeatableComponent = ({ attribute, name, children, layout })=>{
|
|
|
14
14
|
const level = ComponentContext.useComponent('NonRepeatableComponent', (state)=>state.level);
|
|
15
15
|
const isNested = level > 0;
|
|
16
16
|
const { currentDocument } = useDocumentContext.useDocumentContext('NonRepeatableComponent');
|
|
17
|
-
|
|
17
|
+
strapiAdmin.createRulesEngine();
|
|
18
18
|
return /*#__PURE__*/ jsxRuntime.jsx(ComponentContext.ComponentProvider, {
|
|
19
19
|
id: value?.id,
|
|
20
20
|
uid: attribute.component,
|
|
@@ -33,19 +33,9 @@ const NonRepeatableComponent = ({ attribute, name, children, layout })=>{
|
|
|
33
33
|
alignItems: "stretch",
|
|
34
34
|
gap: 6,
|
|
35
35
|
children: layout.map((row, index)=>{
|
|
36
|
-
const visibleFields = row.filter(({ ...field })=>{
|
|
37
|
-
const condition = field.attribute.conditions?.visible;
|
|
38
|
-
if (condition) {
|
|
39
|
-
return rulesEngine.evaluate(condition, value);
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
42
|
-
});
|
|
43
|
-
if (visibleFields.length === 0) {
|
|
44
|
-
return null; // Skip rendering the entire grid row
|
|
45
|
-
}
|
|
46
36
|
return /*#__PURE__*/ jsxRuntime.jsx(FormLayout.ResponsiveGridRoot, {
|
|
47
37
|
gap: 4,
|
|
48
|
-
children:
|
|
38
|
+
children: row.map(({ size, ...field })=>{
|
|
49
39
|
/**
|
|
50
40
|
* Layouts are built from schemas so they don't understand the complete
|
|
51
41
|
* schema tree, for components we append the parent name to the field name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonRepeatable.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Component/NonRepeatable.tsx"],"sourcesContent":["import { useField, createRulesEngine } from '@strapi/admin/strapi-admin';\nimport { Box, Flex } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { ComponentProvider, useComponent } from '../ComponentContext';\n\nimport type { ComponentInputProps } from './Input';\n\ntype NonRepeatableComponentProps = Omit<ComponentInputProps, 'required' | 'label'>;\n\nconst NonRepeatableComponent = ({\n attribute,\n name,\n children,\n layout,\n}: NonRepeatableComponentProps) => {\n const { formatMessage } = useIntl();\n const { value } = useField(name);\n const level = useComponent('NonRepeatableComponent', (state) => state.level);\n const isNested = level > 0;\n const { currentDocument } = useDocumentContext('NonRepeatableComponent');\n const rulesEngine = createRulesEngine();\n\n return (\n <ComponentProvider id={value?.id} uid={attribute.component} level={level + 1} type=\"component\">\n <Box\n background={'neutral100'}\n paddingLeft={6}\n paddingRight={6}\n paddingTop={6}\n paddingBottom={6}\n hasRadius={isNested}\n borderColor={isNested ? 'neutral200' : undefined}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((row, index) => {\n
|
|
1
|
+
{"version":3,"file":"NonRepeatable.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Component/NonRepeatable.tsx"],"sourcesContent":["import { useField, createRulesEngine } from '@strapi/admin/strapi-admin';\nimport { Box, Flex } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { ComponentProvider, useComponent } from '../ComponentContext';\n\nimport type { ComponentInputProps } from './Input';\n\ntype NonRepeatableComponentProps = Omit<ComponentInputProps, 'required' | 'label'>;\n\nconst NonRepeatableComponent = ({\n attribute,\n name,\n children,\n layout,\n}: NonRepeatableComponentProps) => {\n const { formatMessage } = useIntl();\n const { value } = useField(name);\n const level = useComponent('NonRepeatableComponent', (state) => state.level);\n const isNested = level > 0;\n const { currentDocument } = useDocumentContext('NonRepeatableComponent');\n const rulesEngine = createRulesEngine();\n\n return (\n <ComponentProvider id={value?.id} uid={attribute.component} level={level + 1} type=\"component\">\n <Box\n background={'neutral100'}\n paddingLeft={6}\n paddingRight={6}\n paddingTop={6}\n paddingBottom={6}\n hasRadius={isNested}\n borderColor={isNested ? 'neutral200' : undefined}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((row, index) => {\n return (\n <ResponsiveGridRoot gap={4} key={index}>\n {row.map(({ size, ...field }) => {\n /**\n * Layouts are built from schemas so they don't understand the complete\n * schema tree, for components we append the parent name to the field name\n * because this is the structure for the data & permissions also understand\n * the nesting involved.\n */\n const completeFieldName = `${name}.${field.name}`;\n\n const translatedLabel = formatMessage({\n id: `content-manager.components.${attribute.component}.${field.name}`,\n defaultMessage: field.label,\n });\n\n return (\n <ResponsiveGridItem\n col={size}\n key={completeFieldName}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {children({\n ...field,\n label: translatedLabel,\n name: completeFieldName,\n document: currentDocument,\n })}\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n );\n })}\n </Flex>\n </Box>\n </ComponentProvider>\n );\n};\n\nexport { NonRepeatableComponent };\nexport type { NonRepeatableComponentProps };\n"],"names":["NonRepeatableComponent","attribute","name","children","layout","formatMessage","useIntl","value","useField","level","useComponent","state","isNested","currentDocument","useDocumentContext","createRulesEngine","_jsx","ComponentProvider","id","uid","component","type","Box","background","paddingLeft","paddingRight","paddingTop","paddingBottom","hasRadius","borderColor","undefined","Flex","direction","alignItems","gap","map","row","index","ResponsiveGridRoot","size","field","completeFieldName","translatedLabel","defaultMessage","label","ResponsiveGridItem","col","s","xs","document"],"mappings":";;;;;;;;;;AAYMA,MAAAA,sBAAAA,GAAyB,CAAC,EAC9BC,SAAS,EACTC,IAAI,EACJC,QAAQ,EACRC,MAAM,EACsB,GAAA;IAC5B,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGC,oBAASN,CAAAA,IAAAA,CAAAA;AAC3B,IAAA,M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BAAkBrC,aAAc,CAAA;gCACpCa,EAAI,EAAA,CAAC,2BAA2B,EAAEjB,SAAUmB,CAAAA,SAAS,CAAC,CAAC,EAAEoB,KAAMtC,CAAAA,IAAI,CAAE,CAAA;AACrEyC,gCAAAA,cAAAA,EAAgBH,MAAMI;AACxB,6BAAA,CAAA;AAEA,4BAAA,qBACE5B,cAAC6B,CAAAA,6BAAAA,EAAAA;gCACCC,GAAKP,EAAAA,IAAAA;gCAELQ,CAAG,EAAA,EAAA;gCACHC,EAAI,EAAA,EAAA;gCACJhB,SAAU,EAAA,QAAA;gCACVC,UAAW,EAAA,SAAA;0CAEV9B,QAAS,CAAA;AACR,oCAAA,GAAGqC,KAAK;oCACRI,KAAOF,EAAAA,eAAAA;oCACPxC,IAAMuC,EAAAA,iBAAAA;oCACNQ,QAAUpC,EAAAA;AACZ,iCAAA;AAXK4B,6BAAAA,EAAAA,iBAAAA,CAAAA;AAcX,yBAAA;AAhC+BJ,qBAAAA,EAAAA,KAAAA,CAAAA;AAmCrC,iBAAA;;;;AAKV;;;;"}
|
|
@@ -12,7 +12,7 @@ const NonRepeatableComponent = ({ attribute, name, children, layout })=>{
|
|
|
12
12
|
const level = useComponent('NonRepeatableComponent', (state)=>state.level);
|
|
13
13
|
const isNested = level > 0;
|
|
14
14
|
const { currentDocument } = useDocumentContext('NonRepeatableComponent');
|
|
15
|
-
|
|
15
|
+
createRulesEngine();
|
|
16
16
|
return /*#__PURE__*/ jsx(ComponentProvider, {
|
|
17
17
|
id: value?.id,
|
|
18
18
|
uid: attribute.component,
|
|
@@ -31,19 +31,9 @@ const NonRepeatableComponent = ({ attribute, name, children, layout })=>{
|
|
|
31
31
|
alignItems: "stretch",
|
|
32
32
|
gap: 6,
|
|
33
33
|
children: layout.map((row, index)=>{
|
|
34
|
-
const visibleFields = row.filter(({ ...field })=>{
|
|
35
|
-
const condition = field.attribute.conditions?.visible;
|
|
36
|
-
if (condition) {
|
|
37
|
-
return rulesEngine.evaluate(condition, value);
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
});
|
|
41
|
-
if (visibleFields.length === 0) {
|
|
42
|
-
return null; // Skip rendering the entire grid row
|
|
43
|
-
}
|
|
44
34
|
return /*#__PURE__*/ jsx(ResponsiveGridRoot, {
|
|
45
35
|
gap: 4,
|
|
46
|
-
children:
|
|
36
|
+
children: row.map(({ size, ...field })=>{
|
|
47
37
|
/**
|
|
48
38
|
* Layouts are built from schemas so they don't understand the complete
|
|
49
39
|
* schema tree, for components we append the parent name to the field name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NonRepeatable.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Component/NonRepeatable.tsx"],"sourcesContent":["import { useField, createRulesEngine } from '@strapi/admin/strapi-admin';\nimport { Box, Flex } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { ComponentProvider, useComponent } from '../ComponentContext';\n\nimport type { ComponentInputProps } from './Input';\n\ntype NonRepeatableComponentProps = Omit<ComponentInputProps, 'required' | 'label'>;\n\nconst NonRepeatableComponent = ({\n attribute,\n name,\n children,\n layout,\n}: NonRepeatableComponentProps) => {\n const { formatMessage } = useIntl();\n const { value } = useField(name);\n const level = useComponent('NonRepeatableComponent', (state) => state.level);\n const isNested = level > 0;\n const { currentDocument } = useDocumentContext('NonRepeatableComponent');\n const rulesEngine = createRulesEngine();\n\n return (\n <ComponentProvider id={value?.id} uid={attribute.component} level={level + 1} type=\"component\">\n <Box\n background={'neutral100'}\n paddingLeft={6}\n paddingRight={6}\n paddingTop={6}\n paddingBottom={6}\n hasRadius={isNested}\n borderColor={isNested ? 'neutral200' : undefined}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((row, index) => {\n
|
|
1
|
+
{"version":3,"file":"NonRepeatable.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Component/NonRepeatable.tsx"],"sourcesContent":["import { useField, createRulesEngine } from '@strapi/admin/strapi-admin';\nimport { Box, Flex } from '@strapi/design-system';\nimport { useIntl } from 'react-intl';\n\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { ComponentProvider, useComponent } from '../ComponentContext';\n\nimport type { ComponentInputProps } from './Input';\n\ntype NonRepeatableComponentProps = Omit<ComponentInputProps, 'required' | 'label'>;\n\nconst NonRepeatableComponent = ({\n attribute,\n name,\n children,\n layout,\n}: NonRepeatableComponentProps) => {\n const { formatMessage } = useIntl();\n const { value } = useField(name);\n const level = useComponent('NonRepeatableComponent', (state) => state.level);\n const isNested = level > 0;\n const { currentDocument } = useDocumentContext('NonRepeatableComponent');\n const rulesEngine = createRulesEngine();\n\n return (\n <ComponentProvider id={value?.id} uid={attribute.component} level={level + 1} type=\"component\">\n <Box\n background={'neutral100'}\n paddingLeft={6}\n paddingRight={6}\n paddingTop={6}\n paddingBottom={6}\n hasRadius={isNested}\n borderColor={isNested ? 'neutral200' : undefined}\n >\n <Flex direction=\"column\" alignItems=\"stretch\" gap={6}>\n {layout.map((row, index) => {\n return (\n <ResponsiveGridRoot gap={4} key={index}>\n {row.map(({ size, ...field }) => {\n /**\n * Layouts are built from schemas so they don't understand the complete\n * schema tree, for components we append the parent name to the field name\n * because this is the structure for the data & permissions also understand\n * the nesting involved.\n */\n const completeFieldName = `${name}.${field.name}`;\n\n const translatedLabel = formatMessage({\n id: `content-manager.components.${attribute.component}.${field.name}`,\n defaultMessage: field.label,\n });\n\n return (\n <ResponsiveGridItem\n col={size}\n key={completeFieldName}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {children({\n ...field,\n label: translatedLabel,\n name: completeFieldName,\n document: currentDocument,\n })}\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n );\n })}\n </Flex>\n </Box>\n </ComponentProvider>\n );\n};\n\nexport { NonRepeatableComponent };\nexport type { NonRepeatableComponentProps };\n"],"names":["NonRepeatableComponent","attribute","name","children","layout","formatMessage","useIntl","value","useField","level","useComponent","state","isNested","currentDocument","useDocumentContext","createRulesEngine","_jsx","ComponentProvider","id","uid","component","type","Box","background","paddingLeft","paddingRight","paddingTop","paddingBottom","hasRadius","borderColor","undefined","Flex","direction","alignItems","gap","map","row","index","ResponsiveGridRoot","size","field","completeFieldName","translatedLabel","defaultMessage","label","ResponsiveGridItem","col","s","xs","document"],"mappings":";;;;;;;;AAYMA,MAAAA,sBAAAA,GAAyB,CAAC,EAC9BC,SAAS,EACTC,IAAI,EACJC,QAAQ,EACRC,MAAM,EACsB,GAAA;IAC5B,MAAM,EAAEC,aAAa,EAAE,GAAGC,OAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,KAAK,EAAE,GAAGC,QAASN,CAAAA,IAAAA,CAAAA;AAC3B,IAAA,MAAMO,QAAQC,YAAa,CAAA,wBAAA,EAA0B,CAACC,KAAAA,GAAUA,MAAMF,KAAK,CAAA;AAC3E,IAAA,MAAMG,WAAWH,KAAQ,GAAA,CAAA;AACzB,IAAA,MAAM,EAAEI,eAAe,EAAE,GAAGC,kBAAmB,CAAA,wBAAA,CAAA;AAC/C,IAAoBC,iBAAAA;AAEpB,IAAA,qBACEC,GAACC,CAAAA,iBAAAA,EAAAA;AAAkBC,QAAAA,EAAAA,EAAIX,KAAOW,EAAAA,EAAAA;AAAIC,QAAAA,GAAAA,EAAKlB,UAAUmB,SAAS;AAAEX,QAAAA,KAAAA,EAAOA,KAAQ,GAAA,CAAA;QAAGY,IAAK,EAAA,WAAA;AACjF,QAAA,QAAA,gBAAAL,GAACM,CAAAA,GAAAA,EAAAA;YACCC,UAAY,EAAA,YAAA;YACZC,WAAa,EAAA,CAAA;YACbC,YAAc,EAAA,CAAA;YACdC,UAAY,EAAA,CAAA;YACZC,aAAe,EAAA,CAAA;YACfC,SAAW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rC,iBAAA;;;;AAKV;;;;"}
|
|
@@ -229,6 +229,7 @@ const RepeatableComponent = ({ attribute, disabled, name, mainField, children, l
|
|
|
229
229
|
onDropItem: handleDropItem,
|
|
230
230
|
onGrabItem: handleGrabItem,
|
|
231
231
|
__temp_key__: key,
|
|
232
|
+
totalLength: value.length,
|
|
232
233
|
children: layout.map((row, index)=>{
|
|
233
234
|
const visibleFields = row.filter(({ ...field })=>{
|
|
234
235
|
const condition = field.attribute.conditions?.visible;
|
|
@@ -319,7 +320,7 @@ const TextButtonCustom = styledComponents.styled(designSystem.TextButton)`
|
|
|
319
320
|
const Component = ({ disabled, index, name, mainField = {
|
|
320
321
|
name: 'id',
|
|
321
322
|
type: 'integer'
|
|
322
|
-
}, children, onDeleteComponent, toggleCollapses, __temp_key__, ...dragProps })=>{
|
|
323
|
+
}, children, onDeleteComponent, toggleCollapses, __temp_key__, totalLength, onMoveItem, ...dragProps })=>{
|
|
323
324
|
const { formatMessage } = reactIntl.useIntl();
|
|
324
325
|
const isDesktop = strapiAdmin.useIsDesktop();
|
|
325
326
|
const displayValue = strapiAdmin.useForm('RepeatableComponent', (state)=>{
|
|
@@ -346,6 +347,7 @@ const Component = ({ disabled, index, name, mainField = {
|
|
|
346
347
|
// Close all collapses
|
|
347
348
|
toggleCollapses();
|
|
348
349
|
},
|
|
350
|
+
onMoveItem,
|
|
349
351
|
...dragProps
|
|
350
352
|
});
|
|
351
353
|
React__namespace.useEffect(()=>{
|
|
@@ -358,6 +360,27 @@ const Component = ({ disabled, index, name, mainField = {
|
|
|
358
360
|
]);
|
|
359
361
|
const composedAccordionRefs = designSystem.useComposedRefs(accordionRef, dragRef);
|
|
360
362
|
const composedBoxRefs = designSystem.useComposedRefs(boxRef, dropRef);
|
|
363
|
+
const handleMoveUp = React__namespace.useCallback((e)=>{
|
|
364
|
+
e.stopPropagation();
|
|
365
|
+
if (index > 0 && onMoveItem) {
|
|
366
|
+
onMoveItem(index - 1, index);
|
|
367
|
+
}
|
|
368
|
+
}, [
|
|
369
|
+
index,
|
|
370
|
+
onMoveItem
|
|
371
|
+
]);
|
|
372
|
+
const handleMoveDown = React__namespace.useCallback((e)=>{
|
|
373
|
+
e.stopPropagation();
|
|
374
|
+
if (index < totalLength - 1 && onMoveItem) {
|
|
375
|
+
onMoveItem(index + 1, index);
|
|
376
|
+
}
|
|
377
|
+
}, [
|
|
378
|
+
index,
|
|
379
|
+
totalLength,
|
|
380
|
+
onMoveItem
|
|
381
|
+
]);
|
|
382
|
+
const canMoveUp = index > 0;
|
|
383
|
+
const canMoveDown = index < totalLength - 1;
|
|
361
384
|
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
362
385
|
children: isDragging ? /*#__PURE__*/ jsxRuntime.jsx(Preview, {}) : /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Accordion.Item, {
|
|
363
386
|
ref: composedBoxRefs,
|
|
@@ -392,6 +415,30 @@ const Component = ({ disabled, index, name, mainField = {
|
|
|
392
415
|
}),
|
|
393
416
|
onKeyDown: handleKeyDown,
|
|
394
417
|
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.Drag, {})
|
|
418
|
+
}),
|
|
419
|
+
!isDesktop && /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
420
|
+
children: [
|
|
421
|
+
canMoveUp && /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
|
422
|
+
disabled: disabled || !canMoveUp,
|
|
423
|
+
variant: "ghost",
|
|
424
|
+
onClick: handleMoveUp,
|
|
425
|
+
label: formatMessage({
|
|
426
|
+
id: translations.getTranslation('components.DynamicZone.move-up'),
|
|
427
|
+
defaultMessage: 'Move up'
|
|
428
|
+
}),
|
|
429
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.ArrowUp, {})
|
|
430
|
+
}),
|
|
431
|
+
canMoveDown && /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
|
|
432
|
+
disabled: disabled || !canMoveDown,
|
|
433
|
+
variant: "ghost",
|
|
434
|
+
onClick: handleMoveDown,
|
|
435
|
+
label: formatMessage({
|
|
436
|
+
id: translations.getTranslation('components.DynamicZone.move-down'),
|
|
437
|
+
defaultMessage: 'Move down'
|
|
438
|
+
}),
|
|
439
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Icons.ArrowDown, {})
|
|
440
|
+
})
|
|
441
|
+
]
|
|
395
442
|
})
|
|
396
443
|
]
|
|
397
444
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repeatable.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Component/Repeatable.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useField,\n useNotification,\n useForm,\n createRulesEngine,\n useIsDesktop,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Flex,\n TextButton,\n VisuallyHidden,\n Accordion,\n IconButton,\n useComposedRefs,\n BoxComponent,\n} from '@strapi/design-system';\nimport { Plus, Drag, Trash } from '@strapi/icons';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { useLocation } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { useDragAndDrop, type UseDragAndDropOptions } from '../../../../../hooks/useDragAndDrop';\nimport { usePrev } from '../../../../../hooks/usePrev';\nimport { getIn } from '../../../../../utils/objects';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { transformDocument } from '../../../utils/data';\nimport { createDefaultForm } from '../../../utils/forms';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { ComponentProvider, useComponent } from '../ComponentContext';\n\nimport { Initializer } from './Initializer';\n\nimport type { ComponentInputProps } from './Input';\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * RepeatableComponent\n * -----------------------------------------------------------------------------------------------*/\n\ntype RepeatableComponentProps = Omit<ComponentInputProps, 'required' | 'label'>;\n\nconst RepeatableComponent = ({\n attribute,\n disabled,\n name,\n mainField,\n children,\n layout,\n}: RepeatableComponentProps) => {\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { search: searchString } = useLocation();\n const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);\n const { currentDocument } = useDocumentContext('RepeatableComponent');\n const components = currentDocument.components;\n\n const {\n value = [],\n error,\n rawError,\n } = useField<Schema.Attribute.ComponentValue<`${string}.${string}`, true>>(name);\n const addFieldRow = useForm('RepeatableComponent', (state) => state.addFieldRow);\n const moveFieldRow = useForm('RepeatableComponent', (state) => state.moveFieldRow);\n const removeFieldRow = useForm('RepeatableComponent', (state) => state.removeFieldRow);\n const { max = Infinity } = attribute;\n\n const [collapseToOpen, setCollapseToOpen] = React.useState<string>('');\n const [liveText, setLiveText] = React.useState('');\n\n const rulesEngine = createRulesEngine();\n\n React.useEffect(() => {\n const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;\n const hasNestedValue = value && Array.isArray(value) && value.length > 0;\n\n if (hasNestedErrors && hasNestedValue) {\n const errorOpenItems = rawError\n .map((_: unknown, idx: number) => {\n return value[idx] ? value[idx].__temp_key__ : null;\n })\n .filter((value) => !!value);\n\n if (errorOpenItems && errorOpenItems.length > 0) {\n setCollapseToOpen((collapseToOpen) => {\n if (!errorOpenItems.includes(collapseToOpen)) {\n return errorOpenItems[0];\n }\n\n return collapseToOpen;\n });\n }\n }\n }, [rawError, value]);\n\n /**\n * Get the temp key of the component that has the field that is currently focussed\n * as defined by the `field` query param. We can then force this specific component\n * to be in its \"open\" state.\n */\n const componentTmpKeyWithFocussedField = React.useMemo(() => {\n if (search.has('field')) {\n const fieldParam = search.get('field');\n\n if (!fieldParam) {\n return undefined;\n }\n\n const [, path] = fieldParam.split(`${name}.`);\n\n if (getIn(value, path, undefined) !== undefined) {\n const [subpath] = path.split('.');\n\n return getIn(value, subpath, undefined)?.__temp_key__;\n }\n }\n\n return undefined;\n }, [search, name, value]);\n\n const prevValue = usePrev(value);\n\n React.useEffect(() => {\n /**\n * When we add a new item to the array, we want to open the collapse.\n */\n if (prevValue && prevValue.length < value.length) {\n setCollapseToOpen(value[value.length - 1].__temp_key__);\n }\n }, [value, prevValue]);\n\n React.useEffect(() => {\n if (typeof componentTmpKeyWithFocussedField === 'string') {\n setCollapseToOpen(componentTmpKeyWithFocussedField);\n }\n }, [componentTmpKeyWithFocussedField]);\n\n const toggleCollapses = () => {\n setCollapseToOpen('');\n };\n\n const handleClick = () => {\n if (value.length < max) {\n const schema = components[attribute.component];\n const form = createDefaultForm(schema, components);\n const data = transformDocument(schema, components)(form);\n\n addFieldRow(name, data);\n // setCollapseToOpen(nextTempKey);\n } else if (value.length >= max) {\n toggleNotification({\n type: 'info',\n message: formatMessage({\n id: getTranslation('components.notification.info.maximum-requirement'),\n }),\n });\n }\n };\n\n const handleMoveComponentField: ComponentProps['onMoveItem'] = (newIndex, currentIndex) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.reorder'),\n defaultMessage: '{item}, moved. New position in list: {position}.',\n },\n {\n item: `${name}.${currentIndex}`,\n position: getItemPos(newIndex),\n }\n )\n );\n\n moveFieldRow(name, currentIndex, newIndex);\n };\n\n const handleValueChange = (key: string) => {\n setCollapseToOpen(key);\n };\n\n const getItemPos = (index: number) => `${index + 1} of ${value.length}`;\n\n const handleCancel = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.cancel-item'),\n defaultMessage: '{item}, dropped. Re-order cancelled.',\n },\n {\n item: `${name}.${index}`,\n }\n )\n );\n };\n\n const handleGrabItem = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.grab-item'),\n defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`,\n },\n {\n item: `${name}.${index}`,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleDropItem = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.drop-item'),\n defaultMessage: `{item}, dropped. Final position in list: {position}.`,\n },\n {\n item: `${name}.${index}`,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const ariaDescriptionId = React.useId();\n\n const level = useComponent('RepeatableComponent', (state) => state.level);\n\n if (value.length === 0) {\n return <Initializer disabled={disabled} name={name} onClick={handleClick} />;\n }\n\n return (\n <Box hasRadius>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('dnd.instructions'),\n defaultMessage: `Press spacebar to grab and re-order`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n <AccordionRoot\n $error={error}\n value={collapseToOpen}\n onValueChange={handleValueChange}\n aria-describedby={ariaDescriptionId}\n >\n {value.map(({ __temp_key__: key, id, ...currentComponentValues }, index) => {\n const nameWithIndex = `${name}.${index}`;\n\n return (\n <ComponentProvider\n key={key}\n // id is always a number in a component\n id={id as number}\n uid={attribute.component}\n level={level + 1}\n type=\"repeatable\"\n >\n <Component\n disabled={disabled}\n name={nameWithIndex}\n attribute={attribute}\n index={index}\n mainField={mainField}\n onMoveItem={handleMoveComponentField}\n onDeleteComponent={() => {\n removeFieldRow(name, index);\n toggleCollapses();\n }}\n toggleCollapses={toggleCollapses}\n onCancel={handleCancel}\n onDropItem={handleDropItem}\n onGrabItem={handleGrabItem}\n __temp_key__={key}\n >\n {layout.map((row, index) => {\n const visibleFields = row.filter(({ ...field }) => {\n const condition = field.attribute.conditions?.visible;\n if (condition) {\n return rulesEngine.evaluate(condition, currentComponentValues);\n }\n\n return true;\n });\n\n if (visibleFields.length === 0) {\n return null; // Skip rendering the entire grid row\n }\n return (\n <ResponsiveGridRoot gap={4} key={index}>\n {visibleFields.map(({ size, ...field }) => {\n /**\n * Layouts are built from schemas so they don't understand the complete\n * schema tree, for components we append the parent name to the field name\n * because this is the structure for the data & permissions also understand\n * the nesting involved.\n */\n const completeFieldName = `${nameWithIndex}.${field.name}`;\n\n const translatedLabel = formatMessage({\n id: `content-manager.components.${attribute.component}.${field.name}`,\n defaultMessage: field.label,\n });\n\n return (\n <ResponsiveGridItem\n col={size}\n key={completeFieldName}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {children({\n ...field,\n label: translatedLabel,\n name: completeFieldName,\n document: currentDocument,\n })}\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n );\n })}\n </Component>\n </ComponentProvider>\n );\n })}\n <TextButtonCustom disabled={disabled} onClick={handleClick} startIcon={<Plus />}>\n {formatMessage({\n id: getTranslation('containers.EditView.add.new-entry'),\n defaultMessage: 'Add an entry',\n })}\n </TextButtonCustom>\n </AccordionRoot>\n </Box>\n );\n};\n\nconst AccordionRoot = styled(Accordion.Root)<{ $error?: string }>`\n border: 1px solid\n ${({ theme, $error }) => ($error ? theme.colors.danger600 : theme.colors.neutral200)};\n`;\n\nconst TextButtonCustom = styled(TextButton)`\n width: 100%;\n display: flex;\n justify-content: center;\n border-top: 1px solid ${({ theme }) => theme.colors.neutral200};\n padding-inline: ${(props) => props.theme.spaces[6]};\n padding-block: ${(props) => props.theme.spaces[3]};\n\n &:not([disabled]) {\n cursor: pointer;\n\n &:hover {\n background-color: ${(props) => props.theme.colors.primary100};\n }\n }\n\n span {\n font-weight: 600;\n font-size: 1.4rem;\n line-height: 2.4rem;\n }\n\n @media (prefers-reduced-motion: no-preference) {\n transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Field\n * -----------------------------------------------------------------------------------------------*/\n\ninterface ComponentProps\n extends Pick<UseDragAndDropOptions, 'onGrabItem' | 'onDropItem' | 'onCancel' | 'onMoveItem'>,\n Pick<RepeatableComponentProps, 'mainField'> {\n attribute: Schema.Attribute.Component<`${string}.${string}`, boolean>;\n disabled?: boolean;\n index: number;\n name: string;\n onDeleteComponent?: React.MouseEventHandler<HTMLButtonElement>;\n toggleCollapses: () => void;\n children: React.ReactNode;\n __temp_key__: string;\n}\n\nconst Component = ({\n disabled,\n index,\n name,\n mainField = {\n name: 'id',\n type: 'integer',\n },\n children,\n onDeleteComponent,\n toggleCollapses,\n __temp_key__,\n ...dragProps\n}: ComponentProps) => {\n const { formatMessage } = useIntl();\n const isDesktop = useIsDesktop();\n\n const displayValue = useForm('RepeatableComponent', (state) => {\n return getIn(state.values, [...name.split('.'), mainField.name]);\n });\n\n const accordionRef = React.useRef<HTMLButtonElement>(null!);\n\n /**\n * The last item in the fieldName array will be the index of this component.\n * Drag and drop should be isolated to the parent component so nested repeatable\n * components are not affected by the drag and drop of the parent component in\n * their own re-ordering context.\n */\n const componentKey = name.split('.').slice(0, -1).join('.');\n\n const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop(!disabled, {\n type: `${ItemTypes.COMPONENT}_${componentKey}`,\n index,\n item: {\n index,\n displayedValue: displayValue,\n },\n onStart() {\n // Close all collapses\n toggleCollapses();\n },\n ...dragProps,\n });\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage(), { captureDraggingState: false });\n }, [dragPreviewRef, index]);\n\n const composedAccordionRefs = useComposedRefs<HTMLButtonElement>(accordionRef, dragRef);\n const composedBoxRefs = useComposedRefs<HTMLDivElement>(\n boxRef as React.RefObject<HTMLDivElement>,\n dropRef\n );\n\n return (\n <>\n {isDragging ? (\n <Preview />\n ) : (\n <Accordion.Item ref={composedBoxRefs} value={__temp_key__}>\n <Accordion.Header>\n <Accordion.Trigger>{displayValue}</Accordion.Trigger>\n <Accordion.Actions>\n <IconButton\n disabled={disabled}\n variant=\"ghost\"\n onClick={onDeleteComponent}\n label={formatMessage({\n id: getTranslation('containers.Edit.delete'),\n defaultMessage: 'Delete',\n })}\n >\n <Trash />\n </IconButton>\n {isDesktop && (\n <IconButton\n disabled={disabled}\n ref={composedAccordionRefs}\n variant=\"ghost\"\n onClick={(e) => e.stopPropagation()}\n data-handler-id={handlerId}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onKeyDown={handleKeyDown}\n >\n <Drag />\n </IconButton>\n )}\n </Accordion.Actions>\n </Accordion.Header>\n <Accordion.Content>\n <Flex\n direction=\"column\"\n alignItems=\"stretch\"\n background=\"neutral100\"\n padding={6}\n gap={6}\n >\n {children}\n </Flex>\n </Accordion.Content>\n </Accordion.Item>\n )}\n </>\n );\n};\n\nconst Preview = () => {\n return <StyledSpan tag=\"span\" padding={6} background=\"primary100\" />;\n};\n\nconst StyledSpan = styled<BoxComponent<'span'>>(Box)`\n display: block;\n outline: 1px dashed ${({ theme }) => theme.colors.primary500};\n outline-offset: -1px;\n`;\n\nexport { RepeatableComponent };\nexport type { RepeatableComponentProps };\n"],"names":["RepeatableComponent","attribute","disabled","name","mainField","children","layout","toggleNotification","useNotification","formatMessage","useIntl","search","searchString","useLocation","React","useMemo","URLSearchParams","currentDocument","useDocumentContext","components","value","error","rawError","useField","addFieldRow","useForm","state","moveFieldRow","removeFieldRow","max","Infinity","collapseToOpen","setCollapseToOpen","useState","liveText","setLiveText","rulesEngine","createRulesEngine","useEffect","hasNestedErrors","Array","isArray","length","hasNestedValue","errorOpenItems","map","_","idx","__temp_key__","filter","includes","componentTmpKeyWithFocussedField","has","fieldParam","get","undefined","path","split","getIn","subpath","prevValue","usePrev","toggleCollapses","handleClick","schema","component","form","createDefaultForm","data","transformDocument","type","message","id","getTranslation","handleMoveComponentField","newIndex","currentIndex","defaultMessage","item","position","getItemPos","handleValueChange","key","index","handleCancel","handleGrabItem","handleDropItem","ariaDescriptionId","useId","level","useComponent","_jsx","Initializer","onClick","_jsxs","Box","hasRadius","VisuallyHidden","aria-live","AccordionRoot","$error","onValueChange","aria-describedby","currentComponentValues","nameWithIndex","ComponentProvider","uid","Component","onMoveItem","onDeleteComponent","onCancel","onDropItem","onGrabItem","row","visibleFields","field","condition","conditions","visible","evaluate","ResponsiveGridRoot","gap","size","completeFieldName","translatedLabel","label","ResponsiveGridItem","col","s","xs","direction","alignItems","document","TextButtonCustom","startIcon","Plus","styled","Accordion","Root","theme","colors","danger600","neutral200","TextButton","props","spaces","primary100","motion","easings","easeOutQuad","dragProps","isDesktop","useIsDesktop","displayValue","values","accordionRef","useRef","componentKey","slice","join","handlerId","isDragging","handleKeyDown","boxRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","ItemTypes","COMPONENT","displayedValue","onStart","getEmptyImage","captureDraggingState","composedAccordionRefs","useComposedRefs","composedBoxRefs","_Fragment","Preview","Item","ref","Header","Trigger","Actions","IconButton","variant","Trash","e","stopPropagation","data-handler-id","onKeyDown","Drag","Content","Flex","background","padding","StyledSpan","tag","primary500"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAMA,mBAAsB,GAAA,CAAC,EAC3BC,SAAS,EACTC,QAAQ,EACRC,IAAI,EACJC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACmB,GAAA;IACzB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;IAC/B,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,MAAAA,EAAQC,YAAY,EAAE,GAAGC,0BAAAA,EAAAA;AACjC,IAAA,MAAMF,SAASG,gBAAMC,CAAAA,OAAO,CAAC,IAAM,IAAIC,gBAAgBJ,YAAe,CAAA,EAAA;AAACA,QAAAA;AAAa,KAAA,CAAA;AACpF,IAAA,MAAM,EAAEK,eAAe,EAAE,GAAGC,qCAAmB,CAAA,qBAAA,CAAA;IAC/C,MAAMC,UAAAA,GAAaF,gBAAgBE,UAAU;IAE7C,MAAM,EACJC,QAAQ,EAAE,EACVC,KAAK,EACLC,QAAQ,EACT,GAAGC,oBAAuEpB,CAAAA,IAAAA,CAAAA;AAC3E,IAAA,MAAMqB,cAAcC,mB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EAAAA,qBAAAA;oCACLW,OAAQ,EAAA,OAAA;oCACR5F,OAAS,EAAA,CAAC8F,CAAMA,GAAAA,CAAAA,CAAEC,eAAe,EAAA;oCACjCC,iBAAiB7B,EAAAA,SAAAA;AACjBnC,oCAAAA,KAAAA,EAAOpH,aAAc,CAAA;AACnB+D,wCAAAA,EAAAA,EAAIC,2BAAe,CAAA,6BAAA,CAAA;wCACnBI,cAAgB,EAAA;AAClB,qCAAA,CAAA;oCACAiH,SAAW5B,EAAAA,aAAAA;AAEX,oCAAA,QAAA,gBAAAvE,cAACoG,CAAAA,UAAAA,EAAAA,EAAAA;;;;;;AAKT,8BAAApG,cAAA,CAAC8C,uBAAUuD,OAAO,EAAA;AAChB,oBAAA,QAAA,gBAAArG,cAACsG,CAAAA,iBAAAA,EAAAA;wBACC/D,SAAU,EAAA,QAAA;wBACVC,UAAW,EAAA,SAAA;wBACX+D,UAAW,EAAA,YAAA;wBACXC,OAAS,EAAA,CAAA;wBACT1E,GAAK,EAAA,CAAA;AAEJpH,wBAAAA,QAAAA,EAAAA;;;;;;AAOf,CAAA;AAEA,MAAM6K,OAAU,GAAA,IAAA;AACd,IAAA,qBAAOvF,cAACyG,CAAAA,UAAAA,EAAAA;QAAWC,GAAI,EAAA,MAAA;QAAOF,OAAS,EAAA,CAAA;QAAGD,UAAW,EAAA;;AACvD,CAAA;AAEA,MAAME,UAAAA,GAAa5D,uBAA6BzC,CAAAA,gBAAAA,CAAI;;sBAE9B,EAAE,CAAC,EAAE4C,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAAC0D,UAAU,CAAC;;AAE/D,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Repeatable.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/Component/Repeatable.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n useField,\n useNotification,\n useForm,\n createRulesEngine,\n useIsDesktop,\n} from '@strapi/admin/strapi-admin';\nimport {\n Box,\n Flex,\n TextButton,\n VisuallyHidden,\n Accordion,\n IconButton,\n useComposedRefs,\n BoxComponent,\n} from '@strapi/design-system';\nimport { Plus, Drag, Trash, ArrowUp, ArrowDown } from '@strapi/icons';\nimport { getEmptyImage } from 'react-dnd-html5-backend';\nimport { useIntl } from 'react-intl';\nimport { useLocation } from 'react-router-dom';\nimport { styled } from 'styled-components';\n\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDocumentContext } from '../../../../../hooks/useDocumentContext';\nimport { useDragAndDrop, type UseDragAndDropOptions } from '../../../../../hooks/useDragAndDrop';\nimport { usePrev } from '../../../../../hooks/usePrev';\nimport { getIn } from '../../../../../utils/objects';\nimport { getTranslation } from '../../../../../utils/translations';\nimport { transformDocument } from '../../../utils/data';\nimport { createDefaultForm } from '../../../utils/forms';\nimport { ResponsiveGridItem, ResponsiveGridRoot } from '../../FormLayout';\nimport { ComponentProvider, useComponent } from '../ComponentContext';\n\nimport { Initializer } from './Initializer';\n\nimport type { ComponentInputProps } from './Input';\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * RepeatableComponent\n * -----------------------------------------------------------------------------------------------*/\n\ntype RepeatableComponentProps = Omit<ComponentInputProps, 'required' | 'label'>;\n\nconst RepeatableComponent = ({\n attribute,\n disabled,\n name,\n mainField,\n children,\n layout,\n}: RepeatableComponentProps) => {\n const { toggleNotification } = useNotification();\n const { formatMessage } = useIntl();\n const { search: searchString } = useLocation();\n const search = React.useMemo(() => new URLSearchParams(searchString), [searchString]);\n const { currentDocument } = useDocumentContext('RepeatableComponent');\n const components = currentDocument.components;\n\n const {\n value = [],\n error,\n rawError,\n } = useField<Schema.Attribute.ComponentValue<`${string}.${string}`, true>>(name);\n const addFieldRow = useForm('RepeatableComponent', (state) => state.addFieldRow);\n const moveFieldRow = useForm('RepeatableComponent', (state) => state.moveFieldRow);\n const removeFieldRow = useForm('RepeatableComponent', (state) => state.removeFieldRow);\n const { max = Infinity } = attribute;\n\n const [collapseToOpen, setCollapseToOpen] = React.useState<string>('');\n const [liveText, setLiveText] = React.useState('');\n\n const rulesEngine = createRulesEngine();\n\n React.useEffect(() => {\n const hasNestedErrors = rawError && Array.isArray(rawError) && rawError.length > 0;\n const hasNestedValue = value && Array.isArray(value) && value.length > 0;\n\n if (hasNestedErrors && hasNestedValue) {\n const errorOpenItems = rawError\n .map((_: unknown, idx: number) => {\n return value[idx] ? value[idx].__temp_key__ : null;\n })\n .filter((value) => !!value);\n\n if (errorOpenItems && errorOpenItems.length > 0) {\n setCollapseToOpen((collapseToOpen) => {\n if (!errorOpenItems.includes(collapseToOpen)) {\n return errorOpenItems[0];\n }\n\n return collapseToOpen;\n });\n }\n }\n }, [rawError, value]);\n\n /**\n * Get the temp key of the component that has the field that is currently focussed\n * as defined by the `field` query param. We can then force this specific component\n * to be in its \"open\" state.\n */\n const componentTmpKeyWithFocussedField = React.useMemo(() => {\n if (search.has('field')) {\n const fieldParam = search.get('field');\n\n if (!fieldParam) {\n return undefined;\n }\n\n const [, path] = fieldParam.split(`${name}.`);\n\n if (getIn(value, path, undefined) !== undefined) {\n const [subpath] = path.split('.');\n\n return getIn(value, subpath, undefined)?.__temp_key__;\n }\n }\n\n return undefined;\n }, [search, name, value]);\n\n const prevValue = usePrev(value);\n\n React.useEffect(() => {\n /**\n * When we add a new item to the array, we want to open the collapse.\n */\n if (prevValue && prevValue.length < value.length) {\n setCollapseToOpen(value[value.length - 1].__temp_key__);\n }\n }, [value, prevValue]);\n\n React.useEffect(() => {\n if (typeof componentTmpKeyWithFocussedField === 'string') {\n setCollapseToOpen(componentTmpKeyWithFocussedField);\n }\n }, [componentTmpKeyWithFocussedField]);\n\n const toggleCollapses = () => {\n setCollapseToOpen('');\n };\n\n const handleClick = () => {\n if (value.length < max) {\n const schema = components[attribute.component];\n const form = createDefaultForm(schema, components);\n const data = transformDocument(schema, components)(form);\n\n addFieldRow(name, data);\n // setCollapseToOpen(nextTempKey);\n } else if (value.length >= max) {\n toggleNotification({\n type: 'info',\n message: formatMessage({\n id: getTranslation('components.notification.info.maximum-requirement'),\n }),\n });\n }\n };\n\n const handleMoveComponentField: ComponentProps['onMoveItem'] = (newIndex, currentIndex) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.reorder'),\n defaultMessage: '{item}, moved. New position in list: {position}.',\n },\n {\n item: `${name}.${currentIndex}`,\n position: getItemPos(newIndex),\n }\n )\n );\n\n moveFieldRow(name, currentIndex, newIndex);\n };\n\n const handleValueChange = (key: string) => {\n setCollapseToOpen(key);\n };\n\n const getItemPos = (index: number) => `${index + 1} of ${value.length}`;\n\n const handleCancel = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.cancel-item'),\n defaultMessage: '{item}, dropped. Re-order cancelled.',\n },\n {\n item: `${name}.${index}`,\n }\n )\n );\n };\n\n const handleGrabItem = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.grab-item'),\n defaultMessage: `{item}, grabbed. Current position in list: {position}. Press up and down arrow to change position, Spacebar to drop, Escape to cancel.`,\n },\n {\n item: `${name}.${index}`,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const handleDropItem = (index: number) => {\n setLiveText(\n formatMessage(\n {\n id: getTranslation('dnd.drop-item'),\n defaultMessage: `{item}, dropped. Final position in list: {position}.`,\n },\n {\n item: `${name}.${index}`,\n position: getItemPos(index),\n }\n )\n );\n };\n\n const ariaDescriptionId = React.useId();\n\n const level = useComponent('RepeatableComponent', (state) => state.level);\n\n if (value.length === 0) {\n return <Initializer disabled={disabled} name={name} onClick={handleClick} />;\n }\n\n return (\n <Box hasRadius>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('dnd.instructions'),\n defaultMessage: `Press spacebar to grab and re-order`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n <AccordionRoot\n $error={error}\n value={collapseToOpen}\n onValueChange={handleValueChange}\n aria-describedby={ariaDescriptionId}\n >\n {value.map(({ __temp_key__: key, id, ...currentComponentValues }, index) => {\n const nameWithIndex = `${name}.${index}`;\n\n return (\n <ComponentProvider\n key={key}\n // id is always a number in a component\n id={id as number}\n uid={attribute.component}\n level={level + 1}\n type=\"repeatable\"\n >\n <Component\n disabled={disabled}\n name={nameWithIndex}\n attribute={attribute}\n index={index}\n mainField={mainField}\n onMoveItem={handleMoveComponentField}\n onDeleteComponent={() => {\n removeFieldRow(name, index);\n toggleCollapses();\n }}\n toggleCollapses={toggleCollapses}\n onCancel={handleCancel}\n onDropItem={handleDropItem}\n onGrabItem={handleGrabItem}\n __temp_key__={key}\n totalLength={value.length}\n >\n {layout.map((row, index) => {\n const visibleFields = row.filter(({ ...field }) => {\n const condition = field.attribute.conditions?.visible;\n if (condition) {\n return rulesEngine.evaluate(condition, currentComponentValues);\n }\n\n return true;\n });\n\n if (visibleFields.length === 0) {\n return null; // Skip rendering the entire grid row\n }\n return (\n <ResponsiveGridRoot gap={4} key={index}>\n {visibleFields.map(({ size, ...field }) => {\n /**\n * Layouts are built from schemas so they don't understand the complete\n * schema tree, for components we append the parent name to the field name\n * because this is the structure for the data & permissions also understand\n * the nesting involved.\n */\n const completeFieldName = `${nameWithIndex}.${field.name}`;\n\n const translatedLabel = formatMessage({\n id: `content-manager.components.${attribute.component}.${field.name}`,\n defaultMessage: field.label,\n });\n\n return (\n <ResponsiveGridItem\n col={size}\n key={completeFieldName}\n s={12}\n xs={12}\n direction=\"column\"\n alignItems=\"stretch\"\n >\n {children({\n ...field,\n label: translatedLabel,\n name: completeFieldName,\n document: currentDocument,\n })}\n </ResponsiveGridItem>\n );\n })}\n </ResponsiveGridRoot>\n );\n })}\n </Component>\n </ComponentProvider>\n );\n })}\n <TextButtonCustom disabled={disabled} onClick={handleClick} startIcon={<Plus />}>\n {formatMessage({\n id: getTranslation('containers.EditView.add.new-entry'),\n defaultMessage: 'Add an entry',\n })}\n </TextButtonCustom>\n </AccordionRoot>\n </Box>\n );\n};\n\nconst AccordionRoot = styled(Accordion.Root)<{ $error?: string }>`\n border: 1px solid\n ${({ theme, $error }) => ($error ? theme.colors.danger600 : theme.colors.neutral200)};\n`;\n\nconst TextButtonCustom = styled(TextButton)`\n width: 100%;\n display: flex;\n justify-content: center;\n border-top: 1px solid ${({ theme }) => theme.colors.neutral200};\n padding-inline: ${(props) => props.theme.spaces[6]};\n padding-block: ${(props) => props.theme.spaces[3]};\n\n &:not([disabled]) {\n cursor: pointer;\n\n &:hover {\n background-color: ${(props) => props.theme.colors.primary100};\n }\n }\n\n span {\n font-weight: 600;\n font-size: 1.4rem;\n line-height: 2.4rem;\n }\n\n @media (prefers-reduced-motion: no-preference) {\n transition: background-color 120ms ${(props) => props.theme.motion.easings.easeOutQuad};\n }\n`;\n\n/* -------------------------------------------------------------------------------------------------\n * Field\n * -----------------------------------------------------------------------------------------------*/\n\ninterface ComponentProps\n extends Pick<UseDragAndDropOptions, 'onGrabItem' | 'onDropItem' | 'onCancel' | 'onMoveItem'>,\n Pick<RepeatableComponentProps, 'mainField'> {\n attribute: Schema.Attribute.Component<`${string}.${string}`, boolean>;\n disabled?: boolean;\n index: number;\n name: string;\n onDeleteComponent?: React.MouseEventHandler<HTMLButtonElement>;\n toggleCollapses: () => void;\n children: React.ReactNode;\n __temp_key__: string;\n totalLength: number;\n}\n\nconst Component = ({\n disabled,\n index,\n name,\n mainField = {\n name: 'id',\n type: 'integer',\n },\n children,\n onDeleteComponent,\n toggleCollapses,\n __temp_key__,\n totalLength,\n onMoveItem,\n ...dragProps\n}: ComponentProps) => {\n const { formatMessage } = useIntl();\n const isDesktop = useIsDesktop();\n\n const displayValue = useForm('RepeatableComponent', (state) => {\n return getIn(state.values, [...name.split('.'), mainField.name]);\n });\n\n const accordionRef = React.useRef<HTMLButtonElement>(null!);\n\n /**\n * The last item in the fieldName array will be the index of this component.\n * Drag and drop should be isolated to the parent component so nested repeatable\n * components are not affected by the drag and drop of the parent component in\n * their own re-ordering context.\n */\n const componentKey = name.split('.').slice(0, -1).join('.');\n\n const [{ handlerId, isDragging, handleKeyDown }, boxRef, dropRef, dragRef, dragPreviewRef] =\n useDragAndDrop(!disabled, {\n type: `${ItemTypes.COMPONENT}_${componentKey}`,\n index,\n item: {\n index,\n displayedValue: displayValue,\n },\n onStart() {\n // Close all collapses\n toggleCollapses();\n },\n onMoveItem,\n ...dragProps,\n });\n\n React.useEffect(() => {\n dragPreviewRef(getEmptyImage(), { captureDraggingState: false });\n }, [dragPreviewRef, index]);\n\n const composedAccordionRefs = useComposedRefs<HTMLButtonElement>(accordionRef, dragRef);\n const composedBoxRefs = useComposedRefs<HTMLDivElement>(\n boxRef as React.RefObject<HTMLDivElement>,\n dropRef\n );\n\n const handleMoveUp = React.useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n if (index > 0 && onMoveItem) {\n onMoveItem(index - 1, index);\n }\n },\n [index, onMoveItem]\n );\n\n const handleMoveDown = React.useCallback(\n (e: React.MouseEvent) => {\n e.stopPropagation();\n if (index < totalLength - 1 && onMoveItem) {\n onMoveItem(index + 1, index);\n }\n },\n [index, totalLength, onMoveItem]\n );\n\n const canMoveUp = index > 0;\n const canMoveDown = index < totalLength - 1;\n\n return (\n <>\n {isDragging ? (\n <Preview />\n ) : (\n <Accordion.Item ref={composedBoxRefs} value={__temp_key__}>\n <Accordion.Header>\n <Accordion.Trigger>{displayValue}</Accordion.Trigger>\n <Accordion.Actions>\n <IconButton\n disabled={disabled}\n variant=\"ghost\"\n onClick={onDeleteComponent}\n label={formatMessage({\n id: getTranslation('containers.Edit.delete'),\n defaultMessage: 'Delete',\n })}\n >\n <Trash />\n </IconButton>\n {isDesktop && (\n <IconButton\n disabled={disabled}\n ref={composedAccordionRefs}\n variant=\"ghost\"\n onClick={(e) => e.stopPropagation()}\n data-handler-id={handlerId}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onKeyDown={handleKeyDown}\n >\n <Drag />\n </IconButton>\n )}\n {!isDesktop && (\n <>\n {canMoveUp && (\n <IconButton\n disabled={disabled || !canMoveUp}\n variant=\"ghost\"\n onClick={handleMoveUp}\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-up'),\n defaultMessage: 'Move up',\n })}\n >\n <ArrowUp />\n </IconButton>\n )}\n {canMoveDown && (\n <IconButton\n disabled={disabled || !canMoveDown}\n variant=\"ghost\"\n onClick={handleMoveDown}\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-down'),\n defaultMessage: 'Move down',\n })}\n >\n <ArrowDown />\n </IconButton>\n )}\n </>\n )}\n </Accordion.Actions>\n </Accordion.Header>\n <Accordion.Content>\n <Flex\n direction=\"column\"\n alignItems=\"stretch\"\n background=\"neutral100\"\n padding={6}\n gap={6}\n >\n {children}\n </Flex>\n </Accordion.Content>\n </Accordion.Item>\n )}\n </>\n );\n};\n\nconst Preview = () => {\n return <StyledSpan tag=\"span\" padding={6} background=\"primary100\" />;\n};\n\nconst StyledSpan = styled<BoxComponent<'span'>>(Box)`\n display: block;\n outline: 1px dashed ${({ theme }) => theme.colors.primary500};\n outline-offset: -1px;\n`;\n\nexport { RepeatableComponent };\nexport type { RepeatableComponentProps };\n"],"names":["RepeatableComponent","attribute","disabled","name","mainField","children","layout","toggleNotification","useNotification","formatMessage","useIntl","search","searchString","useLocation","React","useMemo","URLSearchParams","currentDocument","useDocumentContext","components","value","error","rawError","useField","addFieldRow","useForm","state","moveFieldRow","removeFieldRow","max","Infinity","collapseToOpen","setCollapseToOpen","useState","liveText","setLiveText","rulesEngine","createRulesEngine","useEffect","hasNestedErrors","Array","isArray","length","hasNestedValue","errorOpenItems","map","_","idx","__temp_key__","filter","includes","componentTmpKeyWithFocussedField","has","fieldParam","get","undefined","path","split","getIn","subpath","prevValue","usePrev","toggleCollapses","handleClick","schema","component","form","createDefaultForm","data","transformDocument","type","message","id","getTranslation","handleMoveComponentField","newIndex","currentIndex","defaultMessage","item","position","getItemPos","handleValueChange","key","index","handleCancel","handleGrabItem","handleDropItem","ariaDescriptionId","useId","level","useComponent","_jsx","Initializer","onClick","_jsxs","Box","hasRadius","VisuallyHidden","aria-live","AccordionRoot","$error","onValueChange","aria-describedby","currentComponentValues","nameWithIndex","ComponentProvider","uid","Component","onMoveItem","onDeleteComponent","onCancel","onDropItem","onGrabItem","totalLength","row","visibleFields","field","condition","conditions","visible","evaluate","ResponsiveGridRoot","gap","size","completeFieldName","translatedLabel","label","ResponsiveGridItem","col","s","xs","direction","alignItems","document","TextButtonCustom","startIcon","Plus","styled","Accordion","Root","theme","colors","danger600","neutral200","TextButton","props","spaces","primary100","motion","easings","easeOutQuad","dragProps","isDesktop","useIsDesktop","displayValue","values","accordionRef","useRef","componentKey","slice","join","handlerId","isDragging","handleKeyDown","boxRef","dropRef","dragRef","dragPreviewRef","useDragAndDrop","ItemTypes","COMPONENT","displayedValue","onStart","getEmptyImage","captureDraggingState","composedAccordionRefs","useComposedRefs","composedBoxRefs","handleMoveUp","useCallback","e","stopPropagation","handleMoveDown","canMoveUp","canMoveDown","_Fragment","Preview","Item","ref","Header","Trigger","Actions","IconButton","variant","Trash","data-handler-id","onKeyDown","Drag","ArrowUp","ArrowDown","Content","Flex","background","padding","StyledSpan","tag","primary500"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAMA,mBAAsB,GAAA,CAAC,EAC3BC,SAAS,EACTC,QAAQ,EACRC,IAAI,EACJC,SAAS,EACTC,QAAQ,EACRC,MAAM,EACmB,GAAA;IACzB,MAAM,EAAEC,kBAAkB,EAAE,GAAGC,2BAAAA,EAAAA;IAC/B,MAAM,EAAEC,aAAa,EAAE,GAAGC,iBAAAA,EAAAA;AAC1B,IAAA,MAAM,EAAEC,MAAAA,EAAQC,YAAY,EAAE,GAAGC,0BAAAA,EAAAA;AACjC,IAAA,MAAMF,SAASG,gBAAMC,CAAAA,OAAO,CAAC,IAAM,IAAIC,gBAAgBJ,YAAe,CAAA,EAAA;AAACA,QAAAA;AA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AU,EAAA,QAAA;wBACVC,UAAW,EAAA,SAAA;wBACXsE,UAAW,EAAA,YAAA;wBACXC,OAAS,EAAA,CAAA;wBACTjF,GAAK,EAAA,CAAA;AAEJrH,wBAAAA,QAAAA,EAAAA;;;;;;AAOf,CAAA;AAEA,MAAMqL,OAAU,GAAA,IAAA;AACd,IAAA,qBAAO/F,cAACiH,CAAAA,UAAAA,EAAAA;QAAWC,GAAI,EAAA,MAAA;QAAOF,OAAS,EAAA,CAAA;QAAGD,UAAW,EAAA;;AACvD,CAAA;AAEA,MAAME,UAAAA,GAAanE,uBAA6B1C,CAAAA,gBAAAA,CAAI;;sBAE9B,EAAE,CAAC,EAAE6C,KAAK,EAAE,GAAKA,KAAMC,CAAAA,MAAM,CAACiE,UAAU,CAAC;;AAE/D,CAAC;;;;"}
|
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useNotification, useField, useForm, createRulesEngine, useIsDesktop } from '@strapi/admin/strapi-admin';
|
|
4
4
|
import { Accordion, TextButton, Box, VisuallyHidden, useComposedRefs, IconButton, Flex } from '@strapi/design-system';
|
|
5
|
-
import { Plus, Trash, Drag } from '@strapi/icons';
|
|
5
|
+
import { Plus, Trash, Drag, ArrowUp, ArrowDown } from '@strapi/icons';
|
|
6
6
|
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
7
7
|
import { useIntl } from 'react-intl';
|
|
8
8
|
import { useLocation } from 'react-router-dom';
|
|
@@ -208,6 +208,7 @@ const RepeatableComponent = ({ attribute, disabled, name, mainField, children, l
|
|
|
208
208
|
onDropItem: handleDropItem,
|
|
209
209
|
onGrabItem: handleGrabItem,
|
|
210
210
|
__temp_key__: key,
|
|
211
|
+
totalLength: value.length,
|
|
211
212
|
children: layout.map((row, index)=>{
|
|
212
213
|
const visibleFields = row.filter(({ ...field })=>{
|
|
213
214
|
const condition = field.attribute.conditions?.visible;
|
|
@@ -298,7 +299,7 @@ const TextButtonCustom = styled(TextButton)`
|
|
|
298
299
|
const Component = ({ disabled, index, name, mainField = {
|
|
299
300
|
name: 'id',
|
|
300
301
|
type: 'integer'
|
|
301
|
-
}, children, onDeleteComponent, toggleCollapses, __temp_key__, ...dragProps })=>{
|
|
302
|
+
}, children, onDeleteComponent, toggleCollapses, __temp_key__, totalLength, onMoveItem, ...dragProps })=>{
|
|
302
303
|
const { formatMessage } = useIntl();
|
|
303
304
|
const isDesktop = useIsDesktop();
|
|
304
305
|
const displayValue = useForm('RepeatableComponent', (state)=>{
|
|
@@ -325,6 +326,7 @@ const Component = ({ disabled, index, name, mainField = {
|
|
|
325
326
|
// Close all collapses
|
|
326
327
|
toggleCollapses();
|
|
327
328
|
},
|
|
329
|
+
onMoveItem,
|
|
328
330
|
...dragProps
|
|
329
331
|
});
|
|
330
332
|
React.useEffect(()=>{
|
|
@@ -337,6 +339,27 @@ const Component = ({ disabled, index, name, mainField = {
|
|
|
337
339
|
]);
|
|
338
340
|
const composedAccordionRefs = useComposedRefs(accordionRef, dragRef);
|
|
339
341
|
const composedBoxRefs = useComposedRefs(boxRef, dropRef);
|
|
342
|
+
const handleMoveUp = React.useCallback((e)=>{
|
|
343
|
+
e.stopPropagation();
|
|
344
|
+
if (index > 0 && onMoveItem) {
|
|
345
|
+
onMoveItem(index - 1, index);
|
|
346
|
+
}
|
|
347
|
+
}, [
|
|
348
|
+
index,
|
|
349
|
+
onMoveItem
|
|
350
|
+
]);
|
|
351
|
+
const handleMoveDown = React.useCallback((e)=>{
|
|
352
|
+
e.stopPropagation();
|
|
353
|
+
if (index < totalLength - 1 && onMoveItem) {
|
|
354
|
+
onMoveItem(index + 1, index);
|
|
355
|
+
}
|
|
356
|
+
}, [
|
|
357
|
+
index,
|
|
358
|
+
totalLength,
|
|
359
|
+
onMoveItem
|
|
360
|
+
]);
|
|
361
|
+
const canMoveUp = index > 0;
|
|
362
|
+
const canMoveDown = index < totalLength - 1;
|
|
340
363
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
341
364
|
children: isDragging ? /*#__PURE__*/ jsx(Preview, {}) : /*#__PURE__*/ jsxs(Accordion.Item, {
|
|
342
365
|
ref: composedBoxRefs,
|
|
@@ -371,6 +394,30 @@ const Component = ({ disabled, index, name, mainField = {
|
|
|
371
394
|
}),
|
|
372
395
|
onKeyDown: handleKeyDown,
|
|
373
396
|
children: /*#__PURE__*/ jsx(Drag, {})
|
|
397
|
+
}),
|
|
398
|
+
!isDesktop && /*#__PURE__*/ jsxs(Fragment, {
|
|
399
|
+
children: [
|
|
400
|
+
canMoveUp && /*#__PURE__*/ jsx(IconButton, {
|
|
401
|
+
disabled: disabled || !canMoveUp,
|
|
402
|
+
variant: "ghost",
|
|
403
|
+
onClick: handleMoveUp,
|
|
404
|
+
label: formatMessage({
|
|
405
|
+
id: getTranslation('components.DynamicZone.move-up'),
|
|
406
|
+
defaultMessage: 'Move up'
|
|
407
|
+
}),
|
|
408
|
+
children: /*#__PURE__*/ jsx(ArrowUp, {})
|
|
409
|
+
}),
|
|
410
|
+
canMoveDown && /*#__PURE__*/ jsx(IconButton, {
|
|
411
|
+
disabled: disabled || !canMoveDown,
|
|
412
|
+
variant: "ghost",
|
|
413
|
+
onClick: handleMoveDown,
|
|
414
|
+
label: formatMessage({
|
|
415
|
+
id: getTranslation('components.DynamicZone.move-down'),
|
|
416
|
+
defaultMessage: 'Move down'
|
|
417
|
+
}),
|
|
418
|
+
children: /*#__PURE__*/ jsx(ArrowDown, {})
|
|
419
|
+
})
|
|
420
|
+
]
|
|
374
421
|
})
|
|
375
422
|
]
|
|
376
423
|
})
|