vee-validate 4.10.6 → 4.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -48
- package/dist/vee-validate.d.ts +1 -0
- package/dist/vee-validate.esm.js +53 -19
- package/dist/vee-validate.js +52 -18
- package/dist/vee-validate.min.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -77,81 +77,77 @@ vee-validate offers two styles to integrate form validation into your Vue.js app
|
|
|
77
77
|
|
|
78
78
|
#### Composition API
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
The fastest way to create a form and manage its validation, behavior, and values is with the composition API.
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
<script setup>
|
|
84
|
-
// MyInputComponent.vue
|
|
85
|
-
import { useField } from 'vee-validate';
|
|
86
|
-
|
|
87
|
-
const props = defineProps<{
|
|
88
|
-
name: string;
|
|
89
|
-
}>();
|
|
90
|
-
|
|
91
|
-
// Validator function
|
|
92
|
-
const isRequired = value => (value ? true : 'This field is required');
|
|
93
|
-
|
|
94
|
-
const { value, errorMessage } = useField(props.name, isRequired);
|
|
95
|
-
</script>
|
|
96
|
-
|
|
97
|
-
<template>
|
|
98
|
-
<input v-model="value" />
|
|
99
|
-
<span>{{ errorMessage }}</span>
|
|
100
|
-
</template>
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Then you can you can use `useForm` to make your form component automatically pick up your input fields declared with `useField` and manage them:
|
|
82
|
+
Create your form with `useForm` and then use `defineInputBinds` to create your fields bindings and `handleSubmit` to use the values and send them to an API.
|
|
104
83
|
|
|
105
84
|
```vue
|
|
106
85
|
<script setup>
|
|
107
86
|
import { useForm } from 'vee-validate';
|
|
108
|
-
import MyInputComponent from '@/components/MyInputComponent.vue';
|
|
109
87
|
|
|
110
|
-
|
|
88
|
+
// Validation, or use `yup` or `zod`
|
|
89
|
+
function required(value) {
|
|
90
|
+
return value ? true : 'This field is required';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Create the form
|
|
94
|
+
const { defineInputBinds, handleSubmit, errors } = useForm({
|
|
95
|
+
validationSchema: {
|
|
96
|
+
field: required,
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Define fields
|
|
101
|
+
const field = defineInputBinds('field');
|
|
111
102
|
|
|
103
|
+
// Submit handler
|
|
112
104
|
const onSubmit = handleSubmit(values => {
|
|
113
105
|
// Submit to API
|
|
114
|
-
console.log(values);
|
|
106
|
+
console.log(values);
|
|
115
107
|
});
|
|
116
108
|
</script>
|
|
117
109
|
|
|
118
110
|
<template>
|
|
119
111
|
<form @submit="onSubmit">
|
|
120
|
-
<
|
|
112
|
+
<input v-bind="field" />
|
|
113
|
+
<span>{{ errors.field }}</span>
|
|
114
|
+
|
|
115
|
+
<button>Submit</button>
|
|
121
116
|
</form>
|
|
122
117
|
</template>
|
|
123
118
|
```
|
|
124
119
|
|
|
125
|
-
You can do so much more than this, for more info [check the composition API documentation](https://vee-validate.logaretm.com/v4/guide/composition-api/
|
|
120
|
+
You can do so much more than this, for more info [check the composition API documentation](https://vee-validate.logaretm.com/v4/guide/composition-api/getting-started/).
|
|
126
121
|
|
|
127
122
|
#### Declarative Components
|
|
128
123
|
|
|
129
|
-
Higher-order components
|
|
124
|
+
Higher-order components can also be used to build forms. Register the `Field` and `Form` components and create a simple `required` validator:
|
|
130
125
|
|
|
131
|
-
```
|
|
126
|
+
```vue
|
|
127
|
+
<script setup>
|
|
132
128
|
import { Field, Form } from 'vee-validate';
|
|
133
129
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
},
|
|
139
|
-
methods: {
|
|
140
|
-
isRequired(value) {
|
|
141
|
-
return value ? true : 'This field is required';
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
```
|
|
130
|
+
// Validation, or use `yup` or `zod`
|
|
131
|
+
function required(value) {
|
|
132
|
+
return value ? true : 'This field is required';
|
|
133
|
+
}
|
|
146
134
|
|
|
147
|
-
|
|
135
|
+
// Submit handler
|
|
136
|
+
function onSubmit(values) {
|
|
137
|
+
// Submit to API
|
|
138
|
+
console.log(values);
|
|
139
|
+
}
|
|
140
|
+
</script>
|
|
148
141
|
|
|
149
|
-
|
|
150
|
-
<Form v-slot="{ errors }">
|
|
151
|
-
|
|
142
|
+
<template>
|
|
143
|
+
<Form v-slot="{ errors }" @submit="onSubmit">
|
|
144
|
+
<Field name="field" :rules="required" />
|
|
152
145
|
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
<span>{{ errors.field }}</span>
|
|
147
|
+
|
|
148
|
+
<button>Submit</button>
|
|
149
|
+
</Form>
|
|
150
|
+
</template>
|
|
155
151
|
```
|
|
156
152
|
|
|
157
153
|
The `Field` component renders an `input` of type `text` by default but you can [control that](https://vee-validate.logaretm.com/v4/api/field#rendering-fields)
|
|
@@ -164,6 +160,12 @@ Read the [documentation and demos](https://vee-validate.logaretm.com/v4).
|
|
|
164
160
|
|
|
165
161
|
You are welcome to contribute to this project, but before you do, please make sure you read the [contribution guide](/CONTRIBUTING.md).
|
|
166
162
|
|
|
163
|
+
## Translations 🌎🗺
|
|
164
|
+
|
|
165
|
+
[](https://inlang.com/editor/github.com/logaretm/vee-validate?ref=badge)
|
|
166
|
+
|
|
167
|
+
To add translations, you can manually edit the JSON translation files in `packages/i18n/src/locale`, use the [inlang](https://inlang.com/) online editor, or run `pnpm machine-translate` to add missing translations using AI from Inlang.
|
|
168
|
+
|
|
167
169
|
## Credits
|
|
168
170
|
|
|
169
171
|
- Inspired by Laravel's [validation syntax](https://laravel.com/docs/5.4/validation)
|
package/dist/vee-validate.d.ts
CHANGED
|
@@ -202,6 +202,7 @@ type InputType = 'checkbox' | 'radio' | 'default';
|
|
|
202
202
|
type SchemaValidationMode = 'validated-only' | 'silent' | 'force';
|
|
203
203
|
interface ValidationOptions$1 {
|
|
204
204
|
mode: SchemaValidationMode;
|
|
205
|
+
warn: boolean;
|
|
205
206
|
}
|
|
206
207
|
type FieldValidator = (opts?: Partial<ValidationOptions$1>) => Promise<ValidationResult>;
|
|
207
208
|
interface PathStateConfig {
|
package/dist/vee-validate.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.10.
|
|
2
|
+
* vee-validate v4.10.8
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import { getCurrentInstance, inject, warn as warn$1, computed,
|
|
6
|
+
import { getCurrentInstance, inject, warn as warn$1, computed, unref, ref, watch, nextTick, isRef, reactive, onUnmounted, toValue, onMounted, provide, onBeforeUnmount, defineComponent, toRef, resolveDynamicComponent, h, readonly, watchEffect, shallowRef } from 'vue';
|
|
7
7
|
import { setupDevtoolsPlugin } from '@vue/devtools-api';
|
|
8
8
|
|
|
9
9
|
function isCallable(fn) {
|
|
@@ -276,9 +276,6 @@ function isFile(a) {
|
|
|
276
276
|
}
|
|
277
277
|
return a instanceof File;
|
|
278
278
|
}
|
|
279
|
-
function isPathsEqual(lhs, rhs) {
|
|
280
|
-
return normalizeFormPath(lhs) === normalizeFormPath(rhs);
|
|
281
|
-
}
|
|
282
279
|
|
|
283
280
|
function set(obj, key, val) {
|
|
284
281
|
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
@@ -532,9 +529,6 @@ function computedDeep({ get, set }) {
|
|
|
532
529
|
});
|
|
533
530
|
return baseRef;
|
|
534
531
|
}
|
|
535
|
-
function lazyToRef(value) {
|
|
536
|
-
return computed(() => toValue(value));
|
|
537
|
-
}
|
|
538
532
|
function normalizeErrorItem(message) {
|
|
539
533
|
return Array.isArray(message) ? message : message ? [message] : [];
|
|
540
534
|
}
|
|
@@ -556,6 +550,26 @@ function omit(obj, keys) {
|
|
|
556
550
|
}
|
|
557
551
|
return target;
|
|
558
552
|
}
|
|
553
|
+
function debounceNextTick(inner) {
|
|
554
|
+
let lastTick = null;
|
|
555
|
+
let resolves = [];
|
|
556
|
+
return function (...args) {
|
|
557
|
+
// Run the function after a certain amount of time
|
|
558
|
+
const thisTick = nextTick(() => {
|
|
559
|
+
if (lastTick !== thisTick) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
// Get the result of the inner function, then apply it to the resolve function of
|
|
563
|
+
// each promise that has been created since the last time the inner function was run
|
|
564
|
+
const result = inner(...args);
|
|
565
|
+
resolves.forEach(r => r(result));
|
|
566
|
+
resolves = [];
|
|
567
|
+
lastTick = null;
|
|
568
|
+
});
|
|
569
|
+
lastTick = thisTick;
|
|
570
|
+
return new Promise(resolve => resolves.push(resolve));
|
|
571
|
+
};
|
|
572
|
+
}
|
|
559
573
|
|
|
560
574
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
561
575
|
const normalizeChildren = (tag, context, slotProps) => {
|
|
@@ -1549,7 +1563,7 @@ function _useField(path, rules, opts) {
|
|
|
1549
1563
|
const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount, syncVModel, form: controlForm, } = normalizeOptions(opts);
|
|
1550
1564
|
const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
|
|
1551
1565
|
const form = controlForm || injectedForm;
|
|
1552
|
-
const name =
|
|
1566
|
+
const name = computed(() => normalizeFormPath(toValue(path)));
|
|
1553
1567
|
const validator = computed(() => {
|
|
1554
1568
|
const schema = unref(form === null || form === void 0 ? void 0 : form.schema);
|
|
1555
1569
|
if (schema) {
|
|
@@ -2135,6 +2149,13 @@ function useForm(opts) {
|
|
|
2135
2149
|
const formValues = reactive(resolveInitialValues(opts));
|
|
2136
2150
|
const pathStates = ref([]);
|
|
2137
2151
|
const extraErrorsBag = ref({});
|
|
2152
|
+
const pathStateLookup = ref({});
|
|
2153
|
+
const rebuildPathLookup = debounceNextTick(() => {
|
|
2154
|
+
pathStateLookup.value = pathStates.value.reduce((names, state) => {
|
|
2155
|
+
names[normalizeFormPath(toValue(state.path))] = state;
|
|
2156
|
+
return names;
|
|
2157
|
+
}, {});
|
|
2158
|
+
});
|
|
2138
2159
|
/**
|
|
2139
2160
|
* Manually sets an error message on a specific field
|
|
2140
2161
|
*/
|
|
@@ -2148,8 +2169,9 @@ function useForm(opts) {
|
|
|
2148
2169
|
}
|
|
2149
2170
|
// Move the error from the extras path if exists
|
|
2150
2171
|
if (typeof field === 'string') {
|
|
2151
|
-
|
|
2152
|
-
|
|
2172
|
+
const normalizedPath = normalizeFormPath(field);
|
|
2173
|
+
if (extraErrorsBag.value[normalizedPath]) {
|
|
2174
|
+
delete extraErrorsBag.value[normalizedPath];
|
|
2153
2175
|
}
|
|
2154
2176
|
}
|
|
2155
2177
|
state.errors = normalizeErrorItem(message);
|
|
@@ -2220,7 +2242,7 @@ function useForm(opts) {
|
|
|
2220
2242
|
function createPathState(path, config) {
|
|
2221
2243
|
var _a, _b;
|
|
2222
2244
|
const initialValue = computed(() => getFromPath(initialValues.value, toValue(path)));
|
|
2223
|
-
const pathStateExists =
|
|
2245
|
+
const pathStateExists = pathStateLookup.value[toValue(path)];
|
|
2224
2246
|
if (pathStateExists) {
|
|
2225
2247
|
if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
|
|
2226
2248
|
pathStateExists.multiple = true;
|
|
@@ -2263,6 +2285,8 @@ function useForm(opts) {
|
|
|
2263
2285
|
}),
|
|
2264
2286
|
});
|
|
2265
2287
|
pathStates.value.push(state);
|
|
2288
|
+
pathStateLookup.value[pathValue] = state;
|
|
2289
|
+
rebuildPathLookup();
|
|
2266
2290
|
if (errors.value[pathValue] && !initialErrors[pathValue]) {
|
|
2267
2291
|
nextTick(() => {
|
|
2268
2292
|
validateField(pathValue, { mode: 'silent' });
|
|
@@ -2271,7 +2295,9 @@ function useForm(opts) {
|
|
|
2271
2295
|
// Handles when a path changes
|
|
2272
2296
|
if (isRef(path)) {
|
|
2273
2297
|
watch(path, newPath => {
|
|
2298
|
+
rebuildPathLookup();
|
|
2274
2299
|
const nextValue = klona(currentValue.value);
|
|
2300
|
+
pathStateLookup.value[newPath] = state;
|
|
2275
2301
|
nextTick(() => {
|
|
2276
2302
|
setInPath(formValues, newPath, nextValue);
|
|
2277
2303
|
});
|
|
@@ -2334,7 +2360,8 @@ function useForm(opts) {
|
|
|
2334
2360
|
pathStates.value.forEach(mutation);
|
|
2335
2361
|
}
|
|
2336
2362
|
function findPathState(path) {
|
|
2337
|
-
const
|
|
2363
|
+
const normalizedPath = typeof path === 'string' ? normalizeFormPath(path) : path;
|
|
2364
|
+
const pathState = typeof normalizedPath === 'string' ? pathStateLookup.value[normalizedPath] : normalizedPath;
|
|
2338
2365
|
return pathState;
|
|
2339
2366
|
}
|
|
2340
2367
|
function findHoistedPath(path) {
|
|
@@ -2419,13 +2446,13 @@ function useForm(opts) {
|
|
|
2419
2446
|
const handleSubmit = handleSubmitImpl;
|
|
2420
2447
|
handleSubmit.withControlled = makeSubmissionFactory(true);
|
|
2421
2448
|
function removePathState(path, id) {
|
|
2422
|
-
const idx = pathStates.value.findIndex(s =>
|
|
2449
|
+
const idx = pathStates.value.findIndex(s => s.path === path);
|
|
2423
2450
|
const pathState = pathStates.value[idx];
|
|
2424
2451
|
if (idx === -1 || !pathState) {
|
|
2425
2452
|
return;
|
|
2426
2453
|
}
|
|
2427
2454
|
nextTick(() => {
|
|
2428
|
-
validateField(path, { mode: 'silent' });
|
|
2455
|
+
validateField(path, { mode: 'silent', warn: false });
|
|
2429
2456
|
});
|
|
2430
2457
|
if (pathState.multiple && pathState.fieldsCount) {
|
|
2431
2458
|
pathState.fieldsCount--;
|
|
@@ -2440,6 +2467,8 @@ function useForm(opts) {
|
|
|
2440
2467
|
if (!pathState.multiple || pathState.fieldsCount <= 0) {
|
|
2441
2468
|
pathStates.value.splice(idx, 1);
|
|
2442
2469
|
unsetInitialValue(path);
|
|
2470
|
+
rebuildPathLookup();
|
|
2471
|
+
delete pathStateLookup.value[path];
|
|
2443
2472
|
}
|
|
2444
2473
|
}
|
|
2445
2474
|
function markForUnmount(path) {
|
|
@@ -2628,6 +2657,7 @@ function useForm(opts) {
|
|
|
2628
2657
|
};
|
|
2629
2658
|
}
|
|
2630
2659
|
async function validateField(path, opts) {
|
|
2660
|
+
var _a;
|
|
2631
2661
|
const state = findPathState(path);
|
|
2632
2662
|
if (state) {
|
|
2633
2663
|
state.validated = true;
|
|
@@ -2639,7 +2669,8 @@ function useForm(opts) {
|
|
|
2639
2669
|
if (state === null || state === void 0 ? void 0 : state.validate) {
|
|
2640
2670
|
return state.validate(opts);
|
|
2641
2671
|
}
|
|
2642
|
-
|
|
2672
|
+
const shouldWarn = !state && ((_a = opts === null || opts === void 0 ? void 0 : opts.warn) !== null && _a !== void 0 ? _a : true);
|
|
2673
|
+
if (shouldWarn) {
|
|
2643
2674
|
warn$1(`field with path ${path} was not found`);
|
|
2644
2675
|
}
|
|
2645
2676
|
return Promise.resolve({ errors: [], valid: true });
|
|
@@ -3117,7 +3148,8 @@ function useFieldArray(arrayPath) {
|
|
|
3117
3148
|
fields.value.splice(idx, 1);
|
|
3118
3149
|
afterMutation();
|
|
3119
3150
|
}
|
|
3120
|
-
function push(
|
|
3151
|
+
function push(initialValue) {
|
|
3152
|
+
const value = klona(initialValue);
|
|
3121
3153
|
const pathName = unref(arrayPath);
|
|
3122
3154
|
const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
|
|
3123
3155
|
const normalizedPathValue = isNullOrUndefined(pathValue) ? [] : pathValue;
|
|
@@ -3150,7 +3182,8 @@ function useFieldArray(arrayPath) {
|
|
|
3150
3182
|
fields.value = newFields;
|
|
3151
3183
|
updateEntryFlags();
|
|
3152
3184
|
}
|
|
3153
|
-
function insert(idx,
|
|
3185
|
+
function insert(idx, initialValue) {
|
|
3186
|
+
const value = klona(initialValue);
|
|
3154
3187
|
const pathName = unref(arrayPath);
|
|
3155
3188
|
const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
|
|
3156
3189
|
if (!Array.isArray(pathValue) || pathValue.length < idx) {
|
|
@@ -3180,7 +3213,8 @@ function useFieldArray(arrayPath) {
|
|
|
3180
3213
|
setInPath(form.values, `${pathName}[${idx}]`, value);
|
|
3181
3214
|
form === null || form === void 0 ? void 0 : form.validate({ mode: 'validated-only' });
|
|
3182
3215
|
}
|
|
3183
|
-
function prepend(
|
|
3216
|
+
function prepend(initialValue) {
|
|
3217
|
+
const value = klona(initialValue);
|
|
3184
3218
|
const pathName = unref(arrayPath);
|
|
3185
3219
|
const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
|
|
3186
3220
|
const normalizedPathValue = isNullOrUndefined(pathValue) ? [] : pathValue;
|
package/dist/vee-validate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.10.
|
|
2
|
+
* vee-validate v4.10.8
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -279,9 +279,6 @@
|
|
|
279
279
|
}
|
|
280
280
|
return a instanceof File;
|
|
281
281
|
}
|
|
282
|
-
function isPathsEqual(lhs, rhs) {
|
|
283
|
-
return normalizeFormPath(lhs) === normalizeFormPath(rhs);
|
|
284
|
-
}
|
|
285
282
|
|
|
286
283
|
function set(obj, key, val) {
|
|
287
284
|
if (typeof val.value === 'object') val.value = klona(val.value);
|
|
@@ -517,9 +514,6 @@
|
|
|
517
514
|
});
|
|
518
515
|
return baseRef;
|
|
519
516
|
}
|
|
520
|
-
function lazyToRef(value) {
|
|
521
|
-
return vue.computed(() => vue.toValue(value));
|
|
522
|
-
}
|
|
523
517
|
function normalizeErrorItem(message) {
|
|
524
518
|
return Array.isArray(message) ? message : message ? [message] : [];
|
|
525
519
|
}
|
|
@@ -541,6 +535,26 @@
|
|
|
541
535
|
}
|
|
542
536
|
return target;
|
|
543
537
|
}
|
|
538
|
+
function debounceNextTick(inner) {
|
|
539
|
+
let lastTick = null;
|
|
540
|
+
let resolves = [];
|
|
541
|
+
return function (...args) {
|
|
542
|
+
// Run the function after a certain amount of time
|
|
543
|
+
const thisTick = vue.nextTick(() => {
|
|
544
|
+
if (lastTick !== thisTick) {
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
// Get the result of the inner function, then apply it to the resolve function of
|
|
548
|
+
// each promise that has been created since the last time the inner function was run
|
|
549
|
+
const result = inner(...args);
|
|
550
|
+
resolves.forEach(r => r(result));
|
|
551
|
+
resolves = [];
|
|
552
|
+
lastTick = null;
|
|
553
|
+
});
|
|
554
|
+
lastTick = thisTick;
|
|
555
|
+
return new Promise(resolve => resolves.push(resolve));
|
|
556
|
+
};
|
|
557
|
+
}
|
|
544
558
|
|
|
545
559
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
546
560
|
const normalizeChildren = (tag, context, slotProps) => {
|
|
@@ -1151,7 +1165,7 @@
|
|
|
1151
1165
|
const { initialValue: modelValue, validateOnMount, bails, type, checkedValue, label, validateOnValueUpdate, uncheckedValue, controlled, keepValueOnUnmount, syncVModel, form: controlForm, } = normalizeOptions(opts);
|
|
1152
1166
|
const injectedForm = controlled ? injectWithSelf(FormContextKey) : undefined;
|
|
1153
1167
|
const form = controlForm || injectedForm;
|
|
1154
|
-
const name =
|
|
1168
|
+
const name = vue.computed(() => normalizeFormPath(vue.toValue(path)));
|
|
1155
1169
|
const validator = vue.computed(() => {
|
|
1156
1170
|
const schema = vue.unref(form === null || form === void 0 ? void 0 : form.schema);
|
|
1157
1171
|
if (schema) {
|
|
@@ -1715,6 +1729,13 @@
|
|
|
1715
1729
|
const formValues = vue.reactive(resolveInitialValues(opts));
|
|
1716
1730
|
const pathStates = vue.ref([]);
|
|
1717
1731
|
const extraErrorsBag = vue.ref({});
|
|
1732
|
+
const pathStateLookup = vue.ref({});
|
|
1733
|
+
const rebuildPathLookup = debounceNextTick(() => {
|
|
1734
|
+
pathStateLookup.value = pathStates.value.reduce((names, state) => {
|
|
1735
|
+
names[normalizeFormPath(vue.toValue(state.path))] = state;
|
|
1736
|
+
return names;
|
|
1737
|
+
}, {});
|
|
1738
|
+
});
|
|
1718
1739
|
/**
|
|
1719
1740
|
* Manually sets an error message on a specific field
|
|
1720
1741
|
*/
|
|
@@ -1728,8 +1749,9 @@
|
|
|
1728
1749
|
}
|
|
1729
1750
|
// Move the error from the extras path if exists
|
|
1730
1751
|
if (typeof field === 'string') {
|
|
1731
|
-
|
|
1732
|
-
|
|
1752
|
+
const normalizedPath = normalizeFormPath(field);
|
|
1753
|
+
if (extraErrorsBag.value[normalizedPath]) {
|
|
1754
|
+
delete extraErrorsBag.value[normalizedPath];
|
|
1733
1755
|
}
|
|
1734
1756
|
}
|
|
1735
1757
|
state.errors = normalizeErrorItem(message);
|
|
@@ -1800,7 +1822,7 @@
|
|
|
1800
1822
|
function createPathState(path, config) {
|
|
1801
1823
|
var _a, _b;
|
|
1802
1824
|
const initialValue = vue.computed(() => getFromPath(initialValues.value, vue.toValue(path)));
|
|
1803
|
-
const pathStateExists =
|
|
1825
|
+
const pathStateExists = pathStateLookup.value[vue.toValue(path)];
|
|
1804
1826
|
if (pathStateExists) {
|
|
1805
1827
|
if ((config === null || config === void 0 ? void 0 : config.type) === 'checkbox' || (config === null || config === void 0 ? void 0 : config.type) === 'radio') {
|
|
1806
1828
|
pathStateExists.multiple = true;
|
|
@@ -1843,6 +1865,8 @@
|
|
|
1843
1865
|
}),
|
|
1844
1866
|
});
|
|
1845
1867
|
pathStates.value.push(state);
|
|
1868
|
+
pathStateLookup.value[pathValue] = state;
|
|
1869
|
+
rebuildPathLookup();
|
|
1846
1870
|
if (errors.value[pathValue] && !initialErrors[pathValue]) {
|
|
1847
1871
|
vue.nextTick(() => {
|
|
1848
1872
|
validateField(pathValue, { mode: 'silent' });
|
|
@@ -1851,7 +1875,9 @@
|
|
|
1851
1875
|
// Handles when a path changes
|
|
1852
1876
|
if (vue.isRef(path)) {
|
|
1853
1877
|
vue.watch(path, newPath => {
|
|
1878
|
+
rebuildPathLookup();
|
|
1854
1879
|
const nextValue = klona(currentValue.value);
|
|
1880
|
+
pathStateLookup.value[newPath] = state;
|
|
1855
1881
|
vue.nextTick(() => {
|
|
1856
1882
|
setInPath(formValues, newPath, nextValue);
|
|
1857
1883
|
});
|
|
@@ -1914,7 +1940,8 @@
|
|
|
1914
1940
|
pathStates.value.forEach(mutation);
|
|
1915
1941
|
}
|
|
1916
1942
|
function findPathState(path) {
|
|
1917
|
-
const
|
|
1943
|
+
const normalizedPath = typeof path === 'string' ? normalizeFormPath(path) : path;
|
|
1944
|
+
const pathState = typeof normalizedPath === 'string' ? pathStateLookup.value[normalizedPath] : normalizedPath;
|
|
1918
1945
|
return pathState;
|
|
1919
1946
|
}
|
|
1920
1947
|
function findHoistedPath(path) {
|
|
@@ -1999,13 +2026,13 @@
|
|
|
1999
2026
|
const handleSubmit = handleSubmitImpl;
|
|
2000
2027
|
handleSubmit.withControlled = makeSubmissionFactory(true);
|
|
2001
2028
|
function removePathState(path, id) {
|
|
2002
|
-
const idx = pathStates.value.findIndex(s =>
|
|
2029
|
+
const idx = pathStates.value.findIndex(s => s.path === path);
|
|
2003
2030
|
const pathState = pathStates.value[idx];
|
|
2004
2031
|
if (idx === -1 || !pathState) {
|
|
2005
2032
|
return;
|
|
2006
2033
|
}
|
|
2007
2034
|
vue.nextTick(() => {
|
|
2008
|
-
validateField(path, { mode: 'silent' });
|
|
2035
|
+
validateField(path, { mode: 'silent', warn: false });
|
|
2009
2036
|
});
|
|
2010
2037
|
if (pathState.multiple && pathState.fieldsCount) {
|
|
2011
2038
|
pathState.fieldsCount--;
|
|
@@ -2020,6 +2047,8 @@
|
|
|
2020
2047
|
if (!pathState.multiple || pathState.fieldsCount <= 0) {
|
|
2021
2048
|
pathStates.value.splice(idx, 1);
|
|
2022
2049
|
unsetInitialValue(path);
|
|
2050
|
+
rebuildPathLookup();
|
|
2051
|
+
delete pathStateLookup.value[path];
|
|
2023
2052
|
}
|
|
2024
2053
|
}
|
|
2025
2054
|
function markForUnmount(path) {
|
|
@@ -2208,6 +2237,7 @@
|
|
|
2208
2237
|
};
|
|
2209
2238
|
}
|
|
2210
2239
|
async function validateField(path, opts) {
|
|
2240
|
+
var _a;
|
|
2211
2241
|
const state = findPathState(path);
|
|
2212
2242
|
if (state) {
|
|
2213
2243
|
state.validated = true;
|
|
@@ -2219,7 +2249,8 @@
|
|
|
2219
2249
|
if (state === null || state === void 0 ? void 0 : state.validate) {
|
|
2220
2250
|
return state.validate(opts);
|
|
2221
2251
|
}
|
|
2222
|
-
|
|
2252
|
+
const shouldWarn = !state && ((_a = opts === null || opts === void 0 ? void 0 : opts.warn) !== null && _a !== void 0 ? _a : true);
|
|
2253
|
+
if (shouldWarn) {
|
|
2223
2254
|
vue.warn(`field with path ${path} was not found`);
|
|
2224
2255
|
}
|
|
2225
2256
|
return Promise.resolve({ errors: [], valid: true });
|
|
@@ -2691,7 +2722,8 @@
|
|
|
2691
2722
|
fields.value.splice(idx, 1);
|
|
2692
2723
|
afterMutation();
|
|
2693
2724
|
}
|
|
2694
|
-
function push(
|
|
2725
|
+
function push(initialValue) {
|
|
2726
|
+
const value = klona(initialValue);
|
|
2695
2727
|
const pathName = vue.unref(arrayPath);
|
|
2696
2728
|
const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
|
|
2697
2729
|
const normalizedPathValue = isNullOrUndefined(pathValue) ? [] : pathValue;
|
|
@@ -2724,7 +2756,8 @@
|
|
|
2724
2756
|
fields.value = newFields;
|
|
2725
2757
|
updateEntryFlags();
|
|
2726
2758
|
}
|
|
2727
|
-
function insert(idx,
|
|
2759
|
+
function insert(idx, initialValue) {
|
|
2760
|
+
const value = klona(initialValue);
|
|
2728
2761
|
const pathName = vue.unref(arrayPath);
|
|
2729
2762
|
const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
|
|
2730
2763
|
if (!Array.isArray(pathValue) || pathValue.length < idx) {
|
|
@@ -2754,7 +2787,8 @@
|
|
|
2754
2787
|
setInPath(form.values, `${pathName}[${idx}]`, value);
|
|
2755
2788
|
form === null || form === void 0 ? void 0 : form.validate({ mode: 'validated-only' });
|
|
2756
2789
|
}
|
|
2757
|
-
function prepend(
|
|
2790
|
+
function prepend(initialValue) {
|
|
2791
|
+
const value = klona(initialValue);
|
|
2758
2792
|
const pathName = vue.unref(arrayPath);
|
|
2759
2793
|
const pathValue = getFromPath(form === null || form === void 0 ? void 0 : form.values, pathName);
|
|
2760
2794
|
const normalizedPathValue = isNullOrUndefined(pathValue) ? [] : pathValue;
|
package/dist/vee-validate.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v4.10.
|
|
2
|
+
* vee-validate v4.10.8
|
|
3
3
|
* (c) 2023 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function l(e){return Number(e)>=0}function i(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function u(e,t){return Object.keys(t).forEach((n=>{if(i(t[n]))return e[n]||(e[n]={}),void u(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)l(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};const d=Symbol("vee-validate-form"),c=Symbol("vee-validate-field-instance"),v=Symbol("Default empty value"),f="undefined"!=typeof window;function p(e){return n(e)&&!!e.__locatorRef}function m(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function h(e){return!!e&&n(e.validate)}function y(e){return"checkbox"===e||"radio"===e}function g(e){return/^\[.+\]$/i.test(e)}function b(e){return"SELECT"===e.tagName}function V(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!y(t.type)}function O(e){return F(e)&&e.target&&"submit"in e.target}function F(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function A(e,t){return t in e&&e[t]!==v}function j(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!j(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!j(r[1],t.get(r[0])))return!1;return!0}if(w(e)&&w(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();for(r=n=(a=Object.keys(e)).length;0!=r--;){var l=a[r];if(!j(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function w(e){return!!f&&e instanceof File}function S(e,t){return o(e)===o(t)}function E(e,t,n){"object"==typeof n.value&&(n.value=k(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function k(e){if("object"!=typeof e)return e;var t,n,r,a=0,l=Object.prototype.toString.call(e);if("[object Object]"===l?r=Object.create(e.__proto__||null):"[object Array]"===l?r=Array(e.length):"[object Set]"===l?(r=new Set,e.forEach((function(e){r.add(k(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(k(t),k(e))}))):"[object Date]"===l?r=new Date(+e):"[object RegExp]"===l?r=new RegExp(e.source,e.flags):"[object DataView]"===l?r=new e.constructor(k(e.buffer)):"[object ArrayBuffer]"===l?r=e.slice(0):"Array]"===l.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)E(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||E(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function I(e){return g(e)?e.replace(/\[|\]/gi,""):e}function M(e,t,n){if(!e)return n;if(g(t))return e[I(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function C(e,t,n){if(g(t))return void(e[I(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=l(a[e+1])?[]:{}),i=i[a[e]]}}function B(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function U(e,t){if(g(t))return void delete e[I(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){B(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const i=n.map(((t,r)=>M(e,n.slice(0,r).join("."))));for(let t=i.length-1;t>=0;t--)u=i[t],(Array.isArray(u)?0===u.length:a(u)&&0===Object.keys(u).length)&&(0!==t?B(i[t-1],n[t-1]):B(e,n[0]));var u}function P(e){return Object.keys(e)}function T(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function _(e){t.warn(`[vee-validate]: ${e}`)}function R(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>j(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return j(e,t)?n:t}function N(e,t=0){let n=null,r=[];return function(...a){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function $(e,t){let n;return async function(...r){const a=e(...r);n=a;const l=await a;return a!==n||(n=void 0,t(l,r)),l}}function D({get:e,set:n}){const r=t.ref(k(e()));return t.watch(e,(e=>{j(e,r.value)||(r.value=k(e))}),{deep:!0}),t.watch(r,(t=>{j(t,e())||n(k(t))}),{deep:!0}),r}function z(e){return Array.isArray(e)?e:e?[e]:[]}function q(e){const n=T(d),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(c);return a||(null==r?void 0:r.value)||_(`field with name ${t.unref(e)} was not found`),r||a}function L(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const K=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function W(e){if(G(e))return e._value}function G(e){return"_value"in e}function X(e){if(!F(e))return e;const t=e.target;if(y(t.type)&&G(t))return W(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(b(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(W);var n;if(b(t)){const e=Array.from(t.options).find((e=>e.selected));return e?W(e):t.value}return function(e){return"number"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function H(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=J(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=Q(t);return n.name?(e[n.name]=J(n.params),e):e}),t):t}function J(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>M(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const Q=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let Y=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const Z=()=>Y,ee=e=>{Y=Object.assign(Object.assign({},Y),e)};async function te(e,t,r={}){const a=null==r?void 0:r.bails,l={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(m(e.rules)||h(e.rules))return async function(e,t){const n=m(t)?t:ne(t),r=await n.parse(e),a=[];for(const e of r.errors)e.errors.length&&a.push(...e.errors);return{errors:a}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,l=[];for(let i=0;i<a;i++){const a=r[i],u=await a(t,n);if(!("string"!=typeof u&&!Array.isArray(u)&&u)){if(Array.isArray(u))l.push(...u);else{const e="string"==typeof u?u:ae(n);l.push(e)}if(e.bails)return{errors:l}}}return{errors:l}}const r=Object.assign(Object.assign({},e),{rules:H(e.rules)}),a=[],l=Object.keys(r.rules),i=l.length;for(let n=0;n<i;n++){const i=l[n],u=await re(r,t,{name:i,params:r.rules[i]});if(u.error&&(a.push(u.error),e.bails))return{errors:a}}return{errors:a}}(l,e),u=i.errors;return{errors:u,valid:!u.length}}function ne(e){return{__type:"VVTypedSchema",async parse(t){var n;try{return{output:await e.validate(t,{abortEarly:!1}),errors:[]}}catch(e){if(!function(e){return!!e&&"ValidationError"===e.name}(e))throw e;if(!(null===(n=e.inner)||void 0===n?void 0:n.length)&&e.errors.length)return{errors:[{path:e.path,errors:e.errors}]};const t=e.inner.reduce(((e,t)=>{const n=t.path||"";return e[n]||(e[n]={errors:[],path:n}),e[n].errors.push(...t.errors),e}),{});return{errors:Object.values(t)}}}}}async function re(e,t,n){const r=(a=n.name,s[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>p(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),i={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:l})},u=await r(t,l,i);return"string"==typeof u?{error:u}:{error:u?void 0:ae(i)}}function ae(e){const t=Z().generateMessage;return t?t(e):"Field is invalid"}async function le(e,t,n){const r=P(e).map((async r=>{var a,l,i;const u=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await te(M(t,r),e[r],{name:(null==u?void 0:u.name)||r,label:null==u?void 0:u.label,values:t,bails:null===(i=null===(l=null==n?void 0:n.bailsMap)||void 0===l?void 0:l[r])||void 0===i||i});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const l=await Promise.all(r),i={},u={};for(const e of l)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,u[e.path]=e.errors[0]);return{valid:a,results:i,errors:u}}let ie=0;function ue(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?M(r.initialValues.value,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const u=t.computed(l);if(!r){return{value:t.ref(l()),initialValue:u,setInitialValue:i}}const o=function(e,n,r,a){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return M(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>M(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:u,setInitialValue:i}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=z(t)}}}(),d=ie>=Number.MAX_SAFE_INTEGER?0:++ie,c=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!j(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&l(e.initialValue)}return{id:d,path:e,value:r,initialValue:a,meta:c,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const i=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),u=t.computed((()=>i.errors));return{id:Array.isArray(i.id)?i.id[i.id.length-1]:i.id,path:e,value:r,errors:u,meta:i,initialValue:a,flags:i.__flags,setState:function(a){var i,u,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(i=n.form)||void 0===i||i.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(u=n.form)||void 0===u||u.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&l(a.initialValue)}}}function oe(e,n,r){return y(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:T(d),l=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function u(n){const u=n.handleChange,o=t.computed((()=>{const e=t.unref(n.value),r=t.unref(l);return Array.isArray(e)?e.findIndex((e=>j(e,r)))>=0:j(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==a?void 0:a.getPathState(f),m=X(s);let h=null!==(v=t.unref(l))&&void 0!==v?v:m;a&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=R(M(a.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=R(t.unref(n.value),h,t.unref(i))),u(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:l,uncheckedValue:i,handleChange:s})}return u(se(e,n,r))}(e,n,r):se(e,n,r)}function se(e,r,a){const{initialValue:l,validateOnMount:i,bails:u,type:o,checkedValue:s,label:f,validateOnValueUpdate:y,uncheckedValue:g,controlled:b,keepValueOnUnmount:V,syncVModel:O,form:F}=function(e){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),r=!!(null==e?void 0:e.syncVModel),a="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",l=r&&!("initialValue"in(e||{}))?de(t.getCurrentInstance(),a):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:l});const i="valueProp"in e?e.valueProp:e.checkedValue,u="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:l,controlled:null==u||u,checkedValue:i,syncVModel:o})}(a),A=b?T(d):void 0,w=F||A,S=function(e){return t.computed((()=>t.toValue(e)))}(e),E=t.computed((()=>{if(t.unref(null==w?void 0:w.schema))return;const e=t.unref(r);return h(e)||m(e)||n(e)||Array.isArray(e)?e:H(e)})),{id:I,value:C,initialValue:B,meta:U,setState:_,errors:R,flags:N}=ue(S,{modelValue:l,form:w,bails:u,label:f,type:o,validate:E.value?K:void 0}),D=t.computed((()=>R.value[0]));O&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a||!e)return;const l="string"==typeof e?e:"modelValue",i=`update:${l}`;if(!(l in a.props))return;t.watch(n,(e=>{j(e,de(a,l))||a.emit(i,e)})),t.watch((()=>de(a,l)),(e=>{if(e===v&&void 0===n.value)return;const t=e===v?void 0:e;j(t,n.value)||r(t)}))}({value:C,prop:O,handleChange:W});async function z(e){var n,r;return(null==w?void 0:w.validateSchema)?null!==(n=(await w.validateSchema(e)).results[t.unref(S)])&&void 0!==n?n:{valid:!0,errors:[]}:E.value?te(C.value,E.value,{name:t.unref(S),label:t.unref(f),values:null!==(r=null==w?void 0:w.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const q=$((async()=>(U.pending=!0,U.validated=!0,z("validated-only"))),(e=>{if(!N.pendingUnmount[Z.id])return _({errors:e.errors}),U.pending=!1,U.valid=e.valid,e})),L=$((async()=>z("silent")),(e=>(U.valid=e.valid,e)));function K(e){return"silent"===(null==e?void 0:e.mode)?L():q()}function W(e,t=!0){Q(X(e),t)}function G(e){var t;const n=e&&"value"in e?e.value:B.value;_({value:k(n),initialValue:k(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),U.pending=!1,U.validated=!1,L()}t.onMounted((()=>{if(i)return q();w&&w.validateSchema||L()}));const J=t.getCurrentInstance();function Q(e,t=!0){C.value=J&&O?x(e,J.props.modelModifiers):e;(t?q:L)()}const Y=t.computed({get:()=>C.value,set(e){Q(e,y)}}),Z={id:I,name:S,label:f,value:Y,meta:U,errors:R,errorMessage:D,type:o,checkedValue:s,uncheckedValue:g,bails:u,keepValueOnUnmount:V,resetField:G,handleReset:()=>G(),validate:K,handleChange:W,handleBlur:(e,t=!1)=>{U.touched=!0,t&&q()},setState:_,setTouched:function(e){U.touched=e},setErrors:function(e){_({errors:Array.isArray(e)?e:[e]})},setValue:Q};if(t.provide(c,Z),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{j(e,t)||(U.validated?q():L())}),{deep:!0}),!w)return Z;const ee=t.computed((()=>{const e=E.value;return!e||n(e)||h(e)||m(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(p):P(a).filter((e=>p(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=M(w.values,t)||w.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(ee,((e,t)=>{if(!Object.keys(e).length)return;!j(e,t)&&(U.validated?q():L())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(Z.keepValueOnUnmount))&&void 0!==e?e:t.unref(w.keepValuesOnUnmount),r=t.toValue(S);if(n||!w||N.pendingUnmount[Z.id])return void(null==w||w.removePathState(r,I));N.pendingUnmount[Z.id]=!0;const a=w.getPathState(r);if(Array.isArray(null==a?void 0:a.id)&&(null==a?void 0:a.multiple)?null==a?void 0:a.id.includes(Z.id):(null==a?void 0:a.id)===Z.id){if((null==a?void 0:a.multiple)&&Array.isArray(a.value)){const e=a.value.findIndex((e=>j(e,t.unref(Z.checkedValue))));if(e>-1){const t=[...a.value];t.splice(e,1),w.setFieldValue(r,t)}Array.isArray(a.id)&&a.id.splice(a.id.indexOf(Z.id),1)}else w.unsetPathValue(t.toValue(S));w.removePathState(r,I)}})),Z}function de(e,t){if(e)return e.props[t]}function ce(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ve(e,t){return y(t.attrs.type)?A(e,"modelValue")?e.modelValue:void 0:A(e,"modelValue")?e.modelValue:t.attrs.value}const fe=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>Z().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:v},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const a=t.toRef(e,"rules"),l=t.toRef(e,"name"),i=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:g,meta:b,checked:O,setErrors:F}=oe(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:ve(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o,syncVModel:!0}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},j=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:l,validateOnModelUpdate:i}=function(e){var t,n,r,a;const{validateOnInput:l,validateOnChange:i,validateOnBlur:u,validateOnModelUpdate:o}=Z();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:l,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:u,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const u={name:e.name,onBlur:function(e){p(e,l),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,i)};return u})),w=t.computed((()=>{const t=Object.assign({},j.value);y(r.attrs.type)&&O&&(t.checked=O.value);return V(ce(e,r),r.attrs)&&(t.value=d.value),t})),S=t.computed((()=>Object.assign(Object.assign({},j.value),{modelValue:d.value})));function E(){return{field:w.value,componentField:S.value,value:d.value,meta:b,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:A,handleInput:e=>A(e,!1),handleReset:g,handleBlur:j.value.onBlur,setTouched:m,setErrors:F}}return r.expose({setErrors:F,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(ce(e,r)),a=K(n,r,E);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let pe=0;const me=["bails","fieldsCount","id","multiple","type","validate"];function he(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&m(a)&&n(a.cast)?k(a.cast(r)||{}):k(r)}function ye(e){var r;const a=pe++;let l=0;const i=t.ref(!1),s=t.ref(!1),c=t.ref(0),v=[],f=t.reactive(he(e)),p=t.ref([]),y=t.ref({});function g(e,t){const n=J(e);n?("string"==typeof e&&y.value[o(e)]&&delete y.value[o(e)],n.errors=z(t),n.valid=!n.errors.length):"string"==typeof e&&(y.value[o(e)]=z(t))}function b(e){P(e).forEach((t=>{g(t,e[t])}))}(null==e?void 0:e.initialErrors)&&b(e.initialErrors);const V=t.computed((()=>{const e=p.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},y.value),e)})),F=t.computed((()=>P(V.value).reduce(((e,t)=>{const n=V.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),A=t.computed((()=>p.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),w=t.computed((()=>p.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),E=Object.assign({},(null==e?void 0:e.initialErrors)||{}),I=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:B,originalInitialValues:T,setInitialValues:_}=function(e,n,r){const a=he(r),l=null==r?void 0:r.initialValues,i=t.ref(a),o=t.ref(k(a));function s(t,r=!1){i.value=u(k(i.value)||{},k(t)),o.value=u(k(o.value)||{},k(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=M(i.value,e.path);C(n,e.path,k(t))}))}t.isRef(l)&&t.watch(l,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:i,originalInitialValues:o,setInitialValues:s}}(p,f,e),R=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!j(n,t.unref(r))));function u(){const t=e.value;return P(l).reduce(((e,n)=>{const r=l[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(u());return t.watchEffect((()=>{const e=u();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!P(a.value).length,dirty:i.value})))}(p,f,T,F),x=t.computed((()=>p.value.reduce(((e,t)=>{const n=M(f,t.path);return C(e,t.path,n),e}),{}))),D=null==e?void 0:e.validationSchema;function q(e,n){var r,a;const i=t.computed((()=>M(B.value,t.toValue(e)))),u=p.value.find((n=>S(n.path,t.toValue(e))));if(u){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(u.multiple=!0);const e=l++;return Array.isArray(u.id)?u.id.push(e):u.id=[u.id,e],u.fieldsCount++,u.__flags.pendingUnmount[e]=!1,u}const o=t.computed((()=>M(f,t.toValue(e)))),s=t.toValue(e),d=l++,c=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=E[s])||void 0===r?void 0:r.length),initialValue:i,errors:t.shallowRef([]),bails:null!==(a=null==n?void 0:n.bails)&&void 0!==a&&a,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1}},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!j(t.unref(o),t.unref(i))))});return p.value.push(c),F.value[s]&&!E[s]&&t.nextTick((()=>{fe(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{const n=k(o.value);t.nextTick((()=>{C(f,e,n)}))})),c}const K=N(be,5),W=N(be,5),G=$((async e=>"silent"===await e?K():W()),((e,[t])=>{const n=P(re.errorBag.value);return[...new Set([...P(e.results),...p.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const a=r,l=J(a)||function(e){const t=p.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(a),i=(e.results[a]||{errors:[]}).errors,u={errors:i,valid:!i.length};return n.results[a]=u,u.valid||(n.errors[a]=u.errors[0]),l&&y.value[a]&&delete y.value[a],l?(l.valid=u.valid,"silent"===t?n:"validated-only"!==t||l.validated?(g(l,u.errors),n):n):(g(a,i),n)}),{valid:e.valid,results:{},errors:{}})}));function H(e){p.value.forEach(e)}function J(e){return"string"==typeof e?p.value.find((t=>S(t.path,e))):e}let Q,Y=[];function ee(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),H((e=>e.touched=!0)),i.value=!0,c.value++,ve().then((a=>{const l=k(f);if(a.valid&&"function"==typeof t){const n=k(x.value);let i=e?n:l;return a.values&&(i=a.values),t(i,{evt:r,controlledValues:n,setErrors:b,setFieldError:g,setTouched:se,setFieldTouched:oe,setValues:ie,setFieldValue:ae,resetForm:ce,resetField:de})}a.valid||"function"!=typeof n||n({values:l,evt:r,errors:a.errors,results:a.results})})).then((e=>(i.value=!1,e)),(e=>{throw i.value=!1,e}))}}}const te=ee(!1);te.withControlled=ee(!0);const re={formId:a,values:f,controlledValues:x,errorBag:V,errors:F,schema:D,submitCount:c,meta:R,isSubmitting:i,isValidating:s,fieldArrays:v,keepValuesOnUnmount:I,validateSchema:t.unref(D)?G:void 0,validate:ve,setFieldError:g,validateField:fe,setFieldValue:ae,setValues:ie,setErrors:b,setFieldTouched:oe,setTouched:se,resetForm:ce,resetField:de,handleSubmit:te,stageInitialValue:function(t,n,r=!1){ge(t,n),C(f,t,n),r&&!(null==e?void 0:e.initialValues)&&C(T.value,t,k(n))},unsetInitialValue:ye,setFieldInitialValue:ge,useFieldModel:function(e){if(!Array.isArray(e))return ue(e);return e.map(ue)},createPathState:q,getPathState:J,unsetPathValue:function(e){return Y.push(e),Q||(Q=t.nextTick((()=>{[...Y].sort().reverse().forEach((e=>{U(f,e)})),Y=[],Q=null}))),Q},removePathState:function(e,n){const r=p.value.findIndex((t=>S(t.path,e))),a=p.value[r];if(-1!==r&&a){if(t.nextTick((()=>{fe(e,{mode:"silent"})})),a.multiple&&a.fieldsCount&&a.fieldsCount--,Array.isArray(a.id)){const e=a.id.indexOf(n);e>=0&&a.id.splice(e,1),delete a.__flags.pendingUnmount[n]}(!a.multiple||a.fieldsCount<=0)&&(p.value.splice(r,1),ye(e))}},initialValues:B,getAllPathStates:()=>p.value,markForUnmount:function(e){return H((t=>{t.path.startsWith(e)&&P(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))}};function ae(e,t,n=!0){const r=k(t),a="string"==typeof e?e:e.path;J(a)||q(a),C(f,a,r),n&&fe(a)}function ie(e,t=!0){u(f,e),v.forEach((e=>e&&e.reset())),t&&ve()}function ue(e){const n=J(t.unref(e))||q(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);ae(a,r,!1),n.validated=!0,n.pending=!0,fe(a).then((()=>{n.pending=!1}))}})}function oe(e,t){const n=J(e);n&&(n.touched=t)}function se(e){P(e).forEach((t=>{oe(t,!!e[t])}))}function de(e,t){var n;const r=t&&"value"in t?t.value:M(B.value,e);ge(e,k(r)),ae(e,r,!1),oe(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),g(e,(null==t?void 0:t.errors)||[])}function ce(e){let r=(null==e?void 0:e.values)?e.values:T.value;r=m(D)&&n(D.cast)?D.cast(r):r,_(r),H((t=>{var n;t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ae(t.path,M(r,t.path),!1),g(t.path,void 0)})),ie(r,!1),b((null==e?void 0:e.errors)||{}),c.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{ve({mode:"silent"})}))}async function ve(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&H((e=>e.validated=!0)),re.validateSchema)return re.validateSchema(t);s.value=!0;const n=await Promise.all(p.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));s.value=!1;const r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function fe(e,n){const r=J(e);if(r&&(r.validated=!0),D){const{results:t}=await G((null==n?void 0:n.mode)||"validated-only");return t[e]||{errors:[],valid:!0}}return(null==r?void 0:r.validate)?r.validate(n):(r||t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function ye(e){U(B.value,e)}function ge(e,t){C(B.value,e,k(t))}async function be(){const e=t.unref(D);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=h(e)||m(e)?await async function(e,t){const n=m(e)?e:ne(e),r=await n.parse(t),a={},l={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));a[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!r.errors.length,results:a,errors:l,values:r.value}}(e,f):await le(e,f,{names:A.value,bailsMap:w.value});return s.value=!1,n}const Ve=te(((e,{evt:t})=>{O(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&b(e.initialErrors),(null==e?void 0:e.initialTouched)&&se(e.initialTouched),(null==e?void 0:e.validateOnMount)?ve():re.validateSchema&&re.validateSchema("silent")})),t.isRef(D)&&t.watch(D,(()=>{var e;null===(e=re.validateSchema)||void 0===e||e.call(re,"validated-only")})),t.provide(d,re),Object.assign(Object.assign({},re),{values:t.readonly(f),handleReset:()=>ce(),submitForm:Ve,defineComponentBinds:function(e,r){const a=J(t.toValue(e))||q(e),l=()=>n(r)?r(L(a,me)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Z().validateOnBlur)&&fe(a.path)}function u(e){var t;const n=null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:Z().validateOnModelUpdate;ae(a.path,e,n)}return t.computed((()=>{if(n(r)){const e=r(a),t=e.model||"modelValue";return Object.assign({onBlur:i,[t]:a.value,[`onUpdate:${t}`]:u},e.props||{})}const e=(null==r?void 0:r.model)||"modelValue",t={onBlur:i,[e]:a.value,[`onUpdate:${e}`]:u};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},t),r.mapProps(L(a,me))):t}))},defineInputBinds:function(e,r){const a=J(t.toValue(e))||q(e),l=()=>n(r)?r(L(a,me)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Z().validateOnBlur)&&fe(a.path)}function u(e){var t;const n=X(e),r=null!==(t=l().validateOnInput)&&void 0!==t?t:Z().validateOnInput;ae(a.path,n,r)}function o(e){var t;const n=X(e),r=null!==(t=l().validateOnChange)&&void 0!==t?t:Z().validateOnChange;ae(a.path,n,r)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(L(a,me)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(L(a,me))):e}))}})}const ge=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:i,errorBag:u,values:o,meta:s,isSubmitting:d,isValidating:c,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetField:E}=ye({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),I=g(((e,{evt:t})=>{O(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function C(e){F(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function B(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function U(){return k(o)}function P(){return k(s.value)}function T(){return k(i.value)}function _(){return{meta:s.value,errors:i.value,errorBag:u.value,values:o,isSubmitting:d.value,isValidating:c.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:B,handleReset:h,submitForm:I,setErrors:b,setFieldError:V,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetForm:y,resetField:E,getValues:U,getMeta:P,getErrors:T}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetForm:y,validate:p,validateField:m,resetField:E,getValues:U,getMeta:P,getErrors:T}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=K(r,n,_);if(!e.as)return a;const l="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},l),n.attrs),{onSubmit:M,onReset:C}),a)}}}),be=ge;function Ve(e){const n=T(d,void 0),a=t.ref([]),l=()=>{},i={fields:a,remove:l,push:l,swap:l,insert:l,update:l,replace:l,prepend:l,move:l};if(!n)return _("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),i;if(!t.unref(e))return _("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const u=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(u)return u;let o=0;function s(){return M(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=s();Array.isArray(e)&&(a.value=e.map(((e,t)=>f(e,t,a.value))),v())}function v(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(l,i,u){if(u&&!r(i)&&u[i])return u[i];const s=o++,d={key:s,value:D({get(){const r=M(null==n?void 0:n.values,t.unref(e),[])||[],i=a.value.findIndex((e=>e.key===s));return-1===i?l:r[i]},set(e){const t=a.value.findIndex((e=>e.key===s));-1!==t?m(t,e):_("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return d}function p(){v(),null==n||n.validate({mode:"silent"})}function m(r,a){const l=t.unref(e),i=M(null==n?void 0:n.values,l);!Array.isArray(i)||i.length-1<r||(C(n.values,`${l}[${r}]`,a),null==n||n.validate({mode:"validated-only"}))}c();const h={fields:a,remove:function(r){const l=t.unref(e),i=M(null==n?void 0:n.values,l);if(!i||!Array.isArray(i))return;const u=[...i];u.splice(r,1);const o=l+`[${r}]`;n.markForUnmount(o),n.unsetInitialValue(o),C(n.values,l,u),a.value.splice(r,1),p()},push:function(l){const i=t.unref(e),u=M(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[...o];s.push(l),n.stageInitialValue(i+`[${s.length-1}]`,l),C(n.values,i,s),a.value.push(f(l)),p()},swap:function(r,l){const i=t.unref(e),u=M(null==n?void 0:n.values,i);if(!Array.isArray(u)||!(r in u)||!(l in u))return;const o=[...u],s=[...a.value],d=o[r];o[r]=o[l],o[l]=d;const c=s[r];s[r]=s[l],s[l]=c,C(n.values,i,o),a.value=s,v()},insert:function(r,l){const i=t.unref(e),u=M(null==n?void 0:n.values,i);if(!Array.isArray(u)||u.length<r)return;const o=[...u],s=[...a.value];o.splice(r,0,l),s.splice(r,0,f(l)),C(n.values,i,o),a.value=s,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),C(n.values,a,r),c(),p()},prepend:function(l){const i=t.unref(e),u=M(null==n?void 0:n.values,i),o=r(u)?[]:u;if(!Array.isArray(o))return;const s=[l,...o];n.stageInitialValue(i+`[${s.length-1}]`,l),C(n.values,i,s),a.value.unshift(f(l)),p()},move:function(l,i){const u=t.unref(e),o=M(null==n?void 0:n.values,u),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(l in o)||!(i in o))return;const d=[...a.value],c=d[l];d.splice(l,1),d.splice(i,0,c);const v=s[l];s.splice(l,1),s.splice(i,0,v),C(n.values,u,s),a.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{j(e,a.value.map((e=>e.value)))||c()})),h}const Oe=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:l,insert:i,replace:u,update:o,prepend:s,move:d,fields:c}=Ve(t.toRef(e,"name"));function v(){return{fields:c.value,push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:l,insert:i,update:o,replace:u,prepend:s,move:d}),()=>K(void 0,n,v)}}),Fe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(d,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function l(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=K(r,n,l),u=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,u,i):t.h(r||"span",u,a.value):i}}});e.ErrorMessage=Fe,e.Field=fe,e.FieldArray=Oe,e.FieldContextKey=c,e.Form=be,e.FormContextKey=d,e.IS_ABSENT=v,e.configure=ee,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),s[e]=t},e.normalizeRules=H,e.useField=oe,e.useFieldArray=Ve,e.useFieldError=function(e){const n=T(d),r=e?void 0:t.inject(c);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=T(d),r=e?void 0:t.inject(c);return t.computed((()=>e?M(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=ye,e.useFormErrors=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=q(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.dirty:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.dirty)&&void 0!==t&&t)}))},e.useIsFieldTouched=function(e){const n=q(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.touched:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.touched)&&void 0!==t&&t)}))},e.useIsFieldValid=function(e){const n=q(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=T(d);t||_("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=T(d),r=e?void 0:t.inject(c);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(_(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=T(d);return e||_("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=te,e.validateObject=le}));
|
|
6
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function l(e){return Number(e)>=0}function i(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function u(e,t){return Object.keys(t).forEach((n=>{if(i(t[n]))return e[n]||(e[n]={}),void u(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)l(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};const d=Symbol("vee-validate-form"),c=Symbol("vee-validate-field-instance"),v=Symbol("Default empty value"),f="undefined"!=typeof window;function p(e){return n(e)&&!!e.__locatorRef}function m(e){return!!e&&n(e.parse)&&"VVTypedSchema"===e.__type}function h(e){return!!e&&n(e.validate)}function y(e){return"checkbox"===e||"radio"===e}function g(e){return/^\[.+\]$/i.test(e)}function b(e){return"SELECT"===e.tagName}function V(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!y(t.type)}function O(e){return F(e)&&e.target&&"submit"in e.target}function F(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function A(e,t){return t in e&&e[t]!==v}function j(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!j(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!j(r[1],t.get(r[0])))return!1;return!0}if(w(e)&&w(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();for(r=n=(a=Object.keys(e)).length;0!=r--;){var l=a[r];if(!j(e[l],t[l]))return!1}return!0}return e!=e&&t!=t}function w(e){return!!f&&e instanceof File}function S(e,t,n){"object"==typeof n.value&&(n.value=E(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function E(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(E(e))}))):"[object Map]"===l?(r=new Map,e.forEach((function(e,t){r.set(E(t),E(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(E(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++)S(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]||S(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function k(e){return g(e)?e.replace(/\[|\]/gi,""):e}function I(e,t,n){if(!e)return n;if(g(t))return e[k(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 M(e,t,n){if(g(t))return void(e[k(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 C(e,t){Array.isArray(e)&&l(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function B(e,t){if(g(t))return void delete e[k(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let l=e;for(let e=0;e<n.length;e++){if(e===n.length-1){C(l,n[e]);break}if(!(n[e]in l)||r(l[n[e]]))break;l=l[n[e]]}const i=n.map(((t,r)=>I(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?C(i[t-1],n[t-1]):C(e,n[0]));var u}function P(e){return Object.keys(e)}function T(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function U(e){t.warn(`[vee-validate]: ${e}`)}function _(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>j(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return j(e,t)?n:t}function R(e,t=0){let n=null,r=[];return function(...a){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function 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 $({get:e,set:n}){const r=t.ref(E(e()));return t.watch(e,(e=>{j(e,r.value)||(r.value=E(e))}),{deep:!0}),t.watch(r,(t=>{j(t,e())||n(E(t))}),{deep:!0}),r}function D(e){return Array.isArray(e)?e:e?[e]:[]}function z(e){const n=T(d),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.unref(e)))):void 0,a=e?void 0:t.inject(c);return a||(null==r?void 0:r.value)||U(`field with name ${t.unref(e)} was not found`),r||a}function q(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}const L=(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 K(e){if(W(e))return e._value}function W(e){return"_value"in e}function G(e){if(!F(e))return e;const t=e.target;if(y(t.type)&&W(t))return K(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(b(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(K);var n;if(b(t)){const e=Array.from(t.options).find((e=>e.selected));return e?K(e):t.value}return function(e){return"number"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}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=>I(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const 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 Y=()=>Q,Z=e=>{Q=Object.assign(Object.assign({},Q),e)};async function ee(e,t,r={}){const a=null==r?void 0:r.bails,l={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(m(e.rules)||h(e.rules))return async function(e,t){const n=m(t)?t:te(t),r=await n.parse(e),a=[];for(const e of r.errors)e.errors.length&&a.push(...e.errors);return{errors:a}}(t,e.rules);if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,l=[];for(let i=0;i<a;i++){const a=r[i],u=await a(t,n);if(!("string"!=typeof u&&!Array.isArray(u)&&u)){if(Array.isArray(u))l.push(...u);else{const e="string"==typeof u?u:re(n);l.push(e)}if(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 ne(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 te(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 ne(e,t,n){const r=(a=n.name,s[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const l=function(e,t){const n=e=>p(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),i={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:l})},u=await r(t,l,i);return"string"==typeof u?{error:u}:{error:u?void 0:re(i)}}function re(e){const t=Y().generateMessage;return t?t(e):"Field is invalid"}async function ae(e,t,n){const r=P(e).map((async r=>{var a,l,i;const u=null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r],o=await ee(I(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 le=0;function ie(e,n){const{value:r,initialValue:a,setInitialValue:l}=function(e,n,r){const a=t.ref(t.unref(n));function l(){return r?I(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 I(n.values,t.unref(a),t.unref(r))}(n,r,u,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>I(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue: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=D(t)}}}(),d=le>=Number.MAX_SAFE_INTEGER?0:++le,c=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!j(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&l(e.initialValue)}return{id:d,path:e,value:r,initialValue:a,meta:c,flags:{pendingUnmount:{[d]:!1}},errors:o,setState:v}}const i=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),u=t.computed((()=>i.errors));return{id:Array.isArray(i.id)?i.id[i.id.length-1]:i.id,path:e,value:r,errors:u,meta:i,initialValue:a,flags:i.__flags,setState:function(a){var i,u,o;"value"in a&&(r.value=a.value),"errors"in a&&(null===(i=n.form)||void 0===i||i.setFieldError(t.unref(e),a.errors)),"touched"in a&&(null===(u=n.form)||void 0===u||u.setFieldTouched(t.unref(e),null!==(o=a.touched)&&void 0!==o&&o)),"initialValue"in a&&l(a.initialValue)}}}function ue(e,n,r){return y(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:T(d),l=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function u(n){const u=n.handleChange,o=t.computed((()=>{const e=t.unref(n.value),r=t.unref(l);return Array.isArray(e)?e.findIndex((e=>j(e,r)))>=0:j(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==a?void 0:a.getPathState(f),m=G(s);let h=null!==(v=t.unref(l))&&void 0!==v?v:m;a&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=_(I(a.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=_(t.unref(n.value),h,t.unref(i))),u(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:l,uncheckedValue:i,handleChange:s})}return u(oe(e,n,r))}(e,n,r):oe(e,n,r)}function oe(e,r,a){const{initialValue:l,validateOnMount:i,bails:u,type:s,checkedValue:f,label:y,validateOnValueUpdate:g,uncheckedValue:b,controlled:V,keepValueOnUnmount:O,syncVModel:F,form:A}=function(e){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),r=!!(null==e?void 0:e.syncVModel),a="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",l=r&&!("initialValue"in(e||{}))?se(t.getCurrentInstance(),a):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:l});const i="valueProp"in e?e.valueProp:e.checkedValue,u="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:l,controlled:null==u||u,checkedValue:i,syncVModel:o})}(a),w=V?T(d):void 0,S=A||w,k=t.computed((()=>o(t.toValue(e)))),M=t.computed((()=>{if(t.unref(null==S?void 0:S.schema))return;const e=t.unref(r);return h(e)||m(e)||n(e)||Array.isArray(e)?e:X(e)})),{id:C,value:B,initialValue:U,meta:_,setState:R,errors:$,flags:D}=ie(k,{modelValue:l,form:S,bails:u,label:y,type:s,validate:M.value?W:void 0}),z=t.computed((()=>$.value[0]));F&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a||!e)return;const l="string"==typeof e?e:"modelValue",i=`update:${l}`;if(!(l in a.props))return;t.watch(n,(e=>{j(e,se(a,l))||a.emit(i,e)})),t.watch((()=>se(a,l)),(e=>{if(e===v&&void 0===n.value)return;const t=e===v?void 0:e;j(t,n.value)||r(t)}))}({value:B,prop:F,handleChange:H});async function q(e){var n,r;return(null==S?void 0:S.validateSchema)?null!==(n=(await S.validateSchema(e)).results[t.unref(k)])&&void 0!==n?n:{valid:!0,errors:[]}:M.value?ee(B.value,M.value,{name:t.unref(k),label:t.unref(y),values:null!==(r=null==S?void 0:S.values)&&void 0!==r?r:{},bails:u}):{valid:!0,errors:[]}}const L=N((async()=>(_.pending=!0,_.validated=!0,q("validated-only"))),(e=>{if(!D.pendingUnmount[te.id])return R({errors:e.errors}),_.pending=!1,_.valid=e.valid,e})),K=N((async()=>q("silent")),(e=>(_.valid=e.valid,e)));function W(e){return"silent"===(null==e?void 0:e.mode)?K():L()}function H(e,t=!0){Y(G(e),t)}function J(e){var t;const n=e&&"value"in e?e.value:U.value;R({value:E(n),initialValue:E(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,K()}t.onMounted((()=>{if(i)return L();S&&S.validateSchema||K()}));const Q=t.getCurrentInstance();function Y(e,t=!0){B.value=Q&&F?x(e,Q.props.modelModifiers):e;(t?L:K)()}const Z=t.computed({get:()=>B.value,set(e){Y(e,g)}}),te={id:C,name:k,label:y,value:Z,meta:_,errors:$,errorMessage:z,type:s,checkedValue:f,uncheckedValue:b,bails:u,keepValueOnUnmount:O,resetField:J,handleReset:()=>J(),validate:W,handleChange:H,handleBlur:(e,t=!1)=>{_.touched=!0,t&&L()},setState:R,setTouched:function(e){_.touched=e},setErrors:function(e){R({errors:Array.isArray(e)?e:[e]})},setValue:Y};if(t.provide(c,te),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{j(e,t)||(_.validated?L():K())}),{deep:!0}),!S)return te;const ne=t.computed((()=>{const e=M.value;return!e||n(e)||h(e)||m(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(p):P(a).filter((e=>p(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=I(S.values,t)||S.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;!j(e,t)&&(_.validated?L():K())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.unref(te.keepValueOnUnmount))&&void 0!==e?e:t.unref(S.keepValuesOnUnmount),r=t.toValue(k);if(n||!S||D.pendingUnmount[te.id])return void(null==S||S.removePathState(r,C));D.pendingUnmount[te.id]=!0;const a=S.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=>j(e,t.unref(te.checkedValue))));if(e>-1){const t=[...a.value];t.splice(e,1),S.setFieldValue(r,t)}Array.isArray(a.id)&&a.id.splice(a.id.indexOf(te.id),1)}else S.unsetPathValue(t.toValue(k));S.removePathState(r,C)}})),te}function se(e,t){if(e)return e.props[t]}function de(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ce(e,t){return y(t.attrs.type)?A(e,"modelValue")?e.modelValue:void 0:A(e,"modelValue")?e.modelValue:t.attrs.value}const ve=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:()=>Y().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:v},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const a=t.toRef(e,"rules"),l=t.toRef(e,"name"),i=t.toRef(e,"label"),u=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:g,meta:b,checked:O,setErrors:F}=ue(l,a,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:ce(e,r),checkedValue:r.attrs.value,uncheckedValue:u,label:i,validateOnValueUpdate:!1,keepValueOnUnmount:o,syncVModel:!0}),A=function(e,t=!0){f(e,t),r.emit("update:modelValue",d.value)},j=t.computed((()=>{const{validateOnInput:t,validateOnChange:a,validateOnBlur:l,validateOnModelUpdate:i}=function(e){var t,n,r,a;const{validateOnInput:l,validateOnChange:i,validateOnBlur:u,validateOnModelUpdate:o}=Y();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:l,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:u,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e);const u={name:e.name,onBlur:function(e){p(e,l),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){A(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){A(e,a),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>A(e,i)};return u})),w=t.computed((()=>{const t=Object.assign({},j.value);y(r.attrs.type)&&O&&(t.checked=O.value);return V(de(e,r),r.attrs)&&(t.value=d.value),t})),S=t.computed((()=>Object.assign(Object.assign({},j.value),{modelValue:d.value})));function E(){return{field:w.value,componentField:S.value,value:d.value,meta:b,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:A,handleInput:e=>A(e,!1),handleReset:g,handleBlur:j.value.onBlur,setTouched:m,setErrors:F}}return r.expose({setErrors:F,setTouched:m,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(de(e,r)),a=L(n,r,E);return n?t.h(n,Object.assign(Object.assign({},r.attrs),w.value),a):a}}});let fe=0;const pe=["bails","fieldsCount","id","multiple","type","validate"];function me(e){const r=t.unref(null==e?void 0:e.initialValues)||{},a=t.unref(null==e?void 0:e.validationSchema);return a&&m(a)&&n(a.cast)?E(a.cast(r)||{}):E(r)}function he(e){var r;const a=fe++;let l=0;const i=t.ref(!1),s=t.ref(!1),c=t.ref(0),v=[],f=t.reactive(me(e)),p=t.ref([]),y=t.ref({}),g=t.ref({}),b=function(e){let n=null,r=[];return function(...a){const l=t.nextTick((()=>{if(n!==l)return;const t=e(...a);r.forEach((e=>e(t))),r=[],n=null}));return n=l,new Promise((e=>r.push(e)))}}((()=>{g.value=p.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function V(e,t){const n=Q(e);if(n){if("string"==typeof e){const t=o(e);y.value[t]&&delete y.value[t]}n.errors=D(t),n.valid=!n.errors.length}else"string"==typeof e&&(y.value[o(e)]=D(t))}function F(e){P(e).forEach((t=>{V(t,e[t])}))}(null==e?void 0:e.initialErrors)&&F(e.initialErrors);const A=t.computed((()=>{const e=p.value.reduce(((e,t)=>(t.errors.length&&(e[t.path]=t.errors),e)),{});return Object.assign(Object.assign({},y.value),e)})),w=t.computed((()=>P(A.value).reduce(((e,t)=>{const n=A.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),S=t.computed((()=>p.value.reduce(((e,t)=>(e[t.path]={name:t.path||"",label:t.label||""},e)),{}))),k=t.computed((()=>p.value.reduce(((e,t)=>{var n;return e[t.path]=null===(n=t.bails)||void 0===n||n,e}),{}))),C=Object.assign({},(null==e?void 0:e.initialErrors)||{}),T=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:U,originalInitialValues:_,setInitialValues:x}=function(e,n,r){const a=me(r),l=null==r?void 0:r.initialValues,i=t.ref(a),o=t.ref(E(a));function s(t,r=!1){i.value=u(E(i.value)||{},E(t)),o.value=u(E(o.value)||{},E(t)),r&&e.value.forEach((e=>{if(e.touched)return;const t=I(i.value,e.path);M(n,e.path,E(t))}))}t.isRef(l)&&t.watch(l,(e=>{e&&s(e,!0)}),{deep:!0});return{initialValues:i,originalInitialValues:o,setInitialValues:s}}(p,f,e),$=function(e,n,r,a){const l={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!j(n,t.unref(r))));function u(){const t=e.value;return P(l).reduce(((e,n)=>{const r=l[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(u());return t.watchEffect((()=>{const e=u();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!P(a.value).length,dirty:i.value})))}(p,f,_,w),z=t.computed((()=>p.value.reduce(((e,t)=>{const n=I(f,t.path);return M(e,t.path,n),e}),{}))),L=null==e?void 0:e.validationSchema;function K(e,n){var r,a;const i=t.computed((()=>I(U.value,t.toValue(e)))),u=g.value[t.toValue(e)];if(u){"checkbox"!==(null==n?void 0:n.type)&&"radio"!==(null==n?void 0:n.type)||(u.multiple=!0);const e=l++;return Array.isArray(u.id)?u.id.push(e):u.id=[u.id,e],u.fieldsCount++,u.__flags.pendingUnmount[e]=!1,u}const o=t.computed((()=>I(f,t.toValue(e)))),s=t.toValue(e),d=l++,c=t.reactive({id:d,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=C[s])||void 0===r?void 0:r.length),initialValue:i,errors:t.shallowRef([]),bails:null!==(a=null==n?void 0:n.bails)&&void 0!==a&&a,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:o,multiple:!1,__flags:{pendingUnmount:{[d]:!1}},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!j(t.unref(o),t.unref(i))))});return p.value.push(c),g.value[s]=c,b(),w.value[s]&&!C[s]&&t.nextTick((()=>{ye(s,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{b();const n=E(o.value);g.value[e]=c,t.nextTick((()=>{M(f,e,n)}))})),c}const W=R(Ve,5),X=R(Ve,5),H=N((async e=>"silent"===await e?W():X()),((e,[t])=>{const n=P(le.errorBag.value);return[...new Set([...P(e.results),...p.value.map((e=>e.path)),...n])].sort().reduce(((n,r)=>{const a=r,l=Q(a)||function(e){const t=p.value.filter((t=>e.startsWith(t.path)));return t.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(a),i=(e.results[a]||{errors:[]}).errors,u={errors:i,valid:!i.length};return n.results[a]=u,u.valid||(n.errors[a]=u.errors[0]),l&&y.value[a]&&delete y.value[a],l?(l.valid=u.valid,"silent"===t?n:"validated-only"!==t||l.validated?(V(l,u.errors),n):n):(V(a,i),n)}),{valid:e.valid,results:{},errors:{}})}));function J(e){p.value.forEach(e)}function Q(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?g.value[t]:t}let Z,ee=[];function ne(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),J((e=>e.touched=!0)),i.value=!0,c.value++,he().then((a=>{const l=E(f);if(a.valid&&"function"==typeof t){const n=E(z.value);let i=e?n:l;return a.values&&(i=a.values),t(i,{evt:r,controlledValues:n,setErrors:F,setFieldError:V,setTouched:de,setFieldTouched:se,setValues:ue,setFieldValue:ie,resetForm:ve,resetField:ce})}a.valid||"function"!=typeof n||n({values:l,evt:r,errors:a.errors,results:a.results})})).then((e=>(i.value=!1,e)),(e=>{throw i.value=!1,e}))}}}const re=ne(!1);re.withControlled=ne(!0);const le={formId:a,values:f,controlledValues:z,errorBag:A,errors:w,schema:L,submitCount:c,meta:$,isSubmitting:i,isValidating:s,fieldArrays:v,keepValuesOnUnmount:T,validateSchema:t.unref(L)?H:void 0,validate:he,setFieldError:V,validateField:ye,setFieldValue:ie,setValues:ue,setErrors:F,setFieldTouched:se,setTouched:de,resetForm:ve,resetField:ce,handleSubmit:re,stageInitialValue:function(t,n,r=!1){be(t,n),M(f,t,n),r&&!(null==e?void 0:e.initialValues)&&M(_.value,t,E(n))},unsetInitialValue:ge,setFieldInitialValue:be,useFieldModel:function(e){if(!Array.isArray(e))return oe(e);return e.map(oe)},createPathState:K,getPathState:Q,unsetPathValue:function(e){return ee.push(e),Z||(Z=t.nextTick((()=>{[...ee].sort().reverse().forEach((e=>{B(f,e)})),ee=[],Z=null}))),Z},removePathState:function(e,n){const r=p.value.findIndex((t=>t.path===e)),a=p.value[r];if(-1!==r&&a){if(t.nextTick((()=>{ye(e,{mode:"silent",warn:!1})})),a.multiple&&a.fieldsCount&&a.fieldsCount--,Array.isArray(a.id)){const e=a.id.indexOf(n);e>=0&&a.id.splice(e,1),delete a.__flags.pendingUnmount[n]}(!a.multiple||a.fieldsCount<=0)&&(p.value.splice(r,1),ge(e),b(),delete g.value[e])}},initialValues:U,getAllPathStates:()=>p.value,markForUnmount:function(e){return J((t=>{t.path.startsWith(e)&&P(t.__flags.pendingUnmount).forEach((e=>{t.__flags.pendingUnmount[e]=!0}))}))}};function ie(e,t,n=!0){const r=E(t),a="string"==typeof e?e:e.path;Q(a)||K(a),M(f,a,r),n&&ye(a)}function ue(e,t=!0){u(f,e),v.forEach((e=>e&&e.reset())),t&&he()}function oe(e){const n=Q(t.unref(e))||K(e);return t.computed({get:()=>n.value,set(r){const a=t.unref(e);ie(a,r,!1),n.validated=!0,n.pending=!0,ye(a).then((()=>{n.pending=!1}))}})}function se(e,t){const n=Q(e);n&&(n.touched=t)}function de(e){P(e).forEach((t=>{se(t,!!e[t])}))}function ce(e,t){var n;const r=t&&"value"in t?t.value:I(U.value,e);be(e,E(r)),ie(e,r,!1),se(e,null!==(n=null==t?void 0:t.touched)&&void 0!==n&&n),V(e,(null==t?void 0:t.errors)||[])}function ve(e){let r=(null==e?void 0:e.values)?e.values:_.value;r=m(L)&&n(L.cast)?L.cast(r):r,x(r),J((t=>{var n;t.validated=!1,t.touched=(null===(n=null==e?void 0:e.touched)||void 0===n?void 0:n[t.path])||!1,ie(t.path,I(r,t.path),!1),V(t.path,void 0)})),ue(r,!1),F((null==e?void 0:e.errors)||{}),c.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{he({mode:"silent"})}))}async function he(e){const t=(null==e?void 0:e.mode)||"force";if("force"===t&&J((e=>e.validated=!0)),le.validateSchema)return le.validateSchema(t);s.value=!0;const n=await Promise.all(p.value.map((t=>t.validate?t.validate(e).then((e=>({key:t.path,valid:e.valid,errors:e.errors}))):Promise.resolve({key:t.path,valid:!0,errors:[]}))));s.value=!1;const r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function ye(e,n){var r;const a=Q(e);if(a&&(a.validated=!0),L){const{results:t}=await H((null==n?void 0:n.mode)||"validated-only");return t[e]||{errors:[],valid:!0}}if(null==a?void 0:a.validate)return a.validate(n);return!a&&(null===(r=null==n?void 0:n.warn)||void 0===r||r)&&t.warn(`field with path ${e} was not found`),Promise.resolve({errors:[],valid:!0})}function ge(e){B(U.value,e)}function be(e,t){M(U.value,e,E(t))}async function Ve(){const e=t.unref(L);if(!e)return{valid:!0,results:{},errors:{}};s.value=!0;const n=h(e)||m(e)?await async function(e,t){const n=m(e)?e:te(e),r=await n.parse(t),a={},l={};for(const e of r.errors){const t=e.errors,n=(e.path||"").replace(/\["(\d+)"\]/g,((e,t)=>`[${t}]`));a[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!r.errors.length,results:a,errors:l,values:r.value}}(e,f):await ae(e,f,{names:S.value,bailsMap:k.value});return s.value=!1,n}const Oe=re(((e,{evt:t})=>{O(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&F(e.initialErrors),(null==e?void 0:e.initialTouched)&&de(e.initialTouched),(null==e?void 0:e.validateOnMount)?he():le.validateSchema&&le.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=le.validateSchema)||void 0===e||e.call(le,"validated-only")})),t.provide(d,le),Object.assign(Object.assign({},le),{values:t.readonly(f),handleReset:()=>ve(),submitForm:Oe,defineComponentBinds:function(e,r){const a=Q(t.toValue(e))||K(e),l=()=>n(r)?r(q(a,pe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Y().validateOnBlur)&&ye(a.path)}function u(e){var t;const n=null!==(t=l().validateOnModelUpdate)&&void 0!==t?t:Y().validateOnModelUpdate;ie(a.path,e,n)}return t.computed((()=>{if(n(r)){const e=r(a),t=e.model||"modelValue";return Object.assign({onBlur:i,[t]:a.value,[`onUpdate:${t}`]:u},e.props||{})}const e=(null==r?void 0:r.model)||"modelValue",t={onBlur:i,[e]:a.value,[`onUpdate:${e}`]:u};return(null==r?void 0:r.mapProps)?Object.assign(Object.assign({},t),r.mapProps(q(a,pe))):t}))},defineInputBinds:function(e,r){const a=Q(t.toValue(e))||K(e),l=()=>n(r)?r(q(a,pe)):r||{};function i(){var e;a.touched=!0;(null!==(e=l().validateOnBlur)&&void 0!==e?e:Y().validateOnBlur)&&ye(a.path)}function u(e){var t;const n=G(e),r=null!==(t=l().validateOnInput)&&void 0!==t?t:Y().validateOnInput;ie(a.path,n,r)}function o(e){var t;const n=G(e),r=null!==(t=l().validateOnChange)&&void 0!==t?t:Y().validateOnChange;ie(a.path,n,r)}return t.computed((()=>{const e={value:a.value,onChange:o,onInput:u,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(q(a,pe)).attrs||{}):(null==r?void 0:r.mapAttrs)?Object.assign(Object.assign({},e),r.mapAttrs(q(a,pe))):e}))}})}const ye=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:i,errorBag:u,values:o,meta:s,isSubmitting:d,isValidating:c,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetField:k}=he({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l}),I=g(((e,{evt:t})=>{O(t)&&t.target.submit()}),e.onInvalidSubmit),M=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):I;function C(e){F(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function B(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function P(){return E(o)}function T(){return E(s.value)}function U(){return E(i.value)}function _(){return{meta:s.value,errors:i.value,errorBag:u.value,values:o,isSubmitting:d.value,isValidating:c.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:B,handleReset:h,submitForm:I,setErrors:b,setFieldError:V,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetForm:y,resetField:k,getValues:P,getMeta:T,getErrors:U}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:A,setValues:j,setFieldTouched:w,setTouched:S,resetForm:y,validate:p,validateField:m,resetField:k,getValues:P,getMeta:T,getErrors:U}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=L(r,n,_);if(!e.as)return a;const l="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},l),n.attrs),{onSubmit:M,onReset:C}),a)}}}),ge=ye;function be(e){const n=T(d,void 0),a=t.ref([]),l=()=>{},i={fields:a,remove:l,push:l,swap:l,insert:l,update:l,replace:l,prepend:l,move:l};if(!n)return U("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 U("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const u=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(u)return u;let o=0;function s(){return I(null==n?void 0:n.values,t.unref(e),[])||[]}function c(){const e=s();Array.isArray(e)&&(a.value=e.map(((e,t)=>f(e,t,a.value))),v())}function v(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(l,i,u){if(u&&!r(i)&&u[i])return u[i];const s=o++,d={key:s,value:$({get(){const r=I(null==n?void 0:n.values,t.unref(e),[])||[],i=a.value.findIndex((e=>e.key===s));return-1===i?l:r[i]},set(e){const t=a.value.findIndex((e=>e.key===s));-1!==t?m(t,e):U("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=I(null==n?void 0:n.values,l);!Array.isArray(i)||i.length-1<r||(M(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=I(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),M(n.values,l,u),a.value.splice(r,1),p()},push:function(l){const i=E(l),u=t.unref(e),o=I(null==n?void 0:n.values,u),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(i),n.stageInitialValue(u+`[${d.length-1}]`,i),M(n.values,u,d),a.value.push(f(i)),p()},swap:function(r,l){const i=t.unref(e),u=I(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,M(n.values,i,o),a.value=s,v()},insert:function(r,l){const i=E(l),u=t.unref(e),o=I(null==n?void 0:n.values,u);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...a.value];s.splice(r,0,i),d.splice(r,0,f(i)),M(n.values,u,s),a.value=d,p()},update:m,replace:function(r){const a=t.unref(e);n.stageInitialValue(a,r),M(n.values,a,r),c(),p()},prepend:function(l){const i=E(l),u=t.unref(e),o=I(null==n?void 0:n.values,u),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[i,...s];n.stageInitialValue(u+`[${d.length-1}]`,i),M(n.values,u,d),a.value.unshift(f(i)),p()},move:function(l,i){const u=t.unref(e),o=I(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),M(n.values,u,s),a.value=d,p()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},h)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{j(e,a.value.map((e=>e.value)))||c()})),h}const Ve=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}=be(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}),()=>L(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(d,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function l(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=L(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=ve,e.FieldArray=Ve,e.FieldContextKey=c,e.Form=ge,e.FormContextKey=d,e.IS_ABSENT=v,e.configure=Z,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),s[e]=t},e.normalizeRules=X,e.useField=ue,e.useFieldArray=be,e.useFieldError=function(e){const n=T(d),r=e?void 0:t.inject(c);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=T(d),r=e?void 0:t.inject(c);return t.computed((()=>e?I(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=he,e.useFormErrors=function(){const e=T(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=T(d);return e||U("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=z(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=z(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=z(e);return t.computed((()=>{var e,t;return!!n&&(null!==(t="meta"in n?n.meta.valid:null===(e=null==n?void 0:n.value)||void 0===e?void 0:e.valid)&&void 0!==t&&t)}))},e.useIsFormDirty=function(){const e=T(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=T(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=T(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=T(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=T(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=T(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=T(d);return e||U("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=T(d);t||U("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=T(d),r=e?void 0:t.inject(c);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.unref(e)):(U(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=T(d);return e||U("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=ee,e.validateObject=ae}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vee-validate",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.8",
|
|
4
4
|
"description": "Form Validation for Vue.js",
|
|
5
5
|
"author": "Abdelrahman Awad <logaretm1@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@vue/devtools-api": "^6.5.0",
|
|
35
|
-
"type-fest": "^
|
|
35
|
+
"type-fest": "^4.0.0"
|
|
36
36
|
}
|
|
37
37
|
}
|