vee-validate 4.9.6 → 4.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vee-validate.d.ts +29 -22
- package/dist/vee-validate.esm.js +69 -62
- package/dist/vee-validate.js +68 -61
- package/dist/vee-validate.min.js +2 -2
- package/package.json +3 -3
package/dist/vee-validate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import { Ref, ComputedRef, VNode, PropType, UnwrapRef, InjectionKey } from 'vue';
|
|
2
|
+
import { MaybeRef, Ref, DeepReadonly, MaybeRefOrGetter, ComputedRef, VNode, PropType, UnwrapRef, InjectionKey } from 'vue';
|
|
3
3
|
import { PartialDeep } from 'type-fest';
|
|
4
4
|
|
|
5
5
|
type BrowserNativeObject = Date | FileList | File;
|
|
@@ -128,8 +128,8 @@ type PathValue<T, P extends Path<T> | ArrayPath<T>> = T extends any ? P extends
|
|
|
128
128
|
type Path<T> = T extends any ? PathInternal<T> : never;
|
|
129
129
|
|
|
130
130
|
type GenericObject = Record<string, any>;
|
|
131
|
-
type
|
|
132
|
-
type
|
|
131
|
+
type MaybeArray<T> = T | T[];
|
|
132
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
133
133
|
type MapValuesPathsToRefs<TValues extends GenericObject, TPaths extends readonly [...MaybeRef<Path<TValues>>[]]> = {
|
|
134
134
|
readonly [K in keyof TPaths]: TPaths[K] extends MaybeRef<infer TKey> ? TKey extends Path<TValues> ? Ref<PathValue<TValues, TKey>> : Ref<unknown> : Ref<unknown>;
|
|
135
135
|
};
|
|
@@ -270,14 +270,14 @@ interface PrivateFieldContext<TValue = unknown> {
|
|
|
270
270
|
handleReset(): void;
|
|
271
271
|
validate: FieldValidator;
|
|
272
272
|
handleChange(e: Event | unknown, shouldValidate?: boolean): void;
|
|
273
|
-
handleBlur(e?: Event): void;
|
|
273
|
+
handleBlur(e?: Event, shouldValidate?: boolean): void;
|
|
274
274
|
setState(state: Partial<FieldState<TValue>>): void;
|
|
275
275
|
setTouched(isTouched: boolean): void;
|
|
276
276
|
setErrors(message: string | string[]): void;
|
|
277
277
|
setValue(value: TValue): void;
|
|
278
278
|
}
|
|
279
279
|
type FieldContext<TValue = unknown> = Omit<PrivateFieldContext<TValue>, 'id' | 'instances'>;
|
|
280
|
-
type GenericValidateFunction<TValue = unknown> = (value: TValue, ctx: FieldValidationMetaInfo) => boolean |
|
|
280
|
+
type GenericValidateFunction<TValue = unknown> = (value: TValue, ctx: FieldValidationMetaInfo) => MaybePromise<boolean | MaybeArray<string>>;
|
|
281
281
|
interface FormState<TValues> {
|
|
282
282
|
values: PartialDeep<TValues>;
|
|
283
283
|
errors: Partial<Record<Path<TValues>, string | undefined>>;
|
|
@@ -286,11 +286,8 @@ interface FormState<TValues> {
|
|
|
286
286
|
}
|
|
287
287
|
type FormErrors<TValues extends GenericObject> = Partial<Record<Path<TValues>, string | undefined>>;
|
|
288
288
|
type FormErrorBag<TValues extends GenericObject> = Partial<Record<Path<TValues>, string[]>>;
|
|
289
|
-
interface SetFieldValueOptions {
|
|
290
|
-
force: boolean;
|
|
291
|
-
}
|
|
292
289
|
interface FormActions<TValues extends GenericObject, TOutput = TValues> {
|
|
293
|
-
setFieldValue<T extends Path<TValues>>(field: T, value: PathValue<TValues, T>,
|
|
290
|
+
setFieldValue<T extends Path<TValues>>(field: T, value: PathValue<TValues, T>, shouldValidate?: boolean): void;
|
|
294
291
|
setFieldError(field: Path<TValues>, message: string | string[] | undefined): void;
|
|
295
292
|
setErrors(fields: FormErrors<TValues>): void;
|
|
296
293
|
setValues(fields: PartialDeep<TValues>): void;
|
|
@@ -351,9 +348,7 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
|
|
|
351
348
|
unsetPathValue<TPath extends Path<TValues>>(path: TPath): void;
|
|
352
349
|
markForUnmount(path: string): void;
|
|
353
350
|
}
|
|
354
|
-
interface BaseComponentBinds<TValue = unknown> {
|
|
355
|
-
modelValue: TValue | undefined;
|
|
356
|
-
'onUpdate:modelValue': (value: TValue) => void;
|
|
351
|
+
interface BaseComponentBinds<TValue = unknown, TModel = 'modelValue'> {
|
|
357
352
|
onBlur: () => void;
|
|
358
353
|
}
|
|
359
354
|
type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type' | '__flags'>;
|
|
@@ -361,11 +356,13 @@ interface ComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObje
|
|
|
361
356
|
mapProps: (state: PublicPathState<TValue>) => TExtraProps;
|
|
362
357
|
validateOnBlur: boolean;
|
|
363
358
|
validateOnModelUpdate: boolean;
|
|
359
|
+
model: string;
|
|
364
360
|
}
|
|
365
361
|
type LazyComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> = (state: PublicPathState<TValue>) => Partial<{
|
|
366
362
|
props: TExtraProps;
|
|
367
363
|
validateOnBlur: boolean;
|
|
368
364
|
validateOnModelUpdate: boolean;
|
|
365
|
+
model: string;
|
|
369
366
|
}>;
|
|
370
367
|
interface BaseInputBinds<TValue = unknown> {
|
|
371
368
|
value: TValue | undefined;
|
|
@@ -385,11 +382,12 @@ type LazyInputBindsConfig<TValue = unknown, TExtraProps extends GenericObject =
|
|
|
385
382
|
validateOnChange: boolean;
|
|
386
383
|
validateOnInput: boolean;
|
|
387
384
|
}>;
|
|
388
|
-
interface FormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount'> {
|
|
385
|
+
interface FormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount' | 'values'> {
|
|
386
|
+
values: DeepReadonly<TValues>;
|
|
389
387
|
handleReset: () => void;
|
|
390
388
|
submitForm: (e?: unknown) => Promise<void>;
|
|
391
|
-
defineComponentBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path:
|
|
392
|
-
defineInputBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path:
|
|
389
|
+
defineComponentBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<ComponentBindsConfig<TValue, TExtras>> | LazyComponentBindsConfig<TValue, TExtras>): Ref<BaseComponentBinds<TValue> & TExtras>;
|
|
390
|
+
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>;
|
|
393
391
|
}
|
|
394
392
|
|
|
395
393
|
interface ValidationOptions {
|
|
@@ -431,22 +429,31 @@ interface FieldOptions<TValue = unknown> {
|
|
|
431
429
|
validateOnMount?: boolean;
|
|
432
430
|
bails?: boolean;
|
|
433
431
|
type?: InputType;
|
|
432
|
+
/**
|
|
433
|
+
* @deprecated Use `checkedValue` instead.
|
|
434
|
+
*/
|
|
434
435
|
valueProp?: MaybeRef<TValue>;
|
|
435
436
|
checkedValue?: MaybeRef<TValue>;
|
|
436
437
|
uncheckedValue?: MaybeRef<TValue>;
|
|
437
438
|
label?: MaybeRef<string | undefined>;
|
|
438
439
|
controlled?: boolean;
|
|
440
|
+
/**
|
|
441
|
+
* @deprecated Use `controlled` instead, controlled is opposite of standalone.
|
|
442
|
+
*/
|
|
439
443
|
standalone?: boolean;
|
|
440
444
|
keepValueOnUnmount?: MaybeRef<boolean | undefined>;
|
|
445
|
+
/**
|
|
446
|
+
* @deprecated Pass the model prop name to `syncVModel` instead.
|
|
447
|
+
*/
|
|
441
448
|
modelPropName?: string;
|
|
442
|
-
syncVModel?: boolean;
|
|
449
|
+
syncVModel?: boolean | string;
|
|
443
450
|
form?: FormContext;
|
|
444
451
|
}
|
|
445
452
|
type RuleExpression<TValue> = string | Record<string, unknown> | GenericValidateFunction<TValue> | GenericValidateFunction<TValue>[] | TypedSchema<TValue> | YupSchema<TValue> | undefined;
|
|
446
453
|
/**
|
|
447
454
|
* Creates a field composite.
|
|
448
455
|
*/
|
|
449
|
-
declare function useField<TValue = unknown>(path:
|
|
456
|
+
declare function useField<TValue = unknown>(path: MaybeRefOrGetter<string>, rules?: MaybeRef<RuleExpression<TValue>>, opts?: Partial<FieldOptions<TValue>>): FieldContext<TValue>;
|
|
450
457
|
|
|
451
458
|
interface SharedBindingObject<TValue = any> {
|
|
452
459
|
name: string;
|
|
@@ -480,11 +487,11 @@ declare const Field: {
|
|
|
480
487
|
as?: string | Record<string, any>;
|
|
481
488
|
bails?: boolean;
|
|
482
489
|
uncheckedValue?: any;
|
|
490
|
+
modelValue?: any;
|
|
483
491
|
validateOnInput?: boolean;
|
|
484
492
|
validateOnChange?: boolean;
|
|
485
493
|
validateOnBlur?: boolean;
|
|
486
494
|
validateOnModelUpdate?: boolean;
|
|
487
|
-
modelValue?: any;
|
|
488
495
|
validateOnMount?: boolean;
|
|
489
496
|
standalone?: boolean;
|
|
490
497
|
modelModifiers?: any;
|
|
@@ -628,11 +635,11 @@ declare const Field: {
|
|
|
628
635
|
as: string | Record<string, any>;
|
|
629
636
|
bails: boolean;
|
|
630
637
|
uncheckedValue: any;
|
|
638
|
+
modelValue: any;
|
|
631
639
|
validateOnInput: boolean;
|
|
632
640
|
validateOnChange: boolean;
|
|
633
641
|
validateOnBlur: boolean;
|
|
634
642
|
validateOnModelUpdate: boolean;
|
|
635
|
-
modelValue: any;
|
|
636
643
|
validateOnMount: boolean;
|
|
637
644
|
standalone: boolean;
|
|
638
645
|
modelModifiers: any;
|
|
@@ -814,11 +821,11 @@ declare const Field: {
|
|
|
814
821
|
as: string | Record<string, any>;
|
|
815
822
|
bails: boolean;
|
|
816
823
|
uncheckedValue: any;
|
|
824
|
+
modelValue: any;
|
|
817
825
|
validateOnInput: boolean;
|
|
818
826
|
validateOnChange: boolean;
|
|
819
827
|
validateOnBlur: boolean;
|
|
820
828
|
validateOnModelUpdate: boolean;
|
|
821
|
-
modelValue: any;
|
|
822
829
|
validateOnMount: boolean;
|
|
823
830
|
standalone: boolean;
|
|
824
831
|
modelModifiers: any;
|
|
@@ -1479,7 +1486,7 @@ declare function useFieldValue<TValue = unknown>(path?: MaybeRef<string>): vue.C
|
|
|
1479
1486
|
/**
|
|
1480
1487
|
* Gives access to a form's values
|
|
1481
1488
|
*/
|
|
1482
|
-
declare function useFormValues<TValues extends Record<string, any> = Record<string, any>>(): vue.ComputedRef<Partial<TValues>>;
|
|
1489
|
+
declare function useFormValues<TValues extends Record<string, any> = Record<string, any>>(): vue.ComputedRef<vue.DeepReadonly<TValues> | Partial<TValues>>;
|
|
1483
1490
|
|
|
1484
1491
|
/**
|
|
1485
1492
|
* Gives access to all form errors
|
|
@@ -1497,4 +1504,4 @@ declare const FormContextKey: InjectionKey<PrivateFormContext>;
|
|
|
1497
1504
|
declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
|
|
1498
1505
|
declare const IS_ABSENT: any;
|
|
1499
1506
|
|
|
1500
|
-
export { ComponentBindsConfig, ErrorMessage, Field, FieldArray, FieldArrayContext, FieldContext, FieldContextKey, FieldEntry, FieldMeta, FieldOptions, FieldState, Form, FormActions, FormContext, FormContextKey, FormMeta, FormOptions, FormState, FormValidationResult, GenericValidateFunction, IS_ABSENT, InputBindsConfig, InvalidSubmissionContext, InvalidSubmissionHandler, LazyComponentBindsConfig, LazyInputBindsConfig, Path, PublicPathState as PathState, RawFormSchema, RuleExpression,
|
|
1507
|
+
export { ComponentBindsConfig, ErrorMessage, Field, FieldArray, FieldArrayContext, FieldContext, FieldContextKey, FieldEntry, FieldMeta, FieldOptions, FieldState, Form, FormActions, FormContext, FormContextKey, FormMeta, FormOptions, FormState, FormValidationResult, GenericValidateFunction, IS_ABSENT, InputBindsConfig, InvalidSubmissionContext, InvalidSubmissionHandler, LazyComponentBindsConfig, LazyInputBindsConfig, Path, PublicPathState as PathState, RawFormSchema, RuleExpression, SubmissionContext, SubmissionHandler, TypedSchema, TypedSchemaError, ValidationOptions$1 as ValidationOptions, ValidationResult, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
|
package/dist/vee-validate.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.
|
|
2
|
+
* vee-validate v4.10.1
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import { getCurrentInstance, inject, warn as warn$1,
|
|
6
|
+
import { getCurrentInstance, inject, warn as warn$1, computed, toValue, unref, ref, watch, isRef, reactive, onUnmounted, nextTick, onMounted, provide, onBeforeUnmount, defineComponent, toRef, resolveDynamicComponent, h, readonly, watchEffect, shallowRef } from 'vue';
|
|
7
7
|
import { setupDevtoolsPlugin } from '@vue/devtools-api';
|
|
8
8
|
|
|
9
9
|
function isCallable(fn) {
|
|
@@ -515,14 +515,8 @@ function computedDeep({ get, set }) {
|
|
|
515
515
|
});
|
|
516
516
|
return baseRef;
|
|
517
517
|
}
|
|
518
|
-
function unravel(value) {
|
|
519
|
-
if (isCallable(value)) {
|
|
520
|
-
return value();
|
|
521
|
-
}
|
|
522
|
-
return unref(value);
|
|
523
|
-
}
|
|
524
518
|
function lazyToRef(value) {
|
|
525
|
-
return computed(() =>
|
|
519
|
+
return computed(() => toValue(value));
|
|
526
520
|
}
|
|
527
521
|
function normalizeErrorItem(message) {
|
|
528
522
|
return Array.isArray(message) ? message : message ? [message] : [];
|
|
@@ -576,6 +570,12 @@ function hasValueBinding(el) {
|
|
|
576
570
|
return '_value' in el;
|
|
577
571
|
}
|
|
578
572
|
|
|
573
|
+
function parseInputValue(el) {
|
|
574
|
+
if (el.type === 'number') {
|
|
575
|
+
return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
|
|
576
|
+
}
|
|
577
|
+
return el.value;
|
|
578
|
+
}
|
|
579
579
|
function normalizeEventValue(value) {
|
|
580
580
|
if (!isEvent(value)) {
|
|
581
581
|
return value;
|
|
@@ -601,7 +601,7 @@ function normalizeEventValue(value) {
|
|
|
601
601
|
const selectedOption = Array.from(input.options).find(opt => opt.selected);
|
|
602
602
|
return selectedOption ? getBoundValue(selectedOption) : input.value;
|
|
603
603
|
}
|
|
604
|
-
return input
|
|
604
|
+
return parseInputValue(input);
|
|
605
605
|
}
|
|
606
606
|
|
|
607
607
|
/**
|
|
@@ -764,12 +764,17 @@ async function _validate(field, value) {
|
|
|
764
764
|
for (let i = 0; i < length; i++) {
|
|
765
765
|
const rule = pipeline[i];
|
|
766
766
|
const result = await rule(value, ctx);
|
|
767
|
-
const isValid = typeof result !== 'string' && result;
|
|
767
|
+
const isValid = typeof result !== 'string' && !Array.isArray(result) && result;
|
|
768
768
|
if (isValid) {
|
|
769
769
|
continue;
|
|
770
770
|
}
|
|
771
|
-
|
|
772
|
-
|
|
771
|
+
if (Array.isArray(result)) {
|
|
772
|
+
errors.push(...result);
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
const message = typeof result === 'string' ? result : _generateFieldError(ctx);
|
|
776
|
+
errors.push(message);
|
|
777
|
+
}
|
|
773
778
|
if (field.bails) {
|
|
774
779
|
return {
|
|
775
780
|
errors,
|
|
@@ -1072,7 +1077,7 @@ function _useFieldValue(path, modelValue, form) {
|
|
|
1072
1077
|
return getFromPath(form.values, unref(path));
|
|
1073
1078
|
},
|
|
1074
1079
|
set(newVal) {
|
|
1075
|
-
form.setFieldValue(unref(path), newVal);
|
|
1080
|
+
form.setFieldValue(unref(path), newVal, false);
|
|
1076
1081
|
},
|
|
1077
1082
|
});
|
|
1078
1083
|
return {
|
|
@@ -1524,7 +1529,7 @@ function useField(path, rules, opts) {
|
|
|
1524
1529
|
return _useField(path, rules, opts);
|
|
1525
1530
|
}
|
|
1526
1531
|
function _useField(path, rules, opts) {
|
|
1527
|
-
const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount,
|
|
1532
|
+
const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount, syncVModel, form: controlForm, } = normalizeOptions(opts);
|
|
1528
1533
|
const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
|
|
1529
1534
|
const form = controlForm || injectedForm;
|
|
1530
1535
|
const name = lazyToRef(path);
|
|
@@ -1552,13 +1557,16 @@ function _useField(path, rules, opts) {
|
|
|
1552
1557
|
});
|
|
1553
1558
|
const errorMessage = computed(() => errors.value[0]);
|
|
1554
1559
|
if (syncVModel) {
|
|
1555
|
-
useVModel({ value, prop:
|
|
1560
|
+
useVModel({ value, prop: syncVModel, handleChange });
|
|
1556
1561
|
}
|
|
1557
1562
|
/**
|
|
1558
1563
|
* Handles common onBlur meta update
|
|
1559
1564
|
*/
|
|
1560
|
-
const handleBlur = () => {
|
|
1565
|
+
const handleBlur = (evt, shouldValidate = false) => {
|
|
1561
1566
|
meta.touched = true;
|
|
1567
|
+
if (shouldValidate) {
|
|
1568
|
+
validateWithStateMutation();
|
|
1569
|
+
}
|
|
1562
1570
|
};
|
|
1563
1571
|
async function validateCurrentValue(mode) {
|
|
1564
1572
|
var _a, _b;
|
|
@@ -1634,10 +1642,6 @@ function _useField(path, rules, opts) {
|
|
|
1634
1642
|
}
|
|
1635
1643
|
function setValue(newValue, shouldValidate = true) {
|
|
1636
1644
|
value.value = newValue;
|
|
1637
|
-
if (!shouldValidate) {
|
|
1638
|
-
validateValidStateOnly();
|
|
1639
|
-
return;
|
|
1640
|
-
}
|
|
1641
1645
|
const validateFn = shouldValidate ? validateWithStateMutation : validateValidStateOnly;
|
|
1642
1646
|
validateFn();
|
|
1643
1647
|
}
|
|
@@ -1749,7 +1753,7 @@ function _useField(path, rules, opts) {
|
|
|
1749
1753
|
onBeforeUnmount(() => {
|
|
1750
1754
|
var _a;
|
|
1751
1755
|
const shouldKeepValue = (_a = unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : unref(form.keepValuesOnUnmount);
|
|
1752
|
-
const path =
|
|
1756
|
+
const path = toValue(name);
|
|
1753
1757
|
if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
|
|
1754
1758
|
form === null || form === void 0 ? void 0 : form.removePathState(path, id);
|
|
1755
1759
|
return;
|
|
@@ -1774,7 +1778,7 @@ function _useField(path, rules, opts) {
|
|
|
1774
1778
|
}
|
|
1775
1779
|
}
|
|
1776
1780
|
else {
|
|
1777
|
-
form.unsetPathValue(
|
|
1781
|
+
form.unsetPathValue(toValue(name));
|
|
1778
1782
|
}
|
|
1779
1783
|
form.removePathState(path, id);
|
|
1780
1784
|
});
|
|
@@ -1784,7 +1788,6 @@ function _useField(path, rules, opts) {
|
|
|
1784
1788
|
* Normalizes partial field options to include the full options
|
|
1785
1789
|
*/
|
|
1786
1790
|
function normalizeOptions(opts) {
|
|
1787
|
-
var _a;
|
|
1788
1791
|
const defaults = () => ({
|
|
1789
1792
|
initialValue: undefined,
|
|
1790
1793
|
validateOnMount: false,
|
|
@@ -1792,13 +1795,13 @@ function normalizeOptions(opts) {
|
|
|
1792
1795
|
label: undefined,
|
|
1793
1796
|
validateOnValueUpdate: true,
|
|
1794
1797
|
keepValueOnUnmount: undefined,
|
|
1795
|
-
|
|
1796
|
-
syncVModel: true,
|
|
1798
|
+
syncVModel: false,
|
|
1797
1799
|
controlled: true,
|
|
1798
1800
|
});
|
|
1799
|
-
const isVModelSynced = (
|
|
1801
|
+
const isVModelSynced = !!(opts === null || opts === void 0 ? void 0 : opts.syncVModel);
|
|
1802
|
+
const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === 'string' ? opts.syncVModel : (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || 'modelValue';
|
|
1800
1803
|
const initialValue = isVModelSynced && !('initialValue' in (opts || {}))
|
|
1801
|
-
? getCurrentModelValue(getCurrentInstance(),
|
|
1804
|
+
? getCurrentModelValue(getCurrentInstance(), modelPropName)
|
|
1802
1805
|
: opts === null || opts === void 0 ? void 0 : opts.initialValue;
|
|
1803
1806
|
if (!opts) {
|
|
1804
1807
|
return Object.assign(Object.assign({}, defaults()), { initialValue });
|
|
@@ -1806,7 +1809,9 @@ function normalizeOptions(opts) {
|
|
|
1806
1809
|
// TODO: Deprecate this in next major release
|
|
1807
1810
|
const checkedValue = 'valueProp' in opts ? opts.valueProp : opts.checkedValue;
|
|
1808
1811
|
const controlled = 'standalone' in opts ? !opts.standalone : opts.controlled;
|
|
1809
|
-
|
|
1812
|
+
const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
|
|
1813
|
+
return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { initialValue, controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue,
|
|
1814
|
+
syncVModel });
|
|
1810
1815
|
}
|
|
1811
1816
|
function useFieldWithChecked(name, rules, opts) {
|
|
1812
1817
|
const form = !(opts === null || opts === void 0 ? void 0 : opts.standalone) ? injectWithSelf(FormContextKey) : undefined;
|
|
@@ -1822,23 +1827,22 @@ function useFieldWithChecked(name, rules, opts) {
|
|
|
1822
1827
|
: isEqual(checkedVal, currentValue);
|
|
1823
1828
|
});
|
|
1824
1829
|
function handleCheckboxChange(e, shouldValidate = true) {
|
|
1825
|
-
var _a;
|
|
1830
|
+
var _a, _b;
|
|
1826
1831
|
if (checked.value === ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.checked)) {
|
|
1827
1832
|
if (shouldValidate) {
|
|
1828
1833
|
field.validate();
|
|
1829
1834
|
}
|
|
1830
1835
|
return;
|
|
1831
1836
|
}
|
|
1832
|
-
const path =
|
|
1837
|
+
const path = toValue(name);
|
|
1833
1838
|
const pathState = form === null || form === void 0 ? void 0 : form.getPathState(path);
|
|
1834
1839
|
const value = normalizeEventValue(e);
|
|
1835
|
-
let newValue;
|
|
1840
|
+
let newValue = (_b = unref(checkedValue)) !== null && _b !== void 0 ? _b : value;
|
|
1836
1841
|
if (form && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && pathState.type === 'checkbox') {
|
|
1837
|
-
newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [],
|
|
1842
|
+
newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [], newValue, undefined);
|
|
1838
1843
|
}
|
|
1839
|
-
else {
|
|
1840
|
-
|
|
1841
|
-
newValue = resolveNextCheckboxValue(unref(field.value), unref(checkedValue), unref(uncheckedValue));
|
|
1844
|
+
else if ((opts === null || opts === void 0 ? void 0 : opts.type) === 'checkbox') {
|
|
1845
|
+
newValue = resolveNextCheckboxValue(unref(field.value), newValue, unref(uncheckedValue));
|
|
1842
1846
|
}
|
|
1843
1847
|
handleChange(newValue, shouldValidate);
|
|
1844
1848
|
}
|
|
@@ -1851,13 +1855,13 @@ function useFieldWithChecked(name, rules, opts) {
|
|
|
1851
1855
|
function useVModel({ prop, value, handleChange }) {
|
|
1852
1856
|
const vm = getCurrentInstance();
|
|
1853
1857
|
/* istanbul ignore next */
|
|
1854
|
-
if (!vm) {
|
|
1858
|
+
if (!vm || !prop) {
|
|
1855
1859
|
if ((process.env.NODE_ENV !== 'production')) {
|
|
1856
1860
|
console.warn('Failed to setup model events because `useField` was not called in setup.');
|
|
1857
1861
|
}
|
|
1858
1862
|
return;
|
|
1859
1863
|
}
|
|
1860
|
-
const propName = prop
|
|
1864
|
+
const propName = typeof prop === 'string' ? prop : 'modelValue';
|
|
1861
1865
|
const emitName = `update:${propName}`;
|
|
1862
1866
|
// Component doesn't have a model prop setup (must be defined on the props)
|
|
1863
1867
|
if (!(propName in vm.props)) {
|
|
@@ -1974,6 +1978,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
|
|
|
1974
1978
|
label,
|
|
1975
1979
|
validateOnValueUpdate: false,
|
|
1976
1980
|
keepValueOnUnmount: keepValue,
|
|
1981
|
+
syncVModel: true,
|
|
1977
1982
|
});
|
|
1978
1983
|
// If there is a v-model applied on the component we need to emit the `update:modelValue` whenever the value binding changes
|
|
1979
1984
|
const onChangeHandler = function handleChangeWithModel(e, shouldValidate = true) {
|
|
@@ -1983,13 +1988,10 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
|
|
|
1983
1988
|
const sharedProps = computed(() => {
|
|
1984
1989
|
const { validateOnInput, validateOnChange, validateOnBlur, validateOnModelUpdate } = resolveValidationTriggers(props);
|
|
1985
1990
|
function baseOnBlur(e) {
|
|
1986
|
-
handleBlur(e);
|
|
1991
|
+
handleBlur(e, validateOnBlur);
|
|
1987
1992
|
if (isCallable(ctx.attrs.onBlur)) {
|
|
1988
1993
|
ctx.attrs.onBlur(e);
|
|
1989
1994
|
}
|
|
1990
|
-
if (validateOnBlur) {
|
|
1991
|
-
validateField();
|
|
1992
|
-
}
|
|
1993
1995
|
}
|
|
1994
1996
|
function baseOnInput(e) {
|
|
1995
1997
|
onChangeHandler(e, validateOnInput);
|
|
@@ -2193,7 +2195,7 @@ function useForm(opts) {
|
|
|
2193
2195
|
const schema = opts === null || opts === void 0 ? void 0 : opts.validationSchema;
|
|
2194
2196
|
function createPathState(path, config) {
|
|
2195
2197
|
var _a, _b;
|
|
2196
|
-
const initialValue = computed(() => getFromPath(initialValues.value,
|
|
2198
|
+
const initialValue = computed(() => getFromPath(initialValues.value, toValue(path)));
|
|
2197
2199
|
const pathStateExists = pathStates.value.find(state => state.path === unref(path));
|
|
2198
2200
|
if (pathStateExists) {
|
|
2199
2201
|
if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
|
|
@@ -2210,8 +2212,8 @@ function useForm(opts) {
|
|
|
2210
2212
|
pathStateExists.__flags.pendingUnmount[id] = false;
|
|
2211
2213
|
return pathStateExists;
|
|
2212
2214
|
}
|
|
2213
|
-
const currentValue = computed(() => getFromPath(formValues,
|
|
2214
|
-
const pathValue =
|
|
2215
|
+
const currentValue = computed(() => getFromPath(formValues, toValue(path)));
|
|
2216
|
+
const pathValue = toValue(path);
|
|
2215
2217
|
const id = FIELD_ID_COUNTER++;
|
|
2216
2218
|
const state = reactive({
|
|
2217
2219
|
id,
|
|
@@ -2463,7 +2465,7 @@ function useForm(opts) {
|
|
|
2463
2465
|
/**
|
|
2464
2466
|
* Sets a single field value
|
|
2465
2467
|
*/
|
|
2466
|
-
function setFieldValue(field, value) {
|
|
2468
|
+
function setFieldValue(field, value, shouldValidate = true) {
|
|
2467
2469
|
const clonedValue = klona(value);
|
|
2468
2470
|
const path = typeof field === 'string' ? field : field.path;
|
|
2469
2471
|
const pathState = findPathState(path);
|
|
@@ -2471,6 +2473,9 @@ function useForm(opts) {
|
|
|
2471
2473
|
createPathState(path);
|
|
2472
2474
|
}
|
|
2473
2475
|
setInPath(formValues, path, clonedValue);
|
|
2476
|
+
if (shouldValidate) {
|
|
2477
|
+
validateField(path);
|
|
2478
|
+
}
|
|
2474
2479
|
}
|
|
2475
2480
|
/**
|
|
2476
2481
|
* Sets multiple fields values
|
|
@@ -2488,7 +2493,7 @@ function useForm(opts) {
|
|
|
2488
2493
|
},
|
|
2489
2494
|
set(value) {
|
|
2490
2495
|
const pathValue = unref(path);
|
|
2491
|
-
setFieldValue(pathValue, value);
|
|
2496
|
+
setFieldValue(pathValue, value, false);
|
|
2492
2497
|
pathState.validated = true;
|
|
2493
2498
|
pathState.pending = true;
|
|
2494
2499
|
validateField(pathValue).then(() => {
|
|
@@ -2524,7 +2529,7 @@ function useForm(opts) {
|
|
|
2524
2529
|
var _a;
|
|
2525
2530
|
const newValue = state && 'value' in state ? state.value : getFromPath(initialValues.value, field);
|
|
2526
2531
|
setFieldInitialValue(field, klona(newValue));
|
|
2527
|
-
setFieldValue(field, newValue);
|
|
2532
|
+
setFieldValue(field, newValue, false);
|
|
2528
2533
|
setFieldTouched(field, (_a = state === null || state === void 0 ? void 0 : state.touched) !== null && _a !== void 0 ? _a : false);
|
|
2529
2534
|
setFieldError(field, (state === null || state === void 0 ? void 0 : state.errors) || []);
|
|
2530
2535
|
}
|
|
@@ -2534,14 +2539,14 @@ function useForm(opts) {
|
|
|
2534
2539
|
function resetForm(resetState) {
|
|
2535
2540
|
const newValues = (resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value;
|
|
2536
2541
|
setInitialValues(newValues);
|
|
2537
|
-
setValues(newValues);
|
|
2538
2542
|
mutateAllPathState(state => {
|
|
2539
2543
|
var _a;
|
|
2540
2544
|
state.validated = false;
|
|
2541
2545
|
state.touched = ((_a = resetState === null || resetState === void 0 ? void 0 : resetState.touched) === null || _a === void 0 ? void 0 : _a[state.path]) || false;
|
|
2542
|
-
setFieldValue(state.path, getFromPath(newValues, state.path));
|
|
2546
|
+
setFieldValue(state.path, getFromPath(newValues, state.path), false);
|
|
2543
2547
|
setFieldError(state.path, undefined);
|
|
2544
2548
|
});
|
|
2549
|
+
setValues(newValues);
|
|
2545
2550
|
setErrors((resetState === null || resetState === void 0 ? void 0 : resetState.errors) || {});
|
|
2546
2551
|
submitCount.value = (resetState === null || resetState === void 0 ? void 0 : resetState.submitCount) || 0;
|
|
2547
2552
|
nextTick(() => {
|
|
@@ -2679,7 +2684,7 @@ function useForm(opts) {
|
|
|
2679
2684
|
});
|
|
2680
2685
|
}
|
|
2681
2686
|
function defineComponentBinds(path, config) {
|
|
2682
|
-
const pathState = findPathState(
|
|
2687
|
+
const pathState = findPathState(toValue(path)) || createPathState(path);
|
|
2683
2688
|
const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
|
|
2684
2689
|
function onBlur() {
|
|
2685
2690
|
var _a;
|
|
@@ -2698,23 +2703,25 @@ function useForm(opts) {
|
|
|
2698
2703
|
}
|
|
2699
2704
|
}
|
|
2700
2705
|
const props = computed(() => {
|
|
2701
|
-
const base = {
|
|
2702
|
-
modelValue: pathState.value,
|
|
2703
|
-
'onUpdate:modelValue': onUpdateModelValue,
|
|
2704
|
-
onBlur,
|
|
2705
|
-
};
|
|
2706
2706
|
if (isCallable(config)) {
|
|
2707
|
-
|
|
2707
|
+
const configVal = config(pathState);
|
|
2708
|
+
const model = configVal.model || 'modelValue';
|
|
2709
|
+
return Object.assign({ onBlur, [model]: pathState.value, [`onUpdate:${model}`]: onUpdateModelValue }, (configVal.props || {}));
|
|
2708
2710
|
}
|
|
2711
|
+
const model = (config === null || config === void 0 ? void 0 : config.model) || 'modelValue';
|
|
2712
|
+
const base = {
|
|
2713
|
+
[model]: pathState.value,
|
|
2714
|
+
[`onUpdate:${model}`]: onUpdateModelValue,
|
|
2715
|
+
};
|
|
2709
2716
|
if (config === null || config === void 0 ? void 0 : config.mapProps) {
|
|
2710
|
-
return Object.assign(Object.assign({}, base), config.mapProps(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2717
|
+
return Object.assign(Object.assign({ onBlur }, base), config.mapProps(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2711
2718
|
}
|
|
2712
2719
|
return base;
|
|
2713
2720
|
});
|
|
2714
2721
|
return props;
|
|
2715
2722
|
}
|
|
2716
2723
|
function defineInputBinds(path, config) {
|
|
2717
|
-
const pathState = (findPathState(
|
|
2724
|
+
const pathState = (findPathState(toValue(path)) || createPathState(path));
|
|
2718
2725
|
const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
|
|
2719
2726
|
function onBlur() {
|
|
2720
2727
|
var _a;
|
|
@@ -2759,7 +2766,7 @@ function useForm(opts) {
|
|
|
2759
2766
|
});
|
|
2760
2767
|
return props;
|
|
2761
2768
|
}
|
|
2762
|
-
return Object.assign(Object.assign({}, formCtx), { handleReset: () => resetForm(), submitForm,
|
|
2769
|
+
return Object.assign(Object.assign({}, formCtx), { values: readonly(formValues), handleReset: () => resetForm(), submitForm,
|
|
2763
2770
|
defineComponentBinds,
|
|
2764
2771
|
defineInputBinds });
|
|
2765
2772
|
}
|
|
@@ -2809,8 +2816,8 @@ function useFormInitialValues(pathsState, formValues, opts) {
|
|
|
2809
2816
|
// these only change when the user explicitly changes the initial values or when the user resets them with new values.
|
|
2810
2817
|
const originalInitialValues = ref(klona(values));
|
|
2811
2818
|
function setInitialValues(values, updateFields = false) {
|
|
2812
|
-
initialValues.value = klona(values);
|
|
2813
|
-
originalInitialValues.value = klona(values);
|
|
2819
|
+
initialValues.value = merge(klona(initialValues.value) || {}, klona(values));
|
|
2820
|
+
originalInitialValues.value = merge(klona(originalInitialValues.value) || {}, klona(values));
|
|
2814
2821
|
if (!updateFields) {
|
|
2815
2822
|
return;
|
|
2816
2823
|
}
|
package/dist/vee-validate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.
|
|
2
|
+
* vee-validate v4.10.1
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -500,14 +500,8 @@
|
|
|
500
500
|
});
|
|
501
501
|
return baseRef;
|
|
502
502
|
}
|
|
503
|
-
function unravel(value) {
|
|
504
|
-
if (isCallable(value)) {
|
|
505
|
-
return value();
|
|
506
|
-
}
|
|
507
|
-
return vue.unref(value);
|
|
508
|
-
}
|
|
509
503
|
function lazyToRef(value) {
|
|
510
|
-
return vue.computed(() =>
|
|
504
|
+
return vue.computed(() => vue.toValue(value));
|
|
511
505
|
}
|
|
512
506
|
function normalizeErrorItem(message) {
|
|
513
507
|
return Array.isArray(message) ? message : message ? [message] : [];
|
|
@@ -561,6 +555,12 @@
|
|
|
561
555
|
return '_value' in el;
|
|
562
556
|
}
|
|
563
557
|
|
|
558
|
+
function parseInputValue(el) {
|
|
559
|
+
if (el.type === 'number') {
|
|
560
|
+
return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
|
|
561
|
+
}
|
|
562
|
+
return el.value;
|
|
563
|
+
}
|
|
564
564
|
function normalizeEventValue(value) {
|
|
565
565
|
if (!isEvent(value)) {
|
|
566
566
|
return value;
|
|
@@ -586,7 +586,7 @@
|
|
|
586
586
|
const selectedOption = Array.from(input.options).find(opt => opt.selected);
|
|
587
587
|
return selectedOption ? getBoundValue(selectedOption) : input.value;
|
|
588
588
|
}
|
|
589
|
-
return input
|
|
589
|
+
return parseInputValue(input);
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
/**
|
|
@@ -749,12 +749,17 @@
|
|
|
749
749
|
for (let i = 0; i < length; i++) {
|
|
750
750
|
const rule = pipeline[i];
|
|
751
751
|
const result = await rule(value, ctx);
|
|
752
|
-
const isValid = typeof result !== 'string' && result;
|
|
752
|
+
const isValid = typeof result !== 'string' && !Array.isArray(result) && result;
|
|
753
753
|
if (isValid) {
|
|
754
754
|
continue;
|
|
755
755
|
}
|
|
756
|
-
|
|
757
|
-
|
|
756
|
+
if (Array.isArray(result)) {
|
|
757
|
+
errors.push(...result);
|
|
758
|
+
}
|
|
759
|
+
else {
|
|
760
|
+
const message = typeof result === 'string' ? result : _generateFieldError(ctx);
|
|
761
|
+
errors.push(message);
|
|
762
|
+
}
|
|
758
763
|
if (field.bails) {
|
|
759
764
|
return {
|
|
760
765
|
errors,
|
|
@@ -1057,7 +1062,7 @@
|
|
|
1057
1062
|
return getFromPath(form.values, vue.unref(path));
|
|
1058
1063
|
},
|
|
1059
1064
|
set(newVal) {
|
|
1060
|
-
form.setFieldValue(vue.unref(path), newVal);
|
|
1065
|
+
form.setFieldValue(vue.unref(path), newVal, false);
|
|
1061
1066
|
},
|
|
1062
1067
|
});
|
|
1063
1068
|
return {
|
|
@@ -1126,7 +1131,7 @@
|
|
|
1126
1131
|
return _useField(path, rules, opts);
|
|
1127
1132
|
}
|
|
1128
1133
|
function _useField(path, rules, opts) {
|
|
1129
|
-
const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount,
|
|
1134
|
+
const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount, syncVModel, form: controlForm, } = normalizeOptions(opts);
|
|
1130
1135
|
const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
|
|
1131
1136
|
const form = controlForm || injectedForm;
|
|
1132
1137
|
const name = lazyToRef(path);
|
|
@@ -1154,13 +1159,16 @@
|
|
|
1154
1159
|
});
|
|
1155
1160
|
const errorMessage = vue.computed(() => errors.value[0]);
|
|
1156
1161
|
if (syncVModel) {
|
|
1157
|
-
useVModel({ value, prop:
|
|
1162
|
+
useVModel({ value, prop: syncVModel, handleChange });
|
|
1158
1163
|
}
|
|
1159
1164
|
/**
|
|
1160
1165
|
* Handles common onBlur meta update
|
|
1161
1166
|
*/
|
|
1162
|
-
const handleBlur = () => {
|
|
1167
|
+
const handleBlur = (evt, shouldValidate = false) => {
|
|
1163
1168
|
meta.touched = true;
|
|
1169
|
+
if (shouldValidate) {
|
|
1170
|
+
validateWithStateMutation();
|
|
1171
|
+
}
|
|
1164
1172
|
};
|
|
1165
1173
|
async function validateCurrentValue(mode) {
|
|
1166
1174
|
var _a, _b;
|
|
@@ -1236,10 +1244,6 @@
|
|
|
1236
1244
|
}
|
|
1237
1245
|
function setValue(newValue, shouldValidate = true) {
|
|
1238
1246
|
value.value = newValue;
|
|
1239
|
-
if (!shouldValidate) {
|
|
1240
|
-
validateValidStateOnly();
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
1247
|
const validateFn = shouldValidate ? validateWithStateMutation : validateValidStateOnly;
|
|
1244
1248
|
validateFn();
|
|
1245
1249
|
}
|
|
@@ -1332,7 +1336,7 @@
|
|
|
1332
1336
|
vue.onBeforeUnmount(() => {
|
|
1333
1337
|
var _a;
|
|
1334
1338
|
const shouldKeepValue = (_a = vue.unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : vue.unref(form.keepValuesOnUnmount);
|
|
1335
|
-
const path =
|
|
1339
|
+
const path = vue.toValue(name);
|
|
1336
1340
|
if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
|
|
1337
1341
|
form === null || form === void 0 ? void 0 : form.removePathState(path, id);
|
|
1338
1342
|
return;
|
|
@@ -1357,7 +1361,7 @@
|
|
|
1357
1361
|
}
|
|
1358
1362
|
}
|
|
1359
1363
|
else {
|
|
1360
|
-
form.unsetPathValue(
|
|
1364
|
+
form.unsetPathValue(vue.toValue(name));
|
|
1361
1365
|
}
|
|
1362
1366
|
form.removePathState(path, id);
|
|
1363
1367
|
});
|
|
@@ -1367,7 +1371,6 @@
|
|
|
1367
1371
|
* Normalizes partial field options to include the full options
|
|
1368
1372
|
*/
|
|
1369
1373
|
function normalizeOptions(opts) {
|
|
1370
|
-
var _a;
|
|
1371
1374
|
const defaults = () => ({
|
|
1372
1375
|
initialValue: undefined,
|
|
1373
1376
|
validateOnMount: false,
|
|
@@ -1375,13 +1378,13 @@
|
|
|
1375
1378
|
label: undefined,
|
|
1376
1379
|
validateOnValueUpdate: true,
|
|
1377
1380
|
keepValueOnUnmount: undefined,
|
|
1378
|
-
|
|
1379
|
-
syncVModel: true,
|
|
1381
|
+
syncVModel: false,
|
|
1380
1382
|
controlled: true,
|
|
1381
1383
|
});
|
|
1382
|
-
const isVModelSynced = (
|
|
1384
|
+
const isVModelSynced = !!(opts === null || opts === void 0 ? void 0 : opts.syncVModel);
|
|
1385
|
+
const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === 'string' ? opts.syncVModel : (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || 'modelValue';
|
|
1383
1386
|
const initialValue = isVModelSynced && !('initialValue' in (opts || {}))
|
|
1384
|
-
? getCurrentModelValue(vue.getCurrentInstance(),
|
|
1387
|
+
? getCurrentModelValue(vue.getCurrentInstance(), modelPropName)
|
|
1385
1388
|
: opts === null || opts === void 0 ? void 0 : opts.initialValue;
|
|
1386
1389
|
if (!opts) {
|
|
1387
1390
|
return Object.assign(Object.assign({}, defaults()), { initialValue });
|
|
@@ -1389,7 +1392,9 @@
|
|
|
1389
1392
|
// TODO: Deprecate this in next major release
|
|
1390
1393
|
const checkedValue = 'valueProp' in opts ? opts.valueProp : opts.checkedValue;
|
|
1391
1394
|
const controlled = 'standalone' in opts ? !opts.standalone : opts.controlled;
|
|
1392
|
-
|
|
1395
|
+
const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
|
|
1396
|
+
return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { initialValue, controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue,
|
|
1397
|
+
syncVModel });
|
|
1393
1398
|
}
|
|
1394
1399
|
function useFieldWithChecked(name, rules, opts) {
|
|
1395
1400
|
const form = !(opts === null || opts === void 0 ? void 0 : opts.standalone) ? injectWithSelf(FormContextKey) : undefined;
|
|
@@ -1405,23 +1410,22 @@
|
|
|
1405
1410
|
: isEqual(checkedVal, currentValue);
|
|
1406
1411
|
});
|
|
1407
1412
|
function handleCheckboxChange(e, shouldValidate = true) {
|
|
1408
|
-
var _a;
|
|
1413
|
+
var _a, _b;
|
|
1409
1414
|
if (checked.value === ((_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.checked)) {
|
|
1410
1415
|
if (shouldValidate) {
|
|
1411
1416
|
field.validate();
|
|
1412
1417
|
}
|
|
1413
1418
|
return;
|
|
1414
1419
|
}
|
|
1415
|
-
const path =
|
|
1420
|
+
const path = vue.toValue(name);
|
|
1416
1421
|
const pathState = form === null || form === void 0 ? void 0 : form.getPathState(path);
|
|
1417
1422
|
const value = normalizeEventValue(e);
|
|
1418
|
-
let newValue;
|
|
1423
|
+
let newValue = (_b = vue.unref(checkedValue)) !== null && _b !== void 0 ? _b : value;
|
|
1419
1424
|
if (form && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple) && pathState.type === 'checkbox') {
|
|
1420
|
-
newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [],
|
|
1425
|
+
newValue = resolveNextCheckboxValue(getFromPath(form.values, path) || [], newValue, undefined);
|
|
1421
1426
|
}
|
|
1422
|
-
else {
|
|
1423
|
-
|
|
1424
|
-
newValue = resolveNextCheckboxValue(vue.unref(field.value), vue.unref(checkedValue), vue.unref(uncheckedValue));
|
|
1427
|
+
else if ((opts === null || opts === void 0 ? void 0 : opts.type) === 'checkbox') {
|
|
1428
|
+
newValue = resolveNextCheckboxValue(vue.unref(field.value), newValue, vue.unref(uncheckedValue));
|
|
1425
1429
|
}
|
|
1426
1430
|
handleChange(newValue, shouldValidate);
|
|
1427
1431
|
}
|
|
@@ -1434,10 +1438,10 @@
|
|
|
1434
1438
|
function useVModel({ prop, value, handleChange }) {
|
|
1435
1439
|
const vm = vue.getCurrentInstance();
|
|
1436
1440
|
/* istanbul ignore next */
|
|
1437
|
-
if (!vm) {
|
|
1441
|
+
if (!vm || !prop) {
|
|
1438
1442
|
return;
|
|
1439
1443
|
}
|
|
1440
|
-
const propName = prop
|
|
1444
|
+
const propName = typeof prop === 'string' ? prop : 'modelValue';
|
|
1441
1445
|
const emitName = `update:${propName}`;
|
|
1442
1446
|
// Component doesn't have a model prop setup (must be defined on the props)
|
|
1443
1447
|
if (!(propName in vm.props)) {
|
|
@@ -1554,6 +1558,7 @@
|
|
|
1554
1558
|
label,
|
|
1555
1559
|
validateOnValueUpdate: false,
|
|
1556
1560
|
keepValueOnUnmount: keepValue,
|
|
1561
|
+
syncVModel: true,
|
|
1557
1562
|
});
|
|
1558
1563
|
// If there is a v-model applied on the component we need to emit the `update:modelValue` whenever the value binding changes
|
|
1559
1564
|
const onChangeHandler = function handleChangeWithModel(e, shouldValidate = true) {
|
|
@@ -1563,13 +1568,10 @@
|
|
|
1563
1568
|
const sharedProps = vue.computed(() => {
|
|
1564
1569
|
const { validateOnInput, validateOnChange, validateOnBlur, validateOnModelUpdate } = resolveValidationTriggers(props);
|
|
1565
1570
|
function baseOnBlur(e) {
|
|
1566
|
-
handleBlur(e);
|
|
1571
|
+
handleBlur(e, validateOnBlur);
|
|
1567
1572
|
if (isCallable(ctx.attrs.onBlur)) {
|
|
1568
1573
|
ctx.attrs.onBlur(e);
|
|
1569
1574
|
}
|
|
1570
|
-
if (validateOnBlur) {
|
|
1571
|
-
validateField();
|
|
1572
|
-
}
|
|
1573
1575
|
}
|
|
1574
1576
|
function baseOnInput(e) {
|
|
1575
1577
|
onChangeHandler(e, validateOnInput);
|
|
@@ -1773,7 +1775,7 @@
|
|
|
1773
1775
|
const schema = opts === null || opts === void 0 ? void 0 : opts.validationSchema;
|
|
1774
1776
|
function createPathState(path, config) {
|
|
1775
1777
|
var _a, _b;
|
|
1776
|
-
const initialValue = vue.computed(() => getFromPath(initialValues.value,
|
|
1778
|
+
const initialValue = vue.computed(() => getFromPath(initialValues.value, vue.toValue(path)));
|
|
1777
1779
|
const pathStateExists = pathStates.value.find(state => state.path === vue.unref(path));
|
|
1778
1780
|
if (pathStateExists) {
|
|
1779
1781
|
if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
|
|
@@ -1790,8 +1792,8 @@
|
|
|
1790
1792
|
pathStateExists.__flags.pendingUnmount[id] = false;
|
|
1791
1793
|
return pathStateExists;
|
|
1792
1794
|
}
|
|
1793
|
-
const currentValue = vue.computed(() => getFromPath(formValues,
|
|
1794
|
-
const pathValue =
|
|
1795
|
+
const currentValue = vue.computed(() => getFromPath(formValues, vue.toValue(path)));
|
|
1796
|
+
const pathValue = vue.toValue(path);
|
|
1795
1797
|
const id = FIELD_ID_COUNTER++;
|
|
1796
1798
|
const state = vue.reactive({
|
|
1797
1799
|
id,
|
|
@@ -2043,7 +2045,7 @@
|
|
|
2043
2045
|
/**
|
|
2044
2046
|
* Sets a single field value
|
|
2045
2047
|
*/
|
|
2046
|
-
function setFieldValue(field, value) {
|
|
2048
|
+
function setFieldValue(field, value, shouldValidate = true) {
|
|
2047
2049
|
const clonedValue = klona(value);
|
|
2048
2050
|
const path = typeof field === 'string' ? field : field.path;
|
|
2049
2051
|
const pathState = findPathState(path);
|
|
@@ -2051,6 +2053,9 @@
|
|
|
2051
2053
|
createPathState(path);
|
|
2052
2054
|
}
|
|
2053
2055
|
setInPath(formValues, path, clonedValue);
|
|
2056
|
+
if (shouldValidate) {
|
|
2057
|
+
validateField(path);
|
|
2058
|
+
}
|
|
2054
2059
|
}
|
|
2055
2060
|
/**
|
|
2056
2061
|
* Sets multiple fields values
|
|
@@ -2068,7 +2073,7 @@
|
|
|
2068
2073
|
},
|
|
2069
2074
|
set(value) {
|
|
2070
2075
|
const pathValue = vue.unref(path);
|
|
2071
|
-
setFieldValue(pathValue, value);
|
|
2076
|
+
setFieldValue(pathValue, value, false);
|
|
2072
2077
|
pathState.validated = true;
|
|
2073
2078
|
pathState.pending = true;
|
|
2074
2079
|
validateField(pathValue).then(() => {
|
|
@@ -2104,7 +2109,7 @@
|
|
|
2104
2109
|
var _a;
|
|
2105
2110
|
const newValue = state && 'value' in state ? state.value : getFromPath(initialValues.value, field);
|
|
2106
2111
|
setFieldInitialValue(field, klona(newValue));
|
|
2107
|
-
setFieldValue(field, newValue);
|
|
2112
|
+
setFieldValue(field, newValue, false);
|
|
2108
2113
|
setFieldTouched(field, (_a = state === null || state === void 0 ? void 0 : state.touched) !== null && _a !== void 0 ? _a : false);
|
|
2109
2114
|
setFieldError(field, (state === null || state === void 0 ? void 0 : state.errors) || []);
|
|
2110
2115
|
}
|
|
@@ -2114,14 +2119,14 @@
|
|
|
2114
2119
|
function resetForm(resetState) {
|
|
2115
2120
|
const newValues = (resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value;
|
|
2116
2121
|
setInitialValues(newValues);
|
|
2117
|
-
setValues(newValues);
|
|
2118
2122
|
mutateAllPathState(state => {
|
|
2119
2123
|
var _a;
|
|
2120
2124
|
state.validated = false;
|
|
2121
2125
|
state.touched = ((_a = resetState === null || resetState === void 0 ? void 0 : resetState.touched) === null || _a === void 0 ? void 0 : _a[state.path]) || false;
|
|
2122
|
-
setFieldValue(state.path, getFromPath(newValues, state.path));
|
|
2126
|
+
setFieldValue(state.path, getFromPath(newValues, state.path), false);
|
|
2123
2127
|
setFieldError(state.path, undefined);
|
|
2124
2128
|
});
|
|
2129
|
+
setValues(newValues);
|
|
2125
2130
|
setErrors((resetState === null || resetState === void 0 ? void 0 : resetState.errors) || {});
|
|
2126
2131
|
submitCount.value = (resetState === null || resetState === void 0 ? void 0 : resetState.submitCount) || 0;
|
|
2127
2132
|
vue.nextTick(() => {
|
|
@@ -2253,7 +2258,7 @@
|
|
|
2253
2258
|
// Provide injections
|
|
2254
2259
|
vue.provide(FormContextKey, formCtx);
|
|
2255
2260
|
function defineComponentBinds(path, config) {
|
|
2256
|
-
const pathState = findPathState(
|
|
2261
|
+
const pathState = findPathState(vue.toValue(path)) || createPathState(path);
|
|
2257
2262
|
const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
|
|
2258
2263
|
function onBlur() {
|
|
2259
2264
|
var _a;
|
|
@@ -2272,23 +2277,25 @@
|
|
|
2272
2277
|
}
|
|
2273
2278
|
}
|
|
2274
2279
|
const props = vue.computed(() => {
|
|
2275
|
-
const base = {
|
|
2276
|
-
modelValue: pathState.value,
|
|
2277
|
-
'onUpdate:modelValue': onUpdateModelValue,
|
|
2278
|
-
onBlur,
|
|
2279
|
-
};
|
|
2280
2280
|
if (isCallable(config)) {
|
|
2281
|
-
|
|
2281
|
+
const configVal = config(pathState);
|
|
2282
|
+
const model = configVal.model || 'modelValue';
|
|
2283
|
+
return Object.assign({ onBlur, [model]: pathState.value, [`onUpdate:${model}`]: onUpdateModelValue }, (configVal.props || {}));
|
|
2282
2284
|
}
|
|
2285
|
+
const model = (config === null || config === void 0 ? void 0 : config.model) || 'modelValue';
|
|
2286
|
+
const base = {
|
|
2287
|
+
[model]: pathState.value,
|
|
2288
|
+
[`onUpdate:${model}`]: onUpdateModelValue,
|
|
2289
|
+
};
|
|
2283
2290
|
if (config === null || config === void 0 ? void 0 : config.mapProps) {
|
|
2284
|
-
return Object.assign(Object.assign({}, base), config.mapProps(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2291
|
+
return Object.assign(Object.assign({ onBlur }, base), config.mapProps(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2285
2292
|
}
|
|
2286
2293
|
return base;
|
|
2287
2294
|
});
|
|
2288
2295
|
return props;
|
|
2289
2296
|
}
|
|
2290
2297
|
function defineInputBinds(path, config) {
|
|
2291
|
-
const pathState = (findPathState(
|
|
2298
|
+
const pathState = (findPathState(vue.toValue(path)) || createPathState(path));
|
|
2292
2299
|
const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
|
|
2293
2300
|
function onBlur() {
|
|
2294
2301
|
var _a;
|
|
@@ -2333,7 +2340,7 @@
|
|
|
2333
2340
|
});
|
|
2334
2341
|
return props;
|
|
2335
2342
|
}
|
|
2336
|
-
return Object.assign(Object.assign({}, formCtx), { handleReset: () => resetForm(), submitForm,
|
|
2343
|
+
return Object.assign(Object.assign({}, formCtx), { values: vue.readonly(formValues), handleReset: () => resetForm(), submitForm,
|
|
2337
2344
|
defineComponentBinds,
|
|
2338
2345
|
defineInputBinds });
|
|
2339
2346
|
}
|
|
@@ -2383,8 +2390,8 @@
|
|
|
2383
2390
|
// these only change when the user explicitly changes the initial values or when the user resets them with new values.
|
|
2384
2391
|
const originalInitialValues = vue.ref(klona(values));
|
|
2385
2392
|
function setInitialValues(values, updateFields = false) {
|
|
2386
|
-
initialValues.value = klona(values);
|
|
2387
|
-
originalInitialValues.value = klona(values);
|
|
2393
|
+
initialValues.value = merge(klona(initialValues.value) || {}, klona(values));
|
|
2394
|
+
originalInitialValues.value = merge(klona(originalInitialValues.value) || {}, klona(values));
|
|
2388
2395
|
if (!updateFields) {
|
|
2389
2396
|
return;
|
|
2390
2397
|
}
|
package/dist/vee-validate.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.
|
|
2
|
+
* vee-validate v4.10.1
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function l(e){return Number(e)>=0}function i(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function u(e,t){return Object.keys(t).forEach((n=>{if(i(t[n]))return e[n]||(e[n]={}),void u(e[n],t[n]);e[n]=t[n]})),e}const o={};const s=Symbol("vee-validate-form"),d=Symbol("vee-validate-field-instance"),c=Symbol("Default empty value"),v="undefined"!=typeof window;function f(e){return n(e)&&!!e.__locatorRef}function p(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function m(e){return!!e&&n(e.validate)}function h(e){return"checkbox"===e||"radio"===e}function y(e){return/^\[.+\]$/i.test(e)}function g(e){return"SELECT"===e.tagName}function b(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!h(t.type)}function O(e){return V(e)&&e.target&&"submit"in e.target}function V(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function j(e,t){return t in e&&e[t]!==c}function F(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!F(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!F(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var l=a[r];if(!F(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!v&&e instanceof File}function w(e,t,n){"object"==typeof n.value&&(n.value=S(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function S(e){if("object"!=typeof e)return e;var t,n,r,a=0,l=Object.prototype.toString.call(e);if("[object Object]"===l?r=Object.create(e.__proto__||null):"[object Array]"===l?r=Array(e.length):"[object Set]"===l?(r=new Set,e.forEach((function(e){r.add(S(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(S(t),S(e))}))):"[object Date]"===l?r=new Date(+e):"[object RegExp]"===l?r=new RegExp(e.source,e.flags):"[object DataView]"===l?r=new e.constructor(S(e.buffer)):"[object ArrayBuffer]"===l?r=e.slice(0):"Array]"===l.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)w(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||w(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function E(e){return y(e)?e.replace(/\[|\]/gi,""):e}function k(e,t,n){if(!e)return n;if(y(t))return e[E(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function I(e,t,n){if(y(t))return void(e[E(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=l(a[e+1])?[]:{}),i=i[a[e]]}}function C(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function B(e,t){if(y(t))return void delete e[E(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const i=n.map(((t,r)=>k(e,n.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)u=i[t],(Array.isArray(u)?0===u.length:a(u)&&0===Object.keys(u).length)&&(0!==t?C(i[t-1],n[t-1]):C(e,n[0]));var u}function M(e){return Object.keys(e)}function P(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function U(e){t.warn(`[vee-validate]: ${e}`)}function _(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>F(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return F(e,t)?n:t}function T(e,t=0){let n=null,r=[];return function(...a){return n&&window.clearTimeout(n),n=window.setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function R(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function x(e,t){let n;return async function(...r){const a=e(...r);n=a;const l=await a;return a!==n||(n=void 0,t(l,r)),l}}function N({get:e,set:n}){const r=t.ref(S(e()));return t.watch(e,(e=>{F(e,r.value)||(r.value=S(e))}),{deep:!0}),t.watch(r,(t=>{F(t,e())||n(S(t))}),{deep:!0}),r}function $(e){return n(e)?e():t.unref(e)}function D(e){return Array.isArray(e)?e:e?[e]:[]}function z(e){const n=P(s),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(d);return a||(null==r?void 0:r.value)||U(`field with name ${t.unref(e)} was not found`),r||a}function q(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const L=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function K(e){if(W(e))return e._value}function W(e){return"_value"in e}function G(e){if(!V(e))return e;const t=e.target;if(h(t.type)&&W(t))return K(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(g(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(K);var n;if(g(t)){const e=Array.from(t.options).find((e=>e.selected));return e?K(e):t.value}return t.value}function X(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=H(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=J(t);return n.name?(e[n.name]=H(n.params),e):e}),t):t}function H(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>k(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const J=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let Q=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Y=()=>Q,Z=e=>{Q=Object.assign(Object.assign({},Q),e)};async function ee(e,t,r={}){const a=null==r?void 0:r.bails,l={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(p(e.rules)||m(e.rules))return async function(e,t){const n=p(t)?t:te(t),r=await n.parse(e),a=[];for(const e of r.errors)e.errors.length&&a.push(...e.errors);return{errors:a}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,l=[];for(let i=0;i<a;i++){const a=r[i],u=await a(t,n);if("string"!=typeof u&&u)continue;const o="string"==typeof u?u:re(n);if(l.push(o),e.bails)return{errors:l}}return{errors:l}}const r=Object.assign(Object.assign({},e),{rules:X(e.rules)}),a=[],l=Object.keys(r.rules),i=l.length;for(let n=0;n<i;n++){const i=l[n],u=await ne(r,t,{name:i,params:r.rules[i]});if(u.error&&(a.push(u.error),e.bails))return{errors:a}}return{errors:a}}(l,e),u=i.errors;return{errors:u,valid:!u.length}}function te(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function ne(e,t,n){const r=(a=n.name,o[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>f(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),i={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:l})},u=await r(t,l,i);return"string"==typeof u?{error:u}:{error:u?void 0:re(i)}}function re(e){const t=Y().generateMessage;return t?t(e):"Field is invalid"}async function ae(e,t,n){const r=M(e).map((async r=>{var a,l,i;const u=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await ee(k(t,r),e[r],{name:(null==u?void 0:u.name)||r,label:null==u?void 0:u.label,values:t,bails:null===(i=null===(l=null==n?void 0:n.bailsMap)||void 0===l?void 0:l[r])||void 0===i||i});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const l=await Promise.all(r),i={},u={};for(const e of l)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,u[e.path]=e.errors[0]);return{valid:a,results:i,errors:u}}let le=0;function ie(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?k(r.initialValues.value,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const u=t.computed(l);if(!r){return{value:t.ref(l()),initialValue:u,setInitialValue:i}}const o=function(e,n,r,a){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return k(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>k(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n)}});return{value:s,initialValue:u,setInitialValue:i}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=D(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!F(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&l(e.initialValue)}return{id:d,path:e,value:r,initialValue:a,meta:c,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const i=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),u=t.computed((()=>i.errors));return{id:Array.isArray(i.id)?i.id[i.id.length-1]:i.id,path:e,value:r,errors:u,meta:i,initialValue:a,flags:i.__flags,setState:function(a){var i,u,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(i=n.form)||void 0===i||i.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(u=n.form)||void 0===u||u.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&l(a.initialValue)}}}function ue(e,n,r){return h(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:P(s),l=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function u(n){const r=n.handleChange,u=t.computed((()=>{const e=t.unref(n.value),r=t.unref(l);return Array.isArray(e)?e.findIndex((e=>F(e,r)))>=0:F(r,e)}));function o(o,s=!0){var d;if(u.value===(null===(d=null==o?void 0:o.target)||void 0===d?void 0:d.checked))return void(s&&n.validate());const c=$(e),v=null==a?void 0:a.getPathState(c),f=G(o);let p;p=a&&(null==v?void 0:v.multiple)&&"checkbox"===v.type?_(k(a.values,c)||[],f,void 0):_(t.unref(n.value),t.unref(l),t.unref(i)),r(p,s)}return Object.assign(Object.assign({},n),{checked:u,checkedValue:l,uncheckedValue:i,handleChange:o})}return u(oe(e,n,r))}(e,n,r):oe(e,n,r)}function oe(e,r,a){const{initialValue:l,validateOnMount:i,bails:u,type:o,checkedValue:v,label:h,validateOnValueUpdate:y,uncheckedValue:g,controlled:b,keepValueOnUnmount:O,modelPropName:V,syncVModel:j,form:A}=function(e){var n;const r=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0,controlled:!0}),a=null===(n=null==e?void 0:e.syncVModel)||void 0===n||n,l=a&&!("initialValue"in(e||{}))?se(t.getCurrentInstance(),(null==e?void 0:e.modelPropName)||"modelValue"):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},r()),{initialValue:l});const i="valueProp"in e?e.valueProp:e.checkedValue,u="standalone"in e?!e.standalone:e.controlled;return Object.assign(Object.assign(Object.assign({},r()),e||{}),{initialValue:l,controlled:null==u||u,checkedValue:i})}(a),w=b?P(s):void 0,E=A||w,I=function(e){return t.computed((()=>$(e)))}(e),C=t.computed((()=>{if(t.unref(null==E?void 0:E.schema))return;const e=t.unref(r);return m(e)||p(e)||n(e)||Array.isArray(e)?e:X(e)})),{id:B,value:U,initialValue:_,meta:T,setState:N,errors:D,flags:z}=ie(I,{modelValue:l,form:E,bails:u,label:h,type:o,validate:C.value?H:void 0}),q=t.computed((()=>D.value[0]));j&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const l=e||"modelValue",i=`update:${l}`;if(!(l in a.props))return;t.watch(n,(e=>{F(e,se(a,l))||a.emit(i,e)})),t.watch((()=>se(a,l)),(e=>{if(e===c&&void 0===n.value)return;const t=e===c?void 0:e;F(t,R(n.value,a.props.modelModifiers))||r(t)}))}({value:U,prop:V,handleChange:J});async function L(e){var n,r;return(null==E?void 0:E.validateSchema)?null!==(n=(await E.validateSchema(e)).results[t.unref(I)])&&void 0!==n?n:{valid:!0,errors:[]}:C.value?ee(U.value,C.value,{name:t.unref(I),label:t.unref(h),values:null!==(r=null==E?void 0:E.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const K=x((async()=>(T.pending=!0,T.validated=!0,L("validated-only"))),(e=>{if(!z.pendingUnmount[te.id])return N({errors:e.errors}),T.pending=!1,T.valid=e.valid,e})),W=x((async()=>L("silent")),(e=>(T.valid=e.valid,e)));function H(e){return"silent"===(null==e?void 0:e.mode)?W():K()}function J(e,t=!0){Y(G(e),t)}function Q(e){var t;const n=e&&"value"in e?e.value:_.value;N({value:S(n),initialValue:S(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),T.pending=!1,T.validated=!1,W()}function Y(e,t=!0){if(U.value=e,!t)return void W();(t?K:W)()}t.onMounted((()=>{if(i)return K();E&&E.validateSchema||W()}));const Z=t.computed({get:()=>U.value,set(e){Y(e,y)}}),te={id:B,name:I,label:h,value:Z,meta:T,errors:D,errorMessage:q,type:o,checkedValue:v,uncheckedValue:g,bails:u,keepValueOnUnmount:O,resetField:Q,handleReset:()=>Q(),validate:H,handleChange:J,handleBlur:()=>{T.touched=!0},setState:N,setTouched:function(e){T.touched=e},setErrors:function(e){N({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(d,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{F(e,t)||(T.validated?K():W())}),{deep:!0}),!E)return te;const ne=t.computed((()=>{const e=C.value;return!e||n(e)||m(e)||p(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(f):M(a).filter((e=>f(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=k(E.values,t)||E.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!F(e,t)&&(T.validated?K():W())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(te.keepValueOnUnmount))&&void 0!==e?e:t.unref(E.keepValuesOnUnmount),r=$(I);if(n||!E||z.pendingUnmount[te.id])return void(null==E||E.removePathState(r,B));z.pendingUnmount[te.id]=!0;const a=E.getPathState(r);if(Array.isArray(null==a?void 0:a.id)&&(null==a?void 0:a.multiple)?null==a?void 0:a.id.includes(te.id):(null==a?void 0:a.id)===te.id){if((null==a?void 0:a.multiple)&&Array.isArray(a.value)){const e=a.value.findIndex((e=>F(e,t.unref(te.checkedValue))));if(e>-1){const t=[...a.value];t.splice(e,1),E.setFieldValue(r,t)}Array.isArray(a.id)&&a.id.splice(a.id.indexOf(te.id),1)}else E.unsetPathValue($(I));E.removePathState(r,B)}})),te}function se(e,t){if(e)return e.props[t]}function de(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ce(e,t){return h(t.attrs.type)?j(e,"modelValue")?e.modelValue:void 0:j(e,"modelValue")?e.modelValue:t.attrs.value}const ve=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>Y().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:c},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const a=t.toRef(e,"rules"),l=t.toRef(e,"name"),i=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:y,handleReset:g,meta:O,checked:V,setErrors:j}=ue(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:ce(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o}),F=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},A=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:l,validateOnModelUpdate:i}=function(e){var t,n,r,a;const{validateOnInput:l,validateOnChange:i,validateOnBlur:u,validateOnModelUpdate:o}=Y();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:l,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:u,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const u={name:e.name,onBlur:function(e){p(e),n(r.attrs.onBlur)&&r.attrs.onBlur(e),l&&v()},onInput:function(e){F(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){F(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>F(e,i)};return u})),w=t.computed((()=>{const t=Object.assign({},A.value);h(r.attrs.type)&&V&&(t.checked=V.value);return b(de(e,r),r.attrs)&&(t.value=d.value),t})),S=t.computed((()=>Object.assign(Object.assign({},A.value),{modelValue:d.value})));function E(){return{field:w.value,componentField:S.value,value:d.value,meta:O,errors:s.value,errorMessage:c.value,validate:v,resetField:y,handleChange:F,handleInput:e=>F(e,!1),handleReset:g,handleBlur:A.value.onBlur,setTouched:m,setErrors:j}}return r.expose({setErrors:j,setTouched:m,reset:y,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(de(e,r)),a=L(n,r,E);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let fe=0;const pe=["bails","fieldsCount","id","multiple","type","validate"];function me(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&p(a)&&n(a.cast)?S(a.cast(r)||{}):S(r)}function he(e){var r;const a=fe++;let l=0;const i=t.ref(!1),o=t.ref(!1),d=t.ref(0),c=[],v=t.reactive(me(e)),f=t.ref([]),h=t.ref({});function y(e,t){const n=H(e);n?(n.errors=D(t),n.valid=!n.errors.length):"string"==typeof e&&(h.value[e]=D(t))}function g(e){M(e).forEach((t=>{y(t,e[t])}))}(null==e?void 0:e.initialErrors)&&g(e.initialErrors);const b=t.computed((()=>{const e=f.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),V=t.computed((()=>M(b.value).reduce(((e,t)=>{const n=b.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),j=t.computed((()=>f.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),A=t.computed((()=>f.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),w=Object.assign({},(null==e?void 0:e.initialErrors)||{}),E=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:C,originalInitialValues:P,setInitialValues:U}=function(e,n,r){const a=me(r),l=null==r?void 0:r.initialValues,i=t.ref(a),u=t.ref(S(a));function o(t,r=!1){i.value=S(t),u.value=S(t),r&&e.value.forEach((e=>{if(e.touched)return;const t=k(i.value,e.path);I(n,e.path,S(t))}))}t.isRef(l)&&t.watch(l,(e=>{e&&o(e,!0)}),{deep:!0});return{initialValues:i,originalInitialValues:u,setInitialValues:o}}(f,v,e),_=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!F(n,t.unref(r))));function u(){const t=e.value;return M(l).reduce(((e,n)=>{const r=l[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(u());return t.watchEffect((()=>{const e=u();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!M(a.value).length,dirty:i.value})))}(f,v,P,V),R=t.computed((()=>f.value.reduce(((e,t)=>{const n=k(v,t.path);return I(e,t.path,n),e}),{}))),N=null==e?void 0:e.validationSchema;function z(e,n){var r,a;const i=t.computed((()=>k(C.value,$(e)))),u=f.value.find((n=>n.path===t.unref(e)));if(u){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(u.multiple=!0);const e=l++;return Array.isArray(u.id)?u.id.push(e):u.id=[u.id,e],u.fieldsCount++,u.__flags.pendingUnmount[e]=!1,u}const o=t.computed((()=>k(v,$(e)))),s=$(e),d=l++,c=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=w[s])||void 0===r?void 0:r.length),initialValue:i,errors:t.shallowRef([]),bails:null!==(a=null==n?void 0:n.bails)&&void 0!==a&&a,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1}},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!F(t.unref(o),t.unref(i))))});return f.value.push(c),V.value[s]&&!w[s]&&t.nextTick((()=>{ve(s)})),t.isRef(e)&&t.watch(e,(e=>{const n=S(o.value);t.nextTick((()=>{I(v,e,n)}))})),c}const L=T(ge,5),K=T(ge,5),W=x((async e=>"silent"===await e?L():K()),((e,[t])=>{const n=M(ne.errorBag.value);return[...new Set([...M(e.results),...f.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const a=r,l=H(a)||function(e){const t=f.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(a),i=(e.results[a]||{errors:[]}).errors,u={errors:i,valid:!i.length};return n.results[a]=u,u.valid||(n.errors[a]=u.errors[0]),l&&h.value[a]&&delete h.value[a],l?(l.valid=u.valid,"silent"===t?n:"validated-only"!==t||l.validated?(y(l,u.errors),n):n):(y(a,i),n)}),{valid:e.valid,results:{},errors:{}})}));function X(e){f.value.forEach(e)}function H(e){return"string"==typeof e?f.value.find((t=>t.path===e)):e}let J,Q=[];function Z(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),X((e=>e.touched=!0)),i.value=!0,d.value++,ce().then((a=>{const l=S(v);if(a.valid&&"function"==typeof t){const n=S(R.value);let i=e?n:l;return a.values&&(i=a.values),t(i,{evt:r,controlledValues:n,setErrors:g,setFieldError:y,setTouched:oe,setFieldTouched:ue,setValues:le,setFieldValue:re,resetForm:de,resetField:se})}a.valid||"function"!=typeof n||n({values:l,evt:r,errors:a.errors,results:a.results})})).then((e=>(i.value=!1,e)),(e=>{throw i.value=!1,e}))}}}const ee=Z(!1);ee.withControlled=Z(!0);const ne={formId:a,values:v,controlledValues:R,errorBag:b,errors:V,schema:N,submitCount:d,meta:_,isSubmitting:i,isValidating:o,fieldArrays:c,keepValuesOnUnmount:E,validateSchema:t.unref(N)?W:void 0,validate:ce,setFieldError:y,validateField:ve,setFieldValue:re,setValues:le,setErrors:g,setFieldTouched:ue,setTouched:oe,resetForm:de,resetField:se,handleSubmit:ee,stageInitialValue:function(t,n,r=!1){ye(t,n),I(v,t,n),r&&!(null==e?void 0:e.initialValues)&&I(P.value,t,S(n))},unsetInitialValue:he,setFieldInitialValue:ye,useFieldModel:function(e){if(!Array.isArray(e))return ie(e);return e.map(ie)},createPathState:z,getPathState:H,unsetPathValue:function(e){return Q.push(e),J||(J=t.nextTick((()=>{[...Q].sort().reverse().forEach((e=>{B(v,e)})),Q=[],J=null}))),J},removePathState:function(e,t){const n=f.value.findIndex((t=>t.path===e)),r=f.value[n];if(-1!==n&&r){if(r.multiple&&r.fieldsCount&&r.fieldsCount--,Array.isArray(r.id)){const e=r.id.indexOf(t);e>=0&&r.id.splice(e,1),delete r.__flags.pendingUnmount[t]}(!r.multiple||r.fieldsCount<=0)&&(f.value.splice(n,1),he(e))}},initialValues:C,getAllPathStates:()=>f.value,markForUnmount:function(e){return X((t=>{t.path.startsWith(e)&&M(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))}};function re(e,t){const n=S(t),r="string"==typeof e?e:e.path;H(r)||z(r),I(v,r,n)}function le(e){u(v,e),c.forEach((e=>e&&e.reset()))}function ie(e){const n=H(t.unref(e))||z(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);re(a,r),n.validated=!0,n.pending=!0,ve(a).then((()=>{n.pending=!1}))}})}function ue(e,t){const n=H(e);n&&(n.touched=t)}function oe(e){M(e).forEach((t=>{ue(t,!!e[t])}))}function se(e,t){var n;const r=t&&"value"in t?t.value:k(C.value,e);ye(e,S(r)),re(e,r),ue(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),y(e,(null==t?void 0:t.errors)||[])}function de(e){const n=(null==e?void 0:e.values)?e.values:P.value;U(n),le(n),X((t=>{var r;t.validated=!1,t.touched=(null===(r=null==e?void 0:e.touched)||void 0===r?void 0:r[t.path])||!1,re(t.path,k(n,t.path)),y(t.path,void 0)})),g((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{ce({mode:"silent"})}))}async function ce(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&X((e=>e.validated=!0)),ne.validateSchema)return ne.validateSchema(t);o.value=!0;const n=await Promise.all(f.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));o.value=!1;const r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function ve(e){const n=H(e);if(n&&(n.validated=!0),N){const{results:t}=await W("validated-only");return t[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate():(n||t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function he(e){B(C.value,e)}function ye(e,t){I(C.value,e,S(t))}async function ge(){const e=t.unref(N);if(!e)return{valid:!0,results:{},errors:{}};o.value=!0;const n=m(e)||p(e)?await async function(e,t){const n=p(e)?e:te(e),r=await n.parse(t),a={},l={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));a[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!r.errors.length,results:a,errors:l,values:r.value}}(e,v):await ae(e,v,{names:j.value,bailsMap:A.value});return o.value=!1,n}const be=ee(((e,{evt:t})=>{O(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&g(e.initialErrors),(null==e?void 0:e.initialTouched)&&oe(e.initialTouched),(null==e?void 0:e.validateOnMount)?ce():ne.validateSchema&&ne.validateSchema("silent")})),t.isRef(N)&&t.watch(N,(()=>{var e;null===(e=ne.validateSchema)||void 0===e||e.call(ne,"validated-only")})),t.provide(s,ne),Object.assign(Object.assign({},ne),{handleReset:()=>de(),submitForm:be,defineComponentBinds:function(e,r){const a=H($(e))||z(e),l=()=>n(r)?r(q(a,pe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Y().validateOnBlur)&&ve(a.path)}function u(e){var t;re(a.path,e);(null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:Y().validateOnModelUpdate)&&ve(a.path)}return t.computed((()=>{const e={modelValue:a.value,"onUpdate:modelValue":u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(a).props||{}):(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},e),r.mapProps(q(a,pe))):e}))},defineInputBinds:function(e,r){const a=H($(e))||z(e),l=()=>n(r)?r(q(a,pe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Y().validateOnBlur)&&ve(a.path)}function u(e){var t;const n=G(e);re(a.path,n);(null!==(t=l().validateOnInput)&&void 0!==t?t:Y().validateOnInput)&&ve(a.path)}function o(e){var t;const n=G(e);re(a.path,n);(null!==(t=l().validateOnChange)&&void 0!==t?t:Y().validateOnChange)&&ve(a.path)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(q(a,pe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(q(a,pe))):e}))}})}const ye=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:i,errorBag:u,values:o,meta:s,isSubmitting:d,isValidating:c,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:j,setFieldValue:F,setValues:A,setFieldTouched:w,setTouched:E,resetField:k}=he({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),I=g(((e,{evt:t})=>{O(t)&&t.target.submit()}),e.onInvalidSubmit),C=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function B(e){V(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function M(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function P(){return S(o)}function U(){return S(s.value)}function _(){return S(i.value)}function T(){return{meta:s.value,errors:i.value,errorBag:u.value,values:o,isSubmitting:d.value,isValidating:c.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:M,handleReset:h,submitForm:I,setErrors:b,setFieldError:j,setFieldValue:F,setValues:A,setFieldTouched:w,setTouched:E,resetForm:y,resetField:k,getValues:P,getMeta:U,getErrors:_}}return n.expose({setFieldError:j,setErrors:b,setFieldValue:F,setValues:A,setFieldTouched:w,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:P,getMeta:U,getErrors:_}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=L(r,n,T);if(!e.as)return a;const l="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},l),n.attrs),{onSubmit:C,onReset:B}),a)}}}),ge=ye;function be(e){const n=P(s,void 0),a=t.ref([]),l=()=>{},i={fields:a,remove:l,push:l,swap:l,insert:l,update:l,replace:l,prepend:l,move:l};if(!n)return U("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),i;if(!t.unref(e))return U("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const u=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(u)return u;let o=0;function d(){return k(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=d();Array.isArray(e)&&(a.value=e.map(((e,t)=>f(e,t,a.value))),v())}function v(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(l,i,u){if(u&&!r(i)&&u[i])return u[i];const s=o++,d={key:s,value:N({get(){const r=k(null==n?void 0:n.values,t.unref(e),[])||[],i=a.value.findIndex((e=>e.key===s));return-1===i?l:r[i]},set(e){const t=a.value.findIndex((e=>e.key===s));-1!==t?m(t,e):U("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,a){const l=t.unref(e),i=k(null==n?void 0:n.values,l);!Array.isArray(i)||i.length-1<r||(I(n.values,`${l}[${r}]`,a),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:a,remove:function(r){const l=t.unref(e),i=k(null==n?void 0:n.values,l);if(!i||!Array.isArray(i))return;const u=[...i];u.splice(r,1);const o=l+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),I(n.values,l,u),a.value.splice(r,1),p()},push:function(l){const i=t.unref(e),u=k(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[...o];s.push(l),n.stageInitialValue(i+`[${s.length-1}]`,l),I(n.values,i,s),a.value.push(f(l)),p()},swap:function(r,l){const i=t.unref(e),u=k(null==n?void 0:n.values,i);if(!Array.isArray(u)||!(r in u)||!(l in u))return;const o=[...u],s=[...a.value],d=o[r];o[r]=o[l],o[l]=d;const c=s[r];s[r]=s[l],s[l]=c,I(n.values,i,o),a.value=s,v()},insert:function(r,l){const i=t.unref(e),u=k(null==n?void 0:n.values,i);if(!Array.isArray(u)||u.length<r)return;const o=[...u],s=[...a.value];o.splice(r,0,l),s.splice(r,0,f(l)),I(n.values,i,o),a.value=s,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),I(n.values,a,r),c(),p()},prepend:function(l){const i=t.unref(e),u=k(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[l,...o];n.stageInitialValue(i+`[${s.length-1}]`,l),I(n.values,i,s),a.value.unshift(f(l)),p()},move:function(l,i){const u=t.unref(e),o=k(null==n?void 0:n.values,u),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(l in o)||!(i in o))return;const d=[...a.value],c=d[l];d.splice(l,1),d.splice(i,0,c);const v=s[l];s.splice(l,1),s.splice(i,0,v),I(n.values,u,s),a.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(d,(e=>{F(e,a.value.map((e=>e.value)))||c()})),h}const Oe=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:l,insert:i,replace:u,update:o,prepend:s,move:d,fields:c}=be(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}),()=>L(void 0,n,v)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(s,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function l(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=L(r,n,l),u=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,u,i):t.h(r||"span",u,a.value):i}}});e.ErrorMessage=Ve,e.Field=ve,e.FieldArray=Oe,e.FieldContextKey=d,e.Form=ge,e.FormContextKey=s,e.IS_ABSENT=c,e.configure=Z,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),o[e]=t},e.useField=ue,e.useFieldArray=be,e.useFieldError=function(e){const n=P(s),r=e?void 0:t.inject(d);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=P(s),r=e?void 0:t.inject(d);return t.computed((()=>e?k(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=he,e.useFormErrors=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=z(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=z(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=z(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=P(s);t||U("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=P(s),r=e?void 0:t.inject(d);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(U(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=ee,e.validateObject=ae}));
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function l(e){return Number(e)>=0}function i(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function u(e,t){return Object.keys(t).forEach((n=>{if(i(t[n]))return e[n]||(e[n]={}),void u(e[n],t[n]);e[n]=t[n]})),e}const o={};const s=Symbol("vee-validate-form"),d=Symbol("vee-validate-field-instance"),c=Symbol("Default empty value"),v="undefined"!=typeof window;function f(e){return n(e)&&!!e.__locatorRef}function p(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function m(e){return!!e&&n(e.validate)}function h(e){return"checkbox"===e||"radio"===e}function y(e){return/^\[.+\]$/i.test(e)}function g(e){return"SELECT"===e.tagName}function b(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!h(t.type)}function V(e){return O(e)&&e.target&&"submit"in e.target}function O(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function j(e,t){return t in e&&e[t]!==c}function F(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!F(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!F(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var l=a[r];if(!F(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!v&&e instanceof File}function w(e,t,n){"object"==typeof n.value&&(n.value=S(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function S(e){if("object"!=typeof e)return e;var t,n,r,a=0,l=Object.prototype.toString.call(e);if("[object Object]"===l?r=Object.create(e.__proto__||null):"[object Array]"===l?r=Array(e.length):"[object Set]"===l?(r=new Set,e.forEach((function(e){r.add(S(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(S(t),S(e))}))):"[object Date]"===l?r=new Date(+e):"[object RegExp]"===l?r=new RegExp(e.source,e.flags):"[object DataView]"===l?r=new e.constructor(S(e.buffer)):"[object ArrayBuffer]"===l?r=e.slice(0):"Array]"===l.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)w(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||w(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function E(e){return y(e)?e.replace(/\[|\]/gi,""):e}function k(e,t,n){if(!e)return n;if(y(t))return e[E(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function I(e,t,n){if(y(t))return void(e[E(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=l(a[e+1])?[]:{}),i=i[a[e]]}}function M(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function C(e,t){if(y(t))return void delete e[E(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){M(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const i=n.map(((t,r)=>k(e,n.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)u=i[t],(Array.isArray(u)?0===u.length:a(u)&&0===Object.keys(u).length)&&(0!==t?M(i[t-1],n[t-1]):M(e,n[0]));var u}function B(e){return Object.keys(e)}function P(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function U(e){t.warn(`[vee-validate]: ${e}`)}function _(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>F(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return F(e,t)?n:t}function T(e,t=0){let n=null,r=[];return function(...a){return n&&window.clearTimeout(n),n=window.setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function N(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function R(e,t){let n;return async function(...r){const a=e(...r);n=a;const l=await a;return a!==n||(n=void 0,t(l,r)),l}}function x({get:e,set:n}){const r=t.ref(S(e()));return t.watch(e,(e=>{F(e,r.value)||(r.value=S(e))}),{deep:!0}),t.watch(r,(t=>{F(t,e())||n(S(t))}),{deep:!0}),r}function $(e){return Array.isArray(e)?e:e?[e]:[]}function D(e){const n=P(s),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(d);return a||(null==r?void 0:r.value)||U(`field with name ${t.unref(e)} was not found`),r||a}function z(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const q=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function L(e){if(K(e))return e._value}function K(e){return"_value"in e}function W(e){if(!O(e))return e;const t=e.target;if(h(t.type)&&K(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(g(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(g(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return function(e){return"number"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function G(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=X(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=H(t);return n.name?(e[n.name]=X(n.params),e):e}),t):t}function X(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>k(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const H=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let J=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Q=()=>J,Y=e=>{J=Object.assign(Object.assign({},J),e)};async function Z(e,t,r={}){const a=null==r?void 0:r.bails,l={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(p(e.rules)||m(e.rules))return async function(e,t){const n=p(t)?t:ee(t),r=await n.parse(e),a=[];for(const e of r.errors)e.errors.length&&a.push(...e.errors);return{errors:a}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,l=[];for(let i=0;i<a;i++){const a=r[i],u=await a(t,n);if(!("string"!=typeof u&&!Array.isArray(u)&&u)){if(Array.isArray(u))l.push(...u);else{const e="string"==typeof u?u:ne(n);l.push(e)}if(e.bails)return{errors:l}}}return{errors:l}}const r=Object.assign(Object.assign({},e),{rules:G(e.rules)}),a=[],l=Object.keys(r.rules),i=l.length;for(let n=0;n<i;n++){const i=l[n],u=await te(r,t,{name:i,params:r.rules[i]});if(u.error&&(a.push(u.error),e.bails))return{errors:a}}return{errors:a}}(l,e),u=i.errors;return{errors:u,valid:!u.length}}function ee(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function te(e,t,n){const r=(a=n.name,o[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>f(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),i={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:l})},u=await r(t,l,i);return"string"==typeof u?{error:u}:{error:u?void 0:ne(i)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=B(e).map((async r=>{var a,l,i;const u=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await Z(k(t,r),e[r],{name:(null==u?void 0:u.name)||r,label:null==u?void 0:u.label,values:t,bails:null===(i=null===(l=null==n?void 0:n.bailsMap)||void 0===l?void 0:l[r])||void 0===i||i});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const l=await Promise.all(r),i={},u={};for(const e of l)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,u[e.path]=e.errors[0]);return{valid:a,results:i,errors:u}}let ae=0;function le(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?k(r.initialValues.value,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const u=t.computed(l);if(!r){return{value:t.ref(l()),initialValue:u,setInitialValue:i}}const o=function(e,n,r,a){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return k(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>k(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:u,setInitialValue:i}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=ae>=Number.MAX_SAFE_INTEGER?0:++ae,c=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!F(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&l(e.initialValue)}return{id:d,path:e,value:r,initialValue:a,meta:c,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const i=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),u=t.computed((()=>i.errors));return{id:Array.isArray(i.id)?i.id[i.id.length-1]:i.id,path:e,value:r,errors:u,meta:i,initialValue:a,flags:i.__flags,setState:function(a){var i,u,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(i=n.form)||void 0===i||i.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(u=n.form)||void 0===u||u.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&l(a.initialValue)}}}function ie(e,n,r){return h(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:P(s),l=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function u(n){const u=n.handleChange,o=t.computed((()=>{const e=t.unref(n.value),r=t.unref(l);return Array.isArray(e)?e.findIndex((e=>F(e,r)))>=0:F(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==a?void 0:a.getPathState(f),m=W(s);let h=null!==(v=t.unref(l))&&void 0!==v?v:m;a&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=_(k(a.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=_(t.unref(n.value),h,t.unref(i))),u(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:l,uncheckedValue:i,handleChange:s})}return u(ue(e,n,r))}(e,n,r):ue(e,n,r)}function ue(e,r,a){const{initialValue:l,validateOnMount:i,bails:u,type:o,checkedValue:v,label:h,validateOnValueUpdate:y,uncheckedValue:g,controlled:b,keepValueOnUnmount:V,syncVModel:O,form:j}=function(e){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),r=!!(null==e?void 0:e.syncVModel),a="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",l=r&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),a):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:l});const i="valueProp"in e?e.valueProp:e.checkedValue,u="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:l,controlled:null==u||u,checkedValue:i,syncVModel:o})}(a),A=b?P(s):void 0,w=j||A,E=function(e){return t.computed((()=>t.toValue(e)))}(e),I=t.computed((()=>{if(t.unref(null==w?void 0:w.schema))return;const e=t.unref(r);return m(e)||p(e)||n(e)||Array.isArray(e)?e:G(e)})),{id:M,value:C,initialValue:U,meta:_,setState:T,errors:x,flags:$}=le(E,{modelValue:l,form:w,bails:u,label:h,type:o,validate:I.value?K:void 0}),D=t.computed((()=>x.value[0]));O&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a||!e)return;const l="string"==typeof e?e:"modelValue",i=`update:${l}`;if(!(l in a.props))return;t.watch(n,(e=>{F(e,oe(a,l))||a.emit(i,e)})),t.watch((()=>oe(a,l)),(e=>{if(e===c&&void 0===n.value)return;const t=e===c?void 0:e;F(t,N(n.value,a.props.modelModifiers))||r(t)}))}({value:C,prop:O,handleChange:X});async function z(e){var n,r;return(null==w?void 0:w.validateSchema)?null!==(n=(await w.validateSchema(e)).results[t.unref(E)])&&void 0!==n?n:{valid:!0,errors:[]}:I.value?Z(C.value,I.value,{name:t.unref(E),label:t.unref(h),values:null!==(r=null==w?void 0:w.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const q=R((async()=>(_.pending=!0,_.validated=!0,z("validated-only"))),(e=>{if(!$.pendingUnmount[Y.id])return T({errors:e.errors}),_.pending=!1,_.valid=e.valid,e})),L=R((async()=>z("silent")),(e=>(_.valid=e.valid,e)));function K(e){return"silent"===(null==e?void 0:e.mode)?L():q()}function X(e,t=!0){J(W(e),t)}function H(e){var t;const n=e&&"value"in e?e.value:U.value;T({value:S(n),initialValue:S(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),_.pending=!1,_.validated=!1,L()}function J(e,t=!0){C.value=e;(t?q:L)()}t.onMounted((()=>{if(i)return q();w&&w.validateSchema||L()}));const Q=t.computed({get:()=>C.value,set(e){J(e,y)}}),Y={id:M,name:E,label:h,value:Q,meta:_,errors:x,errorMessage:D,type:o,checkedValue:v,uncheckedValue:g,bails:u,keepValueOnUnmount:V,resetField:H,handleReset:()=>H(),validate:K,handleChange:X,handleBlur:(e,t=!1)=>{_.touched=!0,t&&q()},setState:T,setTouched:function(e){_.touched=e},setErrors:function(e){T({errors:Array.isArray(e)?e:[e]})},setValue:J};if(t.provide(d,Y),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{F(e,t)||(_.validated?q():L())}),{deep:!0}),!w)return Y;const ee=t.computed((()=>{const e=I.value;return!e||n(e)||m(e)||p(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(f):B(a).filter((e=>f(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=k(w.values,t)||w.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(ee,((e,t)=>{if(!Object.keys(e).length)return;!F(e,t)&&(_.validated?q():L())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(Y.keepValueOnUnmount))&&void 0!==e?e:t.unref(w.keepValuesOnUnmount),r=t.toValue(E);if(n||!w||$.pendingUnmount[Y.id])return void(null==w||w.removePathState(r,M));$.pendingUnmount[Y.id]=!0;const a=w.getPathState(r);if(Array.isArray(null==a?void 0:a.id)&&(null==a?void 0:a.multiple)?null==a?void 0:a.id.includes(Y.id):(null==a?void 0:a.id)===Y.id){if((null==a?void 0:a.multiple)&&Array.isArray(a.value)){const e=a.value.findIndex((e=>F(e,t.unref(Y.checkedValue))));if(e>-1){const t=[...a.value];t.splice(e,1),w.setFieldValue(r,t)}Array.isArray(a.id)&&a.id.splice(a.id.indexOf(Y.id),1)}else w.unsetPathValue(t.toValue(E));w.removePathState(r,M)}})),Y}function oe(e,t){if(e)return e.props[t]}function se(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function de(e,t){return h(t.attrs.type)?j(e,"modelValue")?e.modelValue:void 0:j(e,"modelValue")?e.modelValue:t.attrs.value}const ce=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>Q().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:c},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const a=t.toRef(e,"rules"),l=t.toRef(e,"name"),i=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:y,handleReset:g,meta:V,checked:O,setErrors:j}=ie(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o,syncVModel:!0}),F=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},A=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:l,validateOnModelUpdate:i}=function(e){var t,n,r,a;const{validateOnInput:l,validateOnChange:i,validateOnBlur:u,validateOnModelUpdate:o}=Q();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:l,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:u,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const u={name:e.name,onBlur:function(e){p(e,l),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){F(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){F(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>F(e,i)};return u})),w=t.computed((()=>{const t=Object.assign({},A.value);h(r.attrs.type)&&O&&(t.checked=O.value);return b(se(e,r),r.attrs)&&(t.value=d.value),t})),S=t.computed((()=>Object.assign(Object.assign({},A.value),{modelValue:d.value})));function E(){return{field:w.value,componentField:S.value,value:d.value,meta:V,errors:s.value,errorMessage:c.value,validate:v,resetField:y,handleChange:F,handleInput:e=>F(e,!1),handleReset:g,handleBlur:A.value.onBlur,setTouched:m,setErrors:j}}return r.expose({setErrors:j,setTouched:m,reset:y,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),a=q(n,r,E);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&p(a)&&n(a.cast)?S(a.cast(r)||{}):S(r)}function me(e){var r;const a=ve++;let l=0;const i=t.ref(!1),o=t.ref(!1),d=t.ref(0),c=[],v=t.reactive(pe(e)),f=t.ref([]),h=t.ref({});function y(e,t){const n=X(e);n?(n.errors=$(t),n.valid=!n.errors.length):"string"==typeof e&&(h.value[e]=$(t))}function g(e){B(e).forEach((t=>{y(t,e[t])}))}(null==e?void 0:e.initialErrors)&&g(e.initialErrors);const b=t.computed((()=>{const e=f.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),O=t.computed((()=>B(b.value).reduce(((e,t)=>{const n=b.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),j=t.computed((()=>f.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),A=t.computed((()=>f.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),w=Object.assign({},(null==e?void 0:e.initialErrors)||{}),E=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:M,originalInitialValues:P,setInitialValues:U}=function(e,n,r){const a=pe(r),l=null==r?void 0:r.initialValues,i=t.ref(a),o=t.ref(S(a));function s(t,r=!1){i.value=u(S(i.value)||{},S(t)),o.value=u(S(o.value)||{},S(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=k(i.value,e.path);I(n,e.path,S(t))}))}t.isRef(l)&&t.watch(l,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:i,originalInitialValues:o,setInitialValues:s}}(f,v,e),_=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!F(n,t.unref(r))));function u(){const t=e.value;return B(l).reduce(((e,n)=>{const r=l[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(u());return t.watchEffect((()=>{const e=u();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!B(a.value).length,dirty:i.value})))}(f,v,P,O),N=t.computed((()=>f.value.reduce(((e,t)=>{const n=k(v,t.path);return I(e,t.path,n),e}),{}))),x=null==e?void 0:e.validationSchema;function D(e,n){var r,a;const i=t.computed((()=>k(M.value,t.toValue(e)))),u=f.value.find((n=>n.path===t.unref(e)));if(u){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(u.multiple=!0);const e=l++;return Array.isArray(u.id)?u.id.push(e):u.id=[u.id,e],u.fieldsCount++,u.__flags.pendingUnmount[e]=!1,u}const o=t.computed((()=>k(v,t.toValue(e)))),s=t.toValue(e),d=l++,c=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=w[s])||void 0===r?void 0:r.length),initialValue:i,errors:t.shallowRef([]),bails:null!==(a=null==n?void 0:n.bails)&&void 0!==a&&a,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1}},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!F(t.unref(o),t.unref(i))))});return f.value.push(c),O.value[s]&&!w[s]&&t.nextTick((()=>{ce(s)})),t.isRef(e)&&t.watch(e,(e=>{const n=S(o.value);t.nextTick((()=>{I(v,e,n)}))})),c}const q=T(ye,5),L=T(ye,5),K=R((async e=>"silent"===await e?q():L()),((e,[t])=>{const n=B(te.errorBag.value);return[...new Set([...B(e.results),...f.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const a=r,l=X(a)||function(e){const t=f.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(a),i=(e.results[a]||{errors:[]}).errors,u={errors:i,valid:!i.length};return n.results[a]=u,u.valid||(n.errors[a]=u.errors[0]),l&&h.value[a]&&delete h.value[a],l?(l.valid=u.valid,"silent"===t?n:"validated-only"!==t||l.validated?(y(l,u.errors),n):n):(y(a,i),n)}),{valid:e.valid,results:{},errors:{}})}));function G(e){f.value.forEach(e)}function X(e){return"string"==typeof e?f.value.find((t=>t.path===e)):e}let H,J=[];function Y(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),G((e=>e.touched=!0)),i.value=!0,d.value++,de().then((a=>{const l=S(v);if(a.valid&&"function"==typeof t){const n=S(N.value);let i=e?n:l;return a.values&&(i=a.values),t(i,{evt:r,controlledValues:n,setErrors:g,setFieldError:y,setTouched:ue,setFieldTouched:ie,setValues:ae,setFieldValue:ne,resetForm:se,resetField:oe})}a.valid||"function"!=typeof n||n({values:l,evt:r,errors:a.errors,results:a.results})})).then((e=>(i.value=!1,e)),(e=>{throw i.value=!1,e}))}}}const Z=Y(!1);Z.withControlled=Y(!0);const te={formId:a,values:v,controlledValues:N,errorBag:b,errors:O,schema:x,submitCount:d,meta:_,isSubmitting:i,isValidating:o,fieldArrays:c,keepValuesOnUnmount:E,validateSchema:t.unref(x)?K:void 0,validate:de,setFieldError:y,validateField:ce,setFieldValue:ne,setValues:ae,setErrors:g,setFieldTouched:ie,setTouched:ue,resetForm:se,resetField:oe,handleSubmit:Z,stageInitialValue:function(t,n,r=!1){he(t,n),I(v,t,n),r&&!(null==e?void 0:e.initialValues)&&I(P.value,t,S(n))},unsetInitialValue:me,setFieldInitialValue:he,useFieldModel:function(e){if(!Array.isArray(e))return le(e);return e.map(le)},createPathState:D,getPathState:X,unsetPathValue:function(e){return J.push(e),H||(H=t.nextTick((()=>{[...J].sort().reverse().forEach((e=>{C(v,e)})),J=[],H=null}))),H},removePathState:function(e,t){const n=f.value.findIndex((t=>t.path===e)),r=f.value[n];if(-1!==n&&r){if(r.multiple&&r.fieldsCount&&r.fieldsCount--,Array.isArray(r.id)){const e=r.id.indexOf(t);e>=0&&r.id.splice(e,1),delete r.__flags.pendingUnmount[t]}(!r.multiple||r.fieldsCount<=0)&&(f.value.splice(n,1),me(e))}},initialValues:M,getAllPathStates:()=>f.value,markForUnmount:function(e){return G((t=>{t.path.startsWith(e)&&B(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))}};function ne(e,t,n=!0){const r=S(t),a="string"==typeof e?e:e.path;X(a)||D(a),I(v,a,r),n&&ce(a)}function ae(e){u(v,e),c.forEach((e=>e&&e.reset()))}function le(e){const n=X(t.unref(e))||D(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);ne(a,r,!1),n.validated=!0,n.pending=!0,ce(a).then((()=>{n.pending=!1}))}})}function ie(e,t){const n=X(e);n&&(n.touched=t)}function ue(e){B(e).forEach((t=>{ie(t,!!e[t])}))}function oe(e,t){var n;const r=t&&"value"in t?t.value:k(M.value,e);he(e,S(r)),ne(e,r,!1),ie(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),y(e,(null==t?void 0:t.errors)||[])}function se(e){const n=(null==e?void 0:e.values)?e.values:P.value;U(n),G((t=>{var r;t.validated=!1,t.touched=(null===(r=null==e?void 0:e.touched)||void 0===r?void 0:r[t.path])||!1,ne(t.path,k(n,t.path),!1),y(t.path,void 0)})),ae(n),g((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{de({mode:"silent"})}))}async function de(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&G((e=>e.validated=!0)),te.validateSchema)return te.validateSchema(t);o.value=!0;const n=await Promise.all(f.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));o.value=!1;const r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function ce(e){const n=X(e);if(n&&(n.validated=!0),x){const{results:t}=await K("validated-only");return t[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate():(n||t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function me(e){C(M.value,e)}function he(e,t){I(M.value,e,S(t))}async function ye(){const e=t.unref(x);if(!e)return{valid:!0,results:{},errors:{}};o.value=!0;const n=m(e)||p(e)?await async function(e,t){const n=p(e)?e:ee(e),r=await n.parse(t),a={},l={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));a[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!r.errors.length,results:a,errors:l,values:r.value}}(e,v):await re(e,v,{names:j.value,bailsMap:A.value});return o.value=!1,n}const ge=Z(((e,{evt:t})=>{V(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&g(e.initialErrors),(null==e?void 0:e.initialTouched)&&ue(e.initialTouched),(null==e?void 0:e.validateOnMount)?de():te.validateSchema&&te.validateSchema("silent")})),t.isRef(x)&&t.watch(x,(()=>{var e;null===(e=te.validateSchema)||void 0===e||e.call(te,"validated-only")})),t.provide(s,te),Object.assign(Object.assign({},te),{values:t.readonly(v),handleReset:()=>se(),submitForm:ge,defineComponentBinds:function(e,r){const a=X(t.toValue(e))||D(e),l=()=>n(r)?r(z(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ce(a.path)}function u(e){var t;ne(a.path,e);(null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:Q().validateOnModelUpdate)&&ce(a.path)}return t.computed((()=>{if(n(r)){const e=r(a),t=e.model||"modelValue";return Object.assign({onBlur:i,[t]:a.value,[`onUpdate:${t}`]:u},e.props||{})}const e=(null==r?void 0:r.model)||"modelValue",t={[e]:a.value,[`onUpdate:${e}`]:u};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({onBlur:i},t),r.mapProps(z(a,fe))):t}))},defineInputBinds:function(e,r){const a=X(t.toValue(e))||D(e),l=()=>n(r)?r(z(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ce(a.path)}function u(e){var t;const n=W(e);ne(a.path,n);(null!==(t=l().validateOnInput)&&void 0!==t?t:Q().validateOnInput)&&ce(a.path)}function o(e){var t;const n=W(e);ne(a.path,n);(null!==(t=l().validateOnChange)&&void 0!==t?t:Q().validateOnChange)&&ce(a.path)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(z(a,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(a,fe))):e}))}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:i,errorBag:u,values:o,meta:s,isSubmitting:d,isValidating:c,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:j,setFieldValue:F,setValues:A,setFieldTouched:w,setTouched:E,resetField:k}=me({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),I=g(((e,{evt:t})=>{V(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function C(e){O(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function B(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function P(){return S(o)}function U(){return S(s.value)}function _(){return S(i.value)}function T(){return{meta:s.value,errors:i.value,errorBag:u.value,values:o,isSubmitting:d.value,isValidating:c.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:B,handleReset:h,submitForm:I,setErrors:b,setFieldError:j,setFieldValue:F,setValues:A,setFieldTouched:w,setTouched:E,resetForm:y,resetField:k,getValues:P,getMeta:U,getErrors:_}}return n.expose({setFieldError:j,setErrors:b,setFieldValue:F,setValues:A,setFieldTouched:w,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:P,getMeta:U,getErrors:_}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=q(r,n,T);if(!e.as)return a;const l="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},l),n.attrs),{onSubmit:M,onReset:C}),a)}}}),ye=he;function ge(e){const n=P(s,void 0),a=t.ref([]),l=()=>{},i={fields:a,remove:l,push:l,swap:l,insert:l,update:l,replace:l,prepend:l,move:l};if(!n)return U("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),i;if(!t.unref(e))return U("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const u=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(u)return u;let o=0;function d(){return k(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=d();Array.isArray(e)&&(a.value=e.map(((e,t)=>f(e,t,a.value))),v())}function v(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(l,i,u){if(u&&!r(i)&&u[i])return u[i];const s=o++,d={key:s,value:x({get(){const r=k(null==n?void 0:n.values,t.unref(e),[])||[],i=a.value.findIndex((e=>e.key===s));return-1===i?l:r[i]},set(e){const t=a.value.findIndex((e=>e.key===s));-1!==t?m(t,e):U("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,a){const l=t.unref(e),i=k(null==n?void 0:n.values,l);!Array.isArray(i)||i.length-1<r||(I(n.values,`${l}[${r}]`,a),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:a,remove:function(r){const l=t.unref(e),i=k(null==n?void 0:n.values,l);if(!i||!Array.isArray(i))return;const u=[...i];u.splice(r,1);const o=l+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),I(n.values,l,u),a.value.splice(r,1),p()},push:function(l){const i=t.unref(e),u=k(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[...o];s.push(l),n.stageInitialValue(i+`[${s.length-1}]`,l),I(n.values,i,s),a.value.push(f(l)),p()},swap:function(r,l){const i=t.unref(e),u=k(null==n?void 0:n.values,i);if(!Array.isArray(u)||!(r in u)||!(l in u))return;const o=[...u],s=[...a.value],d=o[r];o[r]=o[l],o[l]=d;const c=s[r];s[r]=s[l],s[l]=c,I(n.values,i,o),a.value=s,v()},insert:function(r,l){const i=t.unref(e),u=k(null==n?void 0:n.values,i);if(!Array.isArray(u)||u.length<r)return;const o=[...u],s=[...a.value];o.splice(r,0,l),s.splice(r,0,f(l)),I(n.values,i,o),a.value=s,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),I(n.values,a,r),c(),p()},prepend:function(l){const i=t.unref(e),u=k(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[l,...o];n.stageInitialValue(i+`[${s.length-1}]`,l),I(n.values,i,s),a.value.unshift(f(l)),p()},move:function(l,i){const u=t.unref(e),o=k(null==n?void 0:n.values,u),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(l in o)||!(i in o))return;const d=[...a.value],c=d[l];d.splice(l,1),d.splice(i,0,c);const v=s[l];s.splice(l,1),s.splice(i,0,v),I(n.values,u,s),a.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(d,(e=>{F(e,a.value.map((e=>e.value)))||c()})),h}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:l,insert:i,replace:u,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}),()=>q(void 0,n,v)}}),Ve=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(s,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function l(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=q(r,n,l),u=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,u,i):t.h(r||"span",u,a.value):i}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=d,e.Form=ye,e.FormContextKey=s,e.IS_ABSENT=c,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),o[e]=t},e.useField=ie,e.useFieldArray=ge,e.useFieldError=function(e){const n=P(s),r=e?void 0:t.inject(d);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=P(s),r=e?void 0:t.inject(d);return t.computed((()=>e?k(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=P(s);t||U("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=P(s),r=e?void 0:t.inject(d);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(U(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=P(s);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vee-validate",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.1",
|
|
4
4
|
"description": "Form Validation for Vue.js",
|
|
5
5
|
"author": "Abdelrahman Awad <logaretm1@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"dist/*.d.ts"
|
|
29
29
|
],
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"vue": "^3.3.
|
|
31
|
+
"vue": "^3.3.4"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@vue/devtools-api": "^6.5.0",
|
|
35
|
-
"type-fest": "^3.
|
|
35
|
+
"type-fest": "^3.12.0"
|
|
36
36
|
}
|
|
37
37
|
}
|