|
|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
import type { DeepKeys } from '@tanstack/react-form'
|
|
|
|
|
import type { FormType } from '../..'
|
|
|
|
|
import type { Option } from '../../../select/pure'
|
|
|
|
|
|
|
|
|
|
@ -9,8 +8,8 @@ export enum BaseFieldType {
|
|
|
|
|
select = 'select',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type ShowCondition<T> = {
|
|
|
|
|
variable: DeepKeys<T>
|
|
|
|
|
export type ShowCondition = {
|
|
|
|
|
variable: string
|
|
|
|
|
value: any
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -29,21 +28,21 @@ export type SelectConfiguration = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type BaseConfiguration<T> = {
|
|
|
|
|
export type BaseConfiguration = {
|
|
|
|
|
label: string
|
|
|
|
|
variable: DeepKeys<T> // Variable name
|
|
|
|
|
variable: string // Variable name
|
|
|
|
|
maxLength?: number // Max length for text input
|
|
|
|
|
placeholder?: string
|
|
|
|
|
required: boolean
|
|
|
|
|
showOptional?: boolean // show optional label
|
|
|
|
|
showConditions: ShowCondition<T>[] // Show this field only when all conditions are met
|
|
|
|
|
showConditions: ShowCondition[] // Show this field only when all conditions are met
|
|
|
|
|
type: BaseFieldType
|
|
|
|
|
tooltip?: string // Tooltip for this field
|
|
|
|
|
} & NumberConfiguration & Partial<SelectConfiguration>
|
|
|
|
|
|
|
|
|
|
export type BaseFormProps<T> = {
|
|
|
|
|
initialData?: T
|
|
|
|
|
configurations: BaseConfiguration<T>[]
|
|
|
|
|
export type BaseFormProps = {
|
|
|
|
|
initialData?: Record<string, any>
|
|
|
|
|
configurations: BaseConfiguration[]
|
|
|
|
|
CustomActions?: (form: FormType) => React.ReactNode
|
|
|
|
|
onSubmit: (value: T) => void
|
|
|
|
|
onSubmit: (value: Record<string, any>) => void
|
|
|
|
|
}
|
|
|
|
|
|