vee-validate
Advanced tools
Comparing version 4.7.0 to 4.7.1
@@ -625,3 +625,3 @@ import * as vue from 'vue'; | ||
$slots: { | ||
default: (arg: FieldSlotProps<unknown>) => VNode[]; | ||
default: (arg: FieldSlotProps<any>) => VNode[]; | ||
}; | ||
@@ -628,0 +628,0 @@ }); |
/** | ||
* vee-validate v4.7.0 | ||
* vee-validate v4.7.1 | ||
* (c) 2022 Abdelrahman Awad | ||
* @license MIT | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function u(e){return Number(e)>=0}const i={};const o=Symbol("vee-validate-form"),l=Symbol("vee-validate-field-instance"),s=Symbol("Default empty value"),c="undefined"!=typeof window;function d(e){return n(e)&&!!e.__locatorRef}function f(e){return!!e&&n(e.validate)}function v(e){return"checkbox"===e||"radio"===e}function p(e){return Array.isArray(e)?0===e.length:a(e)&&0===Object.keys(e).length}function m(e){return/^\[.+\]$/i.test(e)}function y(e){return"SELECT"===e.tagName}function h(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!v(t.type)}function g(e){return b(e)&&e.target&&"submit"in e.target}function b(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function O(e,t){return t in e&&e[t]!==s}function V(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!V(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!V(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var u=a[r];if(!V(e[u],t[u]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!c&&e instanceof File}var F=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,a,u;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(a=r;0!=a--;)if(!e(t[a],n[a]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(u=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(a=r;0!=a--;)if(!Object.prototype.hasOwnProperty.call(n,u[a]))return!1;for(a=r;0!=a--;){var i=u[a];if(!e(t[i],n[i]))return!1}return!0}return t!=t&&n!=n};function j(e){return m(e)?e.replace(/\[|\]/gi,""):e}function w(e,t,n){if(!e)return n;if(m(t))return e[j(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function E(e,t,n){if(m(t))return void(e[j(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=u(a[e+1])?[]:{}),i=i[a[e]]}}function S(e,t){Array.isArray(e)&&u(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function k(e,t){if(m(t))return void delete e[j(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){S(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>w(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)p(u[t])&&(0!==t?S(u[t-1],n[t-1]):S(e,n[0]))}function B(e){return Object.keys(e)}function I(e,n){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function M(e){t.warn(`[vee-validate]: ${e}`)}function C(e){return Array.isArray(e)?e[0]:e}function T(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>F(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return F(e,t)?n:t}function R(e,t=0){let n=null,r=[];return function(...a){return n&&window.clearTimeout(n),n=window.setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function x(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function P(e,t){let n;return async function(...r){const a=e(...r);n=a;const u=await a;return a!==n||(n=void 0,t(u,r)),u}}const N=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function _(e){if(U(e))return e._value}function U(e){return"_value"in e}function $(e){if(!b(e))return e;const t=e.target;if(v(t.type)&&U(t))return _(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(y(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map(_);var n;if(y(t)){const e=Array.from(t.options).find((e=>e.selected));return e?_(e):t.value}return t.value}function D(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=z(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=q(t);return n.name?(e[n.name]=z(n.params),e):e}),t):t}function z(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>w(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const q=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let L=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const K=()=>L,G=e=>{L=Object.assign(Object.assign({},L),e)};async function X(e,t,r={}){const a=null==r?void 0:r.bails,u={name:(null==r?void 0:r.name)||"{field}",rules:t,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(f(e.rules))return async function(e,t,n){var r;return{errors:await t.validate(e,{abortEarly:null===(r=n.bails)||void 0===r||r}).then((()=>[])).catch((e=>{if("ValidationError"===e.name)return e.errors;throw e}))}}(t,e.rules,{bails:e.bails});if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.name,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,u=[];for(let i=0;i<a;i++){const a=r[i],o=await a(t,n);if("string"!=typeof o&&o)continue;const l="string"==typeof o?o:J(n);if(u.push(l),e.bails)return{errors:u}}return{errors:u}}const r=Object.assign(Object.assign({},e),{rules:D(e.rules)}),a=[],u=Object.keys(r.rules),i=u.length;for(let n=0;n<i;n++){const i=u[n],o=await H(r,t,{name:i,params:r.rules[i]});if(o.error&&(a.push(o.error),e.bails))return{errors:a}}return{errors:a}}(u,e),o=i.errors;return{errors:o,valid:!o.length}}async function H(e,t,n){const r=(a=n.name,i[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const u=function(e,t){const n=e=>d(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),o={field:e.name,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:u})},l=await r(t,u,o);return"string"==typeof l?{error:l}:{error:l?void 0:J(o)}}function J(e){const t=K().generateMessage;return t?t(e):"Field is invalid"}async function Q(e,t,n){const r=B(e).map((async r=>{var a,u,i;const o=await X(w(t,r),e[r],{name:(null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r])||r,values:t,bails:null===(i=null===(u=null==n?void 0:n.bailsMap)||void 0===u?void 0:u[r])||void 0===i||i});return Object.assign(Object.assign({},o),{path:r})}));let a=!0;const u=await Promise.all(r),i={},o={};for(const e of u)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,o[e.path]=e.errors[0]);return{valid:a,results:i,errors:o}}function W(e,t,n){"object"==typeof n.value&&(n.value=Y(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function Y(e){if("object"!=typeof e)return e;var t,n,r,a=0,u=Object.prototype.toString.call(e);if("[object Object]"===u?r=Object.create(e.__proto__||null):"[object Array]"===u?r=Array(e.length):"[object Set]"===u?(r=new Set,e.forEach((function(e){r.add(Y(e))}))):"[object Map]"===u?(r=new Map,e.forEach((function(e,t){r.set(Y(t),Y(e))}))):"[object Date]"===u?r=new Date(+e):"[object RegExp]"===u?r=new RegExp(e.source,e.flags):"[object DataView]"===u?r=new e.constructor(Y(e.buffer)):"[object ArrayBuffer]"===u?r=e.slice(0):"Array]"===u.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)W(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||W(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}let Z=0;function ee(e,n){const{value:r,initialValue:a,setInitialValue:u}=te(e,n.modelValue,n.form),{errorMessage:i,errors:o,setErrors:l}=function(e,n){function r(e){return e?Array.isArray(e)?e:[e]:[]}if(!n){const e=t.ref([]);return{errors:e,errorMessage:t.computed((()=>e.value[0])),setErrors:t=>{e.value=r(t)}}}const a=t.computed((()=>n.errorBag.value[t.unref(e)]||[]));return{errors:a,errorMessage:t.computed((()=>a.value[0])),setErrors:a=>{n.setFieldErrorBag(t.unref(e),r(a))}}}(e,n.form),s=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!V(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,o);return{id:Z>=Number.MAX_SAFE_INTEGER?0:++Z,path:e,value:r,initialValue:a,meta:s,errors:o,errorMessage:i,setState:function(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&l(e.errors),"touched"in e&&(s.touched=null!==(t=e.touched)&&void 0!==t?t:s.touched),"initialValue"in e&&u(e.initialValue)}}}function te(e,n,r){const a=t.ref(t.unref(n));function u(){return r?w(r.meta.value.initialValues,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const o=t.computed(u);if(!r){return{value:t.ref(u()),initialValue:o,setInitialValue:i}}const l=n?t.unref(n):w(r.values,t.unref(e),t.unref(o));r.stageInitialValue(t.unref(e),l,!0);return{value:t.computed({get:()=>w(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n)}}),initialValue:o,setInitialValue:i}}function ne(e,n,r){return v(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:I(o),u=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function l(e){const n=e.handleChange,r=t.computed((()=>{const n=t.unref(e.value),r=t.unref(u);return Array.isArray(n)?n.findIndex((e=>V(e,r)))>=0:V(r,n)}));function o(o,l=!0){var s;if(r.value===(null===(s=null==o?void 0:o.target)||void 0===s?void 0:s.checked))return void(l&&e.validate());let c=$(o);a||(c=T(t.unref(e.value),t.unref(u),t.unref(i))),n(c,l)}return Object.assign(Object.assign({},e),{checked:r,checkedValue:u,uncheckedValue:i,handleChange:o})}return l(re(e,n,r))}(e,n,r):re(e,n,r)}function re(e,r,a){const{initialValue:u,validateOnMount:i,bails:c,type:v,checkedValue:p,label:m,validateOnValueUpdate:y,uncheckedValue:h,controlled:g,keepValueOnUnmount:b,modelPropName:O,syncVModel:A,form:F}=function(e,t){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:e,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0,controlled:!0});if(!t)return n();const r="valueProp"in t?t.valueProp:t.checkedValue,a="standalone"in t?!t.standalone:t.controlled;return Object.assign(Object.assign(Object.assign({},n()),t||{}),{controlled:null==a||a,checkedValue:r})}(t.unref(e),a),j=g?I(o):void 0,E=F||j;let S=!1;const{id:k,value:M,initialValue:C,meta:T,setState:R,errors:N,errorMessage:_}=ee(e,{modelValue:u,form:E});A&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const u=e||"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{V(e,ae(a,u))||a.emit(i,e)})),t.watch((()=>ae(a,u)),(e=>{if(e===s&&void 0===n.value)return;const t=e===s?void 0:e;V(t,x(n.value,a.props.modelModifiers))||r(t)}))}({value:M,prop:O,handleChange:K});const U=t.computed((()=>{let a=t.unref(r);const u=t.unref(null==E?void 0:E.schema);return u&&!f(u)&&(a=function(e,t){if(!e)return;return e[t]}(u,t.unref(e))||a),f(a)||n(a)||Array.isArray(a)?a:D(a)}));async function z(n){var r,a;return(null==E?void 0:E.validateSchema)?null!==(r=(await E.validateSchema(n)).results[t.unref(e)])&&void 0!==r?r:{valid:!0,errors:[]}:X(M.value,U.value,{name:t.unref(m)||t.unref(e),values:null!==(a=null==E?void 0:E.values)&&void 0!==a?a:{},bails:c})}const q=P((async()=>(T.pending=!0,T.validated=!0,z("validated-only"))),(e=>(S&&(e.valid=!0,e.errors=[]),R({errors:e.errors}),T.pending=!1,e))),L=P((async()=>z("silent")),(e=>(S&&(e.valid=!0),T.valid=e.valid,e)));function K(e,t=!0){const n=$(e);M.value=n,!y&&t&&q()}let G;t.onMounted((()=>{if(i)return q();E&&E.validateSchema||L()}));let H=Y(M.value);function J(){G=t.watch(M,((e,t)=>{if(V(e,t)&&V(e,H))return;(y?q:L)(),H=Y(e)}),{deep:!0})}function Q(e){var n;null==G||G();const r=e&&"value"in e?e.value:C.value;R({value:Y(r),initialValue:Y(r),touched:null!==(n=null==e?void 0:e.touched)&&void 0!==n&&n,errors:(null==e?void 0:e.errors)||[]}),T.pending=!1,T.validated=!1,L(),t.nextTick((()=>{J()}))}J();const W={id:k,name:e,label:m,value:M,meta:T,errors:N,errorMessage:_,type:v,checkedValue:p,uncheckedValue:h,bails:c,keepValueOnUnmount:b,resetField:Q,handleReset:()=>Q(),validate:function(e){return"silent"===(null==e?void 0:e.mode)?L():q()},handleChange:K,handleBlur:()=>{T.touched=!0},setState:R,setTouched:function(e){T.touched=e},setErrors:function(e){R({errors:Array.isArray(e)?e:[e]})},setValue:function(e){M.value=e}};if(t.provide(l,W),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{V(e,t)||(T.validated?q():L())}),{deep:!0}),!E)return W;E.register(W),t.onBeforeUnmount((()=>{S=!0,E.unregister(W)}));const Z=t.computed((()=>{const e=U.value;return!e||n(e)||f(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(d):B(a).filter((e=>d(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=w(E.values,t)||E.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(Z,((e,t)=>{if(!Object.keys(e).length)return;!V(e,t)&&(T.validated?q():L())})),W}function ae(e,t){return e.props[t]}function ue(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ie(e,t){return v(t.attrs.type)?O(e,"modelValue")?e.modelValue:void 0:O(e,"modelValue")?e.modelValue:t.attrs.value}const oe=t.defineComponent({name:"Field",inheritAttrs:!1,props:{as:{type:[String,Object],default:void 0},name:{type:String,required:!0},rules:{type:[Object,String,Function],default:void 0},validateOnMount:{type:Boolean,default:!1},validateOnBlur:{type:Boolean,default:void 0},validateOnChange:{type:Boolean,default:void 0},validateOnInput:{type:Boolean,default:void 0},validateOnModelUpdate:{type:Boolean,default:void 0},bails:{type:Boolean,default:()=>K().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:s},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,n){const r=t.toRef(e,"rules"),a=t.toRef(e,"name"),u=t.toRef(e,"label"),i=t.toRef(e,"uncheckedValue"),o=t.toRef(e,"keepValue"),{errors:l,value:s,errorMessage:c,validate:d,handleChange:f,handleBlur:p,setTouched:m,resetField:y,handleReset:g,meta:b,checked:O,setErrors:V}=ne(a,r,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:n.attrs.type,initialValue:ie(e,n),checkedValue:n.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:!1,keepValueOnUnmount:o}),A=function(e,t=!0){f(e,t),n.emit("update:modelValue",s.value)},F=function(e){(e=>{v(n.attrs.type)||(s.value=$(e))})(e),n.emit("update:modelValue",s.value)},j=t.computed((()=>{const{validateOnInput:t,validateOnChange:r,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,a;const{validateOnInput:u,validateOnChange:i,validateOnBlur:o,validateOnModelUpdate:l}=K();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:u,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:o,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:l}}(e),i=[p,n.attrs.onBlur,a?d:void 0].filter(Boolean),o=[e=>A(e,t),n.attrs.onInput].filter(Boolean),l=[e=>A(e,r),n.attrs.onChange].filter(Boolean),c={name:e.name,onBlur:i,onInput:o,onChange:l,"onUpdate:modelValue":e=>A(e,u)};v(n.attrs.type)&&O&&(c.checked=O.value);return h(ue(e,n),n.attrs)&&(c.value=s.value),c}));function w(){return{field:j.value,value:s.value,meta:b,errors:l.value,errorMessage:c.value,validate:d,resetField:y,handleChange:A,handleInput:F,handleReset:g,handleBlur:p,setTouched:m,setErrors:V}}return n.expose({setErrors:V,setTouched:m,reset:y,validate:d,handleChange:f}),()=>{const r=t.resolveDynamicComponent(ue(e,n)),a=N(r,n,w);return r?t.h(r,Object.assign(Object.assign({},n.attrs),j.value),a):a}}});let le=0;function se(e){var n;const r=le++,a=new Set;let u=!1;const i=t.ref({}),l=t.ref(!1),s=t.ref(0),c=[],d=t.reactive(Y(t.unref(null==e?void 0:e.initialValues)||{})),{errorBag:v,setErrorBag:m,setFieldErrorBag:y}=function(e){const n=t.ref({});function r(e){return Array.isArray(e)?e:e?[e]:[]}function a(e,t){t?n.value[e]=r(t):delete n.value[e]}function u(e){n.value=B(e).reduce(((t,n)=>{const a=e[n];return a&&(t[n]=r(a)),t}),{})}e&&u(e);return{errorBag:n,setErrorBag:u,setFieldErrorBag:a}}(null==e?void 0:e.initialErrors),h=t.computed((()=>B(v.value).reduce(((e,t)=>{const n=v.value[t];return n&&n.length&&(e[t]=n[0]),e}),{})));function b(e){const t=i.value[e];return Array.isArray(t)?t[0]:t}function O(e){return!!i.value[e]}const A=t.computed((()=>B(i.value).reduce(((e,n)=>{const r=b(n);return r&&(e[n]=t.unref(r.label||r.name)||""),e}),{}))),F=t.computed((()=>B(i.value).reduce(((e,t)=>{var n;const r=b(t);return r&&(e[t]=null===(n=r.bails)||void 0===n||n),e}),{}))),j=Object.assign({},(null==e?void 0:e.initialErrors)||{}),S=null!==(n=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==n&&n,{initialValues:I,originalInitialValues:M,setInitialValues:C}=function(e,n,r){const a=t.ref(Y(t.unref(r))||{}),u=t.ref(Y(t.unref(r))||{});function i(t,r=!1){a.value=Y(t),u.value=Y(t),r&&B(e.value).forEach((t=>{const r=e.value[t],u=Array.isArray(r)?r.some((e=>e.meta.touched)):null==r?void 0:r.meta.touched;if(!r||u)return;const i=w(a.value,t);E(n,t,Y(i))}))}t.isRef(r)&&t.watch(r,(e=>{i(e,!0)}),{deep:!0});return{initialValues:a,originalInitialValues:u,setInitialValues:i}}(i,d,null==e?void 0:e.initialValues),x=function(e,n,r,a){const u={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!V(n,t.unref(r))));function o(){const t=Object.values(e.value).flat(1).filter(Boolean);return B(u).reduce(((e,n)=>{const r=u[n];return e[n]=t[r]((e=>e.meta[n])),e}),{})}const l=t.reactive(o());return t.watchEffect((()=>{const e=o();l.touched=e.touched,l.valid=e.valid,l.pending=e.pending})),t.computed((()=>Object.assign(Object.assign({initialValues:t.unref(r)},l),{valid:l.valid&&!B(a.value).length,dirty:i.value})))}(i,d,M,h),N=t.computed((()=>[...a,...B(i.value)].reduce(((e,t)=>(E(e,t,w(d,t)),e)),{}))),_=null==e?void 0:e.validationSchema,U=R(de,5),$=R(de,5),D=P((async e=>"silent"===await e?U():$()),((e,[t])=>{const n=L.fieldsByPath.value||{},r=B(L.errorBag.value);return[...new Set([...B(e.results),...B(n),...r])].reduce(((r,a)=>{const u=n[a],i=(e.results[a]||{errors:[]}).errors,o={errors:i,valid:!i.length};if(r.results[a]=o,o.valid||(r.errors[a]=o.errors[0]),!u)return H(a,i),r;if(G(u,(e=>e.meta.valid=o.valid)),"silent"===t)return r;const l=Array.isArray(u)?u.some((e=>e.meta.validated)):u.meta.validated;return"validated-only"!==t||l?(G(u,(e=>e.setState({errors:o.errors}))),r):r}),{valid:e.valid,results:{},errors:{}})}));function z(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),re(B(i.value).reduce(((e,t)=>(e[t]=!0,e)),{})),l.value=!0,s.value++,oe().then((a=>{const u=Y(d);if(a.valid&&"function"==typeof t){const n=Y(N.value);return t(e?n:u,{evt:r,controlledValues:n,setErrors:J,setFieldError:H,setTouched:re,setFieldTouched:ne,setValues:Z,setFieldValue:W,resetForm:ae})}a.valid||"function"!=typeof n||n({values:u,evt:r,errors:a.errors,results:a.results})})).then((e=>(l.value=!1,e)),(e=>{throw l.value=!1,e}))}}}const q=z(!1);q.withControlled=z(!0);const L={formId:r,fieldsByPath:i,values:d,controlledValues:N,errorBag:v,errors:h,schema:_,submitCount:s,meta:x,isSubmitting:l,fieldArrays:c,keepValuesOnUnmount:S,validateSchema:t.unref(_)?D:void 0,validate:oe,register:function(e){const n=t.unref(e.name);ue(e,n),t.isRef(e.name)&&t.watch(e.name,(async(n,r)=>{await t.nextTick(),ie(e,r),ue(e,n),(h.value[r]||h.value[n])&&(H(r,void 0),se(n)),await t.nextTick(),O(r)||k(d,r)}));const r=t.unref(e.errorMessage);r&&(null==j?void 0:j[n])!==r&&se(n);delete j[n]},unregister:function(e){const n=t.unref(e.name),r=i.value[n],a=!!r&&K(r);ie(e,n),t.nextTick((()=>{var u;const o=null!==(u=t.unref(e.keepValueOnUnmount))&&void 0!==u?u:t.unref(S),l=w(d,n);if(a&&(r===i.value[n]||!i.value[n])&&Array.isArray(l)&&!o){const r=l.findIndex((n=>V(n,t.unref(e.checkedValue))));if(r>-1){const e=[...l];e.splice(r,1),W(n,e,{force:!0})}}if(!O(n)){if(H(n,void 0),o)return;if(a&&!p(w(d,n)))return;k(d,n)}}))},setFieldErrorBag:y,validateField:se,setFieldValue:W,setValues:Z,setErrors:J,setFieldError:H,setFieldTouched:ne,setTouched:re,resetForm:ae,handleSubmit:q,stageInitialValue:function(t,n,r=!1){E(d,t,n),ce(t,n),r&&!(null==e?void 0:e.initialValues)&&E(M.value,t,Y(n))},unsetInitialValue:function(e){k(I.value,e)},setFieldInitialValue:ce,useFieldModel:function(e){if(!Array.isArray(e))return ee(e);return e.map(ee)}};function K(e){return Array.isArray(e)}function G(e,t){return Array.isArray(e)?e.forEach(t):t(e)}function X(e){Object.values(i.value).forEach((t=>{t&&G(t,e)}))}function H(e,t){y(e,t)}function J(e){m(e)}function W(e,n,{force:r}={force:!1}){var a;const o=i.value[e],l=Y(n);if(!o)return void E(d,e,l);if(K(o)&&"checkbox"===(null===(a=o[0])||void 0===a?void 0:a.type)&&!Array.isArray(n)){const t=Y(T(w(d,e)||[],n,void 0));return void E(d,e,t)}let s=n;K(o)||"checkbox"!==o.type||r||u||(s=Y(T(w(d,e),n,t.unref(o.uncheckedValue)))),E(d,e,s)}function Z(e){B(d).forEach((e=>{delete d[e]})),B(e).forEach((t=>{W(t,e[t])})),c.forEach((e=>e&&e.reset()))}function ee(e){const{value:n}=te(e,void 0,L);return t.watch(n,(()=>{O(t.unref(e))||oe({mode:"validated-only"})}),{deep:!0}),a.add(t.unref(e)),n}function ne(e,t){const n=i.value[e];n&&G(n,(e=>e.setTouched(t)))}function re(e){B(e).forEach((t=>{ne(t,!!e[t])}))}function ae(e){u=!0,X((e=>e.resetField())),(null==e?void 0:e.values)?(C(e.values),Z(null==e?void 0:e.values)):(C(M.value),Z(M.value)),(null==e?void 0:e.touched)&&re(e.touched),J((null==e?void 0:e.errors)||{}),s.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{u=!1}))}function ue(e,n){const r=t.markRaw(e),a=n;if(!i.value[a])return void(i.value[a]=r);const u=i.value[a];u&&!Array.isArray(u)&&(i.value[a]=[u]),i.value[a]=[...i.value[a],r]}function ie(e,t){const n=t,r=i.value[n];if(r)if(K(r)||e.id!==r.id){if(K(r)){const t=r.findIndex((t=>t.id===e.id));if(-1===t)return;r.splice(t,1),r.length||delete i.value[n]}}else delete i.value[n]}async function oe(e){if(X((e=>e.meta.validated=!0)),L.validateSchema)return L.validateSchema((null==e?void 0:e.mode)||"force");const n=await Promise.all(Object.values(i.value).map((n=>{const r=Array.isArray(n)?n[0]:n;return r?r.validate(e).then((e=>({key:t.unref(r.name),valid:e.valid,errors:e.errors}))):Promise.resolve({key:"",valid:!0,errors:[]})}))),r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function se(e){const n=i.value[e];return n?Array.isArray(n)?n.map((e=>e.validate()))[0]:n.validate():(t.warn(`field with name ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function ce(e,t){E(I.value,e,Y(t))}async function de(){const e=t.unref(_);if(!e)return{valid:!0,results:{},errors:{}};const n=f(e)?await async function(e,t){const n=await e.validate(t,{abortEarly:!1}).then((()=>[])).catch((e=>{if("ValidationError"!==e.name)throw e;return e.inner||[]})),r={},a={};for(const e of n){const t=e.errors;r[e.path]={valid:!t.length,errors:t},t.length&&(a[e.path]=t[0])}return{valid:!n.length,results:r,errors:a}}(e,d):await Q(e,d,{names:A.value,bailsMap:F.value});return n}const fe=q(((e,{evt:t})=>{g(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&J(e.initialErrors),(null==e?void 0:e.initialTouched)&&re(e.initialTouched),(null==e?void 0:e.validateOnMount)?oe():L.validateSchema&&L.validateSchema("silent")})),t.isRef(_)&&t.watch(_,(()=>{var e;null===(e=L.validateSchema)||void 0===e||e.call(L,"validated-only")})),t.provide(o,L),Object.assign(Object.assign({},L),{handleReset:()=>ae(),submitForm:fe})}const ce=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),u=t.toRef(e,"keepValues"),{errors:i,values:o,meta:l,isSubmitting:s,submitCount:c,controlledValues:d,validate:f,validateField:v,handleReset:p,resetForm:m,handleSubmit:y,setErrors:h,setFieldError:O,setFieldValue:V,setValues:A,setFieldTouched:F,setTouched:j}=se({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:u}),w=y(((e,{evt:t})=>{g(t)&&t.target.submit()}),e.onInvalidSubmit),E=e.onSubmit?y(e.onSubmit,e.onInvalidSubmit):w;function S(e){b(e)&&e.preventDefault(),p(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function k(t,n){return y("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function B(){return{meta:l.value,errors:i.value,values:o,isSubmitting:s.value,submitCount:c.value,controlledValues:d.value,validate:f,validateField:v,handleSubmit:k,handleReset:p,submitForm:w,setErrors:h,setFieldError:O,setFieldValue:V,setValues:A,setFieldTouched:F,setTouched:j,resetForm:m}}return n.expose({setFieldError:O,setErrors:h,setFieldValue:V,setValues:A,setFieldTouched:F,setTouched:j,resetForm:m,validate:f,validateField:v}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=N(r,n,B);if(!e.as)return a;const u="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},u),n.attrs),{onSubmit:E,onReset:S}),a)}}}),de=ce;function fe(e){const n=I(o,void 0),a=t.ref([]),u=()=>{},i={fields:a,remove:u,push:u,swap:u,insert:u,update:u,replace:u,prepend:u,move:u};if(!n)return M("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),i;if(!t.unref(e))return M("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const l=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(l)return l;let s=0;function c(){const r=w(null==n?void 0:n.values,t.unref(e),[])||[];a.value=r.map(f),d()}function d(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(r){const u=s++,i={key:u,value:t.computed({get(){const i=w(null==n?void 0:n.values,t.unref(e),[])||[],o=a.value.findIndex((e=>e.key===u));return-1===o?r:i[o]},set(e){const t=a.value.findIndex((e=>e.key===u));-1!==t?v(t,e):M("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return i}function v(r,a){const u=t.unref(e),i=w(null==n?void 0:n.values,u);!Array.isArray(i)||i.length-1<r||null==n||n.setFieldValue(`${u}[${r}]`,a)}c();const p={fields:a,remove:function(r){const u=t.unref(e),i=w(null==n?void 0:n.values,u);if(!i||!Array.isArray(i))return;const o=[...i];o.splice(r,1),null==n||n.unsetInitialValue(u+`[${r}]`),null==n||n.setFieldValue(u,o),a.value.splice(r,1),d()},push:function(u){const i=t.unref(e),o=w(null==n?void 0:n.values,i),l=r(o)?[]:o;if(!Array.isArray(l))return;const s=[...l];s.push(u),null==n||n.stageInitialValue(i+`[${s.length-1}]`,u),null==n||n.setFieldValue(i,s),a.value.push(f(u)),d()},swap:function(r,u){const i=t.unref(e),o=w(null==n?void 0:n.values,i);if(!Array.isArray(o)||!(r in o)||!(u in o))return;const l=[...o],s=[...a.value],c=l[r];l[r]=l[u],l[u]=c;const f=s[r];s[r]=s[u],s[u]=f,null==n||n.setFieldValue(i,l),a.value=s,d()},insert:function(r,u){const i=t.unref(e),o=w(null==n?void 0:n.values,i);if(!Array.isArray(o)||o.length<r)return;const l=[...o],s=[...a.value];l.splice(r,0,u),s.splice(r,0,f(u)),null==n||n.setFieldValue(i,l),a.value=s,d()},update:v,replace:function(r){const a=t.unref(e);null==n||n.setFieldValue(a,r),c()},prepend:function(u){const i=t.unref(e),o=w(null==n?void 0:n.values,i),l=r(o)?[]:o;if(!Array.isArray(l))return;const s=[u,...l];null==n||n.stageInitialValue(i+`[${s.length-1}]`,u),null==n||n.setFieldValue(i,s),a.value.unshift(f(u)),d()},move:function(u,i){const o=t.unref(e),l=w(null==n?void 0:n.values,o),s=r(l)?[]:[...l];if(!Array.isArray(l)||!(u in l)||!(i in l))return;const c=[...a.value],f=c[u];c.splice(u,1),c.splice(i,0,f);const v=s[u];s.splice(u,1),s.splice(i,0,v),null==n||n.setFieldValue(o,s),a.value=c,d()}};return n.fieldArrays.push(Object.assign({path:e,reset:c},p)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),p}const ve=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:u,insert:i,replace:o,update:l,prepend:s,move:c,fields:d}=fe(t.toRef(e,"name"));function f(){return{fields:d.value,push:r,remove:a,swap:u,insert:i,update:l,replace:o,prepend:s,move:c}}return n.expose({push:r,remove:a,swap:u,insert:i,update:l,replace:o,prepend:s,move:c}),()=>N(void 0,n,f)}}),pe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(o,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function u(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=N(r,n,u),o=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,o,i):t.h(r||"span",o,a.value):i}}});e.ErrorMessage=pe,e.Field=oe,e.FieldArray=ve,e.FieldContextKey=l,e.Form=de,e.FormContextKey=o,e.IS_ABSENT=s,e.configure=G,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),i[e]=t},e.useField=ne,e.useFieldArray=fe,e.useFieldError=function(e){const n=I(o),r=e?void 0:t.inject(l);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=I(o),r=e?void 0:t.inject(l);return t.computed((()=>e?w(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=se,e.useFormErrors=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=C(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.dirty:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldTouched=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=C(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.touched:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldValid=function(e){const n=I(o);let r=e?void 0:t.inject(l);return t.computed((()=>(e&&(r=C(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.valid:(M(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFormDirty=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=I(o);t||M("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=I(o);let r=e?void 0:t.inject(l);return function(){return e&&(r=C(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.validate():(M(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=I(o);return e||M("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=X,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidate={},e.Vue)}(this,(function(e,t){"use strict";function n(e){return"function"==typeof e}function r(e){return null==e}const a=e=>null!==e&&!!e&&"object"==typeof e&&!Array.isArray(e);function u(e){return Number(e)>=0}const i={};const l=Symbol("vee-validate-form"),o=Symbol("vee-validate-field-instance"),s=Symbol("Default empty value"),d="undefined"!=typeof window;function c(e){return n(e)&&!!e.__locatorRef}function f(e){return!!e&&n(e.validate)}function v(e){return"checkbox"===e||"radio"===e}function p(e){return Array.isArray(e)?0===e.length:a(e)&&0===Object.keys(e).length}function m(e){return/^\[.+\]$/i.test(e)}function h(e){return"SELECT"===e.tagName}function y(e,t){return!function(e,t){const n=![!1,null,void 0,0].includes(t.multiple)&&!Number.isNaN(t.multiple);return"select"===e&&"multiple"in t&&n}(e,t)&&"file"!==t.type&&!v(t.type)}function g(e){return b(e)&&e.target&&"submit"in e.target}function b(e){return!!e&&(!!("undefined"!=typeof Event&&n(Event)&&e instanceof Event)||!(!e||!e.srcElement))}function V(e,t){return t in e&&e[t]!==s}function O(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,r,a;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(!O(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(!O(r[1],t.get(r[0])))return!1;return!0}if(A(e)&&A(t))return e.size===t.size&&(e.name===t.name&&(e.lastModified===t.lastModified&&e.type===t.type));if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if((n=e.length)!=t.length)return!1;for(r=n;0!=r--;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(a=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(r=n;0!=r--;)if(!Object.prototype.hasOwnProperty.call(t,a[r]))return!1;for(r=n;0!=r--;){var u=a[r];if(!O(e[u],t[u]))return!1}return!0}return e!=e&&t!=t}function A(e){return!!d&&e instanceof File}function F(e,t,n){"object"==typeof n.value&&(n.value=w(n.value)),n.enumerable&&!n.get&&!n.set&&n.configurable&&n.writable&&"__proto__"!==t?e[t]=n.value:Object.defineProperty(e,t,n)}function w(e){if("object"!=typeof e)return e;var t,n,r,a=0,u=Object.prototype.toString.call(e);if("[object Object]"===u?r=Object.create(e.__proto__||null):"[object Array]"===u?r=Array(e.length):"[object Set]"===u?(r=new Set,e.forEach((function(e){r.add(w(e))}))):"[object Map]"===u?(r=new Map,e.forEach((function(e,t){r.set(w(t),w(e))}))):"[object Date]"===u?r=new Date(+e):"[object RegExp]"===u?r=new RegExp(e.source,e.flags):"[object DataView]"===u?r=new e.constructor(w(e.buffer)):"[object ArrayBuffer]"===u?r=e.slice(0):"Array]"===u.slice(-6)&&(r=new e.constructor(e)),r){for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)F(r,n[a],Object.getOwnPropertyDescriptor(e,n[a]));for(a=0,n=Object.getOwnPropertyNames(e);a<n.length;a++)Object.hasOwnProperty.call(r,t=n[a])&&r[t]===e[t]||F(r,t,Object.getOwnPropertyDescriptor(e,t))}return r||e}function j(e){return m(e)?e.replace(/\[|\]/gi,""):e}function E(e,t,n){if(!e)return n;if(m(t))return e[j(t)];return(t||"").split(/\.|\[(\d+)\]/).filter(Boolean).reduce(((e,t)=>{return(a(r=e)||Array.isArray(r))&&t in e?e[t]:n;var r}),e)}function S(e,t,n){if(m(t))return void(e[j(t)]=n);const a=t.split(/\.|\[(\d+)\]/).filter(Boolean);let i=e;for(let e=0;e<a.length;e++){if(e===a.length-1)return void(i[a[e]]=n);a[e]in i&&!r(i[a[e]])||(i[a[e]]=u(a[e+1])?[]:{}),i=i[a[e]]}}function k(e,t){Array.isArray(e)&&u(t)?e.splice(Number(t),1):a(e)&&delete e[t]}function B(e,t){if(m(t))return void delete e[j(t)];const n=t.split(/\.|\[(\d+)\]/).filter(Boolean);let a=e;for(let e=0;e<n.length;e++){if(e===n.length-1){k(a,n[e]);break}if(!(n[e]in a)||r(a[n[e]]))break;a=a[n[e]]}const u=n.map(((t,r)=>E(e,n.slice(0,r).join("."))));for(let t=u.length-1;t>=0;t--)p(u[t])&&(0!==t?k(u[t-1],n[t-1]):k(e,n[0]))}function I(e){return Object.keys(e)}function M(e,n){const r=t.getCurrentInstance();return(null==r?void 0:r.provides[e])||t.inject(e,n)}function C(e){t.warn(`[vee-validate]: ${e}`)}function T(e){return Array.isArray(e)?e[0]:e}function R(e,t,n){if(Array.isArray(e)){const n=[...e],r=n.findIndex((e=>O(e,t)));return r>=0?n.splice(r,1):n.push(t),n}return O(e,t)?n:t}function x(e,t=0){let n=null,r=[];return function(...a){return n&&window.clearTimeout(n),n=window.setTimeout((()=>{const t=e(...a);r.forEach((e=>e(t))),r=[]}),t),new Promise((e=>r.push(e)))}}function N(e,t){return a(t)&&t.number?function(e){const t=parseFloat(e);return isNaN(t)?e:t}(e):e}function P(e,t){let n;return async function(...r){const a=e(...r);n=a;const u=await a;return a!==n||(n=void 0,t(u,r)),u}}function _({get:e,set:n}){const r=t.ref(w(e()));return t.watch(e,(e=>{O(e,r.value)||(r.value=w(e))}),{deep:!0}),t.watch(r,(t=>{O(t,e())||n(w(t))}),{deep:!0}),r}const U=(e,t,n)=>t.slots.default?"string"!=typeof e&&e?{default:()=>{var e,r;return null===(r=(e=t.slots).default)||void 0===r?void 0:r.call(e,n())}}:t.slots.default(n()):t.slots.default;function $(e){if(D(e))return e._value}function D(e){return"_value"in e}function z(e){if(!b(e))return e;const t=e.target;if(v(t.type)&&D(t))return $(t);if("file"===t.type&&t.files){const e=Array.from(t.files);return t.multiple?e:e[0]}if(h(n=t)&&n.multiple)return Array.from(t.options).filter((e=>e.selected&&!e.disabled)).map($);var n;if(h(t)){const e=Array.from(t.options).find((e=>e.selected));return e?$(e):t.value}return t.value}function q(e){const t={};return Object.defineProperty(t,"_$$isNormalized",{value:!0,writable:!1,enumerable:!1,configurable:!1}),e?a(e)&&e._$$isNormalized?e:a(e)?Object.keys(e).reduce(((t,n)=>{const r=function(e){if(!0===e)return[];if(Array.isArray(e))return e;if(a(e))return e;return[e]}(e[n]);return!1!==e[n]&&(t[n]=L(r)),t}),t):"string"!=typeof e?t:e.split("|").reduce(((e,t)=>{const n=K(t);return n.name?(e[n.name]=L(n.params),e):e}),t):t}function L(e){const t=e=>"string"==typeof e&&"@"===e[0]?function(e){const t=t=>E(t,e)||t[e];return t.__locatorRef=e,t}(e.slice(1)):e;return Array.isArray(e)?e.map(t):e instanceof RegExp?[e]:Object.keys(e).reduce(((n,r)=>(n[r]=t(e[r]),n)),{})}const K=e=>{let t=[];const n=e.split(":")[0];return e.includes(":")&&(t=e.split(":").slice(1).join(":").split(",")),{name:n,params:t}};let G=Object.assign({},{generateMessage:({field:e})=>`${e} is not valid.`,bails:!0,validateOnBlur:!0,validateOnChange:!0,validateOnInput:!1,validateOnModelUpdate:!0});const X=()=>G,H=e=>{G=Object.assign(Object.assign({},G),e)};async function J(e,t,r={}){const a=null==r?void 0:r.bails,u={name:(null==r?void 0:r.name)||"{field}",rules:t,bails:null==a||a,formData:(null==r?void 0:r.values)||{}},i=await async function(e,t){if(f(e.rules))return async function(e,t,n){var r;return{errors:await t.validate(e,{abortEarly:null===(r=n.bails)||void 0===r||r}).then((()=>[])).catch((e=>{if("ValidationError"===e.name)return e.errors;throw e}))}}(t,e.rules,{bails:e.bails});if(n(e.rules)||Array.isArray(e.rules)){const n={field:e.name,form:e.formData,value:t},r=Array.isArray(e.rules)?e.rules:[e.rules],a=r.length,u=[];for(let i=0;i<a;i++){const a=r[i],l=await a(t,n);if("string"!=typeof l&&l)continue;const o="string"==typeof l?l:W(n);if(u.push(o),e.bails)return{errors:u}}return{errors:u}}const r=Object.assign(Object.assign({},e),{rules:q(e.rules)}),a=[],u=Object.keys(r.rules),i=u.length;for(let n=0;n<i;n++){const i=u[n],l=await Q(r,t,{name:i,params:r.rules[i]});if(l.error&&(a.push(l.error),e.bails))return{errors:a}}return{errors:a}}(u,e),l=i.errors;return{errors:l,valid:!l.length}}async function Q(e,t,n){const r=(a=n.name,i[a]);var a;if(!r)throw new Error(`No such validator '${n.name}' exists.`);const u=function(e,t){const n=e=>c(e)?e(t):e;if(Array.isArray(e))return e.map(n);return Object.keys(e).reduce(((t,r)=>(t[r]=n(e[r]),t)),{})}(n.params,e.formData),l={field:e.name,value:t,form:e.formData,rule:Object.assign(Object.assign({},n),{params:u})},o=await r(t,u,l);return"string"==typeof o?{error:o}:{error:o?void 0:W(l)}}function W(e){const t=X().generateMessage;return t?t(e):"Field is invalid"}async function Y(e,t,n){const r=I(e).map((async r=>{var a,u,i;const l=await J(E(t,r),e[r],{name:(null===(a=null==n?void 0:n.names)||void 0===a?void 0:a[r])||r,values:t,bails:null===(i=null===(u=null==n?void 0:n.bailsMap)||void 0===u?void 0:u[r])||void 0===i||i});return Object.assign(Object.assign({},l),{path:r})}));let a=!0;const u=await Promise.all(r),i={},l={};for(const e of u)i[e.path]={valid:e.valid,errors:e.errors},e.valid||(a=!1,l[e.path]=e.errors[0]);return{valid:a,results:i,errors:l}}let Z=0;function ee(e,n){const{value:r,initialValue:a,setInitialValue:u}=te(e,n.modelValue,n.form),{errorMessage:i,errors:l,setErrors:o}=function(e,n){function r(e){return e?Array.isArray(e)?e:[e]:[]}if(!n){const e=t.ref([]);return{errors:e,errorMessage:t.computed((()=>e.value[0])),setErrors:t=>{e.value=r(t)}}}const a=t.computed((()=>n.errorBag.value[t.unref(e)]||[]));return{errors:a,errorMessage:t.computed((()=>a.value[0])),setErrors:a=>{n.setFieldErrorBag(t.unref(e),r(a))}}}(e,n.form),s=function(e,n,r){const a=t.reactive({touched:!1,pending:!1,valid:!0,validated:!!t.unref(r).length,initialValue:t.computed((()=>t.unref(n))),dirty:t.computed((()=>!O(t.unref(e),t.unref(n))))});return t.watch(r,(e=>{a.valid=!e.length}),{immediate:!0,flush:"sync"}),a}(r,a,l);return{id:Z>=Number.MAX_SAFE_INTEGER?0:++Z,path:e,value:r,initialValue:a,meta:s,errors:l,errorMessage:i,setState:function(e){var t;"value"in e&&(r.value=e.value),"errors"in e&&o(e.errors),"touched"in e&&(s.touched=null!==(t=e.touched)&&void 0!==t?t:s.touched),"initialValue"in e&&u(e.initialValue)}}}function te(e,n,r){const a=t.ref(t.unref(n));function u(){return r?E(r.meta.value.initialValues,t.unref(e),t.unref(a)):t.unref(a)}function i(n){r?r.stageInitialValue(t.unref(e),n,!0):a.value=n}const l=t.computed(u);if(!r){return{value:t.ref(u()),initialValue:l,setInitialValue:i}}const o=n?t.unref(n):E(r.values,t.unref(e),t.unref(l));r.stageInitialValue(t.unref(e),o,!0);return{value:t.computed({get:()=>E(r.values,t.unref(e)),set(n){r.setFieldValue(t.unref(e),n)}}),initialValue:l,setInitialValue:i}}function ne(e,n,r){return v(null==r?void 0:r.type)?function(e,n,r){const a=(null==r?void 0:r.standalone)?void 0:M(l),u=null==r?void 0:r.checkedValue,i=null==r?void 0:r.uncheckedValue;function o(e){const n=e.handleChange,r=t.computed((()=>{const n=t.unref(e.value),r=t.unref(u);return Array.isArray(n)?n.findIndex((e=>O(e,r)))>=0:O(r,n)}));function l(l,o=!0){var s;if(r.value===(null===(s=null==l?void 0:l.target)||void 0===s?void 0:s.checked))return void(o&&e.validate());let d=z(l);a||(d=R(t.unref(e.value),t.unref(u),t.unref(i))),n(d,o)}return Object.assign(Object.assign({},e),{checked:r,checkedValue:u,uncheckedValue:i,handleChange:l})}return o(re(e,n,r))}(e,n,r):re(e,n,r)}function re(e,r,a){const{initialValue:u,validateOnMount:i,bails:d,type:v,checkedValue:p,label:m,validateOnValueUpdate:h,uncheckedValue:y,controlled:g,keepValueOnUnmount:b,modelPropName:V,syncVModel:A,form:F}=function(e,t){const n=()=>({initialValue:void 0,validateOnMount:!1,bails:!0,label:e,validateOnValueUpdate:!0,keepValueOnUnmount:void 0,modelPropName:"modelValue",syncVModel:!0,controlled:!0});if(!t)return n();const r="valueProp"in t?t.valueProp:t.checkedValue,a="standalone"in t?!t.standalone:t.controlled;return Object.assign(Object.assign(Object.assign({},n()),t||{}),{controlled:null==a||a,checkedValue:r})}(t.unref(e),a),j=g?M(l):void 0,S=F||j;let k=!1;const{id:B,value:C,initialValue:T,meta:R,setState:x,errors:_,errorMessage:U}=ee(e,{modelValue:u,form:S});A&&function({prop:e,value:n,handleChange:r}){const a=t.getCurrentInstance();if(!a)return;const u=e||"modelValue",i=`update:${u}`;if(!(u in a.props))return;t.watch(n,(e=>{O(e,ae(a,u))||a.emit(i,e)})),t.watch((()=>ae(a,u)),(e=>{if(e===s&&void 0===n.value)return;const t=e===s?void 0:e;O(t,N(n.value,a.props.modelModifiers))||r(t)}))}({value:C,prop:V,handleChange:G});const $=t.computed((()=>{let a=t.unref(r);const u=t.unref(null==S?void 0:S.schema);return u&&!f(u)&&(a=function(e,t){if(!e)return;return e[t]}(u,t.unref(e))||a),f(a)||n(a)||Array.isArray(a)?a:q(a)}));async function D(n){var r,a;return(null==S?void 0:S.validateSchema)?null!==(r=(await S.validateSchema(n)).results[t.unref(e)])&&void 0!==r?r:{valid:!0,errors:[]}:J(C.value,$.value,{name:t.unref(m)||t.unref(e),values:null!==(a=null==S?void 0:S.values)&&void 0!==a?a:{},bails:d})}const L=P((async()=>(R.pending=!0,R.validated=!0,D("validated-only"))),(e=>(k&&(e.valid=!0,e.errors=[]),x({errors:e.errors}),R.pending=!1,e))),K=P((async()=>D("silent")),(e=>(k&&(e.valid=!0),R.valid=e.valid,e)));function G(e,t=!0){const n=z(e);C.value=n,!h&&t&&L()}let X;t.onMounted((()=>{if(i)return L();S&&S.validateSchema||K()}));let H=w(C.value);function Q(){X=t.watch(C,((e,t)=>{if(O(e,t)&&O(e,H))return;(h?L:K)(),H=w(e)}),{deep:!0})}function W(e){var n;null==X||X();const r=e&&"value"in e?e.value:T.value;x({value:w(r),initialValue:w(r),touched:null!==(n=null==e?void 0:e.touched)&&void 0!==n&&n,errors:(null==e?void 0:e.errors)||[]}),R.pending=!1,R.validated=!1,K(),t.nextTick((()=>{Q()}))}Q();const Y={id:B,name:e,label:m,value:C,meta:R,errors:_,errorMessage:U,type:v,checkedValue:p,uncheckedValue:y,bails:d,keepValueOnUnmount:b,resetField:W,handleReset:()=>W(),validate:function(e){return"silent"===(null==e?void 0:e.mode)?K():L()},handleChange:G,handleBlur:()=>{R.touched=!0},setState:x,setTouched:function(e){R.touched=e},setErrors:function(e){x({errors:Array.isArray(e)?e:[e]})},setValue:function(e){C.value=e}};if(t.provide(o,Y),t.isRef(r)&&"function"!=typeof t.unref(r)&&t.watch(r,((e,t)=>{O(e,t)||(R.validated?L():K())}),{deep:!0}),!S)return Y;S.register(Y),t.onBeforeUnmount((()=>{k=!0,S.unregister(Y)}));const Z=t.computed((()=>{const e=$.value;return!e||n(e)||f(e)||Array.isArray(e)?{}:Object.keys(e).reduce(((t,n)=>{const r=(a=e[n],Array.isArray(a)?a.filter(c):I(a).filter((e=>c(a[e]))).map((e=>a[e]))).map((e=>e.__locatorRef)).reduce(((e,t)=>{const n=E(S.values,t)||S.values[t];return void 0!==n&&(e[t]=n),e}),{});var a;return Object.assign(t,r),t}),{})}));return t.watch(Z,((e,t)=>{if(!Object.keys(e).length)return;!O(e,t)&&(R.validated?L():K())})),Y}function ae(e,t){return e.props[t]}function ue(e,t){let n=e.as||"";return e.as||t.slots.default||(n="input"),n}function ie(e,t){return v(t.attrs.type)?V(e,"modelValue")?e.modelValue:void 0:V(e,"modelValue")?e.modelValue:t.attrs.value}const le=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:()=>X().bails},label:{type:String,default:void 0},uncheckedValue:{type:null,default:void 0},modelValue:{type:null,default:s},modelModifiers:{type:null,default:()=>({})},"onUpdate:modelValue":{type:null,default:void 0},standalone:{type:Boolean,default:!1},keepValue:{type:Boolean,default:void 0}},setup(e,n){const r=t.toRef(e,"rules"),a=t.toRef(e,"name"),u=t.toRef(e,"label"),i=t.toRef(e,"uncheckedValue"),l=t.toRef(e,"keepValue"),{errors:o,value:s,errorMessage:d,validate:c,handleChange:f,handleBlur:p,setTouched:m,resetField:h,handleReset:g,meta:b,checked:V,setErrors:O}=ne(a,r,{validateOnMount:e.validateOnMount,bails:e.bails,standalone:e.standalone,type:n.attrs.type,initialValue:ie(e,n),checkedValue:n.attrs.value,uncheckedValue:i,label:u,validateOnValueUpdate:!1,keepValueOnUnmount:l}),A=function(e,t=!0){f(e,t),n.emit("update:modelValue",s.value)},F=function(e){(e=>{v(n.attrs.type)||(s.value=z(e))})(e),n.emit("update:modelValue",s.value)},w=t.computed((()=>{const{validateOnInput:t,validateOnChange:r,validateOnBlur:a,validateOnModelUpdate:u}=function(e){var t,n,r,a;const{validateOnInput:u,validateOnChange:i,validateOnBlur:l,validateOnModelUpdate:o}=X();return{validateOnInput:null!==(t=e.validateOnInput)&&void 0!==t?t:u,validateOnChange:null!==(n=e.validateOnChange)&&void 0!==n?n:i,validateOnBlur:null!==(r=e.validateOnBlur)&&void 0!==r?r:l,validateOnModelUpdate:null!==(a=e.validateOnModelUpdate)&&void 0!==a?a:o}}(e),i=[p,n.attrs.onBlur,a?c:void 0].filter(Boolean),l=[e=>A(e,t),n.attrs.onInput].filter(Boolean),o=[e=>A(e,r),n.attrs.onChange].filter(Boolean),d={name:e.name,onBlur:i,onInput:l,onChange:o,"onUpdate:modelValue":e=>A(e,u)};v(n.attrs.type)&&V&&(d.checked=V.value);return y(ue(e,n),n.attrs)&&(d.value=s.value),d}));function j(){return{field:w.value,value:s.value,meta:b,errors:o.value,errorMessage:d.value,validate:c,resetField:h,handleChange:A,handleInput:F,handleReset:g,handleBlur:p,setTouched:m,setErrors:O}}return n.expose({setErrors:O,setTouched:m,reset:h,validate:c,handleChange:f}),()=>{const r=t.resolveDynamicComponent(ue(e,n)),a=U(r,n,j);return r?t.h(r,Object.assign(Object.assign({},n.attrs),w.value),a):a}}});let oe=0;function se(e){var n;const r=oe++,a=new Set;let u=!1;const i=t.ref({}),o=t.ref(!1),s=t.ref(0),d=[],c=t.reactive(w(t.unref(null==e?void 0:e.initialValues)||{})),{errorBag:v,setErrorBag:m,setFieldErrorBag:h}=function(e){const n=t.ref({});function r(e){return Array.isArray(e)?e:e?[e]:[]}function a(e,t){t?n.value[e]=r(t):delete n.value[e]}function u(e){n.value=I(e).reduce(((t,n)=>{const a=e[n];return a&&(t[n]=r(a)),t}),{})}e&&u(e);return{errorBag:n,setErrorBag:u,setFieldErrorBag:a}}(null==e?void 0:e.initialErrors),y=t.computed((()=>I(v.value).reduce(((e,t)=>{const n=v.value[t];return n&&n.length&&(e[t]=n[0]),e}),{})));function b(e){const t=i.value[e];return Array.isArray(t)?t[0]:t}function V(e){return!!i.value[e]}const A=t.computed((()=>I(i.value).reduce(((e,n)=>{const r=b(n);return r&&(e[n]=t.unref(r.label||r.name)||""),e}),{}))),F=t.computed((()=>I(i.value).reduce(((e,t)=>{var n;const r=b(t);return r&&(e[t]=null===(n=r.bails)||void 0===n||n),e}),{}))),j=Object.assign({},(null==e?void 0:e.initialErrors)||{}),k=null!==(n=null==e?void 0:e.keepValuesOnUnmount)&&void 0!==n&&n,{initialValues:M,originalInitialValues:C,setInitialValues:T}=function(e,n,r){const a=t.ref(w(t.unref(r))||{}),u=t.ref(w(t.unref(r))||{});function i(t,r=!1){a.value=w(t),u.value=w(t),r&&I(e.value).forEach((t=>{const r=e.value[t],u=Array.isArray(r)?r.some((e=>e.meta.touched)):null==r?void 0:r.meta.touched;if(!r||u)return;const i=E(a.value,t);S(n,t,w(i))}))}t.isRef(r)&&t.watch(r,(e=>{i(e,!0)}),{deep:!0});return{initialValues:a,originalInitialValues:u,setInitialValues:i}}(i,c,null==e?void 0:e.initialValues),N=function(e,n,r,a){const u={touched:"some",pending:"some",valid:"every"},i=t.computed((()=>!O(n,t.unref(r))));function l(){const t=Object.values(e.value).flat(1).filter(Boolean);return I(u).reduce(((e,n)=>{const r=u[n];return e[n]=t[r]((e=>e.meta[n])),e}),{})}const o=t.reactive(l());return t.watchEffect((()=>{const e=l();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&&!I(a.value).length,dirty:i.value})))}(i,c,C,y),_=t.computed((()=>[...a,...I(i.value)].reduce(((e,t)=>(S(e,t,E(c,t)),e)),{}))),U=null==e?void 0:e.validationSchema,$=x(ce,5),D=x(ce,5),z=P((async e=>"silent"===await e?$():D()),((e,[t])=>{const n=K.fieldsByPath.value||{},r=I(K.errorBag.value);return[...new Set([...I(e.results),...I(n),...r])].reduce(((r,a)=>{const u=n[a],i=(e.results[a]||{errors:[]}).errors,l={errors:i,valid:!i.length};if(r.results[a]=l,l.valid||(r.errors[a]=l.errors[0]),!u)return J(a,i),r;if(X(u,(e=>e.meta.valid=l.valid)),"silent"===t)return r;const o=Array.isArray(u)?u.some((e=>e.meta.validated)):u.meta.validated;return"validated-only"!==t||o?(X(u,(e=>e.setState({errors:l.errors}))),r):r}),{valid:e.valid,results:{},errors:{}})}));function q(e){return function(t,n){return function(r){return r instanceof Event&&(r.preventDefault(),r.stopPropagation()),re(I(i.value).reduce(((e,t)=>(e[t]=!0,e)),{})),o.value=!0,s.value++,le().then((a=>{const u=w(c);if(a.valid&&"function"==typeof t){const n=w(_.value);return t(e?n:u,{evt:r,controlledValues:n,setErrors:Q,setFieldError:J,setTouched:re,setFieldTouched:ne,setValues:Z,setFieldValue:W,resetForm:ae})}a.valid||"function"!=typeof n||n({values:u,evt:r,errors:a.errors,results:a.results})})).then((e=>(o.value=!1,e)),(e=>{throw o.value=!1,e}))}}}const L=q(!1);L.withControlled=q(!0);const K={formId:r,fieldsByPath:i,values:c,controlledValues:_,errorBag:v,errors:y,schema:U,submitCount:s,meta:N,isSubmitting:o,fieldArrays:d,keepValuesOnUnmount:k,validateSchema:t.unref(U)?z:void 0,validate:le,register:function(e){const n=t.unref(e.name);ue(e,n),t.isRef(e.name)&&t.watch(e.name,(async(n,r)=>{await t.nextTick(),ie(e,r),ue(e,n),(y.value[r]||y.value[n])&&(J(r,void 0),se(n)),await t.nextTick(),V(r)||B(c,r)}));const r=t.unref(e.errorMessage);r&&(null==j?void 0:j[n])!==r&&se(n);delete j[n]},unregister:function(e){const n=t.unref(e.name),r=i.value[n],a=!!r&&G(r);ie(e,n),t.nextTick((()=>{var u;const l=null!==(u=t.unref(e.keepValueOnUnmount))&&void 0!==u?u:t.unref(k),o=E(c,n);if(a&&(r===i.value[n]||!i.value[n])&&!l)if(Array.isArray(o)){const r=o.findIndex((n=>O(n,t.unref(e.checkedValue))));if(r>-1){const e=[...o];e.splice(r,1),W(n,e,{force:!0})}}else o===t.unref(e.checkedValue)&&B(c,n);if(!V(n)){if(J(n,void 0),l)return;if(a&&Array.isArray(o)&&!p(o))return;B(c,n)}}))},setFieldErrorBag:h,validateField:se,setFieldValue:W,setValues:Z,setErrors:Q,setFieldError:J,setFieldTouched:ne,setTouched:re,resetForm:ae,handleSubmit:L,stageInitialValue:function(t,n,r=!1){S(c,t,n),de(t,n),r&&!(null==e?void 0:e.initialValues)&&S(C.value,t,w(n))},unsetInitialValue:function(e){B(M.value,e)},setFieldInitialValue:de,useFieldModel:function(e){if(!Array.isArray(e))return ee(e);return e.map(ee)}};function G(e){return Array.isArray(e)}function X(e,t){return Array.isArray(e)?e.forEach(t):t(e)}function H(e){Object.values(i.value).forEach((t=>{t&&X(t,e)}))}function J(e,t){h(e,t)}function Q(e){m(e)}function W(e,n,{force:r}={force:!1}){var a;const l=i.value[e],o=w(n);if(!l)return void S(c,e,o);if(G(l)&&"checkbox"===(null===(a=l[0])||void 0===a?void 0:a.type)&&!Array.isArray(n)){const t=w(R(E(c,e)||[],n,void 0));return void S(c,e,t)}let s=n;G(l)||"checkbox"!==l.type||r||u||(s=w(R(E(c,e),n,t.unref(l.uncheckedValue)))),S(c,e,s)}function Z(e){I(c).forEach((e=>{delete c[e]})),I(e).forEach((t=>{W(t,e[t])})),d.forEach((e=>e&&e.reset()))}function ee(e){const{value:n}=te(e,void 0,K);return t.watch(n,(()=>{V(t.unref(e))||le({mode:"validated-only"})}),{deep:!0}),a.add(t.unref(e)),n}function ne(e,t){const n=i.value[e];n&&X(n,(e=>e.setTouched(t)))}function re(e){I(e).forEach((t=>{ne(t,!!e[t])}))}function ae(e){u=!0,H((e=>e.resetField())),(null==e?void 0:e.values)?(T(e.values),Z(null==e?void 0:e.values)):(T(C.value),Z(C.value)),(null==e?void 0:e.touched)&&re(e.touched),Q((null==e?void 0:e.errors)||{}),s.value=(null==e?void 0:e.submitCount)||0,t.nextTick((()=>{u=!1}))}function ue(e,n){const r=t.markRaw(e),a=n;if(!i.value[a])return void(i.value[a]=r);const u=i.value[a];u&&!Array.isArray(u)&&(i.value[a]=[u]),i.value[a]=[...i.value[a],r]}function ie(e,t){const n=t,r=i.value[n];if(r)if(G(r)||e.id!==r.id){if(G(r)){const t=r.findIndex((t=>t.id===e.id));if(-1===t)return;r.splice(t,1),r.length||delete i.value[n]}}else delete i.value[n]}async function le(e){if(H((e=>e.meta.validated=!0)),K.validateSchema)return K.validateSchema((null==e?void 0:e.mode)||"force");const n=await Promise.all(Object.values(i.value).map((n=>{const r=Array.isArray(n)?n[0]:n;return r?r.validate(e).then((e=>({key:t.unref(r.name),valid:e.valid,errors:e.errors}))):Promise.resolve({key:"",valid:!0,errors:[]})}))),r={},a={};for(const e of n)r[e.key]={valid:e.valid,errors:e.errors},e.errors.length&&(a[e.key]=e.errors[0]);return{valid:n.every((e=>e.valid)),results:r,errors:a}}async function se(e){const n=i.value[e];return n?Array.isArray(n)?n.map((e=>e.validate()))[0]:n.validate():(t.warn(`field with name ${e} was not found`),Promise.resolve({errors:[],valid:!0}))}function de(e,t){S(M.value,e,w(t))}async function ce(){const e=t.unref(U);if(!e)return{valid:!0,results:{},errors:{}};const n=f(e)?await async function(e,t){const n=await e.validate(t,{abortEarly:!1}).then((()=>[])).catch((e=>{if("ValidationError"!==e.name)throw e;return e.inner||[]})),r={},a={};for(const e of n){const t=e.errors;r[e.path]={valid:!t.length,errors:t},t.length&&(a[e.path]=t[0])}return{valid:!n.length,results:r,errors:a}}(e,c):await Y(e,c,{names:A.value,bailsMap:F.value});return n}const fe=L(((e,{evt:t})=>{g(t)&&t.target.submit()}));return t.onMounted((()=>{(null==e?void 0:e.initialErrors)&&Q(e.initialErrors),(null==e?void 0:e.initialTouched)&&re(e.initialTouched),(null==e?void 0:e.validateOnMount)?le():K.validateSchema&&K.validateSchema("silent")})),t.isRef(U)&&t.watch(U,(()=>{var e;null===(e=K.validateSchema)||void 0===e||e.call(K,"validated-only")})),t.provide(l,K),Object.assign(Object.assign({},K),{handleReset:()=>ae(),submitForm:fe})}const de=t.defineComponent({name:"Form",inheritAttrs:!1,props:{as:{type:String,default:"form"},validationSchema:{type:Object,default:void 0},initialValues:{type:Object,default:void 0},initialErrors:{type:Object,default:void 0},initialTouched:{type:Object,default:void 0},validateOnMount:{type:Boolean,default:!1},onSubmit:{type:Function,default:void 0},onInvalidSubmit:{type:Function,default:void 0},keepValues:{type:Boolean,default:!1}},setup(e,n){const r=t.toRef(e,"initialValues"),a=t.toRef(e,"validationSchema"),u=t.toRef(e,"keepValues"),{errors:i,values:l,meta:o,isSubmitting:s,submitCount:d,controlledValues:c,validate:f,validateField:v,handleReset:p,resetForm:m,handleSubmit:h,setErrors:y,setFieldError:V,setFieldValue:O,setValues:A,setFieldTouched:F,setTouched:w}=se({validationSchema:a.value?a:void 0,initialValues:r,initialErrors:e.initialErrors,initialTouched:e.initialTouched,validateOnMount:e.validateOnMount,keepValuesOnUnmount:u}),j=h(((e,{evt:t})=>{g(t)&&t.target.submit()}),e.onInvalidSubmit),E=e.onSubmit?h(e.onSubmit,e.onInvalidSubmit):j;function S(e){b(e)&&e.preventDefault(),p(),"function"==typeof n.attrs.onReset&&n.attrs.onReset()}function k(t,n){return h("function"!=typeof t||n?n:t,e.onInvalidSubmit)(t)}function B(){return{meta:o.value,errors:i.value,values:l,isSubmitting:s.value,submitCount:d.value,controlledValues:c.value,validate:f,validateField:v,handleSubmit:k,handleReset:p,submitForm:j,setErrors:y,setFieldError:V,setFieldValue:O,setValues:A,setFieldTouched:F,setTouched:w,resetForm:m}}return n.expose({setFieldError:V,setErrors:y,setFieldValue:O,setValues:A,setFieldTouched:F,setTouched:w,resetForm:m,validate:f,validateField:v}),function(){const r="form"===e.as?e.as:t.resolveDynamicComponent(e.as),a=U(r,n,B);if(!e.as)return a;const u="form"===e.as?{novalidate:!0}:{};return t.h(r,Object.assign(Object.assign(Object.assign({},u),n.attrs),{onSubmit:E,onReset:S}),a)}}}),ce=de;function fe(e){const n=M(l,void 0),a=t.ref([]),u=()=>{},i={fields:a,remove:u,push:u,swap:u,insert:u,update:u,replace:u,prepend:u,move:u};if(!n)return C("FieldArray requires being a child of `<Form/>` or `useForm` being called before it. Array fields may not work correctly"),i;if(!t.unref(e))return C("FieldArray requires a field path to be provided, did you forget to pass the `name` prop?"),i;const o=n.fieldArrays.find((n=>t.unref(n.path)===t.unref(e)));if(o)return o;let s=0;function d(){const r=E(null==n?void 0:n.values,t.unref(e),[])||[];a.value=r.map(f),c()}function c(){const e=a.value.length;for(let t=0;t<e;t++){const n=a.value[t];n.isFirst=0===t,n.isLast=t===e-1}}function f(r){const u=s++,i={key:u,value:_({get(){const i=E(null==n?void 0:n.values,t.unref(e),[])||[],l=a.value.findIndex((e=>e.key===u));return-1===l?r:i[l]},set(e){const t=a.value.findIndex((e=>e.key===u));-1!==t?v(t,e):C("Attempting to update a non-existent array item")}}),isFirst:!1,isLast:!1};return i}function v(r,a){const u=t.unref(e),i=E(null==n?void 0:n.values,u);!Array.isArray(i)||i.length-1<r||(null==n||n.setFieldValue(`${u}[${r}]`,a),null==n||n.validate({mode:"validated-only"}))}d();const p={fields:a,remove:function(r){const u=t.unref(e),i=E(null==n?void 0:n.values,u);if(!i||!Array.isArray(i))return;const l=[...i];l.splice(r,1),null==n||n.unsetInitialValue(u+`[${r}]`),null==n||n.setFieldValue(u,l),a.value.splice(r,1),c()},push:function(u){const i=t.unref(e),l=E(null==n?void 0:n.values,i),o=r(l)?[]:l;if(!Array.isArray(o))return;const s=[...o];s.push(u),null==n||n.stageInitialValue(i+`[${s.length-1}]`,u),null==n||n.setFieldValue(i,s),a.value.push(f(u)),c()},swap:function(r,u){const i=t.unref(e),l=E(null==n?void 0:n.values,i);if(!Array.isArray(l)||!(r in l)||!(u in l))return;const o=[...l],s=[...a.value],d=o[r];o[r]=o[u],o[u]=d;const f=s[r];s[r]=s[u],s[u]=f,null==n||n.setFieldValue(i,o),a.value=s,c()},insert:function(r,u){const i=t.unref(e),l=E(null==n?void 0:n.values,i);if(!Array.isArray(l)||l.length<r)return;const o=[...l],s=[...a.value];o.splice(r,0,u),s.splice(r,0,f(u)),null==n||n.setFieldValue(i,o),a.value=s,c()},update:v,replace:function(r){const a=t.unref(e);null==n||n.setFieldValue(a,r),d()},prepend:function(u){const i=t.unref(e),l=E(null==n?void 0:n.values,i),o=r(l)?[]:l;if(!Array.isArray(o))return;const s=[u,...o];null==n||n.stageInitialValue(i+`[${s.length-1}]`,u),null==n||n.setFieldValue(i,s),a.value.unshift(f(u)),c()},move:function(u,i){const l=t.unref(e),o=E(null==n?void 0:n.values,l),s=r(o)?[]:[...o];if(!Array.isArray(o)||!(u in o)||!(i in o))return;const d=[...a.value],f=d[u];d.splice(u,1),d.splice(i,0,f);const v=s[u];s.splice(u,1),s.splice(i,0,v),null==n||n.setFieldValue(l,s),a.value=d,c()}};return n.fieldArrays.push(Object.assign({path:e,reset:d},p)),t.onBeforeUnmount((()=>{const r=n.fieldArrays.findIndex((n=>t.unref(n.path)===t.unref(e)));r>=0&&n.fieldArrays.splice(r,1)})),p}const ve=t.defineComponent({name:"FieldArray",inheritAttrs:!1,props:{name:{type:String,required:!0}},setup(e,n){const{push:r,remove:a,swap:u,insert:i,replace:l,update:o,prepend:s,move:d,fields:c}=fe(t.toRef(e,"name"));function f(){return{fields:c.value,push:r,remove:a,swap:u,insert:i,update:o,replace:l,prepend:s,move:d}}return n.expose({push:r,remove:a,swap:u,insert:i,update:o,replace:l,prepend:s,move:d}),()=>U(void 0,n,f)}}),pe=t.defineComponent({name:"ErrorMessage",props:{as:{type:String,default:void 0},name:{type:String,required:!0}},setup(e,n){const r=t.inject(l,void 0),a=t.computed((()=>null==r?void 0:r.errors.value[e.name]));function u(){return{message:a.value}}return()=>{if(!a.value)return;const r=e.as?t.resolveDynamicComponent(e.as):e.as,i=U(r,n,u),l=Object.assign({role:"alert"},n.attrs);return r||!Array.isArray(i)&&i||!(null==i?void 0:i.length)?!Array.isArray(i)&&i||(null==i?void 0:i.length)?t.h(r,l,i):t.h(r||"span",l,a.value):i}}});e.ErrorMessage=pe,e.Field=le,e.FieldArray=ve,e.FieldContextKey=o,e.Form=ce,e.FormContextKey=l,e.IS_ABSENT=s,e.configure=H,e.defineRule=function(e,t){!function(e,t){if(n(t))return;throw new Error(`Extension Error: The validator '${e}' must be a function.`)}(e,t),i[e]=t},e.useField=ne,e.useFieldArray=fe,e.useFieldError=function(e){const n=M(l),r=e?void 0:t.inject(o);return t.computed((()=>e?null==n?void 0:n.errors.value[t.unref(e)]:null==r?void 0:r.errorMessage.value))},e.useFieldValue=function(e){const n=M(l),r=e?void 0:t.inject(o);return t.computed((()=>e?E(null==n?void 0:n.values,t.unref(e)):t.unref(null==r?void 0:r.value)))},e.useForm=se,e.useFormErrors=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.errors.value)||{}))},e.useFormValues=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>(null==e?void 0:e.values)||{}))},e.useIsFieldDirty=function(e){const n=M(l);let r=e?void 0:t.inject(o);return t.computed((()=>(e&&(r=T(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.dirty:(C(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldTouched=function(e){const n=M(l);let r=e?void 0:t.inject(o);return t.computed((()=>(e&&(r=T(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.touched:(C(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFieldValid=function(e){const n=M(l);let r=e?void 0:t.inject(o);return t.computed((()=>(e&&(r=T(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.meta.valid:(C(`field with name ${t.unref(e)} was not found`),!1))))},e.useIsFormDirty=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.dirty)&&void 0!==t&&t}))},e.useIsFormTouched=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.touched)&&void 0!==t&&t}))},e.useIsFormValid=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.meta.value.valid)&&void 0!==t&&t}))},e.useIsSubmitting=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.isSubmitting.value)&&void 0!==t&&t}))},e.useResetForm=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(t){if(e)return e.resetForm(t)}},e.useSubmitCount=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),t.computed((()=>{var t;return null!==(t=null==e?void 0:e.submitCount.value)&&void 0!==t?t:0}))},e.useSubmitForm=function(e){const t=M(l);t||C("No vee-validate <Form /> or `useForm` was detected in the component tree");const n=t?t.handleSubmit(e):void 0;return function(e){if(n)return n(e)}},e.useValidateField=function(e){const n=M(l);let r=e?void 0:t.inject(o);return function(){return e&&(r=T(null==n?void 0:n.fieldsByPath.value[t.unref(e)])),r?r.validate():(C(`field with name ${t.unref(e)} was not found`),Promise.resolve({errors:[],valid:!0}))}},e.useValidateForm=function(){const e=M(l);return e||C("No vee-validate <Form /> or `useForm` was detected in the component tree"),function(){return e?e.validate():Promise.resolve({results:{},errors:{},valid:!0})}},e.validate=J,Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "vee-validate", | ||
"version": "4.7.0", | ||
"version": "4.7.1", | ||
"description": "Form Validation for Vue.js", | ||
@@ -36,3 +36,3 @@ "author": "Abdelrahman Awad <logaretm1@gmail.com>", | ||
}, | ||
"gitHead": "45e0b22343b4bb60422b21179b156b9a2c342054" | ||
"gitHead": "ab1330bf3c2309d00bd43ebf824789a1cc1ae077" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
314989
7188