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