import React, { ReactNode } from 'react'; import { ButtonProps, ColProps, RowProps } from 'antd'; import { FormProps, FormInstance } from 'antd/es/form/Form'; import { NamePath } from 'antd/es/form/interface'; import type { StoreValue, Store } from '@rc-component/form/es/interface'; import type { ShouldUpdate } from '@rc-component/form/es/Field'; import type { ProFormColumnType, ViewType } from './components/render/propsType'; import type { ProFormComponentType } from './components'; export interface ButtonType extends ButtonProps { children?: any; } export interface FooterButtonType { okButtonProps?: ButtonType; cancelButtonProps?: ButtonType; } export interface ProFormItemChildType { value?: any; onChange?: () => void; [key: string]: any; } export type ModeEnum = 'search' | 'drawer'; type FooterType = ReactNode | { okButtonProps: ButtonType; cancelButtonProps: ButtonType; } | boolean; export declare const otherKeys: string[]; export interface ProFormOtherType { isView?: boolean; viewEmpty?: React.ReactNode; label?: React.ReactNode; valueType?: string; viewType?: ViewType; name?: NamePath; names?: NamePath[]; form?: FormInstance; type?: ProFormComponentType; hiddenNames?: string[] | any[]; colProps: ColProps; disabled: boolean; show?: boolean | (() => boolean); required?: boolean | boolean[] | (() => boolean | boolean[]); mode?: string; namePath?: any[] | string | number; listName?: any[] | string | number; globalControl?: boolean; formDisabled?: boolean; isDiffChange?: boolean; diffConfig?: DiffConfigType; shouldUpdateDebounce?: number; /** 灵活模式 Group 相关属性,独立管理灵活模式配置 */ flexibleGroupProps?: { className?: string; style?: React.CSSProperties; }; } export interface DiffConfigType { /** 比对原始数据源 */ originalValues: Values; /** 是否显示对比值气泡 */ toolTip?: boolean; /** 变更提示颜色 */ changeTipColor?: string; /** 新增提示颜色 */ addTipColor?: string; /** 是否跟随父组件滚动 */ scrollFollowParent?: string; } export interface ProFormType extends FormProps { disabled?: boolean; /** 全局控制优先 */ globalControl?: boolean; mode?: ModeEnum; /** * 如果有formKey,则会在全局中查找或创建表单实例 * 可以不需要手动传入form实例 且formKey的优先级高于form */ formKey?: string; /** 是否查看 */ isView?: boolean; span?: number; columns?: ProFormColumnType[]; rowProps?: RowProps; footer?: FooterType; expand?: boolean | number; expandOpen?: boolean; expandOpenChange?: (open: boolean) => void; onOk?: () => void; okText?: string; onCancel?: () => void; cancelText?: string; viewEmpty?: React.ReactNode | string; confirmLoading?: boolean; labelWidth?: string | number; /** 是否回车提交 */ submitOnEnter?: boolean; clearNotShow?: boolean; requiredOnView?: boolean; formId?: string; required?: boolean | boolean[]; /** 表单比对配置 */ diffConfig?: DiffConfigType; scrollToError?: boolean; /** 性能模式,谨慎使用,默认不开启 * 1. 开启不过滤names的中间态值 */ optimize?: boolean; /** 是否在遇到第一个错误时停止验证 */ stopOnFirstError?: boolean; /** shouldUpdate防抖延迟时间,默认500ms,设置为0则不防抖 */ shouldUpdateDebounce?: number; /** label 对齐方式 */ labelAlign?: 'left' | 'right'; } export interface TransformType { normalize?: (value: StoreValue, prevValue: StoreValue, allValues: Store) => StoreValue; getValueProps?: (value: StoreValue) => Record; shouldUpdate?: ShouldUpdate; } export type DistributiveOmit = T extends any ? Omit : never; /** * ProForm 组件接口类型 * 用于定义 ProForm 组件及其静态方法的类型 * 注意:此接口的具体实现方法类型在组件文件中定义,这里只提供基础结构 */ export interface ProFormInstanceType extends React.ForwardRefExoticComponent & React.RefAttributes>> { useForm: any; useWatch: any; useFormInstances: any; [key: string]: any; } export type { ProFormColumnType } from './components/render/propsType';