vee-validate 4.10.4 → 4.10.6
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 +12 -7
- package/dist/vee-validate.esm.js +50 -19
- package/dist/vee-validate.js +50 -18
- package/dist/vee-validate.min.js +2 -2
- package/package.json +1 -1
package/dist/vee-validate.d.ts
CHANGED
|
@@ -290,7 +290,7 @@ interface FormActions<TValues extends GenericObject, TOutput = TValues> {
|
|
|
290
290
|
setFieldValue<T extends Path<TValues>>(field: T, value: PathValue<TValues, T>, shouldValidate?: boolean): void;
|
|
291
291
|
setFieldError(field: Path<TValues>, message: string | string[] | undefined): void;
|
|
292
292
|
setErrors(fields: FormErrors<TValues>): void;
|
|
293
|
-
setValues(fields: PartialDeep<TValues
|
|
293
|
+
setValues(fields: PartialDeep<TValues>, shouldValidate?: boolean): void;
|
|
294
294
|
setFieldTouched(field: Path<TValues>, isTouched: boolean): void;
|
|
295
295
|
setTouched(fields: Partial<Record<Path<TValues>, boolean>>): void;
|
|
296
296
|
resetForm(state?: Partial<FormState<TValues>>): void;
|
|
@@ -332,7 +332,7 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
|
|
|
332
332
|
keepValuesOnUnmount: MaybeRef<boolean>;
|
|
333
333
|
validateSchema?: (mode: SchemaValidationMode) => Promise<FormValidationResult<TValues, TOutput>>;
|
|
334
334
|
validate(opts?: Partial<ValidationOptions$1>): Promise<FormValidationResult<TValues, TOutput>>;
|
|
335
|
-
validateField(field: Path<TValues>): Promise<ValidationResult>;
|
|
335
|
+
validateField(field: Path<TValues>, opts?: Partial<ValidationOptions$1>): Promise<ValidationResult>;
|
|
336
336
|
stageInitialValue(path: string, value: unknown, updateOriginal?: boolean): void;
|
|
337
337
|
unsetInitialValue(path: string): void;
|
|
338
338
|
handleSubmit: HandleSubmitFactory<TValues, TOutput> & {
|
|
@@ -423,6 +423,11 @@ interface VeeValidateConfig {
|
|
|
423
423
|
}
|
|
424
424
|
declare const configure: (newConf: Partial<VeeValidateConfig>) => void;
|
|
425
425
|
|
|
426
|
+
/**
|
|
427
|
+
* Normalizes the given rules expression.
|
|
428
|
+
*/
|
|
429
|
+
declare function normalizeRules(rules: undefined | string | Record<string, unknown | unknown[] | Record<string, unknown>>): Record<string, unknown[] | Record<string, unknown>>;
|
|
430
|
+
|
|
426
431
|
interface FieldOptions<TValue = unknown> {
|
|
427
432
|
initialValue?: MaybeRef<TValue>;
|
|
428
433
|
validateOnValueUpdate: boolean;
|
|
@@ -604,7 +609,7 @@ declare const Field: {
|
|
|
604
609
|
};
|
|
605
610
|
modelValue: {
|
|
606
611
|
type: any;
|
|
607
|
-
default:
|
|
612
|
+
default: symbol;
|
|
608
613
|
};
|
|
609
614
|
modelModifiers: {
|
|
610
615
|
type: any;
|
|
@@ -713,7 +718,7 @@ declare const Field: {
|
|
|
713
718
|
};
|
|
714
719
|
modelValue: {
|
|
715
720
|
type: any;
|
|
716
|
-
default:
|
|
721
|
+
default: symbol;
|
|
717
722
|
};
|
|
718
723
|
modelModifiers: {
|
|
719
724
|
type: any;
|
|
@@ -790,7 +795,7 @@ declare const Field: {
|
|
|
790
795
|
};
|
|
791
796
|
modelValue: {
|
|
792
797
|
type: any;
|
|
793
|
-
default:
|
|
798
|
+
default: symbol;
|
|
794
799
|
};
|
|
795
800
|
modelModifiers: {
|
|
796
801
|
type: any;
|
|
@@ -1502,6 +1507,6 @@ declare function useSubmitForm<TValues extends Record<string, unknown> = Record<
|
|
|
1502
1507
|
|
|
1503
1508
|
declare const FormContextKey: InjectionKey<PrivateFormContext>;
|
|
1504
1509
|
declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
|
|
1505
|
-
declare const IS_ABSENT:
|
|
1510
|
+
declare const IS_ABSENT: unique symbol;
|
|
1506
1511
|
|
|
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 };
|
|
1512
|
+
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, normalizeRules, 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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.10.
|
|
2
|
+
* vee-validate v4.10.6
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -56,6 +56,24 @@ function merge(target, source) {
|
|
|
56
56
|
});
|
|
57
57
|
return target;
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Constructs a path with dot paths for arrays to use brackets to be compatible with vee-validate path syntax
|
|
61
|
+
*/
|
|
62
|
+
function normalizeFormPath(path) {
|
|
63
|
+
const pathArr = path.split('.');
|
|
64
|
+
if (!pathArr.length) {
|
|
65
|
+
return '';
|
|
66
|
+
}
|
|
67
|
+
let fullPath = String(pathArr[0]);
|
|
68
|
+
for (let i = 1; i < pathArr.length; i++) {
|
|
69
|
+
if (isIndex(pathArr[i])) {
|
|
70
|
+
fullPath += `[${pathArr[i]}]`;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
fullPath += `.${pathArr[i]}`;
|
|
74
|
+
}
|
|
75
|
+
return fullPath;
|
|
76
|
+
}
|
|
59
77
|
|
|
60
78
|
const RULES = {};
|
|
61
79
|
/**
|
|
@@ -258,6 +276,9 @@ function isFile(a) {
|
|
|
258
276
|
}
|
|
259
277
|
return a instanceof File;
|
|
260
278
|
}
|
|
279
|
+
function isPathsEqual(lhs, rhs) {
|
|
280
|
+
return normalizeFormPath(lhs) === normalizeFormPath(rhs);
|
|
281
|
+
}
|
|
261
282
|
|
|
262
283
|
function set(obj, key, val) {
|
|
263
284
|
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
@@ -2121,10 +2142,16 @@ function useForm(opts) {
|
|
|
2121
2142
|
const state = findPathState(field);
|
|
2122
2143
|
if (!state) {
|
|
2123
2144
|
if (typeof field === 'string') {
|
|
2124
|
-
extraErrorsBag.value[field] = normalizeErrorItem(message);
|
|
2145
|
+
extraErrorsBag.value[normalizeFormPath(field)] = normalizeErrorItem(message);
|
|
2125
2146
|
}
|
|
2126
2147
|
return;
|
|
2127
2148
|
}
|
|
2149
|
+
// Move the error from the extras path if exists
|
|
2150
|
+
if (typeof field === 'string') {
|
|
2151
|
+
if (extraErrorsBag.value[normalizeFormPath(field)]) {
|
|
2152
|
+
delete extraErrorsBag.value[normalizeFormPath(field)];
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2128
2155
|
state.errors = normalizeErrorItem(message);
|
|
2129
2156
|
state.valid = !state.errors.length;
|
|
2130
2157
|
}
|
|
@@ -2193,7 +2220,7 @@ function useForm(opts) {
|
|
|
2193
2220
|
function createPathState(path, config) {
|
|
2194
2221
|
var _a, _b;
|
|
2195
2222
|
const initialValue = computed(() => getFromPath(initialValues.value, toValue(path)));
|
|
2196
|
-
const pathStateExists = pathStates.value.find(
|
|
2223
|
+
const pathStateExists = pathStates.value.find(s => isPathsEqual(s.path, toValue(path)));
|
|
2197
2224
|
if (pathStateExists) {
|
|
2198
2225
|
if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
|
|
2199
2226
|
pathStateExists.multiple = true;
|
|
@@ -2236,10 +2263,9 @@ function useForm(opts) {
|
|
|
2236
2263
|
}),
|
|
2237
2264
|
});
|
|
2238
2265
|
pathStates.value.push(state);
|
|
2239
|
-
// if it has errors before, validate it.
|
|
2240
2266
|
if (errors.value[pathValue] && !initialErrors[pathValue]) {
|
|
2241
2267
|
nextTick(() => {
|
|
2242
|
-
validateField(pathValue);
|
|
2268
|
+
validateField(pathValue, { mode: 'silent' });
|
|
2243
2269
|
});
|
|
2244
2270
|
}
|
|
2245
2271
|
// Handles when a path changes
|
|
@@ -2308,7 +2334,7 @@ function useForm(opts) {
|
|
|
2308
2334
|
pathStates.value.forEach(mutation);
|
|
2309
2335
|
}
|
|
2310
2336
|
function findPathState(path) {
|
|
2311
|
-
const pathState = typeof path === 'string' ? pathStates.value.find(
|
|
2337
|
+
const pathState = typeof path === 'string' ? pathStates.value.find(s => isPathsEqual(s.path, path)) : path;
|
|
2312
2338
|
return pathState;
|
|
2313
2339
|
}
|
|
2314
2340
|
function findHoistedPath(path) {
|
|
@@ -2393,11 +2419,14 @@ function useForm(opts) {
|
|
|
2393
2419
|
const handleSubmit = handleSubmitImpl;
|
|
2394
2420
|
handleSubmit.withControlled = makeSubmissionFactory(true);
|
|
2395
2421
|
function removePathState(path, id) {
|
|
2396
|
-
const idx = pathStates.value.findIndex(s => s.path
|
|
2422
|
+
const idx = pathStates.value.findIndex(s => isPathsEqual(s.path, path));
|
|
2397
2423
|
const pathState = pathStates.value[idx];
|
|
2398
2424
|
if (idx === -1 || !pathState) {
|
|
2399
2425
|
return;
|
|
2400
2426
|
}
|
|
2427
|
+
nextTick(() => {
|
|
2428
|
+
validateField(path, { mode: 'silent' });
|
|
2429
|
+
});
|
|
2401
2430
|
if (pathState.multiple && pathState.fieldsCount) {
|
|
2402
2431
|
pathState.fieldsCount--;
|
|
2403
2432
|
}
|
|
@@ -2477,10 +2506,13 @@ function useForm(opts) {
|
|
|
2477
2506
|
/**
|
|
2478
2507
|
* Sets multiple fields values
|
|
2479
2508
|
*/
|
|
2480
|
-
function setValues(fields) {
|
|
2509
|
+
function setValues(fields, shouldValidate = true) {
|
|
2481
2510
|
merge(formValues, fields);
|
|
2482
2511
|
// regenerate the arrays when the form values change
|
|
2483
2512
|
fieldArrays.forEach(f => f && f.reset());
|
|
2513
|
+
if (shouldValidate) {
|
|
2514
|
+
validate();
|
|
2515
|
+
}
|
|
2484
2516
|
}
|
|
2485
2517
|
function createModel(path) {
|
|
2486
2518
|
const pathState = findPathState(unref(path)) || createPathState(path);
|
|
@@ -2534,7 +2566,8 @@ function useForm(opts) {
|
|
|
2534
2566
|
* Resets all fields
|
|
2535
2567
|
*/
|
|
2536
2568
|
function resetForm(resetState) {
|
|
2537
|
-
|
|
2569
|
+
let newValues = (resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value;
|
|
2570
|
+
newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
|
|
2538
2571
|
setInitialValues(newValues);
|
|
2539
2572
|
mutateAllPathState(state => {
|
|
2540
2573
|
var _a;
|
|
@@ -2543,7 +2576,7 @@ function useForm(opts) {
|
|
|
2543
2576
|
setFieldValue(state.path, getFromPath(newValues, state.path), false);
|
|
2544
2577
|
setFieldError(state.path, undefined);
|
|
2545
2578
|
});
|
|
2546
|
-
setValues(newValues);
|
|
2579
|
+
setValues(newValues, false);
|
|
2547
2580
|
setErrors((resetState === null || resetState === void 0 ? void 0 : resetState.errors) || {});
|
|
2548
2581
|
submitCount.value = (resetState === null || resetState === void 0 ? void 0 : resetState.submitCount) || 0;
|
|
2549
2582
|
nextTick(() => {
|
|
@@ -2594,17 +2627,17 @@ function useForm(opts) {
|
|
|
2594
2627
|
errors,
|
|
2595
2628
|
};
|
|
2596
2629
|
}
|
|
2597
|
-
async function validateField(path) {
|
|
2630
|
+
async function validateField(path, opts) {
|
|
2598
2631
|
const state = findPathState(path);
|
|
2599
2632
|
if (state) {
|
|
2600
2633
|
state.validated = true;
|
|
2601
2634
|
}
|
|
2602
2635
|
if (schema) {
|
|
2603
|
-
const { results } = await validateSchema('validated-only');
|
|
2636
|
+
const { results } = await validateSchema((opts === null || opts === void 0 ? void 0 : opts.mode) || 'validated-only');
|
|
2604
2637
|
return results[path] || { errors: [], valid: true };
|
|
2605
2638
|
}
|
|
2606
2639
|
if (state === null || state === void 0 ? void 0 : state.validate) {
|
|
2607
|
-
return state.validate();
|
|
2640
|
+
return state.validate(opts);
|
|
2608
2641
|
}
|
|
2609
2642
|
if (!state) {
|
|
2610
2643
|
warn$1(`field with path ${path} was not found`);
|
|
@@ -2693,11 +2726,8 @@ function useForm(opts) {
|
|
|
2693
2726
|
}
|
|
2694
2727
|
function onUpdateModelValue(value) {
|
|
2695
2728
|
var _a;
|
|
2696
|
-
setFieldValue(pathState.path, value);
|
|
2697
2729
|
const validateOnModelUpdate = (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : getConfig().validateOnModelUpdate;
|
|
2698
|
-
|
|
2699
|
-
validateField(pathState.path);
|
|
2700
|
-
}
|
|
2730
|
+
setFieldValue(pathState.path, value, validateOnModelUpdate);
|
|
2701
2731
|
}
|
|
2702
2732
|
const props = computed(() => {
|
|
2703
2733
|
if (isCallable(config)) {
|
|
@@ -2707,11 +2737,12 @@ function useForm(opts) {
|
|
|
2707
2737
|
}
|
|
2708
2738
|
const model = (config === null || config === void 0 ? void 0 : config.model) || 'modelValue';
|
|
2709
2739
|
const base = {
|
|
2740
|
+
onBlur,
|
|
2710
2741
|
[model]: pathState.value,
|
|
2711
2742
|
[`onUpdate:${model}`]: onUpdateModelValue,
|
|
2712
2743
|
};
|
|
2713
2744
|
if (config === null || config === void 0 ? void 0 : config.mapProps) {
|
|
2714
|
-
return Object.assign(Object.assign({
|
|
2745
|
+
return Object.assign(Object.assign({}, base), config.mapProps(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2715
2746
|
}
|
|
2716
2747
|
return base;
|
|
2717
2748
|
});
|
|
@@ -3544,4 +3575,4 @@ function useSubmitForm(cb) {
|
|
|
3544
3575
|
};
|
|
3545
3576
|
}
|
|
3546
3577
|
|
|
3547
|
-
export { ErrorMessage, Field, FieldArray, FieldContextKey, Form, FormContextKey, IS_ABSENT, 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 };
|
|
3578
|
+
export { ErrorMessage, Field, FieldArray, FieldContextKey, Form, FormContextKey, IS_ABSENT, configure, defineRule, normalizeRules, 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.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.10.
|
|
2
|
+
* vee-validate v4.10.6
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -59,6 +59,24 @@
|
|
|
59
59
|
});
|
|
60
60
|
return target;
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Constructs a path with dot paths for arrays to use brackets to be compatible with vee-validate path syntax
|
|
64
|
+
*/
|
|
65
|
+
function normalizeFormPath(path) {
|
|
66
|
+
const pathArr = path.split('.');
|
|
67
|
+
if (!pathArr.length) {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
let fullPath = String(pathArr[0]);
|
|
71
|
+
for (let i = 1; i < pathArr.length; i++) {
|
|
72
|
+
if (isIndex(pathArr[i])) {
|
|
73
|
+
fullPath += `[${pathArr[i]}]`;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
fullPath += `.${pathArr[i]}`;
|
|
77
|
+
}
|
|
78
|
+
return fullPath;
|
|
79
|
+
}
|
|
62
80
|
|
|
63
81
|
const RULES = {};
|
|
64
82
|
/**
|
|
@@ -261,6 +279,9 @@
|
|
|
261
279
|
}
|
|
262
280
|
return a instanceof File;
|
|
263
281
|
}
|
|
282
|
+
function isPathsEqual(lhs, rhs) {
|
|
283
|
+
return normalizeFormPath(lhs) === normalizeFormPath(rhs);
|
|
284
|
+
}
|
|
264
285
|
|
|
265
286
|
function set(obj, key, val) {
|
|
266
287
|
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
@@ -1701,10 +1722,16 @@
|
|
|
1701
1722
|
const state = findPathState(field);
|
|
1702
1723
|
if (!state) {
|
|
1703
1724
|
if (typeof field === 'string') {
|
|
1704
|
-
extraErrorsBag.value[field] = normalizeErrorItem(message);
|
|
1725
|
+
extraErrorsBag.value[normalizeFormPath(field)] = normalizeErrorItem(message);
|
|
1705
1726
|
}
|
|
1706
1727
|
return;
|
|
1707
1728
|
}
|
|
1729
|
+
// Move the error from the extras path if exists
|
|
1730
|
+
if (typeof field === 'string') {
|
|
1731
|
+
if (extraErrorsBag.value[normalizeFormPath(field)]) {
|
|
1732
|
+
delete extraErrorsBag.value[normalizeFormPath(field)];
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1708
1735
|
state.errors = normalizeErrorItem(message);
|
|
1709
1736
|
state.valid = !state.errors.length;
|
|
1710
1737
|
}
|
|
@@ -1773,7 +1800,7 @@
|
|
|
1773
1800
|
function createPathState(path, config) {
|
|
1774
1801
|
var _a, _b;
|
|
1775
1802
|
const initialValue = vue.computed(() => getFromPath(initialValues.value, vue.toValue(path)));
|
|
1776
|
-
const pathStateExists = pathStates.value.find(
|
|
1803
|
+
const pathStateExists = pathStates.value.find(s => isPathsEqual(s.path, vue.toValue(path)));
|
|
1777
1804
|
if (pathStateExists) {
|
|
1778
1805
|
if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
|
|
1779
1806
|
pathStateExists.multiple = true;
|
|
@@ -1816,10 +1843,9 @@
|
|
|
1816
1843
|
}),
|
|
1817
1844
|
});
|
|
1818
1845
|
pathStates.value.push(state);
|
|
1819
|
-
// if it has errors before, validate it.
|
|
1820
1846
|
if (errors.value[pathValue] && !initialErrors[pathValue]) {
|
|
1821
1847
|
vue.nextTick(() => {
|
|
1822
|
-
validateField(pathValue);
|
|
1848
|
+
validateField(pathValue, { mode: 'silent' });
|
|
1823
1849
|
});
|
|
1824
1850
|
}
|
|
1825
1851
|
// Handles when a path changes
|
|
@@ -1888,7 +1914,7 @@
|
|
|
1888
1914
|
pathStates.value.forEach(mutation);
|
|
1889
1915
|
}
|
|
1890
1916
|
function findPathState(path) {
|
|
1891
|
-
const pathState = typeof path === 'string' ? pathStates.value.find(
|
|
1917
|
+
const pathState = typeof path === 'string' ? pathStates.value.find(s => isPathsEqual(s.path, path)) : path;
|
|
1892
1918
|
return pathState;
|
|
1893
1919
|
}
|
|
1894
1920
|
function findHoistedPath(path) {
|
|
@@ -1973,11 +1999,14 @@
|
|
|
1973
1999
|
const handleSubmit = handleSubmitImpl;
|
|
1974
2000
|
handleSubmit.withControlled = makeSubmissionFactory(true);
|
|
1975
2001
|
function removePathState(path, id) {
|
|
1976
|
-
const idx = pathStates.value.findIndex(s => s.path
|
|
2002
|
+
const idx = pathStates.value.findIndex(s => isPathsEqual(s.path, path));
|
|
1977
2003
|
const pathState = pathStates.value[idx];
|
|
1978
2004
|
if (idx === -1 || !pathState) {
|
|
1979
2005
|
return;
|
|
1980
2006
|
}
|
|
2007
|
+
vue.nextTick(() => {
|
|
2008
|
+
validateField(path, { mode: 'silent' });
|
|
2009
|
+
});
|
|
1981
2010
|
if (pathState.multiple && pathState.fieldsCount) {
|
|
1982
2011
|
pathState.fieldsCount--;
|
|
1983
2012
|
}
|
|
@@ -2057,10 +2086,13 @@
|
|
|
2057
2086
|
/**
|
|
2058
2087
|
* Sets multiple fields values
|
|
2059
2088
|
*/
|
|
2060
|
-
function setValues(fields) {
|
|
2089
|
+
function setValues(fields, shouldValidate = true) {
|
|
2061
2090
|
merge(formValues, fields);
|
|
2062
2091
|
// regenerate the arrays when the form values change
|
|
2063
2092
|
fieldArrays.forEach(f => f && f.reset());
|
|
2093
|
+
if (shouldValidate) {
|
|
2094
|
+
validate();
|
|
2095
|
+
}
|
|
2064
2096
|
}
|
|
2065
2097
|
function createModel(path) {
|
|
2066
2098
|
const pathState = findPathState(vue.unref(path)) || createPathState(path);
|
|
@@ -2114,7 +2146,8 @@
|
|
|
2114
2146
|
* Resets all fields
|
|
2115
2147
|
*/
|
|
2116
2148
|
function resetForm(resetState) {
|
|
2117
|
-
|
|
2149
|
+
let newValues = (resetState === null || resetState === void 0 ? void 0 : resetState.values) ? resetState.values : originalInitialValues.value;
|
|
2150
|
+
newValues = isTypedSchema(schema) && isCallable(schema.cast) ? schema.cast(newValues) : newValues;
|
|
2118
2151
|
setInitialValues(newValues);
|
|
2119
2152
|
mutateAllPathState(state => {
|
|
2120
2153
|
var _a;
|
|
@@ -2123,7 +2156,7 @@
|
|
|
2123
2156
|
setFieldValue(state.path, getFromPath(newValues, state.path), false);
|
|
2124
2157
|
setFieldError(state.path, undefined);
|
|
2125
2158
|
});
|
|
2126
|
-
setValues(newValues);
|
|
2159
|
+
setValues(newValues, false);
|
|
2127
2160
|
setErrors((resetState === null || resetState === void 0 ? void 0 : resetState.errors) || {});
|
|
2128
2161
|
submitCount.value = (resetState === null || resetState === void 0 ? void 0 : resetState.submitCount) || 0;
|
|
2129
2162
|
vue.nextTick(() => {
|
|
@@ -2174,17 +2207,17 @@
|
|
|
2174
2207
|
errors,
|
|
2175
2208
|
};
|
|
2176
2209
|
}
|
|
2177
|
-
async function validateField(path) {
|
|
2210
|
+
async function validateField(path, opts) {
|
|
2178
2211
|
const state = findPathState(path);
|
|
2179
2212
|
if (state) {
|
|
2180
2213
|
state.validated = true;
|
|
2181
2214
|
}
|
|
2182
2215
|
if (schema) {
|
|
2183
|
-
const { results } = await validateSchema('validated-only');
|
|
2216
|
+
const { results } = await validateSchema((opts === null || opts === void 0 ? void 0 : opts.mode) || 'validated-only');
|
|
2184
2217
|
return results[path] || { errors: [], valid: true };
|
|
2185
2218
|
}
|
|
2186
2219
|
if (state === null || state === void 0 ? void 0 : state.validate) {
|
|
2187
|
-
return state.validate();
|
|
2220
|
+
return state.validate(opts);
|
|
2188
2221
|
}
|
|
2189
2222
|
if (!state) {
|
|
2190
2223
|
vue.warn(`field with path ${path} was not found`);
|
|
@@ -2267,11 +2300,8 @@
|
|
|
2267
2300
|
}
|
|
2268
2301
|
function onUpdateModelValue(value) {
|
|
2269
2302
|
var _a;
|
|
2270
|
-
setFieldValue(pathState.path, value);
|
|
2271
2303
|
const validateOnModelUpdate = (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : getConfig().validateOnModelUpdate;
|
|
2272
|
-
|
|
2273
|
-
validateField(pathState.path);
|
|
2274
|
-
}
|
|
2304
|
+
setFieldValue(pathState.path, value, validateOnModelUpdate);
|
|
2275
2305
|
}
|
|
2276
2306
|
const props = vue.computed(() => {
|
|
2277
2307
|
if (isCallable(config)) {
|
|
@@ -2281,11 +2311,12 @@
|
|
|
2281
2311
|
}
|
|
2282
2312
|
const model = (config === null || config === void 0 ? void 0 : config.model) || 'modelValue';
|
|
2283
2313
|
const base = {
|
|
2314
|
+
onBlur,
|
|
2284
2315
|
[model]: pathState.value,
|
|
2285
2316
|
[`onUpdate:${model}`]: onUpdateModelValue,
|
|
2286
2317
|
};
|
|
2287
2318
|
if (config === null || config === void 0 ? void 0 : config.mapProps) {
|
|
2288
|
-
return Object.assign(Object.assign({
|
|
2319
|
+
return Object.assign(Object.assign({}, base), config.mapProps(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2289
2320
|
}
|
|
2290
2321
|
return base;
|
|
2291
2322
|
});
|
|
@@ -3127,6 +3158,7 @@
|
|
|
3127
3158
|
exports.IS_ABSENT = IS_ABSENT;
|
|
3128
3159
|
exports.configure = configure;
|
|
3129
3160
|
exports.defineRule = defineRule;
|
|
3161
|
+
exports.normalizeRules = normalizeRules;
|
|
3130
3162
|
exports.useField = useField;
|
|
3131
3163
|
exports.useFieldArray = useFieldArray;
|
|
3132
3164
|
exports.useFieldError = useFieldError;
|
package/dist/vee-validate.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.10.
|
|
2
|
+
* vee-validate v4.10.6
|
|
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 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 F(e,t){return t in e&&e[t]!==c}function A(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(!A(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(!A(r[1],t.get(r[0])))return!1;return!0}if(j(e)&&j(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();for(r=n=(a=Object.keys(e)).length;0!=r--;){var l=a[r];if(!A(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function j(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 U(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function P(e){t.warn(`[vee-validate]: ${e}`)}function _(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>A(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return A(e,t)?n:t}function T(e,t=0){let n=null,r=[];return function(...a){return n&&clearTimeout(n),n=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=>{A(e,r.value)||(r.value=S(e))}),{deep:!0}),t.watch(r,(t=>{A(t,e())||n(S(t))}),{deep:!0}),r}function $(e){return Array.isArray(e)?e:e?[e]:[]}function D(e){const n=U(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)||P(`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((()=>!A(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:U(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=>A(e,r)))>=0:A(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:F}=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),j=b?U(s):void 0,w=F||j,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:P,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=>{A(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;A(t,n.value)||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[ee.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){Q(W(e),t)}function H(e){var t;const n=e&&"value"in e?e.value:P.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()}t.onMounted((()=>{if(i)return q();w&&w.validateSchema||L()}));const J=t.getCurrentInstance();function Q(e,t=!0){C.value=J&&O?N(e,J.props.modelModifiers):e;(t?q:L)()}const Y=t.computed({get:()=>C.value,set(e){Q(e,y)}}),ee={id:M,name:E,label:h,value:Y,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:Q};if(t.provide(d,ee),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{A(e,t)||(_.validated?q():L())}),{deep:!0}),!w)return ee;const te=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(te,((e,t)=>{if(!Object.keys(e).length)return;!A(e,t)&&(_.validated?q():L())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(ee.keepValueOnUnmount))&&void 0!==e?e:t.unref(w.keepValuesOnUnmount),r=t.toValue(E);if(n||!w||$.pendingUnmount[ee.id])return void(null==w||w.removePathState(r,M));$.pendingUnmount[ee.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(ee.id):(null==a?void 0:a.id)===ee.id){if((null==a?void 0:a.multiple)&&Array.isArray(a.value)){const e=a.value.findIndex((e=>A(e,t.unref(ee.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(ee.id),1)}else w.unsetPathValue(t.toValue(E));w.removePathState(r,M)}})),ee}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)?F(e,"modelValue")?e.modelValue:void 0:F(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:F}=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}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},j=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){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,i)};return u})),w=t.computed((()=>{const t=Object.assign({},j.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({},j.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:A,handleInput:e=>A(e,!1),handleReset:g,handleBlur:j.value.onBlur,setTouched:m,setErrors:F}}return r.expose({setErrors:F,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}),{}))),F=t.computed((()=>f.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),j=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:U,setInitialValues:P}=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((()=>!A(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,U,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((()=>!A(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(U.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:U.value;P(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:F.value,bailsMap:j.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),r=null!==(t=l().validateOnInput)&&void 0!==t?t:Q().validateOnInput;ne(a.path,n,r)}function o(e){var t;const n=W(e),r=null!==(t=l().validateOnChange)&&void 0!==t?t:Q().validateOnChange;ne(a.path,n,r)}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:F,setFieldValue:A,setValues:j,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 U(){return S(o)}function P(){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:F,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:E,resetForm:y,resetField:k,getValues:U,getMeta:P,getErrors:_}}return n.expose({setFieldError:F,setErrors:b,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:U,getMeta:P,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=U(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 P("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 P("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):P("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=>{A(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=U(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=U(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=U(s);return e||P("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=U(s);return e||P("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=U(s);return e||P("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=U(s);return e||P("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=U(s);return e||P("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=U(s);return e||P("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=U(s);return e||P("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=U(s);return e||P("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=U(s);return e||P("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=U(s);t||P("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=U(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)):(P(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=U(s);return e||P("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}));
|
|
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}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)l(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};const d=Symbol("vee-validate-form"),c=Symbol("vee-validate-field-instance"),v=Symbol("Default empty value"),f="undefined"!=typeof window;function p(e){return n(e)&&!!e.__locatorRef}function m(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function h(e){return!!e&&n(e.validate)}function y(e){return"checkbox"===e||"radio"===e}function g(e){return/^\[.+\]$/i.test(e)}function b(e){return"SELECT"===e.tagName}function V(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&&!y(t.type)}function O(e){return F(e)&&e.target&&"submit"in e.target}function F(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function A(e,t){return t in e&&e[t]!==v}function j(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(!j(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(!j(r[1],t.get(r[0])))return!1;return!0}if(w(e)&&w(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();for(r=n=(a=Object.keys(e)).length;0!=r--;){var l=a[r];if(!j(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function w(e){return!!f&&e instanceof File}function S(e,t){return o(e)===o(t)}function E(e,t,n){"object"==typeof n.value&&(n.value=k(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function k(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(k(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(k(t),k(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(k(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++)E(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]||E(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function I(e){return g(e)?e.replace(/\[|\]/gi,""):e}function M(e,t,n){if(!e)return n;if(g(t))return e[I(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 C(e,t,n){if(g(t))return void(e[I(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 B(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function U(e,t){if(g(t))return void delete e[I(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){B(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const i=n.map(((t,r)=>M(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?B(i[t-1],n[t-1]):B(e,n[0]));var u}function P(e){return Object.keys(e)}function T(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function _(e){t.warn(`[vee-validate]: ${e}`)}function R(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>j(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return j(e,t)?n:t}function N(e,t=0){let n=null,r=[];return function(...a){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function $(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 D({get:e,set:n}){const r=t.ref(k(e()));return t.watch(e,(e=>{j(e,r.value)||(r.value=k(e))}),{deep:!0}),t.watch(r,(t=>{j(t,e())||n(k(t))}),{deep:!0}),r}function z(e){return Array.isArray(e)?e:e?[e]:[]}function q(e){const n=T(d),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(c);return a||(null==r?void 0:r.value)||_(`field with name ${t.unref(e)} was not found`),r||a}function L(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const K=(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 W(e){if(G(e))return e._value}function G(e){return"_value"in e}function X(e){if(!F(e))return e;const t=e.target;if(y(t.type)&&G(t))return W(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(b(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(W);var n;if(b(t)){const e=Array.from(t.options).find((e=>e.selected));return e?W(e):t.value}return function(e){return"number"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function H(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]=J(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=Q(t);return n.name?(e[n.name]=J(n.params),e):e}),t):t}function J(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>M(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 Q=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let Y=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Z=()=>Y,ee=e=>{Y=Object.assign(Object.assign({},Y),e)};async function te(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(m(e.rules)||h(e.rules))return async function(e,t){const n=m(t)?t:ne(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:ae(n);l.push(e)}if(e.bails)return{errors:l}}}return{errors:l}}const r=Object.assign(Object.assign({},e),{rules:H(e.rules)}),a=[],l=Object.keys(r.rules),i=l.length;for(let n=0;n<i;n++){const i=l[n],u=await re(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 ne(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 re(e,t,n){const r=(a=n.name,s[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>p(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:ae(i)}}function ae(e){const t=Z().generateMessage;return t?t(e):"Field is invalid"}async function le(e,t,n){const r=P(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 te(M(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 ie=0;function ue(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?M(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 M(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>M(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=z(t)}}}(),d=ie>=Number.MAX_SAFE_INTEGER?0:++ie,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((()=>!j(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 oe(e,n,r){return y(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:T(d),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=>j(e,r)))>=0:j(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=X(s);let h=null!==(v=t.unref(l))&&void 0!==v?v:m;a&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=R(M(a.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=R(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(se(e,n,r))}(e,n,r):se(e,n,r)}function se(e,r,a){const{initialValue:l,validateOnMount:i,bails:u,type:o,checkedValue:s,label:f,validateOnValueUpdate:y,uncheckedValue:g,controlled:b,keepValueOnUnmount:V,syncVModel:O,form:F}=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||{}))?de(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?T(d):void 0,w=F||A,S=function(e){return t.computed((()=>t.toValue(e)))}(e),E=t.computed((()=>{if(t.unref(null==w?void 0:w.schema))return;const e=t.unref(r);return h(e)||m(e)||n(e)||Array.isArray(e)?e:H(e)})),{id:I,value:C,initialValue:B,meta:U,setState:_,errors:R,flags:N}=ue(S,{modelValue:l,form:w,bails:u,label:f,type:o,validate:E.value?K:void 0}),D=t.computed((()=>R.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=>{j(e,de(a,l))||a.emit(i,e)})),t.watch((()=>de(a,l)),(e=>{if(e===v&&void 0===n.value)return;const t=e===v?void 0:e;j(t,n.value)||r(t)}))}({value:C,prop:O,handleChange:W});async function z(e){var n,r;return(null==w?void 0:w.validateSchema)?null!==(n=(await w.validateSchema(e)).results[t.unref(S)])&&void 0!==n?n:{valid:!0,errors:[]}:E.value?te(C.value,E.value,{name:t.unref(S),label:t.unref(f),values:null!==(r=null==w?void 0:w.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const q=$((async()=>(U.pending=!0,U.validated=!0,z("validated-only"))),(e=>{if(!N.pendingUnmount[Z.id])return _({errors:e.errors}),U.pending=!1,U.valid=e.valid,e})),L=$((async()=>z("silent")),(e=>(U.valid=e.valid,e)));function K(e){return"silent"===(null==e?void 0:e.mode)?L():q()}function W(e,t=!0){Q(X(e),t)}function G(e){var t;const n=e&&"value"in e?e.value:B.value;_({value:k(n),initialValue:k(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),U.pending=!1,U.validated=!1,L()}t.onMounted((()=>{if(i)return q();w&&w.validateSchema||L()}));const J=t.getCurrentInstance();function Q(e,t=!0){C.value=J&&O?x(e,J.props.modelModifiers):e;(t?q:L)()}const Y=t.computed({get:()=>C.value,set(e){Q(e,y)}}),Z={id:I,name:S,label:f,value:Y,meta:U,errors:R,errorMessage:D,type:o,checkedValue:s,uncheckedValue:g,bails:u,keepValueOnUnmount:V,resetField:G,handleReset:()=>G(),validate:K,handleChange:W,handleBlur:(e,t=!1)=>{U.touched=!0,t&&q()},setState:_,setTouched:function(e){U.touched=e},setErrors:function(e){_({errors:Array.isArray(e)?e:[e]})},setValue:Q};if(t.provide(c,Z),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{j(e,t)||(U.validated?q():L())}),{deep:!0}),!w)return Z;const ee=t.computed((()=>{const e=E.value;return!e||n(e)||h(e)||m(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(p):P(a).filter((e=>p(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=M(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;!j(e,t)&&(U.validated?q():L())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(Z.keepValueOnUnmount))&&void 0!==e?e:t.unref(w.keepValuesOnUnmount),r=t.toValue(S);if(n||!w||N.pendingUnmount[Z.id])return void(null==w||w.removePathState(r,I));N.pendingUnmount[Z.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(Z.id):(null==a?void 0:a.id)===Z.id){if((null==a?void 0:a.multiple)&&Array.isArray(a.value)){const e=a.value.findIndex((e=>j(e,t.unref(Z.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(Z.id),1)}else w.unsetPathValue(t.toValue(S));w.removePathState(r,I)}})),Z}function de(e,t){if(e)return e.props[t]}function ce(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ve(e,t){return y(t.attrs.type)?A(e,"modelValue")?e.modelValue:void 0:A(e,"modelValue")?e.modelValue:t.attrs.value}const fe=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:()=>Z().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:v},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:h,handleReset:g,meta:b,checked:O,setErrors:F}=oe(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:ve(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o,syncVModel:!0}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},j=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}=Z();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){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,i)};return u})),w=t.computed((()=>{const t=Object.assign({},j.value);y(r.attrs.type)&&O&&(t.checked=O.value);return V(ce(e,r),r.attrs)&&(t.value=d.value),t})),S=t.computed((()=>Object.assign(Object.assign({},j.value),{modelValue:d.value})));function E(){return{field:w.value,componentField:S.value,value:d.value,meta:b,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:A,handleInput:e=>A(e,!1),handleReset:g,handleBlur:j.value.onBlur,setTouched:m,setErrors:F}}return r.expose({setErrors:F,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(ce(e,r)),a=K(n,r,E);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let pe=0;const me=["bails","fieldsCount","id","multiple","type","validate"];function he(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&m(a)&&n(a.cast)?k(a.cast(r)||{}):k(r)}function ye(e){var r;const a=pe++;let l=0;const i=t.ref(!1),s=t.ref(!1),c=t.ref(0),v=[],f=t.reactive(he(e)),p=t.ref([]),y=t.ref({});function g(e,t){const n=J(e);n?("string"==typeof e&&y.value[o(e)]&&delete y.value[o(e)],n.errors=z(t),n.valid=!n.errors.length):"string"==typeof e&&(y.value[o(e)]=z(t))}function b(e){P(e).forEach((t=>{g(t,e[t])}))}(null==e?void 0:e.initialErrors)&&b(e.initialErrors);const V=t.computed((()=>{const e=p.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},y.value),e)})),F=t.computed((()=>P(V.value).reduce(((e,t)=>{const n=V.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),A=t.computed((()=>p.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),w=t.computed((()=>p.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),E=Object.assign({},(null==e?void 0:e.initialErrors)||{}),I=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:B,originalInitialValues:T,setInitialValues:_}=function(e,n,r){const a=he(r),l=null==r?void 0:r.initialValues,i=t.ref(a),o=t.ref(k(a));function s(t,r=!1){i.value=u(k(i.value)||{},k(t)),o.value=u(k(o.value)||{},k(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=M(i.value,e.path);C(n,e.path,k(t))}))}t.isRef(l)&&t.watch(l,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:i,originalInitialValues:o,setInitialValues:s}}(p,f,e),R=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!j(n,t.unref(r))));function u(){const t=e.value;return P(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&&!P(a.value).length,dirty:i.value})))}(p,f,T,F),x=t.computed((()=>p.value.reduce(((e,t)=>{const n=M(f,t.path);return C(e,t.path,n),e}),{}))),D=null==e?void 0:e.validationSchema;function q(e,n){var r,a;const i=t.computed((()=>M(B.value,t.toValue(e)))),u=p.value.find((n=>S(n.path,t.toValue(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((()=>M(f,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=E[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((()=>!j(t.unref(o),t.unref(i))))});return p.value.push(c),F.value[s]&&!E[s]&&t.nextTick((()=>{fe(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{const n=k(o.value);t.nextTick((()=>{C(f,e,n)}))})),c}const K=N(be,5),W=N(be,5),G=$((async e=>"silent"===await e?K():W()),((e,[t])=>{const n=P(re.errorBag.value);return[...new Set([...P(e.results),...p.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const a=r,l=J(a)||function(e){const t=p.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&&y.value[a]&&delete y.value[a],l?(l.valid=u.valid,"silent"===t?n:"validated-only"!==t||l.validated?(g(l,u.errors),n):n):(g(a,i),n)}),{valid:e.valid,results:{},errors:{}})}));function H(e){p.value.forEach(e)}function J(e){return"string"==typeof e?p.value.find((t=>S(t.path,e))):e}let Q,Y=[];function ee(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),H((e=>e.touched=!0)),i.value=!0,c.value++,ve().then((a=>{const l=k(f);if(a.valid&&"function"==typeof t){const n=k(x.value);let i=e?n:l;return a.values&&(i=a.values),t(i,{evt:r,controlledValues:n,setErrors:b,setFieldError:g,setTouched:se,setFieldTouched:oe,setValues:ie,setFieldValue:ae,resetForm:ce,resetField:de})}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 te=ee(!1);te.withControlled=ee(!0);const re={formId:a,values:f,controlledValues:x,errorBag:V,errors:F,schema:D,submitCount:c,meta:R,isSubmitting:i,isValidating:s,fieldArrays:v,keepValuesOnUnmount:I,validateSchema:t.unref(D)?G:void 0,validate:ve,setFieldError:g,validateField:fe,setFieldValue:ae,setValues:ie,setErrors:b,setFieldTouched:oe,setTouched:se,resetForm:ce,resetField:de,handleSubmit:te,stageInitialValue:function(t,n,r=!1){ge(t,n),C(f,t,n),r&&!(null==e?void 0:e.initialValues)&&C(T.value,t,k(n))},unsetInitialValue:ye,setFieldInitialValue:ge,useFieldModel:function(e){if(!Array.isArray(e))return ue(e);return e.map(ue)},createPathState:q,getPathState:J,unsetPathValue:function(e){return Y.push(e),Q||(Q=t.nextTick((()=>{[...Y].sort().reverse().forEach((e=>{U(f,e)})),Y=[],Q=null}))),Q},removePathState:function(e,n){const r=p.value.findIndex((t=>S(t.path,e))),a=p.value[r];if(-1!==r&&a){if(t.nextTick((()=>{fe(e,{mode:"silent"})})),a.multiple&&a.fieldsCount&&a.fieldsCount--,Array.isArray(a.id)){const e=a.id.indexOf(n);e>=0&&a.id.splice(e,1),delete a.__flags.pendingUnmount[n]}(!a.multiple||a.fieldsCount<=0)&&(p.value.splice(r,1),ye(e))}},initialValues:B,getAllPathStates:()=>p.value,markForUnmount:function(e){return H((t=>{t.path.startsWith(e)&&P(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))}};function ae(e,t,n=!0){const r=k(t),a="string"==typeof e?e:e.path;J(a)||q(a),C(f,a,r),n&&fe(a)}function ie(e,t=!0){u(f,e),v.forEach((e=>e&&e.reset())),t&&ve()}function ue(e){const n=J(t.unref(e))||q(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);ae(a,r,!1),n.validated=!0,n.pending=!0,fe(a).then((()=>{n.pending=!1}))}})}function oe(e,t){const n=J(e);n&&(n.touched=t)}function se(e){P(e).forEach((t=>{oe(t,!!e[t])}))}function de(e,t){var n;const r=t&&"value"in t?t.value:M(B.value,e);ge(e,k(r)),ae(e,r,!1),oe(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),g(e,(null==t?void 0:t.errors)||[])}function ce(e){let r=(null==e?void 0:e.values)?e.values:T.value;r=m(D)&&n(D.cast)?D.cast(r):r,_(r),H((t=>{var n;t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ae(t.path,M(r,t.path),!1),g(t.path,void 0)})),ie(r,!1),b((null==e?void 0:e.errors)||{}),c.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{ve({mode:"silent"})}))}async function ve(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&H((e=>e.validated=!0)),re.validateSchema)return re.validateSchema(t);s.value=!0;const n=await Promise.all(p.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:[]}))));s.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 fe(e,n){const r=J(e);if(r&&(r.validated=!0),D){const{results:t}=await G((null==n?void 0:n.mode)||"validated-only");return t[e]||{errors:[],valid:!0}}return(null==r?void 0:r.validate)?r.validate(n):(r||t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function ye(e){U(B.value,e)}function ge(e,t){C(B.value,e,k(t))}async function be(){const e=t.unref(D);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=h(e)||m(e)?await async function(e,t){const n=m(e)?e:ne(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,f):await le(e,f,{names:A.value,bailsMap:w.value});return s.value=!1,n}const Ve=te(((e,{evt:t})=>{O(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&b(e.initialErrors),(null==e?void 0:e.initialTouched)&&se(e.initialTouched),(null==e?void 0:e.validateOnMount)?ve():re.validateSchema&&re.validateSchema("silent")})),t.isRef(D)&&t.watch(D,(()=>{var e;null===(e=re.validateSchema)||void 0===e||e.call(re,"validated-only")})),t.provide(d,re),Object.assign(Object.assign({},re),{values:t.readonly(f),handleReset:()=>ce(),submitForm:Ve,defineComponentBinds:function(e,r){const a=J(t.toValue(e))||q(e),l=()=>n(r)?r(L(a,me)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Z().validateOnBlur)&&fe(a.path)}function u(e){var t;const n=null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:Z().validateOnModelUpdate;ae(a.path,e,n)}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={onBlur:i,[e]:a.value,[`onUpdate:${e}`]:u};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},t),r.mapProps(L(a,me))):t}))},defineInputBinds:function(e,r){const a=J(t.toValue(e))||q(e),l=()=>n(r)?r(L(a,me)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Z().validateOnBlur)&&fe(a.path)}function u(e){var t;const n=X(e),r=null!==(t=l().validateOnInput)&&void 0!==t?t:Z().validateOnInput;ae(a.path,n,r)}function o(e){var t;const n=X(e),r=null!==(t=l().validateOnChange)&&void 0!==t?t:Z().validateOnChange;ae(a.path,n,r)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(L(a,me)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(L(a,me))):e}))}})}const ge=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:V,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetField:E}=ye({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),M=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function C(e){F(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 U(){return k(o)}function P(){return k(s.value)}function T(){return k(i.value)}function _(){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:V,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetForm:y,resetField:E,getValues:U,getMeta:P,getErrors:T}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetForm:y,validate:p,validateField:m,resetField:E,getValues:U,getMeta:P,getErrors:T}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=K(r,n,_);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)}}}),be=ge;function Ve(e){const n=T(d,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 _("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 _("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 s(){return M(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=s();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:D({get(){const r=M(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):_("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=M(null==n?void 0:n.values,l);!Array.isArray(i)||i.length-1<r||(C(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=M(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),C(n.values,l,u),a.value.splice(r,1),p()},push:function(l){const i=t.unref(e),u=M(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),C(n.values,i,s),a.value.push(f(l)),p()},swap:function(r,l){const i=t.unref(e),u=M(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,C(n.values,i,o),a.value=s,v()},insert:function(r,l){const i=t.unref(e),u=M(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)),C(n.values,i,o),a.value=s,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),C(n.values,a,r),c(),p()},prepend:function(l){const i=t.unref(e),u=M(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),C(n.values,i,s),a.value.unshift(f(l)),p()},move:function(l,i){const u=t.unref(e),o=M(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),C(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(s,(e=>{j(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}=Ve(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}),()=>K(void 0,n,v)}}),Fe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(d,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=K(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=Fe,e.Field=fe,e.FieldArray=Oe,e.FieldContextKey=c,e.Form=be,e.FormContextKey=d,e.IS_ABSENT=v,e.configure=ee,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),s[e]=t},e.normalizeRules=H,e.useField=oe,e.useFieldArray=Ve,e.useFieldError=function(e){const n=T(d),r=e?void 0:t.inject(c);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=T(d),r=e?void 0:t.inject(c);return t.computed((()=>e?M(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=ye,e.useFormErrors=function(){const e=T(d);return e||_("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=T(d);return e||_("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=q(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=q(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=q(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=T(d);return e||_("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=T(d);return e||_("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=T(d);return e||_("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=T(d);return e||_("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=T(d);return e||_("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=T(d);return e||_("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=T(d);return e||_("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=T(d);t||_("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=T(d),r=e?void 0:t.inject(c);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(_(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=T(d);return e||_("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=te,e.validateObject=le}));
|