Skip to content

Commit

Permalink
feat: add formItemInstance type
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Jan 10, 2022
1 parent 7dda6e8 commit 23f5fba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
11 changes: 10 additions & 1 deletion components/form/FormItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PropType, ExtractPropTypes, ComputedRef, Ref } from 'vue';
import type { PropType, ExtractPropTypes, ComputedRef, Ref, ComponentPublicInstance } from 'vue';
import {
watch,
defineComponent,
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion components/form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 23f5fba

Please sign in to comment.