vee-validate 4.6.1 → 4.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -20
- package/dist/vee-validate.d.ts +1 -1
- package/dist/vee-validate.esm.js +26 -17
- package/dist/vee-validate.js +26 -17
- package/dist/vee-validate.min.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,38 +5,35 @@
|
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
|
|
9
|
-
[](https://npm-stat.com/charts.html?package=vee-validate 'Go to NPM stats')
|
|
10
|
-
[](https://cdnjs.com/libraries/vee-validate/ 'Download using CDNJS')
|
|
11
|
-
[](https://www.npmjs.com/package/vee-validate 'Go to package on NPM')
|
|
12
|
-
|
|
8
|
+
Painless Vue forms with declarative and composition toolkit
|
|
13
9
|
</p>
|
|
14
10
|
|
|
15
|
-
<
|
|
11
|
+
<p align="center">
|
|
16
12
|
|
|
17
|
-
|
|
13
|
+
<a target="_blank" href="https://www.npmjs.com/package/vee-validate">
|
|
14
|
+
<img src="https://img.shields.io/npm/v/vee-validate.svg?label=&color=05bda8">
|
|
15
|
+
</a>
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
<a target="_blank" href="https://npm-stat.com/charts.html?package=vee-validate">
|
|
18
|
+
<img src="https://img.shields.io/npm/dm/vee-validate.svg?color=05bd6d&label=">
|
|
19
|
+
</a>
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
<a href="https://vee-validate.logaretm.com/v4/" target="_blank">
|
|
22
|
+
<img src="https://img.shields.io/badge/-docs%20and%20demos-009f53">
|
|
23
|
+
</a>
|
|
22
24
|
|
|
23
|
-
<
|
|
25
|
+
<a href="https://github.com/sponsors/logaretm">
|
|
26
|
+
<img src="https://img.shields.io/badge/-%E2%99%A5%20Sponsors-ec5cc6">
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
<a href="https://getform.io" target="_blank">
|
|
27
|
-
<img src="https://raw.githubusercontent.com/logaretm/vee-validate/main/docs/assets/img/sponsors/getform.svg" width="230" title="Go to getform.io">
|
|
28
|
-
</a>
|
|
29
|
-
</p>
|
|
28
|
+
</a>
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
You can also help this this project and my other projects by donating one time or by sponsoring via the following link
|
|
30
|
+
</p>
|
|
34
31
|
|
|
35
32
|
<br>
|
|
36
33
|
|
|
37
34
|
<p align="center">
|
|
38
|
-
<a href="https://
|
|
39
|
-
|
|
35
|
+
<a href="https://github.com/sponsors/logaretm">
|
|
36
|
+
<img src='https://sponsors.logaretm.com/sponsors.svg'>
|
|
40
37
|
</a>
|
|
41
38
|
</p>
|
|
42
39
|
|
package/dist/vee-validate.d.ts
CHANGED
|
@@ -1183,4 +1183,4 @@ declare const FormContextKey: InjectionKey<PrivateFormContext>;
|
|
|
1183
1183
|
declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
|
|
1184
1184
|
declare const IS_ABSENT: unique symbol;
|
|
1185
1185
|
|
|
1186
|
-
export { ErrorMessage, Field, FieldArray, FieldArrayContext, FieldContext, FieldContextKey, FieldEntry, FieldMeta, Form, FormActions, FormContext, FormContextKey, FormMeta, FormState, FormValidationResult, IS_ABSENT, InvalidSubmissionContext, SubmissionContext, SubmissionHandler, ValidationOptions$1 as ValidationOptions, ValidationResult, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate };
|
|
1186
|
+
export { ErrorMessage, Field, FieldArray, FieldArrayContext, FieldContext, FieldContextKey, FieldEntry, FieldMeta, FieldOptions, Form, FormActions, FormContext, FormContextKey, FormMeta, FormOptions, FormState, FormValidationResult, GenericValidateFunction, IS_ABSENT, InvalidSubmissionContext, InvalidSubmissionHandler, SubmissionContext, SubmissionHandler, ValidationOptions$1 as ValidationOptions, ValidationResult, configure, defineRule, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useResetForm, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate };
|
package/dist/vee-validate.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.6.
|
|
2
|
+
* vee-validate v4.6.4
|
|
3
3
|
* (c) 2022 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -1582,14 +1582,6 @@ function useCheckboxField(name, rules, opts) {
|
|
|
1582
1582
|
}
|
|
1583
1583
|
handleChange(newValue, shouldValidate);
|
|
1584
1584
|
}
|
|
1585
|
-
onBeforeUnmount(() => {
|
|
1586
|
-
var _a, _b;
|
|
1587
|
-
const shouldKeepValue = (_b = (_a = unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : unref(form === null || form === void 0 ? void 0 : form.keepValuesOnUnmount)) !== null && _b !== void 0 ? _b : false;
|
|
1588
|
-
// toggles the checkbox value if it was checked and the unset behavior is set
|
|
1589
|
-
if (checked.value && !shouldKeepValue) {
|
|
1590
|
-
handleCheckboxChange(unref(checkedValue), false);
|
|
1591
|
-
}
|
|
1592
|
-
});
|
|
1593
1585
|
return Object.assign(Object.assign({}, field), { checked,
|
|
1594
1586
|
checkedValue,
|
|
1595
1587
|
uncheckedValue, handleChange: handleCheckboxChange });
|
|
@@ -1990,6 +1982,8 @@ function useForm(opts) {
|
|
|
1990
1982
|
if (!fieldExists(unref(path))) {
|
|
1991
1983
|
validate({ mode: 'validated-only' });
|
|
1992
1984
|
}
|
|
1985
|
+
}, {
|
|
1986
|
+
deep: true,
|
|
1993
1987
|
});
|
|
1994
1988
|
return value;
|
|
1995
1989
|
}
|
|
@@ -2075,10 +2069,6 @@ function useForm(opts) {
|
|
|
2075
2069
|
return;
|
|
2076
2070
|
}
|
|
2077
2071
|
fieldAtPath.splice(idx, 1);
|
|
2078
|
-
if (fieldAtPath.length === 1) {
|
|
2079
|
-
fieldsByPath.value[fieldPath] = fieldAtPath[0];
|
|
2080
|
-
return;
|
|
2081
|
-
}
|
|
2082
2072
|
if (!fieldAtPath.length) {
|
|
2083
2073
|
delete fieldsByPath.value[fieldPath];
|
|
2084
2074
|
}
|
|
@@ -2124,17 +2114,36 @@ function useForm(opts) {
|
|
|
2124
2114
|
const fieldInstance = fieldsByPath.value[fieldName];
|
|
2125
2115
|
const isGroup = !!fieldInstance && isFieldGroup(fieldInstance);
|
|
2126
2116
|
removeFieldFromPath(field, fieldName);
|
|
2117
|
+
// clears a field error on unmounted
|
|
2118
|
+
// we wait till next tick to make sure if the field is completely removed and doesn't have any siblings like checkboxes
|
|
2127
2119
|
nextTick(() => {
|
|
2128
2120
|
var _a;
|
|
2129
|
-
|
|
2130
|
-
|
|
2121
|
+
const shouldKeepValue = (_a = unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : unref(keepValuesOnUnmount);
|
|
2122
|
+
const currentGroupValue = getFromPath(formValues, fieldName);
|
|
2123
|
+
// The boolean here is we check if the field still belongs to the same control group with that name
|
|
2124
|
+
// if another group claimed the name, we should avoid handling it since it is no longer the same group
|
|
2125
|
+
// this happens with `v-for` over some checkboxes and field arrays.
|
|
2126
|
+
// also if the group no longer exist we can assume this group was the last one that controlled it
|
|
2127
|
+
const isSameGroup = isGroup && (fieldInstance === fieldsByPath.value[fieldName] || !fieldsByPath.value[fieldName]);
|
|
2128
|
+
// group field that still has a dangling value, the field may exist or not after it was removed.
|
|
2129
|
+
// This used to be handled in the useField composable but the form has better context on when it should/not happen.
|
|
2130
|
+
// if it does belong to it that means the group still exists
|
|
2131
|
+
// #3844
|
|
2132
|
+
if (isSameGroup && Array.isArray(currentGroupValue) && !shouldKeepValue) {
|
|
2133
|
+
const valueIdx = currentGroupValue.findIndex(i => es6(i, unref(field.checkedValue)));
|
|
2134
|
+
if (valueIdx > -1) {
|
|
2135
|
+
const newVal = [...currentGroupValue];
|
|
2136
|
+
newVal.splice(valueIdx, 1);
|
|
2137
|
+
setFieldValue(fieldName, newVal, { force: true });
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
// Field was removed entirely, we should unset its path
|
|
2131
2141
|
// #3384
|
|
2132
2142
|
if (!fieldExists(fieldName)) {
|
|
2133
2143
|
setFieldError(fieldName, undefined);
|
|
2134
2144
|
// Checks if the field was configured to be unset during unmount or not
|
|
2135
2145
|
// Checks both the form-level config and field-level one
|
|
2136
2146
|
// Field has the priority if it is set, otherwise it goes to the form settings
|
|
2137
|
-
const shouldKeepValue = (_a = unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : unref(keepValuesOnUnmount);
|
|
2138
2147
|
if (shouldKeepValue) {
|
|
2139
2148
|
return;
|
|
2140
2149
|
}
|
|
@@ -2250,7 +2259,7 @@ function useForm(opts) {
|
|
|
2250
2259
|
function stageInitialValue(path, value, updateOriginal = false) {
|
|
2251
2260
|
setInPath(formValues, path, value);
|
|
2252
2261
|
setFieldInitialValue(path, value);
|
|
2253
|
-
if (updateOriginal) {
|
|
2262
|
+
if (updateOriginal && !(opts === null || opts === void 0 ? void 0 : opts.initialValues)) {
|
|
2254
2263
|
setInPath(originalInitialValues.value, path, klona(value));
|
|
2255
2264
|
}
|
|
2256
2265
|
}
|
package/dist/vee-validate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.6.
|
|
2
|
+
* vee-validate v4.6.4
|
|
3
3
|
* (c) 2022 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -1198,14 +1198,6 @@
|
|
|
1198
1198
|
}
|
|
1199
1199
|
handleChange(newValue, shouldValidate);
|
|
1200
1200
|
}
|
|
1201
|
-
vue.onBeforeUnmount(() => {
|
|
1202
|
-
var _a, _b;
|
|
1203
|
-
const shouldKeepValue = (_b = (_a = vue.unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : vue.unref(form === null || form === void 0 ? void 0 : form.keepValuesOnUnmount)) !== null && _b !== void 0 ? _b : false;
|
|
1204
|
-
// toggles the checkbox value if it was checked and the unset behavior is set
|
|
1205
|
-
if (checked.value && !shouldKeepValue) {
|
|
1206
|
-
handleCheckboxChange(vue.unref(checkedValue), false);
|
|
1207
|
-
}
|
|
1208
|
-
});
|
|
1209
1201
|
return Object.assign(Object.assign({}, field), { checked,
|
|
1210
1202
|
checkedValue,
|
|
1211
1203
|
uncheckedValue, handleChange: handleCheckboxChange });
|
|
@@ -1603,6 +1595,8 @@
|
|
|
1603
1595
|
if (!fieldExists(vue.unref(path))) {
|
|
1604
1596
|
validate({ mode: 'validated-only' });
|
|
1605
1597
|
}
|
|
1598
|
+
}, {
|
|
1599
|
+
deep: true,
|
|
1606
1600
|
});
|
|
1607
1601
|
return value;
|
|
1608
1602
|
}
|
|
@@ -1688,10 +1682,6 @@
|
|
|
1688
1682
|
return;
|
|
1689
1683
|
}
|
|
1690
1684
|
fieldAtPath.splice(idx, 1);
|
|
1691
|
-
if (fieldAtPath.length === 1) {
|
|
1692
|
-
fieldsByPath.value[fieldPath] = fieldAtPath[0];
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
1685
|
if (!fieldAtPath.length) {
|
|
1696
1686
|
delete fieldsByPath.value[fieldPath];
|
|
1697
1687
|
}
|
|
@@ -1737,17 +1727,36 @@
|
|
|
1737
1727
|
const fieldInstance = fieldsByPath.value[fieldName];
|
|
1738
1728
|
const isGroup = !!fieldInstance && isFieldGroup(fieldInstance);
|
|
1739
1729
|
removeFieldFromPath(field, fieldName);
|
|
1730
|
+
// clears a field error on unmounted
|
|
1731
|
+
// we wait till next tick to make sure if the field is completely removed and doesn't have any siblings like checkboxes
|
|
1740
1732
|
vue.nextTick(() => {
|
|
1741
1733
|
var _a;
|
|
1742
|
-
|
|
1743
|
-
|
|
1734
|
+
const shouldKeepValue = (_a = vue.unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : vue.unref(keepValuesOnUnmount);
|
|
1735
|
+
const currentGroupValue = getFromPath(formValues, fieldName);
|
|
1736
|
+
// The boolean here is we check if the field still belongs to the same control group with that name
|
|
1737
|
+
// if another group claimed the name, we should avoid handling it since it is no longer the same group
|
|
1738
|
+
// this happens with `v-for` over some checkboxes and field arrays.
|
|
1739
|
+
// also if the group no longer exist we can assume this group was the last one that controlled it
|
|
1740
|
+
const isSameGroup = isGroup && (fieldInstance === fieldsByPath.value[fieldName] || !fieldsByPath.value[fieldName]);
|
|
1741
|
+
// group field that still has a dangling value, the field may exist or not after it was removed.
|
|
1742
|
+
// This used to be handled in the useField composable but the form has better context on when it should/not happen.
|
|
1743
|
+
// if it does belong to it that means the group still exists
|
|
1744
|
+
// #3844
|
|
1745
|
+
if (isSameGroup && Array.isArray(currentGroupValue) && !shouldKeepValue) {
|
|
1746
|
+
const valueIdx = currentGroupValue.findIndex(i => es6(i, vue.unref(field.checkedValue)));
|
|
1747
|
+
if (valueIdx > -1) {
|
|
1748
|
+
const newVal = [...currentGroupValue];
|
|
1749
|
+
newVal.splice(valueIdx, 1);
|
|
1750
|
+
setFieldValue(fieldName, newVal, { force: true });
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
// Field was removed entirely, we should unset its path
|
|
1744
1754
|
// #3384
|
|
1745
1755
|
if (!fieldExists(fieldName)) {
|
|
1746
1756
|
setFieldError(fieldName, undefined);
|
|
1747
1757
|
// Checks if the field was configured to be unset during unmount or not
|
|
1748
1758
|
// Checks both the form-level config and field-level one
|
|
1749
1759
|
// Field has the priority if it is set, otherwise it goes to the form settings
|
|
1750
|
-
const shouldKeepValue = (_a = vue.unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : vue.unref(keepValuesOnUnmount);
|
|
1751
1760
|
if (shouldKeepValue) {
|
|
1752
1761
|
return;
|
|
1753
1762
|
}
|
|
@@ -1863,7 +1872,7 @@
|
|
|
1863
1872
|
function stageInitialValue(path, value, updateOriginal = false) {
|
|
1864
1873
|
setInPath(formValues, path, value);
|
|
1865
1874
|
setFieldInitialValue(path, value);
|
|
1866
|
-
if (updateOriginal) {
|
|
1875
|
+
if (updateOriginal && !(opts === null || opts === void 0 ? void 0 : opts.initialValues)) {
|
|
1867
1876
|
setInPath(originalInitialValues.value, path, klona(value));
|
|
1868
1877
|
}
|
|
1869
1878
|
}
|
package/dist/vee-validate.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.6.
|
|
2
|
+
* vee-validate v4.6.4
|
|
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 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");function d(e){return n(e)&&!!e.__locatorRef}function c(e){return!!e&&n(e.validate)}function f(e){return"checkbox"===e||"radio"===e}function v(e){return Array.isArray(e)?0===e.length:a(e)&&0===Object.keys(e).length}function m(e){return/^\[.+\]$/i.test(e)}function p(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&&!f(t.type)}function y(e){return g(e)&&e.target&&"submit"in e.target}function g(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function b(e,t){return t in e&&e[t]!==s}function V(e){return m(e)?e.replace(/\[|\]/gi,""):e}function O(e,t,n){if(!e)return n;if(m(t))return e[V(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 F(e,t,n){if(m(t))return void(e[V(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 A(e,t){Array.isArray(e)&&u(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function w(e,t){if(m(t))return void delete e[V(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){A(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>O(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)v(u[t])&&(0!==t?A(u[t-1],n[t-1]):A(e,n[0]))}function j(e){return Object.keys(e)}function E(e,n){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function S(e){t.warn(`[vee-validate]: ${e}`)}function k(e){return Array.isArray(e)?e[0]:e}function B(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.indexOf(t);return r>=0?n.splice(r,1):n.push(t),n}return e===t?n:t}function M(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 I(e,t){if(a(t))return t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}const T=(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 C(e){if(R(e))return e._value}function R(e){return"_value"in e}function x(e){if(!g(e))return e;const t=e.target;if(f(t.type)&&R(t))return C(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(p(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(C);var n;if(p(t)){const e=Array.from(t.options).find((e=>e.selected));return e?C(e):t.value}return t.value}function N(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]=P(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=U(t);return n.name?(e[n.name]=P(n.params),e):e}),t):t}function P(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>O(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 U=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let _=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const $=()=>_,D=e=>{_=Object.assign(Object.assign({},_),e)};async function q(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(c(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:L(n);if(u.push(l),e.bails)return{errors:u}}return{errors:u}}const r=Object.assign(Object.assign({},e),{rules:N(e.rules)}),a=[],u=Object.keys(r.rules),i=u.length;for(let n=0;n<i;n++){const i=u[n],o=await z(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 z(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:L(o)}}function L(e){const t=$().generateMessage;return t?t(e):"Field is invalid"}async function K(e,t,n){const r=j(e).map((async r=>{var a,u,i;const o=await q(O(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 G(e,t,n){"object"==typeof n.value&&(n.value=X(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function X(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(X(e))}))):"[object Map]"===u?(r=new Map,e.forEach((function(e,t){r.set(X(t),X(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(X(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++)G(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]||G(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}var H=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 instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(a of t.entries())if(!n.has(a[0]))return!1;for(a of t.entries())if(!e(a[1],n.get(a[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(a of t.entries())if(!n.has(a[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(a=r;0!=a--;)if(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};let J=0;function Q(e,n){const{value:r,initialValue:a,setInitialValue:u}=W(e,n.modelValue,!n.standalone),{errorMessage:i,errors:l,setErrors:s}=function(e,n){const r=n?E(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 u=t.computed((()=>r.errorBag.value[t.unref(e)]||[]));return{errors:u,errorMessage:t.computed((()=>u.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((()=>!H(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:J>=Number.MAX_SAFE_INTEGER?0:++J,path:e,value:r,initialValue:a,meta:d,errors:l,errorMessage:i,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&&u(e.initialValue)}}}function W(e,n,r=!0){const a=!0===r?E(o,void 0):void 0,u=t.ref(t.unref(n));function i(){return a?O(a.meta.value.initialValues,t.unref(e),t.unref(u)):t.unref(u)}function l(n){a?a.setFieldInitialValue(t.unref(e),n):u.value=n}const s=t.computed(i);if(!a){return{value:t.ref(i()),initialValue:s,setInitialValue:l}}const d=n?t.unref(n):O(a.values,t.unref(e),t.unref(s));a.stageInitialValue(t.unref(e),d,!0);return{value:t.computed({get:()=>O(a.values,t.unref(e)),set(n){a.setFieldValue(t.unref(e),n)}}),initialValue:s,setInitialValue:l}}function Y(e,n,r){return f(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:E(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.includes(r):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;let d=x(o);a||(d=B(t.unref(e.value),t.unref(u),t.unref(i))),n(d,l)}return t.onBeforeUnmount((()=>{var n,i;const l=null!==(i=null!==(n=t.unref(e.keepValueOnUnmount))&&void 0!==n?n:t.unref(null==a?void 0:a.keepValuesOnUnmount))&&void 0!==i&&i;r.value&&!l&&o(t.unref(u),!1)})),Object.assign(Object.assign({},e),{checked:r,checkedValue:u,uncheckedValue:i,handleChange:o})}return l(Z(e,n,r))}(e,n,r):Z(e,n,r)}function Z(e,r,a){const{initialValue:u,validateOnMount:i,bails:f,type:v,checkedValue:m,label:p,validateOnValueUpdate:h,uncheckedValue:y,standalone:g,keepValueOnUnmount:b,modelPropName:V,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:E(o);let w=!1;const{id:S,value:k,initialValue:B,meta:M,setState:T,errors:C,errorMessage:R}=Q(e,{modelValue:u,standalone:g});F&&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=>{H(e,ee(a,u))||a.emit(i,e)})),t.watch((()=>ee(a,u)),(e=>{if(e===s&&void 0===n.value)return;const t=e===s?void 0:e;H(t,I(n.value,a.props.modelModifiers))||r(t)}))}({value:k,prop:V,handleChange:D});const P=t.computed((()=>{let a=t.unref(r);const u=t.unref(null==A?void 0:A.schema);return u&&!c(u)&&(a=function(e,t){if(!e)return;return e[t]}(u,t.unref(e))||a),c(a)||n(a)||Array.isArray(a)?a:N(a)}));async function U(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:[]}:q(k.value,P.value,{name:t.unref(p)||t.unref(e),values:null!==(a=null==A?void 0:A.values)&&void 0!==a?a:{},bails:f})}async function _(){M.pending=!0,M.validated=!0;const e=await U("validated-only");return w&&(e.valid=!0,e.errors=[]),T({errors:e.errors}),M.pending=!1,e}async function $(){const e=await U("silent");return w&&(e.valid=!0),M.valid=e.valid,e}function D(e,t=!0){const n=x(e);k.value=n,!h&&t&&_()}let z;function L(){z=t.watch(k,((e,t)=>{if(H(e,t))return;(h?_:$)()}),{deep:!0})}function K(e){var n;null==z||z();const r=e&&"value"in e?e.value:B.value;T({value:X(r),initialValue:X(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,$(),t.nextTick((()=>{L()}))}t.onMounted((()=>{if(i)return _();A&&A.validateSchema||$()})),L();const G={id:S,name:e,label:p,value:k,meta:M,errors:C,errorMessage:R,type:v,checkedValue:m,uncheckedValue:y,bails:f,keepValueOnUnmount:b,resetField:K,handleReset:()=>K(),validate:function(e){return(null==e?void 0:e.mode)&&"force"!==(null==e?void 0:e.mode)?"validated-only"===(null==e?void 0:e.mode)?_():$():_()},handleChange:D,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){k.value=e}};if(t.provide(l,G),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{H(e,t)||(M.validated?_():$())}),{deep:!0}),!A)return G;A.register(G),t.onBeforeUnmount((()=>{w=!0,A.unregister(G)}));const J=t.computed((()=>{const e=P.value;return!e||n(e)||c(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(d):j(a).filter((e=>d(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=O(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(J,((e,t)=>{if(!Object.keys(e).length)return;!H(e,t)&&(M.validated?_():$())})),G}function ee(e,t){return e.props[t]}function te(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ne(e,t){return f(t.attrs.type)?b(e,"modelValue")?e.modelValue:void 0:b(e,"modelValue")?e.modelValue:t.attrs.value}const re=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:()=>$().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:d,validate:c,handleChange:v,handleBlur:m,setTouched:p,resetField:y,handleReset:g,meta:b,checked:V,setErrors:O}=Y(a,r,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:n.attrs.type,initialValue:ne(e,n),checkedValue:n.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:!1,keepValueOnUnmount:o}),F=function(e,t=!0){v(e,t),n.emit("update:modelValue",s.value)},A=function(e){(e=>{f(n.attrs.type)||(s.value=x(e))})(e),n.emit("update:modelValue",s.value)},w=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}=$();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=[m,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:i,onInput:o,onChange:l,"onUpdate:modelValue":e=>F(e,u)};f(n.attrs.type)&&V&&(d.checked=V.value);return h(te(e,n),n.attrs)&&(d.value=s.value),d}));function j(){return{field:w.value,value:s.value,meta:b,errors:l.value,errorMessage:d.value,validate:c,resetField:y,handleChange:F,handleInput:A,handleReset:g,handleBlur:m,setTouched:p,setErrors:O}}return n.expose({setErrors:O,setTouched:p,reset:y,validate:c,handleChange:v}),()=>{const r=t.resolveDynamicComponent(te(e,n)),a=T(r,n,j);return r?t.h(r,Object.assign(Object.assign({},n.attrs),w.value),a):a}}});let ae=0;function ue(e){var n;const r=ae++;let a=!1;const u=t.ref({}),i=t.ref(!1),l=t.ref(0),s=[],d=t.reactive(X(t.unref(null==e?void 0:e.initialValues)||{})),{errorBag:f,setErrorBag:m,setFieldErrorBag:p}=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=j(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((()=>j(f.value).reduce(((e,t)=>{const n=f.value[t];return n&&n.length&&(e[t]=n[0]),e}),{})));function g(e){const t=u.value[e];return Array.isArray(t)?t[0]:t}function b(e){return!!u.value[e]}const V=t.computed((()=>j(u.value).reduce(((e,n)=>{const r=g(n);return r&&(e[n]=t.unref(r.label||r.name)||""),e}),{}))),A=t.computed((()=>j(u.value).reduce(((e,t)=>{var n;const r=g(t);return r&&(e[t]=null===(n=r.bails)||void 0===n||n),e}),{}))),E=Object.assign({},(null==e?void 0:e.initialErrors)||{}),S=null!==(n=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==n&&n,{initialValues:k,originalInitialValues:I,setInitialValues:T}=function(e,n,r){const a=t.ref(X(t.unref(r))||{}),u=t.ref(X(t.unref(r))||{});function i(t,r=!1){a.value=X(t),u.value=X(t),r&&j(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=O(a.value,t);F(n,t,X(i))}))}t.isRef(r)&&t.watch(r,(e=>{i(e,!0)}),{deep:!0});return{initialValues:a,originalInitialValues:u,setInitialValues:i}}(u,d,null==e?void 0:e.initialValues),C=function(e,n,r,a){const u={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!H(n,t.unref(r))));function o(){const t=Object.values(e.value).flat(1).filter(Boolean);return j(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&&!j(a.value).length,dirty:i.value})))}(u,d,I,h),R=null==e?void 0:e.validationSchema,x={formId:r,fieldsByPath:u,values:d,errorBag:f,errors:h,schema:R,submitCount:l,meta:C,isSubmitting:i,fieldArrays:s,keepValuesOnUnmount:S,validateSchema:t.unref(R)?async function(e){const t=await("silent"===e?ie():oe()),n=x.fieldsByPath.value||{},r=j(x.errorBag.value);return[...new Set([...j(t.results),...j(n),...r])].reduce(((r,a)=>{const u=n[a],i=(t.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 _(a,i),r;if(P(u,(e=>e.meta.valid=o.valid)),"silent"===e)return r;const l=Array.isArray(u)?u.some((e=>e.meta.validated)):u.meta.validated;return"validated-only"!==e||l?(P(u,(e=>e.setState({errors:o.errors}))),r):r}),{valid:t.valid,results:{},errors:{}})}:void 0,validate:ee,register:function(e){const n=t.unref(e.name);Y(e,n),t.isRef(e.name)&&t.watch(e.name,(async(n,r)=>{await t.nextTick(),Z(e,r),Y(e,n),(h.value[r]||h.value[n])&&(_(r,void 0),te(n)),await t.nextTick(),b(r)||w(d,r)}));const r=t.unref(e.errorMessage);r&&(null==E?void 0:E[n])!==r&&te(n);delete E[n]},unregister:function(e){const n=t.unref(e.name),r=u.value[n],a=!!r&&N(r);Z(e,n),t.nextTick((()=>{var r;if(!b(n)){_(n,void 0);if(null!==(r=t.unref(e.keepValueOnUnmount))&&void 0!==r?r:t.unref(S))return;if(a&&!v(O(d,n)))return;w(d,n)}}))},setFieldErrorBag:p,validateField:te,setFieldValue:D,setValues:q,setErrors:$,setFieldError:_,setFieldTouched:G,setTouched:J,resetForm:Q,handleSubmit:ne,stageInitialValue:function(e,t,n=!1){F(d,e,t),re(e,t),n&&F(I.value,e,X(t))},unsetInitialValue:function(e){w(k.value,e)},setFieldInitialValue:re,useFieldModel:L};function N(e){return Array.isArray(e)}function P(e,t){return Array.isArray(e)?e.forEach(t):t(e)}function U(e){Object.values(u.value).forEach((t=>{t&&P(t,e)}))}function _(e,t){p(e,t)}function $(e){m(e)}function D(e,n,{force:r}={force:!1}){var i;const o=u.value[e],l=X(n);if(!o)return void F(d,e,l);if(N(o)&&"checkbox"===(null===(i=o[0])||void 0===i?void 0:i.type)&&!Array.isArray(n)){const t=X(B(O(d,e)||[],n,void 0));return void F(d,e,t)}let s=n;N(o)||"checkbox"!==o.type||r||a||(s=X(B(O(d,e),n,t.unref(o.uncheckedValue)))),F(d,e,s)}function q(e){j(d).forEach((e=>{delete d[e]})),j(e).forEach((t=>{D(t,e[t])})),s.forEach((e=>e&&e.reset()))}function z(e){const{value:n}=W(e);return t.watch(n,(()=>{b(t.unref(e))||ee({mode:"validated-only"})})),n}function L(e){return Array.isArray(e)?e.map(z):z(e)}function G(e,t){const n=u.value[e];n&&P(n,(e=>e.setTouched(t)))}function J(e){j(e).forEach((t=>{G(t,!!e[t])}))}function Q(e){a=!0,(null==e?void 0:e.values)?(T(e.values),q(null==e?void 0:e.values)):(T(I.value),q(I.value)),U((e=>e.resetField())),(null==e?void 0:e.touched)&&J(e.touched),$((null==e?void 0:e.errors)||{}),l.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{a=!1}))}function Y(e,n){const r=t.markRaw(e),a=n;if(!u.value[a])return void(u.value[a]=r);const i=u.value[a];i&&!Array.isArray(i)&&(u.value[a]=[i]),u.value[a]=[...u.value[a],r]}function Z(e,t){const n=t,r=u.value[n];if(r)if(N(r)||e.id!==r.id){if(N(r)){const t=r.findIndex((t=>t.id===e.id));if(-1===t)return;if(r.splice(t,1),1===r.length)return void(u.value[n]=r[0]);r.length||delete u.value[n]}}else delete u.value[n]}async function ee(e){if(U((e=>e.meta.validated=!0)),x.validateSchema)return x.validateSchema((null==e?void 0:e.mode)||"force");const n=await Promise.all(Object.values(u.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 te(e){const n=u.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 ne(e,t){return function(n){return n instanceof Event&&(n.preventDefault(),n.stopPropagation()),J(j(u.value).reduce(((e,t)=>(e[t]=!0,e)),{})),i.value=!0,l.value++,ee().then((r=>{if(r.valid&&"function"==typeof e)return e(X(d),{evt:n,setErrors:$,setFieldError:_,setTouched:J,setFieldTouched:G,setValues:q,setFieldValue:D,resetForm:Q});r.valid||"function"!=typeof t||t({values:X(d),evt:n,errors:r.errors,results:r.results})})).then((e=>(i.value=!1,e)),(e=>{throw i.value=!1,e}))}}function re(e,t){F(k.value,e,X(t))}async function ue(){const e=t.unref(R);if(!e)return{valid:!0,results:{},errors:{}};const n=c(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 K(e,d,{names:V.value,bailsMap:A.value});return n}const ie=M(ue,5),oe=M(ue,5);const le=ne(((e,{evt:t})=>{y(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&$(e.initialErrors),(null==e?void 0:e.initialTouched)&&J(e.initialTouched),(null==e?void 0:e.validateOnMount)?ee():x.validateSchema&&x.validateSchema("silent")})),t.isRef(R)&&t.watch(R,(()=>{var e;null===(e=x.validateSchema)||void 0===e||e.call(x,"validated-only")})),t.provide(o,x),{errors:h,meta:C,values:d,isSubmitting:i,submitCount:l,validate:ee,validateField:te,handleReset:()=>Q(),resetForm:Q,handleSubmit:ne,submitForm:le,setFieldError:_,setErrors:$,setFieldValue:D,setValues:q,setFieldTouched:G,setTouched:J,useFieldModel:L}}const ie=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:d,validate:c,validateField:f,handleReset:v,resetForm:m,handleSubmit:p,setErrors:h,setFieldError:b,setFieldValue:V,setValues:O,setFieldTouched:F,setTouched:A}=ue({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:u}),w=p(((e,{evt:t})=>{y(t)&&t.target.submit()}),e.onInvalidSubmit),j=e.onSubmit?p(e.onSubmit,e.onInvalidSubmit):w;function E(e){g(e)&&e.preventDefault(),v(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function S(t,n){return p("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function k(){return{meta:l.value,errors:i.value,values:o,isSubmitting:s.value,submitCount:d.value,validate:c,validateField:f,handleSubmit:S,handleReset:v,submitForm:w,setErrors:h,setFieldError:b,setFieldValue:V,setValues:O,setFieldTouched:F,setTouched:A,resetForm:m}}return n.expose({setFieldError:b,setErrors:h,setFieldValue:V,setValues:O,setFieldTouched:F,setTouched:A,resetForm:m,validate:c,validateField:f}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=T(r,n,k);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:j,onReset:E}),a)}}}),oe=ie;function le(e){const n=E(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 S("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 S("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 d(){const r=O(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 u=s++,i={key:u,value:t.computed({get(){const i=O(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):S("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return i}function v(r,a){const u=t.unref(e),i=O(null==n?void 0:n.values,u);!Array.isArray(i)||i.length-1<r||null==n||n.setFieldValue(`${u}[${r}]`,a)}d();const m={fields:a,remove:function(r){const u=t.unref(e),i=O(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),c()},push:function(u){const i=t.unref(e),o=O(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)),c()},swap:function(r,u){const i=t.unref(e),o=O(null==n?void 0:n.values,i);if(!Array.isArray(o)||!(r in o)||!(u in o))return;const l=[...o],s=[...a.value],d=l[r];l[r]=l[u],l[u]=d;const f=s[r];s[r]=s[u],s[u]=f,null==n||n.setFieldValue(i,l),a.value=s,c()},insert:function(r,u){const i=t.unref(e),o=O(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,c()},update:v,replace:function(r){const a=t.unref(e);null==n||n.setFieldValue(a,r),d()},prepend:function(u){const i=t.unref(e),o=O(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)),c()},move:function(u,i){const o=t.unref(e),l=O(null==n?void 0:n.values,o),s=r(l)?[]:[...l];if(!Array.isArray(l)||!(u in l)||!(i in l))return;const d=[...a.value],f=d[u];d.splice(u,1),d.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=d,c()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},m)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),m}const se=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:d,fields:c}=le(t.toRef(e,"name"));function f(){return{fields:c.value,push:r,remove:a,swap:u,insert:i,update:l,replace:o,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:u,insert:i,update:l,replace:o,prepend:s,move:d}),()=>T(void 0,n,f)}}),de=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=T(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=de,e.Field=re,e.FieldArray=se,e.FieldContextKey=l,e.Form=oe,e.FormContextKey=o,e.IS_ABSENT=s,e.configure=D,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=Y,e.useFieldArray=le,e.useFieldError=function(e){const n=E(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=E(o),r=e?void 0:t.inject(l);return t.computed((()=>e?O(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=ue,e.useFormErrors=function(){const e=E(o);return e||S("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=E(o);return e||S("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=E(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=k(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.dirty:(S(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldTouched=function(e){const n=E(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=k(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.touched:(S(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldValid=function(e){const n=E(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=k(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.valid:(S(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFormDirty=function(){const e=E(o);return e||S("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=E(o);return e||S("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=E(o);return e||S("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=E(o);return e||S("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=E(o);return e||S("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=E(o);return e||S("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=E(o);t||S("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=E(o);let r=e?void 0:t.inject(l);return function(){return e&&(r=k(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.validate():(S(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=E(o);return e||S("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=q,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 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");function d(e){return n(e)&&!!e.__locatorRef}function c(e){return!!e&&n(e.validate)}function f(e){return"checkbox"===e||"radio"===e}function v(e){return Array.isArray(e)?0===e.length:a(e)&&0===Object.keys(e).length}function p(e){return/^\[.+\]$/i.test(e)}function m(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&&!f(t.type)}function y(e){return g(e)&&e.target&&"submit"in e.target}function g(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function b(e,t){return t in e&&e[t]!==s}function V(e){return p(e)?e.replace(/\[|\]/gi,""):e}function O(e,t,n){if(!e)return n;if(p(t))return e[V(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 F(e,t,n){if(p(t))return void(e[V(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 A(e,t){Array.isArray(e)&&i(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function w(e,t){if(p(t))return void delete e[V(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){A(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const i=n.map(((t,r)=>O(e,n.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)v(i[t])&&(0!==t?A(i[t-1],n[t-1]):A(e,n[0]))}function j(e){return Object.keys(e)}function E(e,n){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function S(e){t.warn(`[vee-validate]: ${e}`)}function k(e){return Array.isArray(e)?e[0]:e}function B(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.indexOf(t);return r>=0?n.splice(r,1):n.push(t),n}return e===t?n:t}function I(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 M(e,t){if(a(t))return t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}const T=(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 C(e){if(R(e))return e._value}function R(e){return"_value"in e}function x(e){if(!g(e))return e;const t=e.target;if(f(t.type)&&R(t))return C(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(m(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(C);var n;if(m(t)){const e=Array.from(t.options).find((e=>e.selected));return e?C(e):t.value}return t.value}function N(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]=P(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=_(t);return n.name?(e[n.name]=P(n.params),e):e}),t):t}function P(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>O(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 _=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let U=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const $=()=>U,D=e=>{U=Object.assign(Object.assign({},U),e)};async function q(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(c(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:L(n);if(i.push(l),e.bails)return{errors:i}}return{errors:i}}const r=Object.assign(Object.assign({},e),{rules:N(e.rules)}),a=[],i=Object.keys(r.rules),u=i.length;for(let n=0;n<u;n++){const u=i[n],o=await z(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 z(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=>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:i})},l=await r(t,i,o);return"string"==typeof l?{error:l}:{error:l?void 0:L(o)}}function L(e){const t=$().generateMessage;return t?t(e):"Field is invalid"}async function K(e,t,n){const r=j(e).map((async r=>{var a,i,u;const o=await q(O(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 G(e,t,n){"object"==typeof n.value&&(n.value=X(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function X(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(X(e))}))):"[object Map]"===i?(r=new Map,e.forEach((function(e,t){r.set(X(t),X(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(X(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++)G(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]||G(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}var H=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 instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(a of t.entries())if(!n.has(a[0]))return!1;for(a of t.entries())if(!e(a[1],n.get(a[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(a of t.entries())if(!n.has(a[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((r=t.length)!=n.length)return!1;for(a=r;0!=a--;)if(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};let J=0;function Q(e,n){const{value:r,initialValue:a,setInitialValue:i}=W(e,n.modelValue,!n.standalone),{errorMessage:u,errors:l,setErrors:s}=function(e,n){const r=n?E(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((()=>!H(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:J>=Number.MAX_SAFE_INTEGER?0:++J,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 W(e,n,r=!0){const a=!0===r?E(o,void 0):void 0,i=t.ref(t.unref(n));function u(){return a?O(a.meta.value.initialValues,t.unref(e),t.unref(i)):t.unref(i)}function l(n){a?a.setFieldInitialValue(t.unref(e),n):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):O(a.values,t.unref(e),t.unref(s));a.stageInitialValue(t.unref(e),d,!0);return{value:t.computed({get:()=>O(a.values,t.unref(e)),set(n){a.setFieldValue(t.unref(e),n)}}),initialValue:s,setInitialValue:l}}function Y(e,n,r){return f(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:E(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.includes(r):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;let d=x(o);a||(d=B(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(Z(e,n,r))}(e,n,r):Z(e,n,r)}function Z(e,r,a){const{initialValue:i,validateOnMount:u,bails:f,type:v,checkedValue:p,label:m,validateOnValueUpdate:h,uncheckedValue:y,standalone:g,keepValueOnUnmount:b,modelPropName:V,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:E(o);let w=!1;const{id:S,value:k,initialValue:B,meta:I,setState:T,errors:C,errorMessage:R}=Q(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=>{H(e,ee(a,i))||a.emit(u,e)})),t.watch((()=>ee(a,i)),(e=>{if(e===s&&void 0===n.value)return;const t=e===s?void 0:e;H(t,M(n.value,a.props.modelModifiers))||r(t)}))}({value:k,prop:V,handleChange:D});const P=t.computed((()=>{let a=t.unref(r);const i=t.unref(null==A?void 0:A.schema);return i&&!c(i)&&(a=function(e,t){if(!e)return;return e[t]}(i,t.unref(e))||a),c(a)||n(a)||Array.isArray(a)?a:N(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:[]}:q(k.value,P.value,{name:t.unref(m)||t.unref(e),values:null!==(a=null==A?void 0:A.values)&&void 0!==a?a:{},bails:f})}async function U(){I.pending=!0,I.validated=!0;const e=await _("validated-only");return w&&(e.valid=!0,e.errors=[]),T({errors:e.errors}),I.pending=!1,e}async function $(){const e=await _("silent");return w&&(e.valid=!0),I.valid=e.valid,e}function D(e,t=!0){const n=x(e);k.value=n,!h&&t&&U()}let z;function L(){z=t.watch(k,((e,t)=>{if(H(e,t))return;(h?U:$)()}),{deep:!0})}function K(e){var n;null==z||z();const r=e&&"value"in e?e.value:B.value;T({value:X(r),initialValue:X(r),touched:null!==(n=null==e?void 0:e.touched)&&void 0!==n&&n,errors:(null==e?void 0:e.errors)||[]}),I.pending=!1,I.validated=!1,$(),t.nextTick((()=>{L()}))}t.onMounted((()=>{if(u)return U();A&&A.validateSchema||$()})),L();const G={id:S,name:e,label:m,value:k,meta:I,errors:C,errorMessage:R,type:v,checkedValue:p,uncheckedValue:y,bails:f,keepValueOnUnmount:b,resetField:K,handleReset:()=>K(),validate:function(e){return(null==e?void 0:e.mode)&&"force"!==(null==e?void 0:e.mode)?"validated-only"===(null==e?void 0:e.mode)?U():$():U()},handleChange:D,handleBlur:()=>{I.touched=!0},setState:T,setTouched:function(e){I.touched=e},setErrors:function(e){T({errors:Array.isArray(e)?e:[e]})},setValue:function(e){k.value=e}};if(t.provide(l,G),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{H(e,t)||(I.validated?U():$())}),{deep:!0}),!A)return G;A.register(G),t.onBeforeUnmount((()=>{w=!0,A.unregister(G)}));const J=t.computed((()=>{const e=P.value;return!e||n(e)||c(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(d):j(a).filter((e=>d(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=O(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(J,((e,t)=>{if(!Object.keys(e).length)return;!H(e,t)&&(I.validated?U():$())})),G}function ee(e,t){return e.props[t]}function te(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ne(e,t){return f(t.attrs.type)?b(e,"modelValue")?e.modelValue:void 0:b(e,"modelValue")?e.modelValue:t.attrs.value}const re=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:()=>$().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:v,handleBlur:p,setTouched:m,resetField:y,handleReset:g,meta:b,checked:V,setErrors:O}=Y(a,r,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:n.attrs.type,initialValue:ne(e,n),checkedValue:n.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o}),F=function(e,t=!0){v(e,t),n.emit("update:modelValue",s.value)},A=function(e){(e=>{f(n.attrs.type)||(s.value=x(e))})(e),n.emit("update:modelValue",s.value)},w=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}=$();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)};f(n.attrs.type)&&V&&(d.checked=V.value);return h(te(e,n),n.attrs)&&(d.value=s.value),d}));function j(){return{field:w.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:O}}return n.expose({setErrors:O,setTouched:m,reset:y,validate:c,handleChange:v}),()=>{const r=t.resolveDynamicComponent(te(e,n)),a=T(r,n,j);return r?t.h(r,Object.assign(Object.assign({},n.attrs),w.value),a):a}}});let ae=0;function ie(e){var n;const r=ae++;let a=!1;const i=t.ref({}),u=t.ref(!1),l=t.ref(0),s=[],d=t.reactive(X(t.unref(null==e?void 0:e.initialValues)||{})),{errorBag:f,setErrorBag:p,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=j(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),h=t.computed((()=>j(f.value).reduce(((e,t)=>{const n=f.value[t];return n&&n.length&&(e[t]=n[0]),e}),{})));function g(e){const t=i.value[e];return Array.isArray(t)?t[0]:t}function b(e){return!!i.value[e]}const V=t.computed((()=>j(i.value).reduce(((e,n)=>{const r=g(n);return r&&(e[n]=t.unref(r.label||r.name)||""),e}),{}))),A=t.computed((()=>j(i.value).reduce(((e,t)=>{var n;const r=g(t);return r&&(e[t]=null===(n=r.bails)||void 0===n||n),e}),{}))),E=Object.assign({},(null==e?void 0:e.initialErrors)||{}),S=null!==(n=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==n&&n,{initialValues:k,originalInitialValues:M,setInitialValues:T}=function(e,n,r){const a=t.ref(X(t.unref(r))||{}),i=t.ref(X(t.unref(r))||{});function u(t,r=!1){a.value=X(t),i.value=X(t),r&&j(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=O(a.value,t);F(n,t,X(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),C=function(e,n,r,a){const i={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!H(n,t.unref(r))));function o(){const t=Object.values(e.value).flat(1).filter(Boolean);return j(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&&!j(a.value).length,dirty:u.value})))}(i,d,M,h),R=null==e?void 0:e.validationSchema,x={formId:r,fieldsByPath:i,values:d,errorBag:f,errors:h,schema:R,submitCount:l,meta:C,isSubmitting:u,fieldArrays:s,keepValuesOnUnmount:S,validateSchema:t.unref(R)?async function(e){const t=await("silent"===e?ue():oe()),n=x.fieldsByPath.value||{},r=j(x.errorBag.value);return[...new Set([...j(t.results),...j(n),...r])].reduce(((r,a)=>{const i=n[a],u=(t.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 U(a,u),r;if(P(i,(e=>e.meta.valid=o.valid)),"silent"===e)return r;const l=Array.isArray(i)?i.some((e=>e.meta.validated)):i.meta.validated;return"validated-only"!==e||l?(P(i,(e=>e.setState({errors:o.errors}))),r):r}),{valid:t.valid,results:{},errors:{}})}:void 0,validate:ee,register:function(e){const n=t.unref(e.name);Y(e,n),t.isRef(e.name)&&t.watch(e.name,(async(n,r)=>{await t.nextTick(),Z(e,r),Y(e,n),(h.value[r]||h.value[n])&&(U(r,void 0),te(n)),await t.nextTick(),b(r)||w(d,r)}));const r=t.unref(e.errorMessage);r&&(null==E?void 0:E[n])!==r&&te(n);delete E[n]},unregister:function(e){const n=t.unref(e.name),r=i.value[n],a=!!r&&N(r);Z(e,n),t.nextTick((()=>{var u;const o=null!==(u=t.unref(e.keepValueOnUnmount))&&void 0!==u?u:t.unref(S),l=O(d,n);if(a&&(r===i.value[n]||!i.value[n])&&Array.isArray(l)&&!o){const r=l.findIndex((n=>H(n,t.unref(e.checkedValue))));if(r>-1){const e=[...l];e.splice(r,1),D(n,e,{force:!0})}}if(!b(n)){if(U(n,void 0),o)return;if(a&&!v(O(d,n)))return;w(d,n)}}))},setFieldErrorBag:m,validateField:te,setFieldValue:D,setValues:q,setErrors:$,setFieldError:U,setFieldTouched:G,setTouched:J,resetForm:Q,handleSubmit:ne,stageInitialValue:function(t,n,r=!1){F(d,t,n),re(t,n),r&&!(null==e?void 0:e.initialValues)&&F(M.value,t,X(n))},unsetInitialValue:function(e){w(k.value,e)},setFieldInitialValue:re,useFieldModel:L};function N(e){return Array.isArray(e)}function P(e,t){return Array.isArray(e)?e.forEach(t):t(e)}function _(e){Object.values(i.value).forEach((t=>{t&&P(t,e)}))}function U(e,t){m(e,t)}function $(e){p(e)}function D(e,n,{force:r}={force:!1}){var u;const o=i.value[e],l=X(n);if(!o)return void F(d,e,l);if(N(o)&&"checkbox"===(null===(u=o[0])||void 0===u?void 0:u.type)&&!Array.isArray(n)){const t=X(B(O(d,e)||[],n,void 0));return void F(d,e,t)}let s=n;N(o)||"checkbox"!==o.type||r||a||(s=X(B(O(d,e),n,t.unref(o.uncheckedValue)))),F(d,e,s)}function q(e){j(d).forEach((e=>{delete d[e]})),j(e).forEach((t=>{D(t,e[t])})),s.forEach((e=>e&&e.reset()))}function z(e){const{value:n}=W(e);return t.watch(n,(()=>{b(t.unref(e))||ee({mode:"validated-only"})}),{deep:!0}),n}function L(e){return Array.isArray(e)?e.map(z):z(e)}function G(e,t){const n=i.value[e];n&&P(n,(e=>e.setTouched(t)))}function J(e){j(e).forEach((t=>{G(t,!!e[t])}))}function Q(e){a=!0,(null==e?void 0:e.values)?(T(e.values),q(null==e?void 0:e.values)):(T(M.value),q(M.value)),_((e=>e.resetField())),(null==e?void 0:e.touched)&&J(e.touched),$((null==e?void 0:e.errors)||{}),l.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{a=!1}))}function Y(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 Z(e,t){const n=t,r=i.value[n];if(r)if(N(r)||e.id!==r.id){if(N(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 ee(e){if(_((e=>e.meta.validated=!0)),x.validateSchema)return x.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 te(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 ne(e,t){return function(n){return n instanceof Event&&(n.preventDefault(),n.stopPropagation()),J(j(i.value).reduce(((e,t)=>(e[t]=!0,e)),{})),u.value=!0,l.value++,ee().then((r=>{if(r.valid&&"function"==typeof e)return e(X(d),{evt:n,setErrors:$,setFieldError:U,setTouched:J,setFieldTouched:G,setValues:q,setFieldValue:D,resetForm:Q});r.valid||"function"!=typeof t||t({values:X(d),evt:n,errors:r.errors,results:r.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}function re(e,t){F(k.value,e,X(t))}async function ie(){const e=t.unref(R);if(!e)return{valid:!0,results:{},errors:{}};const n=c(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 K(e,d,{names:V.value,bailsMap:A.value});return n}const ue=I(ie,5),oe=I(ie,5);const le=ne(((e,{evt:t})=>{y(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&$(e.initialErrors),(null==e?void 0:e.initialTouched)&&J(e.initialTouched),(null==e?void 0:e.validateOnMount)?ee():x.validateSchema&&x.validateSchema("silent")})),t.isRef(R)&&t.watch(R,(()=>{var e;null===(e=x.validateSchema)||void 0===e||e.call(x,"validated-only")})),t.provide(o,x),{errors:h,meta:C,values:d,isSubmitting:u,submitCount:l,validate:ee,validateField:te,handleReset:()=>Q(),resetForm:Q,handleSubmit:ne,submitForm:le,setFieldError:U,setErrors:$,setFieldValue:D,setValues:q,setFieldTouched:G,setTouched:J,useFieldModel:L}}const ue=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:h,setFieldError:b,setFieldValue:V,setValues:O,setFieldTouched:F,setTouched:A}=ie({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:i}),w=m(((e,{evt:t})=>{y(t)&&t.target.submit()}),e.onInvalidSubmit),j=e.onSubmit?m(e.onSubmit,e.onInvalidSubmit):w;function E(e){g(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:w,setErrors:h,setFieldError:b,setFieldValue:V,setValues:O,setFieldTouched:F,setTouched:A,resetForm:p}}return n.expose({setFieldError:b,setErrors:h,setFieldValue:V,setValues:O,setFieldTouched:F,setTouched:A,resetForm:p,validate:c,validateField:f}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=T(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:j,onReset:E}),a)}}}),oe=ue;function le(e){const n=E(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 S("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 S("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=O(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=O(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):S("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return u}function v(r,a){const i=t.unref(e),u=O(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=O(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=O(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=O(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=O(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=O(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=O(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 se=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}=le(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}),()=>T(void 0,n,f)}}),de=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=T(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=de,e.Field=re,e.FieldArray=se,e.FieldContextKey=l,e.Form=oe,e.FormContextKey=o,e.IS_ABSENT=s,e.configure=D,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=Y,e.useFieldArray=le,e.useFieldError=function(e){const n=E(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=E(o),r=e?void 0:t.inject(l);return t.computed((()=>e?O(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=ie,e.useFormErrors=function(){const e=E(o);return e||S("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=E(o);return e||S("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=E(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=k(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.dirty:(S(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldTouched=function(e){const n=E(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=k(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.touched:(S(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldValid=function(e){const n=E(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=k(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.valid:(S(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFormDirty=function(){const e=E(o);return e||S("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=E(o);return e||S("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=E(o);return e||S("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=E(o);return e||S("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=E(o);return e||S("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=E(o);return e||S("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=E(o);t||S("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=E(o);let r=e?void 0:t.inject(l);return function(){return e&&(r=k(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.validate():(S(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=E(o);return e||S("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=q,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.
|
|
3
|
+
"version": "4.6.4",
|
|
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": "
|
|
36
|
+
"gitHead": "4dbafc1704829bbfe0ec84faa11c06f4e180214c"
|
|
37
37
|
}
|