tav-ui
Version:
33 lines (32 loc) • 1.69 kB
TypeScript
import type { NamePath } from 'ant-design-vue/lib/form/interface';
import type { ComputedRef, Ref } from 'vue';
import type { FormActionType, FormEmitType, FormProps, FormSchema } from '../types/form';
declare type Recordable<T = any> = Record<string, T>;
interface Fn<T = any, R = T> {
(...arg: T[]): R;
}
interface UseFormActionContext {
emit: FormEmitType;
getProps: ComputedRef<FormProps>;
getSchema: ComputedRef<FormSchema[]>;
formModel: Recordable;
defaultValueRef: Ref<Recordable>;
formElRef: Ref<FormActionType>;
schemaRef: Ref<FormSchema[]>;
handleFormValues: Fn;
}
export declare function useFormEvents({ emit, getProps, formModel, getSchema, defaultValueRef, formElRef, schemaRef, handleFormValues, }: UseFormActionContext): {
handleSubmit: (e?: Event | undefined) => Promise<void>;
clearValidate: (name?: string | string[] | undefined) => Promise<void>;
validate: (nameList?: NamePath[] | undefined) => Promise<Recordable<any>>;
validateFields: (nameList?: NamePath[] | undefined) => Promise<any>;
getFieldsValue: () => Recordable;
updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>;
resetSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>;
appendSchemaByField: (schema: FormSchema, prefixField?: string | undefined, first?: boolean) => Promise<void>;
removeSchemaByFiled: (fields: string | string[]) => Promise<void>;
resetFields: () => Promise<void>;
setFieldsValue: (values: Recordable, useValidate?: boolean) => Promise<void>;
scrollToField: (name: NamePath, options?: ScrollOptions | undefined) => Promise<void>;
};
export {};