feat(form): FormBuilder和Search的values更改为全部可选属性
parent
fb42f2299b
commit
1b3d5d08c4
|
|
@ -3,12 +3,19 @@ import type { Gutter } from "antd/es/grid/row";
|
|||
import type { ReactElement, ReactNode } from "react";
|
||||
import type { FormOption } from "./FormItemsRenderer";
|
||||
|
||||
/**
|
||||
* 深度部分类型,将所有嵌套属性都变为可选
|
||||
*/
|
||||
export type DeepPartial<T> = T extends object
|
||||
? { [P in keyof T]?: DeepPartial<T[P]> }
|
||||
: T;
|
||||
|
||||
/**
|
||||
* FormBuilder 组件属性
|
||||
*/
|
||||
export interface FormBuilderProps<Values = any> extends Omit<FormProps, "form" | "onFinish"> {
|
||||
/** 表单初始值 */
|
||||
values?: Values;
|
||||
values?: DeepPartial<Values>;
|
||||
/** 表单配置项数组 */
|
||||
options: FormOption<Values>[];
|
||||
/** 栅格间距,默认 24 */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import type { FormInstance, FormProps } from "antd/es/form";
|
||||
import type { ReactElement, ReactNode } from "react";
|
||||
import type { FormOption } from "../FormBuilder";
|
||||
import type { DeepPartial } from "../FormBuilder/FormBuilder";
|
||||
|
||||
export type { FormOption };
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ export interface SearchProps<Values = any> extends Omit<FormProps, "form" | "onF
|
|||
/** 表单配置项数组 */
|
||||
options: FormOption<Values>[];
|
||||
/** 表单值 */
|
||||
values?: Values;
|
||||
values?: DeepPartial<Values>;
|
||||
/** 搜索和重置都会触发的回调 */
|
||||
onFinish?: (values: Values, type: "submit" | "reset") => void;
|
||||
/** 搜索回调 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue