import { RAGFlowNodeType } from '@/interfaces/database/flow'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import { Button, Collapse, Flex, Form, Input, Select } from 'antd'; import { PropsWithChildren, useCallback } from 'react'; import { useTranslation } from 'react-i18next'; import { useBuildComponentIdSelectOptions } from '../../hooks/use-get-begin-query'; import styles from './index.less'; interface IProps { name?: string; node?: RAGFlowNodeType; title?: string; } enum VariableType { Reference = 'reference', Input = 'input', } const getVariableName = (type: string) => type === VariableType.Reference ? 'component_id' : 'value'; const DynamicVariableForm = ({ name: formName, node }: IProps) => { const nextFormName = formName || 'query'; const { t } = useTranslation(); const valueOptions = useBuildComponentIdSelectOptions( node?.id, node?.parentId, ); const form = Form.useFormInstance(); const options = [ { value: VariableType.Reference, label: t('flow.reference') }, { value: VariableType.Input, label: t('flow.text') }, ]; const handleTypeChange = useCallback( (name: number) => () => { setTimeout(() => { form.setFieldValue([nextFormName, name, 'component_id'], undefined); form.setFieldValue([nextFormName, name, 'value'], undefined); }, 0); }, [form, nextFormName], ); return (