FormBuilder类型优化

master
LiuJiaNan 2026-06-16 15:58:10 +08:00
parent 39c7ddbddf
commit b26cf73667
1 changed files with 33 additions and 20 deletions

View File

@ -209,33 +209,46 @@ export type FormOptionCustomRender<
formListUniqueProps?: never;
};
/**
* 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>;
/**
*
*/
export type FormOption<Values = any, AllValues = Values>
= | FormOptionDefault<Values, AllValues, false, false>
| FormOptionDefault<Values, AllValues, false, true>
| FormOptionDefault<Values, AllValues, true, false>
| { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, false, false> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
| { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, false, true> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
| { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, true, false> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
| FormOptionCustomRender<Values, AllValues, false, false>
| FormOptionCustomRender<Values, AllValues, false, true>
| FormOptionCustomRender<Values, AllValues, true, false>;
export type FormOption<Values = any, AllValues = Values> = FormOptionGroup<Values, AllValues>;
/**
* Form.List
*/
export type FormListOption<Values = any, AllValues = Values>
= | FormOptionDefault<Values, AllValues, false, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
| FormOptionDefault<Values, AllValues, false, true, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
| FormOptionDefault<Values, AllValues, true, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
| { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, false, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
| { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, false, true, FormListOptionName<Values>, FormListOptionDependencies<AllValues>> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
| { [K in keyof FORM_ITEM_RENDER_TYPE_MAP]: FormOptionByRender<K, Values, AllValues, true, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>> }[keyof FORM_ITEM_RENDER_TYPE_MAP]
| FormOptionCustomRender<Values, AllValues, false, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
| FormOptionCustomRender<Values, AllValues, false, true, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>
| FormOptionCustomRender<Values, AllValues, true, false, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>;
export type FormListOption<Values = any, AllValues = Values> = FormOptionGroup<Values, AllValues, FormListOptionName<Values>, FormListOptionDependencies<AllValues>>;
/**
* FormItemsRenderer