Skip to content

Commit 23f5fba

Browse files
committed
feat: add formItemInstance type
1 parent 7dda6e8 commit 23f5fba

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

components/components.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export { default as Drawer } from './drawer';
7474
export type { EmptyProps } from './empty';
7575
export { default as Empty } from './empty';
7676

77-
export type { FormProps, FormItemProps, FormInstance } from './form';
77+
export type { FormProps, FormItemProps, FormInstance, FormItemInstance } from './form';
7878
export { default as Form, FormItem, FormItemRest } from './form';
7979

8080
export { default as Grid } from './grid';

components/form/FormItem.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { PropType, ExtractPropTypes, ComputedRef, Ref } from 'vue';
1+
import type { PropType, ExtractPropTypes, ComputedRef, Ref, ComponentPublicInstance } from 'vue';
22
import {
33
watch,
44
defineComponent,
@@ -99,6 +99,15 @@ export const formItemProps = {
9999

100100
export type FormItemProps = Partial<ExtractPropTypes<typeof formItemProps>>;
101101

102+
export type FormItemExpose = {
103+
onFieldBlur: () => void;
104+
onFieldChange: () => void;
105+
clearValidate: () => void;
106+
resetField: () => void;
107+
};
108+
109+
export type FormItemInstance = ComponentPublicInstance<FormItemProps, FormItemExpose>;
110+
102111
let indexGuid = 0;
103112

104113
// default form item id prefix.

components/form/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import FormItemRest, { useInjectFormItemContext } from './FormItemContext';
66
export type { Rule, RuleObject } from './interface';
77

88
export type { FormProps, FormInstance } from './Form';
9-
export type { FormItemProps } from './FormItem';
9+
export type { FormItemProps, FormItemInstance } from './FormItem';
1010

1111
Form.useInjectFormItemContext = useInjectFormItemContext;
1212
Form.ItemRest = FormItemRest;

0 commit comments

Comments
 (0)