Browse Source

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

main
xingyu 2 years ago
parent
commit
f789fa4df1
  1. 35
      src/components/Form/src/types/form.ts

35
src/components/Form/src/types/form.ts

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