UNPKG

55.1 kBTypeScriptView Raw
1import * as vue from 'vue';
2import { MaybeRef, Ref, MaybeRefOrGetter, ComputedRef, PropType, VNode, UnwrapRef, InjectionKey } from 'vue';
3import { PartialDeep } from 'type-fest';
4
5type BrowserNativeObject = Date | FileList | File;
6type Primitive = null | undefined | string | number | boolean | symbol | bigint;
7/**
8 * Checks whether the type is any
9 * See {@link https://stackoverflow.com/a/49928360/3406963}
10 * @typeParam T - type which may be any
11 * ```
12 * IsAny<any> = true
13 * IsAny<string> = false
14 * ```
15 */
16type IsAny<T> = 0 extends 1 & T ? true : false;
17/**
18 * Checks whether T1 can be exactly (mutually) assigned to T2
19 * @typeParam T1 - type to check
20 * @typeParam T2 - type to check against
21 * ```
22 * IsEqual<string, string> = true
23 * IsEqual<'foo', 'foo'> = true
24 * IsEqual<string, number> = false
25 * IsEqual<string, number> = false
26 * IsEqual<string, 'foo'> = false
27 * IsEqual<'foo', string> = false
28 * IsEqual<'foo' | 'bar', 'foo'> = boolean // 'foo' is assignable, but 'bar' is not (true | false) -> boolean
29 * ```
30 */
31type IsEqual<T1, T2> = T1 extends T2 ? (<G>() => G extends T1 ? 1 : 2) extends <G>() => G extends T2 ? 1 : 2 ? true : false : false;
32/**
33 * Type to query whether an array type T is a tuple type.
34 * @typeParam T - type which may be an array or tuple
35 * @example
36 * ```
37 * IsTuple<[number]> = true
38 * IsTuple<number[]> = false
39 * ```
40 */
41type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
42/**
43 * Type which can be used to index an array or tuple type.
44 */
45type ArrayKey = number;
46/**
47 * Helper function to break apart T1 and check if any are equal to T2
48 *
49 * See {@link IsEqual}
50 */
51type AnyIsEqual<T1, T2> = T1 extends T2 ? (IsEqual<T1, T2> extends true ? true : never) : never;
52/**
53 * Type which given a tuple type returns its own keys, i.e. only its indices.
54 * @typeParam T - tuple type
55 * @example
56 * ```
57 * TupleKeys<[number, string]> = '0' | '1'
58 * ```
59 */
60type TupleKeys<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
61/**
62 * Helper type for recursively constructing paths through a type.
63 * This actually constructs the strings and recurses into nested
64 * object types.
65 *
66 * See {@link Path}
67 */
68type PathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? `${K}` : true extends AnyIsEqual<TraversedTypes, V> ? `${K}` : `${K}` | `${K}.${PathInternal<V, TraversedTypes | V>}`;
69/**
70 * Helper type for recursively constructing paths through a type.
71 * This obscures the internal type param TraversedTypes from ed contract.
72 *
73 * See {@link Path}
74 */
75type PathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
76 [K in TupleKeys<T>]-?: PathImpl<K & string, T[K], TraversedTypes>;
77}[TupleKeys<T>] : PathImpl<ArrayKey, V, TraversedTypes> : {
78 [K in keyof T]-?: PathImpl<K & string, T[K], TraversedTypes>;
79}[keyof T];
80/**
81 * Helper type for recursively constructing paths through a type.
82 * This actually constructs the strings and recurses into nested
83 * object types.
84 *
85 * See {@link ArrayPath}
86 */
87type ArrayPathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? IsAny<V> extends true ? string : never : V extends ReadonlyArray<infer U> ? U extends Primitive | BrowserNativeObject ? IsAny<V> extends true ? string : never : true extends AnyIsEqual<TraversedTypes, V> ? never : `${K}` | `${K}.${ArrayPathInternal<V, TraversedTypes | V>}` : true extends AnyIsEqual<TraversedTypes, V> ? never : `${K}.${ArrayPathInternal<V, TraversedTypes | V>}`;
88/**
89 * Helper type for recursively constructing paths through a type.
90 * This obscures the internal type param TraversedTypes from ed contract.
91 *
92 * See {@link ArrayPath}
93 */
94type ArrayPathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? {
95 [K in TupleKeys<T>]-?: ArrayPathImpl<K & string, T[K], TraversedTypes>;
96}[TupleKeys<T>] : ArrayPathImpl<ArrayKey, V, TraversedTypes> : {
97 [K in keyof T]-?: ArrayPathImpl<K & string, T[K], TraversedTypes>;
98}[keyof T];
99/**
100 * Type which eagerly collects all paths through a type which point to an array
101 * type.
102 * @typeParam T - type which should be introspected.
103 * @example
104 * ```
105 * Path<{foo: {bar: string[], baz: number[]}}> = 'foo.bar' | 'foo.baz'
106 * ```
107 */
108type ArrayPath<T> = T extends any ? ArrayPathInternal<T> : never;
109/**
110 * Type to evaluate the type which the given path points to.
111 * @typeParam T - deeply nested type which is indexed by the path
112 * @typeParam P - path into the deeply nested type
113 * @example
114 * ```
115 * PathValue<{foo: {bar: string}}, 'foo.bar'> = string
116 * PathValue<[number, string], '1'> = string
117 * ```
118 */
119type PathValue<T, P extends Path<T> | ArrayPath<T>> = T extends any ? P extends `${infer K}.${infer R}` ? K extends keyof T ? R extends Path<T[K]> ? PathValue<T[K], R> : never : K extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? PathValue<V, R & Path<V>> : never : never : P extends keyof T ? T[P] : P extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? V : never : never : never;
120/**
121 * Type which eagerly collects all paths through a type
122 * @typeParam T - type which should be introspected
123 * @example
124 * ```
125 * Path<{foo: {bar: string}}> = 'foo' | 'foo.bar'
126 * ```
127 */
128type Path<T> = T extends any ? PathInternal<T> : never;
129
130type GenericObject = Record<string, any>;
131type MaybeArray<T> = T | T[];
132type MaybePromise<T> = T | Promise<T>;
133type FlattenAndSetPathsType<TRecord, TType> = {
134 [K in Path<TRecord>]: TType;
135};
136type MapValuesPathsToRefs<TValues extends GenericObject, TPaths extends readonly [...MaybeRef<Path<TValues>>[]]> = {
137 readonly [K in keyof TPaths]: TPaths[K] extends MaybeRef<infer TKey> ? TKey extends Path<TValues> ? Ref<PathValue<TValues, TKey>> : Ref<unknown> : Ref<unknown>;
138};
139
140interface FieldValidationMetaInfo {
141 field: string;
142 name: string;
143 label?: string;
144 value: unknown;
145 form: Record<string, unknown>;
146 rule?: {
147 name: string;
148 params?: Record<string, unknown> | unknown[];
149 };
150}
151type ValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams, ctx: FieldValidationMetaInfo) => boolean | string | Promise<boolean | string>;
152type SimpleValidationRuleFunction<TValue = unknown, TParams = unknown[] | Record<string, unknown>> = (value: TValue, params: TParams) => boolean | string | Promise<boolean | string>;
153type ValidationMessageGenerator = (ctx: FieldValidationMetaInfo) => string;
154
155interface ValidationResult<TValue = unknown> {
156 errors: string[];
157 valid: boolean;
158 value?: TValue;
159}
160type FlattenAndMapPathsValidationResult<TInput extends GenericObject, TOutput extends GenericObject> = {
161 [K in Path<TInput>]: ValidationResult<TOutput[K]>;
162};
163interface TypedSchemaError {
164 path?: string;
165 errors: string[];
166}
167interface TypedSchemaPathDescription {
168 required: boolean;
169 exists: boolean;
170}
171interface TypedSchemaContext {
172 formData: GenericObject;
173}
174interface TypedSchema<TInput = any, TOutput = TInput> {
175 __type: 'VVTypedSchema';
176 parse(values: TInput, context?: TypedSchemaContext): Promise<{
177 value?: TOutput;
178 errors: TypedSchemaError[];
179 }>;
180 cast?(values: Partial<TInput>): TInput;
181 describe?(path?: Path<TInput>): Partial<TypedSchemaPathDescription>;
182}
183type InferOutput<TSchema extends TypedSchema> = TSchema extends TypedSchema<any, infer TOutput> ? TOutput : never;
184type InferInput<TSchema extends TypedSchema> = TSchema extends TypedSchema<infer TInput, any> ? TInput : never;
185type YupSchema<TValues = any> = {
186 __isYupSchema__: boolean;
187 validate(value: any, options: GenericObject): Promise<any>;
188};
189type Locator = {
190 __locatorRef: string;
191} & ((values: GenericObject) => unknown);
192interface FieldMeta<TValue> {
193 touched: boolean;
194 dirty: boolean;
195 valid: boolean;
196 validated: boolean;
197 required: boolean;
198 pending: boolean;
199 initialValue?: TValue;
200}
201interface FormMeta<TValues extends GenericObject> {
202 touched: boolean;
203 dirty: boolean;
204 valid: boolean;
205 pending: boolean;
206 initialValues?: Partial<TValues>;
207}
208interface FieldState<TValue = unknown> {
209 value: TValue;
210 touched: boolean;
211 errors: string[];
212}
213type InputType = 'checkbox' | 'radio' | 'default';
214/**
215 * validated-only: only mutate the previously validated fields
216 * silent: do not mutate any field
217 * force: validate all fields and mutate their state
218 */
219type SchemaValidationMode = 'validated-only' | 'silent' | 'force';
220interface ValidationOptions$1 {
221 mode: SchemaValidationMode;
222 warn: boolean;
223}
224type FieldValidator<TOutput> = (opts?: Partial<ValidationOptions$1>) => Promise<ValidationResult<TOutput>>;
225interface PathStateConfig<TOutput> {
226 bails: boolean;
227 label: MaybeRefOrGetter<string | undefined>;
228 type: InputType;
229 validate: FieldValidator<TOutput>;
230 schema?: MaybeRefOrGetter<TypedSchema | undefined>;
231}
232interface PathState<TInput = unknown, TOutput = TInput> {
233 id: number | number[];
234 path: string;
235 touched: boolean;
236 dirty: boolean;
237 valid: boolean;
238 required: boolean;
239 validated: boolean;
240 pending: boolean;
241 initialValue: TInput | undefined;
242 value: TInput | undefined;
243 errors: string[];
244 bails: boolean;
245 label: string | undefined;
246 type: InputType;
247 multiple: boolean;
248 fieldsCount: number;
249 __flags: {
250 pendingUnmount: Record<string, boolean>;
251 pendingReset: boolean;
252 };
253 validate?: FieldValidator<TOutput>;
254}
255interface FieldEntry<TValue = unknown> {
256 value: TValue;
257 key: string | number;
258 isFirst: boolean;
259 isLast: boolean;
260}
261interface FieldArrayContext<TValue = unknown> {
262 fields: Ref<FieldEntry<TValue>[]>;
263 remove(idx: number): void;
264 replace(newArray: TValue[]): void;
265 update(idx: number, value: TValue): void;
266 push(value: TValue): void;
267 swap(indexA: number, indexB: number): void;
268 insert(idx: number, value: TValue): void;
269 prepend(value: TValue): void;
270 move(oldIdx: number, newIdx: number): void;
271}
272interface PrivateFieldArrayContext<TValue = unknown> extends FieldArrayContext<TValue> {
273 reset(): void;
274 path: MaybeRefOrGetter<string>;
275}
276interface PrivateFieldContext<TInput = unknown, TOutput = TInput> {
277 id: number;
278 name: MaybeRef<string>;
279 value: Ref<TInput>;
280 meta: FieldMeta<TInput>;
281 errors: Ref<string[]>;
282 errorMessage: Ref<string | undefined>;
283 label?: MaybeRefOrGetter<string | undefined>;
284 type?: string;
285 bails?: boolean;
286 keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
287 checkedValue?: MaybeRefOrGetter<TInput>;
288 uncheckedValue?: MaybeRefOrGetter<TInput>;
289 checked?: Ref<boolean>;
290 resetField(state?: Partial<FieldState<TInput>>): void;
291 handleReset(): void;
292 validate: FieldValidator<TOutput>;
293 handleChange(e: Event | unknown, shouldValidate?: boolean): void;
294 handleBlur(e?: Event, shouldValidate?: boolean): void;
295 setState(state: Partial<FieldState<TInput>>): void;
296 setTouched(isTouched: boolean): void;
297 setErrors(message: string | string[]): void;
298 setValue(value: TInput, shouldValidate?: boolean): void;
299}
300type FieldContext<TValue = unknown> = Omit<PrivateFieldContext<TValue>, 'id' | 'instances'>;
301type GenericValidateFunction<TValue = unknown> = (value: TValue, ctx: FieldValidationMetaInfo) => MaybePromise<boolean | MaybeArray<string>>;
302interface FormState<TValues> {
303 values: PartialDeep<TValues>;
304 errors: Partial<Record<Path<TValues>, string | undefined>>;
305 touched: Partial<Record<Path<TValues>, boolean>>;
306 submitCount: number;
307}
308type FormErrors<TValues extends GenericObject> = Partial<Record<Path<TValues>, string | undefined>>;
309type FormErrorBag<TValues extends GenericObject> = Partial<Record<Path<TValues>, string[]>>;
310interface ResetFormOpts {
311 force: boolean;
312}
313interface FormActions<TValues extends GenericObject, TOutput = TValues> {
314 setFieldValue<T extends Path<TValues>>(field: T, value: PathValue<TValues, T>, shouldValidate?: boolean): void;
315 setFieldError(field: Path<TValues>, message: string | string[] | undefined): void;
316 setErrors(fields: Partial<FlattenAndSetPathsType<TValues, string | string[] | undefined>>): void;
317 setValues(fields: PartialDeep<TValues>, shouldValidate?: boolean): void;
318 setFieldTouched(field: Path<TValues>, isTouched: boolean): void;
319 setTouched(fields: Partial<Record<Path<TValues>, boolean>> | boolean): void;
320 resetForm(state?: Partial<FormState<TValues>>, opts?: Partial<ResetFormOpts>): void;
321 resetField(field: Path<TValues>, state?: Partial<FieldState>): void;
322}
323interface FormValidationResult<TInput extends GenericObject, TOutput extends GenericObject = TInput> {
324 valid: boolean;
325 results: Partial<FlattenAndMapPathsValidationResult<TInput, TOutput>>;
326 errors: Partial<Record<Path<TInput>, string>>;
327 values?: Partial<TOutput>;
328 source: 'schema' | 'fields' | 'none';
329}
330interface SubmissionContext<TInput extends GenericObject = GenericObject> extends FormActions<TInput> {
331 evt?: Event;
332 controlledValues: Partial<TInput>;
333}
334type SubmissionHandler<TInput extends GenericObject = GenericObject, TOutput = TInput, TReturn = unknown> = (values: TOutput, ctx: SubmissionContext<TInput>) => TReturn;
335interface InvalidSubmissionContext<TInput extends GenericObject = GenericObject, TOutput extends GenericObject = TInput> {
336 values: TInput;
337 evt?: Event;
338 errors: Partial<Record<Path<TInput>, string>>;
339 results: FormValidationResult<TInput, TOutput>['results'];
340}
341type InvalidSubmissionHandler<TInput extends GenericObject = GenericObject, TOutput extends GenericObject = TInput> = (ctx: InvalidSubmissionContext<TInput, TOutput>) => void;
342type RawFormSchema<TValues> = Record<Path<TValues>, string | GenericValidateFunction | GenericObject>;
343type FieldPathLookup<TValues extends GenericObject = GenericObject> = Partial<Record<Path<TValues>, PrivateFieldContext | PrivateFieldContext[]>>;
344type HandleSubmitFactory<TValues extends GenericObject, TOutput extends GenericObject = TValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TOutput, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues, TOutput>) => (e?: Event) => Promise<TReturn | undefined>;
345type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type' | '__flags'>;
346interface BaseFieldProps {
347 onBlur: () => void;
348 onChange: () => void;
349 onInput: () => void;
350}
351interface InputBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> {
352 props: (state: PublicPathState<TValue>) => TExtraProps;
353 validateOnBlur: boolean;
354 label: MaybeRefOrGetter<string>;
355 validateOnChange: boolean;
356 validateOnInput: boolean;
357 validateOnModelUpdate: boolean;
358}
359type LazyInputBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> = (state: PublicPathState<TValue>) => Partial<{
360 props: TExtraProps;
361 validateOnBlur: boolean;
362 validateOnChange: boolean;
363 validateOnInput: boolean;
364 validateOnModelUpdate: boolean;
365}>;
366interface ComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject, TModel extends string = 'modelValue'> {
367 mapProps: (state: PublicPathState<TValue>) => TExtraProps;
368 validateOnBlur: boolean;
369 validateOnModelUpdate: boolean;
370 model: TModel;
371}
372type LazyComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject, TModel extends string = 'modelValue'> = (state: PublicPathState<TValue>) => Partial<{
373 props: TExtraProps;
374 validateOnBlur: boolean;
375 validateOnModelUpdate: boolean;
376 model: TModel;
377}>;
378interface ComponentModellessBinds {
379 onBlur: () => void;
380}
381type ComponentModelBinds<TValue = any, TModel extends string = 'modelValue'> = ComponentModellessBinds & {
382 [TKey in `onUpdate:${TModel}`]: (value: TValue) => void;
383};
384type BaseComponentBinds<TValue = any, TModel extends string = 'modelValue'> = ComponentModelBinds<TValue, TModel> & {
385 [k in TModel]: TValue;
386};
387interface BaseInputBinds<TValue = unknown> {
388 value: TValue | undefined;
389 onBlur: (e: Event) => void;
390 onChange: (e: Event) => void;
391 onInput: (e: Event) => void;
392}
393interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues> extends FormActions<TValues> {
394 name: string;
395 formId: number;
396 values: TValues;
397 initialValues: Ref<Partial<TValues>>;
398 controlledValues: Ref<TValues>;
399 fieldArrays: PrivateFieldArrayContext[];
400 submitCount: Ref<number>;
401 schema?: MaybeRef<RawFormSchema<TValues> | TypedSchema<TValues, TOutput> | YupSchema<TValues> | undefined>;
402 errorBag: Ref<FormErrorBag<TValues>>;
403 errors: ComputedRef<FormErrors<TValues>>;
404 meta: ComputedRef<FormMeta<TValues>>;
405 isSubmitting: Ref<boolean>;
406 isValidating: Ref<boolean>;
407 keepValuesOnUnmount: MaybeRef<boolean>;
408 validateSchema?: (mode: SchemaValidationMode) => Promise<FormValidationResult<TValues, TOutput>>;
409 validate(opts?: Partial<ValidationOptions$1>): Promise<FormValidationResult<TValues, TOutput>>;
410 validateField<TPath extends Path<TValues>>(field: TPath, opts?: Partial<ValidationOptions$1>): Promise<ValidationResult<TOutput[TPath]>>;
411 stageInitialValue(path: string, value: unknown, updateOriginal?: boolean): void;
412 unsetInitialValue(path: string): void;
413 handleSubmit: HandleSubmitFactory<TValues, TOutput> & {
414 withControlled: HandleSubmitFactory<TValues, TOutput>;
415 };
416 setFieldInitialValue(path: string, value: unknown, updateOriginal?: boolean): void;
417 createPathState<TPath extends Path<TValues>>(path: MaybeRef<TPath>, config?: Partial<PathStateConfig<TOutput[TPath]>>): PathState<PathValue<TValues, TPath>>;
418 getPathState<TPath extends Path<TValues>>(path: TPath): PathState<PathValue<TValues, TPath>> | undefined;
419 getAllPathStates(): PathState[];
420 removePathState<TPath extends Path<TValues>>(path: TPath, id: number): void;
421 unsetPathValue<TPath extends Path<TValues>>(path: TPath): void;
422 destroyPath(path: string): void;
423 isFieldTouched<TPath extends Path<TValues>>(path: TPath): boolean;
424 isFieldDirty<TPath extends Path<TValues>>(path: TPath): boolean;
425 isFieldValid<TPath extends Path<TValues>>(path: TPath): boolean;
426 defineField<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>): [Ref<TValue>, Ref<BaseFieldProps & TExtras>];
427 /**
428 * @deprecated use defineField instead
429 */
430 useFieldModel<TPath extends Path<TValues>>(path: TPath): Ref<PathValue<TValues, TPath>>;
431 /**
432 * @deprecated use defineField instead
433 */
434 useFieldModel<TPaths extends readonly [...MaybeRef<Path<TValues>>[]]>(paths: TPaths): MapValuesPathsToRefs<TValues, TPaths>;
435 /**
436 * @deprecated use defineField instead
437 */
438 defineComponentBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TModel extends string = 'modelValue', TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<ComponentBindsConfig<TValue, TExtras, TModel>> | LazyComponentBindsConfig<TValue, TExtras, TModel>): Ref<BaseComponentBinds<TValue, TModel> & TExtras>;
439 /**
440 * @deprecated use defineField instead
441 */
442 defineInputBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>): Ref<BaseInputBinds<TValue> & TExtras>;
443}
444interface FormContext<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount' | 'values'> {
445 values: TValues;
446 handleReset: () => void;
447 submitForm: (e?: unknown) => Promise<void>;
448}
449
450interface DevtoolsPluginFieldState {
451 name: string;
452 value: any;
453 initialValue: any;
454 errors: string[];
455 meta: FieldMeta<any>;
456}
457interface DevtoolsPluginFormState {
458 meta: FormMeta<Record<string, any>>;
459 errors: FormErrors<Record<string, any>>;
460 values: Record<string, any>;
461 isSubmitting: boolean;
462 isValidating: boolean;
463 submitCount: number;
464}
465
466interface ValidationOptions {
467 name?: string;
468 label?: string;
469 values?: Record<string, unknown>;
470 bails?: boolean;
471}
472/**
473 * Validates a value against the rules.
474 */
475declare function validate<TInput, TOutput>(value: TInput, rules: string | Record<string, unknown | unknown[]> | GenericValidateFunction<TInput> | GenericValidateFunction<TInput>[] | TypedSchema<TInput, TOutput>, options?: ValidationOptions): Promise<ValidationResult<TOutput>>;
476declare function validateObjectSchema<TValues extends GenericObject, TOutput extends GenericObject>(schema: RawFormSchema<TValues>, values: TValues | undefined, opts?: Partial<{
477 names: Record<string, {
478 name: string;
479 label: string;
480 }>;
481 bailsMap: Record<string, boolean>;
482}>): Promise<FormValidationResult<TValues, TOutput>>;
483
484/**
485 * Adds a custom validator to the list of validation rules.
486 */
487declare function defineRule<TValue = unknown, TParams = any[] | Record<string, any>>(id: string, validator: ValidationRuleFunction<TValue, TParams> | SimpleValidationRuleFunction<TValue, TParams>): void;
488
489interface VeeValidateConfig {
490 bails: boolean;
491 generateMessage: ValidationMessageGenerator;
492 validateOnInput: boolean;
493 validateOnChange: boolean;
494 validateOnBlur: boolean;
495 validateOnModelUpdate: boolean;
496}
497declare const configure: (newConf: Partial<VeeValidateConfig>) => void;
498
499/**
500 * Checks if the path opted out of nested fields using `[fieldName]` syntax
501 */
502declare function isNotNestedPath(path: string): boolean;
503
504declare function cleanupNonNestedPath(path: string): string;
505
506/**
507 * Normalizes the given rules expression.
508 */
509declare function normalizeRules(rules: undefined | string | Record<string, unknown | unknown[] | Record<string, unknown>>): Record<string, unknown[] | Record<string, unknown>>;
510
511interface FieldOptions<TValue = unknown> {
512 initialValue?: MaybeRef<TValue>;
513 validateOnValueUpdate: boolean;
514 validateOnMount?: boolean;
515 bails?: boolean;
516 type?: InputType;
517 /**
518 * @deprecated Use `checkedValue` instead.
519 */
520 valueProp?: MaybeRefOrGetter<TValue>;
521 checkedValue?: MaybeRefOrGetter<TValue>;
522 uncheckedValue?: MaybeRefOrGetter<TValue>;
523 label?: MaybeRefOrGetter<string | undefined>;
524 controlled?: boolean;
525 /**
526 * @deprecated Use `controlled` instead, controlled is opposite of standalone.
527 */
528 standalone?: boolean;
529 keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
530 /**
531 * @deprecated Pass the model prop name to `syncVModel` instead.
532 */
533 modelPropName?: string;
534 syncVModel?: boolean | string;
535 form?: FormContext;
536}
537type RuleExpression<TValue> = string | Record<string, unknown> | GenericValidateFunction<TValue> | GenericValidateFunction<TValue>[] | TypedSchema<TValue> | YupSchema<TValue> | undefined;
538/**
539 * Creates a field composite.
540 */
541declare function useField<TValue = unknown>(path: MaybeRefOrGetter<string>, rules?: MaybeRef<RuleExpression<TValue>>, opts?: Partial<FieldOptions<TValue>>): FieldContext<TValue>;
542
543interface SharedBindingObject<TValue = any> {
544 name: string;
545 onBlur: (e: Event) => void;
546 onInput: (e: Event | unknown) => void;
547 onChange: (e: Event | unknown) => void;
548 'onUpdate:modelValue'?: ((e: TValue) => unknown) | undefined;
549}
550interface FieldBindingObject<TValue = any> extends SharedBindingObject<TValue> {
551 value?: TValue;
552 checked?: boolean;
553}
554interface ComponentFieldBindingObject<TValue = any> extends SharedBindingObject<TValue> {
555 modelValue?: TValue;
556}
557interface FieldSlotProps<TValue = unknown> extends Pick<FieldContext, 'validate' | 'resetField' | 'handleChange' | 'handleReset' | 'handleBlur' | 'setTouched' | 'setErrors' | 'setValue'> {
558 field: FieldBindingObject<TValue>;
559 componentField: ComponentFieldBindingObject<TValue>;
560 value: TValue;
561 meta: FieldMeta<TValue>;
562 errors: string[];
563 errorMessage: string | undefined;
564 handleInput: FieldContext['handleChange'];
565}
566declare const Field: {
567 new (...args: any[]): vue.CreateComponentPublicInstance<Readonly<vue.ExtractPropTypes<{
568 as: {
569 type: (ObjectConstructor | StringConstructor)[];
570 default: any;
571 };
572 name: {
573 type: StringConstructor;
574 required: true;
575 };
576 rules: {
577 type: PropType<RuleExpression<unknown>>;
578 default: any;
579 };
580 validateOnMount: {
581 type: BooleanConstructor;
582 default: boolean;
583 };
584 validateOnBlur: {
585 type: BooleanConstructor;
586 default: any;
587 };
588 validateOnChange: {
589 type: BooleanConstructor;
590 default: any;
591 };
592 validateOnInput: {
593 type: BooleanConstructor;
594 default: any;
595 };
596 validateOnModelUpdate: {
597 type: BooleanConstructor;
598 default: any;
599 };
600 bails: {
601 type: BooleanConstructor;
602 default: () => boolean;
603 };
604 label: {
605 type: StringConstructor;
606 default: any;
607 };
608 uncheckedValue: {
609 type: any;
610 default: any;
611 };
612 modelValue: {
613 type: any;
614 default: symbol;
615 };
616 modelModifiers: {
617 type: any;
618 default: () => {};
619 };
620 'onUpdate:modelValue': {
621 type: PropType<(e: any) => unknown>;
622 default: any;
623 };
624 standalone: {
625 type: BooleanConstructor;
626 default: boolean;
627 };
628 keepValue: {
629 type: BooleanConstructor;
630 default: any;
631 };
632 }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
633 [key: string]: any;
634 }> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
635 [key: string]: any;
636 }>[] | {
637 default: () => VNode<vue.RendererNode, vue.RendererElement, {
638 [key: string]: any;
639 }>[];
640 }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & Readonly<vue.ExtractPropTypes<{
641 as: {
642 type: (ObjectConstructor | StringConstructor)[];
643 default: any;
644 };
645 name: {
646 type: StringConstructor;
647 required: true;
648 };
649 rules: {
650 type: PropType<RuleExpression<unknown>>;
651 default: any;
652 };
653 validateOnMount: {
654 type: BooleanConstructor;
655 default: boolean;
656 };
657 validateOnBlur: {
658 type: BooleanConstructor;
659 default: any;
660 };
661 validateOnChange: {
662 type: BooleanConstructor;
663 default: any;
664 };
665 validateOnInput: {
666 type: BooleanConstructor;
667 default: any;
668 };
669 validateOnModelUpdate: {
670 type: BooleanConstructor;
671 default: any;
672 };
673 bails: {
674 type: BooleanConstructor;
675 default: () => boolean;
676 };
677 label: {
678 type: StringConstructor;
679 default: any;
680 };
681 uncheckedValue: {
682 type: any;
683 default: any;
684 };
685 modelValue: {
686 type: any;
687 default: symbol;
688 };
689 modelModifiers: {
690 type: any;
691 default: () => {};
692 };
693 'onUpdate:modelValue': {
694 type: PropType<(e: any) => unknown>;
695 default: any;
696 };
697 standalone: {
698 type: BooleanConstructor;
699 default: boolean;
700 };
701 keepValue: {
702 type: BooleanConstructor;
703 default: any;
704 };
705 }>>, {
706 label: string;
707 as: string | Record<string, any>;
708 bails: boolean;
709 uncheckedValue: any;
710 modelValue: any;
711 validateOnInput: boolean;
712 validateOnChange: boolean;
713 validateOnBlur: boolean;
714 validateOnModelUpdate: boolean;
715 validateOnMount: boolean;
716 standalone: boolean;
717 modelModifiers: any;
718 rules: RuleExpression<unknown>;
719 'onUpdate:modelValue': (e: any) => unknown;
720 keepValue: boolean;
721 }, true, {}, {}, {
722 P: {};
723 B: {};
724 D: {};
725 C: {};
726 M: {};
727 Defaults: {};
728 }, Readonly<vue.ExtractPropTypes<{
729 as: {
730 type: (ObjectConstructor | StringConstructor)[];
731 default: any;
732 };
733 name: {
734 type: StringConstructor;
735 required: true;
736 };
737 rules: {
738 type: PropType<RuleExpression<unknown>>;
739 default: any;
740 };
741 validateOnMount: {
742 type: BooleanConstructor;
743 default: boolean;
744 };
745 validateOnBlur: {
746 type: BooleanConstructor;
747 default: any;
748 };
749 validateOnChange: {
750 type: BooleanConstructor;
751 default: any;
752 };
753 validateOnInput: {
754 type: BooleanConstructor;
755 default: any;
756 };
757 validateOnModelUpdate: {
758 type: BooleanConstructor;
759 default: any;
760 };
761 bails: {
762 type: BooleanConstructor;
763 default: () => boolean;
764 };
765 label: {
766 type: StringConstructor;
767 default: any;
768 };
769 uncheckedValue: {
770 type: any;
771 default: any;
772 };
773 modelValue: {
774 type: any;
775 default: symbol;
776 };
777 modelModifiers: {
778 type: any;
779 default: () => {};
780 };
781 'onUpdate:modelValue': {
782 type: PropType<(e: any) => unknown>;
783 default: any;
784 };
785 standalone: {
786 type: BooleanConstructor;
787 default: boolean;
788 };
789 keepValue: {
790 type: BooleanConstructor;
791 default: any;
792 };
793 }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
794 [key: string]: any;
795 }> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
796 [key: string]: any;
797 }>[] | {
798 default: () => VNode<vue.RendererNode, vue.RendererElement, {
799 [key: string]: any;
800 }>[];
801 }, {}, {}, {}, {
802 label: string;
803 as: string | Record<string, any>;
804 bails: boolean;
805 uncheckedValue: any;
806 modelValue: any;
807 validateOnInput: boolean;
808 validateOnChange: boolean;
809 validateOnBlur: boolean;
810 validateOnModelUpdate: boolean;
811 validateOnMount: boolean;
812 standalone: boolean;
813 modelModifiers: any;
814 rules: RuleExpression<unknown>;
815 'onUpdate:modelValue': (e: any) => unknown;
816 keepValue: boolean;
817 }>;
818 __isFragment?: never;
819 __isTeleport?: never;
820 __isSuspense?: never;
821} & vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
822 as: {
823 type: (ObjectConstructor | StringConstructor)[];
824 default: any;
825 };
826 name: {
827 type: StringConstructor;
828 required: true;
829 };
830 rules: {
831 type: PropType<RuleExpression<unknown>>;
832 default: any;
833 };
834 validateOnMount: {
835 type: BooleanConstructor;
836 default: boolean;
837 };
838 validateOnBlur: {
839 type: BooleanConstructor;
840 default: any;
841 };
842 validateOnChange: {
843 type: BooleanConstructor;
844 default: any;
845 };
846 validateOnInput: {
847 type: BooleanConstructor;
848 default: any;
849 };
850 validateOnModelUpdate: {
851 type: BooleanConstructor;
852 default: any;
853 };
854 bails: {
855 type: BooleanConstructor;
856 default: () => boolean;
857 };
858 label: {
859 type: StringConstructor;
860 default: any;
861 };
862 uncheckedValue: {
863 type: any;
864 default: any;
865 };
866 modelValue: {
867 type: any;
868 default: symbol;
869 };
870 modelModifiers: {
871 type: any;
872 default: () => {};
873 };
874 'onUpdate:modelValue': {
875 type: PropType<(e: any) => unknown>;
876 default: any;
877 };
878 standalone: {
879 type: BooleanConstructor;
880 default: boolean;
881 };
882 keepValue: {
883 type: BooleanConstructor;
884 default: any;
885 };
886}>>, () => VNode<vue.RendererNode, vue.RendererElement, {
887 [key: string]: any;
888}> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
889 [key: string]: any;
890}>[] | {
891 default: () => VNode<vue.RendererNode, vue.RendererElement, {
892 [key: string]: any;
893 }>[];
894}, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
895 label: string;
896 as: string | Record<string, any>;
897 bails: boolean;
898 uncheckedValue: any;
899 modelValue: any;
900 validateOnInput: boolean;
901 validateOnChange: boolean;
902 validateOnBlur: boolean;
903 validateOnModelUpdate: boolean;
904 validateOnMount: boolean;
905 standalone: boolean;
906 modelModifiers: any;
907 rules: RuleExpression<unknown>;
908 'onUpdate:modelValue': (e: any) => unknown;
909 keepValue: boolean;
910}, {}, string, {}> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
911 value: UnwrapRef<FieldContext['value']>;
912 meta: UnwrapRef<FieldContext['meta']>;
913 errors: UnwrapRef<FieldContext['errors']>;
914 errorMessage: UnwrapRef<FieldContext['errorMessage']>;
915 setErrors: FieldContext['setErrors'];
916 setTouched: FieldContext['setTouched'];
917 reset: FieldContext['resetField'];
918 validate: FieldContext['validate'];
919 setValue: FieldContext['setValue'];
920 handleChange: FieldContext['handleChange'];
921 $slots: {
922 default: (arg: FieldSlotProps<any>) => VNode[];
923 };
924});
925
926type FormSlotProps = UnwrapRef<Pick<FormContext, 'meta' | 'errors' | 'errorBag' | 'values' | 'isSubmitting' | 'isValidating' | 'submitCount' | 'validate' | 'validateField' | 'handleReset' | 'setErrors' | 'setFieldError' | 'setFieldValue' | 'setValues' | 'setFieldTouched' | 'setTouched' | 'resetForm' | 'resetField' | 'controlledValues'>> & {
927 handleSubmit: (evt: Event | SubmissionHandler, onSubmit?: SubmissionHandler) => Promise<unknown>;
928 submitForm(evt?: Event): void;
929 getValues<TValues extends GenericObject = GenericObject>(): TValues;
930 getMeta<TValues extends GenericObject = GenericObject>(): FormMeta<TValues>;
931 getErrors<TValues extends GenericObject = GenericObject>(): FormErrors<TValues>;
932};
933declare const Form: {
934 new (...args: any[]): vue.CreateComponentPublicInstance<Readonly<vue.ExtractPropTypes<{
935 as: {
936 type: PropType<string>;
937 default: string;
938 };
939 validationSchema: {
940 type: ObjectConstructor;
941 default: any;
942 };
943 initialValues: {
944 type: ObjectConstructor;
945 default: any;
946 };
947 initialErrors: {
948 type: ObjectConstructor;
949 default: any;
950 };
951 initialTouched: {
952 type: ObjectConstructor;
953 default: any;
954 };
955 validateOnMount: {
956 type: BooleanConstructor;
957 default: boolean;
958 };
959 onSubmit: {
960 type: PropType<SubmissionHandler<GenericObject>>;
961 default: any;
962 };
963 onInvalidSubmit: {
964 type: PropType<InvalidSubmissionHandler>;
965 default: any;
966 };
967 keepValues: {
968 type: BooleanConstructor;
969 default: boolean;
970 };
971 name: {
972 type: StringConstructor;
973 default: string;
974 };
975 }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
976 [key: string]: any;
977 }> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
978 [key: string]: any;
979 }>[] | {
980 default: () => VNode<vue.RendererNode, vue.RendererElement, {
981 [key: string]: any;
982 }>[];
983 }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & Readonly<vue.ExtractPropTypes<{
984 as: {
985 type: PropType<string>;
986 default: string;
987 };
988 validationSchema: {
989 type: ObjectConstructor;
990 default: any;
991 };
992 initialValues: {
993 type: ObjectConstructor;
994 default: any;
995 };
996 initialErrors: {
997 type: ObjectConstructor;
998 default: any;
999 };
1000 initialTouched: {
1001 type: ObjectConstructor;
1002 default: any;
1003 };
1004 validateOnMount: {
1005 type: BooleanConstructor;
1006 default: boolean;
1007 };
1008 onSubmit: {
1009 type: PropType<SubmissionHandler<GenericObject>>;
1010 default: any;
1011 };
1012 onInvalidSubmit: {
1013 type: PropType<InvalidSubmissionHandler>;
1014 default: any;
1015 };
1016 keepValues: {
1017 type: BooleanConstructor;
1018 default: boolean;
1019 };
1020 name: {
1021 type: StringConstructor;
1022 default: string;
1023 };
1024 }>>, {
1025 name: string;
1026 onSubmit: SubmissionHandler<GenericObject>;
1027 as: string;
1028 initialValues: Record<string, any>;
1029 validateOnMount: boolean;
1030 validationSchema: Record<string, any>;
1031 initialErrors: Record<string, any>;
1032 initialTouched: Record<string, any>;
1033 onInvalidSubmit: InvalidSubmissionHandler;
1034 keepValues: boolean;
1035 }, true, {}, {}, {
1036 P: {};
1037 B: {};
1038 D: {};
1039 C: {};
1040 M: {};
1041 Defaults: {};
1042 }, Readonly<vue.ExtractPropTypes<{
1043 as: {
1044 type: PropType<string>;
1045 default: string;
1046 };
1047 validationSchema: {
1048 type: ObjectConstructor;
1049 default: any;
1050 };
1051 initialValues: {
1052 type: ObjectConstructor;
1053 default: any;
1054 };
1055 initialErrors: {
1056 type: ObjectConstructor;
1057 default: any;
1058 };
1059 initialTouched: {
1060 type: ObjectConstructor;
1061 default: any;
1062 };
1063 validateOnMount: {
1064 type: BooleanConstructor;
1065 default: boolean;
1066 };
1067 onSubmit: {
1068 type: PropType<SubmissionHandler<GenericObject>>;
1069 default: any;
1070 };
1071 onInvalidSubmit: {
1072 type: PropType<InvalidSubmissionHandler>;
1073 default: any;
1074 };
1075 keepValues: {
1076 type: BooleanConstructor;
1077 default: boolean;
1078 };
1079 name: {
1080 type: StringConstructor;
1081 default: string;
1082 };
1083 }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
1084 [key: string]: any;
1085 }> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
1086 [key: string]: any;
1087 }>[] | {
1088 default: () => VNode<vue.RendererNode, vue.RendererElement, {
1089 [key: string]: any;
1090 }>[];
1091 }, {}, {}, {}, {
1092 name: string;
1093 onSubmit: SubmissionHandler<GenericObject>;
1094 as: string;
1095 initialValues: Record<string, any>;
1096 validateOnMount: boolean;
1097 validationSchema: Record<string, any>;
1098 initialErrors: Record<string, any>;
1099 initialTouched: Record<string, any>;
1100 onInvalidSubmit: InvalidSubmissionHandler;
1101 keepValues: boolean;
1102 }>;
1103 __isFragment?: never;
1104 __isTeleport?: never;
1105 __isSuspense?: never;
1106} & vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
1107 as: {
1108 type: PropType<string>;
1109 default: string;
1110 };
1111 validationSchema: {
1112 type: ObjectConstructor;
1113 default: any;
1114 };
1115 initialValues: {
1116 type: ObjectConstructor;
1117 default: any;
1118 };
1119 initialErrors: {
1120 type: ObjectConstructor;
1121 default: any;
1122 };
1123 initialTouched: {
1124 type: ObjectConstructor;
1125 default: any;
1126 };
1127 validateOnMount: {
1128 type: BooleanConstructor;
1129 default: boolean;
1130 };
1131 onSubmit: {
1132 type: PropType<SubmissionHandler<GenericObject>>;
1133 default: any;
1134 };
1135 onInvalidSubmit: {
1136 type: PropType<InvalidSubmissionHandler>;
1137 default: any;
1138 };
1139 keepValues: {
1140 type: BooleanConstructor;
1141 default: boolean;
1142 };
1143 name: {
1144 type: StringConstructor;
1145 default: string;
1146 };
1147}>>, () => VNode<vue.RendererNode, vue.RendererElement, {
1148 [key: string]: any;
1149}> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
1150 [key: string]: any;
1151}>[] | {
1152 default: () => VNode<vue.RendererNode, vue.RendererElement, {
1153 [key: string]: any;
1154 }>[];
1155}, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
1156 name: string;
1157 onSubmit: SubmissionHandler<GenericObject>;
1158 as: string;
1159 initialValues: Record<string, any>;
1160 validateOnMount: boolean;
1161 validationSchema: Record<string, any>;
1162 initialErrors: Record<string, any>;
1163 initialTouched: Record<string, any>;
1164 onInvalidSubmit: InvalidSubmissionHandler;
1165 keepValues: boolean;
1166}, {}, string, {}> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1167 setFieldError: FormContext['setFieldError'];
1168 setErrors: FormContext['setErrors'];
1169 setFieldValue: FormContext['setFieldValue'];
1170 setValues: FormContext['setValues'];
1171 setFieldTouched: FormContext['setFieldTouched'];
1172 setTouched: FormContext['setTouched'];
1173 resetForm: FormContext['resetForm'];
1174 resetField: FormContext['resetField'];
1175 validate: FormContext['validate'];
1176 validateField: FormContext['validateField'];
1177 getValues: FormSlotProps['getValues'];
1178 getMeta: FormSlotProps['getMeta'];
1179 getErrors: FormSlotProps['getErrors'];
1180 meta: FormSlotProps['meta'];
1181 values: FormSlotProps['values'];
1182 errors: FormSlotProps['errors'];
1183 $slots: {
1184 default: (arg: FormSlotProps) => VNode[];
1185 };
1186});
1187
1188declare const FieldArray: {
1189 new (...args: any[]): vue.CreateComponentPublicInstance<Readonly<vue.ExtractPropTypes<{
1190 name: {
1191 type: StringConstructor;
1192 required: true;
1193 };
1194 }>>, () => vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
1195 [key: string]: any;
1196 }>[] | {
1197 default: () => VNode<vue.RendererNode, vue.RendererElement, {
1198 [key: string]: any;
1199 }>[];
1200 }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & Readonly<vue.ExtractPropTypes<{
1201 name: {
1202 type: StringConstructor;
1203 required: true;
1204 };
1205 }>>, {}, true, {}, {}, {
1206 P: {};
1207 B: {};
1208 D: {};
1209 C: {};
1210 M: {};
1211 Defaults: {};
1212 }, Readonly<vue.ExtractPropTypes<{
1213 name: {
1214 type: StringConstructor;
1215 required: true;
1216 };
1217 }>>, () => vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
1218 [key: string]: any;
1219 }>[] | {
1220 default: () => VNode<vue.RendererNode, vue.RendererElement, {
1221 [key: string]: any;
1222 }>[];
1223 }, {}, {}, {}, {}>;
1224 __isFragment?: never;
1225 __isTeleport?: never;
1226 __isSuspense?: never;
1227} & vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
1228 name: {
1229 type: StringConstructor;
1230 required: true;
1231 };
1232}>>, () => vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
1233 [key: string]: any;
1234}>[] | {
1235 default: () => VNode<vue.RendererNode, vue.RendererElement, {
1236 [key: string]: any;
1237 }>[];
1238}, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}, {}, string, {}> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1239 push: FieldArrayContext['push'];
1240 remove: FieldArrayContext['remove'];
1241 swap: FieldArrayContext['swap'];
1242 insert: FieldArrayContext['insert'];
1243 update: FieldArrayContext['update'];
1244 replace: FieldArrayContext['replace'];
1245 prepend: FieldArrayContext['prepend'];
1246 move: FieldArrayContext['move'];
1247 $slots: {
1248 default: (arg: UnwrapRef<FieldArrayContext>) => VNode[];
1249 };
1250});
1251
1252interface ErrorMessageSlotProps {
1253 message: string | undefined;
1254}
1255declare const ErrorMessage: {
1256 new (...args: any[]): vue.CreateComponentPublicInstance<Readonly<vue.ExtractPropTypes<{
1257 as: {
1258 type: StringConstructor;
1259 default: any;
1260 };
1261 name: {
1262 type: StringConstructor;
1263 required: true;
1264 };
1265 }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
1266 [key: string]: any;
1267 }> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
1268 [key: string]: any;
1269 }>[] | {
1270 default: () => VNode<vue.RendererNode, vue.RendererElement, {
1271 [key: string]: any;
1272 }>[];
1273 }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & Readonly<vue.ExtractPropTypes<{
1274 as: {
1275 type: StringConstructor;
1276 default: any;
1277 };
1278 name: {
1279 type: StringConstructor;
1280 required: true;
1281 };
1282 }>>, {
1283 as: string;
1284 }, true, {}, {}, {
1285 P: {};
1286 B: {};
1287 D: {};
1288 C: {};
1289 M: {};
1290 Defaults: {};
1291 }, Readonly<vue.ExtractPropTypes<{
1292 as: {
1293 type: StringConstructor;
1294 default: any;
1295 };
1296 name: {
1297 type: StringConstructor;
1298 required: true;
1299 };
1300 }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
1301 [key: string]: any;
1302 }> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
1303 [key: string]: any;
1304 }>[] | {
1305 default: () => VNode<vue.RendererNode, vue.RendererElement, {
1306 [key: string]: any;
1307 }>[];
1308 }, {}, {}, {}, {
1309 as: string;
1310 }>;
1311 __isFragment?: never;
1312 __isTeleport?: never;
1313 __isSuspense?: never;
1314} & vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
1315 as: {
1316 type: StringConstructor;
1317 default: any;
1318 };
1319 name: {
1320 type: StringConstructor;
1321 required: true;
1322 };
1323}>>, () => VNode<vue.RendererNode, vue.RendererElement, {
1324 [key: string]: any;
1325}> | vue.Slot<any> | VNode<vue.RendererNode, vue.RendererElement, {
1326 [key: string]: any;
1327}>[] | {
1328 default: () => VNode<vue.RendererNode, vue.RendererElement, {
1329 [key: string]: any;
1330 }>[];
1331}, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
1332 as: string;
1333}, {}, string, {}> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1334 $slots: {
1335 default: (arg: ErrorMessageSlotProps) => VNode[];
1336 };
1337});
1338
1339type FormSchema<TValues extends Record<string, unknown>> = FlattenAndSetPathsType<TValues, GenericValidateFunction | string | GenericObject> | undefined;
1340interface FormOptions<TValues extends GenericObject, TOutput = TValues, TSchema extends TypedSchema<TValues, TOutput> | FormSchema<TValues> = FormSchema<TValues> | TypedSchema<TValues, TOutput>> {
1341 validationSchema?: MaybeRef<TSchema extends TypedSchema ? TypedSchema<TValues, TOutput> : any>;
1342 initialValues?: PartialDeep<TValues> | undefined | null;
1343 initialErrors?: FlattenAndSetPathsType<TValues, string | undefined>;
1344 initialTouched?: FlattenAndSetPathsType<TValues, boolean>;
1345 validateOnMount?: boolean;
1346 keepValuesOnUnmount?: MaybeRef<boolean>;
1347 name?: string;
1348}
1349declare function useForm<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues, TSchema extends FormSchema<TValues> | TypedSchema<TValues, TOutput> = FormSchema<TValues> | TypedSchema<TValues, TOutput>>(opts?: FormOptions<TValues, TOutput, TSchema>): FormContext<TValues, TOutput>;
1350declare function useFormContext<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues>(): FormContext<TValues, TOutput>;
1351
1352declare function useFieldArray<TValue = unknown>(arrayPath: MaybeRefOrGetter<string>): FieldArrayContext<TValue>;
1353
1354declare function useResetForm<TValues extends Record<string, unknown> = Record<string, unknown>>(): (state?: Partial<FormState<TValues>>, opts?: ResetFormOpts) => void;
1355
1356/**
1357 * If a field is dirty or not
1358 */
1359declare function useIsFieldDirty(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1360
1361/**
1362 * If a field is touched or not
1363 */
1364declare function useIsFieldTouched(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1365
1366/**
1367 * If a field is validated and is valid
1368 */
1369declare function useIsFieldValid(path?: MaybeRefOrGetter<string>): vue.ComputedRef<boolean>;
1370
1371/**
1372 * If the form is submitting or not
1373 */
1374declare function useIsSubmitting(): vue.ComputedRef<boolean>;
1375
1376/**
1377 * If the form is validating or not
1378 */
1379declare function useIsValidating(): vue.ComputedRef<boolean>;
1380
1381/**
1382 * Validates a single field
1383 */
1384declare function useValidateField<TOutput>(path?: MaybeRefOrGetter<string>): () => Promise<ValidationResult<TOutput>>;
1385
1386/**
1387 * If the form is dirty or not
1388 */
1389declare function useIsFormDirty(): vue.ComputedRef<boolean>;
1390
1391/**
1392 * If the form is touched or not
1393 */
1394declare function useIsFormTouched(): vue.ComputedRef<boolean>;
1395
1396/**
1397 * If the form has been validated and is valid
1398 */
1399declare function useIsFormValid(): vue.ComputedRef<boolean>;
1400
1401/**
1402 * Validate multiple fields
1403 */
1404declare function useValidateForm<TValues extends Record<string, unknown> = Record<string, unknown>>(): () => Promise<FormValidationResult<TValues>>;
1405
1406/**
1407 * The number of form's submission count
1408 */
1409declare function useSubmitCount(): vue.ComputedRef<number>;
1410
1411/**
1412 * Gives access to a field's current value
1413 */
1414declare function useFieldValue<TValue = unknown>(path?: MaybeRefOrGetter<string>): vue.ComputedRef<TValue>;
1415
1416/**
1417 * Gives access to a form's values
1418 */
1419declare function useFormValues<TValues extends Record<string, any> = Record<string, any>>(): vue.ComputedRef<Partial<TValues>>;
1420
1421/**
1422 * Gives access to all form errors
1423 */
1424declare function useFormErrors<TValues extends Record<string, unknown> = Record<string, unknown>>(): vue.ComputedRef<Partial<Record<Path<TValues>, string>>>;
1425
1426/**
1427 * Gives access to a single field error
1428 */
1429declare function useFieldError(path?: MaybeRefOrGetter<string>): vue.ComputedRef<string>;
1430
1431declare function useSubmitForm<TValues extends Record<string, unknown> = Record<string, unknown>>(cb: SubmissionHandler<TValues>): (e?: Event) => Promise<unknown>;
1432
1433/**
1434 * Sets a field's error message
1435 */
1436declare function useSetFieldError(path?: MaybeRefOrGetter<string>): (message: string | string[] | undefined) => void;
1437
1438/**
1439 * Sets a field's touched meta state
1440 */
1441declare function useSetFieldTouched(path?: MaybeRefOrGetter<string>): (touched: boolean) => void;
1442
1443/**
1444 * Sets a field's value
1445 */
1446declare function useSetFieldValue<TValue = unknown>(path?: MaybeRefOrGetter<string>): (value: TValue, shouldValidate?: boolean) => void;
1447
1448/**
1449 * Sets multiple fields errors
1450 */
1451declare function useSetFormErrors(): (fields: Record<string, string | string[] | undefined>) => void;
1452
1453/**
1454 * Sets multiple fields touched or all fields in the form
1455 */
1456declare function useSetFormTouched(): (fields: Record<string, boolean> | boolean) => void;
1457
1458/**
1459 * Sets multiple fields values
1460 */
1461declare function useSetFormValues<TValues extends Record<string, unknown> = Record<string, unknown>>(): (fields: TValues, shouldValidate?: boolean) => void;
1462
1463declare const FormContextKey: InjectionKey<PrivateFormContext>;
1464declare const PublicFormContextKey: InjectionKey<FormContext>;
1465declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
1466declare const IS_ABSENT: unique symbol;
1467
1468export { type BaseComponentBinds, type BaseFieldProps, type BaseInputBinds, type ComponentBindsConfig, type ComponentFieldBindingObject, type ComponentModelBinds, type ComponentModellessBinds, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldBindingObject, type FieldContext, FieldContextKey, type FieldEntry, type FieldMeta, type FieldOptions, type FieldPathLookup, type FieldSlotProps, type FieldState, type FieldValidator, type FlattenAndMapPathsValidationResult, type FlattenAndSetPathsType, Form, type FormActions, type FormContext, FormContextKey, type FormErrorBag, type FormErrors, type FormMeta, type FormOptions, type FormSlotProps, type FormState, type FormValidationResult, type GenericObject, type GenericValidateFunction, IS_ABSENT, type InferInput, type InferOutput, type InputBindsConfig, type InputType, type InvalidSubmissionContext, type InvalidSubmissionHandler, type IsAny, type IsEqual, type LazyComponentBindsConfig, type LazyInputBindsConfig, type Locator, type MapValuesPathsToRefs, type MaybeArray, type MaybePromise, type Path, type PathState, type PathStateConfig, type PathValue, type PrivateFieldArrayContext, type PrivateFieldContext, type PrivateFormContext, PublicFormContextKey, type PublicPathState, type RawFormSchema, type ResetFormOpts, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type TypedSchema, type TypedSchemaContext, type TypedSchemaError, type TypedSchemaPathDescription, type ValidationOptions$1 as ValidationOptions, type ValidationResult, type YupSchema, cleanupNonNestedPath, configure, defineRule, isNotNestedPath, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormContext, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };