1
0
mirror of synced 2024-11-25 06:46:02 +03:00
vue-formulario/dist/formulario.esm.js
2020-10-23 14:15:57 +03:00

16 lines
22 KiB
JavaScript

import t from"is-url";import e from"is-plain-object";import r from"vue";import{Model as i,Prop as o,Provide as s,Watch as a,Component as n,Inject as l}from"vue-property-decorator";function u(t,e){if(t===e)return!0;if(!t||!e)return!1;const r=Object.keys(t);if(Object.keys(e).length!==r.length)return!1;if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(0===r.length)return t===e;for(let i=0;i<r.length;i++){const o=r[i];if(t[o]!==e[o])return!1}return!0}function d(t){return"string"==typeof t?t.replace(/([_][a-z0-9])/gi,e=>0!==t.indexOf(e)&&"_"!==t[t.indexOf(e)-1]?e.toUpperCase().replace("_",""):e):t}function h(t){return"string"==typeof t&&/^[\^]/.test(t.charAt(0))?[d(t.substr(1)),t.charAt(0)]:[d(t),null]}function c(t){return t?"string"==typeof t?[t]:Array.isArray(t)?t:"object"==typeof t?Object.values(t):[]:[]}function p(t,e){return"string"==typeof t?p(t.split("|").filter(t=>t.length),e):Array.isArray(t)?t.map(t=>function(t,e){if("function"==typeof t)return[t,[]];if(Array.isArray(t)&&t.length){t=t.slice();const[r,i]=h(t.shift());if("string"==typeof r&&Object.prototype.hasOwnProperty.call(e,r))return[e[r],t,r,i];if("function"==typeof r)return[r,t,r,i]}if("string"==typeof t){const r=t.split(":"),[i,o]=h(r.shift());if(Object.prototype.hasOwnProperty.call(e,i))return[e[i],r.length?r.join(":").split(","):[],i,o];throw new Error("Unknown validation rule "+t)}return!1}(t,e)).filter(t=>!!t):[]}function f(t){switch(typeof t){case"symbol":case"number":case"string":case"boolean":case"undefined":return!0;default:return null===t}}function m(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function v(t,e){const r=e.split(".");let i=t;for(const t in r){const e=r[t].match(/(.+)\[(\d+)\]$/);if(void 0===i)return null;if(e){if(i=i[e[1]],void 0===i)return null;i=i[e[2]]}else i=i[r[t]]}return i}var g={accepted:({value:t})=>Promise.resolve(["yes","on","1",1,!0,"true"].includes(t)),after({value:t},e=!1){const r=!1!==e?Date.parse(e):Date.now(),i=t instanceof Date?t.getTime():Date.parse(t);return Promise.resolve(!isNaN(i)&&i>r)},alpha({value:t},e="default"){const r={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=m(r,e)?e:"default";return Promise.resolve(r[i].test(t))},alphanumeric({value:t},e="default"){const r={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=m(r,e)?e:"default";return Promise.resolve(r[i].test(t))},before({value:t},e=!1){const r=!1!==e?Date.parse(e):Date.now(),i=t instanceof Date?t.getTime():Date.parse(t);return Promise.resolve(!isNaN(i)&&i<r)},between:({value:t},e=0,r=10,i)=>Promise.resolve(null!==e&&null!==r&&!isNaN(e)&&!isNaN(r)&&(!isNaN(Number(t))&&"length"!==i||"value"===i?(t=Number(t),e=Number(e),r=Number(r),t>e&&t<r):("string"==typeof t||"length"===i)&&(t=isNaN(Number(t))?t:t.toString()).length>e&&t.length<r)),confirm:({value:t,getFormValues:e,name:r},i)=>Promise.resolve((()=>{let o=i;return o||(o=/_confirm$/.test(r)?r.substr(0,r.length-8):r+"_confirm"),e()[o]===t})()),date:({value:t},e=!1)=>Promise.resolve(e?function(t){const e=`^${r=t,r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`;var r;const i={MM:"(0[1-9]|1[012])",M:"([1-9]|1[012])",DD:"([012][1-9]|3[01])",D:"([012]?[1-9]|3[01])",YYYY:"\\d{4}",YY:"\\d{2}"};return new RegExp(Object.keys(i).reduce((t,e)=>t.replace(e,i[e]),e))}(e).test(t):!isNaN(Date.parse(t))),email({value:t}){if(!t)return Promise.resolve(!0);return Promise.resolve(/^(([^<>()\[\].,;:\s@"]+(\.[^<>()\[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i.test(t))},endsWith:({value:t},...e)=>t?"string"==typeof t?Promise.resolve(0===e.length||e.some(e=>t.endsWith(e))):Promise.resolve(!1):Promise.resolve(!0),in:({value:t},...e)=>Promise.resolve(e.some(e=>"object"==typeof e?u(e,t):e===t)),matches:({value:t},...e)=>Promise.resolve(!!e.find(e=>("string"==typeof e&&"/"===e.substr(0,1)&&"/"===e.substr(-1)&&(e=new RegExp(e.substr(1,e.length-2))),e instanceof RegExp?e.test(t):e===t))),min:({value:t},e=1,r)=>Promise.resolve(Array.isArray(t)?(e=isNaN(e)?e:Number(e),t.length>=e):!isNaN(t)&&"length"!==r||"value"===r?(t=isNaN(t)?t:Number(t))>=e:("string"==typeof t||"length"===r)&&(t=isNaN(t)?t:t.toString()).length>=e),max:({value:t},e=10,r)=>Promise.resolve(Array.isArray(t)?(e=isNaN(Number(e))?e:Number(e),t.length<=e):!isNaN(t)&&"length"!==r||"value"===r?(t=isNaN(t)?t:Number(t))<=e:("string"==typeof t||"length"===r)&&(t=isNaN(t)?t:t.toString()).length<=e),not:({value:t},...e)=>Promise.resolve(!e.some(e=>"object"==typeof e?u(e,t):e===t)),number:({value:t})=>Promise.resolve(String(t).length>0&&!isNaN(Number(t))),required:({value:t},e=!0)=>Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(t)?!t.length:"string"==typeof t?!t:!("object"!=typeof t||t&&Object.keys(t).length)))),startsWith:({value:t},...e)=>t?"string"==typeof t?Promise.resolve(0===e.length||e.some(e=>t.startsWith(e))):Promise.resolve(!1):Promise.resolve(!0),url:({value:e})=>Promise.resolve(t(e)),bail:()=>Promise.resolve(!0)},y={default:(t,e)=>t.$t("validation.default",e),accepted:(t,e)=>t.$t("validation.accepted",e),after:(t,e)=>Array.isArray(e.args)&&e.args.length?t.$t("validation.after.compare",e):t.$t("validation.after.default",e),alpha:(t,e)=>t.$t("validation.alpha",e),alphanumeric:(t,e)=>t.$t("validation.alphanumeric",e),before:(t,e)=>Array.isArray(e.args)&&e.args.length?t.$t("validation.before.compare",e):t.$t("validation.before.default",e),between(t,e){const r=!(!Array.isArray(e.args)||!e.args[2])&&e.args[2];return!isNaN(e.value)&&"length"!==r||"value"===r?t.$t("validation.between.force",e):t.$t("validation.between.default",e)},confirm:(t,e)=>t.$t("validation.confirm",e),date:(t,e)=>Array.isArray(e.args)&&e.args.length?t.$t("validation.date.format",e):t.$t("validation.date.default",e),email:(t,e)=>t.$t("validation.email.default",e),endsWith:(t,e)=>t.$t("validation.endsWith.default",e),in:function(t,e){return"string"==typeof e.value&&e.value?t.$t("validation.in.string",e):t.$t("validation.in.default",e)},matches:(t,e)=>t.$t("validation.matches.default",e),max(t,e){const r=e.args[0];if(Array.isArray(e.value))return t.$tc("validation.max.array",r,e);const i=!(!Array.isArray(e.args)||!e.args[1])&&e.args[1];return!isNaN(e.value)&&"length"!==i||"value"===i?t.$tc("validation.max.force",r,e):t.$tc("validation.max.default",r,e)},mime:(t,e)=>e.args[0]?t.$t("validation.mime.default",e):t.$t("validation.mime.no_formats_allowed",e),min(t,e){const r=e.args[0];if(Array.isArray(e.value))return t.$tc("validation.min.array",r,e);const i=!(!Array.isArray(e.args)||!e.args[1])&&e.args[1];return!isNaN(e.value)&&"length"!==i||"value"===i?t.$tc("validation.min.force",r,e):t.$tc("validation.min.default",r,e)},not:(t,e)=>t.$t("validation.not.default",e),number:(t,e)=>t.$t("validation.number.default",e),required:(t,e)=>t.$t("validation.required.default",e),startsWith:(t,e)=>t.$t("validation.startsWith.default",e),url:(t,e)=>t.$t("validation.url.default",e)};function b(t,r,i=!0){const o={};for(const s in t)m(r,s)?e(r[s])&&e(t[s])?o[s]=b(t[s],r[s],i):i&&Array.isArray(t[s])&&Array.isArray(r[s])?o[s]=t[s].concat(r[s]):o[s]=r[s]:o[s]=t[s];for(const t in r)m(o,t)||(o[t]=r[t]);return o}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function E(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);o<i.length;o++)e.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(r[i[o]]=t[i[o]])}return r}function $(t,e,r,i){var o,s=arguments.length,a=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,i);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(s<3?o(a):s>3?o(e,r,a):o(e,r))||a);return s>3&&a&&Object.defineProperty(e,r,a),a}class V{constructor(t){this.registry=new Map,this.ctx=t}add(t,e){this.registry.set(t,e)}remove(t){this.registry.delete(t);const e=this.ctx.proxy,r=t,i=(e[r],E(e,["symbol"==typeof r?r:r+""]));this.ctx.proxy=i}has(t){return this.registry.has(t)}hasNested(t){for(const e of this.registry.keys())if(e===t||e.includes(t+"."))return!0;return!1}get(t){return this.registry.get(t)}getNested(t){const e=new Map;for(const r of this.registry.keys())(r===t||r.includes(t+"."))&&e.set(r,this.registry.get(r));return e}map(t){const e={};return this.registry.forEach((r,i)=>Object.assign(e,{[i]:t(r,i)})),e}forEach(t){this.registry.forEach((e,r)=>{t(e,r)})}keys(){return Array.from(this.registry.keys())}register(t,e){if(this.registry.has(t))return;this.registry.set(t,e);const r=m(e.$options.propsData||{},"formularioValue"),i=m(e.$options.propsData||{},"value");!r&&this.ctx.hasInitialValue&&void 0!==v(this.ctx.initialValues,t)?e.context.model=v(this.ctx.initialValues,t):!r&&!i||u(e.proxy,v(this.ctx.initialValues,t))||this.ctx.setFieldValue(t,e.proxy),this.ctx.childrenShouldShowErrors&&(e.formShouldShowErrors=!0)}reduce(t,e){return this.registry.forEach((r,i)=>{e=t(e,r,i)}),e}}class x{constructor(t=[]){this.observers=[],this.observers=t}add(t){this.observers.some(e=>e.callback===t.callback)||this.observers.push(t)}remove(t){this.observers=this.observers.filter(e=>e.callback!==t)}filter(t){return new x(this.observers.filter(t))}some(t){return this.observers.some(t)}observe(t){this.observers.forEach(e=>{"form"===e.type?e.callback(t):e.field&&!Array.isArray(t)&&m(t,e.field)&&e.callback(t[e.field])})}}let F=class extends r{constructor(){super(...arguments),this.path="",this.proxy={},this.registry=new V(this),this.errorObserverRegistry=new x,this.localFormErrors=[],this.localFieldErrors={}}get mergedFormErrors(){return[...this.formErrors,...this.localFormErrors]}get mergedFieldErrors(){return b(this.errors||{},this.localFieldErrors)}get hasModel(){return m(this.$options.propsData||{},"formularioValue")}get hasInitialValue(){return this.formularioValue&&"object"==typeof this.formularioValue}get initialValues(){return this.hasModel&&"object"==typeof this.formularioValue?Object.assign({},this.formularioValue):{}}onFormularioValueChanged(t){this.hasModel&&t&&"object"==typeof t&&this.setValues(t)}onMergedFormErrorsChanged(t){this.errorObserverRegistry.filter(t=>"form"===t.type).observe(t)}onMergedFieldErrorsChanged(t){this.errorObserverRegistry.filter(t=>"input"===t.type).observe(t)}created(){this.initProxy()}getFormValues(){return this.proxy}onFormSubmit(){return this.hasValidationErrors().then(t=>t?void 0:function t(e){if("object"!=typeof e)return e;const r=Array.isArray(e)?[]:{};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(f(e[i])?r[i]=e[i]:r[i]=t(e[i]));return r}(this.proxy)).then(t=>{void 0!==t?this.$emit("submit",t):this.$emit("error")})}onFormularioFieldValidation(t){this.$emit("validation",t)}addErrorObserver(t){this.errorObserverRegistry.add(t),"form"===t.type?t.callback(this.mergedFormErrors):t.field&&m(this.mergedFieldErrors,t.field)&&t.callback(this.mergedFieldErrors[t.field])}removeErrorObserver(t){this.errorObserverRegistry.remove(t)}register(t,e){this.registry.register(t,e)}deregister(t){this.registry.remove(t)}initProxy(){this.hasInitialValue&&(this.proxy=this.initialValues)}setValues(t){const e=Array.from(new Set([...Object.keys(t),...Object.keys(this.proxy)]));let r=!1;e.forEach(e=>{this.registry.hasNested(e)&&this.registry.getNested(e).forEach((e,i)=>{const o=this.registry.get(i),s=v(this.proxy,i),a=v(t,i);u(a,s)||(this.setFieldValue(i,a,!1),r=!0),u(a,o.proxy)||(o.context.model=a)})}),this.initProxy(),r&&this.$emit("input",Object.assign({},this.proxy))}setFieldValue(t,e,r=!0){if(void 0===e){const e=this.proxy,r=t,i=(e[r],E(e,["symbol"==typeof r?r:r+""]));this.proxy=i}else!function(t,e,r){const i=e.split(".");let o=t;for(let t=0;t<i.length;t++){const e=i[t],s=e.match(/(.+)\[(\d+)\]$/);if(s){if(void 0===o[s[1]]&&(o[s[1]]=[]),o=o[s[1]],t===i.length-1){o[s[2]]=r;break}o=o[s[2]]}else{if(t===i.length-1){o[e]=r;break}void 0===o[e]&&(o[e]={}),o=o[e]}}}(this.proxy,t,e);r&&this.$emit("input",Object.assign({},this.proxy))}hasValidationErrors(){return Promise.all(this.registry.reduce((t,e)=>(t.push(e.performValidation()&&e.hasValidationErrors()),t),[])).then(t=>t.some(t=>t))}setErrors({formErrors:t,inputErrors:e}){this.localFormErrors=t||[],this.localFieldErrors=e||{}}resetValidation(){this.localFormErrors=[],this.localFieldErrors={},this.registry.forEach(t=>{t.resetValidation()})}};function O(t,e,r,i,o,s,a,n,l,u){"boolean"!=typeof a&&(l=n,n=a,a=!1);const d="function"==typeof r?r.options:r;let h;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),i&&(d._scopeId=i),s?(h=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,l(t)),t&&t._registeredComponents&&t._registeredComponents.add(s)},d._ssrRegister=h):e&&(h=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,n(t))}),h)if(d.functional){const t=d.render;d.render=function(e,r){return h.call(r),t(e,r)}}else{const t=d.beforeCreate;d.beforeCreate=t?[].concat(t,h):[h]}return r}$([i("input",{default:()=>({})})],F.prototype,"formularioValue",void 0),$([o({default:()=>({})})],F.prototype,"errors",void 0),$([o({default:()=>[]})],F.prototype,"formErrors",void 0),$([s()],F.prototype,"path",void 0),$([a("formularioValue",{deep:!0})],F.prototype,"onFormularioValueChanged",null),$([a("mergedFormErrors")],F.prototype,"onMergedFormErrorsChanged",null),$([a("mergedFieldErrors",{immediate:!0})],F.prototype,"onMergedFieldErrorsChanged",null),$([s()],F.prototype,"getFormValues",null),$([s()],F.prototype,"onFormularioFieldValidation",null),$([s()],F.prototype,"addErrorObserver",null),$([s()],F.prototype,"removeErrorObserver",null),$([s("formularioRegister")],F.prototype,"register",null),$([s("formularioDeregister")],F.prototype,"deregister",null),$([s("formularioSetter")],F.prototype,"setFieldValue",null),F=$([n({name:"FormularioForm"})],F);const N=F;var P=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.onFormSubmit(e)}}},[t._t("default",null,{errors:t.mergedFormErrors})],2)};P._withStripped=!0;const A=O({render:P,staticRenderFns:[]},void 0,N,void 0,!1,void 0,!1,void 0,void 0,void 0);function j(t){const e=[];if(t.length){let r=t.shift();e.push(r),t.forEach(t=>{t.bail||t.bail!==r.bail?(r=Object.assign({},t),e.push(r)):r.validators.push(...t.validators)})}return e}const w={BLUR:"blur",LIVE:"live",SUBMIT:"submit"};let R=class extends r{constructor(){super(...arguments),this.defaultId=this.$formulario.nextId(this),this.proxy=this.getInitialValue(),this.localErrors=[],this.validationErrors=[],this.pendingValidation=Promise.resolve()}get context(){return Object.defineProperty({id:this.id||this.defaultId,name:this.nameOrFallback,blurHandler:this.blurHandler.bind(this),errors:this.explicitErrors,allErrors:this.allErrors,performValidation:this.performValidation.bind(this),validationErrors:this.validationErrors,value:this.value},"model",{get:this.modelGetter.bind(this),set:this.modelSetter.bind(this)})}get parsedValidationRules(){const t={};return Object.keys(this.validationRules).forEach(e=>{t[d(e)]=this.validationRules[e]}),t}get messages(){const t={};return Object.keys(this.validationMessages).forEach(e=>{t[d(e)]=this.validationMessages[e]}),t}get nameOrFallback(){return""!==this.path?`${this.path}.${this.name}`:this.name}get hasErrors(){return this.allErrors.length>0}get allErrors(){return[...this.explicitErrors.map(t=>({message:t})),...c(this.validationErrors)]}get explicitErrors(){return[...c(this.errors),...this.localErrors]}get hasModel(){return m(this.$options.propsData||{},"formularioValue")}onProxyChanged(t,e){this.errorBehavior===w.LIVE?this.performValidation():this.validationErrors=[],this.hasModel||u(t,e)||(this.context.model=t)}onFormularioValueChanged(t,e){this.hasModel&&!u(t,e)&&(this.context.model=t)}created(){this.applyInitialValue(),this.formularioRegister&&"function"==typeof this.formularioRegister&&this.formularioRegister(this.nameOrFallback,this),this.disableErrors||"function"!=typeof this.addErrorObserver||this.addErrorObserver({callback:this.setErrors,type:"input",field:this.nameOrFallback}),this.errorBehavior===w.LIVE&&this.performValidation()}beforeDestroy(){this.disableErrors||"function"!=typeof this.removeErrorObserver||this.removeErrorObserver(this.setErrors),"function"==typeof this.formularioDeregister&&this.formularioDeregister(this.nameOrFallback)}modelGetter(){const t=this.hasModel?"formularioValue":"proxy";return void 0===this[t]?"":this[t]}modelSetter(t){u(t,this.proxy)||(this.proxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formularioSetter&&this.formularioSetter(this.context.name,t)}blurHandler(){this.$emit("blur"),this.errorBehavior===w.BLUR&&this.performValidation()}getInitialValue(){return m(this.$options.propsData,"value")?this.value:m(this.$options.propsData,"formularioValue")?this.formularioValue:""}applyInitialValue(){u(this.context.model,this.proxy)||(this.context.model=this.proxy)}performValidation(){return this.pendingValidation=this.validate().then(t=>{this.didValidate(t)}),this.pendingValidation}applyValidator(t){return function(t,e){return Promise.resolve(t.rule(e,...t.args))}(t,{value:this.context.model,name:this.context.name,getFormValues:this.getFormValues.bind(this)}).then(e=>!e&&this.getMessageObject(t.name,t.args))}applyValidatorGroup(t){return Promise.all(t.validators.map(this.applyValidator)).then(t=>t.filter(t=>!1!==t))}validate(){return new Promise(t=>{const e=(r,i=[])=>{if(r.length){const o=r.shift();this.applyValidatorGroup(o).then(s=>0!==s.length&&o.bail||!r.length?t(i.concat(s)):e(r,i.concat(s)))}else t([])};e(function(t){const e=([t,e,r,i])=>({validators:[{name:r,rule:t,args:e}],bail:"^"===i}),r=[],i=t.findIndex(([,,t])=>"bail"===t.toLowerCase());return i>=0?(r.push(...j(t.splice(0,i+1).slice(0,-1).map(e))),r.push(...t.map(([t,e,r])=>({validators:[{rule:t,args:e,name:r}],bail:!0})))):r.push(...j(t.map(e))),r}(p(this.validation,this.$formulario.rules(this.parsedValidationRules))))})}didValidate(t){const e=!u(t,this.validationErrors);if(this.validationErrors=t,e){const t={name:this.context.name,errors:this.validationErrors};this.$emit("validation",t),this.onFormularioFieldValidation&&"function"==typeof this.onFormularioFieldValidation&&this.onFormularioFieldValidation(t)}}getMessageObject(t,e){const r={args:e,name:this.name,value:this.context.model,formValues:this.getFormValues()};return{rule:t,context:r,message:this.getMessageFunc(t||"")(r)}}getMessageFunc(t){if(t=d(t),this.messages&&void 0!==this.messages[t])switch(typeof this.messages[t]){case"function":return this.messages[t];case"string":case"boolean":return()=>this.messages[t]}return e=>this.$formulario.validationMessage(t,e,this)}hasValidationErrors(){return new Promise(t=>{this.$nextTick(()=>{this.pendingValidation.then(()=>t(!!this.validationErrors.length))})})}setErrors(t){this.localErrors=c(t)}resetValidation(){this.localErrors=[],this.validationErrors=[]}};$([l({default:void 0})],R.prototype,"formularioSetter",void 0),$([l({default:()=>()=>{}})],R.prototype,"onFormularioFieldValidation",void 0),$([l({default:void 0})],R.prototype,"formularioRegister",void 0),$([l({default:void 0})],R.prototype,"formularioDeregister",void 0),$([l({default:()=>()=>({})})],R.prototype,"getFormValues",void 0),$([l({default:void 0})],R.prototype,"addErrorObserver",void 0),$([l({default:void 0})],R.prototype,"removeErrorObserver",void 0),$([l({default:""})],R.prototype,"path",void 0),$([i("input",{default:""})],R.prototype,"formularioValue",void 0),$([o({default:null})],R.prototype,"id",void 0),$([o({required:!0})],R.prototype,"name",void 0),$([o({default:!1})],R.prototype,"value",void 0),$([o({default:""})],R.prototype,"validation",void 0),$([o({default:()=>({})})],R.prototype,"validationRules",void 0),$([o({default:()=>({})})],R.prototype,"validationMessages",void 0),$([o({default:()=>[]})],R.prototype,"errors",void 0),$([o({default:w.BLUR,validator:t=>[w.BLUR,w.LIVE,w.SUBMIT].includes(t)})],R.prototype,"errorBehavior",void 0),$([o({default:!1})],R.prototype,"disableErrors",void 0),$([a("proxy")],R.prototype,"onProxyChanged",null),$([a("formularioValue")],R.prototype,"onFormularioValueChanged",null),R=$([n({name:"FormularioInput",inheritAttrs:!1})],R);const _=R;var M=function(){var t=this.$createElement;return(this._self._c||t)("div",{staticClass:"formulario-input"},[this._t("default",null,{id:this.id,context:this.context,violations:this.validationErrors})],2)};M._withStripped=!0;const k=O({render:M,staticRenderFns:[]},void 0,_,void 0,!1,void 0,!1,void 0,void 0,void 0);let S=class extends r{get groupPath(){return this.isArrayItem?`${this.path}[${this.name}]`:""===this.path?this.name:`${this.path}.${this.name}`}};$([l({default:""})],S.prototype,"path",void 0),$([o({required:!0})],S.prototype,"name",void 0),$([o({default:!1})],S.prototype,"isArrayItem",void 0),$([s("path")],S.prototype,"groupPath",null),S=$([n({name:"FormularioGrouping"})],S);const D=S;var I=function(){var t=this.$createElement;return(this._self._c||t)("div",[this._t("default")],2)};I._withStripped=!0;const C=O({render:I,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0);var T=new class{constructor(){this.options={rules:g,validationMessages:y},this.idRegistry={}}install(t,e){t.prototype.$formulario=this,t.component("FormularioForm",A),t.component("FormularioGrouping",C),t.component("FormularioInput",k),this.extend(e||{})}nextId(t){const e=!(!t.$route||!t.$route.path)&&t.$route.path?t.$route.path.replace(/[/\\.\s]/g,"-"):"global";return m(this.idRegistry,e)||(this.idRegistry[e]=0),`formulario-${e}-${++this.idRegistry[e]}`}extend(t){if("object"==typeof t)return this.options=b(this.options,t),this;throw new Error(`VueFormulario extend() should be passed an object (was ${typeof t})`)}rules(t={}){return Object.assign(Object.assign({},this.options.rules),t)}validationMessage(t,e,r){return m(this.options.validationMessages,t)?this.options.validationMessages[t](r,e):this.options.validationMessages.default(r,e)}};export default T;