diff --git a/packages/form-js-viewer/src/features/repeatRender/RepeatRenderManager.js b/packages/form-js-viewer/src/features/repeatRender/RepeatRenderManager.js index 8b3822959..e91d03ab8 100644 --- a/packages/form-js-viewer/src/features/repeatRender/RepeatRenderManager.js +++ b/packages/form-js-viewer/src/features/repeatRender/RepeatRenderManager.js @@ -79,36 +79,19 @@ export class RepeatRenderManager { return ( <> - {displayValues.map((value, index) => { - const elementProps = useMemo(() => ({ - ...restProps, - indexes: { ...(indexes || {}), [ repeaterField.id ]: index } - }), [ index ]); - - const localExpressionContextInfo = useMemo(() => ({ - data: parentExpressionContextInfo.data, - this: value, - parent: buildExpressionContext(parentExpressionContextInfo), - i: [ ...parentExpressionContextInfo.i , index + 1 ] - }), [ index, value ]); - - return !showRemove ? - - - : -
-
- - - -
- -
; - })} + {displayValues.map((value, index) => + + )} ); } @@ -196,4 +179,63 @@ export class RepeatRenderManager { } +/** + * Individual repetition of a repeated field and context scaffolding. + * + * @param {Object} props + * @param {number} props.index + * @param {Object} props.value + * @param {Object} props.parentExpressionContextInfo + * @param {Object} props.repeaterField + * @param {Function} props.RowsRenderer + * @param {Object} props.indexes + * @param {Function} props.onDeleteItem + * @param {boolean} props.showRemove + */ + +const RepetitionScaffold = (props) => { + + const { + index, + value, + parentExpressionContextInfo, + repeaterField, + RowsRenderer, + indexes, + onDeleteItem, + showRemove, + ...restProps + } = props; + + const elementProps = useMemo(() => ({ + ...restProps, + indexes: { ...(indexes || {}), [ repeaterField.id ]: index } + }), [ index, indexes, repeaterField.id, restProps ]); + + const localExpressionContextInfo = useMemo(() => ({ + data: parentExpressionContextInfo.data, + this: value, + parent: buildExpressionContext(parentExpressionContextInfo), + i: [ ...parentExpressionContextInfo.i , index + 1 ] + }), [ index, parentExpressionContextInfo, value ]); + + return !showRemove ? + + + : +
+
+ + + +
+ +
; + +}; + RepeatRenderManager.$inject = [ 'form', 'formFields', 'formFieldRegistry', 'pathRegistry' ]; \ No newline at end of file