import type { ReactNode } from 'react' import type { ObjectValueItem } from './variable-modal.helpers' import { RiDraftLine, RiInputField } from '@remixicon/react' import Button from '@/app/components/base/button' import Input from '@/app/components/base/input' import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor' import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' import { ChatVarType } from '../type' import ArrayBoolList from './array-bool-list' import ArrayValueList from './array-value-list' import BoolValue from './bool-value' import ObjectValueList from './object-value-list' import VariableTypeSelector from './variable-type-select' type SectionTitleProps = { children: ReactNode } const SectionTitle = ({ children }: SectionTitleProps) => (
{children}
) type NameSectionProps = { name: string onBlur: (value: string) => void onChange: (e: React.ChangeEvent) => void placeholder: string title: string } export const NameSection = ({ name, onBlur, onChange, placeholder, title, }: NameSectionProps) => (
{title}
onBlur(e.target.value)} type="text" />
) type TypeSectionProps = { list: ChatVarType[] onSelect: (value: ChatVarType) => void title: string type: ChatVarType } export const TypeSection = ({ list, onSelect, title, type, }: TypeSectionProps) => (
{title}
) type ValueSectionProps = { editorContent?: string editorMinHeight: string editInJSON: boolean objectValue: ObjectValueItem[] onArrayBoolChange: (value: boolean[]) => void onArrayChange: (value: Array) => void onEditorChange: (nextEditInJson: boolean) => void onEditorValueChange: (content: string) => void onObjectChange: (value: ObjectValueItem[]) => void onValueChange: (value: boolean) => void placeholder: ReactNode t: (key: string, options?: Record) => string toggleLabelKey?: string type: ChatVarType value: unknown } export const ValueSection = ({ editorContent, editorMinHeight, editInJSON, objectValue, onArrayBoolChange, onArrayChange, onEditorChange, onEditorValueChange, onObjectChange, onValueChange, placeholder, t, toggleLabelKey, type, value, }: ValueSectionProps) => (
{t('chatVariable.modal.value', { ns: 'workflow' })}
{toggleLabelKey && ( )}
{type === ChatVarType.String && (