vee-validate 4.9.1 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vee-validate.d.ts +7 -3
- package/dist/vee-validate.esm.js +53 -14
- package/dist/vee-validate.js +53 -14
- package/dist/vee-validate.min.js +2 -2
- package/package.json +1 -1
package/dist/vee-validate.d.ts
CHANGED
|
@@ -226,6 +226,9 @@ interface PathState<TValue = unknown> {
|
|
|
226
226
|
type: InputType;
|
|
227
227
|
multiple: boolean;
|
|
228
228
|
fieldsCount: number;
|
|
229
|
+
__flags: {
|
|
230
|
+
pendingUnmount: Record<string, boolean>;
|
|
231
|
+
};
|
|
229
232
|
validate?: FieldValidator;
|
|
230
233
|
}
|
|
231
234
|
interface FieldEntry<TValue = unknown> {
|
|
@@ -343,15 +346,16 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
|
|
|
343
346
|
createPathState<TPath extends Path<TValues>>(path: MaybeRef<TPath>, config?: Partial<PathStateConfig>): PathState<PathValue<TValues, TPath>>;
|
|
344
347
|
getPathState<TPath extends Path<TValues>>(path: TPath): PathState<PathValue<TValues, TPath>> | undefined;
|
|
345
348
|
getAllPathStates(): PathState[];
|
|
346
|
-
removePathState<TPath extends Path<TValues>>(path: TPath): void;
|
|
349
|
+
removePathState<TPath extends Path<TValues>>(path: TPath, id: number): void;
|
|
347
350
|
unsetPathValue<TPath extends Path<TValues>>(path: TPath): void;
|
|
351
|
+
markForUnmount(path: string): void;
|
|
348
352
|
}
|
|
349
353
|
interface BaseComponentBinds<TValue = unknown> {
|
|
350
354
|
modelValue: TValue | undefined;
|
|
351
355
|
'onUpdate:modelValue': (value: TValue) => void;
|
|
352
356
|
onBlur: () => void;
|
|
353
357
|
}
|
|
354
|
-
type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type'>;
|
|
358
|
+
type PublicPathState<TValue = unknown> = Omit<PathState<TValue>, 'bails' | 'label' | 'multiple' | 'fieldsCount' | 'validate' | 'id' | 'type' | '__flags'>;
|
|
355
359
|
interface ComponentBindsConfig<TValue = unknown, TExtraProps extends GenericObject = GenericObject> {
|
|
356
360
|
mapProps: (state: PublicPathState<TValue>) => TExtraProps;
|
|
357
361
|
validateOnBlur: boolean;
|
|
@@ -380,7 +384,7 @@ type LazyInputBindsConfig<TValue = unknown, TExtraProps extends GenericObject =
|
|
|
380
384
|
validateOnChange: boolean;
|
|
381
385
|
validateOnInput: boolean;
|
|
382
386
|
}>;
|
|
383
|
-
interface FormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'keepValuesOnUnmount'> {
|
|
387
|
+
interface FormContext<TValues extends GenericObject = GenericObject, TOutput = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount'> {
|
|
384
388
|
handleReset: () => void;
|
|
385
389
|
submitForm: (e?: unknown) => Promise<void>;
|
|
386
390
|
defineComponentBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrLazy<TPath>, config?: Partial<ComponentBindsConfig<TValue, TExtras>> | LazyComponentBindsConfig<TValue, TExtras>): Ref<BaseComponentBinds<TValue> & TExtras>;
|
package/dist/vee-validate.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.9.
|
|
2
|
+
* vee-validate v4.9.2
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -971,6 +971,7 @@ function useFieldState(path, init) {
|
|
|
971
971
|
value,
|
|
972
972
|
initialValue,
|
|
973
973
|
meta,
|
|
974
|
+
flags: { pendingUnmount: { [id]: false } },
|
|
974
975
|
errors,
|
|
975
976
|
setState,
|
|
976
977
|
};
|
|
@@ -1004,6 +1005,7 @@ function useFieldState(path, init) {
|
|
|
1004
1005
|
errors,
|
|
1005
1006
|
meta: state,
|
|
1006
1007
|
initialValue,
|
|
1008
|
+
flags: state.__flags,
|
|
1007
1009
|
setState,
|
|
1008
1010
|
};
|
|
1009
1011
|
}
|
|
@@ -1499,7 +1501,6 @@ function _useField(path, rules, opts) {
|
|
|
1499
1501
|
const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
|
|
1500
1502
|
const form = controlForm || injectedForm;
|
|
1501
1503
|
const name = lazyToRef(path);
|
|
1502
|
-
let PENDING_UNMOUNT = false;
|
|
1503
1504
|
const validator = computed(() => {
|
|
1504
1505
|
const schema = unref(form === null || form === void 0 ? void 0 : form.schema);
|
|
1505
1506
|
if (schema) {
|
|
@@ -1514,7 +1515,7 @@ function _useField(path, rules, opts) {
|
|
|
1514
1515
|
}
|
|
1515
1516
|
return normalizeRules(rulesValue);
|
|
1516
1517
|
});
|
|
1517
|
-
const { id, value, initialValue, meta, setState, errors } = useFieldState(name, {
|
|
1518
|
+
const { id, value, initialValue, meta, setState, errors, flags } = useFieldState(name, {
|
|
1518
1519
|
modelValue,
|
|
1519
1520
|
form,
|
|
1520
1521
|
bails,
|
|
@@ -1552,7 +1553,7 @@ function _useField(path, rules, opts) {
|
|
|
1552
1553
|
meta.validated = true;
|
|
1553
1554
|
return validateCurrentValue('validated-only');
|
|
1554
1555
|
}, result => {
|
|
1555
|
-
if (
|
|
1556
|
+
if (flags.pendingUnmount[field.id]) {
|
|
1556
1557
|
return;
|
|
1557
1558
|
}
|
|
1558
1559
|
setState({ errors: result.errors });
|
|
@@ -1722,12 +1723,13 @@ function _useField(path, rules, opts) {
|
|
|
1722
1723
|
});
|
|
1723
1724
|
onBeforeUnmount(() => {
|
|
1724
1725
|
var _a;
|
|
1725
|
-
PENDING_UNMOUNT = true;
|
|
1726
1726
|
const shouldKeepValue = (_a = unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : unref(form.keepValuesOnUnmount);
|
|
1727
|
-
|
|
1727
|
+
const path = unravel(name);
|
|
1728
|
+
if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
|
|
1729
|
+
form === null || form === void 0 ? void 0 : form.removePathState(path, id);
|
|
1728
1730
|
return;
|
|
1729
1731
|
}
|
|
1730
|
-
|
|
1732
|
+
flags.pendingUnmount[field.id] = true;
|
|
1731
1733
|
const pathState = form.getPathState(path);
|
|
1732
1734
|
const matchesId = Array.isArray(pathState === null || pathState === void 0 ? void 0 : pathState.id) && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple)
|
|
1733
1735
|
? pathState === null || pathState === void 0 ? void 0 : pathState.id.includes(field.id)
|
|
@@ -1747,9 +1749,9 @@ function _useField(path, rules, opts) {
|
|
|
1747
1749
|
}
|
|
1748
1750
|
}
|
|
1749
1751
|
else {
|
|
1750
|
-
form.unsetPathValue(
|
|
1752
|
+
form.unsetPathValue(unravel(name));
|
|
1751
1753
|
}
|
|
1752
|
-
form.removePathState(path);
|
|
1754
|
+
form.removePathState(path, id);
|
|
1753
1755
|
});
|
|
1754
1756
|
return field;
|
|
1755
1757
|
}
|
|
@@ -2168,19 +2170,22 @@ function useForm(opts) {
|
|
|
2168
2170
|
if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
|
|
2169
2171
|
pathStateExists.multiple = true;
|
|
2170
2172
|
}
|
|
2173
|
+
const id = FIELD_ID_COUNTER++;
|
|
2171
2174
|
if (Array.isArray(pathStateExists.id)) {
|
|
2172
|
-
pathStateExists.id.push(
|
|
2175
|
+
pathStateExists.id.push(id);
|
|
2173
2176
|
}
|
|
2174
2177
|
else {
|
|
2175
|
-
pathStateExists.id = [pathStateExists.id,
|
|
2178
|
+
pathStateExists.id = [pathStateExists.id, id];
|
|
2176
2179
|
}
|
|
2177
2180
|
pathStateExists.fieldsCount++;
|
|
2181
|
+
pathStateExists.__flags.pendingUnmount[id] = false;
|
|
2178
2182
|
return pathStateExists;
|
|
2179
2183
|
}
|
|
2180
2184
|
const currentValue = computed(() => getFromPath(formValues, unravel(path)));
|
|
2181
2185
|
const pathValue = unravel(path);
|
|
2186
|
+
const id = FIELD_ID_COUNTER++;
|
|
2182
2187
|
const state = reactive({
|
|
2183
|
-
id
|
|
2188
|
+
id,
|
|
2184
2189
|
path,
|
|
2185
2190
|
touched: false,
|
|
2186
2191
|
pending: false,
|
|
@@ -2193,6 +2198,9 @@ function useForm(opts) {
|
|
|
2193
2198
|
type: (config === null || config === void 0 ? void 0 : config.type) || 'default',
|
|
2194
2199
|
value: currentValue,
|
|
2195
2200
|
multiple: false,
|
|
2201
|
+
__flags: {
|
|
2202
|
+
pendingUnmount: { [id]: false },
|
|
2203
|
+
},
|
|
2196
2204
|
fieldsCount: 1,
|
|
2197
2205
|
validate: config === null || config === void 0 ? void 0 : config.validate,
|
|
2198
2206
|
dirty: computed(() => {
|
|
@@ -2275,8 +2283,21 @@ function useForm(opts) {
|
|
|
2275
2283
|
const pathState = typeof path === 'string' ? pathStates.value.find(state => state.path === path) : path;
|
|
2276
2284
|
return pathState;
|
|
2277
2285
|
}
|
|
2286
|
+
let UNSET_BATCH = [];
|
|
2287
|
+
let PENDING_UNSET;
|
|
2278
2288
|
function unsetPathValue(path) {
|
|
2279
|
-
|
|
2289
|
+
UNSET_BATCH.push(path);
|
|
2290
|
+
if (!PENDING_UNSET) {
|
|
2291
|
+
PENDING_UNSET = nextTick(() => {
|
|
2292
|
+
const sortedPaths = [...UNSET_BATCH].sort().reverse();
|
|
2293
|
+
sortedPaths.forEach(p => {
|
|
2294
|
+
unsetPath(formValues, p);
|
|
2295
|
+
});
|
|
2296
|
+
UNSET_BATCH = [];
|
|
2297
|
+
PENDING_UNSET = null;
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
return PENDING_UNSET;
|
|
2280
2301
|
}
|
|
2281
2302
|
function makeSubmissionFactory(onlyControlled) {
|
|
2282
2303
|
return function submitHandlerFactory(fn, onValidationError) {
|
|
@@ -2334,7 +2355,7 @@ function useForm(opts) {
|
|
|
2334
2355
|
const handleSubmitImpl = makeSubmissionFactory(false);
|
|
2335
2356
|
const handleSubmit = handleSubmitImpl;
|
|
2336
2357
|
handleSubmit.withControlled = makeSubmissionFactory(true);
|
|
2337
|
-
function removePathState(path) {
|
|
2358
|
+
function removePathState(path, id) {
|
|
2338
2359
|
const idx = pathStates.value.findIndex(s => s.path === path);
|
|
2339
2360
|
const pathState = pathStates.value[idx];
|
|
2340
2361
|
if (idx === -1 || !pathState) {
|
|
@@ -2343,11 +2364,27 @@ function useForm(opts) {
|
|
|
2343
2364
|
if (pathState.multiple && pathState.fieldsCount) {
|
|
2344
2365
|
pathState.fieldsCount--;
|
|
2345
2366
|
}
|
|
2367
|
+
if (Array.isArray(pathState.id)) {
|
|
2368
|
+
const idIndex = pathState.id.indexOf(id);
|
|
2369
|
+
if (idIndex >= 0) {
|
|
2370
|
+
pathState.id.splice(idIndex, 1);
|
|
2371
|
+
}
|
|
2372
|
+
delete pathState.__flags.pendingUnmount[id];
|
|
2373
|
+
}
|
|
2346
2374
|
if (!pathState.multiple || pathState.fieldsCount <= 0) {
|
|
2347
2375
|
pathStates.value.splice(idx, 1);
|
|
2348
2376
|
unsetInitialValue(path);
|
|
2349
2377
|
}
|
|
2350
2378
|
}
|
|
2379
|
+
function markForUnmount(path) {
|
|
2380
|
+
return mutateAllPathState(s => {
|
|
2381
|
+
if (s.path.startsWith(path)) {
|
|
2382
|
+
keysOf(s.__flags.pendingUnmount).forEach(id => {
|
|
2383
|
+
s.__flags.pendingUnmount[id] = true;
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2351
2388
|
const formCtx = {
|
|
2352
2389
|
formId,
|
|
2353
2390
|
values: formValues,
|
|
@@ -2382,6 +2419,7 @@ function useForm(opts) {
|
|
|
2382
2419
|
removePathState,
|
|
2383
2420
|
initialValues: initialValues,
|
|
2384
2421
|
getAllPathStates: () => pathStates.value,
|
|
2422
|
+
markForUnmount,
|
|
2385
2423
|
};
|
|
2386
2424
|
/**
|
|
2387
2425
|
* Sets a single field value
|
|
@@ -2998,6 +3036,7 @@ function useFieldArray(arrayPath) {
|
|
|
2998
3036
|
const newValue = [...pathValue];
|
|
2999
3037
|
newValue.splice(idx, 1);
|
|
3000
3038
|
const fieldPath = pathName + `[${idx}]`;
|
|
3039
|
+
form.markForUnmount(fieldPath);
|
|
3001
3040
|
form.unsetInitialValue(fieldPath);
|
|
3002
3041
|
setInPath(form.values, pathName, newValue);
|
|
3003
3042
|
fields.value.splice(idx, 1);
|
package/dist/vee-validate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.9.
|
|
2
|
+
* vee-validate v4.9.2
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -956,6 +956,7 @@
|
|
|
956
956
|
value,
|
|
957
957
|
initialValue,
|
|
958
958
|
meta,
|
|
959
|
+
flags: { pendingUnmount: { [id]: false } },
|
|
959
960
|
errors,
|
|
960
961
|
setState,
|
|
961
962
|
};
|
|
@@ -989,6 +990,7 @@
|
|
|
989
990
|
errors,
|
|
990
991
|
meta: state,
|
|
991
992
|
initialValue,
|
|
993
|
+
flags: state.__flags,
|
|
992
994
|
setState,
|
|
993
995
|
};
|
|
994
996
|
}
|
|
@@ -1105,7 +1107,6 @@
|
|
|
1105
1107
|
const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
|
|
1106
1108
|
const form = controlForm || injectedForm;
|
|
1107
1109
|
const name = lazyToRef(path);
|
|
1108
|
-
let PENDING_UNMOUNT = false;
|
|
1109
1110
|
const validator = vue.computed(() => {
|
|
1110
1111
|
const schema = vue.unref(form === null || form === void 0 ? void 0 : form.schema);
|
|
1111
1112
|
if (schema) {
|
|
@@ -1120,7 +1121,7 @@
|
|
|
1120
1121
|
}
|
|
1121
1122
|
return normalizeRules(rulesValue);
|
|
1122
1123
|
});
|
|
1123
|
-
const { id, value, initialValue, meta, setState, errors } = useFieldState(name, {
|
|
1124
|
+
const { id, value, initialValue, meta, setState, errors, flags } = useFieldState(name, {
|
|
1124
1125
|
modelValue,
|
|
1125
1126
|
form,
|
|
1126
1127
|
bails,
|
|
@@ -1158,7 +1159,7 @@
|
|
|
1158
1159
|
meta.validated = true;
|
|
1159
1160
|
return validateCurrentValue('validated-only');
|
|
1160
1161
|
}, result => {
|
|
1161
|
-
if (
|
|
1162
|
+
if (flags.pendingUnmount[field.id]) {
|
|
1162
1163
|
return;
|
|
1163
1164
|
}
|
|
1164
1165
|
setState({ errors: result.errors });
|
|
@@ -1309,12 +1310,13 @@
|
|
|
1309
1310
|
});
|
|
1310
1311
|
vue.onBeforeUnmount(() => {
|
|
1311
1312
|
var _a;
|
|
1312
|
-
PENDING_UNMOUNT = true;
|
|
1313
1313
|
const shouldKeepValue = (_a = vue.unref(field.keepValueOnUnmount)) !== null && _a !== void 0 ? _a : vue.unref(form.keepValuesOnUnmount);
|
|
1314
|
-
|
|
1314
|
+
const path = unravel(name);
|
|
1315
|
+
if (shouldKeepValue || !form || flags.pendingUnmount[field.id]) {
|
|
1316
|
+
form === null || form === void 0 ? void 0 : form.removePathState(path, id);
|
|
1315
1317
|
return;
|
|
1316
1318
|
}
|
|
1317
|
-
|
|
1319
|
+
flags.pendingUnmount[field.id] = true;
|
|
1318
1320
|
const pathState = form.getPathState(path);
|
|
1319
1321
|
const matchesId = Array.isArray(pathState === null || pathState === void 0 ? void 0 : pathState.id) && (pathState === null || pathState === void 0 ? void 0 : pathState.multiple)
|
|
1320
1322
|
? pathState === null || pathState === void 0 ? void 0 : pathState.id.includes(field.id)
|
|
@@ -1334,9 +1336,9 @@
|
|
|
1334
1336
|
}
|
|
1335
1337
|
}
|
|
1336
1338
|
else {
|
|
1337
|
-
form.unsetPathValue(
|
|
1339
|
+
form.unsetPathValue(unravel(name));
|
|
1338
1340
|
}
|
|
1339
|
-
form.removePathState(path);
|
|
1341
|
+
form.removePathState(path, id);
|
|
1340
1342
|
});
|
|
1341
1343
|
return field;
|
|
1342
1344
|
}
|
|
@@ -1752,19 +1754,22 @@
|
|
|
1752
1754
|
if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
|
|
1753
1755
|
pathStateExists.multiple = true;
|
|
1754
1756
|
}
|
|
1757
|
+
const id = FIELD_ID_COUNTER++;
|
|
1755
1758
|
if (Array.isArray(pathStateExists.id)) {
|
|
1756
|
-
pathStateExists.id.push(
|
|
1759
|
+
pathStateExists.id.push(id);
|
|
1757
1760
|
}
|
|
1758
1761
|
else {
|
|
1759
|
-
pathStateExists.id = [pathStateExists.id,
|
|
1762
|
+
pathStateExists.id = [pathStateExists.id, id];
|
|
1760
1763
|
}
|
|
1761
1764
|
pathStateExists.fieldsCount++;
|
|
1765
|
+
pathStateExists.__flags.pendingUnmount[id] = false;
|
|
1762
1766
|
return pathStateExists;
|
|
1763
1767
|
}
|
|
1764
1768
|
const currentValue = vue.computed(() => getFromPath(formValues, unravel(path)));
|
|
1765
1769
|
const pathValue = unravel(path);
|
|
1770
|
+
const id = FIELD_ID_COUNTER++;
|
|
1766
1771
|
const state = vue.reactive({
|
|
1767
|
-
id
|
|
1772
|
+
id,
|
|
1768
1773
|
path,
|
|
1769
1774
|
touched: false,
|
|
1770
1775
|
pending: false,
|
|
@@ -1777,6 +1782,9 @@
|
|
|
1777
1782
|
type: (config === null || config === void 0 ? void 0 : config.type) || 'default',
|
|
1778
1783
|
value: currentValue,
|
|
1779
1784
|
multiple: false,
|
|
1785
|
+
__flags: {
|
|
1786
|
+
pendingUnmount: { [id]: false },
|
|
1787
|
+
},
|
|
1780
1788
|
fieldsCount: 1,
|
|
1781
1789
|
validate: config === null || config === void 0 ? void 0 : config.validate,
|
|
1782
1790
|
dirty: vue.computed(() => {
|
|
@@ -1859,8 +1867,21 @@
|
|
|
1859
1867
|
const pathState = typeof path === 'string' ? pathStates.value.find(state => state.path === path) : path;
|
|
1860
1868
|
return pathState;
|
|
1861
1869
|
}
|
|
1870
|
+
let UNSET_BATCH = [];
|
|
1871
|
+
let PENDING_UNSET;
|
|
1862
1872
|
function unsetPathValue(path) {
|
|
1863
|
-
|
|
1873
|
+
UNSET_BATCH.push(path);
|
|
1874
|
+
if (!PENDING_UNSET) {
|
|
1875
|
+
PENDING_UNSET = vue.nextTick(() => {
|
|
1876
|
+
const sortedPaths = [...UNSET_BATCH].sort().reverse();
|
|
1877
|
+
sortedPaths.forEach(p => {
|
|
1878
|
+
unsetPath(formValues, p);
|
|
1879
|
+
});
|
|
1880
|
+
UNSET_BATCH = [];
|
|
1881
|
+
PENDING_UNSET = null;
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
return PENDING_UNSET;
|
|
1864
1885
|
}
|
|
1865
1886
|
function makeSubmissionFactory(onlyControlled) {
|
|
1866
1887
|
return function submitHandlerFactory(fn, onValidationError) {
|
|
@@ -1918,7 +1939,7 @@
|
|
|
1918
1939
|
const handleSubmitImpl = makeSubmissionFactory(false);
|
|
1919
1940
|
const handleSubmit = handleSubmitImpl;
|
|
1920
1941
|
handleSubmit.withControlled = makeSubmissionFactory(true);
|
|
1921
|
-
function removePathState(path) {
|
|
1942
|
+
function removePathState(path, id) {
|
|
1922
1943
|
const idx = pathStates.value.findIndex(s => s.path === path);
|
|
1923
1944
|
const pathState = pathStates.value[idx];
|
|
1924
1945
|
if (idx === -1 || !pathState) {
|
|
@@ -1927,11 +1948,27 @@
|
|
|
1927
1948
|
if (pathState.multiple && pathState.fieldsCount) {
|
|
1928
1949
|
pathState.fieldsCount--;
|
|
1929
1950
|
}
|
|
1951
|
+
if (Array.isArray(pathState.id)) {
|
|
1952
|
+
const idIndex = pathState.id.indexOf(id);
|
|
1953
|
+
if (idIndex >= 0) {
|
|
1954
|
+
pathState.id.splice(idIndex, 1);
|
|
1955
|
+
}
|
|
1956
|
+
delete pathState.__flags.pendingUnmount[id];
|
|
1957
|
+
}
|
|
1930
1958
|
if (!pathState.multiple || pathState.fieldsCount <= 0) {
|
|
1931
1959
|
pathStates.value.splice(idx, 1);
|
|
1932
1960
|
unsetInitialValue(path);
|
|
1933
1961
|
}
|
|
1934
1962
|
}
|
|
1963
|
+
function markForUnmount(path) {
|
|
1964
|
+
return mutateAllPathState(s => {
|
|
1965
|
+
if (s.path.startsWith(path)) {
|
|
1966
|
+
keysOf(s.__flags.pendingUnmount).forEach(id => {
|
|
1967
|
+
s.__flags.pendingUnmount[id] = true;
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1935
1972
|
const formCtx = {
|
|
1936
1973
|
formId,
|
|
1937
1974
|
values: formValues,
|
|
@@ -1966,6 +2003,7 @@
|
|
|
1966
2003
|
removePathState,
|
|
1967
2004
|
initialValues: initialValues,
|
|
1968
2005
|
getAllPathStates: () => pathStates.value,
|
|
2006
|
+
markForUnmount,
|
|
1969
2007
|
};
|
|
1970
2008
|
/**
|
|
1971
2009
|
* Sets a single field value
|
|
@@ -2576,6 +2614,7 @@
|
|
|
2576
2614
|
const newValue = [...pathValue];
|
|
2577
2615
|
newValue.splice(idx, 1);
|
|
2578
2616
|
const fieldPath = pathName + `[${idx}]`;
|
|
2617
|
+
form.markForUnmount(fieldPath);
|
|
2579
2618
|
form.unsetInitialValue(fieldPath);
|
|
2580
2619
|
setInPath(form.values, pathName, newValue);
|
|
2581
2620
|
fields.value.splice(idx, 1);
|
package/dist/vee-validate.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.9.
|
|
2
|
+
* vee-validate v4.9.2
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function l(e){return Number(e)>=0}function i(e,t){return Object.keys(t).forEach((n=>{if(a(t[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}const u={};const o=Symbol("vee-validate-form"),s=Symbol("vee-validate-field-instance"),d=Symbol("Default empty value"),c="undefined"!=typeof window;function v(e){return n(e)&&!!e.__locatorRef}function f(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function p(e){return!!e&&n(e.validate)}function m(e){return"checkbox"===e||"radio"===e}function h(e){return/^\[.+\]$/i.test(e)}function y(e){return"SELECT"===e.tagName}function g(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&&!m(t.type)}function b(e){return O(e)&&e.target&&"submit"in e.target}function O(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function V(e,t){return t in e&&e[t]!==d}function F(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!F(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!F(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var l=a[r];if(!F(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!c&&e instanceof File}function j(e,t,n){"object"==typeof n.value&&(n.value=w(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function w(e){if("object"!=typeof e)return e;var t,n,r,a=0,l=Object.prototype.toString.call(e);if("[object Object]"===l?r=Object.create(e.__proto__||null):"[object Array]"===l?r=Array(e.length):"[object Set]"===l?(r=new Set,e.forEach((function(e){r.add(w(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(w(t),w(e))}))):"[object Date]"===l?r=new Date(+e):"[object RegExp]"===l?r=new RegExp(e.source,e.flags):"[object DataView]"===l?r=new e.constructor(w(e.buffer)):"[object ArrayBuffer]"===l?r=e.slice(0):"Array]"===l.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)j(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]||j(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function S(e){return h(e)?e.replace(/\[|\]/gi,""):e}function E(e,t,n){if(!e)return n;if(h(t))return e[S(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 k(e,t,n){if(h(t))return void(e[S(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=l(a[e+1])?[]:{}),i=i[a[e]]}}function I(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function C(e,t){if(h(t))return void delete e[S(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){I(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const i=n.map(((t,r)=>E(e,n.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)u=i[t],(Array.isArray(u)?0===u.length:a(u)&&0===Object.keys(u).length)&&(0!==t?I(i[t-1],n[t-1]):I(e,n[0]));var u}function M(e){return Object.keys(e)}function B(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function T(e){t.warn(`[vee-validate]: ${e}`)}function P(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 N(e,t){let n;return async function(...r){const a=e(...r);n=a;const l=await a;return a!==n||(n=void 0,t(l,r)),l}}function U({get:e,set:n}){const r=t.ref(w(e()));return t.watch(e,(e=>{F(e,r.value)||(r.value=w(e))}),{deep:!0}),t.watch(r,(t=>{F(t,e())||n(w(t))}),{deep:!0}),r}function _(e){return n(e)?e():t.unref(e)}function $(e){return Array.isArray(e)?e:e?[e]:[]}function D(e){const n=B(o),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(s);return a||(null==r?void 0:r.value)||T(`field with name ${t.unref(e)} was not found`),r||a}function z(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const q=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function L(e){if(K(e))return e._value}function K(e){return"_value"in e}function G(e){if(!O(e))return e;const t=e.target;if(m(t.type)&&K(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(y(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(y(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return t.value}function X(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=H(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=J(t);return n.name?(e[n.name]=H(n.params),e):e}),t):t}function H(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>E(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const J=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let Q=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const W=()=>Q,Y=e=>{Q=Object.assign(Object.assign({},Q),e)};async function Z(e,t,r={}){const a=null==r?void 0:r.bails,l={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(f(e.rules)||p(e.rules))return async function(e,t){const n=f(t)?t:ee(t),r=await n.parse(e),a=[];for(const e of r.errors)e.errors.length&&a.push(...e.errors);return{errors:a}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,l=[];for(let i=0;i<a;i++){const a=r[i],u=await a(t,n);if("string"!=typeof u&&u)continue;const o="string"==typeof u?u:ne(n);if(l.push(o),e.bails)return{errors:l}}return{errors:l}}const r=Object.assign(Object.assign({},e),{rules:X(e.rules)}),a=[],l=Object.keys(r.rules),i=l.length;for(let n=0;n<i;n++){const i=l[n],u=await te(r,t,{name:i,params:r.rules[i]});if(u.error&&(a.push(u.error),e.bails))return{errors:a}}return{errors:a}}(l,e),u=i.errors;return{errors:u,valid:!u.length}}function ee(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function te(e,t,n){const r=(a=n.name,u[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>v(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),i={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:l})},o=await r(t,l,i);return"string"==typeof o?{error:o}:{error:o?void 0:ne(i)}}function ne(e){const t=W().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=M(e).map((async r=>{var a,l,i;const u=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await Z(E(t,r),e[r],{name:(null==u?void 0:u.name)||r,label:null==u?void 0:u.label,values:t,bails:null===(i=null===(l=null==n?void 0:n.bailsMap)||void 0===l?void 0:l[r])||void 0===i||i});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const l=await Promise.all(r),i={},u={};for(const e of l)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,u[e.path]=e.errors[0]);return{valid:a,results:i,errors:u}}let ae=0;function le(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?E(r.initialValues.value,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const u=t.computed(l);if(!r){return{value:t.ref(l()),initialValue:u,setInitialValue:i}}const o=function(e,n,r,a){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return E(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>E(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n)}});return{value:s,initialValue:u,setInitialValue:i}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=ae>=Number.MAX_SAFE_INTEGER?0:++ae,c=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!F(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&l(e.initialValue)}return{id:d,path:e,value:r,initialValue:a,meta:c,errors:o,setState:v}}const i=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),u=t.computed((()=>i.errors));return{id:Array.isArray(i.id)?i.id[i.id.length-1]:i.id,path:e,value:r,errors:u,meta:i,initialValue:a,setState:function(a){var i,u,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(i=n.form)||void 0===i||i.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(u=n.form)||void 0===u||u.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&l(a.initialValue)}}}function ie(e,n,r){return m(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:B(o),l=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function u(n){const r=n.handleChange,u=t.computed((()=>{const e=t.unref(n.value),r=t.unref(l);return Array.isArray(e)?e.findIndex((e=>F(e,r)))>=0:F(r,e)}));function o(o,s=!0){var d;if(u.value===(null===(d=null==o?void 0:o.target)||void 0===d?void 0:d.checked))return void(s&&n.validate());const c=_(e),v=null==a?void 0:a.getPathState(c),f=G(o);let p;p=a&&(null==v?void 0:v.multiple)&&"checkbox"===v.type?P(E(a.values,c)||[],f,void 0):P(t.unref(n.value),t.unref(l),t.unref(i)),r(p,s)}return Object.assign(Object.assign({},n),{checked:u,checkedValue:l,uncheckedValue:i,handleChange:o})}return u(ue(e,n,r))}(e,n,r):ue(e,n,r)}function ue(e,r,a){const{initialValue:l,validateOnMount:i,bails:u,type:c,checkedValue:m,label:h,validateOnValueUpdate:y,uncheckedValue:g,controlled:b,keepValueOnUnmount:O,modelPropName:V,syncVModel:A,form:j}=function(e){var n;const r=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0,controlled:!0}),a=null===(n=null==e?void 0:e.syncVModel)||void 0===n||n,l=a&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),(null==e?void 0:e.modelPropName)||"modelValue"):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},r()),{initialValue:l});const i="valueProp"in e?e.valueProp:e.checkedValue,u="standalone"in e?!e.standalone:e.controlled;return Object.assign(Object.assign(Object.assign({},r()),e||{}),{initialValue:l,controlled:null==u||u,checkedValue:i})}(a),S=b?B(o):void 0,k=j||S,I=function(e){return t.computed((()=>_(e)))}(e);let C=!1;const T=t.computed((()=>{if(t.unref(null==k?void 0:k.schema))return;const e=t.unref(r);return p(e)||f(e)||n(e)||Array.isArray(e)?e:X(e)})),{id:P,value:R,initialValue:U,meta:$,setState:D,errors:z}=le(I,{modelValue:l,form:k,bails:u,label:h,type:c,validate:T.value?J:void 0}),q=t.computed((()=>z.value[0]));A&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const l=e||"modelValue",i=`update:${l}`;if(!(l in a.props))return;t.watch(n,(e=>{F(e,oe(a,l))||a.emit(i,e)})),t.watch((()=>oe(a,l)),(e=>{if(e===d&&void 0===n.value)return;const t=e===d?void 0:e;F(t,x(n.value,a.props.modelModifiers))||r(t)}))}({value:R,prop:V,handleChange:Q});async function L(e){var n,r;return(null==k?void 0:k.validateSchema)?null!==(n=(await k.validateSchema(e)).results[t.unref(I)])&&void 0!==n?n:{valid:!0,errors:[]}:T.value?Z(R.value,T.value,{name:t.unref(I),label:t.unref(h),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const K=N((async()=>($.pending=!0,$.validated=!0,L("validated-only"))),(e=>{if(!C)return D({errors:e.errors}),$.pending=!1,$.valid=e.valid,e})),H=N((async()=>L("silent")),(e=>($.valid=e.valid,e)));function J(e){return"silent"===(null==e?void 0:e.mode)?H():K()}function Q(e,t=!0){Y(G(e),!1),!y&&t&&K()}function W(e){var t;const n=e&&"value"in e?e.value:U.value;D({value:w(n),initialValue:w(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),$.pending=!1,$.validated=!1,H()}function Y(e,t=!0){if(R.value=e,!t)return;(y?K:H)()}t.onMounted((()=>{if(i)return K();k&&k.validateSchema||H()}));const ee=t.computed({get:()=>R.value,set(e){Y(e,y)}}),te={id:P,name:I,label:h,value:ee,meta:$,errors:z,errorMessage:q,type:c,checkedValue:m,uncheckedValue:g,bails:u,keepValueOnUnmount:O,resetField:W,handleReset:()=>W(),validate:J,handleChange:Q,handleBlur:()=>{$.touched=!0},setState:D,setTouched:function(e){$.touched=e},setErrors:function(e){D({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(s,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{F(e,t)||($.validated?K():H())}),{deep:!0}),!k)return te;const ne=t.computed((()=>{const e=T.value;return!e||n(e)||p(e)||f(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(v):M(a).filter((e=>v(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=E(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!F(e,t)&&($.validated?K():H())})),t.onBeforeUnmount((()=>{var e;C=!0;if((null!==(e=t.unref(te.keepValueOnUnmount))&&void 0!==e?e:t.unref(k.keepValuesOnUnmount))||!k)return;const n=_(I),r=k.getPathState(n);if(Array.isArray(null==r?void 0:r.id)&&(null==r?void 0:r.multiple)?null==r?void 0:r.id.includes(te.id):(null==r?void 0:r.id)===te.id){if((null==r?void 0:r.multiple)&&Array.isArray(r.value)){const e=r.value.findIndex((e=>F(e,t.unref(te.checkedValue))));if(e>-1){const t=[...r.value];t.splice(e,1),k.setFieldValue(n,t)}Array.isArray(r.id)&&r.id.splice(r.id.indexOf(te.id),1)}else k.unsetPathValue(n);k.removePathState(n)}})),te}function oe(e,t){if(e)return e.props[t]}function se(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function de(e,t){return m(t.attrs.type)?V(e,"modelValue")?e.modelValue:void 0:V(e,"modelValue")?e.modelValue:t.attrs.value}const ce=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>W().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:d},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const a=t.toRef(e,"rules"),l=t.toRef(e,"name"),i=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:h,resetField:y,handleReset:b,meta:O,checked:V,setErrors:F}=ie(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},j=function(e){(e=>{m(r.attrs.type)||(d.value=G(e))})(e),r.emit("update:modelValue",d.value)},w=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:l,validateOnModelUpdate:i}=function(e){var t,n,r,a;const{validateOnInput:l,validateOnChange:i,validateOnBlur:u,validateOnModelUpdate:o}=W();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:l,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:u,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const u={name:e.name,onBlur:function(e){p(e),n(r.attrs.onBlur)&&r.attrs.onBlur(e),l&&v()},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,i)};m(r.attrs.type)&&V&&(u.checked=V.value);return g(se(e,r),r.attrs)&&(u.value=d.value),u}));function S(){return{field:w.value,value:d.value,meta:O,errors:s.value,errorMessage:c.value,validate:v,resetField:y,handleChange:A,handleInput:j,handleReset:b,handleBlur:p,setTouched:h,setErrors:F}}return r.expose({setErrors:F,setTouched:h,reset:y,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),a=q(n,r,S);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&f(a)&&n(a.cast)?w(a.cast(r)||{}):w(r)}function me(e){var r;const a=ve++;let l=0;const u=t.ref(!1),s=t.ref(0),d=[],c=t.reactive(pe(e)),v=t.ref([]),m=t.ref({});function h(e,t){const n=H(e);n?n.errors=$(t):m.value[e]=$(t)}function y(e){M(e).forEach((t=>{h(t,e[t])}))}(null==e?void 0:e.initialErrors)&&y(e.initialErrors);const g=t.computed((()=>{const e=v.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},m.value),e)})),O=t.computed((()=>M(g.value).reduce(((e,t)=>{const n=g.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),V=t.computed((()=>v.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),A=t.computed((()=>v.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),j=Object.assign({},(null==e?void 0:e.initialErrors)||{}),S=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:I,originalInitialValues:B,setInitialValues:T}=function(e,n,r){const a=pe(r),l=null==r?void 0:r.initialValues,i=t.ref(a),u=t.ref(w(a));function o(t,r=!1){i.value=w(t),u.value=w(t),r&&e.value.forEach((e=>{if(e.touched)return;const t=E(i.value,e.path);k(n,e.path,w(t))}))}t.isRef(l)&&t.watch(l,(e=>{o(e,!0)}),{deep:!0});return{initialValues:i,originalInitialValues:u,setInitialValues:o}}(v,c,e),P=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!F(n,t.unref(r))));function u(){const t=e.value;return M(l).reduce(((e,n)=>{const r=l[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(u());return t.watchEffect((()=>{const e=u();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!M(a.value).length,dirty:i.value})))}(v,c,B,O),x=t.computed((()=>v.value.reduce(((e,t)=>{const n=E(c,t.path);return k(e,t.path,n),e}),{}))),U=null==e?void 0:e.validationSchema;function D(e,n){var r,a;const i=t.computed((()=>E(I.value,_(e)))),u=v.value.find((n=>n.path===t.unref(e)));if(u)return"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(u.multiple=!0),Array.isArray(u.id)?u.id.push(l++):u.id=[u.id,l++],u.fieldsCount++,u;const o=t.computed((()=>E(c,_(e)))),s=_(e),d=t.reactive({id:l++,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=j[s])||void 0===r?void 0:r.length),initialValue:i,errors:t.shallowRef([]),bails:null!==(a=null==n?void 0:n.bails)&&void 0!==a&&a,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!F(t.unref(o),t.unref(i))))});return v.value.push(d),O.value[s]&&!j[s]&&t.nextTick((()=>{se(s)})),t.isRef(e)&&t.watch(e,(e=>{const n=w(o.value);t.nextTick((()=>{k(c,e,n)}))})),d}const q=R(me,5),L=R(me,5),K=N((async e=>"silent"===await e?q():L()),((e,[t])=>{const n=M(Y.errorBag.value);return[...new Set([...M(e.results),...v.value.map((e=>e.path)),...n])].reduce(((n,r)=>{const a=r,l=H(a),i=(e.results[a]||{errors:[]}).errors,u={errors:i,valid:!i.length};return n.results[a]=u,u.valid||(n.errors[a]=u.errors[0]),l&&m.value[a]&&delete m.value[a],l?(l.valid=u.valid,"silent"===t?n:"validated-only"!==t||l.validated?(h(l,u.errors),n):n):(h(a,i),n)}),{valid:e.valid,results:{},errors:{}})}));function X(e){v.value.forEach(e)}function H(e){return"string"==typeof e?v.value.find((t=>t.path===e)):e}function J(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),X((e=>e.touched=!0)),u.value=!0,s.value++,oe().then((a=>{const l=w(c);if(a.valid&&"function"==typeof t){const n=w(x.value);let i=e?n:l;return a.values&&(i=a.values),t(i,{evt:r,controlledValues:n,setErrors:y,setFieldError:h,setTouched:le,setFieldTouched:ae,setValues:te,setFieldValue:Z,resetForm:ue,resetField:ie})}a.valid||"function"!=typeof n||n({values:l,evt:r,errors:a.errors,results:a.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const Q=J(!1);Q.withControlled=J(!0);const Y={formId:a,values:c,controlledValues:x,errorBag:g,errors:O,schema:U,submitCount:s,meta:P,isSubmitting:u,fieldArrays:d,keepValuesOnUnmount:S,validateSchema:t.unref(U)?K:void 0,validate:oe,setFieldError:h,validateField:se,setFieldValue:Z,setValues:te,setErrors:y,setFieldTouched:ae,setTouched:le,resetForm:ue,resetField:ie,handleSubmit:Q,stageInitialValue:function(t,n,r=!1){ce(t,n),k(c,t,n),r&&!(null==e?void 0:e.initialValues)&&k(B.value,t,w(n))},unsetInitialValue:de,setFieldInitialValue:ce,useFieldModel:function(e){if(!Array.isArray(e))return ne(e);return e.map(ne)},createPathState:D,getPathState:H,unsetPathValue:function(e){C(c,e)},removePathState:function(e){const t=v.value.findIndex((t=>t.path===e)),n=v.value[t];-1!==t&&n&&(n.multiple&&n.fieldsCount&&n.fieldsCount--,(!n.multiple||n.fieldsCount<=0)&&(v.value.splice(t,1),de(e)))},initialValues:I,getAllPathStates:()=>v.value};function Z(e,t){const n=w(t),r="string"==typeof e?e:e.path;H(r)||D(r),k(c,r,n)}function te(e){i(c,e),d.forEach((e=>e&&e.reset()))}function ne(e){const n=H(t.unref(e))||D(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);Z(a,r),n.validated=!0,n.pending=!0,se(a).then((()=>{n.pending=!1}))}})}function ae(e,t){const n=H(e);n&&(n.touched=t)}function le(e){M(e).forEach((t=>{ae(t,!!e[t])}))}function ie(e,t){var n;const r=t&&"value"in t?t.value:E(I.value,e);ce(e,w(r)),Z(e,r),ae(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),h(e,(null==t?void 0:t.errors)||[])}function ue(e){const n=(null==e?void 0:e.values)?e.values:B.value;T(n),te(n),X((t=>{var r;t.validated=!1,t.touched=(null===(r=null==e?void 0:e.touched)||void 0===r?void 0:r[t.path])||!1,Z(t.path,E(n,t.path)),h(t.path,void 0)})),y((null==e?void 0:e.errors)||{}),s.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{oe({mode:"silent"})}))}async function oe(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&X((e=>e.validated=!0)),Y.validateSchema)return Y.validateSchema(t);const n=await Promise.all(v.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]})))),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=H(e);if(n&&(n.validated=!0),U){const{results:t}=await K("validated-only");return t[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate():(n||t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function de(e){C(I.value,e)}function ce(e,t){k(I.value,e,w(t))}async function me(){const e=t.unref(U);if(!e)return{valid:!0,results:{},errors:{}};const n=p(e)||f(e)?await async function(e,t){const n=f(e)?e:ee(e),r=await n.parse(t),a={},l={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));a[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!r.errors.length,results:a,errors:l,values:r.value}}(e,c):await re(e,c,{names:V.value,bailsMap:A.value});return n}const he=Q(((e,{evt:t})=>{b(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&y(e.initialErrors),(null==e?void 0:e.initialTouched)&&le(e.initialTouched),(null==e?void 0:e.validateOnMount)?oe():Y.validateSchema&&Y.validateSchema("silent")})),t.isRef(U)&&t.watch(U,(()=>{var e;null===(e=Y.validateSchema)||void 0===e||e.call(Y,"validated-only")})),t.provide(o,Y),Object.assign(Object.assign({},Y),{handleReset:()=>ue(),submitForm:he,defineComponentBinds:function(e,r){const a=H(_(e))||D(e),l=()=>n(r)?r(z(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:W().validateOnBlur)&&se(a.path)}function u(e){var t;Z(a.path,e);(null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:W().validateOnModelUpdate)&&se(a.path)}return t.computed((()=>{const e={modelValue:a.value,"onUpdate:modelValue":u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(a).props||{}):(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},e),r.mapProps(z(a,fe))):e}))},defineInputBinds:function(e,r){const a=H(_(e))||D(e),l=()=>n(r)?r(z(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:W().validateOnBlur)&&se(a.path)}function u(e){var t;const n=G(e);Z(a.path,n);(null!==(t=l().validateOnInput)&&void 0!==t?t:W().validateOnInput)&&se(a.path)}function o(e){var t;const n=G(e);Z(a.path,n);(null!==(t=l().validateOnChange)&&void 0!==t?t:W().validateOnChange)&&se(a.path)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(z(a,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(a,fe))):e}))}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:i,errorBag:u,values:o,meta:s,isSubmitting:d,submitCount:c,controlledValues:v,validate:f,validateField:p,handleReset:m,resetForm:h,handleSubmit:y,setErrors:g,setFieldError:V,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetField:E}=me({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),k=y(((e,{evt:t})=>{b(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?y(e.onSubmit,e.onInvalidSubmit):k;function C(e){O(e)&&e.preventDefault(),m(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function M(t,n){return y("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function B(){return w(o)}function T(){return w(s.value)}function P(){return w(i.value)}function R(){return{meta:s.value,errors:i.value,errorBag:u.value,values:o,isSubmitting:d.value,submitCount:c.value,controlledValues:v.value,validate:f,validateField:p,handleSubmit:M,handleReset:m,submitForm:k,setErrors:g,setFieldError:V,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetForm:h,resetField:E,getValues:B,getMeta:T,getErrors:P}}return n.expose({setFieldError:V,setErrors:g,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetForm:h,validate:f,validateField:p,resetField:E,getValues:B,getMeta:T,getErrors:P}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=q(r,n,R);if(!e.as)return a;const l="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},l),n.attrs),{onSubmit:I,onReset:C}),a)}}}),ye=he;function ge(e){const n=B(o,void 0),a=t.ref([]),l=()=>{},i={fields:a,remove:l,push:l,swap:l,insert:l,update:l,replace:l,prepend:l,move:l};if(!n)return T("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 T("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const u=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(u)return u;let s=0;function d(){return E(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=d();Array.isArray(e)&&(a.value=e.map(((e,t)=>f(e,t,a.value))),v())}function v(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(l,i,u){if(u&&!r(i)&&u[i])return u[i];const o=s++,d={key:o,value:U({get(){const r=E(null==n?void 0:n.values,t.unref(e),[])||[],i=a.value.findIndex((e=>e.key===o));return-1===i?l:r[i]},set(e){const t=a.value.findIndex((e=>e.key===o));-1!==t?m(t,e):T("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,a){const l=t.unref(e),i=E(null==n?void 0:n.values,l);!Array.isArray(i)||i.length-1<r||(k(n.values,`${l}[${r}]`,a),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:a,remove:function(r){const l=t.unref(e),i=E(null==n?void 0:n.values,l);if(!i||!Array.isArray(i))return;const u=[...i];u.splice(r,1);const o=l+`[${r}]`;n.unsetInitialValue(o),k(n.values,l,u),a.value.splice(r,1),p()},push:function(l){const i=t.unref(e),u=E(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[...o];s.push(l),n.stageInitialValue(i+`[${s.length-1}]`,l),k(n.values,i,s),a.value.push(f(l)),p()},swap:function(r,l){const i=t.unref(e),u=E(null==n?void 0:n.values,i);if(!Array.isArray(u)||!(r in u)||!(l in u))return;const o=[...u],s=[...a.value],d=o[r];o[r]=o[l],o[l]=d;const c=s[r];s[r]=s[l],s[l]=c,k(n.values,i,o),a.value=s,v()},insert:function(r,l){const i=t.unref(e),u=E(null==n?void 0:n.values,i);if(!Array.isArray(u)||u.length<r)return;const o=[...u],s=[...a.value];o.splice(r,0,l),s.splice(r,0,f(l)),k(n.values,i,o),a.value=s,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),k(n.values,a,r),c(),p()},prepend:function(l){const i=t.unref(e),u=E(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[l,...o];n.stageInitialValue(i+`[${s.length-1}]`,l),k(n.values,i,s),a.value.unshift(f(l)),p()},move:function(l,i){const u=t.unref(e),o=E(null==n?void 0:n.values,u),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(l in o)||!(i in o))return;const d=[...a.value],c=d[l];d.splice(l,1),d.splice(i,0,c);const v=s[l];s.splice(l,1),s.splice(i,0,v),k(n.values,u,s),a.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(d,(e=>{F(e,a.value.map((e=>e.value)))||c()})),h}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:l,insert:i,replace:u,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}),()=>q(void 0,n,v)}}),Oe=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 l(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=q(r,n,l),u=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,u,i):t.h(r||"span",u,a.value):i}}});e.ErrorMessage=Oe,e.Field=ce,e.FieldArray=be,e.FieldContextKey=s,e.Form=ye,e.FormContextKey=o,e.IS_ABSENT=d,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),u[e]=t},e.useField=ie,e.useFieldArray=ge,e.useFieldError=function(e){const n=B(o),r=e?void 0:t.inject(s);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=B(o),r=e?void 0:t.inject(s);return t.computed((()=>e?E(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=B(o);return e||T("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=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=B(o);return e||T("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=B(o);return e||T("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=B(o);return e||T("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=B(o);return e||T("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=B(o);return e||T("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=B(o);return e||T("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=B(o);t||T("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=B(o),r=e?void 0:t.inject(s);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(T(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=B(o);return e||T("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re}));
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function l(e){return Number(e)>=0}function i(e,t){return Object.keys(t).forEach((n=>{if(a(t[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}const u={};const o=Symbol("vee-validate-form"),s=Symbol("vee-validate-field-instance"),d=Symbol("Default empty value"),c="undefined"!=typeof window;function v(e){return n(e)&&!!e.__locatorRef}function f(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function p(e){return!!e&&n(e.validate)}function m(e){return"checkbox"===e||"radio"===e}function h(e){return/^\[.+\]$/i.test(e)}function y(e){return"SELECT"===e.tagName}function g(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&&!m(t.type)}function b(e){return O(e)&&e.target&&"submit"in e.target}function O(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function V(e,t){return t in e&&e[t]!==d}function F(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!F(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!F(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var l=a[r];if(!F(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!c&&e instanceof File}function j(e,t,n){"object"==typeof n.value&&(n.value=w(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function w(e){if("object"!=typeof e)return e;var t,n,r,a=0,l=Object.prototype.toString.call(e);if("[object Object]"===l?r=Object.create(e.__proto__||null):"[object Array]"===l?r=Array(e.length):"[object Set]"===l?(r=new Set,e.forEach((function(e){r.add(w(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(w(t),w(e))}))):"[object Date]"===l?r=new Date(+e):"[object RegExp]"===l?r=new RegExp(e.source,e.flags):"[object DataView]"===l?r=new e.constructor(w(e.buffer)):"[object ArrayBuffer]"===l?r=e.slice(0):"Array]"===l.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)j(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]||j(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function S(e){return h(e)?e.replace(/\[|\]/gi,""):e}function E(e,t,n){if(!e)return n;if(h(t))return e[S(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 k(e,t,n){if(h(t))return void(e[S(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=l(a[e+1])?[]:{}),i=i[a[e]]}}function I(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function C(e,t){if(h(t))return void delete e[S(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){I(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const i=n.map(((t,r)=>E(e,n.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)u=i[t],(Array.isArray(u)?0===u.length:a(u)&&0===Object.keys(u).length)&&(0!==t?I(i[t-1],n[t-1]):I(e,n[0]));var u}function M(e){return Object.keys(e)}function B(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function _(e){t.warn(`[vee-validate]: ${e}`)}function 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 U(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 P(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function R(e,t){let n;return async function(...r){const a=e(...r);n=a;const l=await a;return a!==n||(n=void 0,t(l,r)),l}}function x({get:e,set:n}){const r=t.ref(w(e()));return t.watch(e,(e=>{F(e,r.value)||(r.value=w(e))}),{deep:!0}),t.watch(r,(t=>{F(t,e())||n(w(t))}),{deep:!0}),r}function N(e){return n(e)?e():t.unref(e)}function $(e){return Array.isArray(e)?e:e?[e]:[]}function D(e){const n=B(o),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(s);return a||(null==r?void 0:r.value)||_(`field with name ${t.unref(e)} was not found`),r||a}function z(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const q=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function L(e){if(K(e))return e._value}function K(e){return"_value"in e}function G(e){if(!O(e))return e;const t=e.target;if(m(t.type)&&K(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(y(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(y(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return t.value}function W(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=X(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=H(t);return n.name?(e[n.name]=X(n.params),e):e}),t):t}function X(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>E(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const H=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let J=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Q=()=>J,Y=e=>{J=Object.assign(Object.assign({},J),e)};async function Z(e,t,r={}){const a=null==r?void 0:r.bails,l={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(f(e.rules)||p(e.rules))return async function(e,t){const n=f(t)?t:ee(t),r=await n.parse(e),a=[];for(const e of r.errors)e.errors.length&&a.push(...e.errors);return{errors:a}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,l=[];for(let i=0;i<a;i++){const a=r[i],u=await a(t,n);if("string"!=typeof u&&u)continue;const o="string"==typeof u?u:ne(n);if(l.push(o),e.bails)return{errors:l}}return{errors:l}}const r=Object.assign(Object.assign({},e),{rules:W(e.rules)}),a=[],l=Object.keys(r.rules),i=l.length;for(let n=0;n<i;n++){const i=l[n],u=await te(r,t,{name:i,params:r.rules[i]});if(u.error&&(a.push(u.error),e.bails))return{errors:a}}return{errors:a}}(l,e),u=i.errors;return{errors:u,valid:!u.length}}function ee(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function te(e,t,n){const r=(a=n.name,u[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>v(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),i={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:l})},o=await r(t,l,i);return"string"==typeof o?{error:o}:{error:o?void 0:ne(i)}}function ne(e){const t=Q().generateMessage;return t?t(e):"Field is invalid"}async function re(e,t,n){const r=M(e).map((async r=>{var a,l,i;const u=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await Z(E(t,r),e[r],{name:(null==u?void 0:u.name)||r,label:null==u?void 0:u.label,values:t,bails:null===(i=null===(l=null==n?void 0:n.bailsMap)||void 0===l?void 0:l[r])||void 0===i||i});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const l=await Promise.all(r),i={},u={};for(const e of l)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,u[e.path]=e.errors[0]);return{valid:a,results:i,errors:u}}let ae=0;function le(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?E(r.initialValues.value,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const u=t.computed(l);if(!r){return{value:t.ref(l()),initialValue:u,setInitialValue:i}}const o=function(e,n,r,a){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return E(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>E(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n)}});return{value:s,initialValue:u,setInitialValue:i}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=ae>=Number.MAX_SAFE_INTEGER?0:++ae,c=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!F(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&l(e.initialValue)}return{id:d,path:e,value:r,initialValue:a,meta:c,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const i=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),u=t.computed((()=>i.errors));return{id:Array.isArray(i.id)?i.id[i.id.length-1]:i.id,path:e,value:r,errors:u,meta:i,initialValue:a,flags:i.__flags,setState:function(a){var i,u,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(i=n.form)||void 0===i||i.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(u=n.form)||void 0===u||u.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&l(a.initialValue)}}}function ie(e,n,r){return m(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:B(o),l=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function u(n){const r=n.handleChange,u=t.computed((()=>{const e=t.unref(n.value),r=t.unref(l);return Array.isArray(e)?e.findIndex((e=>F(e,r)))>=0:F(r,e)}));function o(o,s=!0){var d;if(u.value===(null===(d=null==o?void 0:o.target)||void 0===d?void 0:d.checked))return void(s&&n.validate());const c=N(e),v=null==a?void 0:a.getPathState(c),f=G(o);let p;p=a&&(null==v?void 0:v.multiple)&&"checkbox"===v.type?T(E(a.values,c)||[],f,void 0):T(t.unref(n.value),t.unref(l),t.unref(i)),r(p,s)}return Object.assign(Object.assign({},n),{checked:u,checkedValue:l,uncheckedValue:i,handleChange:o})}return u(ue(e,n,r))}(e,n,r):ue(e,n,r)}function ue(e,r,a){const{initialValue:l,validateOnMount:i,bails:u,type:c,checkedValue:m,label:h,validateOnValueUpdate:y,uncheckedValue:g,controlled:b,keepValueOnUnmount:O,modelPropName:V,syncVModel:A,form:j}=function(e){var n;const r=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0,controlled:!0}),a=null===(n=null==e?void 0:e.syncVModel)||void 0===n||n,l=a&&!("initialValue"in(e||{}))?oe(t.getCurrentInstance(),(null==e?void 0:e.modelPropName)||"modelValue"):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},r()),{initialValue:l});const i="valueProp"in e?e.valueProp:e.checkedValue,u="standalone"in e?!e.standalone:e.controlled;return Object.assign(Object.assign(Object.assign({},r()),e||{}),{initialValue:l,controlled:null==u||u,checkedValue:i})}(a),S=b?B(o):void 0,k=j||S,I=function(e){return t.computed((()=>N(e)))}(e),C=t.computed((()=>{if(t.unref(null==k?void 0:k.schema))return;const e=t.unref(r);return p(e)||f(e)||n(e)||Array.isArray(e)?e:W(e)})),{id:_,value:T,initialValue:U,meta:x,setState:$,errors:D,flags:z}=le(I,{modelValue:l,form:k,bails:u,label:h,type:c,validate:C.value?H:void 0}),q=t.computed((()=>D.value[0]));A&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const l=e||"modelValue",i=`update:${l}`;if(!(l in a.props))return;t.watch(n,(e=>{F(e,oe(a,l))||a.emit(i,e)})),t.watch((()=>oe(a,l)),(e=>{if(e===d&&void 0===n.value)return;const t=e===d?void 0:e;F(t,P(n.value,a.props.modelModifiers))||r(t)}))}({value:T,prop:V,handleChange:J});async function L(e){var n,r;return(null==k?void 0:k.validateSchema)?null!==(n=(await k.validateSchema(e)).results[t.unref(I)])&&void 0!==n?n:{valid:!0,errors:[]}:C.value?Z(T.value,C.value,{name:t.unref(I),label:t.unref(h),values:null!==(r=null==k?void 0:k.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const K=R((async()=>(x.pending=!0,x.validated=!0,L("validated-only"))),(e=>{if(!z.pendingUnmount[te.id])return $({errors:e.errors}),x.pending=!1,x.valid=e.valid,e})),X=R((async()=>L("silent")),(e=>(x.valid=e.valid,e)));function H(e){return"silent"===(null==e?void 0:e.mode)?X():K()}function J(e,t=!0){Y(G(e),!1),!y&&t&&K()}function Q(e){var t;const n=e&&"value"in e?e.value:U.value;$({value:w(n),initialValue:w(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),x.pending=!1,x.validated=!1,X()}function Y(e,t=!0){if(T.value=e,!t)return;(y?K:X)()}t.onMounted((()=>{if(i)return K();k&&k.validateSchema||X()}));const ee=t.computed({get:()=>T.value,set(e){Y(e,y)}}),te={id:_,name:I,label:h,value:ee,meta:x,errors:D,errorMessage:q,type:c,checkedValue:m,uncheckedValue:g,bails:u,keepValueOnUnmount:O,resetField:Q,handleReset:()=>Q(),validate:H,handleChange:J,handleBlur:()=>{x.touched=!0},setState:$,setTouched:function(e){x.touched=e},setErrors:function(e){$({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(s,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{F(e,t)||(x.validated?K():X())}),{deep:!0}),!k)return te;const ne=t.computed((()=>{const e=C.value;return!e||n(e)||p(e)||f(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(v):M(a).filter((e=>v(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=E(k.values,t)||k.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(ne,((e,t)=>{if(!Object.keys(e).length)return;!F(e,t)&&(x.validated?K():X())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(te.keepValueOnUnmount))&&void 0!==e?e:t.unref(k.keepValuesOnUnmount),r=N(I);if(n||!k||z.pendingUnmount[te.id])return void(null==k||k.removePathState(r,_));z.pendingUnmount[te.id]=!0;const a=k.getPathState(r);if(Array.isArray(null==a?void 0:a.id)&&(null==a?void 0:a.multiple)?null==a?void 0:a.id.includes(te.id):(null==a?void 0:a.id)===te.id){if((null==a?void 0:a.multiple)&&Array.isArray(a.value)){const e=a.value.findIndex((e=>F(e,t.unref(te.checkedValue))));if(e>-1){const t=[...a.value];t.splice(e,1),k.setFieldValue(r,t)}Array.isArray(a.id)&&a.id.splice(a.id.indexOf(te.id),1)}else k.unsetPathValue(N(I));k.removePathState(r,_)}})),te}function oe(e,t){if(e)return e.props[t]}function se(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function de(e,t){return m(t.attrs.type)?V(e,"modelValue")?e.modelValue:void 0:V(e,"modelValue")?e.modelValue:t.attrs.value}const ce=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>Q().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:d},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const a=t.toRef(e,"rules"),l=t.toRef(e,"name"),i=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:h,resetField:y,handleReset:b,meta:O,checked:V,setErrors:F}=ie(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:de(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},j=function(e){(e=>{m(r.attrs.type)||(d.value=G(e))})(e),r.emit("update:modelValue",d.value)},w=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:l,validateOnModelUpdate:i}=function(e){var t,n,r,a;const{validateOnInput:l,validateOnChange:i,validateOnBlur:u,validateOnModelUpdate:o}=Q();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:l,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:u,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const u={name:e.name,onBlur:function(e){p(e),n(r.attrs.onBlur)&&r.attrs.onBlur(e),l&&v()},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,i)};m(r.attrs.type)&&V&&(u.checked=V.value);return g(se(e,r),r.attrs)&&(u.value=d.value),u}));function S(){return{field:w.value,value:d.value,meta:O,errors:s.value,errorMessage:c.value,validate:v,resetField:y,handleChange:A,handleInput:j,handleReset:b,handleBlur:p,setTouched:h,setErrors:F}}return r.expose({setErrors:F,setTouched:h,reset:y,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(se(e,r)),a=q(n,r,S);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let ve=0;const fe=["bails","fieldsCount","id","multiple","type","validate"];function pe(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&f(a)&&n(a.cast)?w(a.cast(r)||{}):w(r)}function me(e){var r;const a=ve++;let l=0;const u=t.ref(!1),s=t.ref(0),d=[],c=t.reactive(pe(e)),v=t.ref([]),m=t.ref({});function h(e,t){const n=X(e);n?n.errors=$(t):m.value[e]=$(t)}function y(e){M(e).forEach((t=>{h(t,e[t])}))}(null==e?void 0:e.initialErrors)&&y(e.initialErrors);const g=t.computed((()=>{const e=v.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},m.value),e)})),O=t.computed((()=>M(g.value).reduce(((e,t)=>{const n=g.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),V=t.computed((()=>v.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),A=t.computed((()=>v.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),j=Object.assign({},(null==e?void 0:e.initialErrors)||{}),S=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:I,originalInitialValues:B,setInitialValues:_}=function(e,n,r){const a=pe(r),l=null==r?void 0:r.initialValues,i=t.ref(a),u=t.ref(w(a));function o(t,r=!1){i.value=w(t),u.value=w(t),r&&e.value.forEach((e=>{if(e.touched)return;const t=E(i.value,e.path);k(n,e.path,w(t))}))}t.isRef(l)&&t.watch(l,(e=>{o(e,!0)}),{deep:!0});return{initialValues:i,originalInitialValues:u,setInitialValues:o}}(v,c,e),T=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!F(n,t.unref(r))));function u(){const t=e.value;return M(l).reduce(((e,n)=>{const r=l[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(u());return t.watchEffect((()=>{const e=u();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!M(a.value).length,dirty:i.value})))}(v,c,B,O),P=t.computed((()=>v.value.reduce(((e,t)=>{const n=E(c,t.path);return k(e,t.path,n),e}),{}))),x=null==e?void 0:e.validationSchema;function D(e,n){var r,a;const i=t.computed((()=>E(I.value,N(e)))),u=v.value.find((n=>n.path===t.unref(e)));if(u){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(u.multiple=!0);const e=l++;return Array.isArray(u.id)?u.id.push(e):u.id=[u.id,e],u.fieldsCount++,u.__flags.pendingUnmount[e]=!1,u}const o=t.computed((()=>E(c,N(e)))),s=N(e),d=l++,f=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=j[s])||void 0===r?void 0:r.length),initialValue:i,errors:t.shallowRef([]),bails:null!==(a=null==n?void 0:n.bails)&&void 0!==a&&a,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1}},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!F(t.unref(o),t.unref(i))))});return v.value.push(f),O.value[s]&&!j[s]&&t.nextTick((()=>{ce(s)})),t.isRef(e)&&t.watch(e,(e=>{const n=w(o.value);t.nextTick((()=>{k(c,e,n)}))})),f}const q=U(ye,5),L=U(ye,5),K=R((async e=>"silent"===await e?q():L()),((e,[t])=>{const n=M(te.errorBag.value);return[...new Set([...M(e.results),...v.value.map((e=>e.path)),...n])].reduce(((n,r)=>{const a=r,l=X(a),i=(e.results[a]||{errors:[]}).errors,u={errors:i,valid:!i.length};return n.results[a]=u,u.valid||(n.errors[a]=u.errors[0]),l&&m.value[a]&&delete m.value[a],l?(l.valid=u.valid,"silent"===t?n:"validated-only"!==t||l.validated?(h(l,u.errors),n):n):(h(a,i),n)}),{valid:e.valid,results:{},errors:{}})}));function W(e){v.value.forEach(e)}function X(e){return"string"==typeof e?v.value.find((t=>t.path===e)):e}let H,J=[];function Y(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),W((e=>e.touched=!0)),u.value=!0,s.value++,de().then((a=>{const l=w(c);if(a.valid&&"function"==typeof t){const n=w(P.value);let i=e?n:l;return a.values&&(i=a.values),t(i,{evt:r,controlledValues:n,setErrors:y,setFieldError:h,setTouched:ue,setFieldTouched:ie,setValues:ae,setFieldValue:ne,resetForm:se,resetField:oe})}a.valid||"function"!=typeof n||n({values:l,evt:r,errors:a.errors,results:a.results})})).then((e=>(u.value=!1,e)),(e=>{throw u.value=!1,e}))}}}const Z=Y(!1);Z.withControlled=Y(!0);const te={formId:a,values:c,controlledValues:P,errorBag:g,errors:O,schema:x,submitCount:s,meta:T,isSubmitting:u,fieldArrays:d,keepValuesOnUnmount:S,validateSchema:t.unref(x)?K:void 0,validate:de,setFieldError:h,validateField:ce,setFieldValue:ne,setValues:ae,setErrors:y,setFieldTouched:ie,setTouched:ue,resetForm:se,resetField:oe,handleSubmit:Z,stageInitialValue:function(t,n,r=!1){he(t,n),k(c,t,n),r&&!(null==e?void 0:e.initialValues)&&k(B.value,t,w(n))},unsetInitialValue:me,setFieldInitialValue:he,useFieldModel:function(e){if(!Array.isArray(e))return le(e);return e.map(le)},createPathState:D,getPathState:X,unsetPathValue:function(e){return J.push(e),H||(H=t.nextTick((()=>{[...J].sort().reverse().forEach((e=>{C(c,e)})),J=[],H=null}))),H},removePathState:function(e,t){const n=v.value.findIndex((t=>t.path===e)),r=v.value[n];if(-1!==n&&r){if(r.multiple&&r.fieldsCount&&r.fieldsCount--,Array.isArray(r.id)){const e=r.id.indexOf(t);e>=0&&r.id.splice(e,1),delete r.__flags.pendingUnmount[t]}(!r.multiple||r.fieldsCount<=0)&&(v.value.splice(n,1),me(e))}},initialValues:I,getAllPathStates:()=>v.value,markForUnmount:function(e){return W((t=>{t.path.startsWith(e)&&M(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))}};function ne(e,t){const n=w(t),r="string"==typeof e?e:e.path;X(r)||D(r),k(c,r,n)}function ae(e){i(c,e),d.forEach((e=>e&&e.reset()))}function le(e){const n=X(t.unref(e))||D(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);ne(a,r),n.validated=!0,n.pending=!0,ce(a).then((()=>{n.pending=!1}))}})}function ie(e,t){const n=X(e);n&&(n.touched=t)}function ue(e){M(e).forEach((t=>{ie(t,!!e[t])}))}function oe(e,t){var n;const r=t&&"value"in t?t.value:E(I.value,e);he(e,w(r)),ne(e,r),ie(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),h(e,(null==t?void 0:t.errors)||[])}function se(e){const n=(null==e?void 0:e.values)?e.values:B.value;_(n),ae(n),W((t=>{var r;t.validated=!1,t.touched=(null===(r=null==e?void 0:e.touched)||void 0===r?void 0:r[t.path])||!1,ne(t.path,E(n,t.path)),h(t.path,void 0)})),y((null==e?void 0:e.errors)||{}),s.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{de({mode:"silent"})}))}async function de(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&W((e=>e.validated=!0)),te.validateSchema)return te.validateSchema(t);const n=await Promise.all(v.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]})))),r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function ce(e){const n=X(e);if(n&&(n.validated=!0),x){const{results:t}=await K("validated-only");return t[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate():(n||t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function me(e){C(I.value,e)}function he(e,t){k(I.value,e,w(t))}async function ye(){const e=t.unref(x);if(!e)return{valid:!0,results:{},errors:{}};const n=p(e)||f(e)?await async function(e,t){const n=f(e)?e:ee(e),r=await n.parse(t),a={},l={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));a[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!r.errors.length,results:a,errors:l,values:r.value}}(e,c):await re(e,c,{names:V.value,bailsMap:A.value});return n}const ge=Z(((e,{evt:t})=>{b(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&y(e.initialErrors),(null==e?void 0:e.initialTouched)&&ue(e.initialTouched),(null==e?void 0:e.validateOnMount)?de():te.validateSchema&&te.validateSchema("silent")})),t.isRef(x)&&t.watch(x,(()=>{var e;null===(e=te.validateSchema)||void 0===e||e.call(te,"validated-only")})),t.provide(o,te),Object.assign(Object.assign({},te),{handleReset:()=>se(),submitForm:ge,defineComponentBinds:function(e,r){const a=X(N(e))||D(e),l=()=>n(r)?r(z(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ce(a.path)}function u(e){var t;ne(a.path,e);(null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:Q().validateOnModelUpdate)&&ce(a.path)}return t.computed((()=>{const e={modelValue:a.value,"onUpdate:modelValue":u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(a).props||{}):(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},e),r.mapProps(z(a,fe))):e}))},defineInputBinds:function(e,r){const a=X(N(e))||D(e),l=()=>n(r)?r(z(a,fe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Q().validateOnBlur)&&ce(a.path)}function u(e){var t;const n=G(e);ne(a.path,n);(null!==(t=l().validateOnInput)&&void 0!==t?t:Q().validateOnInput)&&ce(a.path)}function o(e){var t;const n=G(e);ne(a.path,n);(null!==(t=l().validateOnChange)&&void 0!==t?t:Q().validateOnChange)&&ce(a.path)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(z(a,fe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(z(a,fe))):e}))}})}const he=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:i,errorBag:u,values:o,meta:s,isSubmitting:d,submitCount:c,controlledValues:v,validate:f,validateField:p,handleReset:m,resetForm:h,handleSubmit:y,setErrors:g,setFieldError:V,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetField:E}=me({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),k=y(((e,{evt:t})=>{b(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?y(e.onSubmit,e.onInvalidSubmit):k;function C(e){O(e)&&e.preventDefault(),m(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function M(t,n){return y("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function B(){return w(o)}function _(){return w(s.value)}function T(){return w(i.value)}function U(){return{meta:s.value,errors:i.value,errorBag:u.value,values:o,isSubmitting:d.value,submitCount:c.value,controlledValues:v.value,validate:f,validateField:p,handleSubmit:M,handleReset:m,submitForm:k,setErrors:g,setFieldError:V,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetForm:h,resetField:E,getValues:B,getMeta:_,getErrors:T}}return n.expose({setFieldError:V,setErrors:g,setFieldValue:F,setValues:A,setFieldTouched:j,setTouched:S,resetForm:h,validate:f,validateField:p,resetField:E,getValues:B,getMeta:_,getErrors:T}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=q(r,n,U);if(!e.as)return a;const l="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},l),n.attrs),{onSubmit:I,onReset:C}),a)}}}),ye=he;function ge(e){const n=B(o,void 0),a=t.ref([]),l=()=>{},i={fields:a,remove:l,push:l,swap:l,insert:l,update:l,replace:l,prepend:l,move:l};if(!n)return _("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),i;if(!t.unref(e))return _("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const u=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(u)return u;let s=0;function d(){return E(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=d();Array.isArray(e)&&(a.value=e.map(((e,t)=>f(e,t,a.value))),v())}function v(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(l,i,u){if(u&&!r(i)&&u[i])return u[i];const o=s++,d={key:o,value:x({get(){const r=E(null==n?void 0:n.values,t.unref(e),[])||[],i=a.value.findIndex((e=>e.key===o));return-1===i?l:r[i]},set(e){const t=a.value.findIndex((e=>e.key===o));-1!==t?m(t,e):_("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,a){const l=t.unref(e),i=E(null==n?void 0:n.values,l);!Array.isArray(i)||i.length-1<r||(k(n.values,`${l}[${r}]`,a),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:a,remove:function(r){const l=t.unref(e),i=E(null==n?void 0:n.values,l);if(!i||!Array.isArray(i))return;const u=[...i];u.splice(r,1);const o=l+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),k(n.values,l,u),a.value.splice(r,1),p()},push:function(l){const i=t.unref(e),u=E(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[...o];s.push(l),n.stageInitialValue(i+`[${s.length-1}]`,l),k(n.values,i,s),a.value.push(f(l)),p()},swap:function(r,l){const i=t.unref(e),u=E(null==n?void 0:n.values,i);if(!Array.isArray(u)||!(r in u)||!(l in u))return;const o=[...u],s=[...a.value],d=o[r];o[r]=o[l],o[l]=d;const c=s[r];s[r]=s[l],s[l]=c,k(n.values,i,o),a.value=s,v()},insert:function(r,l){const i=t.unref(e),u=E(null==n?void 0:n.values,i);if(!Array.isArray(u)||u.length<r)return;const o=[...u],s=[...a.value];o.splice(r,0,l),s.splice(r,0,f(l)),k(n.values,i,o),a.value=s,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),k(n.values,a,r),c(),p()},prepend:function(l){const i=t.unref(e),u=E(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[l,...o];n.stageInitialValue(i+`[${s.length-1}]`,l),k(n.values,i,s),a.value.unshift(f(l)),p()},move:function(l,i){const u=t.unref(e),o=E(null==n?void 0:n.values,u),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(l in o)||!(i in o))return;const d=[...a.value],c=d[l];d.splice(l,1),d.splice(i,0,c);const v=s[l];s.splice(l,1),s.splice(i,0,v),k(n.values,u,s),a.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(d,(e=>{F(e,a.value.map((e=>e.value)))||c()})),h}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:l,insert:i,replace:u,update:o,prepend:s,move:d,fields:c}=ge(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}),()=>q(void 0,n,v)}}),Oe=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 l(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=q(r,n,l),u=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,u,i):t.h(r||"span",u,a.value):i}}});e.ErrorMessage=Oe,e.Field=ce,e.FieldArray=be,e.FieldContextKey=s,e.Form=ye,e.FormContextKey=o,e.IS_ABSENT=d,e.configure=Y,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),u[e]=t},e.useField=ie,e.useFieldArray=ge,e.useFieldError=function(e){const n=B(o),r=e?void 0:t.inject(s);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=B(o),r=e?void 0:t.inject(s);return t.computed((()=>e?E(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=me,e.useFormErrors=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=D(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=B(o);t||_("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=B(o),r=e?void 0:t.inject(s);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(_(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=B(o);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=Z,e.validateObject=re}));
|