feat: add formItemInstance type

pull/5147/head
tangjinzhou 2022-01-10 09:27:03 +08:00
parent 7dda6e8e07
commit 23f5fba013
3 changed files with 12 additions and 3 deletions

View File

@ -74,7 +74,7 @@ export { default as Drawer } from './drawer';
export type { EmptyProps } from './empty';
export { default as Empty } from './empty';
export type { FormProps, FormItemProps, FormInstance } from './form';
export type { FormProps, FormItemProps, FormInstance, FormItemInstance } from './form';
export { default as Form, FormItem, FormItemRest } from './form';
export { default as Grid } from './grid';

View File

@ -1,4 +1,4 @@
import type { PropType, ExtractPropTypes, ComputedRef, Ref } from 'vue';
import type { PropType, ExtractPropTypes, ComputedRef, Ref, ComponentPublicInstance } from 'vue';
import {
watch,
defineComponent,
@ -99,6 +99,15 @@ export const formItemProps = {
export type FormItemProps = Partial<ExtractPropTypes<typeof formItemProps>>;
export type FormItemExpose = {
onFieldBlur: () => void;
onFieldChange: () => void;
clearValidate: () => void;
resetField: () => void;
};
export type FormItemInstance = ComponentPublicInstance<FormItemProps, FormItemExpose>;
let indexGuid = 0;
// default form item id prefix.

View File

@ -6,7 +6,7 @@ import FormItemRest, { useInjectFormItemContext } from './FormItemContext';
export type { Rule, RuleObject } from './interface';
export type { FormProps, FormInstance } from './Form';
export type { FormItemProps } from './FormItem';
export type { FormItemProps, FormItemInstance } from './FormItem';
Form.useInjectFormItemContext = useInjectFormItemContext;
Form.ItemRest = FormItemRest;