import { memo, } from 'react' import FormItem from '../../nodes/_base/components/before-run-form/form-item' import type { Node } from '../../types' import { useStore, useWorkflowStore, } from '../../store' import type { StartNodeType } from '../../nodes/start/types' import cn from '@/utils/classnames' import { useFindNode } from '@/app/components/workflow/hooks/use-find-node' const UserInput = () => { const workflowStore = useWorkflowStore() const inputs = useStore(s => s.inputs) const startNode = useFindNode(['sys']) as Node const showDebugAndPreviewPanel = useStore(s => s.showDebugAndPreviewPanel) const variables = startNode?.data.variables || [] const visibleVariables = showDebugAndPreviewPanel ? variables : variables.filter(v => v.hide !== true) const handleValueChange = (variable: string, v: string) => { const { inputs, setInputs, } = workflowStore.getState() setInputs({ ...inputs, [variable]: v, }) } if (!visibleVariables.length) return null return (
{visibleVariables.map((variable, index) => (
handleValueChange(variable.variable, v)} />
))}
) } export default memo(UserInput)