feat(form): FormBuilder和Search的values更改为全部可选属性

master
LiuJiaNan 2026-04-21 17:22:16 +08:00
parent fb42f2299b
commit 1b3d5d08c4
2 changed files with 10 additions and 2 deletions

View File

@ -3,12 +3,19 @@ import type { Gutter } from "antd/es/grid/row";
import type { ReactElement, ReactNode } from "react"; import type { ReactElement, ReactNode } from "react";
import type { FormOption } from "./FormItemsRenderer"; import type { FormOption } from "./FormItemsRenderer";
/**
*
*/
export type DeepPartial<T> = T extends object
? { [P in keyof T]?: DeepPartial<T[P]> }
: T;
/** /**
* FormBuilder * FormBuilder
*/ */
export interface FormBuilderProps<Values = any> extends Omit<FormProps, "form" | "onFinish"> { export interface FormBuilderProps<Values = any> extends Omit<FormProps, "form" | "onFinish"> {
/** 表单初始值 */ /** 表单初始值 */
values?: Values; values?: DeepPartial<Values>;
/** 表单配置项数组 */ /** 表单配置项数组 */
options: FormOption<Values>[]; options: FormOption<Values>[];
/** 栅格间距,默认 24 */ /** 栅格间距,默认 24 */

View File

@ -1,6 +1,7 @@
import type { FormInstance, FormProps } from "antd/es/form"; import type { FormInstance, FormProps } from "antd/es/form";
import type { ReactElement, ReactNode } from "react"; import type { ReactElement, ReactNode } from "react";
import type { FormOption } from "../FormBuilder"; import type { FormOption } from "../FormBuilder";
import type { DeepPartial } from "../FormBuilder/FormBuilder";
export type { FormOption }; export type { FormOption };
@ -11,7 +12,7 @@ export interface SearchProps<Values = any> extends Omit<FormProps, "form" | "onF
/** 表单配置项数组 */ /** 表单配置项数组 */
options: FormOption<Values>[]; options: FormOption<Values>[];
/** 表单值 */ /** 表单值 */
values?: Values; values?: DeepPartial<Values>;
/** 搜索和重置都会触发的回调 */ /** 搜索和重置都会触发的回调 */
onFinish?: (values: Values, type: "submit" | "reset") => void; onFinish?: (values: Values, type: "submit" | "reset") => void;
/** 搜索回调 */ /** 搜索回调 */