vee-validate 4.11.7 → 4.12.0-alpha.0
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 +14 -40
- package/dist/vee-validate.esm.js +30 -74
- package/dist/vee-validate.js +30 -74
- package/dist/vee-validate.min.js +2 -2
- package/package.json +1 -1
package/dist/vee-validate.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { MaybeRefOrGetter, Ref, MaybeRef, ComputedRef, VNode, PropType, UnwrapRef, InjectionKey } from 'vue';
|
|
3
3
|
import { PartialDeep } from 'type-fest';
|
|
4
4
|
|
|
5
5
|
type BrowserNativeObject = Date | FileList | File;
|
|
@@ -130,9 +130,6 @@ type Path<T> = T extends any ? PathInternal<T> : never;
|
|
|
130
130
|
type GenericObject = Record<string, any>;
|
|
131
131
|
type MaybeArray<T> = T | T[];
|
|
132
132
|
type MaybePromise<T> = T | Promise<T>;
|
|
133
|
-
type MapValuesPathsToRefs<TValues extends GenericObject, TPaths extends readonly [...MaybeRef<Path<TValues>>[]]> = {
|
|
134
|
-
readonly [K in keyof TPaths]: TPaths[K] extends MaybeRef<infer TKey> ? TKey extends Path<TValues> ? Ref<PathValue<TValues, TKey>> : Ref<unknown> : Ref<unknown>;
|
|
135
|
-
};
|
|
136
133
|
type FlattenAndSetPathsType<TRecord, TType> = {
|
|
137
134
|
[K in Path<TRecord>]: TType;
|
|
138
135
|
};
|
|
@@ -350,8 +347,6 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
|
|
|
350
347
|
withControlled: HandleSubmitFactory<TValues, TOutput>;
|
|
351
348
|
};
|
|
352
349
|
setFieldInitialValue(path: string, value: unknown): void;
|
|
353
|
-
useFieldModel<TPath extends Path<TValues>>(path: TPath): Ref<PathValue<TValues, TPath>>;
|
|
354
|
-
useFieldModel<TPaths extends readonly [...MaybeRef<Path<TValues>>[]]>(paths: TPaths): MapValuesPathsToRefs<TValues, TPaths>;
|
|
355
350
|
createPathState<TPath extends Path<TValues>>(path: MaybeRef<TPath>, config?: Partial<PathStateConfig>): PathState<PathValue<TValues, TPath>>;
|
|
356
351
|
getPathState<TPath extends Path<TValues>>(path: TPath): PathState<PathValue<TValues, TPath>> | undefined;
|
|
357
352
|
getAllPathStates(): PathState[];
|
|
@@ -362,52 +357,31 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
|
|
|
362
357
|
isFieldDirty<TPath extends Path<TValues>>(path: TPath): boolean;
|
|
363
358
|
isFieldValid<TPath extends Path<TValues>>(path: TPath): boolean;
|
|
364
359
|
}
|
|
365
|
-
interface ComponentModellessBinds {
|
|
366
|
-
onBlur: () => void;
|
|
367
|
-
}
|
|
368
|
-
type ComponentModelBinds<TValue = any, TModel extends string = 'modelValue'> = ComponentModellessBinds & {
|
|
369
|
-
[TKey in `onUpdate:${TModel}`]: (value: TValue) => void;
|
|
370
|
-
};
|
|
371
|
-
type BaseComponentBinds<TValue = any, TModel extends string = 'modelValue'> = ComponentModelBinds<TValue, TModel> & {
|
|
372
|
-
[k in TModel]: TValue;
|
|
373
|
-
};
|
|
374
360
|
type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type' | '__flags'>;
|
|
375
|
-
interface
|
|
376
|
-
mapProps: (state: PublicPathState<TValue>) => TExtraProps;
|
|
377
|
-
validateOnBlur: boolean;
|
|
378
|
-
validateOnModelUpdate: boolean;
|
|
379
|
-
model: TModel;
|
|
380
|
-
}
|
|
381
|
-
type LazyComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject, TModel extends string = 'modelValue'> = (state: PublicPathState<TValue>) => Partial<{
|
|
382
|
-
props: TExtraProps;
|
|
383
|
-
validateOnBlur: boolean;
|
|
384
|
-
validateOnModelUpdate: boolean;
|
|
385
|
-
model: TModel;
|
|
386
|
-
}>;
|
|
387
|
-
interface BaseInputBinds<TValue = unknown> {
|
|
388
|
-
value: TValue | undefined;
|
|
361
|
+
interface BaseFieldProps {
|
|
389
362
|
onBlur: (e: Event) => void;
|
|
390
363
|
onChange: (e: Event) => void;
|
|
391
364
|
onInput: (e: Event) => void;
|
|
392
365
|
}
|
|
393
366
|
interface InputBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> {
|
|
394
|
-
|
|
367
|
+
props: (state: PublicPathState<TValue>) => TExtraProps;
|
|
395
368
|
validateOnBlur: boolean;
|
|
396
369
|
validateOnChange: boolean;
|
|
397
370
|
validateOnInput: boolean;
|
|
371
|
+
validateOnModelUpdate: boolean;
|
|
398
372
|
}
|
|
399
373
|
type LazyInputBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> = (state: PublicPathState<TValue>) => Partial<{
|
|
400
|
-
|
|
374
|
+
props: TExtraProps;
|
|
401
375
|
validateOnBlur: boolean;
|
|
402
376
|
validateOnChange: boolean;
|
|
403
377
|
validateOnInput: boolean;
|
|
378
|
+
validateOnModelUpdate: boolean;
|
|
404
379
|
}>;
|
|
405
380
|
interface FormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount' | 'values'> {
|
|
406
381
|
values: TValues;
|
|
407
382
|
handleReset: () => void;
|
|
408
383
|
submitForm: (e?: unknown) => Promise<void>;
|
|
409
|
-
|
|
410
|
-
defineInputBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>): Ref<BaseInputBinds<TValue> & TExtras>;
|
|
384
|
+
defineField<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>): [Ref<TValue>, Ref<BaseFieldProps & TExtras>];
|
|
411
385
|
}
|
|
412
386
|
|
|
413
387
|
interface DevtoolsPluginFieldState {
|
|
@@ -528,11 +502,11 @@ declare const Field: {
|
|
|
528
502
|
as?: string | Record<string, any>;
|
|
529
503
|
bails?: boolean;
|
|
530
504
|
uncheckedValue?: any;
|
|
531
|
-
modelValue?: any;
|
|
532
505
|
validateOnInput?: boolean;
|
|
533
506
|
validateOnChange?: boolean;
|
|
534
507
|
validateOnBlur?: boolean;
|
|
535
508
|
validateOnModelUpdate?: boolean;
|
|
509
|
+
modelValue?: any;
|
|
536
510
|
validateOnMount?: boolean;
|
|
537
511
|
standalone?: boolean;
|
|
538
512
|
modelModifiers?: any;
|
|
@@ -676,11 +650,11 @@ declare const Field: {
|
|
|
676
650
|
as: string | Record<string, any>;
|
|
677
651
|
bails: boolean;
|
|
678
652
|
uncheckedValue: any;
|
|
679
|
-
modelValue: any;
|
|
680
653
|
validateOnInput: boolean;
|
|
681
654
|
validateOnChange: boolean;
|
|
682
655
|
validateOnBlur: boolean;
|
|
683
656
|
validateOnModelUpdate: boolean;
|
|
657
|
+
modelValue: any;
|
|
684
658
|
validateOnMount: boolean;
|
|
685
659
|
standalone: boolean;
|
|
686
660
|
modelModifiers: any;
|
|
@@ -862,11 +836,11 @@ declare const Field: {
|
|
|
862
836
|
as: string | Record<string, any>;
|
|
863
837
|
bails: boolean;
|
|
864
838
|
uncheckedValue: any;
|
|
865
|
-
modelValue: any;
|
|
866
839
|
validateOnInput: boolean;
|
|
867
840
|
validateOnChange: boolean;
|
|
868
841
|
validateOnBlur: boolean;
|
|
869
842
|
validateOnModelUpdate: boolean;
|
|
843
|
+
modelValue: any;
|
|
870
844
|
validateOnMount: boolean;
|
|
871
845
|
standalone: boolean;
|
|
872
846
|
modelModifiers: any;
|
|
@@ -965,7 +939,7 @@ declare const Form: {
|
|
|
965
939
|
$el: any;
|
|
966
940
|
$options: vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
|
|
967
941
|
as: {
|
|
968
|
-
type:
|
|
942
|
+
type: PropType<string>;
|
|
969
943
|
default: string;
|
|
970
944
|
};
|
|
971
945
|
validationSchema: {
|
|
@@ -1040,7 +1014,7 @@ declare const Form: {
|
|
|
1040
1014
|
$watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => any : (...args: any) => any, options?: vue.WatchOptions<boolean>): vue.WatchStopHandle;
|
|
1041
1015
|
} & Readonly<vue.ExtractPropTypes<{
|
|
1042
1016
|
as: {
|
|
1043
|
-
type:
|
|
1017
|
+
type: PropType<string>;
|
|
1044
1018
|
default: string;
|
|
1045
1019
|
};
|
|
1046
1020
|
validationSchema: {
|
|
@@ -1089,7 +1063,7 @@ declare const Form: {
|
|
|
1089
1063
|
__isSuspense?: never;
|
|
1090
1064
|
} & vue.ComponentOptionsBase<Readonly<vue.ExtractPropTypes<{
|
|
1091
1065
|
as: {
|
|
1092
|
-
type:
|
|
1066
|
+
type: PropType<string>;
|
|
1093
1067
|
default: string;
|
|
1094
1068
|
};
|
|
1095
1069
|
validationSchema: {
|
|
@@ -1575,4 +1549,4 @@ declare const FormContextKey: InjectionKey<PrivateFormContext>;
|
|
|
1575
1549
|
declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
|
|
1576
1550
|
declare const IS_ABSENT: unique symbol;
|
|
1577
1551
|
|
|
1578
|
-
export { type
|
|
1552
|
+
export { type BaseFieldProps, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldContext, FieldContextKey, type FieldEntry, type FieldMeta, type FieldOptions, type FieldPathLookup, type FieldState, type FieldValidator, type FlattenAndSetPathsType, Form, type FormActions, type FormContext, FormContextKey, type FormErrorBag, type FormErrors, type FormMeta, type FormOptions, type FormState, type FormValidationResult, type GenericObject, type GenericValidateFunction, IS_ABSENT, type InferInput, type InferOutput, type InputBindsConfig, type InputType, type InvalidSubmissionContext, type InvalidSubmissionHandler, type IsAny, type IsEqual, type LazyInputBindsConfig, type Locator, type MaybeArray, type MaybePromise, type Path, type PathState, type PathStateConfig, type PathValue, type PrivateFieldArrayContext, type PrivateFieldContext, type PrivateFormContext, type PublicPathState, type RawFormSchema, type ResetFormOpts, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type TypedSchema, type TypedSchemaError, type ValidationOptions$1 as ValidationOptions, type ValidationResult, type YupSchema, configure, defineRule, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
|
package/dist/vee-validate.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.
|
|
2
|
+
* vee-validate v4.12.0-alpha.0
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -573,8 +573,7 @@ function debounceNextTick(inner) {
|
|
|
573
573
|
};
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
-
|
|
577
|
-
const normalizeChildren = (tag, context, slotProps) => {
|
|
576
|
+
function normalizeChildren(tag, context, slotProps) {
|
|
578
577
|
if (!context.slots.default) {
|
|
579
578
|
return context.slots.default;
|
|
580
579
|
}
|
|
@@ -584,7 +583,7 @@ const normalizeChildren = (tag, context, slotProps) => {
|
|
|
584
583
|
return {
|
|
585
584
|
default: () => { var _a, _b; return (_b = (_a = context.slots).default) === null || _b === void 0 ? void 0 : _b.call(_a, slotProps()); },
|
|
586
585
|
};
|
|
587
|
-
}
|
|
586
|
+
}
|
|
588
587
|
/**
|
|
589
588
|
* Vue adds a `_value` prop at the moment on the input elements to store the REAL value on them, real values are different than the `value` attribute
|
|
590
589
|
* as they do not get casted to strings unlike `el.value` which preserves user-code behavior
|
|
@@ -2025,7 +2024,6 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
|
|
|
2025
2024
|
// If there is a v-model applied on the component we need to emit the `update:modelValue` whenever the value binding changes
|
|
2026
2025
|
const onChangeHandler = function handleChangeWithModel(e, shouldValidate = true) {
|
|
2027
2026
|
handleChange(e, shouldValidate);
|
|
2028
|
-
ctx.emit('update:modelValue', value.value);
|
|
2029
2027
|
};
|
|
2030
2028
|
const sharedProps = computed(() => {
|
|
2031
2029
|
const { validateOnInput, validateOnChange, validateOnBlur, validateOnModelUpdate } = resolveValidationTriggers(props);
|
|
@@ -2519,7 +2517,6 @@ function useForm(opts) {
|
|
|
2519
2517
|
stageInitialValue,
|
|
2520
2518
|
unsetInitialValue,
|
|
2521
2519
|
setFieldInitialValue,
|
|
2522
|
-
useFieldModel,
|
|
2523
2520
|
createPathState,
|
|
2524
2521
|
getPathState: findPathState,
|
|
2525
2522
|
unsetPathValue,
|
|
@@ -2570,29 +2567,19 @@ function useForm(opts) {
|
|
|
2570
2567
|
validate();
|
|
2571
2568
|
}
|
|
2572
2569
|
}
|
|
2573
|
-
function createModel(path) {
|
|
2574
|
-
const pathState = findPathState(
|
|
2570
|
+
function createModel(path, shouldValidate) {
|
|
2571
|
+
const pathState = findPathState(toValue(path)) || createPathState(path);
|
|
2575
2572
|
return computed({
|
|
2576
2573
|
get() {
|
|
2577
2574
|
return pathState.value;
|
|
2578
2575
|
},
|
|
2579
2576
|
set(value) {
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
pathState.pending = true;
|
|
2584
|
-
validateField(pathValue).then(() => {
|
|
2585
|
-
pathState.pending = false;
|
|
2586
|
-
});
|
|
2577
|
+
var _a;
|
|
2578
|
+
const pathValue = toValue(path);
|
|
2579
|
+
setFieldValue(pathValue, value, (_a = toValue(shouldValidate)) !== null && _a !== void 0 ? _a : false);
|
|
2587
2580
|
},
|
|
2588
2581
|
});
|
|
2589
2582
|
}
|
|
2590
|
-
function useFieldModel(pathOrPaths) {
|
|
2591
|
-
if (!Array.isArray(pathOrPaths)) {
|
|
2592
|
-
return createModel(pathOrPaths);
|
|
2593
|
-
}
|
|
2594
|
-
return pathOrPaths.map(createModel);
|
|
2595
|
-
}
|
|
2596
2583
|
/**
|
|
2597
2584
|
* Sets the touched meta state on a field
|
|
2598
2585
|
*/
|
|
@@ -2804,42 +2791,7 @@ function useForm(opts) {
|
|
|
2804
2791
|
deep: true,
|
|
2805
2792
|
});
|
|
2806
2793
|
}
|
|
2807
|
-
function
|
|
2808
|
-
const pathState = findPathState(toValue(path)) || createPathState(path);
|
|
2809
|
-
const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
|
|
2810
|
-
function onBlur() {
|
|
2811
|
-
var _a;
|
|
2812
|
-
pathState.touched = true;
|
|
2813
|
-
const validateOnBlur = (_a = evalConfig().validateOnBlur) !== null && _a !== void 0 ? _a : getConfig().validateOnBlur;
|
|
2814
|
-
if (validateOnBlur) {
|
|
2815
|
-
validateField(pathState.path);
|
|
2816
|
-
}
|
|
2817
|
-
}
|
|
2818
|
-
function onUpdateModelValue(value) {
|
|
2819
|
-
var _a;
|
|
2820
|
-
const validateOnModelUpdate = (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : getConfig().validateOnModelUpdate;
|
|
2821
|
-
setFieldValue(pathState.path, value, validateOnModelUpdate);
|
|
2822
|
-
}
|
|
2823
|
-
const props = computed(() => {
|
|
2824
|
-
if (isCallable(config)) {
|
|
2825
|
-
const configVal = config(pathState);
|
|
2826
|
-
const model = configVal.model || 'modelValue';
|
|
2827
|
-
return Object.assign({ onBlur, [model]: pathState.value, [`onUpdate:${model}`]: onUpdateModelValue }, (configVal.props || {}));
|
|
2828
|
-
}
|
|
2829
|
-
const model = (config === null || config === void 0 ? void 0 : config.model) || 'modelValue';
|
|
2830
|
-
const base = {
|
|
2831
|
-
onBlur,
|
|
2832
|
-
[model]: pathState.value,
|
|
2833
|
-
[`onUpdate:${model}`]: onUpdateModelValue,
|
|
2834
|
-
};
|
|
2835
|
-
if (config === null || config === void 0 ? void 0 : config.mapProps) {
|
|
2836
|
-
return Object.assign(Object.assign({}, base), config.mapProps(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2837
|
-
}
|
|
2838
|
-
return base;
|
|
2839
|
-
});
|
|
2840
|
-
return props;
|
|
2841
|
-
}
|
|
2842
|
-
function defineInputBinds(path, config) {
|
|
2794
|
+
function defineField(path, config) {
|
|
2843
2795
|
const pathState = (findPathState(toValue(path)) || createPathState(path));
|
|
2844
2796
|
const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
|
|
2845
2797
|
function onBlur() {
|
|
@@ -2850,38 +2802,42 @@ function useForm(opts) {
|
|
|
2850
2802
|
validateField(pathState.path);
|
|
2851
2803
|
}
|
|
2852
2804
|
}
|
|
2853
|
-
function onInput(
|
|
2805
|
+
function onInput() {
|
|
2854
2806
|
var _a;
|
|
2855
|
-
const value = normalizeEventValue(e);
|
|
2856
2807
|
const validateOnInput = (_a = evalConfig().validateOnInput) !== null && _a !== void 0 ? _a : getConfig().validateOnInput;
|
|
2857
|
-
|
|
2808
|
+
if (validateOnInput) {
|
|
2809
|
+
nextTick(() => {
|
|
2810
|
+
validateField(pathState.path);
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2858
2813
|
}
|
|
2859
|
-
function onChange(
|
|
2814
|
+
function onChange() {
|
|
2860
2815
|
var _a;
|
|
2861
|
-
const value = normalizeEventValue(e);
|
|
2862
2816
|
const validateOnChange = (_a = evalConfig().validateOnChange) !== null && _a !== void 0 ? _a : getConfig().validateOnChange;
|
|
2863
|
-
|
|
2817
|
+
if (validateOnChange) {
|
|
2818
|
+
nextTick(() => {
|
|
2819
|
+
validateField(pathState.path);
|
|
2820
|
+
});
|
|
2821
|
+
}
|
|
2864
2822
|
}
|
|
2865
2823
|
const props = computed(() => {
|
|
2866
2824
|
const base = {
|
|
2867
|
-
value: pathState.value,
|
|
2868
2825
|
onChange,
|
|
2869
2826
|
onInput,
|
|
2870
2827
|
onBlur,
|
|
2871
2828
|
};
|
|
2872
2829
|
if (isCallable(config)) {
|
|
2873
|
-
return Object.assign(Object.assign({}, base), (config(omit(pathState, PRIVATE_PATH_STATE_KEYS)).
|
|
2830
|
+
return Object.assign(Object.assign({}, base), (config(omit(pathState, PRIVATE_PATH_STATE_KEYS)).props || {}));
|
|
2874
2831
|
}
|
|
2875
|
-
if (config === null || config === void 0 ? void 0 : config.
|
|
2876
|
-
return Object.assign(Object.assign({}, base), config.
|
|
2832
|
+
if (config === null || config === void 0 ? void 0 : config.props) {
|
|
2833
|
+
return Object.assign(Object.assign({}, base), config.props(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2877
2834
|
}
|
|
2878
2835
|
return base;
|
|
2879
2836
|
});
|
|
2880
|
-
return props;
|
|
2837
|
+
return [createModel(path, () => { var _a; return (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : false; }), props];
|
|
2881
2838
|
}
|
|
2882
2839
|
return Object.assign(Object.assign({}, formCtx), { values: readonly(formValues), handleReset: () => resetForm(), submitForm,
|
|
2883
|
-
|
|
2884
|
-
defineInputBinds });
|
|
2840
|
+
defineField });
|
|
2885
2841
|
}
|
|
2886
2842
|
/**
|
|
2887
2843
|
* Manages form meta aggregation
|
|
@@ -2968,7 +2924,7 @@ const FormImpl = /** #__PURE__ */ defineComponent({
|
|
|
2968
2924
|
inheritAttrs: false,
|
|
2969
2925
|
props: {
|
|
2970
2926
|
as: {
|
|
2971
|
-
type:
|
|
2927
|
+
type: null,
|
|
2972
2928
|
default: 'form',
|
|
2973
2929
|
},
|
|
2974
2930
|
validationSchema: {
|
|
@@ -3091,13 +3047,13 @@ const FormImpl = /** #__PURE__ */ defineComponent({
|
|
|
3091
3047
|
});
|
|
3092
3048
|
return function renderForm() {
|
|
3093
3049
|
// avoid resolving the form component as itself
|
|
3094
|
-
const tag = props.as === 'form' ? props.as : resolveDynamicComponent(props.as);
|
|
3050
|
+
const tag = props.as === 'form' ? props.as : !props.as ? null : resolveDynamicComponent(props.as);
|
|
3095
3051
|
const children = normalizeChildren(tag, ctx, slotProps);
|
|
3096
|
-
if (!
|
|
3052
|
+
if (!tag) {
|
|
3097
3053
|
return children;
|
|
3098
3054
|
}
|
|
3099
3055
|
// Attributes to add on a native `form` tag
|
|
3100
|
-
const formAttrs =
|
|
3056
|
+
const formAttrs = tag === 'form'
|
|
3101
3057
|
? {
|
|
3102
3058
|
// Disables native validation as vee-validate will handle it.
|
|
3103
3059
|
novalidate: true,
|
package/dist/vee-validate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.
|
|
2
|
+
* vee-validate v4.12.0-alpha.0
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -551,8 +551,7 @@
|
|
|
551
551
|
};
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
-
|
|
555
|
-
const normalizeChildren = (tag, context, slotProps) => {
|
|
554
|
+
function normalizeChildren(tag, context, slotProps) {
|
|
556
555
|
if (!context.slots.default) {
|
|
557
556
|
return context.slots.default;
|
|
558
557
|
}
|
|
@@ -562,7 +561,7 @@
|
|
|
562
561
|
return {
|
|
563
562
|
default: () => { var _a, _b; return (_b = (_a = context.slots).default) === null || _b === void 0 ? void 0 : _b.call(_a, slotProps()); },
|
|
564
563
|
};
|
|
565
|
-
}
|
|
564
|
+
}
|
|
566
565
|
/**
|
|
567
566
|
* Vue adds a `_value` prop at the moment on the input elements to store the REAL value on them, real values are different than the `value` attribute
|
|
568
567
|
* as they do not get casted to strings unlike `el.value` which preserves user-code behavior
|
|
@@ -1598,7 +1597,6 @@
|
|
|
1598
1597
|
// If there is a v-model applied on the component we need to emit the `update:modelValue` whenever the value binding changes
|
|
1599
1598
|
const onChangeHandler = function handleChangeWithModel(e, shouldValidate = true) {
|
|
1600
1599
|
handleChange(e, shouldValidate);
|
|
1601
|
-
ctx.emit('update:modelValue', value.value);
|
|
1602
1600
|
};
|
|
1603
1601
|
const sharedProps = vue.computed(() => {
|
|
1604
1602
|
const { validateOnInput, validateOnChange, validateOnBlur, validateOnModelUpdate } = resolveValidationTriggers(props);
|
|
@@ -2092,7 +2090,6 @@
|
|
|
2092
2090
|
stageInitialValue,
|
|
2093
2091
|
unsetInitialValue,
|
|
2094
2092
|
setFieldInitialValue,
|
|
2095
|
-
useFieldModel,
|
|
2096
2093
|
createPathState,
|
|
2097
2094
|
getPathState: findPathState,
|
|
2098
2095
|
unsetPathValue,
|
|
@@ -2143,29 +2140,19 @@
|
|
|
2143
2140
|
validate();
|
|
2144
2141
|
}
|
|
2145
2142
|
}
|
|
2146
|
-
function createModel(path) {
|
|
2147
|
-
const pathState = findPathState(vue.
|
|
2143
|
+
function createModel(path, shouldValidate) {
|
|
2144
|
+
const pathState = findPathState(vue.toValue(path)) || createPathState(path);
|
|
2148
2145
|
return vue.computed({
|
|
2149
2146
|
get() {
|
|
2150
2147
|
return pathState.value;
|
|
2151
2148
|
},
|
|
2152
2149
|
set(value) {
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
pathState.pending = true;
|
|
2157
|
-
validateField(pathValue).then(() => {
|
|
2158
|
-
pathState.pending = false;
|
|
2159
|
-
});
|
|
2150
|
+
var _a;
|
|
2151
|
+
const pathValue = vue.toValue(path);
|
|
2152
|
+
setFieldValue(pathValue, value, (_a = vue.toValue(shouldValidate)) !== null && _a !== void 0 ? _a : false);
|
|
2160
2153
|
},
|
|
2161
2154
|
});
|
|
2162
2155
|
}
|
|
2163
|
-
function useFieldModel(pathOrPaths) {
|
|
2164
|
-
if (!Array.isArray(pathOrPaths)) {
|
|
2165
|
-
return createModel(pathOrPaths);
|
|
2166
|
-
}
|
|
2167
|
-
return pathOrPaths.map(createModel);
|
|
2168
|
-
}
|
|
2169
2156
|
/**
|
|
2170
2157
|
* Sets the touched meta state on a field
|
|
2171
2158
|
*/
|
|
@@ -2366,42 +2353,7 @@
|
|
|
2366
2353
|
}
|
|
2367
2354
|
// Provide injections
|
|
2368
2355
|
vue.provide(FormContextKey, formCtx);
|
|
2369
|
-
function
|
|
2370
|
-
const pathState = findPathState(vue.toValue(path)) || createPathState(path);
|
|
2371
|
-
const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
|
|
2372
|
-
function onBlur() {
|
|
2373
|
-
var _a;
|
|
2374
|
-
pathState.touched = true;
|
|
2375
|
-
const validateOnBlur = (_a = evalConfig().validateOnBlur) !== null && _a !== void 0 ? _a : getConfig().validateOnBlur;
|
|
2376
|
-
if (validateOnBlur) {
|
|
2377
|
-
validateField(pathState.path);
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
function onUpdateModelValue(value) {
|
|
2381
|
-
var _a;
|
|
2382
|
-
const validateOnModelUpdate = (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : getConfig().validateOnModelUpdate;
|
|
2383
|
-
setFieldValue(pathState.path, value, validateOnModelUpdate);
|
|
2384
|
-
}
|
|
2385
|
-
const props = vue.computed(() => {
|
|
2386
|
-
if (isCallable(config)) {
|
|
2387
|
-
const configVal = config(pathState);
|
|
2388
|
-
const model = configVal.model || 'modelValue';
|
|
2389
|
-
return Object.assign({ onBlur, [model]: pathState.value, [`onUpdate:${model}`]: onUpdateModelValue }, (configVal.props || {}));
|
|
2390
|
-
}
|
|
2391
|
-
const model = (config === null || config === void 0 ? void 0 : config.model) || 'modelValue';
|
|
2392
|
-
const base = {
|
|
2393
|
-
onBlur,
|
|
2394
|
-
[model]: pathState.value,
|
|
2395
|
-
[`onUpdate:${model}`]: onUpdateModelValue,
|
|
2396
|
-
};
|
|
2397
|
-
if (config === null || config === void 0 ? void 0 : config.mapProps) {
|
|
2398
|
-
return Object.assign(Object.assign({}, base), config.mapProps(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2399
|
-
}
|
|
2400
|
-
return base;
|
|
2401
|
-
});
|
|
2402
|
-
return props;
|
|
2403
|
-
}
|
|
2404
|
-
function defineInputBinds(path, config) {
|
|
2356
|
+
function defineField(path, config) {
|
|
2405
2357
|
const pathState = (findPathState(vue.toValue(path)) || createPathState(path));
|
|
2406
2358
|
const evalConfig = () => (isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {});
|
|
2407
2359
|
function onBlur() {
|
|
@@ -2412,38 +2364,42 @@
|
|
|
2412
2364
|
validateField(pathState.path);
|
|
2413
2365
|
}
|
|
2414
2366
|
}
|
|
2415
|
-
function onInput(
|
|
2367
|
+
function onInput() {
|
|
2416
2368
|
var _a;
|
|
2417
|
-
const value = normalizeEventValue(e);
|
|
2418
2369
|
const validateOnInput = (_a = evalConfig().validateOnInput) !== null && _a !== void 0 ? _a : getConfig().validateOnInput;
|
|
2419
|
-
|
|
2370
|
+
if (validateOnInput) {
|
|
2371
|
+
vue.nextTick(() => {
|
|
2372
|
+
validateField(pathState.path);
|
|
2373
|
+
});
|
|
2374
|
+
}
|
|
2420
2375
|
}
|
|
2421
|
-
function onChange(
|
|
2376
|
+
function onChange() {
|
|
2422
2377
|
var _a;
|
|
2423
|
-
const value = normalizeEventValue(e);
|
|
2424
2378
|
const validateOnChange = (_a = evalConfig().validateOnChange) !== null && _a !== void 0 ? _a : getConfig().validateOnChange;
|
|
2425
|
-
|
|
2379
|
+
if (validateOnChange) {
|
|
2380
|
+
vue.nextTick(() => {
|
|
2381
|
+
validateField(pathState.path);
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2426
2384
|
}
|
|
2427
2385
|
const props = vue.computed(() => {
|
|
2428
2386
|
const base = {
|
|
2429
|
-
value: pathState.value,
|
|
2430
2387
|
onChange,
|
|
2431
2388
|
onInput,
|
|
2432
2389
|
onBlur,
|
|
2433
2390
|
};
|
|
2434
2391
|
if (isCallable(config)) {
|
|
2435
|
-
return Object.assign(Object.assign({}, base), (config(omit(pathState, PRIVATE_PATH_STATE_KEYS)).
|
|
2392
|
+
return Object.assign(Object.assign({}, base), (config(omit(pathState, PRIVATE_PATH_STATE_KEYS)).props || {}));
|
|
2436
2393
|
}
|
|
2437
|
-
if (config === null || config === void 0 ? void 0 : config.
|
|
2438
|
-
return Object.assign(Object.assign({}, base), config.
|
|
2394
|
+
if (config === null || config === void 0 ? void 0 : config.props) {
|
|
2395
|
+
return Object.assign(Object.assign({}, base), config.props(omit(pathState, PRIVATE_PATH_STATE_KEYS)));
|
|
2439
2396
|
}
|
|
2440
2397
|
return base;
|
|
2441
2398
|
});
|
|
2442
|
-
return props;
|
|
2399
|
+
return [createModel(path, () => { var _a; return (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : false; }), props];
|
|
2443
2400
|
}
|
|
2444
2401
|
return Object.assign(Object.assign({}, formCtx), { values: vue.readonly(formValues), handleReset: () => resetForm(), submitForm,
|
|
2445
|
-
|
|
2446
|
-
defineInputBinds });
|
|
2402
|
+
defineField });
|
|
2447
2403
|
}
|
|
2448
2404
|
/**
|
|
2449
2405
|
* Manages form meta aggregation
|
|
@@ -2530,7 +2486,7 @@
|
|
|
2530
2486
|
inheritAttrs: false,
|
|
2531
2487
|
props: {
|
|
2532
2488
|
as: {
|
|
2533
|
-
type:
|
|
2489
|
+
type: null,
|
|
2534
2490
|
default: 'form',
|
|
2535
2491
|
},
|
|
2536
2492
|
validationSchema: {
|
|
@@ -2653,13 +2609,13 @@
|
|
|
2653
2609
|
});
|
|
2654
2610
|
return function renderForm() {
|
|
2655
2611
|
// avoid resolving the form component as itself
|
|
2656
|
-
const tag = props.as === 'form' ? props.as : vue.resolveDynamicComponent(props.as);
|
|
2612
|
+
const tag = props.as === 'form' ? props.as : !props.as ? null : vue.resolveDynamicComponent(props.as);
|
|
2657
2613
|
const children = normalizeChildren(tag, ctx, slotProps);
|
|
2658
|
-
if (!
|
|
2614
|
+
if (!tag) {
|
|
2659
2615
|
return children;
|
|
2660
2616
|
}
|
|
2661
2617
|
// Attributes to add on a native `form` tag
|
|
2662
|
-
const formAttrs =
|
|
2618
|
+
const formAttrs = tag === 'form'
|
|
2663
2619
|
? {
|
|
2664
2620
|
// Disables native validation as vee-validate will handle it.
|
|
2665
2621
|
novalidate: true,
|
package/dist/vee-validate.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.
|
|
2
|
+
* vee-validate v4.12.0-alpha.0
|
|
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 l=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function a(e){return Number(e)>=0}function u(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 i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n]))return e[n]||(e[n]={}),void i(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++)a(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};function d(e,t,n){"object"==typeof n.value&&(n.value=c(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function c(e){if("object"!=typeof e)return e;var t,n,r,l=0,a=Object.prototype.toString.call(e);if("[object Object]"===a?r=Object.create(e.__proto__||null):"[object Array]"===a?r=Array(e.length):"[object Set]"===a?(r=new Set,e.forEach((function(e){r.add(c(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(c(t),c(e))}))):"[object Date]"===a?r=new Date(+e):"[object RegExp]"===a?r=new RegExp(e.source,e.flags):"[object DataView]"===a?r=new e.constructor(c(e.buffer)):"[object ArrayBuffer]"===a?r=e.slice(0):"Array]"===a.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)d(r,n[l],Object.getOwnPropertyDescriptor(e,n[l]));for(l=0,n=Object.getOwnPropertyNames(e);l<n.length;l++)Object.hasOwnProperty.call(r,t=n[l])&&r[t]===e[t]||d(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}const v=Symbol("vee-validate-form"),f=Symbol("vee-validate-field-instance"),p=Symbol("Default empty value"),m="undefined"!=typeof window;function h(e){return n(e)&&!!e.__locatorRef}function y(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function g(e){return!!e&&n(e.validate)}function b(e){return"checkbox"===e||"radio"===e}function V(e){return/^\[.+\]$/i.test(e)}function O(e){return"SELECT"===e.tagName}function j(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&&!b(t.type)}function A(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 S(e,t){return t in e&&e[t]!==p}function E(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,l;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!E(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(!E(r[1],t.get(r[0])))return!1;return!0}if(k(e)&&k(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=(l=Object.keys(e)).length;0!=r--;){var a=l[r];if(!E(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function k(e){return!!m&&e instanceof File}function w(e){return V(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(V(t))return e[w(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(l(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function M(e,t,n){if(V(t))return void(e[w(t)]=n);const l=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<l.length;e++){if(e===l.length-1)return void(u[l[e]]=n);l[e]in u&&!r(u[l[e]])||(u[l[e]]=a(l[e+1])?[]:{}),u=u[l[e]]}}function C(e,t){Array.isArray(e)&&a(t)?e.splice(Number(t),1):l(e)&&delete e[t]}function B(e,t){if(V(t))return void delete e[w(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>I(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?C(u[t-1],n[t-1]):C(e,n[0]));var i}function T(e){return Object.keys(e)}function _(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function R(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function U(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function P(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function x(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n||(n=void 0,t(a,r)),a}}function N({get:e,set:n}){const r=t.ref(c(e()));return t.watch(e,(e=>{E(e,r.value)||(r.value=c(e))}),{deep:!0}),t.watch(r,(t=>{E(t,e())||n(c(t))}),{deep:!0}),r}function $(e){return Array.isArray(e)?e:e?[e]:[]}function D(e){const n=_(v),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(f);return!l&&(null==r||r.value),r||l}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(!F(e))return e;const t=e.target;if(b(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(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return function(e){return"number"===e.type||"range"===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?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(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=>I(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 l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){if(y(e.rules)||g(e.rules))return async function(e,t){const n=y(t)?t:ee(t),r=await n.parse(e),l=[];for(const e of r.errors)e.errors.length&&l.push(...e.errors);return{errors:l}}(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],l=r.length,a=[];for(let u=0;u<l;u++){const l=r[u],i=await l(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))a.push(...i);else{const e="string"==typeof i?i:ne(n);a.push(e)}if(e.bails)return{errors:a}}}return{errors:a}}const r=Object.assign(Object.assign({},e),{rules:G(e.rules)}),l=[],a=Object.keys(r.rules),u=a.length;for(let n=0;n<u;n++){const u=a[n],i=await te(r,t,{name:u,params:r.rules[u]});if(i.error&&(l.push(i.error),e.bails))return{errors:l}}return{errors:l}}(a,e),i=u.errors;return{errors:i,valid:!i.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=(l=n.name,s[l]);var l;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const a=function(e,t){const n=e=>h(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),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:a})},i=await r(t,a,u);return"string"==typeof i?{error:i}:{error:i?void 0:ne(u)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=T(e).map((async r=>{var l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await Z(I(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i}}let le=0;function ae(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?I(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.stageInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return I(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(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=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r){const l=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!E(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{l.valid=!e.length}),{immediate:!0,flush:"sync"}),l}(r,l,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&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ue(e,n,r){return b(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:_(v),a=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.toValue(n.value),r=t.toValue(a);return Array.isArray(e)?e.findIndex((e=>E(e,r)))>=0:E(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==l?void 0:l.getPathState(f),m=W(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=R(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=R(t.toValue(n.value),h,t.toValue(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:a,uncheckedValue:u,handleChange:s})}return i(ie(e,n,r))}(e,n,r):ie(e,n,r)}function ie(e,r,l){const{initialValue:a,validateOnMount:u,bails:i,type:s,checkedValue:d,label:m,validateOnValueUpdate:b,uncheckedValue:V,controlled:O,keepValueOnUnmount:j,syncVModel:A,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),l="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",a=r&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),l):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:a});const u="valueProp"in e?e.valueProp:e.checkedValue,i="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:a,controlled:null==i||i,checkedValue:u,syncVModel:o})}(l),S=O?_(v):void 0,k=F||S,w=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.toValue(null==k?void 0:k.schema))return;const e=t.unref(r);return g(e)||y(e)||n(e)||Array.isArray(e)?e:G(e)})),{id:C,value:B,initialValue:R,meta:U,setState:N,errors:$,flags:D}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value?X:void 0}),z=t.computed((()=>$.value[0]));A&&function({prop:e,value:n,handleChange:r,shouldValidate:l}){const a=t.getCurrentInstance();if(!a||!e)return;const u="string"==typeof e?e:"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{E(e,oe(a,u))||a.emit(i,e)})),t.watch((()=>oe(a,u)),(e=>{if(e===p&&void 0===n.value)return;const t=e===p?void 0:e;E(t,n.value)||r(t,l())}))}({value:B,prop:A,handleChange:H,shouldValidate:()=>b&&!D.pendingReset});async function q(e){var n,r;return(null==k?void 0:k.validateSchema)?null!==(n=(await k.validateSchema(e)).results[t.toValue(w)])&&void 0!==n?n:{valid:!0,errors:[]}:M.value?Z(B.value,M.value,{name:t.toValue(w),label:t.toValue(m),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=x((async()=>(U.pending=!0,U.validated=!0,q("validated-only"))),(e=>{if(!D.pendingUnmount[te.id])return N({errors:e.errors}),U.pending=!1,U.valid=e.valid,e})),K=x((async()=>q("silent")),(e=>(U.valid=e.valid,e)));function X(e){return"silent"===(null==e?void 0:e.mode)?K():L()}function H(e,t=!0){Y(W(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:R.value;N({value:c(n),initialValue:c(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,K()}t.onMounted((()=>{if(u)return L();k&&k.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){B.value=Q&&A?P(e,Q.props.modelModifiers):e;(t?L:K)()}const ee=t.computed({get:()=>B.value,set(e){Y(e,b)}}),te={id:C,name:w,label:m,value:ee,meta:U,errors:$,errorMessage:z,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{U.touched=!0,t&&L()},setState:N,setTouched:function(e){U.touched=e},setErrors:function(e){N({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(f,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{E(e,t)||(U.validated?L():K())}),{deep:!0}),!k)return te;const ne=t.computed((()=>{const e=M.value;return!e||n(e)||g(e)||y(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(l=e[n],Array.isArray(l)?l.filter(h):T(l).filter((e=>h(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(U.validated?L():K())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(te.keepValueOnUnmount))&&void 0!==e?e:t.toValue(k.keepValuesOnUnmount),r=t.toValue(w);if(n||!k||D.pendingUnmount[te.id])return void(null==k||k.removePathState(r,C));D.pendingUnmount[te.id]=!0;const l=k.getPathState(r);if(Array.isArray(null==l?void 0:l.id)&&(null==l?void 0:l.multiple)?null==l?void 0:l.id.includes(te.id):(null==l?void 0:l.id)===te.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>E(e,t.toValue(te.checkedValue))));if(e>-1){const t=[...l.value];t.splice(e,1),k.setFieldValue(r,t)}Array.isArray(l.id)&&l.id.splice(l.id.indexOf(te.id),1)}else k.unsetPathValue(t.toValue(w));k.removePathState(r,C)}})),te}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 b(t.attrs.type)?S(e,"modelValue")?e.modelValue:void 0:S(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:p},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 l=t.toRef(e,"rules"),a=t.toRef(e,"name"),u=t.toRef(e,"label"),i=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:y,meta:g,checked:V,setErrors:O}=ue(a,l,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:e.validateOnModelUpdate,keepValueOnUnmount:o,syncVModel:!0}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},F=t.computed((()=>{const{validateOnInput:t,validateOnChange:l,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,l;const{validateOnInput:a,validateOnChange:u,validateOnBlur:i,validateOnModelUpdate:o}=Q();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:a,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:i,validateOnModelUpdate:null!==(l=e.validateOnModelUpdate)&&void 0!==l?l:o}}(e);const i={name:e.name,onBlur:function(e){p(e,a),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,l),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,u)};return i})),S=t.computed((()=>{const t=Object.assign({},F.value);b(r.attrs.type)&&V&&(t.checked=V.value);return j(se(e,r),r.attrs)&&(t.value=d.value),t})),E=t.computed((()=>Object.assign(Object.assign({},F.value),{modelValue:d.value})));function k(){return{field:S.value,componentField:E.value,value:d.value,meta:g,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:A,handleInput:e=>A(e,!1),handleReset:y,handleBlur:F.value.onBlur,setTouched:m,setErrors:O}}return r.expose({setErrors:O,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=q(n,r,k);return n?t.h(n,Object.assign(Object.assign({},r.attrs),S.value),l):l}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},l=t.unref(null==e?void 0:e.validationSchema);return l&&y(l)&&n(l.cast)?c(l.cast(r)||{}):c(r)}function me(e){var r;const l=ve++;let a=0;const u=t.ref(!1),s=t.ref(!1),d=t.ref(0),f=[],p=t.reactive(pe(e)),m=t.ref([]),h=t.ref({}),b=t.ref({}),V=function(e){let n=null,r=[];return function(...l){const a=t.nextTick((()=>{if(n!==a)return;const t=e(...l);r.forEach((e=>e(t))),r=[],n=null}));return n=a,new Promise((e=>r.push(e)))}}((()=>{b.value=m.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function O(e,t){const n=Y(e);if(n){if("string"==typeof e){const t=o(e);h.value[t]&&delete h.value[t]}n.errors=$(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=$(t))}function j(e){T(e).forEach((t=>{O(t,e[t])}))}(null==e?void 0:e.initialErrors)&&j(e.initialErrors);const F=t.computed((()=>{const e=m.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),S=t.computed((()=>T(F.value).reduce(((e,t)=>{const n=F.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),k=t.computed((()=>m.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),w=t.computed((()=>m.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),C=Object.assign({},(null==e?void 0:e.initialErrors)||{}),_=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:R,originalInitialValues:P,setInitialValues:N}=function(e,n,r){const l=pe(r),a=null==r?void 0:r.initialValues,u=t.ref(l),o=t.ref(c(l));function s(t,r=!1){u.value=i(c(u.value)||{},c(t)),o.value=i(c(o.value)||{},c(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(u.value,e.path);M(n,e.path,c(t))}))}t.isRef(a)&&t.watch(a,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:u,originalInitialValues:o,setInitialValues:s}}(m,p,e),D=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!E(n,t.unref(r))));function i(){const t=e.value;return T(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();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&&!T(l.value).length,dirty:u.value})))}(m,p,P,S),q=t.computed((()=>m.value.reduce(((e,t)=>{const n=I(p,t.path);return M(e,t.path,n),e}),{}))),L=null==e?void 0:e.validationSchema;function K(e,n){var r,l;const u=t.computed((()=>I(R.value,t.toValue(e)))),i=b.value[t.toValue(e)];if(i){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(i.multiple=!0);const e=a++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const o=t.computed((()=>I(p,t.toValue(e)))),s=t.toValue(e),d=a++,v=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[s])||void 0===r?void 0:r.length),initialValue:u,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(o),t.unref(u))))});return m.value.push(v),b.value[s]=v,V(),S.value[s]&&!C[s]&&t.nextTick((()=>{ye(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{V();const n=c(o.value);b.value[e]=v,t.nextTick((()=>{M(p,e,n)}))})),v}const G=U(Ve,5),X=U(Ve,5),H=x((async e=>"silent"===await e?G():X()),((e,[t])=>{const n=T(ae.errorBag.value);return[...new Set([...T(e.results),...m.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const l=r,a=Y(l)||function(e){const t=m.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(l),u=(e.results[l]||{errors:[]}).errors,i={errors:u,valid:!u.length};return n.results[l]=i,i.valid||(n.errors[l]=i.errors[0]),a&&h.value[l]&&delete h.value[l],a?(a.valid=i.valid,"silent"===t?n:"validated-only"!==t||a.validated?(O(a,i.errors),n):n):(O(l,u),n)}),{valid:e.valid,results:{},errors:{}})}));function J(e){m.value.forEach(e)}function Y(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.value[t]:t}let Z,te=[];function ne(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),J((e=>e.touched=!0)),u.value=!0,d.value++,he().then((l=>{const a=c(p);if(l.valid&&"function"==typeof t){const n=c(q.value);let u=e?n:a;return l.values&&(u=l.values),t(u,{evt:r,controlledValues:n,setErrors:j,setFieldError:O,setTouched:de,setFieldTouched:se,setValues:ie,setFieldValue:ue,resetForm:me,resetField:ce})}l.valid||"function"!=typeof n||n({values:a,evt:r,errors:l.errors,results:l.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const le=ne(!1);le.withControlled=ne(!0);const ae={formId:l,values:p,controlledValues:q,errorBag:F,errors:S,schema:L,submitCount:d,meta:D,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:_,validateSchema:t.unref(L)?H:void 0,validate:he,setFieldError:O,validateField:ye,setFieldValue:ue,setValues:ie,setErrors:j,setFieldTouched:se,setTouched:de,resetForm:me,resetField:ce,handleSubmit:le,stageInitialValue:function(t,n,r=!1){be(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(P.value,t,c(n))},unsetInitialValue:ge,setFieldInitialValue:be,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map(oe)},createPathState:K,getPathState:Y,unsetPathValue:function(e){return te.push(e),Z||(Z=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{B(p,e)})),te=[],Z=null}))),Z},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e)),l=m.value[r];if(-1!==r&&l){if(t.nextTick((()=>{ye(e,{mode:"silent",warn:!1})})),l.multiple&&l.fieldsCount&&l.fieldsCount--,Array.isArray(l.id)){const e=l.id.indexOf(n);e>=0&&l.id.splice(e,1),delete l.__flags.pendingUnmount[n]}(!l.multiple||l.fieldsCount<=0)&&(m.value.splice(r,1),ge(e),V(),delete b.value[e])}},initialValues:R,getAllPathStates:()=>m.value,markForUnmount:function(e){return J((t=>{t.path.startsWith(e)&&T(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))},isFieldTouched:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.touched)},isFieldDirty:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.dirty)},isFieldValid:function(e){var t;return!!(null===(t=Y(e))||void 0===t?void 0:t.valid)}};function ue(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;Y(l)||K(l),M(p,l,r),n&&ye(l)}function ie(e,t=!0){i(p,e),f.forEach((e=>e&&e.reset())),t&&he()}function oe(e){const n=Y(t.unref(e))||K(e);return t.computed({get:()=>n.value,set(r){const l=t.unref(e);ue(l,r,!1),n.validated=!0,n.pending=!0,ye(l).then((()=>{n.pending=!1}))}})}function se(e,t){const n=Y(e);n&&(n.touched=t)}function de(e){"boolean"!=typeof e?T(e).forEach((t=>{se(t,!!e[t])})):J((t=>{t.touched=e}))}function ce(e,n){var r;const l=n&&"value"in n?n.value:I(R.value,e),a=Y(e);a&&(a.__flags.pendingReset=!0),be(e,c(l)),ue(e,l,!1),se(e,null!==(r=null==n?void 0:n.touched)&&void 0!==r&&r),O(e,(null==n?void 0:n.errors)||[]),t.nextTick((()=>{a&&(a.__flags.pendingReset=!1)}))}function me(e,r){let l=(null==e?void 0:e.values)?e.values:P.value;l=y(L)&&n(L.cast)?L.cast(l):l,N(l),J((t=>{var n;t.__flags.pendingReset=!0,t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ue(t.path,I(l,t.path),!1),O(t.path,void 0)})),(null==r?void 0:r.force)?function(e,t=!0){T(p).forEach((e=>{delete p[e]})),T(e).forEach((t=>{ue(t,e[t],!1)})),t&&he()}(l,!1):ie(l,!1),j((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"}),J((e=>{e.__flags.pendingReset=!1}))}))}async function he(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&J((e=>e.validated=!0)),ae.validateSchema)return ae.validateSchema(t);s.value=!0;const n=await Promise.all(m.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={},l={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(l[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:l}}async function ye(e,t){const n=Y(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),L){const{results:n}=await H((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function ge(e){B(R.value,e)}function be(e,t){M(R.value,e,c(t))}async function Ve(){const e=t.unref(L);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=g(e)||y(e)?await async function(e,t){const n=y(e)?e:ee(e),r=await n.parse(c(t)),l={},a={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));l[n]={valid:!t.length,errors:t},t.length&&(a[n]=t[0])}return{valid:!r.errors.length,results:l,errors:a,values:r.value}}(e,p):await re(e,p,{names:k.value,bailsMap:w.value});return s.value=!1,n}const Oe=le(((e,{evt:t})=>{A(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&j(e.initialErrors),(null==e?void 0:e.initialTouched)&&de(e.initialTouched),(null==e?void 0:e.validateOnMount)?he():ae.validateSchema&&ae.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(v,ae),Object.assign(Object.assign({},ae),{values:t.readonly(p),handleReset:()=>me(),submitForm:Oe,defineComponentBinds:function(e,r){const l=Y(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(l.path)}function i(e){var t;const n=null!==(t=a().validateOnModelUpdate)&&void 0!==t?t:Q().validateOnModelUpdate;ue(l.path,e,n)}return t.computed((()=>{if(n(r)){const e=r(l),t=e.model||"modelValue";return Object.assign({onBlur:u,[t]:l.value,[`onUpdate:${t}`]:i},e.props||{})}const e=(null==r?void 0:r.model)||"modelValue",t={onBlur:u,[e]:l.value,[`onUpdate:${e}`]:i};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},t),r.mapProps(z(l,fe))):t}))},defineInputBinds:function(e,r){const l=Y(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ye(l.path)}function i(e){var t;const n=W(e),r=null!==(t=a().validateOnInput)&&void 0!==t?t:Q().validateOnInput;ue(l.path,n,r)}function o(e){var t;const n=W(e),r=null!==(t=a().validateOnChange)&&void 0!==t?t:Q().validateOnChange;ue(l.path,n,r)}return t.computed((()=>{const e={value:l.value,onChange:o,onInput:i,onBlur:u};return n(r)?Object.assign(Object.assign({},e),r(z(l,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(l,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"),l=t.toRef(e,"validationSchema"),a=t.toRef(e,"keepValues"),{errors:u,errorBag:i,values:o,meta:s,isSubmitting:d,isValidating:v,submitCount:f,controlledValues:p,validate:m,validateField:h,handleReset:y,resetForm:g,handleSubmit:b,setErrors:V,setFieldError:O,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetField:w}=me({validationSchema:l.value?l:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:a}),I=b(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?b(e.onSubmit,e.onInvalidSubmit):I;function C(e){F(e)&&e.preventDefault(),y(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function B(t,n){return b("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return c(o)}function _(){return c(s.value)}function R(){return c(u.value)}function U(){return{meta:s.value,errors:u.value,errorBag:i.value,values:o,isSubmitting:d.value,isValidating:v.value,submitCount:f.value,controlledValues:p.value,validate:m,validateField:h,handleSubmit:B,handleReset:y,submitForm:I,setErrors:V,setFieldError:O,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,resetField:w,getValues:T,getMeta:_,getErrors:R}}return n.expose({setFieldError:O,setErrors:V,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,validate:m,validateField:h,resetField:w,getValues:T,getMeta:_,getErrors:R}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),l=q(r,n,U);if(!e.as)return l;const a="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:M,onReset:C}),l)}}}),ye=he;function ge(e){const n=_(v,void 0),l=t.ref([]),a=()=>{},u={fields:l,remove:a,push:a,swap:a,insert:a,update:a,replace:a,prepend:a,move:a};if(!n)return u;if(!t.unref(e))return u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return I(null==n?void 0:n.values,t.unref(e),[])||[]}function d(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>p(e,t,l.value))),f())}function f(){const e=l.value.length;for(let t=0;t<e;t++){const n=l.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function p(a,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:N({get(){const r=I(null==n?void 0:n.values,t.unref(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&h(t,e)}}),isFirst:!1,isLast:!1};return d}function m(){f(),null==n||n.validate({mode:"silent"})}function h(r,l){const a=t.unref(e),u=I(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}d();const y={fields:l,remove:function(r){const a=t.unref(e),u=I(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(p(u)),m()},swap:function(r,a){const u=t.unref(e),i=I(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,f()},insert:function(r,a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.unref(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.value=d,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),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=>{E(e,l.value.map((e=>e.value)))||d()})),y}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:l,swap:a,insert:u,replace:i,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:l,swap:a,insert:u,update:o,replace:i,prepend:s,move:d}}return n.expose({push:r,remove:l,swap:a,insert:u,update:o,replace:i,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(v,void 0),l=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function a(){return{message:l.value}}return()=>{if(!l.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=q(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=f,e.Form=ye,e.FormContextKey=v,e.IS_ABSENT=p,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),s[e]=t},e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);return t.computed((()=>e?null==n?void 0:n.errors.value[t.toValue(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=_(v),r=e?void 0:t.inject(f);return t.computed((()=>e?I(null==n?void 0:n.values,t.toValue(e)):t.toValue(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=_(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=_(v);return 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=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=_(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=_(v);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=_(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=_(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=_(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=_(v);return 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=_(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=_(v),r=e?void 0:t.inject(f);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.toValue(e)):Promise.resolve({errors:[],valid:!0})}},e.useValidateForm=function(){const e=_(v);return 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 l=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function a(e){return Number(e)>=0}function u(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 i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n]))return e[n]||(e[n]={}),void i(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++)a(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};function d(e,t,n){"object"==typeof n.value&&(n.value=c(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function c(e){if("object"!=typeof e)return e;var t,n,r,l=0,a=Object.prototype.toString.call(e);if("[object Object]"===a?r=Object.create(e.__proto__||null):"[object Array]"===a?r=Array(e.length):"[object Set]"===a?(r=new Set,e.forEach((function(e){r.add(c(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(c(t),c(e))}))):"[object Date]"===a?r=new Date(+e):"[object RegExp]"===a?r=new RegExp(e.source,e.flags):"[object DataView]"===a?r=new e.constructor(c(e.buffer)):"[object ArrayBuffer]"===a?r=e.slice(0):"Array]"===a.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)d(r,n[l],Object.getOwnPropertyDescriptor(e,n[l]));for(l=0,n=Object.getOwnPropertyNames(e);l<n.length;l++)Object.hasOwnProperty.call(r,t=n[l])&&r[t]===e[t]||d(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}const v=Symbol("vee-validate-form"),f=Symbol("vee-validate-field-instance"),p=Symbol("Default empty value"),m="undefined"!=typeof window;function h(e){return n(e)&&!!e.__locatorRef}function y(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function g(e){return!!e&&n(e.validate)}function b(e){return"checkbox"===e||"radio"===e}function V(e){return/^\[.+\]$/i.test(e)}function O(e){return"SELECT"===e.tagName}function j(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&&!b(t.type)}function A(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 S(e,t){return t in e&&e[t]!==p}function E(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,l;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!E(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(!E(r[1],t.get(r[0])))return!1;return!0}if(k(e)&&k(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=(l=Object.keys(e)).length;0!=r--;){var a=l[r];if(!E(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function k(e){return!!m&&e instanceof File}function w(e){return V(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(V(t))return e[w(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(l(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function M(e,t,n){if(V(t))return void(e[w(t)]=n);const l=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<l.length;e++){if(e===l.length-1)return void(u[l[e]]=n);l[e]in u&&!r(u[l[e]])||(u[l[e]]=a(l[e+1])?[]:{}),u=u[l[e]]}}function C(e,t){Array.isArray(e)&&a(t)?e.splice(Number(t),1):l(e)&&delete e[t]}function T(e,t){if(V(t))return void delete e[w(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>I(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?C(u[t-1],n[t-1]):C(e,n[0]));var i}function _(e){return Object.keys(e)}function R(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function B(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function x(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function P(e,t){return l(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function U(e,t){let n;return async function(...r){const l=e(...r);n=l;const a=await l;return l!==n||(n=void 0,t(a,r)),a}}function N({get:e,set:n}){const r=t.ref(c(e()));return t.watch(e,(e=>{E(e,r.value)||(r.value=c(e))}),{deep:!0}),t.watch(r,(t=>{E(t,e())||n(c(t))}),{deep:!0}),r}function D(e){return Array.isArray(e)?e:e?[e]:[]}function $(e){const n=R(v),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(f);return!l&&(null==r||r.value),r||l}function z(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function q(e,t,n){return 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(!F(e))return e;const t=e.target;if(b(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(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return function(e){return"number"===e.type||"range"===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?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(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=>I(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 l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){if(y(e.rules)||g(e.rules))return async function(e,t){const n=y(t)?t:ee(t),r=await n.parse(e),l=[];for(const e of r.errors)e.errors.length&&l.push(...e.errors);return{errors:l}}(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],l=r.length,a=[];for(let u=0;u<l;u++){const l=r[u],i=await l(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))a.push(...i);else{const e="string"==typeof i?i:ne(n);a.push(e)}if(e.bails)return{errors:a}}}return{errors:a}}const r=Object.assign(Object.assign({},e),{rules:G(e.rules)}),l=[],a=Object.keys(r.rules),u=a.length;for(let n=0;n<u;n++){const u=a[n],i=await te(r,t,{name:u,params:r.rules[u]});if(i.error&&(l.push(i.error),e.bails))return{errors:l}}return{errors:l}}(a,e),i=u.errors;return{errors:i,valid:!i.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=(l=n.name,s[l]);var l;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const a=function(e,t){const n=e=>h(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),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:a})},i=await r(t,a,u);return"string"==typeof i?{error:i}:{error:i?void 0:ne(u)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=_(e).map((async r=>{var l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await Z(I(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i}}let le=0;function ae(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?I(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.stageInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return I(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=D(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r){const l=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!E(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{l.valid=!e.length}),{immediate:!0,flush:"sync"}),l}(r,l,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&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ue(e,n,r){return b(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:R(v),a=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.toValue(n.value),r=t.toValue(a);return Array.isArray(e)?e.findIndex((e=>E(e,r)))>=0:E(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==l?void 0:l.getPathState(f),m=W(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=B(I(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=B(t.toValue(n.value),h,t.toValue(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:a,uncheckedValue:u,handleChange:s})}return i(ie(e,n,r))}(e,n,r):ie(e,n,r)}function ie(e,r,l){const{initialValue:a,validateOnMount:u,bails:i,type:s,checkedValue:d,label:m,validateOnValueUpdate:b,uncheckedValue:V,controlled:O,keepValueOnUnmount:j,syncVModel:A,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),l="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",a=r&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),l):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:a});const u="valueProp"in e?e.valueProp:e.checkedValue,i="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:a,controlled:null==i||i,checkedValue:u,syncVModel:o})}(l),S=O?R(v):void 0,k=F||S,w=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.toValue(null==k?void 0:k.schema))return;const e=t.unref(r);return g(e)||y(e)||n(e)||Array.isArray(e)?e:G(e)})),{id:C,value:T,initialValue:B,meta:x,setState:N,errors:D,flags:$}=ae(w,{modelValue:a,form:k,bails:i,label:m,type:s,validate:M.value?X:void 0}),z=t.computed((()=>D.value[0]));A&&function({prop:e,value:n,handleChange:r,shouldValidate:l}){const a=t.getCurrentInstance();if(!a||!e)return;const u="string"==typeof e?e:"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{E(e,oe(a,u))||a.emit(i,e)})),t.watch((()=>oe(a,u)),(e=>{if(e===p&&void 0===n.value)return;const t=e===p?void 0:e;E(t,n.value)||r(t,l())}))}({value:T,prop:A,handleChange:H,shouldValidate:()=>b&&!$.pendingReset});async function q(e){var n,r;return(null==k?void 0:k.validateSchema)?null!==(n=(await k.validateSchema(e)).results[t.toValue(w)])&&void 0!==n?n:{valid:!0,errors:[]}:M.value?Z(T.value,M.value,{name:t.toValue(w),label:t.toValue(m),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const L=U((async()=>(x.pending=!0,x.validated=!0,q("validated-only"))),(e=>{if(!$.pendingUnmount[te.id])return N({errors:e.errors}),x.pending=!1,x.valid=e.valid,e})),K=U((async()=>q("silent")),(e=>(x.valid=e.valid,e)));function X(e){return"silent"===(null==e?void 0:e.mode)?K():L()}function H(e,t=!0){Y(W(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:B.value;N({value:c(n),initialValue:c(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),x.pending=!1,x.validated=!1,K()}t.onMounted((()=>{if(u)return L();k&&k.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){T.value=Q&&A?P(e,Q.props.modelModifiers):e;(t?L:K)()}const ee=t.computed({get:()=>T.value,set(e){Y(e,b)}}),te={id:C,name:w,label:m,value:ee,meta:x,errors:D,errorMessage:z,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:j,resetField:J,handleReset:()=>J(),validate:X,handleChange:H,handleBlur:(e,t=!1)=>{x.touched=!0,t&&L()},setState:N,setTouched:function(e){x.touched=e},setErrors:function(e){N({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(f,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{E(e,t)||(x.validated?L():K())}),{deep:!0}),!k)return te;const ne=t.computed((()=>{const e=M.value;return!e||n(e)||g(e)||y(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(l=e[n],Array.isArray(l)?l.filter(h):_(l).filter((e=>h(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(x.validated?L():K())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(te.keepValueOnUnmount))&&void 0!==e?e:t.toValue(k.keepValuesOnUnmount),r=t.toValue(w);if(n||!k||$.pendingUnmount[te.id])return void(null==k||k.removePathState(r,C));$.pendingUnmount[te.id]=!0;const l=k.getPathState(r);if(Array.isArray(null==l?void 0:l.id)&&(null==l?void 0:l.multiple)?null==l?void 0:l.id.includes(te.id):(null==l?void 0:l.id)===te.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>E(e,t.toValue(te.checkedValue))));if(e>-1){const t=[...l.value];t.splice(e,1),k.setFieldValue(r,t)}Array.isArray(l.id)&&l.id.splice(l.id.indexOf(te.id),1)}else k.unsetPathValue(t.toValue(w));k.removePathState(r,C)}})),te}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 b(t.attrs.type)?S(e,"modelValue")?e.modelValue:void 0:S(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:p},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 l=t.toRef(e,"rules"),a=t.toRef(e,"name"),u=t.toRef(e,"label"),i=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:y,meta:g,checked:V,setErrors:O}=ue(a,l,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:e.validateOnModelUpdate,keepValueOnUnmount:o,syncVModel:!0}),A=function(e,t=!0){f(e,t)},F=t.computed((()=>{const{validateOnInput:t,validateOnChange:l,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,l;const{validateOnInput:a,validateOnChange:u,validateOnBlur:i,validateOnModelUpdate:o}=Q();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:a,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:i,validateOnModelUpdate:null!==(l=e.validateOnModelUpdate)&&void 0!==l?l:o}}(e);const i={name:e.name,onBlur:function(e){p(e,a),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,l),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,u)};return i})),S=t.computed((()=>{const t=Object.assign({},F.value);b(r.attrs.type)&&V&&(t.checked=V.value);return j(se(e,r),r.attrs)&&(t.value=d.value),t})),E=t.computed((()=>Object.assign(Object.assign({},F.value),{modelValue:d.value})));function k(){return{field:S.value,componentField:E.value,value:d.value,meta:g,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:A,handleInput:e=>A(e,!1),handleReset:y,handleBlur:F.value.onBlur,setTouched:m,setErrors:O}}return r.expose({setErrors:O,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),l=q(n,r,k);return n?t.h(n,Object.assign(Object.assign({},r.attrs),S.value),l):l}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},l=t.unref(null==e?void 0:e.validationSchema);return l&&y(l)&&n(l.cast)?c(l.cast(r)||{}):c(r)}function me(e){var r;const l=ve++;let a=0;const u=t.ref(!1),s=t.ref(!1),d=t.ref(0),f=[],p=t.reactive(pe(e)),m=t.ref([]),h=t.ref({}),b=t.ref({}),V=function(e){let n=null,r=[];return function(...l){const a=t.nextTick((()=>{if(n!==a)return;const t=e(...l);r.forEach((e=>e(t))),r=[],n=null}));return n=a,new Promise((e=>r.push(e)))}}((()=>{b.value=m.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function O(e,t){const n=J(e);if(n){if("string"==typeof e){const t=o(e);h.value[t]&&delete h.value[t]}n.errors=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(h.value[o(e)]=D(t))}function j(e){_(e).forEach((t=>{O(t,e[t])}))}(null==e?void 0:e.initialErrors)&&j(e.initialErrors);const F=t.computed((()=>{const e=m.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},h.value),e)})),S=t.computed((()=>_(F.value).reduce(((e,t)=>{const n=F.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),k=t.computed((()=>m.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),w=t.computed((()=>m.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),C=Object.assign({},(null==e?void 0:e.initialErrors)||{}),R=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:B,originalInitialValues:P,setInitialValues:N}=function(e,n,r){const l=pe(r),a=null==r?void 0:r.initialValues,u=t.ref(l),o=t.ref(c(l));function s(t,r=!1){u.value=i(c(u.value)||{},c(t)),o.value=i(c(o.value)||{},c(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(u.value,e.path);M(n,e.path,c(t))}))}t.isRef(a)&&t.watch(a,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:u,originalInitialValues:o,setInitialValues:s}}(m,p,e),$=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!E(n,t.unref(r))));function i(){const t=e.value;return _(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();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&&!_(l.value).length,dirty:u.value})))}(m,p,P,S),q=t.computed((()=>m.value.reduce(((e,t)=>{const n=I(p,t.path);return M(e,t.path,n),e}),{}))),L=null==e?void 0:e.validationSchema;function K(e,n){var r,l;const u=t.computed((()=>I(B.value,t.toValue(e)))),i=b.value[t.toValue(e)];if(i){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(i.multiple=!0);const e=a++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const o=t.computed((()=>I(p,t.toValue(e)))),s=t.toValue(e),d=a++,v=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[s])||void 0===r?void 0:r.length),initialValue:u,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(o),t.unref(u))))});return m.value.push(v),b.value[s]=v,V(),S.value[s]&&!C[s]&&t.nextTick((()=>{he(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{V();const n=c(o.value);b.value[e]=v,t.nextTick((()=>{M(p,e,n)}))})),v}const W=x(be,5),G=x(be,5),X=U((async e=>"silent"===await e?W():G()),((e,[t])=>{const n=_(le.errorBag.value);return[...new Set([..._(e.results),...m.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const l=r,a=J(l)||function(e){const t=m.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(l),u=(e.results[l]||{errors:[]}).errors,i={errors:u,valid:!u.length};return n.results[l]=i,i.valid||(n.errors[l]=i.errors[0]),a&&h.value[l]&&delete h.value[l],a?(a.valid=i.valid,"silent"===t?n:"validated-only"!==t||a.validated?(O(a,i.errors),n):n):(O(l,u),n)}),{valid:e.valid,results:{},errors:{}})}));function H(e){m.value.forEach(e)}function J(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.value[t]:t}let Y,Z=[];function te(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),H((e=>e.touched=!0)),u.value=!0,d.value++,me().then((l=>{const a=c(p);if(l.valid&&"function"==typeof t){const n=c(q.value);let u=e?n:a;return l.values&&(u=l.values),t(u,{evt:r,controlledValues:n,setErrors:j,setFieldError:O,setTouched:se,setFieldTouched:oe,setValues:ue,setFieldValue:ae,resetForm:ce,resetField:de})}l.valid||"function"!=typeof n||n({values:a,evt:r,errors:l.errors,results:l.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const ne=te(!1);ne.withControlled=te(!0);const le={formId:l,values:p,controlledValues:q,errorBag:F,errors:S,schema:L,submitCount:d,meta:$,isSubmitting:u,isValidating:s,fieldArrays:f,keepValuesOnUnmount:R,validateSchema:t.unref(L)?X:void 0,validate:me,setFieldError:O,validateField:he,setFieldValue:ae,setValues:ue,setErrors:j,setFieldTouched:oe,setTouched:se,resetForm:ce,resetField:de,handleSubmit:ne,stageInitialValue:function(t,n,r=!1){ge(t,n),M(p,t,n),r&&!(null==e?void 0:e.initialValues)&&M(P.value,t,c(n))},unsetInitialValue:ye,setFieldInitialValue:ge,createPathState:K,getPathState:J,unsetPathValue:function(e){return Z.push(e),Y||(Y=t.nextTick((()=>{[...Z].sort().reverse().forEach((e=>{T(p,e)})),Z=[],Y=null}))),Y},removePathState:function(e,n){const r=m.value.findIndex((t=>t.path===e)),l=m.value[r];if(-1!==r&&l){if(t.nextTick((()=>{he(e,{mode:"silent",warn:!1})})),l.multiple&&l.fieldsCount&&l.fieldsCount--,Array.isArray(l.id)){const e=l.id.indexOf(n);e>=0&&l.id.splice(e,1),delete l.__flags.pendingUnmount[n]}(!l.multiple||l.fieldsCount<=0)&&(m.value.splice(r,1),ye(e),V(),delete b.value[e])}},initialValues:B,getAllPathStates:()=>m.value,markForUnmount:function(e){return H((t=>{t.path.startsWith(e)&&_(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))},isFieldTouched:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.touched)},isFieldDirty:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.dirty)},isFieldValid:function(e){var t;return!!(null===(t=J(e))||void 0===t?void 0:t.valid)}};function ae(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;J(l)||K(l),M(p,l,r),n&&he(l)}function ue(e,t=!0){i(p,e),f.forEach((e=>e&&e.reset())),t&&me()}function ie(e,n){const r=J(t.toValue(e))||K(e);return t.computed({get:()=>r.value,set(r){var l;ae(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}function oe(e,t){const n=J(e);n&&(n.touched=t)}function se(e){"boolean"!=typeof e?_(e).forEach((t=>{oe(t,!!e[t])})):H((t=>{t.touched=e}))}function de(e,n){var r;const l=n&&"value"in n?n.value:I(B.value,e),a=J(e);a&&(a.__flags.pendingReset=!0),ge(e,c(l)),ae(e,l,!1),oe(e,null!==(r=null==n?void 0:n.touched)&&void 0!==r&&r),O(e,(null==n?void 0:n.errors)||[]),t.nextTick((()=>{a&&(a.__flags.pendingReset=!1)}))}function ce(e,r){let l=(null==e?void 0:e.values)?e.values:P.value;l=y(L)&&n(L.cast)?L.cast(l):l,N(l),H((t=>{var n;t.__flags.pendingReset=!0,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,I(l,t.path),!1),O(t.path,void 0)})),(null==r?void 0:r.force)?function(e,t=!0){_(p).forEach((e=>{delete p[e]})),_(e).forEach((t=>{ae(t,e[t],!1)})),t&&me()}(l,!1):ue(l,!1),j((null==e?void 0:e.errors)||{}),d.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{me({mode:"silent"}),H((e=>{e.__flags.pendingReset=!1}))}))}async function me(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&H((e=>e.validated=!0)),le.validateSchema)return le.validateSchema(t);s.value=!0;const n=await Promise.all(m.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={},l={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(l[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:l}}async function he(e,t){const n=J(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),L){const{results:n}=await X((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function ye(e){T(B.value,e)}function ge(e,t){M(B.value,e,c(t))}async function be(){const e=t.unref(L);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=g(e)||y(e)?await async function(e,t){const n=y(e)?e:ee(e),r=await n.parse(c(t)),l={},a={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));l[n]={valid:!t.length,errors:t},t.length&&(a[n]=t[0])}return{valid:!r.errors.length,results:l,errors:a,values:r.value}}(e,p):await re(e,p,{names:k.value,bailsMap:w.value});return s.value=!1,n}const Ve=ne(((e,{evt:t})=>{A(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&j(e.initialErrors),(null==e?void 0:e.initialTouched)&&se(e.initialTouched),(null==e?void 0:e.validateOnMount)?me():le.validateSchema&&le.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=le.validateSchema)||void 0===e||e.call(le,"validated-only")})),t.provide(v,le),Object.assign(Object.assign({},le),{values:t.readonly(p),handleReset:()=>ce(),submitForm:Ve,defineField:function(e,r){const l=J(t.toValue(e))||K(e),a=()=>n(r)?r(z(l,fe)):r||{};function u(){var e;l.touched=!0;(null!==(e=a().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&he(l.path)}function i(){var e;(null!==(e=a().validateOnInput)&&void 0!==e?e:Q().validateOnInput)&&t.nextTick((()=>{he(l.path)}))}function o(){var e;(null!==(e=a().validateOnChange)&&void 0!==e?e:Q().validateOnChange)&&t.nextTick((()=>{he(l.path)}))}const s=t.computed((()=>{const e={onChange:o,onInput:i,onBlur:u};return n(r)?Object.assign(Object.assign({},e),r(z(l,fe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(z(l,fe))):e}));return[ie(e,(()=>{var e;return null!==(e=a().validateOnModelUpdate)&&void 0!==e&&e})),s]}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,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"),l=t.toRef(e,"validationSchema"),a=t.toRef(e,"keepValues"),{errors:u,errorBag:i,values:o,meta:s,isSubmitting:d,isValidating:v,submitCount:f,controlledValues:p,validate:m,validateField:h,handleReset:y,resetForm:g,handleSubmit:b,setErrors:V,setFieldError:O,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetField:w}=me({validationSchema:l.value?l:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:a}),I=b(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?b(e.onSubmit,e.onInvalidSubmit):I;function C(e){F(e)&&e.preventDefault(),y(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function T(t,n){return b("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function _(){return c(o)}function R(){return c(s.value)}function B(){return c(u.value)}function x(){return{meta:s.value,errors:u.value,errorBag:i.value,values:o,isSubmitting:d.value,isValidating:v.value,submitCount:f.value,controlledValues:p.value,validate:m,validateField:h,handleSubmit:T,handleReset:y,submitForm:I,setErrors:V,setFieldError:O,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,resetField:w,getValues:_,getMeta:R,getErrors:B}}return n.expose({setFieldError:O,setErrors:V,setFieldValue:j,setValues:S,setFieldTouched:E,setTouched:k,resetForm:g,validate:m,validateField:h,resetField:w,getValues:_,getMeta:R,getErrors:B}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=q(r,n,x);if(!r)return l;const a="form"===r?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:M,onReset:C}),l)}}}),ye=he;function ge(e){const n=R(v,void 0),l=t.ref([]),a=()=>{},u={fields:l,remove:a,push:a,swap:a,insert:a,update:a,replace:a,prepend:a,move:a};if(!n)return u;if(!t.unref(e))return u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return I(null==n?void 0:n.values,t.unref(e),[])||[]}function d(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>p(e,t,l.value))),f())}function f(){const e=l.value.length;for(let t=0;t<e;t++){const n=l.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function p(a,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:N({get(){const r=I(null==n?void 0:n.values,t.unref(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&h(t,e)}}),isFirst:!1,isLast:!1};return d}function m(){f(),null==n||n.validate({mode:"silent"})}function h(r,l){const a=t.unref(e),u=I(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}d();const y={fields:l,remove:function(r){const a=t.unref(e),u=I(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(p(u)),m()},swap:function(r,a){const u=t.unref(e),i=I(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,f()},insert:function(r,a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.unref(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.unref(e),o=I(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.value=d,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),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=>{E(e,l.value.map((e=>e.value)))||d()})),y}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:l,swap:a,insert:u,replace:i,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:l,swap:a,insert:u,update:o,replace:i,prepend:s,move:d}}return n.expose({push:r,remove:l,swap:a,insert:u,update:o,replace:i,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(v,void 0),l=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function a(){return{message:l.value}}return()=>{if(!l.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=q(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});e.ErrorMessage=Ve,e.Field=ce,e.FieldArray=be,e.FieldContextKey=f,e.Form=ye,e.FormContextKey=v,e.IS_ABSENT=p,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),s[e]=t},e.normalizeRules=G,e.useField=ue,e.useFieldArray=ge,e.useFieldError=function(e){const n=R(v),r=e?void 0:t.inject(f);return t.computed((()=>e?null==n?void 0:n.errors.value[t.toValue(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=R(v),r=e?void 0:t.inject(f);return t.computed((()=>e?I(null==n?void 0:n.values,t.toValue(e)):t.toValue(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=R(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=R(v);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=$(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=$(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=$(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=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=R(v);return function(t){if(e)return e.resetForm(t)}},e.useSetFieldError=function(e){const n=R(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=R(v),r=e?void 0:t.inject(f);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=R(v),r=e?void 0:t.inject(f);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=R(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=R(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=R(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=R(v);return 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=R(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=R(v),r=e?void 0:t.inject(f);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.toValue(e)):Promise.resolve({errors:[],valid:!0})}},e.useValidateForm=function(){const e=R(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re}));
|