vee-validate 5.0.0-beta.0 → 5.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vee-validate.cjs +12 -63
- package/dist/vee-validate.d.ts +9 -36
- package/dist/vee-validate.iife.js +12 -63
- package/dist/vee-validate.iife.prod.js.mjs +3 -3
- package/dist/vee-validate.mjs +21 -66
- package/package.json +1 -1
package/dist/vee-validate.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v5.0.0-beta.
|
|
3
|
-
* (c)
|
|
2
|
+
* vee-validate v5.0.0-beta.1
|
|
3
|
+
* (c) 2026 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
'use strict';
|
|
@@ -637,9 +637,6 @@ function hasValueBinding(el) {
|
|
|
637
637
|
}
|
|
638
638
|
|
|
639
639
|
function parseInputValue(el) {
|
|
640
|
-
if (el.type === 'number') {
|
|
641
|
-
return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
|
|
642
|
-
}
|
|
643
640
|
if (el.type === 'range') {
|
|
644
641
|
return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
|
|
645
642
|
}
|
|
@@ -1428,6 +1425,7 @@ function _useField(path, rules, opts) {
|
|
|
1428
1425
|
* Normalizes partial field options to include the full options
|
|
1429
1426
|
*/
|
|
1430
1427
|
function normalizeOptions(opts) {
|
|
1428
|
+
var _a;
|
|
1431
1429
|
const defaults = () => ({
|
|
1432
1430
|
initialValue: undefined,
|
|
1433
1431
|
validateOnMount: false,
|
|
@@ -1439,22 +1437,19 @@ function normalizeOptions(opts) {
|
|
|
1439
1437
|
controlled: true,
|
|
1440
1438
|
});
|
|
1441
1439
|
const isVModelSynced = !!(opts === null || opts === void 0 ? void 0 : opts.syncVModel);
|
|
1442
|
-
const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === 'string' ? opts.syncVModel :
|
|
1440
|
+
const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === 'string' ? opts.syncVModel : 'modelValue';
|
|
1443
1441
|
const initialValue = isVModelSynced && !('initialValue' in (opts || {}))
|
|
1444
1442
|
? getCurrentModelValue(vue.getCurrentInstance(), modelPropName)
|
|
1445
1443
|
: opts === null || opts === void 0 ? void 0 : opts.initialValue;
|
|
1446
1444
|
if (!opts) {
|
|
1447
1445
|
return Object.assign(Object.assign({}, defaults()), { initialValue });
|
|
1448
1446
|
}
|
|
1449
|
-
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1452
|
-
const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
|
|
1453
|
-
return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { initialValue, controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue,
|
|
1454
|
-
syncVModel });
|
|
1447
|
+
const controlled = (_a = opts.controlled) !== null && _a !== void 0 ? _a : true;
|
|
1448
|
+
const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
|
|
1449
|
+
return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { initialValue, controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue: opts === null || opts === void 0 ? void 0 : opts.checkedValue, syncVModel });
|
|
1455
1450
|
}
|
|
1456
1451
|
function useFieldWithChecked(name, rules, opts) {
|
|
1457
|
-
const form =
|
|
1452
|
+
const form = (opts === null || opts === void 0 ? void 0 : opts.controlled) ? injectWithSelf(FormContextKey) : undefined;
|
|
1458
1453
|
const checkedValue = opts === null || opts === void 0 ? void 0 : opts.checkedValue;
|
|
1459
1454
|
const uncheckedValue = opts === null || opts === void 0 ? void 0 : opts.uncheckedValue;
|
|
1460
1455
|
function patchCheckedApi(field) {
|
|
@@ -1588,9 +1583,9 @@ const FieldImpl = /** #__PURE__ */ vue.defineComponent({
|
|
|
1588
1583
|
type: null,
|
|
1589
1584
|
default: undefined,
|
|
1590
1585
|
},
|
|
1591
|
-
|
|
1586
|
+
controlled: {
|
|
1592
1587
|
type: Boolean,
|
|
1593
|
-
default:
|
|
1588
|
+
default: true,
|
|
1594
1589
|
},
|
|
1595
1590
|
keepValue: {
|
|
1596
1591
|
type: Boolean,
|
|
@@ -1606,7 +1601,7 @@ const FieldImpl = /** #__PURE__ */ vue.defineComponent({
|
|
|
1606
1601
|
const { errors, value, errorMessage, validate: validateField, handleChange, handleBlur, setTouched, resetField, handleReset, meta, checked, setErrors, setValue, } = useField(name, rules, {
|
|
1607
1602
|
validateOnMount: props.validateOnMount,
|
|
1608
1603
|
bails: props.bails,
|
|
1609
|
-
|
|
1604
|
+
controlled: props.controlled,
|
|
1610
1605
|
type: ctx.attrs.type,
|
|
1611
1606
|
initialValue: resolveInitialValue(props, ctx),
|
|
1612
1607
|
// Only for checkboxes and radio buttons
|
|
@@ -2153,9 +2148,6 @@ function useForm(opts) {
|
|
|
2153
2148
|
resetForm,
|
|
2154
2149
|
resetField,
|
|
2155
2150
|
handleSubmit,
|
|
2156
|
-
useFieldModel,
|
|
2157
|
-
defineInputBinds,
|
|
2158
|
-
defineComponentBinds: defineComponentBinds,
|
|
2159
2151
|
defineField,
|
|
2160
2152
|
stageInitialValue,
|
|
2161
2153
|
unsetInitialValue,
|
|
@@ -2491,50 +2483,6 @@ function useForm(opts) {
|
|
|
2491
2483
|
const model = createModel(path, () => { var _a, _b, _c; return (_c = (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : (_b = getConfig()) === null || _b === void 0 ? void 0 : _b.validateOnModelUpdate) !== null && _c !== void 0 ? _c : true; });
|
|
2492
2484
|
return [model, props];
|
|
2493
2485
|
}
|
|
2494
|
-
function useFieldModel(pathOrPaths) {
|
|
2495
|
-
if (!Array.isArray(pathOrPaths)) {
|
|
2496
|
-
return createModel(pathOrPaths);
|
|
2497
|
-
}
|
|
2498
|
-
return pathOrPaths.map(p => createModel(p, true));
|
|
2499
|
-
}
|
|
2500
|
-
/**
|
|
2501
|
-
* @deprecated use defineField instead
|
|
2502
|
-
*/
|
|
2503
|
-
function defineInputBinds(path, config) {
|
|
2504
|
-
const [model, props] = defineField(path, config);
|
|
2505
|
-
function onBlur() {
|
|
2506
|
-
props.value.onBlur();
|
|
2507
|
-
}
|
|
2508
|
-
function onInput(e) {
|
|
2509
|
-
const value = normalizeEventValue(e);
|
|
2510
|
-
setFieldValue(vue.toValue(path), value, false);
|
|
2511
|
-
props.value.onInput();
|
|
2512
|
-
}
|
|
2513
|
-
function onChange(e) {
|
|
2514
|
-
const value = normalizeEventValue(e);
|
|
2515
|
-
setFieldValue(vue.toValue(path), value, false);
|
|
2516
|
-
props.value.onChange();
|
|
2517
|
-
}
|
|
2518
|
-
return vue.computed(() => {
|
|
2519
|
-
return Object.assign(Object.assign({}, props.value), { onBlur,
|
|
2520
|
-
onInput,
|
|
2521
|
-
onChange, value: model.value });
|
|
2522
|
-
});
|
|
2523
|
-
}
|
|
2524
|
-
/**
|
|
2525
|
-
* @deprecated use defineField instead
|
|
2526
|
-
*/
|
|
2527
|
-
function defineComponentBinds(path, config) {
|
|
2528
|
-
const [model, props] = defineField(path, config);
|
|
2529
|
-
const pathState = findPathState(vue.toValue(path));
|
|
2530
|
-
function onUpdateModelValue(value) {
|
|
2531
|
-
model.value = value;
|
|
2532
|
-
}
|
|
2533
|
-
return vue.computed(() => {
|
|
2534
|
-
const conf = isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {};
|
|
2535
|
-
return Object.assign({ [conf.model || 'modelValue']: model.value, [`onUpdate:${conf.model || 'modelValue'}`]: onUpdateModelValue }, props.value);
|
|
2536
|
-
});
|
|
2537
|
-
}
|
|
2538
2486
|
const ctx = Object.assign(Object.assign({}, formCtx), { values: vue.readonly(formValues), handleReset: () => resetForm(), submitForm });
|
|
2539
2487
|
vue.provide(PublicFormContextKey, ctx);
|
|
2540
2488
|
return ctx;
|
|
@@ -3412,6 +3360,7 @@ exports.PublicFormContextKey = PublicFormContextKey;
|
|
|
3412
3360
|
exports.cleanupNonNestedPath = cleanupNonNestedPath;
|
|
3413
3361
|
exports.configure = configure;
|
|
3414
3362
|
exports.defineRule = defineRule;
|
|
3363
|
+
exports.getConfig = getConfig;
|
|
3415
3364
|
exports.isNotNestedPath = isNotNestedPath;
|
|
3416
3365
|
exports.normalizeRules = normalizeRules;
|
|
3417
3366
|
exports.useField = useField;
|
package/dist/vee-validate.d.ts
CHANGED
|
@@ -418,22 +418,6 @@ interface PrivateFormContext<TValues extends GenericObject = GenericObject, TOut
|
|
|
418
418
|
isFieldDirty<TPath extends Path<TValues>>(path: TPath): boolean;
|
|
419
419
|
isFieldValid<TPath extends Path<TValues>>(path: TPath): boolean;
|
|
420
420
|
defineField<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>): [Ref<TValue>, Ref<BaseFieldProps & TExtras>];
|
|
421
|
-
/**
|
|
422
|
-
* @deprecated use defineField instead
|
|
423
|
-
*/
|
|
424
|
-
useFieldModel<TPath extends Path<TValues>>(path: TPath): Ref<PathValue<TValues, TPath>>;
|
|
425
|
-
/**
|
|
426
|
-
* @deprecated use defineField instead
|
|
427
|
-
*/
|
|
428
|
-
useFieldModel<TPaths extends readonly [...MaybeRef<Path<TValues>>[]]>(paths: TPaths): MapValuesPathsToRefs<TValues, TPaths>;
|
|
429
|
-
/**
|
|
430
|
-
* @deprecated use defineField instead
|
|
431
|
-
*/
|
|
432
|
-
defineComponentBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TModel extends string = 'modelValue', TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<ComponentBindsConfig<TValue, TExtras, TModel>> | LazyComponentBindsConfig<TValue, TExtras, TModel>): Ref<BaseComponentBinds<TValue, TModel> & TExtras>;
|
|
433
|
-
/**
|
|
434
|
-
* @deprecated use defineField instead
|
|
435
|
-
*/
|
|
436
|
-
defineInputBinds<TPath extends Path<TValues>, TValue = PathValue<TValues, TPath>, TExtras extends GenericObject = GenericObject>(path: MaybeRefOrGetter<TPath>, config?: Partial<InputBindsConfig<TValue, TExtras>> | LazyInputBindsConfig<TValue, TExtras>): Ref<BaseInputBinds<TValue> & TExtras>;
|
|
437
421
|
}
|
|
438
422
|
interface FormContext<TValues extends GenericObject = GenericObject, TOutput extends GenericObject = TValues> extends Omit<PrivateFormContext<TValues, TOutput>, 'formId' | 'schema' | 'initialValues' | 'getPathState' | 'getAllPathStates' | 'removePathState' | 'unsetPathValue' | 'validateSchema' | 'stageInitialValue' | 'setFieldInitialValue' | 'unsetInitialValue' | 'fieldArrays' | 'markForUnmount' | 'keepValuesOnUnmount' | 'values'> {
|
|
439
423
|
values: TValues;
|
|
@@ -488,6 +472,7 @@ interface VeeValidateConfig {
|
|
|
488
472
|
validateOnBlur: boolean;
|
|
489
473
|
validateOnModelUpdate: boolean;
|
|
490
474
|
}
|
|
475
|
+
declare const getConfig: () => VeeValidateConfig;
|
|
491
476
|
declare const configure: (newConf: Partial<VeeValidateConfig>) => void;
|
|
492
477
|
|
|
493
478
|
/**
|
|
@@ -508,23 +493,11 @@ interface FieldOptions<TValue = unknown> {
|
|
|
508
493
|
validateOnMount?: boolean;
|
|
509
494
|
bails?: boolean;
|
|
510
495
|
type?: InputType;
|
|
511
|
-
/**
|
|
512
|
-
* @deprecated Use `checkedValue` instead.
|
|
513
|
-
*/
|
|
514
|
-
valueProp?: MaybeRefOrGetter<TValue>;
|
|
515
496
|
checkedValue?: MaybeRefOrGetter<TValue>;
|
|
516
497
|
uncheckedValue?: MaybeRefOrGetter<TValue>;
|
|
517
498
|
label?: MaybeRefOrGetter<string | undefined>;
|
|
518
499
|
controlled?: boolean;
|
|
519
|
-
/**
|
|
520
|
-
* @deprecated Use `controlled` instead, controlled is opposite of standalone.
|
|
521
|
-
*/
|
|
522
|
-
standalone?: boolean;
|
|
523
500
|
keepValueOnUnmount?: MaybeRefOrGetter<boolean | undefined>;
|
|
524
|
-
/**
|
|
525
|
-
* @deprecated Pass the model prop name to `syncVModel` instead.
|
|
526
|
-
*/
|
|
527
|
-
modelPropName?: string;
|
|
528
501
|
syncVModel?: boolean | string;
|
|
529
502
|
form?: FormContext;
|
|
530
503
|
}
|
|
@@ -615,7 +588,7 @@ declare const Field: {
|
|
|
615
588
|
type: PropType<(e: any) => unknown>;
|
|
616
589
|
default: any;
|
|
617
590
|
};
|
|
618
|
-
|
|
591
|
+
controlled: {
|
|
619
592
|
type: BooleanConstructor;
|
|
620
593
|
default: boolean;
|
|
621
594
|
};
|
|
@@ -688,7 +661,7 @@ declare const Field: {
|
|
|
688
661
|
type: PropType<(e: any) => unknown>;
|
|
689
662
|
default: any;
|
|
690
663
|
};
|
|
691
|
-
|
|
664
|
+
controlled: {
|
|
692
665
|
type: BooleanConstructor;
|
|
693
666
|
default: boolean;
|
|
694
667
|
};
|
|
@@ -707,7 +680,7 @@ declare const Field: {
|
|
|
707
680
|
validateOnBlur: boolean;
|
|
708
681
|
validateOnModelUpdate: boolean;
|
|
709
682
|
validateOnMount: boolean;
|
|
710
|
-
|
|
683
|
+
controlled: boolean;
|
|
711
684
|
modelModifiers: any;
|
|
712
685
|
rules: RuleExpression<unknown>;
|
|
713
686
|
'onUpdate:modelValue': (e: any) => unknown;
|
|
@@ -776,7 +749,7 @@ declare const Field: {
|
|
|
776
749
|
type: PropType<(e: any) => unknown>;
|
|
777
750
|
default: any;
|
|
778
751
|
};
|
|
779
|
-
|
|
752
|
+
controlled: {
|
|
780
753
|
type: BooleanConstructor;
|
|
781
754
|
default: boolean;
|
|
782
755
|
};
|
|
@@ -803,7 +776,7 @@ declare const Field: {
|
|
|
803
776
|
validateOnBlur: boolean;
|
|
804
777
|
validateOnModelUpdate: boolean;
|
|
805
778
|
validateOnMount: boolean;
|
|
806
|
-
|
|
779
|
+
controlled: boolean;
|
|
807
780
|
modelModifiers: any;
|
|
808
781
|
rules: RuleExpression<unknown>;
|
|
809
782
|
'onUpdate:modelValue': (e: any) => unknown;
|
|
@@ -869,7 +842,7 @@ declare const Field: {
|
|
|
869
842
|
type: PropType<(e: any) => unknown>;
|
|
870
843
|
default: any;
|
|
871
844
|
};
|
|
872
|
-
|
|
845
|
+
controlled: {
|
|
873
846
|
type: BooleanConstructor;
|
|
874
847
|
default: boolean;
|
|
875
848
|
};
|
|
@@ -896,7 +869,7 @@ declare const Field: {
|
|
|
896
869
|
validateOnBlur: boolean;
|
|
897
870
|
validateOnModelUpdate: boolean;
|
|
898
871
|
validateOnMount: boolean;
|
|
899
|
-
|
|
872
|
+
controlled: boolean;
|
|
900
873
|
modelModifiers: any;
|
|
901
874
|
rules: RuleExpression<unknown>;
|
|
902
875
|
'onUpdate:modelValue': (e: any) => unknown;
|
|
@@ -1459,4 +1432,4 @@ declare const PublicFormContextKey: InjectionKey<FormContext>;
|
|
|
1459
1432
|
declare const FieldContextKey: InjectionKey<PrivateFieldContext<unknown>>;
|
|
1460
1433
|
declare const IS_ABSENT: unique symbol;
|
|
1461
1434
|
|
|
1462
|
-
export { type BaseComponentBinds, type BaseFieldProps, type BaseInputBinds, type ComponentBindsConfig, type ComponentFieldBindingObject, type ComponentModelBinds, type ComponentModellessBinds, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldBindingObject, type FieldContext, FieldContextKey, type FieldEntry, type FieldMeta, type FieldOptions, type FieldPathLookup, type FieldSlotProps, type FieldState, type FieldValidator, type FlattenAndMapPathsValidationResult, type FlattenAndSetPathsType, Form, type FormActions, type FormContext, FormContextKey, type FormErrorBag, type FormErrors, type FormMeta, type FormOptions, type FormSlotProps, type FormState, type FormValidationResult, type GenericObject, type GenericValidateFunction, IS_ABSENT, type InputBindsConfig, type InputType, type InvalidSubmissionContext, type InvalidSubmissionHandler, type IsAny, type IsEqual, type IssueCollection, type LazyComponentBindsConfig, type LazyInputBindsConfig, type Locator, type MapValuesPathsToRefs, type MaybeArray, type MaybePromise, type Path, type PathState, type PathStateConfig, type PathValue, type PrivateFieldArrayContext, type PrivateFieldContext, type PrivateFormContext, PublicFormContextKey, type PublicPathState, type RawFormSchema, type ResetFormOpts, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type ValidationOptions$1 as ValidationOptions, type ValidationResult, cleanupNonNestedPath, configure, defineRule, isNotNestedPath, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormContext, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
|
|
1435
|
+
export { type BaseComponentBinds, type BaseFieldProps, type BaseInputBinds, type ComponentBindsConfig, type ComponentFieldBindingObject, type ComponentModelBinds, type ComponentModellessBinds, type DevtoolsPluginFieldState, type DevtoolsPluginFormState, ErrorMessage, Field, FieldArray, type FieldArrayContext, type FieldBindingObject, type FieldContext, FieldContextKey, type FieldEntry, type FieldMeta, type FieldOptions, type FieldPathLookup, type FieldSlotProps, type FieldState, type FieldValidator, type FlattenAndMapPathsValidationResult, type FlattenAndSetPathsType, Form, type FormActions, type FormContext, FormContextKey, type FormErrorBag, type FormErrors, type FormMeta, type FormOptions, type FormSlotProps, type FormState, type FormValidationResult, type GenericObject, type GenericValidateFunction, IS_ABSENT, type InputBindsConfig, type InputType, type InvalidSubmissionContext, type InvalidSubmissionHandler, type IsAny, type IsEqual, type IssueCollection, type LazyComponentBindsConfig, type LazyInputBindsConfig, type Locator, type MapValuesPathsToRefs, type MaybeArray, type MaybePromise, type Path, type PathState, type PathStateConfig, type PathValue, type PrivateFieldArrayContext, type PrivateFieldContext, type PrivateFormContext, PublicFormContextKey, type PublicPathState, type RawFormSchema, type ResetFormOpts, type RuleExpression, type SchemaValidationMode, type SubmissionContext, type SubmissionHandler, type ValidationOptions$1 as ValidationOptions, type ValidationResult, cleanupNonNestedPath, configure, defineRule, getConfig, isNotNestedPath, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormContext, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v5.0.0-beta.
|
|
3
|
-
* (c)
|
|
2
|
+
* vee-validate v5.0.0-beta.1
|
|
3
|
+
* (c) 2026 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
var VeeValidate = (function (exports, vue) {
|
|
@@ -636,9 +636,6 @@ var VeeValidate = (function (exports, vue) {
|
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
function parseInputValue(el) {
|
|
639
|
-
if (el.type === 'number') {
|
|
640
|
-
return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
|
|
641
|
-
}
|
|
642
639
|
if (el.type === 'range') {
|
|
643
640
|
return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
|
|
644
641
|
}
|
|
@@ -1427,6 +1424,7 @@ var VeeValidate = (function (exports, vue) {
|
|
|
1427
1424
|
* Normalizes partial field options to include the full options
|
|
1428
1425
|
*/
|
|
1429
1426
|
function normalizeOptions(opts) {
|
|
1427
|
+
var _a;
|
|
1430
1428
|
const defaults = () => ({
|
|
1431
1429
|
initialValue: undefined,
|
|
1432
1430
|
validateOnMount: false,
|
|
@@ -1438,22 +1436,19 @@ var VeeValidate = (function (exports, vue) {
|
|
|
1438
1436
|
controlled: true,
|
|
1439
1437
|
});
|
|
1440
1438
|
const isVModelSynced = !!(opts === null || opts === void 0 ? void 0 : opts.syncVModel);
|
|
1441
|
-
const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === 'string' ? opts.syncVModel :
|
|
1439
|
+
const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === 'string' ? opts.syncVModel : 'modelValue';
|
|
1442
1440
|
const initialValue = isVModelSynced && !('initialValue' in (opts || {}))
|
|
1443
1441
|
? getCurrentModelValue(vue.getCurrentInstance(), modelPropName)
|
|
1444
1442
|
: opts === null || opts === void 0 ? void 0 : opts.initialValue;
|
|
1445
1443
|
if (!opts) {
|
|
1446
1444
|
return Object.assign(Object.assign({}, defaults()), { initialValue });
|
|
1447
1445
|
}
|
|
1448
|
-
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1451
|
-
const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
|
|
1452
|
-
return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { initialValue, controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue,
|
|
1453
|
-
syncVModel });
|
|
1446
|
+
const controlled = (_a = opts.controlled) !== null && _a !== void 0 ? _a : true;
|
|
1447
|
+
const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
|
|
1448
|
+
return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { initialValue, controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue: opts === null || opts === void 0 ? void 0 : opts.checkedValue, syncVModel });
|
|
1454
1449
|
}
|
|
1455
1450
|
function useFieldWithChecked(name, rules, opts) {
|
|
1456
|
-
const form =
|
|
1451
|
+
const form = (opts === null || opts === void 0 ? void 0 : opts.controlled) ? injectWithSelf(FormContextKey) : undefined;
|
|
1457
1452
|
const checkedValue = opts === null || opts === void 0 ? void 0 : opts.checkedValue;
|
|
1458
1453
|
const uncheckedValue = opts === null || opts === void 0 ? void 0 : opts.uncheckedValue;
|
|
1459
1454
|
function patchCheckedApi(field) {
|
|
@@ -1587,9 +1582,9 @@ var VeeValidate = (function (exports, vue) {
|
|
|
1587
1582
|
type: null,
|
|
1588
1583
|
default: undefined,
|
|
1589
1584
|
},
|
|
1590
|
-
|
|
1585
|
+
controlled: {
|
|
1591
1586
|
type: Boolean,
|
|
1592
|
-
default:
|
|
1587
|
+
default: true,
|
|
1593
1588
|
},
|
|
1594
1589
|
keepValue: {
|
|
1595
1590
|
type: Boolean,
|
|
@@ -1605,7 +1600,7 @@ var VeeValidate = (function (exports, vue) {
|
|
|
1605
1600
|
const { errors, value, errorMessage, validate: validateField, handleChange, handleBlur, setTouched, resetField, handleReset, meta, checked, setErrors, setValue, } = useField(name, rules, {
|
|
1606
1601
|
validateOnMount: props.validateOnMount,
|
|
1607
1602
|
bails: props.bails,
|
|
1608
|
-
|
|
1603
|
+
controlled: props.controlled,
|
|
1609
1604
|
type: ctx.attrs.type,
|
|
1610
1605
|
initialValue: resolveInitialValue(props, ctx),
|
|
1611
1606
|
// Only for checkboxes and radio buttons
|
|
@@ -2152,9 +2147,6 @@ var VeeValidate = (function (exports, vue) {
|
|
|
2152
2147
|
resetForm,
|
|
2153
2148
|
resetField,
|
|
2154
2149
|
handleSubmit,
|
|
2155
|
-
useFieldModel,
|
|
2156
|
-
defineInputBinds,
|
|
2157
|
-
defineComponentBinds: defineComponentBinds,
|
|
2158
2150
|
defineField,
|
|
2159
2151
|
stageInitialValue,
|
|
2160
2152
|
unsetInitialValue,
|
|
@@ -2490,50 +2482,6 @@ var VeeValidate = (function (exports, vue) {
|
|
|
2490
2482
|
const model = createModel(path, () => { var _a, _b, _c; return (_c = (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : (_b = getConfig()) === null || _b === void 0 ? void 0 : _b.validateOnModelUpdate) !== null && _c !== void 0 ? _c : true; });
|
|
2491
2483
|
return [model, props];
|
|
2492
2484
|
}
|
|
2493
|
-
function useFieldModel(pathOrPaths) {
|
|
2494
|
-
if (!Array.isArray(pathOrPaths)) {
|
|
2495
|
-
return createModel(pathOrPaths);
|
|
2496
|
-
}
|
|
2497
|
-
return pathOrPaths.map(p => createModel(p, true));
|
|
2498
|
-
}
|
|
2499
|
-
/**
|
|
2500
|
-
* @deprecated use defineField instead
|
|
2501
|
-
*/
|
|
2502
|
-
function defineInputBinds(path, config) {
|
|
2503
|
-
const [model, props] = defineField(path, config);
|
|
2504
|
-
function onBlur() {
|
|
2505
|
-
props.value.onBlur();
|
|
2506
|
-
}
|
|
2507
|
-
function onInput(e) {
|
|
2508
|
-
const value = normalizeEventValue(e);
|
|
2509
|
-
setFieldValue(vue.toValue(path), value, false);
|
|
2510
|
-
props.value.onInput();
|
|
2511
|
-
}
|
|
2512
|
-
function onChange(e) {
|
|
2513
|
-
const value = normalizeEventValue(e);
|
|
2514
|
-
setFieldValue(vue.toValue(path), value, false);
|
|
2515
|
-
props.value.onChange();
|
|
2516
|
-
}
|
|
2517
|
-
return vue.computed(() => {
|
|
2518
|
-
return Object.assign(Object.assign({}, props.value), { onBlur,
|
|
2519
|
-
onInput,
|
|
2520
|
-
onChange, value: model.value });
|
|
2521
|
-
});
|
|
2522
|
-
}
|
|
2523
|
-
/**
|
|
2524
|
-
* @deprecated use defineField instead
|
|
2525
|
-
*/
|
|
2526
|
-
function defineComponentBinds(path, config) {
|
|
2527
|
-
const [model, props] = defineField(path, config);
|
|
2528
|
-
const pathState = findPathState(vue.toValue(path));
|
|
2529
|
-
function onUpdateModelValue(value) {
|
|
2530
|
-
model.value = value;
|
|
2531
|
-
}
|
|
2532
|
-
return vue.computed(() => {
|
|
2533
|
-
const conf = isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {};
|
|
2534
|
-
return Object.assign({ [conf.model || 'modelValue']: model.value, [`onUpdate:${conf.model || 'modelValue'}`]: onUpdateModelValue }, props.value);
|
|
2535
|
-
});
|
|
2536
|
-
}
|
|
2537
2485
|
const ctx = Object.assign(Object.assign({}, formCtx), { values: vue.readonly(formValues), handleReset: () => resetForm(), submitForm });
|
|
2538
2486
|
vue.provide(PublicFormContextKey, ctx);
|
|
2539
2487
|
return ctx;
|
|
@@ -3411,6 +3359,7 @@ var VeeValidate = (function (exports, vue) {
|
|
|
3411
3359
|
exports.cleanupNonNestedPath = cleanupNonNestedPath;
|
|
3412
3360
|
exports.configure = configure;
|
|
3413
3361
|
exports.defineRule = defineRule;
|
|
3362
|
+
exports.getConfig = getConfig;
|
|
3414
3363
|
exports.isNotNestedPath = isNotNestedPath;
|
|
3415
3364
|
exports.normalizeRules = normalizeRules;
|
|
3416
3365
|
exports.useField = useField;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v5.0.0-beta.
|
|
3
|
-
* (c)
|
|
2
|
+
* vee-validate v5.0.0-beta.1
|
|
3
|
+
* (c) 2026 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
var VeeValidate=function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const l=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function a(e){return Number(e)>=0}function u(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n])&&u(e[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)a(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};function d(e,t,n){"object"==typeof n.value&&(n.value=c(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function c(e){if("object"!=typeof e)return e;var t,n,r,l=0,a=Object.prototype.toString.call(e);if("[object Object]"===a?r=Object.create(e.__proto__||null):"[object Array]"===a?r=Array(e.length):"[object Set]"===a?(r=new Set,e.forEach((function(e){r.add(c(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(c(t),c(e))}))):"[object Date]"===a?r=new Date(+e):"[object RegExp]"===a?r=new RegExp(e.source,e.flags):"[object DataView]"===a?r=new e.constructor(c(e.buffer)):"[object ArrayBuffer]"===a?r=e.slice(0):"Array]"===a.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)d(r,n[l],Object.getOwnPropertyDescriptor(e,n[l]));for(l=0,n=Object.getOwnPropertyNames(e);l<n.length;l++)Object.hasOwnProperty.call(r,t=n[l])&&r[t]===e[t]||d(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}const v=Symbol("vee-validate-form"),f=Symbol("vee-validate-form-context"),p=Symbol("vee-validate-field-instance"),m=Symbol("Default empty value"),h="undefined"!=typeof window;function y(e){return n(e)&&!!e.__locatorRef}function g(e){return l(e)&&"~standard"in e}function V(e){return"checkbox"===e||"radio"===e}function b(e){return/^\[.+\]$/i.test(e)}function O(e){return"SELECT"===e.tagName}function j(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!V(t.type)}function A(e){return F(e)&&e.target&&"submit"in e.target}function F(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function S(e,t){return t in e&&e[t]!==m}function E(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,l;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!E(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!E(r[1],t.get(r[0])))return!1;return!0}if(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();if(e=k(e),t=k(t),(n=(l=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,l[r]))return!1;for(r=n;0!=r--;){var a=l[r];if(!E(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function k(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e)))}function w(e){return!!h&&e instanceof File}function I(e){return b(e)?e.replace(/\[|\]/gi,""):e}function C(e,t,n){if(!e)return n;if(b(t))return e[I(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(l(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function M(e,t,n){if(b(t))return void(e[I(t)]=n);const l=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<l.length;e++){if(e===l.length-1)return void(u[l[e]]=n);l[e]in u&&!r(u[l[e]])||(u[l[e]]=a(l[e+1])?[]:{}),u=u[l[e]]}}function T(e,t){Array.isArray(e)&&a(t)?e.splice(Number(t),1):l(e)&&delete e[t]}function B(e,t){if(b(t))return void delete e[I(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){T(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>C(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?T(u[t-1],n[t-1]):T(e,n[0]));var i}function P(e){return Object.keys(e)}function R(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function x(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function _(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function U(e,t){return l(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 l=e(...r);n=l;const a=await l;return l!==n?a:(n=void 0,t(a,r))}}function D({get:e,set:n}){const r=t.ref(c(e()));return t.watch(e,(e=>{E(e,r.value)||(r.value=c(e))}),{deep:!0}),t.watch(r,(t=>{E(t,e())||n(c(t))}),{deep:!0}),r}function $(e){return Array.isArray(e)?e:e?[e]:[]}function z(e){const n=R(v),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(p);return!l&&(null==r||r.value),r||l}function W(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function q(e){return function(e,t){const n={};for(const r of e){const e=t(r);n[e]||(n[e]={path:e,messages:[]}),"messages"in r?n[e].messages.push(...r.messages):n[e].messages.push(r.message)}return Object.values(n)}(e,(e=>{var t;return e.path&&null!==(t=function(e){if(e.path?.length){let t="";for(const n of e.path){const e="object"==typeof n?n.key:n;if("string"!=typeof e&&"number"!=typeof e)return null;t+=t?`.${e}`:e}return t}return null}(e))&&void 0!==t?t:""}))}function K(e,t,n){return t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default}function L(e){if(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(V(t.type)&&G(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return function(e){return"number"===e.type||"range"===e.type?Number.isNaN(e.valueAsNumber)?e.value:e.valueAsNumber:e.value}(t)}function H(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=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=>{var n;return null!==(n=C(t,e))&&void 0!==n?n: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 l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){const r=e.rules;if(g(r))return async function(e,t){const n=await t.rules["~standard"].validate(e);if(!n.issues)return{value:n.value,errors:[]};const r=[];for(const e of n.issues)e.message&&r.push(e.message);return{errors:r}}(t,Object.assign(Object.assign({},e),{rules:r}));if(n(r)||Array.isArray(r)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},l=Array.isArray(r)?r:[r],a=l.length,u=[];for(let r=0;r<a;r++){const a=l[r],i=await a(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))u.push(...i);else{const e="string"==typeof i?i:re(n);u.push(e)}if(e.bails)return{errors:u}}}return{errors:u}}const l=Object.assign(Object.assign({},e),{rules:H(r)}),a=[],u=Object.keys(l.rules),i=u.length;for(let n=0;n<i;n++){const r=u[n],i=await ne(l,t,{name:r,params:l.rules[r]});if(i.error&&(a.push(i.error),e.bails))return{errors:a}}return{errors:a}}(a,e);return Object.assign(Object.assign({},u),{valid:!u.errors.length})}async function ne(e,t,n){const r=(l=n.name,s[l]);var l;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const a=function(e,t){const n=e=>y(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:a})},i=await r(t,a,u);return"string"==typeof i?{error:i}:{error:i?void 0:re(u)}}function re(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 l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await te(C(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i,source:"schema"}}let ae=0;function ue(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?C(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.setFieldInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return C(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>C(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=ae>=Number.MAX_SAFE_INTEGER?0:++ae,c=function(e,n,r){const l=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!E(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{l.valid=!e.length}),{immediate:!0,flush:"sync"}),l}(r,l,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ie(e,n,r){return V(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.standalone)?void 0:R(v),a=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.toValue(n.value),r=t.toValue(a);return Array.isArray(e)?e.findIndex((e=>E(e,r)))>=0:E(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==l?void 0:l.getPathState(f),m=X(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=x(C(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=x(t.toValue(n.value),h,t.toValue(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:a,uncheckedValue:u,handleChange:s})}return i(oe(e,n,r))}(e,n,r):oe(e,n,r)}function oe(e,r,l){const{initialValue:a,validateOnMount:u,bails:i,type:s,checkedValue:d,label:f,validateOnValueUpdate:h,uncheckedValue:V,controlled:b,keepValueOnUnmount:O,syncVModel:j,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),l="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:(null==e?void 0:e.modelPropName)||"modelValue",a=r&&!("initialValue"in(e||{}))?se(t.getCurrentInstance(),l):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},n()),{initialValue:a});const u="valueProp"in e?e.valueProp:e.checkedValue,i="standalone"in e?!e.standalone:e.controlled,o=(null==e?void 0:e.modelPropName)||(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},n()),e||{}),{initialValue:a,controlled:null==i||i,checkedValue:u,syncVModel:o})}(l),F=b?R(v):void 0,S=A||F,k=t.computed((()=>o(t.toValue(e)))),w=t.computed((()=>{if(t.toValue(null==S?void 0:S.schema))return;const e=t.unref(r);return g(e)||n(e)||Array.isArray(e)?e:H(e)})),{id:I,value:M,initialValue:T,meta:B,setState:x,errors:_,flags:D}=ue(k,{modelValue:a,form:S,bails:i,label:f,type:s,validate:w.value?K:void 0}),$=t.computed((()=>_.value[0]));j&&function({prop:e,value:n,handleChange:r,shouldValidate:l}){const a=t.getCurrentInstance();if(!a||!e)return;const u="string"==typeof e?e:"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{E(e,se(a,u))||a.emit(i,e)})),t.watch((()=>se(a,u)),(e=>{if(e===m&&void 0===n.value)return;const t=e===m?void 0:e;E(t,n.value)||r(t,l())}))}({value:M,prop:j,handleChange:L,shouldValidate:()=>h&&!D.pendingReset});async function z(e){var n,r;if(null==S?void 0:S.validateSchema){const{results:r}=await S.validateSchema(e);return null!==(n=r[t.toValue(k)])&&void 0!==n?n:{valid:!0,errors:[]}}return w.value?te(M.value,w.value,{name:t.toValue(k),label:t.toValue(f),values:null!==(r=null==S?void 0:S.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const W=N((async()=>(B.pending=!0,B.validated=!0,z("validated-only"))),(e=>(D.pendingUnmount[Z.id]||(x({errors:e.errors}),B.pending=!1,B.valid=e.valid),e))),q=N((async()=>z("silent")),(e=>(B.valid=e.valid,e)));function K(e){return"silent"===(null==e?void 0:e.mode)?q():W()}function L(e,t=!0){Q(X(e),t)}function G(e){var t;const n=e&&"value"in e?e.value:T.value;x({value:c(n),initialValue:c(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),B.pending=!1,B.validated=!1,q()}t.onMounted((()=>{if(u)return W();S&&S.validateSchema||q()}));const J=t.getCurrentInstance();function Q(e,t=!0){M.value=J&&j?U(e,J.props.modelModifiers):e;(t?W:q)()}const Y=t.computed({get:()=>M.value,set(e){Q(e,h)}}),Z={id:I,name:k,label:f,value:Y,meta:B,errors:_,errorMessage:$,type:s,checkedValue:d,uncheckedValue:V,bails:i,keepValueOnUnmount:O,resetField:G,handleReset:()=>G(),validate:K,handleChange:L,handleBlur:(e,t=!1)=>{B.touched=!0,t&&W()},setState:x,setTouched:function(e){B.touched=e},setErrors:function(e){x({errors:Array.isArray(e)?e:[e]})},setValue:Q};if(t.provide(p,Z),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{E(e,t)||(B.validated?W():q())}),{deep:!0}),!S)return Z;const ee=t.computed((()=>{const e=w.value;return!e||n(e)||g(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(l=e[n],Array.isArray(l)?l.filter(y):P(l).filter((e=>y(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=C(S.values,t)||S.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(ee,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(B.validated?W():q())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(Z.keepValueOnUnmount))&&void 0!==e?e:t.toValue(S.keepValuesOnUnmount),r=t.toValue(k);if(n||!S||D.pendingUnmount[Z.id])return void(null==S||S.removePathState(r,I));D.pendingUnmount[Z.id]=!0;const l=S.getPathState(r);if(Array.isArray(null==l?void 0:l.id)&&(null==l?void 0:l.multiple)?null==l?void 0:l.id.includes(Z.id):(null==l?void 0:l.id)===Z.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>E(e,t.toValue(Z.checkedValue))));if(e>-1){const t=[...l.value];t.splice(e,1),S.setFieldValue(r,t)}Array.isArray(l.id)&&l.id.splice(l.id.indexOf(Z.id),1)}else S.unsetPathValue(t.toValue(k));S.removePathState(r,I)}})),Z}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 V(t.attrs.type)?S(e,"modelValue")?e.modelValue:void 0:S(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:()=>Z().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:m},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,r){const l=t.toRef(e,"rules"),a=t.toRef(e,"name"),u=t.toRef(e,"label"),i=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:y,meta:g,checked:b,setErrors:O,setValue:A}=ie(a,l,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:r.attrs.type,initialValue:ce(e,r),checkedValue:r.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:e.validateOnModelUpdate,keepValueOnUnmount:o,syncVModel:!0}),F=function(e,t=!0){f(e,t)},S=t.computed((()=>{const{validateOnInput:t,validateOnChange:l,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,l;const{validateOnInput:a,validateOnChange:u,validateOnBlur:i,validateOnModelUpdate:o}=Z();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:a,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:i,validateOnModelUpdate:null!==(l=e.validateOnModelUpdate)&&void 0!==l?l:o}}(e);const i={name:e.name,onBlur:function(e){p(e,a),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){F(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){F(e,l),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>F(e,u)};return i})),E=t.computed((()=>{const t=Object.assign({},S.value);V(r.attrs.type)&&b&&(t.checked=b.value);return j(de(e,r),r.attrs)&&(t.value=d.value),t})),k=t.computed((()=>Object.assign(Object.assign({},S.value),{modelValue:d.value})));function w(){return{field:E.value,componentField:k.value,value:d.value,meta:g,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:F,handleInput:e=>F(e,!1),handleReset:y,handleBlur:S.value.onBlur,setTouched:m,setErrors:O,setValue:A}}return r.expose({value:d,meta:g,errors:s,errorMessage:c,setErrors:O,setTouched:m,setValue:A,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(de(e,r)),l=K(n,r,w);return n?t.h(n,Object.assign(Object.assign({},r.attrs),E.value),l):l}}});let fe=0;const pe=["bails","fieldsCount","id","multiple","type","validate"];function me(e){const n=(null==e?void 0:e.initialValues)||{};return c(Object.assign({},t.toValue(n)))}function he(e){var r;const l=fe++,a=(null==e?void 0:e.name)||"Form";let u=0;const s=t.ref(!1),d=t.ref(!1),p=t.ref(0),m=[],h=t.reactive(me(e)),y=t.ref([]),V=t.ref({}),b=t.ref({}),O=function(e){let n=null,r=[];return function(...l){const a=t.nextTick((()=>{if(n!==a)return;const t=e(...l);r.forEach((e=>e(t))),r=[],n=null}));return n=a,new Promise((e=>r.push(e)))}}((()=>{b.value=y.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function j(e,t){const n=ee(e);if(n){if("string"==typeof e){const t=o(e);V.value[t]&&delete V.value[t]}n.errors=$(t),n.valid=!n.errors.length}else"string"==typeof e&&(V.value[o(e)]=$(t))}function F(e){P(e).forEach((t=>{j(t,e[t])}))}(null==e?void 0:e.initialErrors)&&F(e.initialErrors);const S=t.computed((()=>{const e=y.value.reduce(((e,n)=>(n.errors.length&&(e[t.toValue(n.path)]=n.errors),e)),{});return Object.assign(Object.assign({},V.value),e)})),k=t.computed((()=>P(S.value).reduce(((e,t)=>{const n=S.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),w=t.computed((()=>y.value.reduce(((e,n)=>(e[t.toValue(n.path)]={name:t.toValue(n.path)||"",label:n.label||""},e)),{}))),I=t.computed((()=>y.value.reduce(((e,n)=>{var r;return e[t.toValue(n.path)]=null===(r=n.bails)||void 0===r||r,e}),{}))),T=Object.assign({},(null==e?void 0:e.initialErrors)||{}),R=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:x,originalInitialValues:U,setInitialValues:D}=function(e,n,r){const l=me(r),a=t.ref(l),u=t.ref(c(l));function o(r,l){(null==l?void 0:l.force)?(a.value=c(r),u.value=c(r)):(a.value=i(c(a.value)||{},c(r)),u.value=i(c(u.value)||{},c(r))),(null==l?void 0:l.updateFields)&&e.value.forEach((e=>{if(e.touched)return;const r=C(a.value,t.toValue(e.path));M(n,t.toValue(e.path),c(r))}))}return{initialValues:a,originalInitialValues:u,setInitialValues:o}}(y,h,e),z=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!E(n,t.unref(r))));function i(){const t=e.value;return P(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!P(l.value).length,dirty:u.value})))}(y,h,U,k),K=t.computed((()=>y.value.reduce(((e,n)=>{const r=C(h,t.toValue(n.path));return M(e,t.toValue(n.path),r),e}),{}))),L=null==e?void 0:e.validationSchema;function G(e,n){var r,l;const a=t.computed((()=>C(x.value,t.toValue(e)))),i=b.value[t.toValue(e)],o="checkbox"===(null==n?void 0:n.type)||"radio"===(null==n?void 0:n.type);if(i&&o){i.multiple=!0;const e=u++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const s=t.computed((()=>C(h,t.toValue(e)))),d=t.toValue(e),v=ne.findIndex((e=>e===d));-1!==v&&ne.splice(v,1);const f=u++,p=t.reactive({id:f,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=T[d])||void 0===r?void 0:r.length),initialValue:a,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:s,multiple:!1,__flags:{pendingUnmount:{[f]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(s),t.unref(a))))});return y.value.push(p),b.value[d]=p,O(),k.value[d]&&!T[d]&&t.nextTick((()=>{ge(d,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{O();const n=c(s.value);b.value[e]=p,t.nextTick((()=>{M(h,e,n)}))})),p}const H=_(Oe,5),J=_(Oe,5),Q=N((async e=>await("silent"===e?H():J())),((e,[n])=>{const r=P(ue.errorBag.value),l=[...new Set([...P(e.results),...y.value.map((e=>e.path)),...r])].sort().reduce(((r,l)=>{var a;const u=l,i=ee(u)||function(e){const n=y.value.filter((n=>e.startsWith(t.toValue(n.path))));return n.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(u),o=(null===(a=e.results[u])||void 0===a?void 0:a.errors)||[],s=t.toValue(null==i?void 0:i.path)||u,d=function(e,t){if(!t)return e;return{valid:e.valid&&t.valid,errors:[...e.errors,...t.errors]}}({errors:o,valid:!o.length},r.results[s]);return r.results[s]=d,d.valid||(r.errors[s]=d.errors[0]),i&&V.value[s]&&delete V.value[s],i?(i.valid=d.valid,"silent"===n?r:"validated-only"!==n||i.validated?(j(i,d.errors),r):r):(j(s,o),r)}),{valid:e.valid,results:{},errors:{},source:e.source});return e.values&&(l.values=e.values,l.source=e.source),P(l.results).forEach((e=>{var t;const r=ee(e);r&&"silent"!==n&&("validated-only"!==n||r.validated)&&j(r,null===(t=l.results[e])||void 0===t?void 0:t.errors)})),l}));function Y(e){y.value.forEach(e)}function ee(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?b.value[t]:t}let te,ne=[];function re(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),Y((e=>e.touched=!0)),s.value=!0,p.value++,ye().then((l=>{const a=c(h);if(l.valid&&"function"==typeof t){const n=c(K.value);let u=e?n:a;return l.values&&(u="schema"===l.source?l.values:Object.assign({},u,l.values)),t(u,{evt:r,controlledValues:n,setErrors:F,setFieldError:j,setTouched:ce,setFieldTouched:de,setValues:oe,setFieldValue:ie,resetForm:he,resetField:ve})}l.valid||"function"!=typeof n||n({values:a,evt:r,errors:l.errors,results:l.results})})).then((e=>(s.value=!1,e)),(e=>{throw s.value=!1,e}))}}}const ae=re(!1);ae.withControlled=re(!0);const ue={name:a,formId:l,values:h,controlledValues:K,errorBag:S,errors:k,schema:L,submitCount:p,meta:z,isSubmitting:s,isValidating:d,fieldArrays:m,keepValuesOnUnmount:R,validateSchema:t.unref(L)?Q:void 0,validate:ye,setFieldError:j,validateField:ge,setFieldValue:ie,setValues:oe,setErrors:F,setFieldTouched:de,setTouched:ce,resetForm:he,resetField:ve,handleSubmit:ae,useFieldModel:function(e){if(!Array.isArray(e))return se(e);return e.map((e=>se(e,!0)))},defineInputBinds:function(e,n){const[r,l]=Ae(e,n);function a(){l.value.onBlur()}function u(n){const r=X(n);ie(t.toValue(e),r,!1),l.value.onInput()}function i(n){const r=X(n);ie(t.toValue(e),r,!1),l.value.onChange()}return t.computed((()=>Object.assign(Object.assign({},l.value),{onBlur:a,onInput:u,onChange:i,value:r.value})))},defineComponentBinds:function(e,r){const[l,a]=Ae(e,r),u=ee(t.toValue(e));function i(e){l.value=e}return t.computed((()=>{const e=n(r)?r(W(u,pe)):r||{};return Object.assign({[e.model||"modelValue"]:l.value,[`onUpdate:${e.model||"modelValue"}`]:i},a.value)}))},defineField:Ae,stageInitialValue:function(t,n,r=!1){be(t,n),M(h,t,n),r&&!(null==e?void 0:e.initialValues)&&M(U.value,t,c(n))},unsetInitialValue:Ve,setFieldInitialValue:be,createPathState:G,getPathState:ee,unsetPathValue:function(e){return ne.push(e),te||(te=t.nextTick((()=>{[...ne].sort().reverse().forEach((e=>{B(h,e)})),ne=[],te=null}))),te},removePathState:function(e,n){const r=y.value.findIndex((t=>t.path===e&&(Array.isArray(t.id)?t.id.includes(n):t.id===n))),l=y.value[r];if(-1!==r&&l){if(t.nextTick((()=>{ge(e,{mode:"silent",warn:!1})})),l.multiple&&l.fieldsCount&&l.fieldsCount--,Array.isArray(l.id)){const e=l.id.indexOf(n);e>=0&&l.id.splice(e,1),delete l.__flags.pendingUnmount[n]}(!l.multiple||l.fieldsCount<=0)&&(y.value.splice(r,1),Ve(e),O(),delete b.value[e])}},initialValues:x,getAllPathStates:()=>y.value,destroyPath:function(e){P(b.value).forEach((t=>{t.startsWith(e)&&delete b.value[t]})),y.value=y.value.filter((t=>!t.path.startsWith(e))),t.nextTick((()=>{O()}))},isFieldTouched:function(e){const t=ee(e);if(t)return t.touched;return y.value.filter((t=>t.path.startsWith(e))).some((e=>e.touched))},isFieldDirty:function(e){const t=ee(e);if(t)return t.dirty;return y.value.filter((t=>t.path.startsWith(e))).some((e=>e.dirty))},isFieldValid:function(e){const t=ee(e);if(t)return t.valid;return y.value.filter((t=>t.path.startsWith(e))).every((e=>e.valid))}};function ie(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;ee(l)||G(l),M(h,l,r),n&&ge(l)}function oe(e,t=!0){i(h,e),m.forEach((e=>e&&e.reset())),t&&ye()}function se(e,n){const r=ee(t.toValue(e))||G(e);return t.computed({get:()=>r.value,set(r){var l;ie(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}function de(e,t){const n=ee(e);n&&(n.touched=t)}function ce(e){"boolean"!=typeof e?P(e).forEach((t=>{de(t,!!e[t])})):Y((t=>{t.touched=e}))}function ve(e,n){var r;const l=n&&"value"in n?n.value:C(x.value,e),a=ee(e);a&&(a.__flags.pendingReset=!0),be(e,c(l),!0),ie(e,l,!1),de(e,null!==(r=null==n?void 0:n.touched)&&void 0!==r&&r),j(e,(null==n?void 0:n.errors)||[]),t.nextTick((()=>{a&&(a.__flags.pendingReset=!1)}))}function he(e,n){let r=c((null==e?void 0:e.values)?e.values:U.value);r=(null==n?void 0:n.force)?r:i(U.value,r),D(r,{force:null==n?void 0:n.force}),Y((n=>{var l;n.__flags.pendingReset=!0,n.validated=!1,n.touched=(null===(l=null==e?void 0:e.touched)||void 0===l?void 0:l[t.toValue(n.path)])||!1,ie(t.toValue(n.path),C(r,t.toValue(n.path)),!1),j(t.toValue(n.path),void 0)})),(null==n?void 0:n.force)?function(e,t=!0){P(h).forEach((e=>{delete h[e]})),P(e).forEach((t=>{ie(t,e[t],!1)})),t&&ye()}(r,!1):oe(r,!1),F((null==e?void 0:e.errors)||{}),p.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{ye({mode:"silent"}),Y((e=>{e.__flags.pendingReset=!1}))}))}async function ye(e){const n=(null==e?void 0:e.mode)||"force";if("force"===n&&Y((e=>e.validated=!0)),ue.validateSchema)return ue.validateSchema(n);d.value=!0;const r=await Promise.all(y.value.map((n=>n.validate?n.validate(e).then((e=>({key:t.toValue(n.path),valid:e.valid,errors:e.errors,value:e.value}))):Promise.resolve({key:t.toValue(n.path),valid:!0,errors:[],value:void 0}))));d.value=!1;const l={},a={},u={};for(const e of r)l[e.key]={valid:e.valid,errors:e.errors},e.value&&M(u,e.key,e.value),e.errors.length&&(a[e.key]=e.errors[0]);return{valid:r.every((e=>e.valid)),results:l,errors:a,values:u,source:"fields"}}async function ge(e,t){const n=ee(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),L){const{results:n}=await Q((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function Ve(e){B(x.value,e)}function be(e,t,n=!1){M(x.value,e,c(t)),n&&M(U.value,e,c(t))}async function Oe(){const e=t.unref(L);if(!e)return{valid:!0,results:{},errors:{},source:"none"};d.value=!0;const n=g(e)?await async function(e,t){const n=await e["~standard"].validate(c(t)),r={},l={};if(!n.issues)return{valid:!0,results:{},errors:{},values:n.value,source:"schema"};const a=q(n.issues||[]);for(const e of a){const t=e.messages,n=e.path;r[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!a.length,results:r,errors:l,values:void 0,source:"schema"}}(e,h):await le(e,h,{names:w.value,bailsMap:I.value});return d.value=!1,n}const je=ae(((e,{evt:t})=>{A(t)&&t.target.submit()}));function Ae(e,r){const l=n(r)||null==r?void 0:r.label,a=ee(t.toValue(e))||G(e,{label:l}),u=()=>n(r)?r(W(a,pe)):r||{};function i(){var e;a.touched=!0;(null!==(e=u().validateOnBlur)&&void 0!==e?e:Z().validateOnBlur)&&ge(t.toValue(a.path))}function o(){var e;(null!==(e=u().validateOnInput)&&void 0!==e?e:Z().validateOnInput)&&t.nextTick((()=>{ge(t.toValue(a.path))}))}function s(){var e;(null!==(e=u().validateOnChange)&&void 0!==e?e:Z().validateOnChange)&&t.nextTick((()=>{ge(t.toValue(a.path))}))}const d=t.computed((()=>{const e={onChange:s,onInput:o,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(W(a,pe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(W(a,pe))):e})),c=se(e,(()=>{var e,t,n;return null===(n=null!==(e=u().validateOnModelUpdate)&&void 0!==e?e:null===(t=Z())||void 0===t?void 0:t.validateOnModelUpdate)||void 0===n||n}));return[c,d]}t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&F(e.initialErrors),(null==e?void 0:e.initialTouched)&&ce(e.initialTouched),(null==e?void 0:e.validateOnMount)?ye():ue.validateSchema&&ue.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=ue.validateSchema)||void 0===e||e.call(ue,"validated-only")})),t.provide(v,ue);const Fe=Object.assign(Object.assign({},ue),{values:t.readonly(h),handleReset:()=>he(),submitForm:je});return t.provide(f,Fe),Fe}const ye=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1},name:{type:String,default:"Form"}},setup(e,n){const r=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:a,errorBag:u,values:i,meta:o,isSubmitting:s,isValidating:d,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:V,setFieldError:b,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetField:k}=he({validationSchema:r.value?r:void 0,initialValues:e.initialValues,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l,name:e.name}),w=g(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):w;function C(e){F(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function M(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return c(i)}function B(){return c(o.value)}function P(){return c(a.value)}function R(){return{meta:o.value,errors:a.value,errorBag:u.value,values:i,isSubmitting:s.value,isValidating:d.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:M,handleReset:h,submitForm:w,setErrors:V,setFieldError:b,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:T,getMeta:B,getErrors:P}}return n.expose({setFieldError:b,setErrors:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:B,getErrors:P,values:i,meta:o,errors:a}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=K(r,n,R);if(!r)return l;const a="form"===r?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:I,onReset:C}),l)}}}),ge=ye;function Ve(e){const n=R(v,void 0),l=t.ref([]),a=()=>{},u={fields:l,remove:a,push:a,swap:a,insert:a,update:a,replace:a,prepend:a,move:a};if(!n)return u;if(!t.unref(e))return u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return C(null==n?void 0:n.values,t.toValue(e),[])||[]}function d(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>p(e,t,l.value))),f())}function f(){const e=l.value.length;for(let t=0;t<e;t++){const n=l.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function p(a,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:D({get(){const r=C(null==n?void 0:n.values,t.toValue(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&h(t,e)}}),isFirst:!1,isLast:!1};return d}function m(){f(),null==n||n.validate({mode:"silent"})}function h(r,l){const a=t.toValue(e),u=C(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}d();const y={fields:l,remove:function(r){const a=t.toValue(e),u=C(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.destroyPath(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.toValue(e),o=C(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(p(u)),m()},swap:function(r,a){const u=t.toValue(e),i=C(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,f()},insert:function(r,a){const u=c(a),i=t.toValue(e),o=C(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.toValue(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.toValue(e),o=C(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];M(n.values,i,d),n.stageInitialValue(i+"[0]",u),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.toValue(e),o=C(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.value=d,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.toValue(n.path)===t.toValue(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{E(e,l.value.map((e=>e.value)))||d()})),y}const be=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,t){const{push:n,remove:r,swap:l,insert:a,replace:u,update:i,prepend:o,move:s,fields:d}=Ve((()=>e.name));function c(){return{fields:d.value,push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}}return t.expose({push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}),()=>K(void 0,t,c)}}),Oe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(v,void 0),l=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function a(){return{message:l.value}}return()=>{if(!l.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=K(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});return e.ErrorMessage=Oe,e.Field=ve,e.FieldArray=be,e.FieldContextKey=p,e.Form=ge,e.FormContextKey=v,e.IS_ABSENT=m,e.PublicFormContextKey=f,e.cleanupNonNestedPath=I,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.isNotNestedPath=b,e.normalizeRules=H,e.useField=ie,e.useFieldArray=Ve,e.useFieldError=function(e){const n=R(v),r=e?void 0:t.inject(p);return t.computed((()=>e?null==n?void 0:n.errors.value[t.toValue(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=R(v),r=e?void 0:t.inject(p);return t.computed((()=>e?C(null==n?void 0:n.values,t.toValue(e)):t.toValue(null==r?void 0:r.value)))},e.useForm=he,e.useFormContext=function(){return t.inject(f)},e.useFormErrors=function(){const e=R(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=R(v);return t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=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=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=R(v);return function(t,n){if(e)return e.resetForm(t,n)}},e.useSetFieldError=function(e){const n=R(v),r=e?void 0:t.inject(p);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=R(v),r=e?void 0:t.inject(p);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=R(v),r=e?void 0:t.inject(p);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=R(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=R(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=R(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=R(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=R(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=R(v),r=e?void 0:t.inject(p);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.toValue(e)):Promise.resolve({errors:[],valid:!0})}},e.useValidateForm=function(){const e=R(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0,source:"none"})}},e.validate=te,e.validateObject=le,e}({},Vue);
|
|
6
|
+
var VeeValidate=function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const l=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function a(e){return Number(e)>=0}function u(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function i(e,t){return Object.keys(t).forEach((n=>{if(u(t[n])&&u(e[n]))return e[n]||(e[n]={}),void i(e[n],t[n]);e[n]=t[n]})),e}function o(e){const t=e.split(".");if(!t.length)return"";let n=String(t[0]);for(let e=1;e<t.length;e++)a(t[e])?n+=`[${t[e]}]`:n+=`.${t[e]}`;return n}const s={};function d(e,t,n){"object"==typeof n.value&&(n.value=c(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function c(e){if("object"!=typeof e)return e;var t,n,r,l=0,a=Object.prototype.toString.call(e);if("[object Object]"===a?r=Object.create(e.__proto__||null):"[object Array]"===a?r=Array(e.length):"[object Set]"===a?(r=new Set,e.forEach((function(e){r.add(c(e))}))):"[object Map]"===a?(r=new Map,e.forEach((function(e,t){r.set(c(t),c(e))}))):"[object Date]"===a?r=new Date(+e):"[object RegExp]"===a?r=new RegExp(e.source,e.flags):"[object DataView]"===a?r=new e.constructor(c(e.buffer)):"[object ArrayBuffer]"===a?r=e.slice(0):"Array]"===a.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)d(r,n[l],Object.getOwnPropertyDescriptor(e,n[l]));for(l=0,n=Object.getOwnPropertyNames(e);l<n.length;l++)Object.hasOwnProperty.call(r,t=n[l])&&r[t]===e[t]||d(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}const v=Symbol("vee-validate-form"),f=Symbol("vee-validate-form-context"),p=Symbol("vee-validate-field-instance"),m=Symbol("Default empty value"),h="undefined"!=typeof window;function y(e){return n(e)&&!!e.__locatorRef}function g(e){return l(e)&&"~standard"in e}function b(e){return"checkbox"===e||"radio"===e}function V(e){return/^\[.+\]$/i.test(e)}function O(e){return"SELECT"===e.tagName}function j(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!b(t.type)}function A(e){return F(e)&&e.target&&"submit"in e.target}function F(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function S(e,t){return t in e&&e[t]!==m}function E(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,l;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!E(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!E(r[1],t.get(r[0])))return!1;return!0}if(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();if(e=k(e),t=k(t),(n=(l=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,l[r]))return!1;for(r=n;0!=r--;){var a=l[r];if(!E(e[a],t[a]))return!1}return!0}return e!=e&&t!=t}function k(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e)))}function w(e){return!!h&&e instanceof File}function I(e){return V(e)?e.replace(/\[|\]/gi,""):e}function C(e,t,n){if(!e)return n;if(V(t))return e[I(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(l(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function M(e,t,n){if(V(t))return void(e[I(t)]=n);const l=t.split(/\.|\[(\d+)\]/).filter(Boolean);let u=e;for(let e=0;e<l.length;e++){if(e===l.length-1)return void(u[l[e]]=n);l[e]in u&&!r(u[l[e]])||(u[l[e]]=a(l[e+1])?[]:{}),u=u[l[e]]}}function T(e,t){Array.isArray(e)&&a(t)?e.splice(Number(t),1):l(e)&&delete e[t]}function B(e,t){if(V(t))return void delete e[I(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){T(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>C(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)i=u[t],(Array.isArray(i)?0===i.length:l(i)&&0===Object.keys(i).length)&&(0!==t?T(u[t-1],n[t-1]):T(e,n[0]));var i}function R(e){return Object.keys(e)}function x(e,n=void 0){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function P(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>E(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return E(e,t)?n:t}function _(e,t=0){let n=null,r=[];return function(...l){return n&&clearTimeout(n),n=setTimeout((()=>{const t=e(...l);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function U(e,t){return l(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 l=e(...r);n=l;const a=await l;return l!==n?a:(n=void 0,t(a,r))}}function D({get:e,set:n}){const r=t.ref(c(e()));return t.watch(e,(e=>{E(e,r.value)||(r.value=c(e))}),{deep:!0}),t.watch(r,(t=>{E(t,e())||n(c(t))}),{deep:!0}),r}function $(e){return Array.isArray(e)?e:e?[e]:[]}function z(e){const n=x(v),r=e?t.computed((()=>null==n?void 0:n.getPathState(t.toValue(e)))):void 0,l=e?void 0:t.inject(p);return!l&&(null==r||r.value),r||l}function W(e,t){const n={};for(const r in e)t.includes(r)||(n[r]=e[r]);return n}function q(e){return function(e,t){const n={};for(const r of e){const e=t(r);n[e]||(n[e]={path:e,messages:[]}),"messages"in r?n[e].messages.push(...r.messages):n[e].messages.push(r.message)}return Object.values(n)}(e,(e=>{var t;return e.path&&null!==(t=function(e){if(e.path?.length){let t="";for(const n of e.path){const e="object"==typeof n?n.key:n;if("string"!=typeof e&&"number"!=typeof e)return null;t+=t?`.${e}`:e}return t}return null}(e))&&void 0!==t?t:""}))}function K(e,t,n){return t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default}function L(e){if(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(b(t.type)&&G(t))return L(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(O(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(L);var n;if(O(t)){const e=Array.from(t.options).find((e=>e.selected));return e?L(e):t.value}return function(e){return"range"===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?l(e)&&e._$$isNormalized?e:l(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(l(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=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=>{var n;return null!==(n=C(t,e))&&void 0!==n?n: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 l=null==r?void 0:r.bails,a={name:(null==r?void 0:r.name)||"{field}",rules:t,label:null==r?void 0:r.label,bails:null==l||l,formData:(null==r?void 0:r.values)||{}},u=await async function(e,t){const r=e.rules;if(g(r))return async function(e,t){const n=await t.rules["~standard"].validate(e);if(!n.issues)return{value:n.value,errors:[]};const r=[];for(const e of n.issues)e.message&&r.push(e.message);return{errors:r}}(t,Object.assign(Object.assign({},e),{rules:r}));if(n(r)||Array.isArray(r)){const n={field:e.label||e.name,name:e.name,label:e.label,form:e.formData,value:t},l=Array.isArray(r)?r:[r],a=l.length,u=[];for(let r=0;r<a;r++){const a=l[r],i=await a(t,n);if(!("string"!=typeof i&&!Array.isArray(i)&&i)){if(Array.isArray(i))u.push(...i);else{const e="string"==typeof i?i:re(n);u.push(e)}if(e.bails)return{errors:u}}}return{errors:u}}const l=Object.assign(Object.assign({},e),{rules:H(r)}),a=[],u=Object.keys(l.rules),i=u.length;for(let n=0;n<i;n++){const r=u[n],i=await ne(l,t,{name:r,params:l.rules[r]});if(i.error&&(a.push(i.error),e.bails))return{errors:a}}return{errors:a}}(a,e);return Object.assign(Object.assign({},u),{valid:!u.errors.length})}async function ne(e,t,n){const r=(l=n.name,s[l]);var l;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const a=function(e,t){const n=e=>y(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),u={field:e.label||e.name,name:e.name,label:e.label,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:a})},i=await r(t,a,u);return"string"==typeof i?{error:i}:{error:i?void 0:re(u)}}function re(e){const t=Z().generateMessage;return t?t(e):"Field is invalid"}async function le(e,t,n){const r=R(e).map((async r=>{var l,a,u;const i=null===(l=null==n?void 0:n.names)||void 0===l?void 0:l[r],o=await te(C(t,r),e[r],{name:(null==i?void 0:i.name)||r,label:null==i?void 0:i.label,values:t,bails:null===(u=null===(a=null==n?void 0:n.bailsMap)||void 0===a?void 0:a[r])||void 0===u||u});return Object.assign(Object.assign({},o),{path:r})}));let l=!0;const a=await Promise.all(r),u={},i={};for(const e of a)u[e.path]={valid:e.valid,errors:e.errors},e.valid||(l=!1,i[e.path]=e.errors[0]);return{valid:l,results:u,errors:i,source:"schema"}}let ae=0;function ue(e,n){const{value:r,initialValue:l,setInitialValue:a}=function(e,n,r){const l=t.ref(t.unref(n));function a(){return r?C(r.initialValues.value,t.unref(e),t.unref(l)):t.unref(l)}function u(n){r?r.setFieldInitialValue(t.unref(e),n,!0):l.value=n}const i=t.computed(a);if(!r){return{value:t.ref(a()),initialValue:i,setInitialValue:u}}const o=function(e,n,r,l){if(t.isRef(e))return t.unref(e);if(void 0!==e)return e;return C(n.values,t.unref(l),t.unref(r))}(n,r,i,e);r.stageInitialValue(t.unref(e),o,!0);const s=t.computed({get:()=>C(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n,!1)}});return{value:s,initialValue:i,setInitialValue:u}}(e,n.modelValue,n.form);if(!n.form){const{errors:o,setErrors:s}=function(){const e=t.ref([]);return{errors:e,setErrors:t=>{e.value=$(t)}}}(),d=ae>=Number.MAX_SAFE_INTEGER?0:++ae,c=function(e,n,r){const l=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!E(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{l.valid=!e.length}),{immediate:!0,flush:"sync"}),l}(r,l,o);function v(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&s(e.errors),"touched"in e&&(c.touched=null!==(t=e.touched)&&void 0!==t?t:c.touched),"initialValue"in e&&a(e.initialValue)}return{id:d,path:e,value:r,initialValue:l,meta:c,flags:{pendingUnmount:{[d]:!1},pendingReset:!1},errors:o,setState:v}}const u=n.form.createPathState(e,{bails:n.bails,label:n.label,type:n.type,validate:n.validate}),i=t.computed((()=>u.errors));return{id:Array.isArray(u.id)?u.id[u.id.length-1]:u.id,path:e,value:r,errors:i,meta:u,initialValue:l,flags:u.__flags,setState:function(l){var u,i,o;"value"in l&&(r.value=l.value),"errors"in l&&(null===(u=n.form)||void 0===u||u.setFieldError(t.unref(e),l.errors)),"touched"in l&&(null===(i=n.form)||void 0===i||i.setFieldTouched(t.unref(e),null!==(o=l.touched)&&void 0!==o&&o)),"initialValue"in l&&a(l.initialValue)}}}function ie(e,n,r){return b(null==r?void 0:r.type)?function(e,n,r){const l=(null==r?void 0:r.controlled)?x(v):void 0,a=null==r?void 0:r.checkedValue,u=null==r?void 0:r.uncheckedValue;function i(n){const i=n.handleChange,o=t.computed((()=>{const e=t.toValue(n.value),r=t.toValue(a);return Array.isArray(e)?e.findIndex((e=>E(e,r)))>=0:E(r,e)}));function s(s,d=!0){var c,v;if(o.value===(null===(c=null==s?void 0:s.target)||void 0===c?void 0:c.checked))return void(d&&n.validate());const f=t.toValue(e),p=null==l?void 0:l.getPathState(f),m=X(s);let h=null!==(v=t.toValue(a))&&void 0!==v?v:m;l&&(null==p?void 0:p.multiple)&&"checkbox"===p.type?h=P(C(l.values,f)||[],h,void 0):"checkbox"===(null==r?void 0:r.type)&&(h=P(t.toValue(n.value),h,t.toValue(u))),i(h,d)}return Object.assign(Object.assign({},n),{checked:o,checkedValue:a,uncheckedValue:u,handleChange:s})}return i(oe(e,n,r))}(e,n,r):oe(e,n,r)}function oe(e,r,l){const{initialValue:a,validateOnMount:u,bails:i,type:s,checkedValue:d,label:f,validateOnValueUpdate:h,uncheckedValue:b,controlled:V,keepValueOnUnmount:O,syncVModel:j,form:A}=function(e){var n;const r=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:void 0,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,syncVModel:!1,controlled:!0}),l=!!(null==e?void 0:e.syncVModel),a="string"==typeof(null==e?void 0:e.syncVModel)?e.syncVModel:"modelValue",u=l&&!("initialValue"in(e||{}))?se(t.getCurrentInstance(),a):null==e?void 0:e.initialValue;if(!e)return Object.assign(Object.assign({},r()),{initialValue:u});const i=null===(n=e.controlled)||void 0===n||n,o=(null==e?void 0:e.syncVModel)||!1;return Object.assign(Object.assign(Object.assign({},r()),e||{}),{initialValue:u,controlled:null==i||i,checkedValue:null==e?void 0:e.checkedValue,syncVModel:o})}(l),F=V?x(v):void 0,S=A||F,k=t.computed((()=>o(t.toValue(e)))),w=t.computed((()=>{if(t.toValue(null==S?void 0:S.schema))return;const e=t.unref(r);return g(e)||n(e)||Array.isArray(e)?e:H(e)})),{id:I,value:M,initialValue:T,meta:B,setState:P,errors:_,flags:D}=ue(k,{modelValue:a,form:S,bails:i,label:f,type:s,validate:w.value?K:void 0}),$=t.computed((()=>_.value[0]));j&&function({prop:e,value:n,handleChange:r,shouldValidate:l}){const a=t.getCurrentInstance();if(!a||!e)return;const u="string"==typeof e?e:"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{E(e,se(a,u))||a.emit(i,e)})),t.watch((()=>se(a,u)),(e=>{if(e===m&&void 0===n.value)return;const t=e===m?void 0:e;E(t,n.value)||r(t,l())}))}({value:M,prop:j,handleChange:L,shouldValidate:()=>h&&!D.pendingReset});async function z(e){var n,r;if(null==S?void 0:S.validateSchema){const{results:r}=await S.validateSchema(e);return null!==(n=r[t.toValue(k)])&&void 0!==n?n:{valid:!0,errors:[]}}return w.value?te(M.value,w.value,{name:t.toValue(k),label:t.toValue(f),values:null!==(r=null==S?void 0:S.values)&&void 0!==r?r:{},bails:i}):{valid:!0,errors:[]}}const W=N((async()=>(B.pending=!0,B.validated=!0,z("validated-only"))),(e=>(D.pendingUnmount[Z.id]||(P({errors:e.errors}),B.pending=!1,B.valid=e.valid),e))),q=N((async()=>z("silent")),(e=>(B.valid=e.valid,e)));function K(e){return"silent"===(null==e?void 0:e.mode)?q():W()}function L(e,t=!0){Q(X(e),t)}function G(e){var t;const n=e&&"value"in e?e.value:T.value;P({value:c(n),initialValue:c(n),touched:null!==(t=null==e?void 0:e.touched)&&void 0!==t&&t,errors:(null==e?void 0:e.errors)||[]}),B.pending=!1,B.validated=!1,q()}t.onMounted((()=>{if(u)return W();S&&S.validateSchema||q()}));const J=t.getCurrentInstance();function Q(e,t=!0){M.value=J&&j?U(e,J.props.modelModifiers):e;(t?W:q)()}const Y=t.computed({get:()=>M.value,set(e){Q(e,h)}}),Z={id:I,name:k,label:f,value:Y,meta:B,errors:_,errorMessage:$,type:s,checkedValue:d,uncheckedValue:b,bails:i,keepValueOnUnmount:O,resetField:G,handleReset:()=>G(),validate:K,handleChange:L,handleBlur:(e,t=!1)=>{B.touched=!0,t&&W()},setState:P,setTouched:function(e){B.touched=e},setErrors:function(e){P({errors:Array.isArray(e)?e:[e]})},setValue:Q};if(t.provide(p,Z),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{E(e,t)||(B.validated?W():q())}),{deep:!0}),!S)return Z;const ee=t.computed((()=>{const e=w.value;return!e||n(e)||g(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(l=e[n],Array.isArray(l)?l.filter(y):R(l).filter((e=>y(l[e]))).map((e=>l[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=C(S.values,t)||S.values[t];return void 0!==n&&(e[t]=n),e}),{});var l;return Object.assign(t,r),t}),{})}));return t.watch(ee,((e,t)=>{if(!Object.keys(e).length)return;!E(e,t)&&(B.validated?W():q())})),t.onBeforeUnmount((()=>{var e;const n=null!==(e=t.toValue(Z.keepValueOnUnmount))&&void 0!==e?e:t.toValue(S.keepValuesOnUnmount),r=t.toValue(k);if(n||!S||D.pendingUnmount[Z.id])return void(null==S||S.removePathState(r,I));D.pendingUnmount[Z.id]=!0;const l=S.getPathState(r);if(Array.isArray(null==l?void 0:l.id)&&(null==l?void 0:l.multiple)?null==l?void 0:l.id.includes(Z.id):(null==l?void 0:l.id)===Z.id){if((null==l?void 0:l.multiple)&&Array.isArray(l.value)){const e=l.value.findIndex((e=>E(e,t.toValue(Z.checkedValue))));if(e>-1){const t=[...l.value];t.splice(e,1),S.setFieldValue(r,t)}Array.isArray(l.id)&&l.id.splice(l.id.indexOf(Z.id),1)}else S.unsetPathValue(t.toValue(k));S.removePathState(r,I)}})),Z}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 b(t.attrs.type)?S(e,"modelValue")?e.modelValue:void 0:S(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:()=>Z().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:m},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},controlled:{type:Boolean,default:!0},keepValue:{type:Boolean,default:void 0}},setup(e,r){const l=t.toRef(e,"rules"),a=t.toRef(e,"name"),u=t.toRef(e,"label"),i=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:s,value:d,errorMessage:c,validate:v,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:y,meta:g,checked:V,setErrors:O,setValue:A}=ie(a,l,{validateOnMount:e.validateOnMount,bails:e.bails,controlled:e.controlled,type:r.attrs.type,initialValue:ce(e,r),checkedValue:r.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:e.validateOnModelUpdate,keepValueOnUnmount:o,syncVModel:!0}),F=function(e,t=!0){f(e,t)},S=t.computed((()=>{const{validateOnInput:t,validateOnChange:l,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,l;const{validateOnInput:a,validateOnChange:u,validateOnBlur:i,validateOnModelUpdate:o}=Z();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:a,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:u,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:i,validateOnModelUpdate:null!==(l=e.validateOnModelUpdate)&&void 0!==l?l:o}}(e);const i={name:e.name,onBlur:function(e){p(e,a),n(r.attrs.onBlur)&&r.attrs.onBlur(e)},onInput:function(e){F(e,t),n(r.attrs.onInput)&&r.attrs.onInput(e)},onChange:function(e){F(e,l),n(r.attrs.onChange)&&r.attrs.onChange(e)},"onUpdate:modelValue":e=>F(e,u)};return i})),E=t.computed((()=>{const t=Object.assign({},S.value);b(r.attrs.type)&&V&&(t.checked=V.value);return j(de(e,r),r.attrs)&&(t.value=d.value),t})),k=t.computed((()=>Object.assign(Object.assign({},S.value),{modelValue:d.value})));function w(){return{field:E.value,componentField:k.value,value:d.value,meta:g,errors:s.value,errorMessage:c.value,validate:v,resetField:h,handleChange:F,handleInput:e=>F(e,!1),handleReset:y,handleBlur:S.value.onBlur,setTouched:m,setErrors:O,setValue:A}}return r.expose({value:d,meta:g,errors:s,errorMessage:c,setErrors:O,setTouched:m,setValue:A,reset:h,validate:v,handleChange:f}),()=>{const n=t.resolveDynamicComponent(de(e,r)),l=K(n,r,w);return n?t.h(n,Object.assign(Object.assign({},r.attrs),E.value),l):l}}});let fe=0;const pe=["bails","fieldsCount","id","multiple","type","validate"];function me(e){const n=(null==e?void 0:e.initialValues)||{};return c(Object.assign({},t.toValue(n)))}function he(e){var r;const l=fe++,a=(null==e?void 0:e.name)||"Form";let u=0;const s=t.ref(!1),d=t.ref(!1),p=t.ref(0),m=[],h=t.reactive(me(e)),y=t.ref([]),b=t.ref({}),V=t.ref({}),O=function(e){let n=null,r=[];return function(...l){const a=t.nextTick((()=>{if(n!==a)return;const t=e(...l);r.forEach((e=>e(t))),r=[],n=null}));return n=a,new Promise((e=>r.push(e)))}}((()=>{V.value=y.value.reduce(((e,n)=>(e[o(t.toValue(n.path))]=n,e)),{})}));function j(e,t){const n=Y(e);if(n){if("string"==typeof e){const t=o(e);b.value[t]&&delete b.value[t]}n.errors=$(t),n.valid=!n.errors.length}else"string"==typeof e&&(b.value[o(e)]=$(t))}function F(e){R(e).forEach((t=>{j(t,e[t])}))}(null==e?void 0:e.initialErrors)&&F(e.initialErrors);const S=t.computed((()=>{const e=y.value.reduce(((e,n)=>(n.errors.length&&(e[t.toValue(n.path)]=n.errors),e)),{});return Object.assign(Object.assign({},b.value),e)})),k=t.computed((()=>R(S.value).reduce(((e,t)=>{const n=S.value[t];return(null==n?void 0:n.length)&&(e[t]=n[0]),e}),{}))),w=t.computed((()=>y.value.reduce(((e,n)=>(e[t.toValue(n.path)]={name:t.toValue(n.path)||"",label:n.label||""},e)),{}))),I=t.computed((()=>y.value.reduce(((e,n)=>{var r;return e[t.toValue(n.path)]=null===(r=n.bails)||void 0===r||r,e}),{}))),T=Object.assign({},(null==e?void 0:e.initialErrors)||{}),x=null!==(r=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==r&&r,{initialValues:P,originalInitialValues:U,setInitialValues:D}=function(e,n,r){const l=me(r),a=t.ref(l),u=t.ref(c(l));function o(r,l){(null==l?void 0:l.force)?(a.value=c(r),u.value=c(r)):(a.value=i(c(a.value)||{},c(r)),u.value=i(c(u.value)||{},c(r))),(null==l?void 0:l.updateFields)&&e.value.forEach((e=>{if(e.touched)return;const r=C(a.value,t.toValue(e.path));M(n,t.toValue(e.path),c(r))}))}return{initialValues:a,originalInitialValues:u,setInitialValues:o}}(y,h,e),z=function(e,n,r,l){const a={touched:"some",pending:"some",valid:"every"},u=t.computed((()=>!E(n,t.unref(r))));function i(){const t=e.value;return R(a).reduce(((e,n)=>{const r=a[n];return e[n]=t[r]((e=>e[n])),e}),{})}const o=t.reactive(i());return t.watchEffect((()=>{const e=i();o.touched=e.touched,o.valid=e.valid,o.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},o),{valid:o.valid&&!R(l.value).length,dirty:u.value})))}(y,h,U,k),K=t.computed((()=>y.value.reduce(((e,n)=>{const r=C(h,t.toValue(n.path));return M(e,t.toValue(n.path),r),e}),{}))),L=null==e?void 0:e.validationSchema;function G(e,n){var r,l;const a=t.computed((()=>C(P.value,t.toValue(e)))),i=V.value[t.toValue(e)],o="checkbox"===(null==n?void 0:n.type)||"radio"===(null==n?void 0:n.type);if(i&&o){i.multiple=!0;const e=u++;return Array.isArray(i.id)?i.id.push(e):i.id=[i.id,e],i.fieldsCount++,i.__flags.pendingUnmount[e]=!1,i}const s=t.computed((()=>C(h,t.toValue(e)))),d=t.toValue(e),v=te.findIndex((e=>e===d));-1!==v&&te.splice(v,1);const f=u++,p=t.reactive({id:f,path:e,touched:!1,pending:!1,valid:!0,validated:!!(null===(r=T[d])||void 0===r?void 0:r.length),initialValue:a,errors:t.shallowRef([]),bails:null!==(l=null==n?void 0:n.bails)&&void 0!==l&&l,label:null==n?void 0:n.label,type:(null==n?void 0:n.type)||"default",value:s,multiple:!1,__flags:{pendingUnmount:{[f]:!1},pendingReset:!1},fieldsCount:1,validate:null==n?void 0:n.validate,dirty:t.computed((()=>!E(t.unref(s),t.unref(a))))});return y.value.push(p),V.value[d]=p,O(),k.value[d]&&!T[d]&&t.nextTick((()=>{he(d,{mode:"silent"})})),t.isRef(e)&&t.watch(e,(e=>{O();const n=c(s.value);V.value[e]=p,t.nextTick((()=>{M(h,e,n)}))})),p}const X=_(be,5),H=_(be,5),J=N((async e=>await("silent"===e?X():H())),((e,[n])=>{const r=R(ae.errorBag.value),l=[...new Set([...R(e.results),...y.value.map((e=>e.path)),...r])].sort().reduce(((r,l)=>{var a;const u=l,i=Y(u)||function(e){const n=y.value.filter((n=>e.startsWith(t.toValue(n.path))));return n.reduce(((e,t)=>e?t.path.length>e.path.length?t:e:t),void 0)}(u),o=(null===(a=e.results[u])||void 0===a?void 0:a.errors)||[],s=t.toValue(null==i?void 0:i.path)||u,d=function(e,t){if(!t)return e;return{valid:e.valid&&t.valid,errors:[...e.errors,...t.errors]}}({errors:o,valid:!o.length},r.results[s]);return r.results[s]=d,d.valid||(r.errors[s]=d.errors[0]),i&&b.value[s]&&delete b.value[s],i?(i.valid=d.valid,"silent"===n?r:"validated-only"!==n||i.validated?(j(i,d.errors),r):r):(j(s,o),r)}),{valid:e.valid,results:{},errors:{},source:e.source});return e.values&&(l.values=e.values,l.source=e.source),R(l.results).forEach((e=>{var t;const r=Y(e);r&&"silent"!==n&&("validated-only"!==n||r.validated)&&j(r,null===(t=l.results[e])||void 0===t?void 0:t.errors)})),l}));function Q(e){y.value.forEach(e)}function Y(e){const t="string"==typeof e?o(e):e;return"string"==typeof t?V.value[t]:t}let ee,te=[];function ne(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),Q((e=>e.touched=!0)),s.value=!0,p.value++,ve().then((l=>{const a=c(h);if(l.valid&&"function"==typeof t){const n=c(K.value);let u=e?n:a;return l.values&&(u="schema"===l.source?l.values:Object.assign({},u,l.values)),t(u,{evt:r,controlledValues:n,setErrors:F,setFieldError:j,setTouched:se,setFieldTouched:oe,setValues:ie,setFieldValue:ue,resetForm:ce,resetField:de})}l.valid||"function"!=typeof n||n({values:a,evt:r,errors:l.errors,results:l.results})})).then((e=>(s.value=!1,e)),(e=>{throw s.value=!1,e}))}}}const re=ne(!1);re.withControlled=ne(!0);const ae={name:a,formId:l,values:h,controlledValues:K,errorBag:S,errors:k,schema:L,submitCount:p,meta:z,isSubmitting:s,isValidating:d,fieldArrays:m,keepValuesOnUnmount:x,validateSchema:t.unref(L)?J:void 0,validate:ve,setFieldError:j,validateField:he,setFieldValue:ue,setValues:ie,setErrors:F,setFieldTouched:oe,setTouched:se,resetForm:ce,resetField:de,handleSubmit:re,defineField:function(e,r){const l=n(r)||null==r?void 0:r.label,a=Y(t.toValue(e))||G(e,{label:l}),u=()=>n(r)?r(W(a,pe)):r||{};function i(){var e;a.touched=!0;(null!==(e=u().validateOnBlur)&&void 0!==e?e:Z().validateOnBlur)&&he(t.toValue(a.path))}function o(){var e;(null!==(e=u().validateOnInput)&&void 0!==e?e:Z().validateOnInput)&&t.nextTick((()=>{he(t.toValue(a.path))}))}function s(){var e;(null!==(e=u().validateOnChange)&&void 0!==e?e:Z().validateOnChange)&&t.nextTick((()=>{he(t.toValue(a.path))}))}const d=t.computed((()=>{const e={onChange:s,onInput:o,onBlur:i};return n(r)?Object.assign(Object.assign({},e),r(W(a,pe)).props||{}):(null==r?void 0:r.props)?Object.assign(Object.assign({},e),r.props(W(a,pe))):e})),c=function(e,n){const r=Y(t.toValue(e))||G(e);return t.computed({get:()=>r.value,set(r){var l;ue(t.toValue(e),r,null!==(l=t.toValue(n))&&void 0!==l&&l)}})}(e,(()=>{var e,t,n;return null===(n=null!==(e=u().validateOnModelUpdate)&&void 0!==e?e:null===(t=Z())||void 0===t?void 0:t.validateOnModelUpdate)||void 0===n||n}));return[c,d]},stageInitialValue:function(t,n,r=!1){ge(t,n),M(h,t,n),r&&!(null==e?void 0:e.initialValues)&&M(U.value,t,c(n))},unsetInitialValue:ye,setFieldInitialValue:ge,createPathState:G,getPathState:Y,unsetPathValue:function(e){return te.push(e),ee||(ee=t.nextTick((()=>{[...te].sort().reverse().forEach((e=>{B(h,e)})),te=[],ee=null}))),ee},removePathState:function(e,n){const r=y.value.findIndex((t=>t.path===e&&(Array.isArray(t.id)?t.id.includes(n):t.id===n))),l=y.value[r];if(-1!==r&&l){if(t.nextTick((()=>{he(e,{mode:"silent",warn:!1})})),l.multiple&&l.fieldsCount&&l.fieldsCount--,Array.isArray(l.id)){const e=l.id.indexOf(n);e>=0&&l.id.splice(e,1),delete l.__flags.pendingUnmount[n]}(!l.multiple||l.fieldsCount<=0)&&(y.value.splice(r,1),ye(e),O(),delete V.value[e])}},initialValues:P,getAllPathStates:()=>y.value,destroyPath:function(e){R(V.value).forEach((t=>{t.startsWith(e)&&delete V.value[t]})),y.value=y.value.filter((t=>!t.path.startsWith(e))),t.nextTick((()=>{O()}))},isFieldTouched:function(e){const t=Y(e);if(t)return t.touched;return y.value.filter((t=>t.path.startsWith(e))).some((e=>e.touched))},isFieldDirty:function(e){const t=Y(e);if(t)return t.dirty;return y.value.filter((t=>t.path.startsWith(e))).some((e=>e.dirty))},isFieldValid:function(e){const t=Y(e);if(t)return t.valid;return y.value.filter((t=>t.path.startsWith(e))).every((e=>e.valid))}};function ue(e,t,n=!0){const r=c(t),l="string"==typeof e?e:e.path;Y(l)||G(l),M(h,l,r),n&&he(l)}function ie(e,t=!0){i(h,e),m.forEach((e=>e&&e.reset())),t&&ve()}function oe(e,t){const n=Y(e);n&&(n.touched=t)}function se(e){"boolean"!=typeof e?R(e).forEach((t=>{oe(t,!!e[t])})):Q((t=>{t.touched=e}))}function de(e,n){var r;const l=n&&"value"in n?n.value:C(P.value,e),a=Y(e);a&&(a.__flags.pendingReset=!0),ge(e,c(l),!0),ue(e,l,!1),oe(e,null!==(r=null==n?void 0:n.touched)&&void 0!==r&&r),j(e,(null==n?void 0:n.errors)||[]),t.nextTick((()=>{a&&(a.__flags.pendingReset=!1)}))}function ce(e,n){let r=c((null==e?void 0:e.values)?e.values:U.value);r=(null==n?void 0:n.force)?r:i(U.value,r),D(r,{force:null==n?void 0:n.force}),Q((n=>{var l;n.__flags.pendingReset=!0,n.validated=!1,n.touched=(null===(l=null==e?void 0:e.touched)||void 0===l?void 0:l[t.toValue(n.path)])||!1,ue(t.toValue(n.path),C(r,t.toValue(n.path)),!1),j(t.toValue(n.path),void 0)})),(null==n?void 0:n.force)?function(e,t=!0){R(h).forEach((e=>{delete h[e]})),R(e).forEach((t=>{ue(t,e[t],!1)})),t&&ve()}(r,!1):ie(r,!1),F((null==e?void 0:e.errors)||{}),p.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{ve({mode:"silent"}),Q((e=>{e.__flags.pendingReset=!1}))}))}async function ve(e){const n=(null==e?void 0:e.mode)||"force";if("force"===n&&Q((e=>e.validated=!0)),ae.validateSchema)return ae.validateSchema(n);d.value=!0;const r=await Promise.all(y.value.map((n=>n.validate?n.validate(e).then((e=>({key:t.toValue(n.path),valid:e.valid,errors:e.errors,value:e.value}))):Promise.resolve({key:t.toValue(n.path),valid:!0,errors:[],value:void 0}))));d.value=!1;const l={},a={},u={};for(const e of r)l[e.key]={valid:e.valid,errors:e.errors},e.value&&M(u,e.key,e.value),e.errors.length&&(a[e.key]=e.errors[0]);return{valid:r.every((e=>e.valid)),results:l,errors:a,values:u,source:"fields"}}async function he(e,t){const n=Y(e);if(n&&"silent"!==(null==t?void 0:t.mode)&&(n.validated=!0),L){const{results:n}=await J((null==t?void 0:t.mode)||"validated-only");return n[e]||{errors:[],valid:!0}}return(null==n?void 0:n.validate)?n.validate(t):(!n&&(null==t?void 0:t.warn),Promise.resolve({errors:[],valid:!0}))}function ye(e){B(P.value,e)}function ge(e,t,n=!1){M(P.value,e,c(t)),n&&M(U.value,e,c(t))}async function be(){const e=t.unref(L);if(!e)return{valid:!0,results:{},errors:{},source:"none"};d.value=!0;const n=g(e)?await async function(e,t){const n=await e["~standard"].validate(c(t)),r={},l={};if(!n.issues)return{valid:!0,results:{},errors:{},values:n.value,source:"schema"};const a=q(n.issues||[]);for(const e of a){const t=e.messages,n=e.path;r[n]={valid:!t.length,errors:t},t.length&&(l[n]=t[0])}return{valid:!a.length,results:r,errors:l,values:void 0,source:"schema"}}(e,h):await le(e,h,{names:w.value,bailsMap:I.value});return d.value=!1,n}const Ve=re(((e,{evt:t})=>{A(t)&&t.target.submit()}));t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&F(e.initialErrors),(null==e?void 0:e.initialTouched)&&se(e.initialTouched),(null==e?void 0:e.validateOnMount)?ve():ae.validateSchema&&ae.validateSchema("silent")})),t.isRef(L)&&t.watch(L,(()=>{var e;null===(e=ae.validateSchema)||void 0===e||e.call(ae,"validated-only")})),t.provide(v,ae);const Oe=Object.assign(Object.assign({},ae),{values:t.readonly(h),handleReset:()=>ce(),submitForm:Ve});return t.provide(f,Oe),Oe}const ye=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:null,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1},name:{type:String,default:"Form"}},setup(e,n){const r=t.toRef(e,"validationSchema"),l=t.toRef(e,"keepValues"),{errors:a,errorBag:u,values:i,meta:o,isSubmitting:s,isValidating:d,submitCount:v,controlledValues:f,validate:p,validateField:m,handleReset:h,resetForm:y,handleSubmit:g,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetField:k}=he({validationSchema:r.value?r:void 0,initialValues:e.initialValues,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:l,name:e.name}),w=g(((e,{evt:t})=>{A(t)&&t.target.submit()}),e.onInvalidSubmit),I=e.onSubmit?g(e.onSubmit,e.onInvalidSubmit):w;function C(e){F(e)&&e.preventDefault(),h(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function M(t,n){return g("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function T(){return c(i)}function B(){return c(o.value)}function R(){return c(a.value)}function x(){return{meta:o.value,errors:a.value,errorBag:u.value,values:i,isSubmitting:s.value,isValidating:d.value,submitCount:v.value,controlledValues:f.value,validate:p,validateField:m,handleSubmit:M,handleReset:h,submitForm:w,setErrors:b,setFieldError:V,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,resetField:k,getValues:T,getMeta:B,getErrors:R}}return n.expose({setFieldError:V,setErrors:b,setFieldValue:O,setValues:j,setFieldTouched:S,setTouched:E,resetForm:y,validate:p,validateField:m,resetField:k,getValues:T,getMeta:B,getErrors:R,values:i,meta:o,errors:a}),function(){const r="form"===e.as?e.as:e.as?t.resolveDynamicComponent(e.as):null,l=K(r,n,x);if(!r)return l;const a="form"===r?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},a),n.attrs),{onSubmit:I,onReset:C}),l)}}}),ge=ye;function be(e){const n=x(v,void 0),l=t.ref([]),a=()=>{},u={fields:l,remove:a,push:a,swap:a,insert:a,update:a,replace:a,prepend:a,move:a};if(!n)return u;if(!t.unref(e))return u;const i=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(i)return i;let o=0;function s(){return C(null==n?void 0:n.values,t.toValue(e),[])||[]}function d(){const e=s();Array.isArray(e)&&(l.value=e.map(((e,t)=>p(e,t,l.value))),f())}function f(){const e=l.value.length;for(let t=0;t<e;t++){const n=l.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function p(a,u,i){if(i&&!r(u)&&i[u])return i[u];const s=o++,d={key:s,value:D({get(){const r=C(null==n?void 0:n.values,t.toValue(e),[])||[],u=l.value.findIndex((e=>e.key===s));return-1===u?a:r[u]},set(e){const t=l.value.findIndex((e=>e.key===s));-1!==t&&h(t,e)}}),isFirst:!1,isLast:!1};return d}function m(){f(),null==n||n.validate({mode:"silent"})}function h(r,l){const a=t.toValue(e),u=C(null==n?void 0:n.values,a);!Array.isArray(u)||u.length-1<r||(M(n.values,`${a}[${r}]`,l),null==n||n.validate({mode:"validated-only"}))}d();const y={fields:l,remove:function(r){const a=t.toValue(e),u=C(null==n?void 0:n.values,a);if(!u||!Array.isArray(u))return;const i=[...u];i.splice(r,1);const o=a+`[${r}]`;n.destroyPath(o),n.unsetInitialValue(o),M(n.values,a,i),l.value.splice(r,1),m()},push:function(a){const u=c(a),i=t.toValue(e),o=C(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[...s];d.push(u),n.stageInitialValue(i+`[${d.length-1}]`,u),M(n.values,i,d),l.value.push(p(u)),m()},swap:function(r,a){const u=t.toValue(e),i=C(null==n?void 0:n.values,u);if(!Array.isArray(i)||!(r in i)||!(a in i))return;const o=[...i],s=[...l.value],d=o[r];o[r]=o[a],o[a]=d;const c=s[r];s[r]=s[a],s[a]=c,M(n.values,u,o),l.value=s,f()},insert:function(r,a){const u=c(a),i=t.toValue(e),o=C(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const s=[...o],d=[...l.value];s.splice(r,0,u),d.splice(r,0,p(u)),M(n.values,i,s),l.value=d,m()},update:h,replace:function(r){const l=t.toValue(e);n.stageInitialValue(l,r),M(n.values,l,r),d(),m()},prepend:function(a){const u=c(a),i=t.toValue(e),o=C(null==n?void 0:n.values,i),s=r(o)?[]:o;if(!Array.isArray(s))return;const d=[u,...s];M(n.values,i,d),n.stageInitialValue(i+"[0]",u),l.value.unshift(p(u)),m()},move:function(a,u){const i=t.toValue(e),o=C(null==n?void 0:n.values,i),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(a in o)||!(u in o))return;const d=[...l.value],c=d[a];d.splice(a,1),d.splice(u,0,c);const v=s[a];s.splice(a,1),s.splice(u,0,v),M(n.values,i,s),l.value=d,m()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},y)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.toValue(n.path)===t.toValue(e)));r>=0&&n.fieldArrays.splice(r,1)})),t.watch(s,(e=>{E(e,l.value.map((e=>e.value)))||d()})),y}const Ve=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,t){const{push:n,remove:r,swap:l,insert:a,replace:u,update:i,prepend:o,move:s,fields:d}=be((()=>e.name));function c(){return{fields:d.value,push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}}return t.expose({push:n,remove:r,swap:l,insert:a,update:i,replace:u,prepend:o,move:s}),()=>K(void 0,t,c)}}),Oe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(v,void 0),l=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function a(){return{message:l.value}}return()=>{if(!l.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,u=K(r,n,a),i=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(u)&&u||!(null==u?void 0:u.length)?!Array.isArray(u)&&u||(null==u?void 0:u.length)?t.h(r,i,u):t.h(r||"span",i,l.value):u}}});return e.ErrorMessage=Oe,e.Field=ve,e.FieldArray=Ve,e.FieldContextKey=p,e.Form=ge,e.FormContextKey=v,e.IS_ABSENT=m,e.PublicFormContextKey=f,e.cleanupNonNestedPath=I,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.getConfig=Z,e.isNotNestedPath=V,e.normalizeRules=H,e.useField=ie,e.useFieldArray=be,e.useFieldError=function(e){const n=x(v),r=e?void 0:t.inject(p);return t.computed((()=>e?null==n?void 0:n.errors.value[t.toValue(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=x(v),r=e?void 0:t.inject(p);return t.computed((()=>e?C(null==n?void 0:n.values,t.toValue(e)):t.toValue(null==r?void 0:r.value)))},e.useForm=he,e.useFormContext=function(){return t.inject(f)},e.useFormErrors=function(){const e=x(v);return t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=x(v);return 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=x(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=x(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=x(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=x(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useIsValidating=function(){const e=x(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isValidating.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=x(v);return function(t,n){if(e)return e.resetForm(t,n)}},e.useSetFieldError=function(e){const n=x(v),r=e?void 0:t.inject(p);return function(l){e&&n?n.setFieldError(t.toValue(e),l):r&&r.setErrors(l||[])}},e.useSetFieldTouched=function(e){const n=x(v),r=e?void 0:t.inject(p);return function(l){e&&n?n.setFieldTouched(t.toValue(e),l):r&&r.setTouched(l)}},e.useSetFieldValue=function(e){const n=x(v),r=e?void 0:t.inject(p);return function(l,a=!0){e&&n?n.setFieldValue(t.toValue(e),l,a):r&&r.setValue(l,a)}},e.useSetFormErrors=function(){const e=x(v);return function(t){e&&e.setErrors(t)}},e.useSetFormTouched=function(){const e=x(v);return function(t){e&&e.setTouched(t)}},e.useSetFormValues=function(){const e=x(v);return function(t,n=!0){e&&e.setValues(t,n)}},e.useSubmitCount=function(){const e=x(v);return t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=x(v),n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=x(v),r=e?void 0:t.inject(p);return function(){return r?r.validate():n&&e?null==n?void 0:n.validateField(t.toValue(e)):Promise.resolve({errors:[],valid:!0})}},e.useValidateForm=function(){const e=x(v);return function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0,source:"none"})}},e.validate=te,e.validateObject=le,e}({},Vue);
|
package/dist/vee-validate.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* vee-validate v5.0.0-beta.
|
|
3
|
-
* (c)
|
|
2
|
+
* vee-validate v5.0.0-beta.1
|
|
3
|
+
* (c) 2026 Abdelrahman Awad
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
6
|
import { getCurrentInstance, inject, warn as warn$1, computed, toValue, ref, watch, nextTick, unref, isRef, reactive, onUnmounted, onMounted, provide, onBeforeUnmount, defineComponent, toRef, resolveDynamicComponent, h, readonly, watchEffect, shallowRef } from 'vue';
|
|
@@ -660,9 +660,6 @@ function hasValueBinding(el) {
|
|
|
660
660
|
}
|
|
661
661
|
|
|
662
662
|
function parseInputValue(el) {
|
|
663
|
-
if (el.type === 'number') {
|
|
664
|
-
return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
|
|
665
|
-
}
|
|
666
663
|
if (el.type === 'range') {
|
|
667
664
|
return Number.isNaN(el.valueAsNumber) ? el.value : el.valueAsNumber;
|
|
668
665
|
}
|
|
@@ -1341,6 +1338,9 @@ const refreshInspector = throttle(() => {
|
|
|
1341
1338
|
}, 100);
|
|
1342
1339
|
}, 100);
|
|
1343
1340
|
function registerFormWithDevTools(form) {
|
|
1341
|
+
if (!(process.env.NODE_ENV !== 'production') || !isClient) {
|
|
1342
|
+
return;
|
|
1343
|
+
}
|
|
1344
1344
|
const vm = getCurrentInstance();
|
|
1345
1345
|
if (!API) {
|
|
1346
1346
|
const app = vm === null || vm === void 0 ? void 0 : vm.appContext.app;
|
|
@@ -1358,6 +1358,9 @@ function registerFormWithDevTools(form) {
|
|
|
1358
1358
|
refreshInspector();
|
|
1359
1359
|
}
|
|
1360
1360
|
function registerSingleFieldWithDevtools(field) {
|
|
1361
|
+
if (!(process.env.NODE_ENV !== 'production') || !isClient) {
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1361
1364
|
const vm = getCurrentInstance();
|
|
1362
1365
|
if (!API) {
|
|
1363
1366
|
const app = vm === null || vm === void 0 ? void 0 : vm.appContext.app;
|
|
@@ -1382,7 +1385,7 @@ function mapFormForDevtoolsInspector(form) {
|
|
|
1382
1385
|
});
|
|
1383
1386
|
function buildFormTree(tree, path = []) {
|
|
1384
1387
|
const key = [...path].pop();
|
|
1385
|
-
if ('id' in tree) {
|
|
1388
|
+
if ('id' in tree && typeof tree.id === 'string') {
|
|
1386
1389
|
return Object.assign(Object.assign({}, tree), { label: key || tree.label });
|
|
1387
1390
|
}
|
|
1388
1391
|
if (isObject(tree)) {
|
|
@@ -1477,7 +1480,8 @@ function getFieldNodeTags(multiple, fieldsCount, type, valid, form) {
|
|
|
1477
1480
|
function encodeNodeId(form, stateOrField) {
|
|
1478
1481
|
const type = stateOrField ? ('path' in stateOrField ? 'pathState' : 'field') : 'form';
|
|
1479
1482
|
const fieldPath = stateOrField ? ('path' in stateOrField ? stateOrField === null || stateOrField === void 0 ? void 0 : stateOrField.path : toValue(stateOrField === null || stateOrField === void 0 ? void 0 : stateOrField.name)) : '';
|
|
1480
|
-
const
|
|
1483
|
+
const ff = type === 'field' ? stateOrField === null || stateOrField === void 0 ? void 0 : stateOrField.id : fieldPath;
|
|
1484
|
+
const idObject = { f: form === null || form === void 0 ? void 0 : form.formId, ff, type };
|
|
1481
1485
|
return btoa(encodeURIComponent(JSON.stringify(idObject)));
|
|
1482
1486
|
}
|
|
1483
1487
|
function decodeNodeId(nodeId) {
|
|
@@ -1855,6 +1859,7 @@ function _useField(path, rules, opts) {
|
|
|
1855
1859
|
* Normalizes partial field options to include the full options
|
|
1856
1860
|
*/
|
|
1857
1861
|
function normalizeOptions(opts) {
|
|
1862
|
+
var _a;
|
|
1858
1863
|
const defaults = () => ({
|
|
1859
1864
|
initialValue: undefined,
|
|
1860
1865
|
validateOnMount: false,
|
|
@@ -1866,22 +1871,19 @@ function normalizeOptions(opts) {
|
|
|
1866
1871
|
controlled: true,
|
|
1867
1872
|
});
|
|
1868
1873
|
const isVModelSynced = !!(opts === null || opts === void 0 ? void 0 : opts.syncVModel);
|
|
1869
|
-
const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === 'string' ? opts.syncVModel :
|
|
1874
|
+
const modelPropName = typeof (opts === null || opts === void 0 ? void 0 : opts.syncVModel) === 'string' ? opts.syncVModel : 'modelValue';
|
|
1870
1875
|
const initialValue = isVModelSynced && !('initialValue' in (opts || {}))
|
|
1871
1876
|
? getCurrentModelValue(getCurrentInstance(), modelPropName)
|
|
1872
1877
|
: opts === null || opts === void 0 ? void 0 : opts.initialValue;
|
|
1873
1878
|
if (!opts) {
|
|
1874
1879
|
return Object.assign(Object.assign({}, defaults()), { initialValue });
|
|
1875
1880
|
}
|
|
1876
|
-
|
|
1877
|
-
const
|
|
1878
|
-
|
|
1879
|
-
const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.modelPropName) || (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
|
|
1880
|
-
return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { initialValue, controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue,
|
|
1881
|
-
syncVModel });
|
|
1881
|
+
const controlled = (_a = opts.controlled) !== null && _a !== void 0 ? _a : true;
|
|
1882
|
+
const syncVModel = (opts === null || opts === void 0 ? void 0 : opts.syncVModel) || false;
|
|
1883
|
+
return Object.assign(Object.assign(Object.assign({}, defaults()), (opts || {})), { initialValue, controlled: controlled !== null && controlled !== void 0 ? controlled : true, checkedValue: opts === null || opts === void 0 ? void 0 : opts.checkedValue, syncVModel });
|
|
1882
1884
|
}
|
|
1883
1885
|
function useFieldWithChecked(name, rules, opts) {
|
|
1884
|
-
const form =
|
|
1886
|
+
const form = (opts === null || opts === void 0 ? void 0 : opts.controlled) ? injectWithSelf(FormContextKey) : undefined;
|
|
1885
1887
|
const checkedValue = opts === null || opts === void 0 ? void 0 : opts.checkedValue;
|
|
1886
1888
|
const uncheckedValue = opts === null || opts === void 0 ? void 0 : opts.uncheckedValue;
|
|
1887
1889
|
function patchCheckedApi(field) {
|
|
@@ -2019,9 +2021,9 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
|
|
|
2019
2021
|
type: null,
|
|
2020
2022
|
default: undefined,
|
|
2021
2023
|
},
|
|
2022
|
-
|
|
2024
|
+
controlled: {
|
|
2023
2025
|
type: Boolean,
|
|
2024
|
-
default:
|
|
2026
|
+
default: true,
|
|
2025
2027
|
},
|
|
2026
2028
|
keepValue: {
|
|
2027
2029
|
type: Boolean,
|
|
@@ -2037,7 +2039,7 @@ const FieldImpl = /** #__PURE__ */ defineComponent({
|
|
|
2037
2039
|
const { errors, value, errorMessage, validate: validateField, handleChange, handleBlur, setTouched, resetField, handleReset, meta, checked, setErrors, setValue, } = useField(name, rules, {
|
|
2038
2040
|
validateOnMount: props.validateOnMount,
|
|
2039
2041
|
bails: props.bails,
|
|
2040
|
-
|
|
2042
|
+
controlled: props.controlled,
|
|
2041
2043
|
type: ctx.attrs.type,
|
|
2042
2044
|
initialValue: resolveInitialValue(props, ctx),
|
|
2043
2045
|
// Only for checkboxes and radio buttons
|
|
@@ -2584,9 +2586,6 @@ function useForm(opts) {
|
|
|
2584
2586
|
resetForm,
|
|
2585
2587
|
resetField,
|
|
2586
2588
|
handleSubmit,
|
|
2587
|
-
useFieldModel,
|
|
2588
|
-
defineInputBinds,
|
|
2589
|
-
defineComponentBinds: defineComponentBinds,
|
|
2590
2589
|
defineField,
|
|
2591
2590
|
stageInitialValue,
|
|
2592
2591
|
unsetInitialValue,
|
|
@@ -2933,50 +2932,6 @@ function useForm(opts) {
|
|
|
2933
2932
|
const model = createModel(path, () => { var _a, _b, _c; return (_c = (_a = evalConfig().validateOnModelUpdate) !== null && _a !== void 0 ? _a : (_b = getConfig()) === null || _b === void 0 ? void 0 : _b.validateOnModelUpdate) !== null && _c !== void 0 ? _c : true; });
|
|
2934
2933
|
return [model, props];
|
|
2935
2934
|
}
|
|
2936
|
-
function useFieldModel(pathOrPaths) {
|
|
2937
|
-
if (!Array.isArray(pathOrPaths)) {
|
|
2938
|
-
return createModel(pathOrPaths);
|
|
2939
|
-
}
|
|
2940
|
-
return pathOrPaths.map(p => createModel(p, true));
|
|
2941
|
-
}
|
|
2942
|
-
/**
|
|
2943
|
-
* @deprecated use defineField instead
|
|
2944
|
-
*/
|
|
2945
|
-
function defineInputBinds(path, config) {
|
|
2946
|
-
const [model, props] = defineField(path, config);
|
|
2947
|
-
function onBlur() {
|
|
2948
|
-
props.value.onBlur();
|
|
2949
|
-
}
|
|
2950
|
-
function onInput(e) {
|
|
2951
|
-
const value = normalizeEventValue(e);
|
|
2952
|
-
setFieldValue(toValue(path), value, false);
|
|
2953
|
-
props.value.onInput();
|
|
2954
|
-
}
|
|
2955
|
-
function onChange(e) {
|
|
2956
|
-
const value = normalizeEventValue(e);
|
|
2957
|
-
setFieldValue(toValue(path), value, false);
|
|
2958
|
-
props.value.onChange();
|
|
2959
|
-
}
|
|
2960
|
-
return computed(() => {
|
|
2961
|
-
return Object.assign(Object.assign({}, props.value), { onBlur,
|
|
2962
|
-
onInput,
|
|
2963
|
-
onChange, value: model.value });
|
|
2964
|
-
});
|
|
2965
|
-
}
|
|
2966
|
-
/**
|
|
2967
|
-
* @deprecated use defineField instead
|
|
2968
|
-
*/
|
|
2969
|
-
function defineComponentBinds(path, config) {
|
|
2970
|
-
const [model, props] = defineField(path, config);
|
|
2971
|
-
const pathState = findPathState(toValue(path));
|
|
2972
|
-
function onUpdateModelValue(value) {
|
|
2973
|
-
model.value = value;
|
|
2974
|
-
}
|
|
2975
|
-
return computed(() => {
|
|
2976
|
-
const conf = isCallable(config) ? config(omit(pathState, PRIVATE_PATH_STATE_KEYS)) : config || {};
|
|
2977
|
-
return Object.assign({ [conf.model || 'modelValue']: model.value, [`onUpdate:${conf.model || 'modelValue'}`]: onUpdateModelValue }, props.value);
|
|
2978
|
-
});
|
|
2979
|
-
}
|
|
2980
2935
|
const ctx = Object.assign(Object.assign({}, formCtx), { values: readonly(formValues), handleReset: () => resetForm(), submitForm });
|
|
2981
2936
|
provide(PublicFormContextKey, ctx);
|
|
2982
2937
|
return ctx;
|
|
@@ -3928,4 +3883,4 @@ function useSetFormValues() {
|
|
|
3928
3883
|
return setFormValues;
|
|
3929
3884
|
}
|
|
3930
3885
|
|
|
3931
|
-
export { ErrorMessage, Field, FieldArray, FieldContextKey, Form, FormContextKey, IS_ABSENT, PublicFormContextKey, cleanupNonNestedPath, configure, defineRule, isNotNestedPath, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormContext, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
|
|
3886
|
+
export { ErrorMessage, Field, FieldArray, FieldContextKey, Form, FormContextKey, IS_ABSENT, PublicFormContextKey, cleanupNonNestedPath, configure, defineRule, getConfig, isNotNestedPath, normalizeRules, useField, useFieldArray, useFieldError, useFieldValue, useForm, useFormContext, useFormErrors, useFormValues, useIsFieldDirty, useIsFieldTouched, useIsFieldValid, useIsFormDirty, useIsFormTouched, useIsFormValid, useIsSubmitting, useIsValidating, useResetForm, useSetFieldError, useSetFieldTouched, useSetFieldValue, useSetFormErrors, useSetFormTouched, useSetFormValues, useSubmitCount, useSubmitForm, useValidateField, useValidateForm, validate, validateObjectSchema as validateObject };
|