refactor: replace GeneratedFormInputItem with FormInputItem across components for consistency

This commit is contained in:
twwu
2025-12-24 16:01:05 +08:00
parent 57dde4a4d8
commit afddc56bb4
11 changed files with 32 additions and 45 deletions

View File

@ -6,12 +6,12 @@ import { RiArrowLeftLine } from '@remixicon/react'
import Button from '@/app/components/base/button'
import ContentItem from '@/app/components/base/chat/chat/answer/human-input-content/content-item'
import { UserActionButtonType } from '@/app/components/workflow/nodes/human-input/types'
import type { GeneratedFormInputItem, UserAction } from '@/app/components/workflow/nodes/human-input/types'
import type { FormInputItem, UserAction } from '@/app/components/workflow/nodes/human-input/types'
type Props = {
nodeName: string
formContent: string
inputFields: GeneratedFormInputItem[]
inputFields: FormInputItem[]
userActions: UserAction[]
showBackButton?: boolean
handleBack?: () => void
@ -33,7 +33,7 @@ const FormContent = ({
return parts.filter(part => part.length > 0)
}
const initializeInputs = (formInputs: GeneratedFormInputItem[]) => {
const initializeInputs = (formInputs: FormInputItem[]) => {
const initialInputs: Record<string, any> = {}
formInputs.forEach((item) => {
if (item.type === 'text-input' || item.type === 'paragraph')

View File

@ -1,4 +1,9 @@
import type { CommonNodeType, InputVarType, ValueSelector, Variable } from '@/app/components/workflow/types'
import type {
CommonNodeType,
InputVarType,
ValueSelector,
Variable,
} from '@/app/components/workflow/types'
export type HumanInputNodeType = CommonNodeType & {
delivery_methods: DeliveryMethod[]
@ -43,24 +48,6 @@ export type DeliveryMethod = {
config?: EmailConfig | {} | null
}
export type FormInputItemPlaceholder = {
type: 'variable' | 'constant',
selector: ValueSelector
value: string
}
export type FormInputItem = {
type: InputVarType
output_variable_name: string
// only text-input and paragraph support placeholder
placeholder?: FormInputItemPlaceholder
options?: any[]
max_length?: number
allowed_file_extensions?: string[]
allowed_file_types?: string[]
allowed_file_upload_methods?: string[]
}
export enum UserActionButtonType {
Primary = 'primary',
Default = 'default',
@ -74,12 +61,14 @@ export type UserAction = {
button_style: UserActionButtonType
}
export type GeneratedFormInputItem = {
export type FormInputItemPlaceholder = {
selector: ValueSelector
type: 'variable' | 'constant'
value: string
}
export type FormInputItem = {
type: InputVarType
output_variable_name: string
placeholder: {
selector: ValueSelector
type: 'variable' | 'constant'
value: string
}
placeholder: FormInputItemPlaceholder
}