2025-10-22 14:43:42 +08:00
|
|
|
|
import type { ColProps } from "antd/es/col";
|
|
|
|
|
|
import type { FormItemProps, Rule } from "antd/es/form";
|
2025-12-02 17:43:11 +08:00
|
|
|
|
import type { FormListFieldData } from "antd/es/form/FormList";
|
|
|
|
|
|
import type { Gutter } from "antd/es/grid/row";
|
2026-04-27 14:04:35 +08:00
|
|
|
|
import type { NamePath } from "rc-field-form/lib/interface";
|
2026-06-23 14:09:31 +08:00
|
|
|
|
import type { CSSProperties, ReactElement, ReactNode } from "react";
|
2025-12-18 16:29:53 +08:00
|
|
|
|
import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender";
|
2026-04-27 14:04:35 +08:00
|
|
|
|
import type { DeepPartial } from "./FormBuilder";
|
|
|
|
|
|
|
2026-05-08 09:55:46 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Form.List name 类型
|
|
|
|
|
|
*/
|
2026-04-27 14:04:35 +08:00
|
|
|
|
export type FormListOptionName<Values> = [number, NamePath<Values>];
|
2026-05-08 09:55:46 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Form.List 依赖项类型
|
|
|
|
|
|
*/
|
2026-05-15 11:21:10 +08:00
|
|
|
|
export type FormListOptionDependencies<Values> = NamePath<Values>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2026-03-06 10:30:42 +08:00
|
|
|
|
* 选择项数据类型
|
2025-10-22 14:43:42 +08:00
|
|
|
|
*/
|
|
|
|
|
|
export interface OptionItem {
|
|
|
|
|
|
/** ID字段 */
|
2025-11-04 16:20:00 +08:00
|
|
|
|
bianma?: any;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 名称字段 */
|
2026-01-22 17:20:11 +08:00
|
|
|
|
name?: string | ReactNode;
|
2026-01-19 14:43:16 +08:00
|
|
|
|
/** 是否禁用 */
|
|
|
|
|
|
disabled?: boolean;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
[key: string]: any;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 字段键配置
|
|
|
|
|
|
*/
|
2026-03-06 10:30:42 +08:00
|
|
|
|
export interface ItemsFieldConfig {
|
2025-12-24 15:45:07 +08:00
|
|
|
|
/** 值字段的键名,默认 'bianma' */
|
2025-10-22 14:43:42 +08:00
|
|
|
|
valueKey?: string;
|
2025-12-24 15:45:07 +08:00
|
|
|
|
/** 标签字段的键名,默认 'name' */
|
2025-12-16 17:17:22 +08:00
|
|
|
|
labelKey?: string | ((item: Record<string, any>) => ReactNode);
|
2025-10-22 14:43:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-20 13:50:40 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Form.List 操作项
|
|
|
|
|
|
*/
|
2026-04-27 14:04:35 +08:00
|
|
|
|
export interface FormListOperations<Values = any> {
|
2025-12-20 13:50:40 +08:00
|
|
|
|
/** 当前表单项的数据字段信息 */
|
|
|
|
|
|
field: FormListFieldData;
|
|
|
|
|
|
/** 当前项在列表中的索引位置 */
|
2025-12-24 14:27:07 +08:00
|
|
|
|
fieldIndex: number;
|
2025-12-20 13:50:40 +08:00
|
|
|
|
/** 新增方法 */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
add: (defaultValue?: DeepPartial<Values>, insertIndex?: number) => void;
|
2025-12-20 13:50:40 +08:00
|
|
|
|
/** 删除方法 */
|
|
|
|
|
|
remove: (index: number | number[]) => void;
|
|
|
|
|
|
/** 移动方法 */
|
|
|
|
|
|
move: (from: number, to: number) => void;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-02 17:43:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Form.List 独有的属性
|
|
|
|
|
|
*/
|
2026-04-27 14:04:35 +08:00
|
|
|
|
export interface FormListUniqueProps<Values = any, AllValues = Values> {
|
2025-12-02 17:43:11 +08:00
|
|
|
|
/** 是否显示新增按钮,默认 true */
|
|
|
|
|
|
showAddButton?: boolean;
|
|
|
|
|
|
/** 是否显示删除按钮,默认 true */
|
|
|
|
|
|
showRemoveButton?: boolean;
|
|
|
|
|
|
/** 新增按钮的文本,默认 '添加' */
|
|
|
|
|
|
addButtonText?: string;
|
|
|
|
|
|
/** 删除按钮的文本,默认 '删除' */
|
|
|
|
|
|
removeButtonText?: string;
|
|
|
|
|
|
/** 表单配置项 */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
options: (field: FormListFieldData, fieldIndex: number, operations: FormListOperations<Values>) => FormListOption<Values, AllValues>[];
|
2025-12-02 17:43:11 +08:00
|
|
|
|
/** 点击新增按钮时的默认值 */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
addDefaultValue?: DeepPartial<Values>;
|
2025-12-02 17:43:11 +08:00
|
|
|
|
/** 点击新增按钮时插入的索引位置 */
|
|
|
|
|
|
addInsertIndex?: number;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-14 17:56:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 条件类型辅助工具
|
|
|
|
|
|
*/
|
2026-05-08 09:55:46 +08:00
|
|
|
|
export type WhenTrue<Condition extends boolean, T> = Condition extends true ? never : T;
|
2026-04-14 17:56:20 +08:00
|
|
|
|
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 表单配置项属性类型辅助工具
|
|
|
|
|
|
*/
|
2026-05-08 09:55:46 +08:00
|
|
|
|
export type FormOptionProperty<IsOnlyForLabel extends boolean, IsCustomizeRender extends boolean, T> = WhenTrue<IsOnlyForLabel, WhenTrue<IsCustomizeRender, T>>;
|
2026-04-14 17:20:05 +08:00
|
|
|
|
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/**
|
2026-03-06 10:30:42 +08:00
|
|
|
|
* 表单配置项公共字段
|
2025-10-22 14:43:42 +08:00
|
|
|
|
*/
|
2026-04-27 14:04:35 +08:00
|
|
|
|
export interface FormOptionBase<
|
|
|
|
|
|
Values = any,
|
|
|
|
|
|
AllValues = Values,
|
|
|
|
|
|
IsOnlyForLabel extends boolean = false,
|
|
|
|
|
|
IsCustomizeRender extends boolean = false,
|
|
|
|
|
|
Name = NamePath<Values>,
|
|
|
|
|
|
Dependencies = NamePath<Values>,
|
|
|
|
|
|
> {
|
2025-11-05 14:42:39 +08:00
|
|
|
|
/** React 需要的 key,如果传递了唯一的 name,则不需要 */
|
|
|
|
|
|
key?: string;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 表单项字段名 */
|
2026-04-24 16:20:30 +08:00
|
|
|
|
name?: Name;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 表单项标签 */
|
|
|
|
|
|
label?: ReactNode;
|
2025-12-12 15:53:38 +08:00
|
|
|
|
/** 占据栅格列数,默认 12 */
|
2026-06-16 13:46:52 +08:00
|
|
|
|
span?: WhenTrue<IsOnlyForLabel, number>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 是否必填,默认 true,支持函数动态计算 */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
required?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, boolean | ((formValues: AllValues) => boolean)>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 验证规则 */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
rules?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, Rule | Rule[]>;
|
2025-12-15 15:26:56 +08:00
|
|
|
|
/** 是否使用字符验证限制 */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
useConstraints?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, boolean>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 占位符文本,默认会根据传入的 render 类型自动判断(请选择、请输入)和 label 组合 */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
placeholder?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, ReactNode>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 提示信息,传入将在 label 右侧生成图标展示 tooltip */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
tip?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, ReactNode>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 是否隐藏,默认 false,支持函数动态计算 */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
hidden?: WhenTrue<IsOnlyForLabel, boolean | ((formValues: AllValues) => boolean)>;
|
2025-11-11 09:10:08 +08:00
|
|
|
|
/** 是否自定义渲染,完全交给外部控制渲染,默认 false */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
customizeRender?: IsCustomizeRender;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 传递给 Form.Item 的属性,支持函数动态计算 */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
formItemProps?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, FormItemProps | ((formValues: AllValues) => FormItemProps)>;
|
2025-10-28 12:30:57 +08:00
|
|
|
|
/** label 栅格配置,默认直接使用外层的 labelCol,如果 span 等于 24,是外层的 labelCol.span 一半 */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
labelCol?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, ColProps>;
|
2025-12-24 15:45:07 +08:00
|
|
|
|
/** wrapper 栅格配置,默认 24 - labelCol.span */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
wrapperCol?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, ColProps>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 是否应该更新(用于表单联动) */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
shouldUpdate?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, boolean | ((prevValues: AllValues, nextValues: AllValues, info: { source?: string }) => boolean)>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 依赖字段(用于表单联动) */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
dependencies?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, Dependencies[]>;
|
2025-11-10 16:39:38 +08:00
|
|
|
|
/** 是否仅用于保存标签,不渲染到页面上,只在表单中保存数据,默认 false */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
onlyForLabel?: IsOnlyForLabel;
|
2026-06-23 14:09:31 +08:00
|
|
|
|
/** Col 的内联样式,会合并到 Col 的 style 上,支持函数动态计算 */
|
|
|
|
|
|
colStyle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, CSSProperties | ((formValues: AllValues) => CSSProperties)>;
|
|
|
|
|
|
/** Col 内部、Form.Item 之前渲染的标题节点,支持函数动态计算 */
|
|
|
|
|
|
colTitle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, ReactNode | ((formValues: AllValues) => ReactNode)>;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-06 10:30:42 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 按 render 类型区分的表单项
|
|
|
|
|
|
*/
|
2026-04-27 14:04:35 +08:00
|
|
|
|
export type FormOptionByRender<
|
|
|
|
|
|
RenderType extends keyof FORM_ITEM_RENDER_TYPE_MAP,
|
|
|
|
|
|
Values = any,
|
|
|
|
|
|
AllValues = Values,
|
|
|
|
|
|
IsOnlyForLabel extends boolean = false,
|
|
|
|
|
|
IsCustomizeRender extends boolean = false,
|
|
|
|
|
|
Name = NamePath<Values>,
|
|
|
|
|
|
Dependencies = NamePath<Values>,
|
|
|
|
|
|
> = FormOptionBase<Values, AllValues, IsOnlyForLabel, IsCustomizeRender, Name, Dependencies> & {
|
2026-03-06 10:30:42 +08:00
|
|
|
|
/** 渲染类型(写字面量时 componentProps 会按该类型推导) */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
render: RenderType;
|
2026-03-06 10:30:42 +08:00
|
|
|
|
/** 传递给表单控件的属性,类型由 render 决定 */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
componentProps?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, FORM_ITEM_RENDER_TYPE_MAP[RenderType] | ((formValues: AllValues) => FORM_ITEM_RENDER_TYPE_MAP[RenderType])>;
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/** 选项数据(用于 select、radio、checkbox) */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
items?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "select" | "radio" | "checkbox" ? OptionItem[] : never>;
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/** 字段键配置 */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
itemsField?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "select" | "radio" | "checkbox" ? ItemsFieldConfig : never>;
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/** checkbox 的栅格数量,如果不传入不使用栅格,传入才使用 */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
checkboxCol?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "checkbox" ? number : never>;
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/** Form.List 独有的属性 */
|
2026-06-16 14:13:22 +08:00
|
|
|
|
formListUniqueProps?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? FormListUniqueProps | ((formValues: AllValues) => FormListUniqueProps) : never>;
|
2026-06-23 14:09:31 +08:00
|
|
|
|
/** FormList 每行的内联样式,仅 render 为 formList 时可用,支持函数按行计算 */
|
|
|
|
|
|
rowStyle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? CSSProperties | ((field: FormListFieldData, fieldIndex: number) => CSSProperties) : never>;
|
|
|
|
|
|
/** FormList 每行起始位置渲染的标题节点,仅 render 为 formList 时可用,支持函数按行计算 */
|
|
|
|
|
|
rowTitle?: FormOptionProperty<IsOnlyForLabel, IsCustomizeRender, RenderType extends "formList" ? ReactNode | ((field: FormListFieldData, fieldIndex: number) => ReactNode) : never>;
|
2026-03-06 10:30:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 不写 render 或 render 为 input 时的表单项(默认按输入框)
|
|
|
|
|
|
*/
|
2026-04-27 14:04:35 +08:00
|
|
|
|
export type FormOptionDefault<
|
|
|
|
|
|
Values = any,
|
|
|
|
|
|
AllValues = Values,
|
|
|
|
|
|
IsOnlyForLabel extends boolean = false,
|
|
|
|
|
|
IsCustomizeRender extends boolean = false,
|
|
|
|
|
|
Name = NamePath<Values>,
|
|
|
|
|
|
Dependencies = NamePath<Values>,
|
|
|
|
|
|
> = FormOptionBase<Values, AllValues, IsOnlyForLabel, IsCustomizeRender, Name, Dependencies> & {
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/** 渲染类型,默认 input */
|
2026-03-06 10:30:42 +08:00
|
|
|
|
render?: "input" | undefined;
|
|
|
|
|
|
/** 传递给 Input 的属性 */
|
2026-04-27 14:04:35 +08:00
|
|
|
|
componentProps?: FORM_ITEM_RENDER_TYPE_MAP["input"] | ((formValues: AllValues) => FORM_ITEM_RENDER_TYPE_MAP["input"]);
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/** 选项数据(用于 select、radio、checkbox),input 时不需要 */
|
|
|
|
|
|
items?: never;
|
|
|
|
|
|
/** 字段键配置,input 时不需要 */
|
|
|
|
|
|
itemsField?: never;
|
|
|
|
|
|
/** checkbox 的栅格数量,input 时不需要 */
|
|
|
|
|
|
checkboxCol?: never;
|
|
|
|
|
|
/** Form.List 独有的属性,input 时不需要 */
|
|
|
|
|
|
formListUniqueProps?: never;
|
2026-03-06 10:30:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 自定义渲染时的表单项(render 为 ReactNode 时使用)
|
|
|
|
|
|
*/
|
2026-04-27 14:04:35 +08:00
|
|
|
|
export type FormOptionCustomRender<
|
|
|
|
|
|
Values = any,
|
|
|
|
|
|
AllValues = Values,
|
|
|
|
|
|
IsOnlyForLabel extends boolean = false,
|
|
|
|
|
|
IsCustomizeRender extends boolean = false,
|
|
|
|
|
|
Name = NamePath<Values>,
|
|
|
|
|
|
Dependencies = NamePath<Values>,
|
|
|
|
|
|
> = FormOptionBase<Values, AllValues, IsOnlyForLabel, IsCustomizeRender, Name, Dependencies> & {
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/** 渲染类型,默认 ReactNode */
|
|
|
|
|
|
render: ReactNode;
|
|
|
|
|
|
/** 传递给表单控件的属性,自定义渲染时不需要 */
|
2026-04-14 17:56:20 +08:00
|
|
|
|
componentProps?: never;
|
2026-04-14 17:20:05 +08:00
|
|
|
|
/** 选项数据(用于 select、radio、checkbox),自定义渲染时不需要 */
|
|
|
|
|
|
items?: never;
|
|
|
|
|
|
/** 字段键配置,自定义渲染时不需要 */
|
|
|
|
|
|
itemsField?: never;
|
|
|
|
|
|
/** checkbox 的栅格数量,自定义渲染时不需要 */
|
|
|
|
|
|
checkboxCol?: never;
|
|
|
|
|
|
/** Form.List 独有的属性,自定义渲染时不需要 */
|
|
|
|
|
|
formListUniqueProps?: never;
|
2026-03-06 10:30:42 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-06-16 15:58:10 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 根据 render 类型映射生成表单项联合类型
|
|
|
|
|
|
*/
|
|
|
|
|
|
export type FormOptionByRenderUnion<
|
|
|
|
|
|
Values = any,
|
|
|
|
|
|
AllValues = Values,
|
|
|
|
|
|
IsOnlyForLabel extends boolean = false,
|
|
|
|
|
|
IsCustomizeRender extends boolean = false,
|
|
|
|
|
|
Name = NamePath<Values>,
|
|
|
|
|
|
Dependencies = NamePath<Values>,
|
|
|
|
|
|
> = { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, IsOnlyForLabel, IsCustomizeRender, Name, Dependencies> }[keyof FORM_ITEM_RENDER_TYPE_MAP];
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 表单配置项联合类型组合
|
|
|
|
|
|
*/
|
|
|
|
|
|
export type FormOptionGroup<
|
|
|
|
|
|
Values = any,
|
|
|
|
|
|
AllValues = Values,
|
|
|
|
|
|
Name = NamePath<Values>,
|
|
|
|
|
|
Dependencies = NamePath<Values>,
|
|
|
|
|
|
>
|
|
|
|
|
|
= | FormOptionDefault<Values, AllValues, false, false, Name, Dependencies>
|
|
|
|
|
|
| FormOptionDefault<Values, AllValues, false, true, Name, Dependencies>
|
|
|
|
|
|
| FormOptionDefault<Values, AllValues, true, false, Name, Dependencies>
|
|
|
|
|
|
| FormOptionByRenderUnion<Values, AllValues, false, false, Name, Dependencies>
|
|
|
|
|
|
| FormOptionByRenderUnion<Values, AllValues, false, true, Name, Dependencies>
|
|
|
|
|
|
| FormOptionByRenderUnion<Values, AllValues, true, false, Name, Dependencies>
|
|
|
|
|
|
| FormOptionCustomRender<Values, AllValues, false, false, Name, Dependencies>
|
|
|
|
|
|
| FormOptionCustomRender<Values, AllValues, false, true, Name, Dependencies>
|
|
|
|
|
|
| FormOptionCustomRender<Values, AllValues, true, false, Name, Dependencies>;
|
|
|
|
|
|
|
2026-03-06 10:30:42 +08:00
|
|
|
|
/**
|
2026-04-27 14:04:35 +08:00
|
|
|
|
* 普通表单配置项
|
2026-03-06 10:30:42 +08:00
|
|
|
|
*/
|
2026-06-16 15:58:10 +08:00
|
|
|
|
export type FormOption<Values = any, AllValues = Values> = FormOptionGroup<Values, AllValues>;
|
2026-03-06 10:30:42 +08:00
|
|
|
|
|
2026-04-24 16:20:30 +08:00
|
|
|
|
/**
|
2026-04-27 14:04:35 +08:00
|
|
|
|
* Form.List 子项表单配置项
|
2026-04-24 16:20:30 +08:00
|
|
|
|
*/
|
2026-06-16 15:58:10 +08:00
|
|
|
|
export type FormListOption<Values = any, AllValues = Values> = FormOptionGroup<Values, AllValues, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>;
|
2026-04-24 16:20:30 +08:00
|
|
|
|
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* FormItemsRenderer 组件属性
|
|
|
|
|
|
*/
|
2026-04-21 16:08:44 +08:00
|
|
|
|
export interface FormItemsRendererProps<Values = any> {
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 表单配置项数组 */
|
2026-04-21 16:08:44 +08:00
|
|
|
|
options: FormOption<Values>[];
|
2025-10-22 14:43:42 +08:00
|
|
|
|
/** 默认栅格占据列数,默认 12 */
|
|
|
|
|
|
span?: number;
|
|
|
|
|
|
/** 是否折叠(仅显示前3项),默认 false */
|
|
|
|
|
|
collapse?: boolean;
|
|
|
|
|
|
/** 自动生成必填规则,默认 true */
|
|
|
|
|
|
useAutoGenerateRequired?: boolean;
|
2025-10-29 09:38:36 +08:00
|
|
|
|
/** 初始值,用于在表单未初始化时提供默认值 */
|
2026-06-16 13:46:52 +08:00
|
|
|
|
initialValues?: DeepPartial<Values>;
|
2025-12-02 17:43:11 +08:00
|
|
|
|
/** 栅格间距,继承自 FormBuilder */
|
|
|
|
|
|
gutter?: Gutter | [Gutter, Gutter];
|
|
|
|
|
|
/** label 栅格配置,继承自 FormBuilder */
|
|
|
|
|
|
labelCol?: ColProps;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 表单项渲染器组件
|
|
|
|
|
|
*/
|
2026-04-21 16:08:44 +08:00
|
|
|
|
declare const FormItemsRenderer: <Values = any>(props: FormItemsRendererProps<Values>) => ReactElement;
|
2025-10-22 14:43:42 +08:00
|
|
|
|
|
|
|
|
|
|
export default FormItemsRenderer;
|