fix: useForm 中 scheme 选项 slot 与 component冲突

pull/38/head
xingyu 2023-10-12 11:08:06 +08:00
parent 1814ed00ef
commit f789fa4df1
1 changed files with 25 additions and 10 deletions

View File

@ -119,11 +119,13 @@ export interface FormProps {
transformDateFunc?: (date: any) => string transformDateFunc?: (date: any) => string
colon?: boolean colon?: boolean
} }
export interface RenderOpts { export interface RenderOpts {
disabled: boolean disabled: boolean
[key: string]: any [key: string]: any
} }
export interface FormSchema {
interface BaseFormSchema {
// Field name // Field name
field: string field: string
// Extra Fields name[] // Extra Fields name[]
@ -144,12 +146,6 @@ export interface FormSchema {
labelWidth?: string | number labelWidth?: string | number
// Disable the adjustment of labelWidth with global settings of formModel, and manually set labelCol and wrapperCol by yourself // Disable the adjustment of labelWidth with global settings of formModel, and manually set labelCol and wrapperCol by yourself
disabledLabelWidth?: boolean disabledLabelWidth?: boolean
// render component
component: ComponentType
// Component parameters
componentProps?:
| ((opt: { schema: FormSchema; tableAction: TableActionType; formActionType: FormActionType; formModel: Recordable }) => Recordable)
| object
// Required // Required
required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean) required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean)
@ -198,9 +194,6 @@ export interface FormSchema {
renderComponentContent?: ((renderCallbackParams: RenderCallbackParams, opts: RenderOpts) => any) | VNode | VNode[] | string renderComponentContent?: ((renderCallbackParams: RenderCallbackParams, opts: RenderOpts) => any) | VNode | VNode[] | string
// Custom slot, in from-item
slot?: string
// Custom slot, similar to renderColContent // Custom slot, similar to renderColContent
colSlot?: string colSlot?: string
@ -208,6 +201,28 @@ export interface FormSchema {
dynamicRules?: (renderCallbackParams: RenderCallbackParams) => Rule[] dynamicRules?: (renderCallbackParams: RenderCallbackParams) => Rule[]
} }
interface ComponentFormSchema extends BaseFormSchema {
// render component
component: ComponentType
// Component parameters
componentProps?:
| ((opt: {
schema: FormSchema
tableAction: TableActionType
formActionType: FormActionType
formModel: Recordable
}) => Recordable)
| object
}
interface SlotFormSchema extends BaseFormSchema {
// Custom slot, in from-item
slot?: string
}
export type FormSchema = ComponentFormSchema | SlotFormSchema
export interface HelpComponentProps { export interface HelpComponentProps {
maxWidth: string maxWidth: string
// Whether to display the serial number // Whether to display the serial number