vee-validate 4.6.10 → 4.7.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.
@@ -127,6 +127,7 @@ interface FormValidationResult<TValues> {
127
127
  }
128
128
  interface SubmissionContext<TValues extends GenericFormValues = GenericFormValues> extends FormActions<TValues> {
129
129
  evt?: Event;
130
+ controlledValues: Partial<TValues>;
130
131
  }
131
132
  declare type SubmissionHandler<TValues extends GenericFormValues = GenericFormValues, TReturn = unknown> = (values: TValues, ctx: SubmissionContext<TValues>) => TReturn;
132
133
  interface InvalidSubmissionContext<TValues extends GenericFormValues = GenericFormValues> {
@@ -141,9 +142,11 @@ declare type FieldPathLookup<TValues extends Record<string, any> = Record<string
141
142
  declare type MapValues<T, TValues extends Record<string, any>> = {
142
143
  [K in keyof T]: T[K] extends MaybeRef<infer TKey> ? TKey extends keyof TValues ? Ref<TValues[TKey]> : Ref<unknown> : Ref<unknown>;
143
144
  };
145
+ declare type HandleSubmitFactory<TValues extends GenericFormValues> = <TReturn = unknown>(cb: SubmissionHandler<TValues, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues>) => (e?: Event) => Promise<TReturn | undefined>;
144
146
  interface PrivateFormContext<TValues extends Record<string, any> = Record<string, any>> extends FormActions<TValues> {
145
147
  formId: number;
146
148
  values: TValues;
149
+ controlledValues: Ref<TValues>;
147
150
  fieldsByPath: Ref<FieldPathLookup>;
148
151
  fieldArrays: PrivateFieldArrayContext[];
149
152
  submitCount: Ref<number>;
@@ -161,7 +164,9 @@ interface PrivateFormContext<TValues extends Record<string, any> = Record<string
161
164
  unsetInitialValue(path: string): void;
162
165
  register(field: PrivateFieldContext): void;
163
166
  unregister(field: PrivateFieldContext): void;
164
- handleSubmit<TReturn = unknown>(cb: SubmissionHandler<TValues, TReturn>, onSubmitValidationErrorCb?: InvalidSubmissionHandler<TValues>): (e?: Event) => Promise<TReturn | undefined>;
167
+ handleSubmit: HandleSubmitFactory<TValues> & {
168
+ withControlled: HandleSubmitFactory<TValues>;
169
+ };
165
170
  setFieldInitialValue(path: string, value: unknown): void;
166
171
  useFieldModel<TPath extends keyof TValues>(path: MaybeRef<TPath>): Ref<TValues[TPath]>;
167
172
  useFieldModel<TPath extends keyof TValues>(paths: [...MaybeRef<TPath>[]]): MapValues<typeof paths, TValues>;
@@ -206,10 +211,12 @@ interface FieldOptions<TValue = unknown> {
206
211
  checkedValue?: MaybeRef<TValue>;
207
212
  uncheckedValue?: MaybeRef<TValue>;
208
213
  label?: MaybeRef<string | undefined>;
214
+ controlled?: boolean;
209
215
  standalone?: boolean;
210
216
  keepValueOnUnmount?: MaybeRef<boolean | undefined>;
211
217
  modelPropName?: string;
212
218
  syncVModel?: boolean;
219
+ form?: FormContext;
213
220
  }
214
221
  declare type RuleExpression<TValue> = string | Record<string, unknown> | GenericValidateFunction<TValue> | GenericValidateFunction<TValue>[] | YupValidator<TValue> | undefined;
215
222
  /**
@@ -248,8 +255,8 @@ declare const Field: {
248
255
  validateOnBlur: boolean;
249
256
  validateOnModelUpdate: boolean;
250
257
  modelValue: any;
251
- standalone: boolean;
252
258
  validateOnMount: boolean;
259
+ standalone: boolean;
253
260
  modelModifiers: any;
254
261
  rules: RuleExpression<unknown>;
255
262
  'onUpdate:modelValue': (e: any) => unknown;
@@ -319,7 +326,7 @@ declare const Field: {
319
326
  type: BooleanConstructor;
320
327
  default: any;
321
328
  };
322
- }>> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, "label" | "as" | "bails" | "uncheckedValue" | "validateOnInput" | "validateOnChange" | "validateOnBlur" | "validateOnModelUpdate" | "modelValue" | "standalone" | "validateOnMount" | "modelModifiers" | "rules" | "onUpdate:modelValue" | "keepValue">;
329
+ }>> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, "label" | "as" | "bails" | "uncheckedValue" | "validateOnInput" | "validateOnChange" | "validateOnBlur" | "validateOnModelUpdate" | "modelValue" | "validateOnMount" | "standalone" | "modelModifiers" | "rules" | "onUpdate:modelValue" | "keepValue">;
323
330
  $attrs: {
324
331
  [x: string]: unknown;
325
332
  };
@@ -400,13 +407,13 @@ declare const Field: {
400
407
  };
401
408
  }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
402
409
  [key: string]: any;
403
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
410
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
404
411
  [key: string]: any;
405
- }>[] | {
412
+ }>[] | vue.Slot | {
406
413
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
407
414
  [key: string]: any;
408
415
  }>[];
409
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, {
416
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
410
417
  label: string;
411
418
  as: string | Record<string, any>;
412
419
  bails: boolean;
@@ -416,8 +423,8 @@ declare const Field: {
416
423
  validateOnBlur: boolean;
417
424
  validateOnModelUpdate: boolean;
418
425
  modelValue: any;
419
- standalone: boolean;
420
426
  validateOnMount: boolean;
427
+ standalone: boolean;
421
428
  modelModifiers: any;
422
429
  rules: RuleExpression<unknown>;
423
430
  'onUpdate:modelValue': (e: any) => unknown;
@@ -509,9 +516,9 @@ declare const Field: {
509
516
  };
510
517
  }>> & vue.ShallowUnwrapRef<() => VNode<vue.RendererNode, vue.RendererElement, {
511
518
  [key: string]: any;
512
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
519
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
513
520
  [key: string]: any;
514
- }>[] | {
521
+ }>[] | vue.Slot | {
515
522
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
516
523
  [key: string]: any;
517
524
  }>[];
@@ -586,13 +593,13 @@ declare const Field: {
586
593
  };
587
594
  }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
588
595
  [key: string]: any;
589
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
596
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
590
597
  [key: string]: any;
591
- }>[] | {
598
+ }>[] | vue.Slot | {
592
599
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
593
600
  [key: string]: any;
594
601
  }>[];
595
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, {
602
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
596
603
  label: string;
597
604
  as: string | Record<string, any>;
598
605
  bails: boolean;
@@ -602,8 +609,8 @@ declare const Field: {
602
609
  validateOnBlur: boolean;
603
610
  validateOnModelUpdate: boolean;
604
611
  modelValue: any;
605
- standalone: boolean;
606
612
  validateOnMount: boolean;
613
+ standalone: boolean;
607
614
  modelModifiers: any;
608
615
  rules: RuleExpression<unknown>;
609
616
  'onUpdate:modelValue': (e: any) => unknown;
@@ -619,7 +626,7 @@ declare const Field: {
619
626
  };
620
627
  });
621
628
 
622
- declare type FormSlotProps = UnwrapRef<Pick<FormContext, 'meta' | 'errors' | 'values' | 'isSubmitting' | 'submitCount' | 'validate' | 'validateField' | 'handleReset' | 'setErrors' | 'setFieldError' | 'setFieldValue' | 'setValues' | 'setFieldTouched' | 'setTouched' | 'resetForm'>> & {
629
+ declare type FormSlotProps = UnwrapRef<Pick<FormContext, 'meta' | 'errors' | 'values' | 'isSubmitting' | 'submitCount' | 'validate' | 'validateField' | 'handleReset' | 'setErrors' | 'setFieldError' | 'setFieldValue' | 'setValues' | 'setFieldTouched' | 'setTouched' | 'resetForm' | 'controlledValues'>> & {
623
630
  handleSubmit: (evt: Event | SubmissionHandler, onSubmit?: SubmissionHandler) => Promise<unknown>;
624
631
  submitForm(evt?: Event): void;
625
632
  };
@@ -727,13 +734,13 @@ declare const Form: {
727
734
  };
728
735
  }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
729
736
  [key: string]: any;
730
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
737
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
731
738
  [key: string]: any;
732
- }>[] | {
739
+ }>[] | vue.Slot | {
733
740
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
734
741
  [key: string]: any;
735
742
  }>[];
736
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, {
743
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
737
744
  onSubmit: SubmissionHandler<GenericFormValues, unknown>;
738
745
  as: string;
739
746
  initialValues: Record<string, any>;
@@ -802,9 +809,9 @@ declare const Form: {
802
809
  };
803
810
  }>> & vue.ShallowUnwrapRef<() => VNode<vue.RendererNode, vue.RendererElement, {
804
811
  [key: string]: any;
805
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
812
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
806
813
  [key: string]: any;
807
- }>[] | {
814
+ }>[] | vue.Slot | {
808
815
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
809
816
  [key: string]: any;
810
817
  }>[];
@@ -851,13 +858,13 @@ declare const Form: {
851
858
  };
852
859
  }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
853
860
  [key: string]: any;
854
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
861
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
855
862
  [key: string]: any;
856
- }>[] | {
863
+ }>[] | vue.Slot | {
857
864
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
858
865
  [key: string]: any;
859
866
  }>[];
860
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, {
867
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
861
868
  onSubmit: SubmissionHandler<GenericFormValues, unknown>;
862
869
  as: string;
863
870
  initialValues: Record<string, any>;
@@ -910,13 +917,13 @@ declare const FieldArray: {
910
917
  type: StringConstructor;
911
918
  required: true;
912
919
  };
913
- }>>, () => vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
920
+ }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
914
921
  [key: string]: any;
915
- }>[] | {
922
+ }>[] | vue.Slot | {
916
923
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
917
924
  [key: string]: any;
918
925
  }>[];
919
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, {}> & {
926
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}> & {
920
927
  beforeCreate?: (() => void) | (() => void)[];
921
928
  created?: (() => void) | (() => void)[];
922
929
  beforeMount?: (() => void) | (() => void)[];
@@ -941,9 +948,9 @@ declare const FieldArray: {
941
948
  type: StringConstructor;
942
949
  required: true;
943
950
  };
944
- }>> & vue.ShallowUnwrapRef<() => vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
951
+ }>> & vue.ShallowUnwrapRef<() => VNode<vue.RendererNode, vue.RendererElement, {
945
952
  [key: string]: any;
946
- }>[] | {
953
+ }>[] | vue.Slot | {
947
954
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
948
955
  [key: string]: any;
949
956
  }>[];
@@ -956,13 +963,13 @@ declare const FieldArray: {
956
963
  type: StringConstructor;
957
964
  required: true;
958
965
  };
959
- }>>, () => vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
966
+ }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
960
967
  [key: string]: any;
961
- }>[] | {
968
+ }>[] | vue.Slot | {
962
969
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
963
970
  [key: string]: any;
964
971
  }>[];
965
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, {}> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
972
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {}> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
966
973
  push: FieldArrayContext['push'];
967
974
  remove: FieldArrayContext['remove'];
968
975
  swap: FieldArrayContext['swap'];
@@ -1019,13 +1026,13 @@ declare const ErrorMessage: {
1019
1026
  };
1020
1027
  }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
1021
1028
  [key: string]: any;
1022
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
1029
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
1023
1030
  [key: string]: any;
1024
- }>[] | {
1031
+ }>[] | vue.Slot | {
1025
1032
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
1026
1033
  [key: string]: any;
1027
1034
  }>[];
1028
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, {
1035
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
1029
1036
  as: string;
1030
1037
  }> & {
1031
1038
  beforeCreate?: (() => void) | (() => void)[];
@@ -1058,9 +1065,9 @@ declare const ErrorMessage: {
1058
1065
  };
1059
1066
  }>> & vue.ShallowUnwrapRef<() => VNode<vue.RendererNode, vue.RendererElement, {
1060
1067
  [key: string]: any;
1061
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
1068
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
1062
1069
  [key: string]: any;
1063
- }>[] | {
1070
+ }>[] | vue.Slot | {
1064
1071
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
1065
1072
  [key: string]: any;
1066
1073
  }>[];
@@ -1079,13 +1086,13 @@ declare const ErrorMessage: {
1079
1086
  };
1080
1087
  }>>, () => VNode<vue.RendererNode, vue.RendererElement, {
1081
1088
  [key: string]: any;
1082
- }> | vue.Slot | VNode<vue.RendererNode, vue.RendererElement, {
1089
+ }> | VNode<vue.RendererNode, vue.RendererElement, {
1083
1090
  [key: string]: any;
1084
- }>[] | {
1091
+ }>[] | vue.Slot | {
1085
1092
  default: () => VNode<vue.RendererNode, vue.RendererElement, {
1086
1093
  [key: string]: any;
1087
1094
  }>[];
1088
- }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, {
1095
+ }, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, {
1089
1096
  as: string;
1090
1097
  }> & vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps & (new () => {
1091
1098
  $slots: {
@@ -1,9 +1,9 @@
1
1
  /**
2
- * vee-validate v4.6.10
2
+ * vee-validate v4.7.0
3
3
  * (c) 2022 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
6
- import { inject, getCurrentInstance, warn as warn$1, ref, unref, computed, reactive, watch, onUnmounted, nextTick, onMounted, provide, isRef, onBeforeUnmount, defineComponent, toRef, resolveDynamicComponent, h, watchEffect, markRaw } from 'vue';
6
+ import { getCurrentInstance, inject, warn as warn$1, ref, unref, computed, reactive, watch, onUnmounted, nextTick, onMounted, provide, isRef, onBeforeUnmount, defineComponent, toRef, resolveDynamicComponent, h, watchEffect, markRaw } from 'vue';
7
7
  import { setupDevtoolsPlugin } from '@vue/devtools-api';
8
8
 
9
9
  function isCallable(fn) {
@@ -900,8 +900,8 @@ function klona(x) {
900
900
 
901
901
  let ID_COUNTER = 0;
902
902
  function useFieldState(path, init) {
903
- const { value, initialValue, setInitialValue } = _useFieldValue(path, init.modelValue, !init.standalone);
904
- const { errorMessage, errors, setErrors } = _useFieldErrors(path, !init.standalone);
903
+ const { value, initialValue, setInitialValue } = _useFieldValue(path, init.modelValue, init.form);
904
+ const { errorMessage, errors, setErrors } = _useFieldErrors(path, init.form);
905
905
  const meta = _useFieldMeta(value, initialValue, errors);
906
906
  const id = ID_COUNTER >= Number.MAX_SAFE_INTEGER ? 0 : ++ID_COUNTER;
907
907
  function setState(state) {
@@ -933,8 +933,7 @@ function useFieldState(path, init) {
933
933
  /**
934
934
  * Creates the field value and resolves the initial value
935
935
  */
936
- function _useFieldValue(path, modelValue, shouldInjectForm = true) {
937
- const form = shouldInjectForm === true ? injectWithSelf(FormContextKey, undefined) : undefined;
936
+ function _useFieldValue(path, modelValue, form) {
938
937
  const modelRef = ref(unref(modelValue));
939
938
  function resolveInitialValue() {
940
939
  if (!form) {
@@ -1005,8 +1004,7 @@ function _useFieldMeta(currentValue, initialValue, errors) {
1005
1004
  /**
1006
1005
  * Creates the error message state for the field state
1007
1006
  */
1008
- function _useFieldErrors(path, shouldInjectForm) {
1009
- const form = shouldInjectForm ? injectWithSelf(FormContextKey, undefined) : undefined;
1007
+ function _useFieldErrors(path, form) {
1010
1008
  function normalizeErrors(messages) {
1011
1009
  if (!messages) {
1012
1010
  return [];
@@ -1403,13 +1401,14 @@ function useField(name, rules, opts) {
1403
1401
  return _useField(name, rules, opts);
1404
1402
  }
1405
1403
  function _useField(name, rules, opts) {
1406
- const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, standalone, keepValueOnUnmount, modelPropName, syncVModel, } = normalizeOptions(unref(name), opts);
1407
- const form = !standalone ? injectWithSelf(FormContextKey) : undefined;
1404
+ const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount, modelPropName, syncVModel, form: controlForm, } = normalizeOptions(unref(name), opts);
1405
+ const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
1406
+ const form = controlForm || injectedForm;
1408
1407
  // a flag indicating if the field is about to be removed/unmounted.
1409
1408
  let markedForRemoval = false;
1410
1409
  const { id, value, initialValue, meta, setState, errors, errorMessage } = useFieldState(name, {
1411
1410
  modelValue,
1412
- standalone,
1411
+ form,
1413
1412
  });
1414
1413
  if (syncVModel) {
1415
1414
  useVModel({ value, prop: modelPropName, handleChange });
@@ -1626,20 +1625,20 @@ function normalizeOptions(name, opts) {
1626
1625
  initialValue: undefined,
1627
1626
  validateOnMount: false,
1628
1627
  bails: true,
1629
- rules: '',
1630
1628
  label: name,
1631
1629
  validateOnValueUpdate: true,
1632
- standalone: false,
1633
1630
  keepValueOnUnmount: undefined,
1634
1631
  modelPropName: 'modelValue',
1635
1632
  syncVModel: true,
1633
+ controlled: true,
1636
1634
  });
1637
1635
  if (!opts) {
1638
1636
  return defaults();
1639
1637
  }
1640
1638
  // TODO: Deprecate this in next major release
1641
1639
  const checkedValue = 'valueProp' in opts ? opts.valueProp : opts.checkedValue;
1642
- return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { checkedValue });
1640
+ const controlled = 'standalone' in opts ? !opts.standalone : opts.controlled;
1641
+ return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue });
1643
1642
  }
1644
1643
  /**
1645
1644
  * Extracts the validation rules from a schema
@@ -1910,6 +1909,7 @@ let FORM_COUNTER = 0;
1910
1909
  function useForm(opts) {
1911
1910
  var _a;
1912
1911
  const formId = FORM_COUNTER++;
1912
+ const controlledModelPaths = new Set();
1913
1913
  // Prevents fields from double resetting their values, which causes checkboxes to toggle their initial value
1914
1914
  // TODO: This won't be needed if we centralize all the state inside the `form` for form inputs
1915
1915
  let RESET_LOCK = false;
@@ -1972,6 +1972,13 @@ function useForm(opts) {
1972
1972
  const { initialValues, originalInitialValues, setInitialValues } = useFormInitialValues(fieldsByPath, formValues, opts === null || opts === void 0 ? void 0 : opts.initialValues);
1973
1973
  // form meta aggregations
1974
1974
  const meta = useFormMeta(fieldsByPath, formValues, originalInitialValues, errors);
1975
+ const controlledValues = computed(() => {
1976
+ return [...controlledModelPaths, ...keysOf(fieldsByPath.value)].reduce((acc, path) => {
1977
+ const value = getFromPath(formValues, path);
1978
+ setInPath(acc, path, value);
1979
+ return acc;
1980
+ }, {});
1981
+ });
1975
1982
  const schema = opts === null || opts === void 0 ? void 0 : opts.validationSchema;
1976
1983
  /**
1977
1984
  * Batches validation runs in 5ms batches
@@ -2021,10 +2028,65 @@ function useForm(opts) {
2021
2028
  return validation;
2022
2029
  }, { valid: formResult.valid, results: {}, errors: {} });
2023
2030
  });
2031
+ function makeSubmissionFactory(onlyControlled) {
2032
+ return function submitHandlerFactory(fn, onValidationError) {
2033
+ return function submissionHandler(e) {
2034
+ if (e instanceof Event) {
2035
+ e.preventDefault();
2036
+ e.stopPropagation();
2037
+ }
2038
+ // Touch all fields
2039
+ setTouched(keysOf(fieldsByPath.value).reduce((acc, field) => {
2040
+ acc[field] = true;
2041
+ return acc;
2042
+ }, {}));
2043
+ isSubmitting.value = true;
2044
+ submitCount.value++;
2045
+ return validate()
2046
+ .then(result => {
2047
+ const values = klona(formValues);
2048
+ if (result.valid && typeof fn === 'function') {
2049
+ const controlled = klona(controlledValues.value);
2050
+ return fn(onlyControlled ? controlled : values, {
2051
+ evt: e,
2052
+ controlledValues: controlled,
2053
+ setErrors,
2054
+ setFieldError,
2055
+ setTouched,
2056
+ setFieldTouched,
2057
+ setValues,
2058
+ setFieldValue,
2059
+ resetForm,
2060
+ });
2061
+ }
2062
+ if (!result.valid && typeof onValidationError === 'function') {
2063
+ onValidationError({
2064
+ values,
2065
+ evt: e,
2066
+ errors: result.errors,
2067
+ results: result.results,
2068
+ });
2069
+ }
2070
+ })
2071
+ .then(returnVal => {
2072
+ isSubmitting.value = false;
2073
+ return returnVal;
2074
+ }, err => {
2075
+ isSubmitting.value = false;
2076
+ // re-throw the err so it doesn't go silent
2077
+ throw err;
2078
+ });
2079
+ };
2080
+ };
2081
+ }
2082
+ const handleSubmitImpl = makeSubmissionFactory(false);
2083
+ const handleSubmit = handleSubmitImpl;
2084
+ handleSubmit.withControlled = makeSubmissionFactory(true);
2024
2085
  const formCtx = {
2025
2086
  formId,
2026
2087
  fieldsByPath,
2027
2088
  values: formValues,
2089
+ controlledValues,
2028
2090
  errorBag,
2029
2091
  errors,
2030
2092
  schema,
@@ -2123,7 +2185,7 @@ function useForm(opts) {
2123
2185
  fieldArrays.forEach(f => f && f.reset());
2124
2186
  }
2125
2187
  function createModel(path) {
2126
- const { value } = _useFieldValue(path);
2188
+ const { value } = _useFieldValue(path, undefined, formCtx);
2127
2189
  watch(value, () => {
2128
2190
  if (!fieldExists(unref(path))) {
2129
2191
  validate({ mode: 'validated-only' });
@@ -2131,6 +2193,7 @@ function useForm(opts) {
2131
2193
  }, {
2132
2194
  deep: true,
2133
2195
  });
2196
+ controlledModelPaths.add(unref(path));
2134
2197
  return value;
2135
2198
  }
2136
2199
  function useFieldModel(path) {
@@ -2347,55 +2410,6 @@ function useForm(opts) {
2347
2410
  }
2348
2411
  return fieldInstance.validate();
2349
2412
  }
2350
- function handleSubmit(fn, onValidationError) {
2351
- return function submissionHandler(e) {
2352
- if (e instanceof Event) {
2353
- e.preventDefault();
2354
- e.stopPropagation();
2355
- }
2356
- // Touch all fields
2357
- setTouched(keysOf(fieldsByPath.value).reduce((acc, field) => {
2358
- acc[field] = true;
2359
- return acc;
2360
- }, {}));
2361
- isSubmitting.value = true;
2362
- submitCount.value++;
2363
- return validate()
2364
- .then(result => {
2365
- if (result.valid && typeof fn === 'function') {
2366
- return fn(klona(formValues), {
2367
- evt: e,
2368
- setErrors,
2369
- setFieldError,
2370
- setTouched,
2371
- setFieldTouched,
2372
- setValues,
2373
- setFieldValue,
2374
- resetForm,
2375
- });
2376
- }
2377
- if (!result.valid && typeof onValidationError === 'function') {
2378
- onValidationError({
2379
- values: klona(formValues),
2380
- evt: e,
2381
- errors: result.errors,
2382
- results: result.results,
2383
- });
2384
- }
2385
- })
2386
- .then(returnVal => {
2387
- isSubmitting.value = false;
2388
- return returnVal;
2389
- }, err => {
2390
- isSubmitting.value = false;
2391
- // re-throw the err so it doesn't go silent
2392
- throw err;
2393
- });
2394
- };
2395
- }
2396
- function setFieldInitialValue(path, value) {
2397
- setInPath(initialValues.value, path, klona(value));
2398
- }
2399
2413
  function unsetInitialValue(path) {
2400
2414
  unsetPath(initialValues.value, path);
2401
2415
  }
@@ -2409,6 +2423,9 @@ function useForm(opts) {
2409
2423
  setInPath(originalInitialValues.value, path, klona(value));
2410
2424
  }
2411
2425
  }
2426
+ function setFieldInitialValue(path, value) {
2427
+ setInPath(initialValues.value, path, klona(value));
2428
+ }
2412
2429
  async function _validateSchema() {
2413
2430
  const schemaValue = unref(schema);
2414
2431
  if (!schemaValue) {
@@ -2460,26 +2477,7 @@ function useForm(opts) {
2460
2477
  deep: true,
2461
2478
  });
2462
2479
  }
2463
- return {
2464
- errors,
2465
- meta,
2466
- values: formValues,
2467
- isSubmitting,
2468
- submitCount,
2469
- validate,
2470
- validateField,
2471
- handleReset: () => resetForm(),
2472
- resetForm,
2473
- handleSubmit,
2474
- submitForm,
2475
- setFieldError,
2476
- setErrors,
2477
- setFieldValue,
2478
- setValues,
2479
- setFieldTouched,
2480
- setTouched,
2481
- useFieldModel,
2482
- };
2480
+ return Object.assign(Object.assign({}, formCtx), { handleReset: () => resetForm(), submitForm });
2483
2481
  }
2484
2482
  /**
2485
2483
  * Manages form meta aggregation
@@ -2639,7 +2637,7 @@ const FormImpl = defineComponent({
2639
2637
  const initialValues = toRef(props, 'initialValues');
2640
2638
  const validationSchema = toRef(props, 'validationSchema');
2641
2639
  const keepValues = toRef(props, 'keepValues');
2642
- const { errors, values, meta, isSubmitting, submitCount, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, } = useForm({
2640
+ const { errors, values, meta, isSubmitting, submitCount, controlledValues, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, } = useForm({
2643
2641
  validationSchema: validationSchema.value ? validationSchema : undefined,
2644
2642
  initialValues,
2645
2643
  initialErrors: props.initialErrors,
@@ -2674,6 +2672,7 @@ const FormImpl = defineComponent({
2674
2672
  values: values,
2675
2673
  isSubmitting: isSubmitting.value,
2676
2674
  submitCount: submitCount.value,
2675
+ controlledValues: controlledValues.value,
2677
2676
  validate,
2678
2677
  validateField,
2679
2678
  handleSubmit: handleScopedSlotSubmit,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vee-validate v4.6.10
2
+ * vee-validate v4.7.0
3
3
  * (c) 2022 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
@@ -885,8 +885,8 @@
885
885
 
886
886
  let ID_COUNTER = 0;
887
887
  function useFieldState(path, init) {
888
- const { value, initialValue, setInitialValue } = _useFieldValue(path, init.modelValue, !init.standalone);
889
- const { errorMessage, errors, setErrors } = _useFieldErrors(path, !init.standalone);
888
+ const { value, initialValue, setInitialValue } = _useFieldValue(path, init.modelValue, init.form);
889
+ const { errorMessage, errors, setErrors } = _useFieldErrors(path, init.form);
890
890
  const meta = _useFieldMeta(value, initialValue, errors);
891
891
  const id = ID_COUNTER >= Number.MAX_SAFE_INTEGER ? 0 : ++ID_COUNTER;
892
892
  function setState(state) {
@@ -918,8 +918,7 @@
918
918
  /**
919
919
  * Creates the field value and resolves the initial value
920
920
  */
921
- function _useFieldValue(path, modelValue, shouldInjectForm = true) {
922
- const form = shouldInjectForm === true ? injectWithSelf(FormContextKey, undefined) : undefined;
921
+ function _useFieldValue(path, modelValue, form) {
923
922
  const modelRef = vue.ref(vue.unref(modelValue));
924
923
  function resolveInitialValue() {
925
924
  if (!form) {
@@ -990,8 +989,7 @@
990
989
  /**
991
990
  * Creates the error message state for the field state
992
991
  */
993
- function _useFieldErrors(path, shouldInjectForm) {
994
- const form = shouldInjectForm ? injectWithSelf(FormContextKey, undefined) : undefined;
992
+ function _useFieldErrors(path, form) {
995
993
  function normalizeErrors(messages) {
996
994
  if (!messages) {
997
995
  return [];
@@ -1028,13 +1026,14 @@
1028
1026
  return _useField(name, rules, opts);
1029
1027
  }
1030
1028
  function _useField(name, rules, opts) {
1031
- const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, standalone, keepValueOnUnmount, modelPropName, syncVModel, } = normalizeOptions(vue.unref(name), opts);
1032
- const form = !standalone ? injectWithSelf(FormContextKey) : undefined;
1029
+ const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount, modelPropName, syncVModel, form: controlForm, } = normalizeOptions(vue.unref(name), opts);
1030
+ const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
1031
+ const form = controlForm || injectedForm;
1033
1032
  // a flag indicating if the field is about to be removed/unmounted.
1034
1033
  let markedForRemoval = false;
1035
1034
  const { id, value, initialValue, meta, setState, errors, errorMessage } = useFieldState(name, {
1036
1035
  modelValue,
1037
- standalone,
1036
+ form,
1038
1037
  });
1039
1038
  if (syncVModel) {
1040
1039
  useVModel({ value, prop: modelPropName, handleChange });
@@ -1242,20 +1241,20 @@
1242
1241
  initialValue: undefined,
1243
1242
  validateOnMount: false,
1244
1243
  bails: true,
1245
- rules: '',
1246
1244
  label: name,
1247
1245
  validateOnValueUpdate: true,
1248
- standalone: false,
1249
1246
  keepValueOnUnmount: undefined,
1250
1247
  modelPropName: 'modelValue',
1251
1248
  syncVModel: true,
1249
+ controlled: true,
1252
1250
  });
1253
1251
  if (!opts) {
1254
1252
  return defaults();
1255
1253
  }
1256
1254
  // TODO: Deprecate this in next major release
1257
1255
  const checkedValue = 'valueProp' in opts ? opts.valueProp : opts.checkedValue;
1258
- return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { checkedValue });
1256
+ const controlled = 'standalone' in opts ? !opts.standalone : opts.controlled;
1257
+ return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue });
1259
1258
  }
1260
1259
  /**
1261
1260
  * Extracts the validation rules from a schema
@@ -1523,6 +1522,7 @@
1523
1522
  function useForm(opts) {
1524
1523
  var _a;
1525
1524
  const formId = FORM_COUNTER++;
1525
+ const controlledModelPaths = new Set();
1526
1526
  // Prevents fields from double resetting their values, which causes checkboxes to toggle their initial value
1527
1527
  // TODO: This won't be needed if we centralize all the state inside the `form` for form inputs
1528
1528
  let RESET_LOCK = false;
@@ -1585,6 +1585,13 @@
1585
1585
  const { initialValues, originalInitialValues, setInitialValues } = useFormInitialValues(fieldsByPath, formValues, opts === null || opts === void 0 ? void 0 : opts.initialValues);
1586
1586
  // form meta aggregations
1587
1587
  const meta = useFormMeta(fieldsByPath, formValues, originalInitialValues, errors);
1588
+ const controlledValues = vue.computed(() => {
1589
+ return [...controlledModelPaths, ...keysOf(fieldsByPath.value)].reduce((acc, path) => {
1590
+ const value = getFromPath(formValues, path);
1591
+ setInPath(acc, path, value);
1592
+ return acc;
1593
+ }, {});
1594
+ });
1588
1595
  const schema = opts === null || opts === void 0 ? void 0 : opts.validationSchema;
1589
1596
  /**
1590
1597
  * Batches validation runs in 5ms batches
@@ -1634,10 +1641,65 @@
1634
1641
  return validation;
1635
1642
  }, { valid: formResult.valid, results: {}, errors: {} });
1636
1643
  });
1644
+ function makeSubmissionFactory(onlyControlled) {
1645
+ return function submitHandlerFactory(fn, onValidationError) {
1646
+ return function submissionHandler(e) {
1647
+ if (e instanceof Event) {
1648
+ e.preventDefault();
1649
+ e.stopPropagation();
1650
+ }
1651
+ // Touch all fields
1652
+ setTouched(keysOf(fieldsByPath.value).reduce((acc, field) => {
1653
+ acc[field] = true;
1654
+ return acc;
1655
+ }, {}));
1656
+ isSubmitting.value = true;
1657
+ submitCount.value++;
1658
+ return validate()
1659
+ .then(result => {
1660
+ const values = klona(formValues);
1661
+ if (result.valid && typeof fn === 'function') {
1662
+ const controlled = klona(controlledValues.value);
1663
+ return fn(onlyControlled ? controlled : values, {
1664
+ evt: e,
1665
+ controlledValues: controlled,
1666
+ setErrors,
1667
+ setFieldError,
1668
+ setTouched,
1669
+ setFieldTouched,
1670
+ setValues,
1671
+ setFieldValue,
1672
+ resetForm,
1673
+ });
1674
+ }
1675
+ if (!result.valid && typeof onValidationError === 'function') {
1676
+ onValidationError({
1677
+ values,
1678
+ evt: e,
1679
+ errors: result.errors,
1680
+ results: result.results,
1681
+ });
1682
+ }
1683
+ })
1684
+ .then(returnVal => {
1685
+ isSubmitting.value = false;
1686
+ return returnVal;
1687
+ }, err => {
1688
+ isSubmitting.value = false;
1689
+ // re-throw the err so it doesn't go silent
1690
+ throw err;
1691
+ });
1692
+ };
1693
+ };
1694
+ }
1695
+ const handleSubmitImpl = makeSubmissionFactory(false);
1696
+ const handleSubmit = handleSubmitImpl;
1697
+ handleSubmit.withControlled = makeSubmissionFactory(true);
1637
1698
  const formCtx = {
1638
1699
  formId,
1639
1700
  fieldsByPath,
1640
1701
  values: formValues,
1702
+ controlledValues,
1641
1703
  errorBag,
1642
1704
  errors,
1643
1705
  schema,
@@ -1736,7 +1798,7 @@
1736
1798
  fieldArrays.forEach(f => f && f.reset());
1737
1799
  }
1738
1800
  function createModel(path) {
1739
- const { value } = _useFieldValue(path);
1801
+ const { value } = _useFieldValue(path, undefined, formCtx);
1740
1802
  vue.watch(value, () => {
1741
1803
  if (!fieldExists(vue.unref(path))) {
1742
1804
  validate({ mode: 'validated-only' });
@@ -1744,6 +1806,7 @@
1744
1806
  }, {
1745
1807
  deep: true,
1746
1808
  });
1809
+ controlledModelPaths.add(vue.unref(path));
1747
1810
  return value;
1748
1811
  }
1749
1812
  function useFieldModel(path) {
@@ -1960,55 +2023,6 @@
1960
2023
  }
1961
2024
  return fieldInstance.validate();
1962
2025
  }
1963
- function handleSubmit(fn, onValidationError) {
1964
- return function submissionHandler(e) {
1965
- if (e instanceof Event) {
1966
- e.preventDefault();
1967
- e.stopPropagation();
1968
- }
1969
- // Touch all fields
1970
- setTouched(keysOf(fieldsByPath.value).reduce((acc, field) => {
1971
- acc[field] = true;
1972
- return acc;
1973
- }, {}));
1974
- isSubmitting.value = true;
1975
- submitCount.value++;
1976
- return validate()
1977
- .then(result => {
1978
- if (result.valid && typeof fn === 'function') {
1979
- return fn(klona(formValues), {
1980
- evt: e,
1981
- setErrors,
1982
- setFieldError,
1983
- setTouched,
1984
- setFieldTouched,
1985
- setValues,
1986
- setFieldValue,
1987
- resetForm,
1988
- });
1989
- }
1990
- if (!result.valid && typeof onValidationError === 'function') {
1991
- onValidationError({
1992
- values: klona(formValues),
1993
- evt: e,
1994
- errors: result.errors,
1995
- results: result.results,
1996
- });
1997
- }
1998
- })
1999
- .then(returnVal => {
2000
- isSubmitting.value = false;
2001
- return returnVal;
2002
- }, err => {
2003
- isSubmitting.value = false;
2004
- // re-throw the err so it doesn't go silent
2005
- throw err;
2006
- });
2007
- };
2008
- }
2009
- function setFieldInitialValue(path, value) {
2010
- setInPath(initialValues.value, path, klona(value));
2011
- }
2012
2026
  function unsetInitialValue(path) {
2013
2027
  unsetPath(initialValues.value, path);
2014
2028
  }
@@ -2022,6 +2036,9 @@
2022
2036
  setInPath(originalInitialValues.value, path, klona(value));
2023
2037
  }
2024
2038
  }
2039
+ function setFieldInitialValue(path, value) {
2040
+ setInPath(initialValues.value, path, klona(value));
2041
+ }
2025
2042
  async function _validateSchema() {
2026
2043
  const schemaValue = vue.unref(schema);
2027
2044
  if (!schemaValue) {
@@ -2067,26 +2084,7 @@
2067
2084
  }
2068
2085
  // Provide injections
2069
2086
  vue.provide(FormContextKey, formCtx);
2070
- return {
2071
- errors,
2072
- meta,
2073
- values: formValues,
2074
- isSubmitting,
2075
- submitCount,
2076
- validate,
2077
- validateField,
2078
- handleReset: () => resetForm(),
2079
- resetForm,
2080
- handleSubmit,
2081
- submitForm,
2082
- setFieldError,
2083
- setErrors,
2084
- setFieldValue,
2085
- setValues,
2086
- setFieldTouched,
2087
- setTouched,
2088
- useFieldModel,
2089
- };
2087
+ return Object.assign(Object.assign({}, formCtx), { handleReset: () => resetForm(), submitForm });
2090
2088
  }
2091
2089
  /**
2092
2090
  * Manages form meta aggregation
@@ -2246,7 +2244,7 @@
2246
2244
  const initialValues = vue.toRef(props, 'initialValues');
2247
2245
  const validationSchema = vue.toRef(props, 'validationSchema');
2248
2246
  const keepValues = vue.toRef(props, 'keepValues');
2249
- const { errors, values, meta, isSubmitting, submitCount, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, } = useForm({
2247
+ const { errors, values, meta, isSubmitting, submitCount, controlledValues, validate, validateField, handleReset, resetForm, handleSubmit, setErrors, setFieldError, setFieldValue, setValues, setFieldTouched, setTouched, } = useForm({
2250
2248
  validationSchema: validationSchema.value ? validationSchema : undefined,
2251
2249
  initialValues,
2252
2250
  initialErrors: props.initialErrors,
@@ -2281,6 +2279,7 @@
2281
2279
  values: values,
2282
2280
  isSubmitting: isSubmitting.value,
2283
2281
  submitCount: submitCount.value,
2282
+ controlledValues: controlledValues.value,
2284
2283
  validate,
2285
2284
  validateField,
2286
2285
  handleSubmit: handleScopedSlotSubmit,
@@ -1,6 +1,6 @@
1
1
  /**
2
- * vee-validate v4.6.10
2
+ * vee-validate v4.7.0
3
3
  * (c) 2022 Abdelrahman Awad
4
4
  * @license MIT
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function i(e){return Number(e)>=0}const u={};const o=Symbol("vee-validate-form"),l=Symbol("vee-validate-field-instance"),s=Symbol("Default empty value"),d="undefined"!=typeof window;function c(e){return n(e)&&!!e.__locatorRef}function f(e){return!!e&&n(e.validate)}function v(e){return"checkbox"===e||"radio"===e}function p(e){return Array.isArray(e)?0===e.length:a(e)&&0===Object.keys(e).length}function m(e){return/^\[.+\]$/i.test(e)}function y(e){return"SELECT"===e.tagName}function h(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&&!v(t.type)}function g(e){return b(e)&&e.target&&"submit"in e.target}function b(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function O(e,t){return t in e&&e[t]!==s}function V(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!V(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(!V(r[1],t.get(r[0])))return!1;return!0}if(F(e)&&F(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var i=a[r];if(!V(e[i],t[i]))return!1}return!0}return e!=e&&t!=t}function F(e){return!!d&&e instanceof File}var A=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,a,i;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(a=r;0!=a--;)if(!e(t[a],n[a]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(i=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(a=r;0!=a--;)if(!Object.prototype.hasOwnProperty.call(n,i[a]))return!1;for(a=r;0!=a--;){var u=i[a];if(!e(t[u],n[u]))return!1}return!0}return t!=t&&n!=n};function j(e){return m(e)?e.replace(/\[|\]/gi,""):e}function w(e,t,n){if(!e)return n;if(m(t))return e[j(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function E(e,t,n){if(m(t))return void(e[j(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(u[a[e]]=n);a[e]in u&&!r(u[a[e]])||(u[a[e]]=i(a[e+1])?[]:{}),u=u[a[e]]}}function S(e,t){Array.isArray(e)&&i(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function k(e,t){if(m(t))return void delete e[j(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){S(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const i=n.map(((t,r)=>w(e,n.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)p(i[t])&&(0!==t?S(i[t-1],n[t-1]):S(e,n[0]))}function B(e){return Object.keys(e)}function I(e,n){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function M(e){t.warn(`[vee-validate]: ${e}`)}function T(e){return Array.isArray(e)?e[0]:e}function C(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>A(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return A(e,t)?n:t}function R(e,t=0){let n=null,r=[];return function(...a){return n&&window.clearTimeout(n),n=window.setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function P(e,t){let n;return async function(...r){const a=e(...r);n=a;const i=await a;return a!==n||(n=void 0,t(i,r)),i}}const N=(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 _(e){if(U(e))return e._value}function U(e){return"_value"in e}function $(e){if(!b(e))return e;const t=e.target;if(v(t.type)&&U(t))return _(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(y(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(_);var n;if(y(t)){const e=Array.from(t.options).find((e=>e.selected));return e?_(e):t.value}return t.value}function D(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=z(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=q(t);return n.name?(e[n.name]=z(n.params),e):e}),t):t}function z(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>w(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const q=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let L=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const K=()=>L,G=e=>{L=Object.assign(Object.assign({},L),e)};async function X(e,t,r={}){const a=null==r?void 0:r.bails,i={name:(null==r?void 0:r.name)||"{field}",rules:t,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){if(f(e.rules))return async function(e,t,n){var r;return{errors:await t.validate(e,{abortEarly:null===(r=n.bails)||void 0===r||r}).then((()=>[])).catch((e=>{if("ValidationError"===e.name)return e.errors;throw e}))}}(t,e.rules,{bails:e.bails});if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.name,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,i=[];for(let u=0;u<a;u++){const a=r[u],o=await a(t,n);if("string"!=typeof o&&o)continue;const l="string"==typeof o?o:J(n);if(i.push(l),e.bails)return{errors:i}}return{errors:i}}const r=Object.assign(Object.assign({},e),{rules:D(e.rules)}),a=[],i=Object.keys(r.rules),u=i.length;for(let n=0;n<u;n++){const u=i[n],o=await H(r,t,{name:u,params:r.rules[u]});if(o.error&&(a.push(o.error),e.bails))return{errors:a}}return{errors:a}}(i,e),o=u.errors;return{errors:o,valid:!o.length}}async function H(e,t,n){const r=(a=n.name,u[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const i=function(e,t){const n=e=>c(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),o={field:e.name,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:i})},l=await r(t,i,o);return"string"==typeof l?{error:l}:{error:l?void 0:J(o)}}function J(e){const t=K().generateMessage;return t?t(e):"Field is invalid"}async function Q(e,t,n){const r=B(e).map((async r=>{var a,i,u;const o=await X(w(t,r),e[r],{name:(null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r])||r,values:t,bails:null===(u=null===(i=null==n?void 0:n.bailsMap)||void 0===i?void 0:i[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const i=await Promise.all(r),u={},o={};for(const e of i)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,o[e.path]=e.errors[0]);return{valid:a,results:u,errors:o}}function W(e,t,n){"object"==typeof n.value&&(n.value=Y(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function Y(e){if("object"!=typeof e)return e;var t,n,r,a=0,i=Object.prototype.toString.call(e);if("[object Object]"===i?r=Object.create(e.__proto__||null):"[object Array]"===i?r=Array(e.length):"[object Set]"===i?(r=new Set,e.forEach((function(e){r.add(Y(e))}))):"[object Map]"===i?(r=new Map,e.forEach((function(e,t){r.set(Y(t),Y(e))}))):"[object Date]"===i?r=new Date(+e):"[object RegExp]"===i?r=new RegExp(e.source,e.flags):"[object DataView]"===i?r=new e.constructor(Y(e.buffer)):"[object ArrayBuffer]"===i?r=e.slice(0):"Array]"===i.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)W(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||W(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}let Z=0;function ee(e,n){const{value:r,initialValue:a,setInitialValue:i}=te(e,n.modelValue,!n.standalone),{errorMessage:u,errors:l,setErrors:s}=function(e,n){const r=n?I(o,void 0):void 0;function a(e){return e?Array.isArray(e)?e:[e]:[]}if(!r){const e=t.ref([]);return{errors:e,errorMessage:t.computed((()=>e.value[0])),setErrors:t=>{e.value=a(t)}}}const i=t.computed((()=>r.errorBag.value[t.unref(e)]||[]));return{errors:i,errorMessage:t.computed((()=>i.value[0])),setErrors:n=>{r.setFieldErrorBag(t.unref(e),a(n))}}}(e,!n.standalone),d=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!V(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,l);return{id:Z>=Number.MAX_SAFE_INTEGER?0:++Z,path:e,value:r,initialValue:a,meta:d,errors:l,errorMessage:u,setState:function(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(d.touched=null!==(t=e.touched)&&void 0!==t?t:d.touched),"initialValue"in e&&i(e.initialValue)}}}function te(e,n,r=!0){const a=!0===r?I(o,void 0):void 0,i=t.ref(t.unref(n));function u(){return a?w(a.meta.value.initialValues,t.unref(e),t.unref(i)):t.unref(i)}function l(n){a?a.stageInitialValue(t.unref(e),n,!0):i.value=n}const s=t.computed(u);if(!a){return{value:t.ref(u()),initialValue:s,setInitialValue:l}}const d=n?t.unref(n):w(a.values,t.unref(e),t.unref(s));a.stageInitialValue(t.unref(e),d,!0);return{value:t.computed({get:()=>w(a.values,t.unref(e)),set(n){a.setFieldValue(t.unref(e),n)}}),initialValue:s,setInitialValue:l}}function ne(e,n,r){return v(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:I(o),i=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function l(e){const n=e.handleChange,r=t.computed((()=>{const n=t.unref(e.value),r=t.unref(i);return Array.isArray(n)?n.findIndex((e=>V(e,r)))>=0:V(r,n)}));function o(o,l=!0){var s;if(r.value===(null===(s=null==o?void 0:o.target)||void 0===s?void 0:s.checked))return void(l&&e.validate());let d=$(o);a||(d=C(t.unref(e.value),t.unref(i),t.unref(u))),n(d,l)}return Object.assign(Object.assign({},e),{checked:r,checkedValue:i,uncheckedValue:u,handleChange:o})}return l(re(e,n,r))}(e,n,r):re(e,n,r)}function re(e,r,a){const{initialValue:i,validateOnMount:u,bails:d,type:v,checkedValue:p,label:m,validateOnValueUpdate:y,uncheckedValue:h,standalone:g,keepValueOnUnmount:b,modelPropName:O,syncVModel:F}=function(e,t){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,rules:"",label:e,validateOnValueUpdate:!0,standalone:!1,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0});if(!t)return n();const r="valueProp"in t?t.valueProp:t.checkedValue;return Object.assign(Object.assign(Object.assign({},n()),t||{}),{checkedValue:r})}(t.unref(e),a),A=g?void 0:I(o);let j=!1;const{id:E,value:S,initialValue:k,meta:M,setState:T,errors:C,errorMessage:R}=ee(e,{modelValue:i,standalone:g});F&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const i=e||"modelValue",u=`update:${i}`;if(!(i in a.props))return;t.watch(n,(e=>{V(e,ae(a,i))||a.emit(u,e)})),t.watch((()=>ae(a,i)),(e=>{if(e===s&&void 0===n.value)return;const t=e===s?void 0:e;V(t,x(n.value,a.props.modelModifiers))||r(t)}))}({value:S,prop:O,handleChange:q});const N=t.computed((()=>{let a=t.unref(r);const i=t.unref(null==A?void 0:A.schema);return i&&!f(i)&&(a=function(e,t){if(!e)return;return e[t]}(i,t.unref(e))||a),f(a)||n(a)||Array.isArray(a)?a:D(a)}));async function _(n){var r,a;return(null==A?void 0:A.validateSchema)?null!==(r=(await A.validateSchema(n)).results[t.unref(e)])&&void 0!==r?r:{valid:!0,errors:[]}:X(S.value,N.value,{name:t.unref(m)||t.unref(e),values:null!==(a=null==A?void 0:A.values)&&void 0!==a?a:{},bails:d})}const U=P((async()=>(M.pending=!0,M.validated=!0,_("validated-only"))),(e=>(j&&(e.valid=!0,e.errors=[]),T({errors:e.errors}),M.pending=!1,e))),z=P((async()=>_("silent")),(e=>(j&&(e.valid=!0),M.valid=e.valid,e)));function q(e,t=!0){const n=$(e);S.value=n,!y&&t&&U()}let L;t.onMounted((()=>{if(u)return U();A&&A.validateSchema||z()}));let K=Y(S.value);function G(){L=t.watch(S,((e,t)=>{if(V(e,t)&&V(e,K))return;(y?U:z)(),K=Y(e)}),{deep:!0})}function H(e){var n;null==L||L();const r=e&&"value"in e?e.value:k.value;T({value:Y(r),initialValue:Y(r),touched:null!==(n=null==e?void 0:e.touched)&&void 0!==n&&n,errors:(null==e?void 0:e.errors)||[]}),M.pending=!1,M.validated=!1,z(),t.nextTick((()=>{G()}))}G();const J={id:E,name:e,label:m,value:S,meta:M,errors:C,errorMessage:R,type:v,checkedValue:p,uncheckedValue:h,bails:d,keepValueOnUnmount:b,resetField:H,handleReset:()=>H(),validate:function(e){return"silent"===(null==e?void 0:e.mode)?z():U()},handleChange:q,handleBlur:()=>{M.touched=!0},setState:T,setTouched:function(e){M.touched=e},setErrors:function(e){T({errors:Array.isArray(e)?e:[e]})},setValue:function(e){S.value=e}};if(t.provide(l,J),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{V(e,t)||(M.validated?U():z())}),{deep:!0}),!A)return J;A.register(J),t.onBeforeUnmount((()=>{j=!0,A.unregister(J)}));const Q=t.computed((()=>{const e=N.value;return!e||n(e)||f(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(c):B(a).filter((e=>c(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=w(A.values,t)||A.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(Q,((e,t)=>{if(!Object.keys(e).length)return;!V(e,t)&&(M.validated?U():z())})),J}function ae(e,t){return e.props[t]}function ie(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ue(e,t){return v(t.attrs.type)?O(e,"modelValue")?e.modelValue:void 0:O(e,"modelValue")?e.modelValue:t.attrs.value}const oe=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:()=>K().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:s},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,n){const r=t.toRef(e,"rules"),a=t.toRef(e,"name"),i=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:l,value:s,errorMessage:d,validate:c,handleChange:f,handleBlur:p,setTouched:m,resetField:y,handleReset:g,meta:b,checked:O,setErrors:V}=ne(a,r,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:n.attrs.type,initialValue:ue(e,n),checkedValue:n.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o}),F=function(e,t=!0){f(e,t),n.emit("update:modelValue",s.value)},A=function(e){(e=>{v(n.attrs.type)||(s.value=$(e))})(e),n.emit("update:modelValue",s.value)},j=t.computed((()=>{const{validateOnInput:t,validateOnChange:r,validateOnBlur:a,validateOnModelUpdate:i}=function(e){var t,n,r,a;const{validateOnInput:i,validateOnChange:u,validateOnBlur:o,validateOnModelUpdate:l}=K();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:i,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:o,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:l}}(e),u=[p,n.attrs.onBlur,a?c:void 0].filter(Boolean),o=[e=>F(e,t),n.attrs.onInput].filter(Boolean),l=[e=>F(e,r),n.attrs.onChange].filter(Boolean),d={name:e.name,onBlur:u,onInput:o,onChange:l,"onUpdate:modelValue":e=>F(e,i)};v(n.attrs.type)&&O&&(d.checked=O.value);return h(ie(e,n),n.attrs)&&(d.value=s.value),d}));function w(){return{field:j.value,value:s.value,meta:b,errors:l.value,errorMessage:d.value,validate:c,resetField:y,handleChange:F,handleInput:A,handleReset:g,handleBlur:p,setTouched:m,setErrors:V}}return n.expose({setErrors:V,setTouched:m,reset:y,validate:c,handleChange:f}),()=>{const r=t.resolveDynamicComponent(ie(e,n)),a=N(r,n,w);return r?t.h(r,Object.assign(Object.assign({},n.attrs),j.value),a):a}}});let le=0;function se(e){var n;const r=le++;let a=!1;const i=t.ref({}),u=t.ref(!1),l=t.ref(0),s=[],d=t.reactive(Y(t.unref(null==e?void 0:e.initialValues)||{})),{errorBag:c,setErrorBag:v,setFieldErrorBag:m}=function(e){const n=t.ref({});function r(e){return Array.isArray(e)?e:e?[e]:[]}function a(e,t){t?n.value[e]=r(t):delete n.value[e]}function i(e){n.value=B(e).reduce(((t,n)=>{const a=e[n];return a&&(t[n]=r(a)),t}),{})}e&&i(e);return{errorBag:n,setErrorBag:i,setFieldErrorBag:a}}(null==e?void 0:e.initialErrors),y=t.computed((()=>B(c.value).reduce(((e,t)=>{const n=c.value[t];return n&&n.length&&(e[t]=n[0]),e}),{})));function h(e){const t=i.value[e];return Array.isArray(t)?t[0]:t}function b(e){return!!i.value[e]}const O=t.computed((()=>B(i.value).reduce(((e,n)=>{const r=h(n);return r&&(e[n]=t.unref(r.label||r.name)||""),e}),{}))),F=t.computed((()=>B(i.value).reduce(((e,t)=>{var n;const r=h(t);return r&&(e[t]=null===(n=r.bails)||void 0===n||n),e}),{}))),A=Object.assign({},(null==e?void 0:e.initialErrors)||{}),j=null!==(n=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==n&&n,{initialValues:S,originalInitialValues:I,setInitialValues:M}=function(e,n,r){const a=t.ref(Y(t.unref(r))||{}),i=t.ref(Y(t.unref(r))||{});function u(t,r=!1){a.value=Y(t),i.value=Y(t),r&&B(e.value).forEach((t=>{const r=e.value[t],i=Array.isArray(r)?r.some((e=>e.meta.touched)):null==r?void 0:r.meta.touched;if(!r||i)return;const u=w(a.value,t);E(n,t,Y(u))}))}t.isRef(r)&&t.watch(r,(e=>{u(e,!0)}),{deep:!0});return{initialValues:a,originalInitialValues:i,setInitialValues:u}}(i,d,null==e?void 0:e.initialValues),T=function(e,n,r,a){const i={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!V(n,t.unref(r))));function o(){const t=Object.values(e.value).flat(1).filter(Boolean);return B(i).reduce(((e,n)=>{const r=i[n];return e[n]=t[r]((e=>e.meta[n])),e}),{})}const l=t.reactive(o());return t.watchEffect((()=>{const e=o();l.touched=e.touched,l.valid=e.valid,l.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},l),{valid:l.valid&&!B(a.value).length,dirty:u.value})))}(i,d,I,y),x=null==e?void 0:e.validationSchema,N=R(se,5),_=R(se,5),U=P((async e=>"silent"===await e?N():_()),((e,[t])=>{const n=$.fieldsByPath.value||{},r=B($.errorBag.value);return[...new Set([...B(e.results),...B(n),...r])].reduce(((r,a)=>{const i=n[a],u=(e.results[a]||{errors:[]}).errors,o={errors:u,valid:!u.length};if(r.results[a]=o,o.valid||(r.errors[a]=o.errors[0]),!i)return L(a,u),r;if(z(i,(e=>e.meta.valid=o.valid)),"silent"===t)return r;const l=Array.isArray(i)?i.some((e=>e.meta.validated)):i.meta.validated;return"validated-only"!==t||l?(z(i,(e=>e.setState({errors:o.errors}))),r):r}),{valid:e.valid,results:{},errors:{}})})),$={formId:r,fieldsByPath:i,values:d,errorBag:c,errors:y,schema:x,submitCount:l,meta:T,isSubmitting:u,fieldArrays:s,keepValuesOnUnmount:j,validateSchema:t.unref(x)?U:void 0,validate:ae,register:function(e){const n=t.unref(e.name);ne(e,n),t.isRef(e.name)&&t.watch(e.name,(async(n,r)=>{await t.nextTick(),re(e,r),ne(e,n),(y.value[r]||y.value[n])&&(L(r,void 0),ie(n)),await t.nextTick(),b(r)||k(d,r)}));const r=t.unref(e.errorMessage);r&&(null==A?void 0:A[n])!==r&&ie(n);delete A[n]},unregister:function(e){const n=t.unref(e.name),r=i.value[n],a=!!r&&D(r);re(e,n),t.nextTick((()=>{var u;const o=null!==(u=t.unref(e.keepValueOnUnmount))&&void 0!==u?u:t.unref(j),l=w(d,n);if(a&&(r===i.value[n]||!i.value[n])&&Array.isArray(l)&&!o){const r=l.findIndex((n=>V(n,t.unref(e.checkedValue))));if(r>-1){const e=[...l];e.splice(r,1),G(n,e,{force:!0})}}if(!b(n)){if(L(n,void 0),o)return;if(a&&!p(w(d,n)))return;k(d,n)}}))},setFieldErrorBag:m,validateField:ie,setFieldValue:G,setValues:X,setErrors:K,setFieldError:L,setFieldTouched:W,setTouched:Z,resetForm:ee,handleSubmit:ue,stageInitialValue:function(t,n,r=!1){E(d,t,n),oe(t,n),r&&!(null==e?void 0:e.initialValues)&&E(I.value,t,Y(n))},unsetInitialValue:function(e){k(S.value,e)},setFieldInitialValue:oe,useFieldModel:J};function D(e){return Array.isArray(e)}function z(e,t){return Array.isArray(e)?e.forEach(t):t(e)}function q(e){Object.values(i.value).forEach((t=>{t&&z(t,e)}))}function L(e,t){m(e,t)}function K(e){v(e)}function G(e,n,{force:r}={force:!1}){var u;const o=i.value[e],l=Y(n);if(!o)return void E(d,e,l);if(D(o)&&"checkbox"===(null===(u=o[0])||void 0===u?void 0:u.type)&&!Array.isArray(n)){const t=Y(C(w(d,e)||[],n,void 0));return void E(d,e,t)}let s=n;D(o)||"checkbox"!==o.type||r||a||(s=Y(C(w(d,e),n,t.unref(o.uncheckedValue)))),E(d,e,s)}function X(e){B(d).forEach((e=>{delete d[e]})),B(e).forEach((t=>{G(t,e[t])})),s.forEach((e=>e&&e.reset()))}function H(e){const{value:n}=te(e);return t.watch(n,(()=>{b(t.unref(e))||ae({mode:"validated-only"})}),{deep:!0}),n}function J(e){return Array.isArray(e)?e.map(H):H(e)}function W(e,t){const n=i.value[e];n&&z(n,(e=>e.setTouched(t)))}function Z(e){B(e).forEach((t=>{W(t,!!e[t])}))}function ee(e){a=!0,q((e=>e.resetField())),(null==e?void 0:e.values)?(M(e.values),X(null==e?void 0:e.values)):(M(I.value),X(I.value)),(null==e?void 0:e.touched)&&Z(e.touched),K((null==e?void 0:e.errors)||{}),l.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{a=!1}))}function ne(e,n){const r=t.markRaw(e),a=n;if(!i.value[a])return void(i.value[a]=r);const u=i.value[a];u&&!Array.isArray(u)&&(i.value[a]=[u]),i.value[a]=[...i.value[a],r]}function re(e,t){const n=t,r=i.value[n];if(r)if(D(r)||e.id!==r.id){if(D(r)){const t=r.findIndex((t=>t.id===e.id));if(-1===t)return;r.splice(t,1),r.length||delete i.value[n]}}else delete i.value[n]}async function ae(e){if(q((e=>e.meta.validated=!0)),$.validateSchema)return $.validateSchema((null==e?void 0:e.mode)||"force");const n=await Promise.all(Object.values(i.value).map((n=>{const r=Array.isArray(n)?n[0]:n;return r?r.validate(e).then((e=>({key:t.unref(r.name),valid:e.valid,errors:e.errors}))):Promise.resolve({key:"",valid:!0,errors:[]})}))),r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function ie(e){const n=i.value[e];return n?Array.isArray(n)?n.map((e=>e.validate()))[0]:n.validate():(t.warn(`field with name ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function ue(e,t){return function(n){return n instanceof Event&&(n.preventDefault(),n.stopPropagation()),Z(B(i.value).reduce(((e,t)=>(e[t]=!0,e)),{})),u.value=!0,l.value++,ae().then((r=>{if(r.valid&&"function"==typeof e)return e(Y(d),{evt:n,setErrors:K,setFieldError:L,setTouched:Z,setFieldTouched:W,setValues:X,setFieldValue:G,resetForm:ee});r.valid||"function"!=typeof t||t({values:Y(d),evt:n,errors:r.errors,results:r.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}function oe(e,t){E(S.value,e,Y(t))}async function se(){const e=t.unref(x);if(!e)return{valid:!0,results:{},errors:{}};const n=f(e)?await async function(e,t){const n=await e.validate(t,{abortEarly:!1}).then((()=>[])).catch((e=>{if("ValidationError"!==e.name)throw e;return e.inner||[]})),r={},a={};for(const e of n){const t=e.errors;r[e.path]={valid:!t.length,errors:t},t.length&&(a[e.path]=t[0])}return{valid:!n.length,results:r,errors:a}}(e,d):await Q(e,d,{names:O.value,bailsMap:F.value});return n}const de=ue(((e,{evt:t})=>{g(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&K(e.initialErrors),(null==e?void 0:e.initialTouched)&&Z(e.initialTouched),(null==e?void 0:e.validateOnMount)?ae():$.validateSchema&&$.validateSchema("silent")})),t.isRef(x)&&t.watch(x,(()=>{var e;null===(e=$.validateSchema)||void 0===e||e.call($,"validated-only")})),t.provide(o,$),{errors:y,meta:T,values:d,isSubmitting:u,submitCount:l,validate:ae,validateField:ie,handleReset:()=>ee(),resetForm:ee,handleSubmit:ue,submitForm:de,setFieldError:L,setErrors:K,setFieldValue:G,setValues:X,setFieldTouched:W,setTouched:Z,useFieldModel:J}}const de=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),i=t.toRef(e,"keepValues"),{errors:u,values:o,meta:l,isSubmitting:s,submitCount:d,validate:c,validateField:f,handleReset:v,resetForm:p,handleSubmit:m,setErrors:y,setFieldError:h,setFieldValue:O,setValues:V,setFieldTouched:F,setTouched:A}=se({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:i}),j=m(((e,{evt:t})=>{g(t)&&t.target.submit()}),e.onInvalidSubmit),w=e.onSubmit?m(e.onSubmit,e.onInvalidSubmit):j;function E(e){b(e)&&e.preventDefault(),v(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function S(t,n){return m("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function k(){return{meta:l.value,errors:u.value,values:o,isSubmitting:s.value,submitCount:d.value,validate:c,validateField:f,handleSubmit:S,handleReset:v,submitForm:j,setErrors:y,setFieldError:h,setFieldValue:O,setValues:V,setFieldTouched:F,setTouched:A,resetForm:p}}return n.expose({setFieldError:h,setErrors:y,setFieldValue:O,setValues:V,setFieldTouched:F,setTouched:A,resetForm:p,validate:c,validateField:f}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=N(r,n,k);if(!e.as)return a;const i="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},i),n.attrs),{onSubmit:w,onReset:E}),a)}}}),ce=de;function fe(e){const n=I(o,void 0),a=t.ref([]),i=()=>{},u={fields:a,remove:i,push:i,swap:i,insert:i,update:i,replace:i,prepend:i,move:i};if(!n)return M("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),u;if(!t.unref(e))return M("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),u;const l=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(l)return l;let s=0;function d(){const r=w(null==n?void 0:n.values,t.unref(e),[])||[];a.value=r.map(f),c()}function c(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(r){const i=s++,u={key:i,value:t.computed({get(){const u=w(null==n?void 0:n.values,t.unref(e),[])||[],o=a.value.findIndex((e=>e.key===i));return-1===o?r:u[o]},set(e){const t=a.value.findIndex((e=>e.key===i));-1!==t?v(t,e):M("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return u}function v(r,a){const i=t.unref(e),u=w(null==n?void 0:n.values,i);!Array.isArray(u)||u.length-1<r||null==n||n.setFieldValue(`${i}[${r}]`,a)}d();const p={fields:a,remove:function(r){const i=t.unref(e),u=w(null==n?void 0:n.values,i);if(!u||!Array.isArray(u))return;const o=[...u];o.splice(r,1),null==n||n.unsetInitialValue(i+`[${r}]`),null==n||n.setFieldValue(i,o),a.value.splice(r,1),c()},push:function(i){const u=t.unref(e),o=w(null==n?void 0:n.values,u),l=r(o)?[]:o;if(!Array.isArray(l))return;const s=[...l];s.push(i),null==n||n.stageInitialValue(u+`[${s.length-1}]`,i),null==n||n.setFieldValue(u,s),a.value.push(f(i)),c()},swap:function(r,i){const u=t.unref(e),o=w(null==n?void 0:n.values,u);if(!Array.isArray(o)||!(r in o)||!(i in o))return;const l=[...o],s=[...a.value],d=l[r];l[r]=l[i],l[i]=d;const f=s[r];s[r]=s[i],s[i]=f,null==n||n.setFieldValue(u,l),a.value=s,c()},insert:function(r,i){const u=t.unref(e),o=w(null==n?void 0:n.values,u);if(!Array.isArray(o)||o.length<r)return;const l=[...o],s=[...a.value];l.splice(r,0,i),s.splice(r,0,f(i)),null==n||n.setFieldValue(u,l),a.value=s,c()},update:v,replace:function(r){const a=t.unref(e);null==n||n.setFieldValue(a,r),d()},prepend:function(i){const u=t.unref(e),o=w(null==n?void 0:n.values,u),l=r(o)?[]:o;if(!Array.isArray(l))return;const s=[i,...l];null==n||n.stageInitialValue(u+`[${s.length-1}]`,i),null==n||n.setFieldValue(u,s),a.value.unshift(f(i)),c()},move:function(i,u){const o=t.unref(e),l=w(null==n?void 0:n.values,o),s=r(l)?[]:[...l];if(!Array.isArray(l)||!(i in l)||!(u in l))return;const d=[...a.value],f=d[i];d.splice(i,1),d.splice(u,0,f);const v=s[i];s.splice(i,1),s.splice(u,0,v),null==n||n.setFieldValue(o,s),a.value=d,c()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},p)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),p}const ve=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:i,insert:u,replace:o,update:l,prepend:s,move:d,fields:c}=fe(t.toRef(e,"name"));function f(){return{fields:c.value,push:r,remove:a,swap:i,insert:u,update:l,replace:o,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:i,insert:u,update:l,replace:o,prepend:s,move:d}),()=>N(void 0,n,f)}}),pe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(o,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function i(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=N(r,n,i),o=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,o,u):t.h(r||"span",o,a.value):u}}});e.ErrorMessage=pe,e.Field=oe,e.FieldArray=ve,e.FieldContextKey=l,e.Form=ce,e.FormContextKey=o,e.IS_ABSENT=s,e.configure=G,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),u[e]=t},e.useField=ne,e.useFieldArray=fe,e.useFieldError=function(e){const n=I(o),r=e?void 0:t.inject(l);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=I(o),r=e?void 0:t.inject(l);return t.computed((()=>e?w(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=se,e.useFormErrors=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=T(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.dirty:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldTouched=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=T(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.touched:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldValid=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=T(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.valid:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFormDirty=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=I(o);t||M("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=I(o);let r=e?void 0:t.inject(l);return function(){return e&&(r=T(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.validate():(M(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=X,Object.defineProperty(e,"__esModule",{value:!0})}));
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function u(e){return Number(e)>=0}const i={};const o=Symbol("vee-validate-form"),l=Symbol("vee-validate-field-instance"),s=Symbol("Default empty value"),c="undefined"!=typeof window;function d(e){return n(e)&&!!e.__locatorRef}function f(e){return!!e&&n(e.validate)}function v(e){return"checkbox"===e||"radio"===e}function p(e){return Array.isArray(e)?0===e.length:a(e)&&0===Object.keys(e).length}function m(e){return/^\[.+\]$/i.test(e)}function y(e){return"SELECT"===e.tagName}function h(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&&!v(t.type)}function g(e){return b(e)&&e.target&&"submit"in e.target}function b(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function O(e,t){return t in e&&e[t]!==s}function V(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!V(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(!V(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var u=a[r];if(!V(e[u],t[u]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!c&&e instanceof File}var F=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,a,u;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(a=r;0!=a--;)if(!e(t[a],n[a]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(u=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(a=r;0!=a--;)if(!Object.prototype.hasOwnProperty.call(n,u[a]))return!1;for(a=r;0!=a--;){var i=u[a];if(!e(t[i],n[i]))return!1}return!0}return t!=t&&n!=n};function j(e){return m(e)?e.replace(/\[|\]/gi,""):e}function w(e,t,n){if(!e)return n;if(m(t))return e[j(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function E(e,t,n){if(m(t))return void(e[j(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=u(a[e+1])?[]:{}),i=i[a[e]]}}function S(e,t){Array.isArray(e)&&u(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function k(e,t){if(m(t))return void delete e[j(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){S(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>w(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)p(u[t])&&(0!==t?S(u[t-1],n[t-1]):S(e,n[0]))}function B(e){return Object.keys(e)}function I(e,n){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function M(e){t.warn(`[vee-validate]: ${e}`)}function C(e){return Array.isArray(e)?e[0]:e}function T(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>F(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return F(e,t)?n:t}function R(e,t=0){let n=null,r=[];return function(...a){return n&&window.clearTimeout(n),n=window.setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function P(e,t){let n;return async function(...r){const a=e(...r);n=a;const u=await a;return a!==n||(n=void 0,t(u,r)),u}}const N=(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 _(e){if(U(e))return e._value}function U(e){return"_value"in e}function $(e){if(!b(e))return e;const t=e.target;if(v(t.type)&&U(t))return _(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(y(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(_);var n;if(y(t)){const e=Array.from(t.options).find((e=>e.selected));return e?_(e):t.value}return t.value}function D(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=z(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=q(t);return n.name?(e[n.name]=z(n.params),e):e}),t):t}function z(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>w(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const q=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let L=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const K=()=>L,G=e=>{L=Object.assign(Object.assign({},L),e)};async function X(e,t,r={}){const a=null==r?void 0:r.bails,u={name:(null==r?void 0:r.name)||"{field}",rules:t,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(f(e.rules))return async function(e,t,n){var r;return{errors:await t.validate(e,{abortEarly:null===(r=n.bails)||void 0===r||r}).then((()=>[])).catch((e=>{if("ValidationError"===e.name)return e.errors;throw e}))}}(t,e.rules,{bails:e.bails});if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.name,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,u=[];for(let i=0;i<a;i++){const a=r[i],o=await a(t,n);if("string"!=typeof o&&o)continue;const l="string"==typeof o?o:J(n);if(u.push(l),e.bails)return{errors:u}}return{errors:u}}const r=Object.assign(Object.assign({},e),{rules:D(e.rules)}),a=[],u=Object.keys(r.rules),i=u.length;for(let n=0;n<i;n++){const i=u[n],o=await H(r,t,{name:i,params:r.rules[i]});if(o.error&&(a.push(o.error),e.bails))return{errors:a}}return{errors:a}}(u,e),o=i.errors;return{errors:o,valid:!o.length}}async function H(e,t,n){const r=(a=n.name,i[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const u=function(e,t){const n=e=>d(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),o={field:e.name,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:u})},l=await r(t,u,o);return"string"==typeof l?{error:l}:{error:l?void 0:J(o)}}function J(e){const t=K().generateMessage;return t?t(e):"Field is invalid"}async function Q(e,t,n){const r=B(e).map((async r=>{var a,u,i;const o=await X(w(t,r),e[r],{name:(null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r])||r,values:t,bails:null===(i=null===(u=null==n?void 0:n.bailsMap)||void 0===u?void 0:u[r])||void 0===i||i});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const u=await Promise.all(r),i={},o={};for(const e of u)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,o[e.path]=e.errors[0]);return{valid:a,results:i,errors:o}}function W(e,t,n){"object"==typeof n.value&&(n.value=Y(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function Y(e){if("object"!=typeof e)return e;var t,n,r,a=0,u=Object.prototype.toString.call(e);if("[object Object]"===u?r=Object.create(e.__proto__||null):"[object Array]"===u?r=Array(e.length):"[object Set]"===u?(r=new Set,e.forEach((function(e){r.add(Y(e))}))):"[object Map]"===u?(r=new Map,e.forEach((function(e,t){r.set(Y(t),Y(e))}))):"[object Date]"===u?r=new Date(+e):"[object RegExp]"===u?r=new RegExp(e.source,e.flags):"[object DataView]"===u?r=new e.constructor(Y(e.buffer)):"[object ArrayBuffer]"===u?r=e.slice(0):"Array]"===u.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)W(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||W(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}let Z=0;function ee(e,n){const{value:r,initialValue:a,setInitialValue:u}=te(e,n.modelValue,n.form),{errorMessage:i,errors:o,setErrors:l}=function(e,n){function r(e){return e?Array.isArray(e)?e:[e]:[]}if(!n){const e=t.ref([]);return{errors:e,errorMessage:t.computed((()=>e.value[0])),setErrors:t=>{e.value=r(t)}}}const a=t.computed((()=>n.errorBag.value[t.unref(e)]||[]));return{errors:a,errorMessage:t.computed((()=>a.value[0])),setErrors:a=>{n.setFieldErrorBag(t.unref(e),r(a))}}}(e,n.form),s=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!V(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);return{id:Z>=Number.MAX_SAFE_INTEGER?0:++Z,path:e,value:r,initialValue:a,meta:s,errors:o,errorMessage:i,setState:function(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&l(e.errors),"touched"in e&&(s.touched=null!==(t=e.touched)&&void 0!==t?t:s.touched),"initialValue"in e&&u(e.initialValue)}}}function te(e,n,r){const a=t.ref(t.unref(n));function u(){return r?w(r.meta.value.initialValues,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const o=t.computed(u);if(!r){return{value:t.ref(u()),initialValue:o,setInitialValue:i}}const l=n?t.unref(n):w(r.values,t.unref(e),t.unref(o));r.stageInitialValue(t.unref(e),l,!0);return{value:t.computed({get:()=>w(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n)}}),initialValue:o,setInitialValue:i}}function ne(e,n,r){return v(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:I(o),u=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function l(e){const n=e.handleChange,r=t.computed((()=>{const n=t.unref(e.value),r=t.unref(u);return Array.isArray(n)?n.findIndex((e=>V(e,r)))>=0:V(r,n)}));function o(o,l=!0){var s;if(r.value===(null===(s=null==o?void 0:o.target)||void 0===s?void 0:s.checked))return void(l&&e.validate());let c=$(o);a||(c=T(t.unref(e.value),t.unref(u),t.unref(i))),n(c,l)}return Object.assign(Object.assign({},e),{checked:r,checkedValue:u,uncheckedValue:i,handleChange:o})}return l(re(e,n,r))}(e,n,r):re(e,n,r)}function re(e,r,a){const{initialValue:u,validateOnMount:i,bails:c,type:v,checkedValue:p,label:m,validateOnValueUpdate:y,uncheckedValue:h,controlled:g,keepValueOnUnmount:b,modelPropName:O,syncVModel:A,form:F}=function(e,t){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:e,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0,controlled:!0});if(!t)return n();const r="valueProp"in t?t.valueProp:t.checkedValue,a="standalone"in t?!t.standalone:t.controlled;return Object.assign(Object.assign(Object.assign({},n()),t||{}),{controlled:null==a||a,checkedValue:r})}(t.unref(e),a),j=g?I(o):void 0,E=F||j;let S=!1;const{id:k,value:M,initialValue:C,meta:T,setState:R,errors:N,errorMessage:_}=ee(e,{modelValue:u,form:E});A&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const u=e||"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{V(e,ae(a,u))||a.emit(i,e)})),t.watch((()=>ae(a,u)),(e=>{if(e===s&&void 0===n.value)return;const t=e===s?void 0:e;V(t,x(n.value,a.props.modelModifiers))||r(t)}))}({value:M,prop:O,handleChange:K});const U=t.computed((()=>{let a=t.unref(r);const u=t.unref(null==E?void 0:E.schema);return u&&!f(u)&&(a=function(e,t){if(!e)return;return e[t]}(u,t.unref(e))||a),f(a)||n(a)||Array.isArray(a)?a:D(a)}));async function z(n){var r,a;return(null==E?void 0:E.validateSchema)?null!==(r=(await E.validateSchema(n)).results[t.unref(e)])&&void 0!==r?r:{valid:!0,errors:[]}:X(M.value,U.value,{name:t.unref(m)||t.unref(e),values:null!==(a=null==E?void 0:E.values)&&void 0!==a?a:{},bails:c})}const q=P((async()=>(T.pending=!0,T.validated=!0,z("validated-only"))),(e=>(S&&(e.valid=!0,e.errors=[]),R({errors:e.errors}),T.pending=!1,e))),L=P((async()=>z("silent")),(e=>(S&&(e.valid=!0),T.valid=e.valid,e)));function K(e,t=!0){const n=$(e);M.value=n,!y&&t&&q()}let G;t.onMounted((()=>{if(i)return q();E&&E.validateSchema||L()}));let H=Y(M.value);function J(){G=t.watch(M,((e,t)=>{if(V(e,t)&&V(e,H))return;(y?q:L)(),H=Y(e)}),{deep:!0})}function Q(e){var n;null==G||G();const r=e&&"value"in e?e.value:C.value;R({value:Y(r),initialValue:Y(r),touched:null!==(n=null==e?void 0:e.touched)&&void 0!==n&&n,errors:(null==e?void 0:e.errors)||[]}),T.pending=!1,T.validated=!1,L(),t.nextTick((()=>{J()}))}J();const W={id:k,name:e,label:m,value:M,meta:T,errors:N,errorMessage:_,type:v,checkedValue:p,uncheckedValue:h,bails:c,keepValueOnUnmount:b,resetField:Q,handleReset:()=>Q(),validate:function(e){return"silent"===(null==e?void 0:e.mode)?L():q()},handleChange:K,handleBlur:()=>{T.touched=!0},setState:R,setTouched:function(e){T.touched=e},setErrors:function(e){R({errors:Array.isArray(e)?e:[e]})},setValue:function(e){M.value=e}};if(t.provide(l,W),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{V(e,t)||(T.validated?q():L())}),{deep:!0}),!E)return W;E.register(W),t.onBeforeUnmount((()=>{S=!0,E.unregister(W)}));const Z=t.computed((()=>{const e=U.value;return!e||n(e)||f(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(d):B(a).filter((e=>d(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=w(E.values,t)||E.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(Z,((e,t)=>{if(!Object.keys(e).length)return;!V(e,t)&&(T.validated?q():L())})),W}function ae(e,t){return e.props[t]}function ue(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ie(e,t){return v(t.attrs.type)?O(e,"modelValue")?e.modelValue:void 0:O(e,"modelValue")?e.modelValue:t.attrs.value}const oe=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:()=>K().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:s},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,n){const r=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:l,value:s,errorMessage:c,validate:d,handleChange:f,handleBlur:p,setTouched:m,resetField:y,handleReset:g,meta:b,checked:O,setErrors:V}=ne(a,r,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:n.attrs.type,initialValue:ie(e,n),checkedValue:n.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:!1,keepValueOnUnmount:o}),A=function(e,t=!0){f(e,t),n.emit("update:modelValue",s.value)},F=function(e){(e=>{v(n.attrs.type)||(s.value=$(e))})(e),n.emit("update:modelValue",s.value)},j=t.computed((()=>{const{validateOnInput:t,validateOnChange:r,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,a;const{validateOnInput:u,validateOnChange:i,validateOnBlur:o,validateOnModelUpdate:l}=K();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:u,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:o,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:l}}(e),i=[p,n.attrs.onBlur,a?d:void 0].filter(Boolean),o=[e=>A(e,t),n.attrs.onInput].filter(Boolean),l=[e=>A(e,r),n.attrs.onChange].filter(Boolean),c={name:e.name,onBlur:i,onInput:o,onChange:l,"onUpdate:modelValue":e=>A(e,u)};v(n.attrs.type)&&O&&(c.checked=O.value);return h(ue(e,n),n.attrs)&&(c.value=s.value),c}));function w(){return{field:j.value,value:s.value,meta:b,errors:l.value,errorMessage:c.value,validate:d,resetField:y,handleChange:A,handleInput:F,handleReset:g,handleBlur:p,setTouched:m,setErrors:V}}return n.expose({setErrors:V,setTouched:m,reset:y,validate:d,handleChange:f}),()=>{const r=t.resolveDynamicComponent(ue(e,n)),a=N(r,n,w);return r?t.h(r,Object.assign(Object.assign({},n.attrs),j.value),a):a}}});let le=0;function se(e){var n;const r=le++,a=new Set;let u=!1;const i=t.ref({}),l=t.ref(!1),s=t.ref(0),c=[],d=t.reactive(Y(t.unref(null==e?void 0:e.initialValues)||{})),{errorBag:v,setErrorBag:m,setFieldErrorBag:y}=function(e){const n=t.ref({});function r(e){return Array.isArray(e)?e:e?[e]:[]}function a(e,t){t?n.value[e]=r(t):delete n.value[e]}function u(e){n.value=B(e).reduce(((t,n)=>{const a=e[n];return a&&(t[n]=r(a)),t}),{})}e&&u(e);return{errorBag:n,setErrorBag:u,setFieldErrorBag:a}}(null==e?void 0:e.initialErrors),h=t.computed((()=>B(v.value).reduce(((e,t)=>{const n=v.value[t];return n&&n.length&&(e[t]=n[0]),e}),{})));function b(e){const t=i.value[e];return Array.isArray(t)?t[0]:t}function O(e){return!!i.value[e]}const A=t.computed((()=>B(i.value).reduce(((e,n)=>{const r=b(n);return r&&(e[n]=t.unref(r.label||r.name)||""),e}),{}))),F=t.computed((()=>B(i.value).reduce(((e,t)=>{var n;const r=b(t);return r&&(e[t]=null===(n=r.bails)||void 0===n||n),e}),{}))),j=Object.assign({},(null==e?void 0:e.initialErrors)||{}),S=null!==(n=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==n&&n,{initialValues:I,originalInitialValues:M,setInitialValues:C}=function(e,n,r){const a=t.ref(Y(t.unref(r))||{}),u=t.ref(Y(t.unref(r))||{});function i(t,r=!1){a.value=Y(t),u.value=Y(t),r&&B(e.value).forEach((t=>{const r=e.value[t],u=Array.isArray(r)?r.some((e=>e.meta.touched)):null==r?void 0:r.meta.touched;if(!r||u)return;const i=w(a.value,t);E(n,t,Y(i))}))}t.isRef(r)&&t.watch(r,(e=>{i(e,!0)}),{deep:!0});return{initialValues:a,originalInitialValues:u,setInitialValues:i}}(i,d,null==e?void 0:e.initialValues),x=function(e,n,r,a){const u={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!V(n,t.unref(r))));function o(){const t=Object.values(e.value).flat(1).filter(Boolean);return B(u).reduce(((e,n)=>{const r=u[n];return e[n]=t[r]((e=>e.meta[n])),e}),{})}const l=t.reactive(o());return t.watchEffect((()=>{const e=o();l.touched=e.touched,l.valid=e.valid,l.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},l),{valid:l.valid&&!B(a.value).length,dirty:i.value})))}(i,d,M,h),N=t.computed((()=>[...a,...B(i.value)].reduce(((e,t)=>(E(e,t,w(d,t)),e)),{}))),_=null==e?void 0:e.validationSchema,U=R(de,5),$=R(de,5),D=P((async e=>"silent"===await e?U():$()),((e,[t])=>{const n=L.fieldsByPath.value||{},r=B(L.errorBag.value);return[...new Set([...B(e.results),...B(n),...r])].reduce(((r,a)=>{const u=n[a],i=(e.results[a]||{errors:[]}).errors,o={errors:i,valid:!i.length};if(r.results[a]=o,o.valid||(r.errors[a]=o.errors[0]),!u)return H(a,i),r;if(G(u,(e=>e.meta.valid=o.valid)),"silent"===t)return r;const l=Array.isArray(u)?u.some((e=>e.meta.validated)):u.meta.validated;return"validated-only"!==t||l?(G(u,(e=>e.setState({errors:o.errors}))),r):r}),{valid:e.valid,results:{},errors:{}})}));function z(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),re(B(i.value).reduce(((e,t)=>(e[t]=!0,e)),{})),l.value=!0,s.value++,oe().then((a=>{const u=Y(d);if(a.valid&&"function"==typeof t){const n=Y(N.value);return t(e?n:u,{evt:r,controlledValues:n,setErrors:J,setFieldError:H,setTouched:re,setFieldTouched:ne,setValues:Z,setFieldValue:W,resetForm:ae})}a.valid||"function"!=typeof n||n({values:u,evt:r,errors:a.errors,results:a.results})})).then((e=>(l.value=!1,e)),(e=>{throw l.value=!1,e}))}}}const q=z(!1);q.withControlled=z(!0);const L={formId:r,fieldsByPath:i,values:d,controlledValues:N,errorBag:v,errors:h,schema:_,submitCount:s,meta:x,isSubmitting:l,fieldArrays:c,keepValuesOnUnmount:S,validateSchema:t.unref(_)?D:void 0,validate:oe,register:function(e){const n=t.unref(e.name);ue(e,n),t.isRef(e.name)&&t.watch(e.name,(async(n,r)=>{await t.nextTick(),ie(e,r),ue(e,n),(h.value[r]||h.value[n])&&(H(r,void 0),se(n)),await t.nextTick(),O(r)||k(d,r)}));const r=t.unref(e.errorMessage);r&&(null==j?void 0:j[n])!==r&&se(n);delete j[n]},unregister:function(e){const n=t.unref(e.name),r=i.value[n],a=!!r&&K(r);ie(e,n),t.nextTick((()=>{var u;const o=null!==(u=t.unref(e.keepValueOnUnmount))&&void 0!==u?u:t.unref(S),l=w(d,n);if(a&&(r===i.value[n]||!i.value[n])&&Array.isArray(l)&&!o){const r=l.findIndex((n=>V(n,t.unref(e.checkedValue))));if(r>-1){const e=[...l];e.splice(r,1),W(n,e,{force:!0})}}if(!O(n)){if(H(n,void 0),o)return;if(a&&!p(w(d,n)))return;k(d,n)}}))},setFieldErrorBag:y,validateField:se,setFieldValue:W,setValues:Z,setErrors:J,setFieldError:H,setFieldTouched:ne,setTouched:re,resetForm:ae,handleSubmit:q,stageInitialValue:function(t,n,r=!1){E(d,t,n),ce(t,n),r&&!(null==e?void 0:e.initialValues)&&E(M.value,t,Y(n))},unsetInitialValue:function(e){k(I.value,e)},setFieldInitialValue:ce,useFieldModel:function(e){if(!Array.isArray(e))return ee(e);return e.map(ee)}};function K(e){return Array.isArray(e)}function G(e,t){return Array.isArray(e)?e.forEach(t):t(e)}function X(e){Object.values(i.value).forEach((t=>{t&&G(t,e)}))}function H(e,t){y(e,t)}function J(e){m(e)}function W(e,n,{force:r}={force:!1}){var a;const o=i.value[e],l=Y(n);if(!o)return void E(d,e,l);if(K(o)&&"checkbox"===(null===(a=o[0])||void 0===a?void 0:a.type)&&!Array.isArray(n)){const t=Y(T(w(d,e)||[],n,void 0));return void E(d,e,t)}let s=n;K(o)||"checkbox"!==o.type||r||u||(s=Y(T(w(d,e),n,t.unref(o.uncheckedValue)))),E(d,e,s)}function Z(e){B(d).forEach((e=>{delete d[e]})),B(e).forEach((t=>{W(t,e[t])})),c.forEach((e=>e&&e.reset()))}function ee(e){const{value:n}=te(e,void 0,L);return t.watch(n,(()=>{O(t.unref(e))||oe({mode:"validated-only"})}),{deep:!0}),a.add(t.unref(e)),n}function ne(e,t){const n=i.value[e];n&&G(n,(e=>e.setTouched(t)))}function re(e){B(e).forEach((t=>{ne(t,!!e[t])}))}function ae(e){u=!0,X((e=>e.resetField())),(null==e?void 0:e.values)?(C(e.values),Z(null==e?void 0:e.values)):(C(M.value),Z(M.value)),(null==e?void 0:e.touched)&&re(e.touched),J((null==e?void 0:e.errors)||{}),s.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{u=!1}))}function ue(e,n){const r=t.markRaw(e),a=n;if(!i.value[a])return void(i.value[a]=r);const u=i.value[a];u&&!Array.isArray(u)&&(i.value[a]=[u]),i.value[a]=[...i.value[a],r]}function ie(e,t){const n=t,r=i.value[n];if(r)if(K(r)||e.id!==r.id){if(K(r)){const t=r.findIndex((t=>t.id===e.id));if(-1===t)return;r.splice(t,1),r.length||delete i.value[n]}}else delete i.value[n]}async function oe(e){if(X((e=>e.meta.validated=!0)),L.validateSchema)return L.validateSchema((null==e?void 0:e.mode)||"force");const n=await Promise.all(Object.values(i.value).map((n=>{const r=Array.isArray(n)?n[0]:n;return r?r.validate(e).then((e=>({key:t.unref(r.name),valid:e.valid,errors:e.errors}))):Promise.resolve({key:"",valid:!0,errors:[]})}))),r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function se(e){const n=i.value[e];return n?Array.isArray(n)?n.map((e=>e.validate()))[0]:n.validate():(t.warn(`field with name ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function ce(e,t){E(I.value,e,Y(t))}async function de(){const e=t.unref(_);if(!e)return{valid:!0,results:{},errors:{}};const n=f(e)?await async function(e,t){const n=await e.validate(t,{abortEarly:!1}).then((()=>[])).catch((e=>{if("ValidationError"!==e.name)throw e;return e.inner||[]})),r={},a={};for(const e of n){const t=e.errors;r[e.path]={valid:!t.length,errors:t},t.length&&(a[e.path]=t[0])}return{valid:!n.length,results:r,errors:a}}(e,d):await Q(e,d,{names:A.value,bailsMap:F.value});return n}const fe=q(((e,{evt:t})=>{g(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&J(e.initialErrors),(null==e?void 0:e.initialTouched)&&re(e.initialTouched),(null==e?void 0:e.validateOnMount)?oe():L.validateSchema&&L.validateSchema("silent")})),t.isRef(_)&&t.watch(_,(()=>{var e;null===(e=L.validateSchema)||void 0===e||e.call(L,"validated-only")})),t.provide(o,L),Object.assign(Object.assign({},L),{handleReset:()=>ae(),submitForm:fe})}const ce=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),u=t.toRef(e,"keepValues"),{errors:i,values:o,meta:l,isSubmitting:s,submitCount:c,controlledValues:d,validate:f,validateField:v,handleReset:p,resetForm:m,handleSubmit:y,setErrors:h,setFieldError:O,setFieldValue:V,setValues:A,setFieldTouched:F,setTouched:j}=se({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:u}),w=y(((e,{evt:t})=>{g(t)&&t.target.submit()}),e.onInvalidSubmit),E=e.onSubmit?y(e.onSubmit,e.onInvalidSubmit):w;function S(e){b(e)&&e.preventDefault(),p(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function k(t,n){return y("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function B(){return{meta:l.value,errors:i.value,values:o,isSubmitting:s.value,submitCount:c.value,controlledValues:d.value,validate:f,validateField:v,handleSubmit:k,handleReset:p,submitForm:w,setErrors:h,setFieldError:O,setFieldValue:V,setValues:A,setFieldTouched:F,setTouched:j,resetForm:m}}return n.expose({setFieldError:O,setErrors:h,setFieldValue:V,setValues:A,setFieldTouched:F,setTouched:j,resetForm:m,validate:f,validateField:v}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=N(r,n,B);if(!e.as)return a;const u="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},u),n.attrs),{onSubmit:E,onReset:S}),a)}}}),de=ce;function fe(e){const n=I(o,void 0),a=t.ref([]),u=()=>{},i={fields:a,remove:u,push:u,swap:u,insert:u,update:u,replace:u,prepend:u,move:u};if(!n)return M("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),i;if(!t.unref(e))return M("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const l=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(l)return l;let s=0;function c(){const r=w(null==n?void 0:n.values,t.unref(e),[])||[];a.value=r.map(f),d()}function d(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(r){const u=s++,i={key:u,value:t.computed({get(){const i=w(null==n?void 0:n.values,t.unref(e),[])||[],o=a.value.findIndex((e=>e.key===u));return-1===o?r:i[o]},set(e){const t=a.value.findIndex((e=>e.key===u));-1!==t?v(t,e):M("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return i}function v(r,a){const u=t.unref(e),i=w(null==n?void 0:n.values,u);!Array.isArray(i)||i.length-1<r||null==n||n.setFieldValue(`${u}[${r}]`,a)}c();const p={fields:a,remove:function(r){const u=t.unref(e),i=w(null==n?void 0:n.values,u);if(!i||!Array.isArray(i))return;const o=[...i];o.splice(r,1),null==n||n.unsetInitialValue(u+`[${r}]`),null==n||n.setFieldValue(u,o),a.value.splice(r,1),d()},push:function(u){const i=t.unref(e),o=w(null==n?void 0:n.values,i),l=r(o)?[]:o;if(!Array.isArray(l))return;const s=[...l];s.push(u),null==n||n.stageInitialValue(i+`[${s.length-1}]`,u),null==n||n.setFieldValue(i,s),a.value.push(f(u)),d()},swap:function(r,u){const i=t.unref(e),o=w(null==n?void 0:n.values,i);if(!Array.isArray(o)||!(r in o)||!(u in o))return;const l=[...o],s=[...a.value],c=l[r];l[r]=l[u],l[u]=c;const f=s[r];s[r]=s[u],s[u]=f,null==n||n.setFieldValue(i,l),a.value=s,d()},insert:function(r,u){const i=t.unref(e),o=w(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const l=[...o],s=[...a.value];l.splice(r,0,u),s.splice(r,0,f(u)),null==n||n.setFieldValue(i,l),a.value=s,d()},update:v,replace:function(r){const a=t.unref(e);null==n||n.setFieldValue(a,r),c()},prepend:function(u){const i=t.unref(e),o=w(null==n?void 0:n.values,i),l=r(o)?[]:o;if(!Array.isArray(l))return;const s=[u,...l];null==n||n.stageInitialValue(i+`[${s.length-1}]`,u),null==n||n.setFieldValue(i,s),a.value.unshift(f(u)),d()},move:function(u,i){const o=t.unref(e),l=w(null==n?void 0:n.values,o),s=r(l)?[]:[...l];if(!Array.isArray(l)||!(u in l)||!(i in l))return;const c=[...a.value],f=c[u];c.splice(u,1),c.splice(i,0,f);const v=s[u];s.splice(u,1),s.splice(i,0,v),null==n||n.setFieldValue(o,s),a.value=c,d()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},p)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),p}const ve=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:u,insert:i,replace:o,update:l,prepend:s,move:c,fields:d}=fe(t.toRef(e,"name"));function f(){return{fields:d.value,push:r,remove:a,swap:u,insert:i,update:l,replace:o,prepend:s,move:c}}return n.expose({push:r,remove:a,swap:u,insert:i,update:l,replace:o,prepend:s,move:c}),()=>N(void 0,n,f)}}),pe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(o,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function u(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=N(r,n,u),o=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,o,i):t.h(r||"span",o,a.value):i}}});e.ErrorMessage=pe,e.Field=oe,e.FieldArray=ve,e.FieldContextKey=l,e.Form=de,e.FormContextKey=o,e.IS_ABSENT=s,e.configure=G,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),i[e]=t},e.useField=ne,e.useFieldArray=fe,e.useFieldError=function(e){const n=I(o),r=e?void 0:t.inject(l);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=I(o),r=e?void 0:t.inject(l);return t.computed((()=>e?w(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=se,e.useFormErrors=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=C(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.dirty:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldTouched=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=C(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.touched:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldValid=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=C(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.valid:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFormDirty=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=I(o);t||M("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=I(o);let r=e?void 0:t.inject(l);return function(){return e&&(r=C(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.validate():(M(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=X,Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vee-validate",
3
- "version": "4.6.10",
3
+ "version": "4.7.0",
4
4
  "description": "Form Validation for Vue.js",
5
5
  "author": "Abdelrahman Awad <logaretm1@gmail.com>",
6
6
  "license": "MIT",
@@ -33,5 +33,5 @@
33
33
  "dependencies": {
34
34
  "@vue/devtools-api": "^6.1.4"
35
35
  },
36
- "gitHead": "844faec4d8937fbb1a68f4e6667ed3851a0a3e9e"
36
+ "gitHead": "45e0b22343b4bb60422b21179b156b9a2c342054"
37
37
  }