feat: export formInstance type
parent
89435951ae
commit
72f82771f1
|
@ -73,7 +73,7 @@ export { default as Drawer } from './drawer';
|
|||
export type { EmptyProps } from './empty';
|
||||
export { default as Empty } from './empty';
|
||||
|
||||
export type { FormProps, FormItemProps } from './form';
|
||||
export type { FormProps, FormItemProps, FormInstance } from './form';
|
||||
export { default as Form, FormItem, FormItemRest } from './form';
|
||||
|
||||
export { default as Grid } from './grid';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { PropType, ExtractPropTypes, HTMLAttributes } from 'vue';
|
||||
import type { PropType, ExtractPropTypes, HTMLAttributes, ComponentPublicInstance } from 'vue';
|
||||
import { defineComponent, computed, watch, ref } from 'vue';
|
||||
import PropTypes from '../_util/vue-types';
|
||||
import classNames from '../_util/classNames';
|
||||
|
@ -89,6 +89,29 @@ export const formProps = {
|
|||
|
||||
export type FormProps = Partial<ExtractPropTypes<typeof formProps>>;
|
||||
|
||||
export type FormExpose = {
|
||||
resetFields: (name?: NamePath) => void;
|
||||
clearValidate: (name?: NamePath) => void;
|
||||
validateFields: (
|
||||
nameList?: NamePath[],
|
||||
options?: ValidateOptions,
|
||||
) => Promise<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
getFieldsValue: (nameList?: InternalNamePath[] | true) => {
|
||||
[key: string]: any;
|
||||
};
|
||||
validate: (
|
||||
nameList?: NamePath[],
|
||||
options?: ValidateOptions,
|
||||
) => Promise<{
|
||||
[key: string]: any;
|
||||
}>;
|
||||
scrollToField: (name: NamePath, options?: {}) => void;
|
||||
};
|
||||
|
||||
export type FormInstance = ComponentPublicInstance<FormProps, FormExpose>;
|
||||
|
||||
function isEqualName(name1: NamePath, name2: NamePath) {
|
||||
return isEqual(toArray(name1), toArray(name2));
|
||||
}
|
||||
|
@ -328,7 +351,6 @@ const Form = defineComponent({
|
|||
});
|
||||
}
|
||||
};
|
||||
|
||||
expose({
|
||||
resetFields,
|
||||
clearValidate,
|
||||
|
@ -336,7 +358,7 @@ const Form = defineComponent({
|
|||
getFieldsValue,
|
||||
validate,
|
||||
scrollToField,
|
||||
});
|
||||
} as FormExpose);
|
||||
|
||||
useProvideForm({
|
||||
model: computed(() => props.model),
|
||||
|
|
|
@ -5,7 +5,7 @@ import useForm from './useForm';
|
|||
import FormItemRest, { useInjectFormItemContext } from './FormItemContext';
|
||||
export type { Rule, RuleObject } from './interface';
|
||||
|
||||
export type { FormProps } from './Form';
|
||||
export type { FormProps, FormInstance } from './Form';
|
||||
export type { FormItemProps } from './FormItem';
|
||||
|
||||
Form.useInjectFormItemContext = useInjectFormItemContext;
|
||||
|
|
Loading…
Reference in New Issue