From f789fa4df1e5eb72060a3fd1071b53fa961147d5 Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 12 Oct 2023 11:08:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20useForm=20=E4=B8=AD=20scheme=20=E9=80=89?= =?UTF-8?q?=E9=A1=B9=20slot=20=E4=B8=8E=20component=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Form/src/types/form.ts | 35 +++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/components/Form/src/types/form.ts b/src/components/Form/src/types/form.ts index 108ae765..484c4c9a 100644 --- a/src/components/Form/src/types/form.ts +++ b/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