UNPKG

@volverjs/form-vue

Version:

Vue 3 Forms with @volverjs/ui-vue

136 lines (135 loc) 7.33 kB
import { Component, InjectionKey, PropType, SlotsType, UnwrapRef } from 'vue'; import { RefinementCtx, z } from 'zod'; import { FormComponentOptions, FormSchema, FormTemplate, InjectedFormData, InjectedFormWrapperData, Path } from './types'; import { FormStatus } from './enums'; export declare function defineForm<Schema extends FormSchema, Type, FormTemplateComponent extends Component>(schema: Schema, provideKey: InjectionKey<InjectedFormData<Schema, Type>>, options: FormComponentOptions<Schema, Type>, VvFormTemplate: FormTemplateComponent, wrappers: Map<string, InjectedFormWrapperData<Schema>>): { clear: () => void; errors: import('vue').Ref<z.inferFormattedError<Schema, string> | undefined, z.inferFormattedError<Schema, string> | undefined>; formData: import('vue').Ref<(undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined>; ignoreUpdates: import('@vueuse/core').IgnoredUpdater; invalid: import('vue').ComputedRef<boolean>; readonly: import('vue').Ref<boolean, boolean>; reset: () => void; status: import('vue').Ref<FormStatus | undefined, FormStatus | undefined>; wrappers: Map<string, InjectedFormWrapperData<Schema>>; stopUpdatesWatch: import('vue').WatchStopHandle; submit: (options?: { fields?: Set<Path<z.infer<Schema>>>; superRefine?: (arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void>; }) => Promise<boolean>; validate: (value?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, options?: { fields?: Set<Path<z.infer<Schema>>>; superRefine?: (arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void>; }) => Promise<boolean>; VvForm: import('vue').DefineComponent<import('vue').ExtractPropTypes<{ continuousValidation: { type: BooleanConstructor; default: boolean; }; modelValue: { type: ObjectConstructor; default: () => {}; }; readonly: { type: BooleanConstructor; default: boolean; }; tag: { type: StringConstructor; default: string; }; template: { type: PropType<FormTemplate<Schema, Type>>; default: undefined; }; superRefine: { type: PropType<(arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void>>; default: undefined; }; validateFields: { type: PropType<Path<z.infer<Schema>>[]>; default: undefined; }; }>, { clear: () => void; errors: Readonly<import('vue').Ref<import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined, import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>; formData: import('vue').Ref<(undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined>; ignoreUpdates: import('@vueuse/core').IgnoredUpdater; invalid: import('vue').ComputedRef<boolean>; isReadonly: import('vue').Ref<boolean, boolean>; reset: () => void; status: Readonly<import('vue').Ref<FormStatus | undefined, FormStatus | undefined>>; stopUpdatesWatch: import('vue').WatchStopHandle; submit: () => Promise<boolean>; validate: (value?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, options?: { fields?: Set<Path<z.infer<Schema>>>; superRefine?: (arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void>; }) => Promise<boolean>; wrappers: Map<string, InjectedFormWrapperData<Schema>>; }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("invalid" | "valid" | "reset" | "submit" | "update:modelValue" | "update:readonly")[], "invalid" | "valid" | "reset" | "submit" | "update:modelValue" | "update:readonly", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{ continuousValidation: { type: BooleanConstructor; default: boolean; }; modelValue: { type: ObjectConstructor; default: () => {}; }; readonly: { type: BooleanConstructor; default: boolean; }; tag: { type: StringConstructor; default: string; }; template: { type: PropType<FormTemplate<Schema, Type>>; default: undefined; }; superRefine: { type: PropType<(arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void>>; default: undefined; }; validateFields: { type: PropType<Path<z.infer<Schema>>[]>; default: undefined; }; }>> & Readonly<{ onInvalid?: ((...args: any[]) => any) | undefined; onValid?: ((...args: any[]) => any) | undefined; onReset?: ((...args: any[]) => any) | undefined; onSubmit?: ((...args: any[]) => any) | undefined; "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined; "onUpdate:readonly"?: ((...args: any[]) => any) | undefined; }>, { superRefine: (arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void>; readonly: boolean; tag: string; template: FormTemplate<Schema, Type>; continuousValidation: boolean; modelValue: Record<string, any>; validateFields: Path<z.TypeOf<Schema>>[]; }, SlotsType<{ default: { errors: UnwrapRef<Readonly<import('vue').Ref<import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined, import('vue').DeepReadonly<z.inferFormattedError<Schema, string>> | undefined>>>; formData: UnwrapRef<import('vue').Ref<(undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined>>; invalid: UnwrapRef<import('vue').ComputedRef<boolean>>; readonly: UnwrapRef<import('vue').Ref<boolean, boolean>>; status: UnwrapRef<Readonly<import('vue').Ref<FormStatus | undefined, FormStatus | undefined>>>; wrappers: typeof wrappers; clear: () => void; ignoreUpdates: import('@vueuse/core').IgnoredUpdater; reset: () => void; stopUpdatesWatch: import('vue').WatchStopHandle; submit: (options?: { fields?: Set<Path<z.infer<Schema>>>; superRefine?: (arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void>; }) => Promise<boolean>; validate: (value?: (undefined extends Type ? Partial<z.TypeOf<Schema>> : Type) | undefined, options?: { fields?: Set<Path<z.infer<Schema>>>; superRefine?: (arg: z.infer<Schema>, ctx: RefinementCtx) => void | Promise<void>; }) => Promise<boolean>; }; }>, {}, {}, "invalid" | "valid" | "reset" | "status" | "readonly" | "clear" | "submit" | "errors" | "tag" | "template" | "validate", import('vue').ComponentProvideOptions, true, {}, any>; };