1
0
mirror of synced 2024-11-22 13:26:06 +03:00
vue-formulario/dist/formulario.umd.js
2020-10-27 10:50:02 +03:00

17 lines
22 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("is-plain-object"),require("is-url"),require("vue"),require("vue-property-decorator")):"function"==typeof define&&define.amd?define(["is-plain-object","is-url","vue","vue-property-decorator"],t):(e=e||self).Formulario=t(e.isPlainObject,e.isUrl,e.Vue,e.vuePropertyDecorator)}(this,(function(e,t,r,i){"use strict";function o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function s(t,r,i=!0){const a={};for(const n in t)o(r,n)?e(r[n])&&e(t[n])?a[n]=s(t[n],r[n],i):i&&Array.isArray(t[n])&&Array.isArray(r[n])?a[n]=t[n].concat(r[n]):a[n]=r[n]:a[n]=t[n];for(const e in r)o(a,e)||(a[e]=r[e]);return a}function a(e){switch(typeof e){case"symbol":case"number":case"string":case"boolean":case"undefined":return!0;default:return null===e}}function n(e,t){if(e===t)return!0;if(!e||!t)return!1;const r=Object.keys(e);if(Object.keys(t).length!==r.length)return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(0===r.length)return e===t;for(let i=0;i<r.length;i++){const o=r[i];if(e[o]!==t[o])return!1}return!0}function l(e){return e.replace(/([_][a-z0-9])/gi,t=>0!==e.indexOf(t)&&"_"!==e[e.indexOf(t)-1]?t.toUpperCase().replace("_",""):t)}function u(e,t){const r=t.split(".");let i=e;for(const e in r){const t=r[e].match(/(.+)\[(\d+)\]$/);if(void 0===i)return null;if(t){if(i=i[t[1]],void 0===i)return null;i=i[t[2]]}else i=i[r[e]]}return i}e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t,r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var d={accepted:({value:e})=>Promise.resolve(["yes","on","1",1,!0,"true"].includes(e)),after({value:e},t=!1){const r=!1!==t?Date.parse(t):Date.now(),i=e instanceof Date?e.getTime():Date.parse(e);return Promise.resolve(!isNaN(i)&&i>r)},alpha({value:e},t="default"){const r={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=o(r,t)?t:"default";return Promise.resolve(r[i].test(e))},alphanumeric({value:e},t="default"){const r={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=o(r,t)?t:"default";return Promise.resolve(r[i].test(e))},before({value:e},t=!1){const r=!1!==t?Date.parse(t):Date.now(),i=e instanceof Date?e.getTime():Date.parse(e);return Promise.resolve(!isNaN(i)&&i<r)},between:({value:e},t=0,r=10,i)=>Promise.resolve(null!==t&&null!==r&&!isNaN(t)&&!isNaN(r)&&(!isNaN(Number(e))&&"length"!==i||"value"===i?(e=Number(e),t=Number(t),r=Number(r),e>t&&e<r):("string"==typeof e||"length"===i)&&(e=isNaN(Number(e))?e:e.toString()).length>t&&e.length<r)),confirm:({value:e,formValues:t,name:r},i)=>Promise.resolve((()=>{let o=i;return o||(o=/_confirm$/.test(r)?r.substr(0,r.length-8):r+"_confirm"),t[o]===e})()),date:({value:e},t=!1)=>Promise.resolve(t?function(e){const t=`^${r=e,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((e,t)=>e.replace(t,i[t]),t))}(t).test(e):!isNaN(Date.parse(e))),email({value:e}){if(!e)return Promise.resolve(!0);return Promise.resolve(/^(([^<>()\[\].,;:\s@"]+(\.[^<>()\[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i.test(e))},endsWith:({value:e},...t)=>e?"string"==typeof e?Promise.resolve(0===t.length||t.some(t=>e.endsWith(t))):Promise.resolve(!1):Promise.resolve(!0),in:({value:e},...t)=>Promise.resolve(t.some(t=>"object"==typeof t?n(t,e):t===e)),matches:({value:e},...t)=>Promise.resolve(!!t.find(t=>("string"==typeof t&&"/"===t.substr(0,1)&&"/"===t.substr(-1)&&(t=new RegExp(t.substr(1,t.length-2))),t instanceof RegExp?t.test(e):t===e))),max:({value:e},t=10,r)=>Promise.resolve(Array.isArray(e)?(t=isNaN(Number(t))?t:Number(t),e.length<=t):!isNaN(e)&&"length"!==r||"value"===r?(e=isNaN(e)?e:Number(e))<=t:("string"==typeof e||"length"===r)&&(e=isNaN(e)?e:e.toString()).length<=t),min:({value:e},t=1,r)=>Promise.resolve(Array.isArray(e)?(t=isNaN(t)?t:Number(t),e.length>=t):!isNaN(e)&&"length"!==r||"value"===r?(e=isNaN(e)?e:Number(e))>=t:("string"==typeof e||"length"===r)&&(e=isNaN(e)?e:e.toString()).length>=t),not:({value:e},...t)=>Promise.resolve(!t.some(t=>"object"==typeof t?n(t,e):t===e)),number:({value:e})=>Promise.resolve(String(e).length>0&&!isNaN(Number(e))),required:({value:e},t=!0)=>Promise.resolve(!(t&&!["no","false"].includes(t)&&(Array.isArray(e)?!e.length:"string"==typeof e?!e:!("object"!=typeof e||e&&Object.keys(e).length)))),startsWith:({value:e},...t)=>e?"string"==typeof e?Promise.resolve(0===t.length||t.some(t=>e.startsWith(t))):Promise.resolve(!1):Promise.resolve(!0),url:({value:e})=>Promise.resolve(t(e)),bail:()=>Promise.resolve(!0)},h={default:(e,t)=>e.$t("validation.default",t),accepted:(e,t)=>e.$t("validation.accepted",t),after:(e,t,r=!1)=>"string"==typeof r&&r.length?e.$t("validation.after.compare",t):e.$t("validation.after.default",t),alpha:(e,t)=>e.$t("validation.alpha",t),alphanumeric:(e,t)=>e.$t("validation.alphanumeric",t),before:(e,t,r=!1)=>"string"==typeof r&&r.length?e.$t("validation.before.compare",t):e.$t("validation.before.default",t),between(e,t,r=0,i=10,o){const s=Object.assign(Object.assign({},t),{from:r,to:i});return!isNaN(t.value)&&"length"!==o||"value"===o?e.$t("validation.between.force",s):e.$t("validation.between.default",s)},confirm:(e,t)=>e.$t("validation.confirm",t),date:(e,t,r=!1)=>"string"==typeof r&&r.length?e.$t("validation.date.format",t):e.$t("validation.date.default",t),email:(e,t)=>e.$t("validation.email.default",t),endsWith:(e,t)=>e.$t("validation.endsWith.default",t),in:function(e,t){return"string"==typeof t.value&&t.value?e.$t("validation.in.string",t):e.$t("validation.in.default",t)},matches:(e,t)=>e.$t("validation.matches.default",t),max:(e,t,r=10,i)=>Array.isArray(t.value)?e.$tc("validation.max.array",r,t):!isNaN(t.value)&&"length"!==i||"value"===i?e.$tc("validation.max.force",r,t):e.$tc("validation.max.default",r,t),min:(e,t,r=1,i)=>Array.isArray(t.value)?e.$tc("validation.min.array",r,t):!isNaN(t.value)&&"length"!==i||"value"===i?e.$tc("validation.min.force",r,t):e.$tc("validation.min.default",r,t),not:(e,t)=>e.$t("validation.not.default",t),number:(e,t)=>e.$t("validation.number.default",t),required:(e,t)=>e.$t("validation.required.default",t),startsWith:(e,t)=>e.$t("validation.startsWith.default",t),url:(e,t)=>e.$t("validation.url.default",t)};
/*! *****************************************************************************
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 c(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(e);o<i.length;o++)t.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(e,i[o])&&(r[i[o]]=e[i[o]])}return r}function f(e,t,r,i){var o,s=arguments.length,a=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,i);else for(var n=e.length-1;n>=0;n--)(o=e[n])&&(a=(s<3?o(a):s>3?o(t,r,a):o(t,r))||a);return s>3&&a&&Object.defineProperty(t,r,a),a}class p{constructor(e){this.registry=new Map,this.ctx=e}add(e,t){this.registry.set(e,t)}remove(e){this.registry.delete(e);const t=this.ctx.proxy,r=e,i=(t[r],c(t,["symbol"==typeof r?r:r+""]));this.ctx.proxy=i}has(e){return this.registry.has(e)}hasNested(e){for(const t of this.registry.keys())if(t===e||t.includes(e+"."))return!0;return!1}get(e){return this.registry.get(e)}getNested(e){const t=new Map;for(const r of this.registry.keys())(r===e||r.includes(e+"."))&&t.set(r,this.registry.get(r));return t}forEach(e){this.registry.forEach((t,r)=>{e(t,r)})}keys(){return Array.from(this.registry.keys())}register(e,t){if(this.registry.has(e))return;this.registry.set(e,t);const r=o(t.$options.propsData||{},"value");!r&&this.ctx.hasInitialValue&&void 0!==u(this.ctx.initialValues,e)?t.context.model=u(this.ctx.initialValues,e):r&&!n(t.proxy,u(this.ctx.initialValues,e))&&this.ctx.setFieldValue(e,t.proxy)}reduce(e,t){return this.registry.forEach((r,i)=>{t=e(t,r,i)}),t}}class v{constructor(e=[]){this.observers=[],this.observers=e}add(e){this.observers.some(t=>t.callback===e.callback)||this.observers.push(e)}remove(e){this.observers=this.observers.filter(t=>t.callback!==e)}filter(e){return new v(this.observers.filter(e))}some(e){return this.observers.some(e)}observe(e){this.observers.forEach(t=>{"form"===t.type?t.callback(e):t.field&&!Array.isArray(e)&&o(e,t.field)&&t.callback(e[t.field])})}}let m=class extends r{constructor(){super(...arguments),this.path="",this.proxy={},this.registry=new p(this),this.errorObserverRegistry=new v,this.localFormErrors=[],this.localFieldErrors={}}get initialValues(){return this.hasModel&&"object"==typeof this.formularioValue?Object.assign({},this.formularioValue):{}}get mergedFormErrors(){return[...this.formErrors,...this.localFormErrors]}get mergedFieldErrors(){return s(this.errors||{},this.localFieldErrors)}get hasModel(){return o(this.$options.propsData||{},"formularioValue")}get hasInitialValue(){return this.formularioValue&&"object"==typeof this.formularioValue}onFormularioValueChanged(e){this.hasModel&&e&&"object"==typeof e&&this.setValues(e)}onMergedFormErrorsChanged(e){this.errorObserverRegistry.filter(e=>"form"===e.type).observe(e)}onMergedFieldErrorsChanged(e){this.errorObserverRegistry.filter(e=>"input"===e.type).observe(e)}created(){this.initProxy()}getFormValues(){return this.proxy}onFormSubmit(){return this.hasValidationErrors().then(e=>e?void 0:function e(t){if("object"!=typeof t)return t;const r=Array.isArray(t)?[]:{};for(const i in t)o(t,i)&&(r[i]=a(t[i])?t[i]:e(t[i]));return r}(this.proxy)).then(e=>{void 0!==e?this.$emit("submit",e):this.$emit("error")})}onFormularioFieldValidation(e){this.$emit("validation",e)}addErrorObserver(e){this.errorObserverRegistry.add(e),"form"===e.type?e.callback(this.mergedFormErrors):e.field&&o(this.mergedFieldErrors,e.field)&&e.callback(this.mergedFieldErrors[e.field])}removeErrorObserver(e){this.errorObserverRegistry.remove(e)}register(e,t){this.registry.register(e,t)}deregister(e){this.registry.remove(e)}initProxy(){this.hasInitialValue&&(this.proxy=this.initialValues)}setValues(e){const t=Array.from(new Set([...Object.keys(e),...Object.keys(this.proxy)]));let r=!1;t.forEach(t=>{this.registry.hasNested(t)&&this.registry.getNested(t).forEach((t,i)=>{const o=this.registry.get(i),s=u(this.proxy,i),a=u(e,i);n(a,s)||(this.setFieldValue(i,a,!1),r=!0),n(a,o.proxy)||(o.context.model=a)})}),this.initProxy(),r&&this.$emit("input",Object.assign({},this.proxy))}setFieldValue(e,t,r=!0){if(void 0===t){const t=this.proxy,r=e,i=(t[r],c(t,["symbol"==typeof r?r:r+""]));this.proxy=i}else!function(e,t,r){const i=t.split(".");let o=e;for(let e=0;e<i.length;e++){const t=i[e],s=t.match(/(.+)\[(\d+)\]$/);if(s){if(void 0===o[s[1]]&&(o[s[1]]=[]),o=o[s[1]],e===i.length-1){o[s[2]]=r;break}o=o[s[2]]}else{if(e===i.length-1){o[t]=r;break}void 0===o[t]&&(o[t]={}),o=o[t]}}}(this.proxy,e,t);r&&this.$emit("input",Object.assign({},this.proxy))}setErrors({formErrors:e,inputErrors:t}){this.localFormErrors=e||[],this.localFieldErrors=t||{}}hasValidationErrors(){return Promise.all(this.registry.reduce((e,t)=>(e.push(t.runValidation()&&t.hasValidationErrors()),e),[])).then(e=>e.some(e=>e))}resetValidation(){this.localFormErrors=[],this.localFieldErrors={},this.registry.forEach(e=>{e.resetValidation()})}};function y(e,t,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(e&&e.render&&(d.render=e.render,d.staticRenderFns=e.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),i&&(d._scopeId=i),s?(h=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(s)},d._ssrRegister=h):t&&(h=a?function(e){t.call(this,u(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,n(e))}),h)if(d.functional){const e=d.render;d.render=function(t,r){return h.call(r),e(t,r)}}else{const e=d.beforeCreate;d.beforeCreate=e?[].concat(e,h):[h]}return r}f([i.Model("input",{default:()=>({})})],m.prototype,"formularioValue",void 0),f([i.Prop({default:()=>({})})],m.prototype,"errors",void 0),f([i.Prop({default:()=>[]})],m.prototype,"formErrors",void 0),f([i.Provide()],m.prototype,"path",void 0),f([i.Watch("formularioValue",{deep:!0})],m.prototype,"onFormularioValueChanged",null),f([i.Watch("mergedFormErrors")],m.prototype,"onMergedFormErrorsChanged",null),f([i.Watch("mergedFieldErrors",{immediate:!0})],m.prototype,"onMergedFieldErrorsChanged",null),f([i.Provide()],m.prototype,"getFormValues",null),f([i.Provide()],m.prototype,"onFormularioFieldValidation",null),f([i.Provide()],m.prototype,"addErrorObserver",null),f([i.Provide()],m.prototype,"removeErrorObserver",null),f([i.Provide("formularioRegister")],m.prototype,"register",null),f([i.Provide("formularioDeregister")],m.prototype,"deregister",null),f([i.Provide("formularioSetter")],m.prototype,"setFieldValue",null),m=f([i.Component({name:"FormularioForm"})],m);const g=m;var b=function(){var e=this,t=e.$createElement;return(e._self._c||t)("form",{on:{submit:function(t){return t.preventDefault(),e.onFormSubmit(t)}}},[e._t("default",null,{errors:e.mergedFormErrors})],2)};b._withStripped=!0;const E=y({render:b,staticRenderFns:[]},void 0,g,void 0,!1,void 0,!1,void 0,void 0,void 0);let x=class extends r{get groupPath(){return this.isArrayItem?`${this.path}[${this.name}]`:""===this.path?this.name:`${this.path}.${this.name}`}};f([i.Inject({default:""})],x.prototype,"path",void 0),f([i.Prop({required:!0})],x.prototype,"name",void 0),f([i.Prop({default:!1})],x.prototype,"isArrayItem",void 0),f([i.Provide("path")],x.prototype,"groupPath",null),x=f([i.Component({name:"FormularioGrouping"})],x);const P=x;var $=function(){var e=this.$createElement;return(this._self._c||e)("div",[this._t("default")],2)};$._withStripped=!0;const N=y({render:$,staticRenderFns:[]},void 0,P,void 0,!1,void 0,!1,void 0,void 0,void 0);function F(e,t,r,i){return o=>Promise.resolve(e(o,...r)).then(e=>e?null:{rule:t,args:r,context:o,message:i(o,...r)})}function V(e){return/^[\^]/.test(e.charAt(0))?[l(e.substr(1)),e.charAt(0)]:[l(e),null]}function O(e,t,r){return"function"==typeof e?[e,null,null]:Array.isArray(e)&&e.length?function(e,t,r){const i=e.slice(),s=i.shift();if("function"==typeof s)return[s,null,null];if("string"!=typeof s)throw new Error("[Formulario]: For array constraint first element must be rule name or Validator function");const[a,n]=V(s);if(o(t,a))return[F(t[a],a,i,r[a]||r.default),a,n];throw new Error("[Formulario] Can't create validator for constraint: "+JSON.stringify(e))}(e,t,r):"string"==typeof e?function(e,t,r){const i=e.split(":"),[s,a]=V(i.shift()||"");if(o(t,s))return[F(t[s],s,i.length?i.join(":").split(","):[],r[s]||r.default),s,a];throw new Error("[Formulario] Can't create validator for constraint: "+e)}(e,t,r):[()=>Promise.resolve(null),null,null]}function j(e){const t=[];if(e.length){let r=e.shift();t.push(r),e.forEach(e=>{e.bail||e.bail!==r.bail?(r=Object.assign({},e),t.push(r)):r.validators.push(...e.validators)})}return t}function R(e,t){return new Promise(r=>{const i=(e,o=[])=>{if(e.length){const s=e.shift();(function(e,t){return Promise.all(e.validators.map(e=>e(t))).then(e=>e.filter(e=>null!==e))})(s,t).then(t=>0!==t.length&&s.bail||!e.length?r(o.concat(t)):i(e,o.concat(t)))}else r([])};i(function(e){const t=([e,,t])=>({validators:[e],bail:"^"===t}),r=[],i=e.findIndex(([,e])=>e&&"bail"===e.toLowerCase());return i>=0?(r.push(...j(e.splice(0,i+1).slice(0,-1).map(t))),r.push(...e.map(([e])=>({validators:[e],bail:!0})))):r.push(...j(e.map(t))),r}(e))})}const w={DEMAND:"demand",LIVE:"live",SUBMIT:"submit"};let A=class extends r{constructor(){super(...arguments),this.proxy=this.getInitialValue(),this.localErrors=[],this.violations=[],this.validationRun=Promise.resolve()}get fullQualifiedName(){return""!==this.path?`${this.path}.${this.name}`:this.name}get model(){const e=this.hasModel?"value":"proxy";return void 0===this[e]?"":this[e]}set model(e){n(e,this.proxy)||(this.proxy=e),this.$emit("input",e),"function"==typeof this.formularioSetter&&this.formularioSetter(this.context.name,e)}get context(){return Object.defineProperty({name:this.fullQualifiedName,runValidation:this.runValidation.bind(this),violations:this.violations,errors:this.localErrors,allErrors:[...this.localErrors,...this.violations.map(e=>e.message)]},"model",{get:()=>this.model,set:e=>{this.model=e}})}get normalizedValidationRules(){const e={};return Object.keys(this.validationRules).forEach(t=>{e[l(t)]=this.validationRules[t]}),e}get normalizedValidationMessages(){const e={};return Object.keys(this.validationMessages).forEach(t=>{e[l(t)]=this.validationMessages[t]}),e}get hasModel(){return o(this.$options.propsData||{},"value")}onProxyChanged(e,t){this.hasModel||n(e,t)||(this.context.model=e),this.validationBehavior===w.LIVE?this.runValidation():this.violations=[]}onValueChanged(e,t){this.hasModel&&!n(e,t)&&(this.context.model=e)}created(){this.initProxy(),"function"==typeof this.formularioRegister&&this.formularioRegister(this.fullQualifiedName,this),"function"!=typeof this.addErrorObserver||this.errorsDisabled||this.addErrorObserver({callback:this.setErrors,type:"input",field:this.fullQualifiedName}),this.validationBehavior===w.LIVE&&this.runValidation()}beforeDestroy(){this.errorsDisabled||"function"!=typeof this.removeErrorObserver||this.removeErrorObserver(this.setErrors),"function"==typeof this.formularioDeregister&&this.formularioDeregister(this.fullQualifiedName)}getInitialValue(){return o(this.$options.propsData||{},"value")?this.value:""}initProxy(){n(this.context.model,this.proxy)||(this.context.model=this.proxy)}runValidation(){return this.validationRun=this.validate().then(e=>{const t=!n(e,this.violations);if(this.violations=e,t){const e={name:this.context.name,violations:this.violations};this.$emit("validation",e),"function"==typeof this.onFormularioFieldValidation&&this.onFormularioFieldValidation(e)}return this.violations}),this.validationRun}validate(){return R(function e(t,r,i){return"string"==typeof t?e(t.split("|").filter(e=>e.length),r,i):Array.isArray(t)?t.map(e=>O(e,r,i)):[]}(this.validation,this.$formulario.getRules(this.normalizedValidationRules),this.$formulario.getMessages(this,this.normalizedValidationMessages)),{value:this.context.model,name:this.context.name,formValues:this.getFormValues()})}hasValidationErrors(){return new Promise(e=>{this.$nextTick(()=>{this.validationRun.then(()=>e(this.violations.length>0))})})}setErrors(e){var t;this.localErrors=(t=e)?"string"==typeof t?[t]:Array.isArray(t)?t:"object"==typeof t?Object.values(t):[]:[]}resetValidation(){this.localErrors=[],this.violations=[]}};f([i.Inject({default:void 0})],A.prototype,"formularioSetter",void 0),f([i.Inject({default:()=>()=>{}})],A.prototype,"onFormularioFieldValidation",void 0),f([i.Inject({default:void 0})],A.prototype,"formularioRegister",void 0),f([i.Inject({default:void 0})],A.prototype,"formularioDeregister",void 0),f([i.Inject({default:()=>()=>({})})],A.prototype,"getFormValues",void 0),f([i.Inject({default:void 0})],A.prototype,"addErrorObserver",void 0),f([i.Inject({default:void 0})],A.prototype,"removeErrorObserver",void 0),f([i.Inject({default:""})],A.prototype,"path",void 0),f([i.Model("input",{default:""})],A.prototype,"value",void 0),f([i.Prop({required:!0,validator:e=>"string"==typeof e&&e.length>0})],A.prototype,"name",void 0),f([i.Prop({default:""})],A.prototype,"validation",void 0),f([i.Prop({default:()=>({})})],A.prototype,"validationRules",void 0),f([i.Prop({default:()=>({})})],A.prototype,"validationMessages",void 0),f([i.Prop({default:w.DEMAND,validator:e=>Object.values(w).includes(e)})],A.prototype,"validationBehavior",void 0),f([i.Prop({default:!1})],A.prototype,"errorsDisabled",void 0),f([i.Watch("proxy")],A.prototype,"onProxyChanged",null),f([i.Watch("value")],A.prototype,"onValueChanged",null),A=f([i.Component({name:"FormularioInput",inheritAttrs:!1})],A);const M=A;var _=function(){var e=this.$createElement;return(this._self._c||e)("div",{staticClass:"formulario-input"},[this._t("default",null,{context:this.context})],2)};_._withStripped=!0;const D=y({render:_,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0);return new class{constructor(){this.validationRules={},this.validationMessages={},this.validationRules=d,this.validationMessages=h}install(e,t){e.prototype.$formulario=this,e.component("FormularioForm",E),e.component("FormularioGrouping",N),e.component("FormularioInput",D),this.extend(t||{})}extend(e){if("object"==typeof e)return this.validationRules=s(this.validationRules,e.validationRules||{}),this.validationMessages=s(this.validationMessages,e.validationMessages||{}),this;throw new Error(`[Formulario]: Formulario.extend() should be passed an object (was ${typeof e})`)}getRules(e={}){return s(this.validationRules,e)}getMessages(e,t){const r=s(this.validationMessages||{},t),i={};for(const t in r)i[t]=(i,...o)=>"string"==typeof r[t]?r[t]:r[t](e,i,...o);return i}}}));