import type { FC } from 'react' import type { LoopNodeType } from './types' import type { NodePanelProps } from '@/app/components/workflow/types' import { RiAddLine } from '@remixicon/react' import * as React from 'react' import { useTranslation } from 'react-i18next' import Field from '@/app/components/workflow/nodes/_base/components/field' import { LOOP_NODE_MAX_COUNT } from '@/config' import InputNumberWithSlider from '../_base/components/input-number-with-slider' import Split from '../_base/components/split' import ConditionWrap from './components/condition-wrap' import LoopVariable from './components/loop-variables' import useConfig from './use-config' const i18nPrefix = 'nodes.loop' const Panel: FC> = ({ id, data, }) => { const { t } = useTranslation() const { readOnly, inputs, childrenNodeVars, loopChildrenNodes, handleAddCondition, handleUpdateCondition, handleRemoveCondition, handleToggleConditionLogicalOperator, handleAddSubVariableCondition, handleRemoveSubVariableCondition, handleUpdateSubVariableCondition, handleToggleSubVariableConditionLogicalOperator, handleUpdateLoopCount, handleAddLoopVariable, handleRemoveLoopVariable, handleUpdateLoopVariable, } = useConfig(id, data) return (
{t('nodes.loop.loopVariables', { ns: 'workflow' })}
} operations={(
)} >
{t(`${i18nPrefix}.breakCondition`, { ns: 'workflow' })}
} tooltip={t(`${i18nPrefix}.breakConditionTip`, { ns: 'workflow' })} >
{t(`${i18nPrefix}.loopMaxCount`, { ns: 'workflow' })}
} >
{ const roundedVal = Math.round(val) handleUpdateLoopCount(Number.isNaN(roundedVal) ? 1 : roundedVal) }} />
{/* Error handling for the Loop node is currently not considered. */} {/*
*/} ) } export default React.memo(Panel)