2 lines
45 KiB
JavaScript
2 lines
45 KiB
JavaScript
import t from"is-url";import e from"nanoid/non-secure";import r from"is-plain-object";import{en as i}from"@braid/vue-formulate-i18n";var o=function(t,e){return{classification:t,component:"FormulateInput"+(e||t[0].toUpperCase()+t.substr(1))}},n=Object.assign({},["text","email","number","color","date","hidden","month","password","search","tel","time","url","week","datetime-local"].reduce((function(t,e){var r;return Object.assign({},t,((r={})[e]=o("text"),r))}),{}),{range:o("slider"),textarea:o("textarea","TextArea"),checkbox:o("box"),radio:o("box"),submit:o("button"),button:o("button"),select:o("select"),file:o("file"),image:o("file"),group:o("group")}),s=function(t,e,r){void 0===r&&(r={}),this.input=t,this.fileList=t.files,this.files=[],this.options=Object.assign({},{mimes:{}},r),this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var r={};for(var i in t)r[i]=e(i,t[i]);return r}function l(t,e){if(t===e)return!0;if(!t||!e)return!1;var r=Object.keys(t),i=Object.keys(e),o=r.length;if(i.length!==o)return!1;for(var n=0;n<o;n++){var s=r[n];if(t[s]!==e[s])return!1}return!0}function u(t){return"string"==typeof t?t.replace(/([_][a-z0-9])/gi,(function(e){return 0!==t.indexOf(e)&&"_"!==t[t.indexOf(e)-1]?e.toUpperCase().replace("_",""):e})):t}function c(t){return t?"string"==typeof t?[t]:Array.isArray(t)?t:"object"==typeof t?Object.values(t):[]:[]}function h(t,e){return"string"==typeof t?h(t.split("|"),e):Array.isArray(t)?t.map((function(t){return function(t,e){if("function"==typeof t)return[t,[]];if(Array.isArray(t)&&t.length){var r=d((t=t.map((function(t){return t}))).shift()),i=r[0],o=r[1];if("string"==typeof i&&e.hasOwnProperty(i))return[e[i],t,i,o];if("function"==typeof i)return[i,t,i,o]}if("string"==typeof t){var n=t.split(":"),s=d(n.shift()),a=s[0],l=s[1];if(e.hasOwnProperty(a))return[e[a],n.length?n.join(":").split(","):[],a,l];throw new Error("Unknown validation rule "+t)}return!1}(t,e)})).filter((function(t){return!!t})):[]}function d(t){return/^[\^]/.test(t.charAt(0))?[u(t.substr(1)),t.charAt(0)]:[u(t),null]}function f(t){switch(typeof t){case"symbol":case"number":case"string":case"boolean":case"undefined":return!0;default:return null===t}}function p(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function m(t,e){return Object.defineProperty(t,"__id",Object.assign(Object.create(null),{value:e||Symbol("uuid")}))}s.prototype.rehydrateFileList=function(t){var e=this,r=t.reduce((function(t,r){var i=r[e.options?e.options.fileUrlKey:"url"],o=!(!i||-1===i.lastIndexOf("."))&&i.substr(i.lastIndexOf(".")+1),n=e.options.mimes[o]||!1;return t.push(Object.assign({},r,i?{name:i.substr(i.lastIndexOf("/")+1||0),type:r.type?r.type:n,previewData:i}:{})),t}),[]);this.results=t,this.addFileList(r)},s.prototype.addFileList=function(t){for(var r=this,i=function(i){var o=t[i],n=e();r.files.push({progress:!1,error:!1,complete:!1,justFinished:!1,name:o.name||"file-upload",file:o,uuid:n,path:!1,removeFile:function(){this.removeFile(n)}.bind(r),previewData:o.previewData||!1})},o=0;o<t.length;o++)i(o)},s.prototype.hasUploader=function(){return!!this.context.uploader},s.prototype.uploaderIsAxios=function(){return!(!this.hasUploader||"function"!=typeof this.context.uploader.request||"function"!=typeof this.context.uploader.get||"function"!=typeof this.context.uploader.delete||"function"!=typeof this.context.uploader.post)},s.prototype.getUploader=function(){for(var t,e=[],r=arguments.length;r--;)e[r]=arguments[r];if(this.uploaderIsAxios()){var i=new FormData;if(i.append(this.context.name||"file",e[0]),!1===this.context.uploadUrl)throw new Error("No uploadURL specified: https://vueformulate.com/guide/inputs/file/#props");return this.context.uploader.post(this.context.uploadUrl,i,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:function(t){e[1](Math.round(100*t.loaded/t.total))}}).then((function(t){return t.data})).catch((function(t){return e[2](t)}))}return(t=this.context).uploader.apply(t,e)},s.prototype.upload=function(){var t=this;return this.results?Promise.resolve(this.results):new Promise((function(e,r){if(!t.hasUploader)return r(new Error("No uploader has been defined"));Promise.all(t.files.map((function(e){return e.path?Promise.resolve(e.path):t.getUploader(e.file,(function(r){e.progress=r,r>=100&&(e.complete||(e.justFinished=!0,setTimeout((function(){e.justFinished=!1}),t.options.uploadJustCompleteDuration)),e.complete=!0)}),(function(t){e.progress=0,e.error=t,e.complete=!0}),t.options)}))).then((function(r){t.results=r,e(r)})).catch((function(t){throw new Error(t)}))}))},s.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),this.context.performValidation(),window&&this.fileList instanceof FileList){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},s.prototype.loadPreviews=function(){this.files.map((function(t){if(!t.previewData&&window&&window.FileReader&&/^image\//.test(t.file.type)){var e=new FileReader;e.onload=function(e){return Object.assign(t,{previewData:e.target.result})},e.readAsDataURL(t.file)}}))},s.prototype.getFileList=function(){return this.fileList},s.prototype.getFiles=function(){return this.files},s.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var v={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var r=t.value;void 0===e&&(e=!1);var i=Date.parse(e||new Date),o=Date.parse(r);return Promise.resolve(!isNaN(o)&&o>i)},alpha:function(t,e){var r=t.value;void 0===e&&(e="default");var i={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=i.hasOwnProperty(e)?e:"default";return Promise.resolve(i[o].test(r))},alphanumeric:function(t,e){var r=t.value;void 0===e&&(e="default");var i={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=i.hasOwnProperty(e)?e:"default";return Promise.resolve(i[o].test(r))},before:function(t,e){var r=t.value;void 0===e&&(e=!1);var i=Date.parse(e||new Date),o=Date.parse(r);return Promise.resolve(!isNaN(o)&&o<i)},between:function(t,e,r,i){var o=t.value;return void 0===e&&(e=0),void 0===r&&(r=10),Promise.resolve(null!==e&&null!==r&&!isNaN(e)&&!isNaN(r)&&(!isNaN(o)&&"length"!==i||"value"===i?(o=Number(o),e=Number(e),r=Number(r),o>e&&o<r):("string"==typeof o||"length"===i)&&(o=isNaN(o)?o:o.toString()).length>e&&o.length<r))},confirm:function(t,e){var r,i,o=t.value,n=t.getFormValues,s=t.name;return Promise.resolve((r=n(),(i=e)||(i=/_confirm$/.test(s)?s.substr(0,s.length-8):s+"_confirm"),r[i]===o))},date:function(t,e){var r=t.value;return void 0===e&&(e=!1),Promise.resolve(e&&"string"==typeof e?function(t){var e="^"+t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"$",r={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(r).reduce((function(t,e){return t.replace(e,r[e])}),e))}(e).test(r):!isNaN(Date.parse(r)))},email:function(t){var e=t.value;return Promise.resolve(/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];return Promise.resolve("string"==typeof e&&r.length?void 0!==r.find((function(t){return e.endsWith(t)})):"string"==typeof e&&0===r.length)},in:function(t){for(var e=t.value,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];return Promise.resolve(void 0!==r.find((function(t){return"object"==typeof t?l(t,e):t===e})))},matches:function(t){for(var e=t.value,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];return Promise.resolve(!!r.find((function(t){return"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})))},mime:function(t){for(var e=t.value,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];return Promise.resolve(function(){if(e instanceof s)for(var t=e.getFiles(),i=0;i<t.length;i++){var o=t[i].file;if(!r.includes(o.type))return!1}return!0}())},min:function(t,e,r){var i=t.value;return void 0===e&&(e=1),Promise.resolve(Array.isArray(i)?(e=isNaN(e)?e:Number(e),i.length>=e):!isNaN(i)&&"length"!==r||"value"===r?(i=isNaN(i)?i:Number(i))>=e:("string"==typeof i||"length"===r)&&(i=isNaN(i)?i:i.toString()).length>=e)},max:function(t,e,r){var i=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(i)?(e=isNaN(e)?e:Number(e),i.length<=e):!isNaN(i)&&"length"!==r||"value"===r?(i=isNaN(i)?i:Number(i))<=e:("string"==typeof i||"length"===r)&&(i=isNaN(i)?i:i.toString()).length<=e)},not:function(t){for(var e=t.value,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];return Promise.resolve(void 0===r.find((function(t){return"object"==typeof t?l(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var r=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(r)?!!r.length:r instanceof s?r.getFiles().length>0:"string"==typeof r?!!r:"object"!=typeof r||!!r&&!!Object.keys(r).length))},startsWith:function(t){for(var e=t.value,r=[],i=arguments.length-1;i-- >0;)r[i]=arguments[i+1];return Promise.resolve("string"==typeof e&&r.length?void 0!==r.find((function(t){return e.startsWith(t)})):"string"==typeof e&&0===r.length)},url:function(e){var r=e.value;return Promise.resolve(t(r))},bail:function(){return Promise.resolve(!0)}},y="image/",g={csv:"text/csv",gif:y+"gif",jpg:y+"jpeg",jpeg:y+"jpeg",png:y+"png",pdf:"application/pdf",svg:y+"svg+xml"};function b(t,e,r,i){return new Promise((function(r,o){var n=(i.fauxUploaderDuration||2e3)*(.5+Math.random()),s=performance.now(),a=function(){return setTimeout((function(){var i=performance.now()-s,o=Math.min(100,Math.round(i/n*100));if(e(o),o>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});a()}),20)};a()}))}function x(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&-1===e.indexOf(i)&&(r[i]=t[i]);return r}var E={inheritAttrs:!1,functional:!0,render:function(t,e){for(var r=e.props,i=e.data,o=e.parent,n=e.children,s=o,a=(r.name,r.forceWrap),l=r.context,u=x(r,["name","forceWrap","context"]);s&&"FormulateInput"!==s.$options.name;)s=s.$parent;if(!s)return null;if(s.$scopedSlots&&s.$scopedSlots[r.name])return s.$scopedSlots[r.name](Object.assign({},l,u));if(Array.isArray(n)&&(n.length>1||a&&n.length>0)){var c=i.attrs,h=(c.name,c.context,x(c,["name","context"]));return t("div",Object.assign({},i,{attrs:h}),n)}return Array.isArray(n)&&1===n.length?n[0]:null}};function F(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&-1===e.indexOf(i)&&(r[i]=t[i]);return r}var V=function(t){this.registry=new Map,this.ctx=t};function w(t){return new V(t).dataProps()}function O(){return{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values||this.isGrouping&&"object"==typeof this.context.model[this.index]},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return p(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):p(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):this.isGrouping&&"object"==typeof this.context.model[this.index]?this.context.model[this.index]:{}}}}function j(t){void 0===t&&(t=[]);var e={applyInitialValues:function(){this.hasInitialValue&&(this.proxy=this.initialValues)},setFieldValue:function(t,e){var r;if(void 0===e){var i=this.proxy,o=(i[t],F(i,[String(t)]));this.proxy=o}else Object.assign(this.proxy,((r={})[t]=e,r));this.$emit("input",Object.assign({},this.proxy))},getFormValues:function(){return this.proxy},hasValidationErrors:function(){return Promise.all(this.registry.reduce((function(t,e,r){return t.push(e.performValidation()&&e.getValidationErrors()),t}),[])).then((function(t){return t.some((function(t){return t.hasErrors}))}))},showErrors:function(){this.childrenShouldShowErrors=!0,this.registry.map((function(t){t.formShouldShowErrors=!0}))},hideErrors:function(){this.childrenShouldShowErrors=!1,this.registry.map((function(t){t.formShouldShowErrors=!1,t.behavioralErrorVisibility=!1}))},setValues:function(t){var e=this;Array.from(new Set(Object.keys(t).concat(Object.keys(this.proxy)))).forEach((function(r){!e.registry.has(r)||l(t[r],e.proxy[r])||l(t[r],e.registry.get(r).proxy)||(e.setFieldValue(r,t[r]),e.registry.get(r).context.model=t[r])}))}};return Object.keys(e).reduce((function(r,i){var o;return t.includes(i)?r:Object.assign({},r,((o={})[i]=e[i],o))}),{})}function S(t){return{formulateSetter:t.setFieldValue,formulateRegister:t.register,formulateDeregister:t.deregister,getFormValues:t.getFormValues}}V.prototype.add=function(t,e){return this.registry.set(t,e),this},V.prototype.remove=function(t){this.registry.delete(t);var e=this.ctx.proxy,r=(e[t],F(e,[String(t)]));return this.ctx.proxy=r,this},V.prototype.has=function(t){return this.registry.has(t)},V.prototype.get=function(t){return this.registry.get(t)},V.prototype.map=function(t){var e={};return this.registry.forEach((function(r,i){var o;return Object.assign(e,((o={})[i]=t(r,i),o))})),e},V.prototype.keys=function(){return Array.from(this.registry.keys())},V.prototype.register=function(t,e){if(this.registry.has(t))return!1;this.registry.set(t,e);var r=p(e.$options.propsData,"formulateValue"),i=p(e.$options.propsData,"value");!r&&this.ctx.hasInitialValue&&this.ctx.initialValues[t]?e.context.model=this.ctx.initialValues[t]:!r&&!i||l(e.proxy,this.ctx.initialValues[t])||this.ctx.setFieldValue(t,e.proxy),this.childrenShouldShowErrors&&(e.formShouldShowErrors=!0)},V.prototype.reduce=function(t,e){return this.registry.forEach((function(r,i){e=t(e,r,i)})),e},V.prototype.dataProps=function(){var t=this;return{proxy:{},registry:this,register:this.register.bind(this),deregister:function(e){return t.remove(e)},childrenShouldShowErrors:!1}};var P=function(t){this.form=t};function _(t,e,r,i,o,n,s,a,l,u){"boolean"!=typeof s&&(l=a,a=s,s=!1);var c,h="function"==typeof r?r.options:r;if(t&&t.render&&(h.render=t.render,h.staticRenderFns=t.staticRenderFns,h._compiled=!0,o&&(h.functional=!0)),i&&(h._scopeId=i),n?(c=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(n)},h._ssrRegister=c):e&&(c=s?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,a(t))}),c)if(h.functional){var d=h.render;h.render=function(t,e){return c.call(e),d(t,e)}}else{var f=h.beforeCreate;h.beforeCreate=f?[].concat(f,c):[c]}return r}P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,r){var i=[],o=function t(e){if("object"!=typeof e)return e;var r=Array.isArray(e)?[]:{};for(var i in e)e[i]instanceof s||f(e[i])?r[i]=e[i]:r[i]=t(e[i]);return r}(t.form.proxy),n=function(e){"object"==typeof t.form.proxy[e]&&t.form.proxy[e]instanceof s&&i.push(t.form.proxy[e].upload().then((function(t){var r;return Object.assign(o,((r={})[e]=t,r))})))};for(var a in o)n(a);Promise.all(i).then((function(){return e(o)})).catch((function(t){return r(t)}))}))};var A={provide:function(){return Object.assign({},S(this),{observeErrors:this.addErrorObserver,removeErrorObserver:this.removeErrorObserver,formulateFieldValidation:this.formulateFieldValidation})},name:"FormulateForm",model:{prop:"formulateValue",event:"input"},props:{name:{type:[String,Boolean],default:!1},formulateValue:{type:Object,default:function(){return{}}},values:{type:[Object,Boolean],default:!1},errors:{type:[Object,Boolean],default:!1},formErrors:{type:Array,default:function(){return[]}}},data:function(){return Object.assign({},w(this),{formShouldShowErrors:!1,errorObservers:[],namedErrors:[],namedFieldErrors:{}})},computed:Object.assign({},O(),{formContext:function(){return{errors:this.mergedFormErrors}},classes:function(){var t={"formulate-form":!0};return this.name&&(t["formulate-form--"+this.name]=!0),t},mergedFormErrors:function(){return this.formErrors.concat(this.namedErrors)},mergedFieldErrors:function(){var t={};if(this.errors)for(var e in this.errors)t[e]=c(this.errors[e]);for(var r in this.namedFieldErrors)t[r]=c(this.namedFieldErrors[r]);return t},hasFormErrorObservers:function(){return!!this.errorObservers.filter((function(t){return"form"===t.type})).length}}),watch:{formulateValue:{handler:function(t){this.isVmodeled&&t&&"object"==typeof t&&this.setValues(t)},deep:!0},mergedFormErrors:function(t){this.errorObservers.filter((function(t){return"form"===t.type})).forEach((function(e){return e.callback(t)}))},mergedFieldErrors:{handler:function(t){this.errorObservers.filter((function(t){return"input"===t.type})).forEach((function(e){return e.callback(t[e.field]||[])}))},immediate:!0}},created:function(){this.$formulate.register(this),this.applyInitialValues()},destroyed:function(){this.$formulate.deregister(this)},methods:Object.assign({},j(),{applyErrors:function(t){var e=t.formErrors,r=t.inputErrors;this.namedErrors=e,this.namedFieldErrors=r},addErrorObserver:function(t){this.errorObservers.find((function(e){return t.callback===e.callback}))||(this.errorObservers.push(t),"form"===t.type?t.callback(this.mergedFormErrors):p(this.mergedFieldErrors,t.field)&&t.callback(this.mergedFieldErrors[t.field]))},removeErrorObserver:function(t){this.errorObservers=this.errorObservers.filter((function(e){return e.callback!==t}))},registerErrorComponent:function(t){this.errorComponents.includes(t)||this.errorComponents.push(t)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},formulateFieldValidation:function(t){this.$emit("validation",t)}})},$=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("form",{class:t.classes,on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t.hasFormErrorObservers?t._e():r("FormulateErrors",{attrs:{context:t.formContext}}),t._v(" "),t._t("default")],2)};$._withStripped=!0;var R=_({render:$,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),N={context:function(){return k.call(this,Object.assign({},{addLabel:this.logicalAddLabel,attributes:this.elementAttributes,blurHandler:I.bind(this),classification:this.classification,component:this.component,disableErrors:this.disableErrors,errors:this.explicitErrors,allErrors:this.allErrors,formShouldShowErrors:this.formShouldShowErrors,getValidationErrors:this.getValidationErrors.bind(this),hasGivenName:this.hasGivenName,hasLabel:this.label&&"button"!==this.classification,hasValidationErrors:this.hasValidationErrors.bind(this),help:this.help,helpPosition:this.logicalHelpPosition,id:this.id||this.defaultId,imageBehavior:this.imageBehavior,label:this.label,labelPosition:this.logicalLabelPosition,limit:this.limit,name:this.nameOrFallback,performValidation:this.performValidation.bind(this),preventWindowDrops:this.preventWindowDrops,repeatable:this.repeatable,setErrors:this.setErrors.bind(this),showValidationErrors:this.showValidationErrors,slotComponents:this.slotComponents,type:this.type,uploadBehavior:this.uploadBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),validationErrors:this.validationErrors,value:this.value,visibleValidationErrors:this.visibleValidationErrors,isSubField:this.isSubField},this.typeContext))},nameOrFallback:function(){if(!0===this.name&&"button"!==this.classification)return this.type+"_"+this.elementAttributes.id;if(!1===this.name||"button"===this.classification&&!0===this.name)return!1;return this.name},hasGivenName:function(){return"boolean"!=typeof this.name},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:C.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,r){return C.call(t,r)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:C.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;this.hasGivenName&&(t.name=this.name);this.help&&(t["aria-describedby"]=t.id+"-help");return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},logicalHelpPosition:function(){if(this.helpPosition)return this.helpPosition;switch(this.classification){case"group":return"before";default:return"after"}},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedValidationName:function(){if(this.validationName)return this.validationName;if("string"==typeof this.name)return this.name;if(this.label)return this.label;return this.type},explicitErrors:function(){return c(this.errors).concat(this.localErrors).concat(c(this.error))},allErrors:function(){return this.explicitErrors.concat(c(this.validationErrors))},hasErrors:function(){return!!this.allErrors.length},hasVisibleErrors:function(){return this.validationErrors&&this.showValidationErrors||!!this.explicitErrors.length},showValidationErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;if("file"===this.classification&&"live"===this.uploadBehavior&&D.call(this))return!0;return this.behavioralErrorVisibility},visibleValidationErrors:function(){return this.showValidationErrors&&this.validationErrors.length?this.validationErrors:[]},slotComponents:function(){return{label:this.$formulate.slotComponent(this.type,"label"),help:this.$formulate.slotComponent(this.type,"help"),errors:this.$formulate.slotComponent(this.type,"errors"),repeatable:this.$formulate.slotComponent(this.type,"repeatable"),addMore:this.$formulate.slotComponent(this.type,"addMore"),remove:this.$formulate.slotComponent(this.type,"remove")}},logicalAddLabel:function(){if("boolean"==typeof this.addLabel)return"+ "+(this.label||this.name||"Add");return this.addLabel}};function C(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var r in t)e.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return e}return t}function I(){this.$emit("blur"),"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function k(t){return Object.defineProperty(t,"model",{get:D.bind(this),set:L.bind(this)})}function D(){var t=this.isVmodeled?"formulateValue":"proxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function L(t){l(t,this.proxy)||(this.proxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateSetter&&this.formulateSetter(this.context.name,t)}var U={name:"FormulateInput",inheritAttrs:!1,provide:function(){return{formulateRegisterRule:this.registerRule,formulateRemoveRule:this.removeRule}},inject:{formulateSetter:{default:void 0},formulateFieldValidation:{default:function(){return function(){return{}}}},formulateRegister:{default:void 0},formulateDeregister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}},observeErrors:{default:void 0},removeErrorObserver:{default:void 0},isSubField:{default:function(){return function(){return!1}}}},model:{prop:"formulateValue",event:"input"},props:{type:{type:String,default:"text"},name:{type:[String,Boolean],default:!0},formulateValue:{default:""},value:{default:!1},options:{type:[Object,Array,Boolean],default:!1},optionGroups:{type:[Object,Boolean],default:!1},id:{type:[String,Boolean,Number],default:!1},label:{type:[String,Boolean],default:!1},labelPosition:{type:[String,Boolean],default:!1},limit:{type:Number,default:1/0},help:{type:[String,Boolean],default:!1},helpPosition:{type:[String,Boolean],default:!1},errors:{type:[String,Array,Boolean],default:!1},repeatable:{type:Boolean,default:!1},validation:{type:[String,Boolean,Array],default:!1},validationName:{type:[String,Boolean],default:!1},error:{type:[String,Boolean],default:!1},errorBehavior:{type:String,default:"blur",validator:function(t){return["blur","live","submit"].includes(t)}},showErrors:{type:Boolean,default:!1},imageBehavior:{type:String,default:"preview"},uploadUrl:{type:[String,Boolean],default:!1},uploader:{type:[Function,Object,Boolean],default:!1},uploadBehavior:{type:String,default:"live"},preventWindowDrops:{type:Boolean,default:!0},showValue:{type:[String,Boolean],default:!1},validationMessages:{type:Object,default:function(){return{}}},validationRules:{type:Object,default:function(){return{}}},checked:{type:[String,Boolean],default:!1},disableErrors:{type:Boolean,default:!1},addLabel:{type:[Boolean,String],default:!1}},data:function(){return{defaultId:this.$formulate.nextId(this),localAttributes:{},localErrors:[],proxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve(),ruleRegistry:[],messageRegistry:{}}},computed:Object.assign({},N,{classification:function(){var t=this.$formulate.classify(this.type);return"box"===t&&this.options?"group":t},component:function(){return"group"===this.classification?"FormulateInputGroup":this.$formulate.component(this.type)},parsedValidationRules:function(){var t=this,e={};return Object.keys(this.validationRules).forEach((function(r){e[u(r)]=t.validationRules[r]})),e},messages:function(){var t=this,e={};return Object.keys(this.validationMessages).forEach((function(r){e[u(r)]=t.validationMessages[r]})),Object.keys(this.messageRegistry).forEach((function(r){e[u(r)]=t.messageRegistry[r]})),e}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},proxy:function(t,e){this.performValidation(),this.isVmodeled||l(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!l(t,e)&&(this.context.model=t)},showValidationErrors:{handler:function(t){this.$emit("error-visibility",t)},immediate:!0}},created:function(){this.applyInitialValue(),this.formulateRegister&&"function"==typeof this.formulateRegister&&this.formulateRegister(this.nameOrFallback,this),this.disableErrors||"function"!=typeof this.observeErrors||this.observeErrors({callback:this.setErrors,type:"input",field:this.nameOrFallback}),this.updateLocalAttributes(this.$attrs),this.performValidation()},beforeDestroy:function(){this.disableErrors||"function"!=typeof this.removeErrorObserver||this.removeErrorObserver(this.setErrors),"function"==typeof this.formulateDeregister&&this.formulateDeregister(this.nameOrFallback)},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:p(this.$options.propsData,"value")&&"box"!==t?this.value:p(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!l(this.context.model,this.proxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.proxy)},updateLocalAttributes:function(t){l(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=h(this.validation,this.$formulate.rules(this.parsedValidationRules));return e=this.ruleRegistry.length?this.ruleRegistry.concat(e):e,this.pendingValidation=this.runRules(e).then((function(e){return t.didValidate(e)})),this.pendingValidation},runRules:function(t){var e=this,r=function(t){var r=t[0],i=t[1],o=t[2],n=(t[3],r.apply(void 0,[{value:e.context.model,getFormValues:e.getFormValues.bind(e),name:e.context.name}].concat(i)));return(n=n instanceof Promise?n:Promise.resolve(n)).then((function(t){return!t&&e.getMessage(o,i)}))};return new Promise((function(e){var i=function(t,o){void 0===o&&(o=[]);var n=t.shift();Array.isArray(n)&&n.length?Promise.all(n.map(r)).then((function(t){return t.filter((function(t){return!!t}))})).then((function(r){return(r=Array.isArray(r)?r:[]).length&&n.bail||!t.length?e(o.concat(r)):i(t,o.concat(r))})):e([])};i(function(t){var e=[],r=t.findIndex((function(t){return"bail"===t[2].toLowerCase()}));if(r>=0){var i=t.splice(0,r+1).slice(0,-1);i.length&&e.push(i),t.map((function(t){return e.push(Object.defineProperty([t],"bail",{value:!0}))}))}else e.push(t);return e.reduce((function(t,e){var r=function(t,e){if(void 0===e&&(e=!1),t.length<2)return Object.defineProperty([t],"bail",{value:e});var i=[],o=t.findIndex((function(t){return"^"===t[3]}));if(o>=0){var n=t.splice(0,o);n.length&&i.push.apply(i,r(n,e)),i.push(Object.defineProperty([t.shift()],"bail",{value:!0})),t.length&&i.push.apply(i,r(t,e))}else i.push(t);return i};return t.concat(r(e))}),[])}(t))}))},didValidate:function(t){var e=!l(t,this.validationErrors);if(this.validationErrors=t,e){var r=this.getErrorObject();this.$emit("validation",r),this.formulateFieldValidation&&"function"==typeof this.formulateFieldValidation&&this.formulateFieldValidation(r)}},getMessage:function(t,e){return this.getMessageFunc(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getMessageFunc:function(t){var e=this;if(t=u(t),this.messages&&void 0!==this.messages[t])switch(typeof this.messages[t]){case"function":return this.messages[t];case"string":case"boolean":return function(){return e.messages[t]}}return function(r){return e.$formulate.validationMessage(t,r,e)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))},getValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){return t.pendingValidation.then((function(){return e(t.getErrorObject())}))}))}))},getErrorObject:function(){return{name:this.context.nameOrFallback||this.context.name,errors:this.validationErrors.filter((function(t){return"string"==typeof t})),hasErrors:!!this.validationErrors.length}},setErrors:function(t){this.localErrors=c(t)},registerRule:function(t,e,r,i){void 0===i&&(i=null),this.ruleRegistry.some((function(t){return t[2]===r}))||(this.ruleRegistry.push([t,e,r]),null!==i&&(this.messageRegistry[r]=i))},removeRule:function(t){var e=this.ruleRegistry.findIndex((function(e){return e[2]===t}));e>=0&&(this.ruleRegistry.splice(e,1),delete this.messageRegistry[t])}}},B=function(){var t=this,e=t.$createElement;return(t._self._c||e)("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasVisibleErrors,"data-type":t.type}},[t._t("default",null,{id:t.id,context:t.context,errors:t.errors,validationErrors:t.validationErrors})],2)};B._withStripped=!0;var M=_({render:B,staticRenderFns:[]},void 0,U,void 0,!1,void 0,!1,void 0,void 0,void 0),G={inject:{observeErrors:{default:!1},removeErrorObserver:{default:!1}},props:{context:{type:Object,default:function(){return{}}},type:{type:String,default:"form"}},data:function(){return{boundSetErrors:this.setErrors.bind(this),localErrors:[]}},computed:{visibleValidationErrors:function(){return Array.isArray(this.context.visibleValidationErrors)?this.context.visibleValidationErrors:[]},errors:function(){return Array.isArray(this.context.errors)?this.context.errors:[]},mergedErrors:function(){return this.errors.concat(this.localErrors)},visibleErrors:function(){return Array.from(new Set(this.mergedErrors.concat(this.visibleValidationErrors))).filter((function(t){return"string"==typeof t}))}},created:function(){"form"!==this.type||"function"!=typeof this.observeErrors||Array.isArray(this.context.errors)||this.observeErrors({callback:this.boundSetErrors,type:this.type})},destroyed:function(){"form"!==this.type||"function"!=typeof this.removeErrorObserver||Array.isArray(this.context.errors)||this.removeErrorObserver(this.boundSetErrors)},methods:{setErrors:function(t){this.localErrors=c(t)}}},q=function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.visibleErrors.length?r("ul",{class:"formulate-"+t.type+"-errors"},t._l(t.visibleErrors,(function(e){return r("li",{key:e,class:"formulate-"+t.type+"-error",domProps:{textContent:t._s(e)}})})),0):t._e()};q._withStripped=!0;var T=_({render:q,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0),W={props:{context:{type:Object,required:!0}}},H=function(){var t=this.$createElement,e=this._self._c||t;return this.context.help?e("div",{class:"formulate-input-help formulate-input-help--"+this.context.helpPosition,attrs:{id:this.context.id+"-help"},domProps:{textContent:this._s(this.context.help)}}):this._e()};H._withStripped=!0;var Y=_({render:H,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),z={name:"FormulateGrouping",props:{context:{type:Object,required:!0}},provide:function(){return{isSubField:function(){return!0},registerProvider:this.registerProvider,deregisterProvider:this.deregisterProvider}},data:function(){return{providers:[]}},inject:["formulateRegisterRule","formulateRemoveRule"],computed:{items:function(){return Array.isArray(this.context.model)&&(this.context.repeatable||0!==this.context.model.length)?this.context.model.map((function(t){return m(t,t.__id)})):[m({})]},formShouldShowErrors:function(){return this.context.formShouldShowErrors}},watch:{providers:function(){this.formShouldShowErrors&&this.showErrors()},formShouldShowErrors:function(t){t&&this.showErrors()}},created:function(){this.formulateRegisterRule(this.validateGroup.bind(this),[],"formulateGrouping",!0)},destroyed:function(){this.formulateRemoveRule("formulateGrouping")},methods:{getAtIndex:function(t){return void 0!==this.context.model[t]&&this.context.model[t].__id?this.context.model[t]:void 0!==this.context.model[t]?m(this.context.model[t]):void 0===this.context.model[t]&&void 0!==this.items[t]?m({},this.items[t].__id):m({})},setFieldValue:function(t,e,r){var i,o=Array.isArray(this.context.model)?this.context.model:[],n=this.getAtIndex(t),s=m(Object.assign({},n,((i={})[e]=r,i)),n.__id);o.splice(t,1,s),this.context.model=o},validateGroup:function(){return Promise.all(this.providers.reduce((function(t,e){return e&&"function"==typeof e.hasValidationErrors&&t.push(e.hasValidationErrors()),t}),[])).then((function(t){return!t.some((function(t){return!!t}))}))},showErrors:function(){this.providers.forEach((function(t){return t&&"function"==typeof t.showErrors&&t.showErrors()}))},removeItem:function(t){Array.isArray(this.context.model)&&this.context.model.splice(t,1)},registerProvider:function(t){this.providers.some((function(e){return e===t}))||this.providers.push(t)},deregisterProvider:function(t){this.providers=this.providers.filter((function(e){return e!==t}))}}},K=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("FormulateSlot",{staticClass:"formulate-input-grouping",attrs:{name:"grouping",context:t.context,"force-wrap":t.context.repeatable}},t._l(t.items,(function(e,i){return r("FormulateRepeatableProvider",{key:e.__id,attrs:{index:i,"set-field-value":function(e,r){return t.setFieldValue(i,e,r)},context:t.context},on:{remove:t.removeItem}},[t._t("default")],2)})),1)};K._withStripped=!0;var Z=_({render:K,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0),J={props:{context:{type:Object,required:!0}}},X=function(){var t=this.$createElement;return(this._self._c||t)("label",{class:"formulate-input-label formulate-input-label--"+this.context.labelPosition,attrs:{for:this.context.id},domProps:{textContent:this._s(this.context.label)}})};X._withStripped=!0;var Q=_({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={props:{context:{type:Object,required:!0},addMore:{type:Function,required:!0}}},et=function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"formulate-input-group-add-more"},[e("FormulateInput",{attrs:{type:"button",label:this.context.addLabel,"data-minor":"","data-ghost":""},on:{click:this.addMore}})],1)};et._withStripped=!0;var rt=_({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),it={props:{context:{type:Object,required:!0},removeItem:{type:Function,required:!0},index:{type:Number,required:!0}}},ot=function(){var t=this.$createElement,e=this._self._c||t;return e("div",{staticClass:"formulate-input-group-repeatable"},[e("FormulateSlot",{attrs:{name:"remove",context:this.context,"remove-item":this.removeItem}},[e(this.context.slotComponents.remove,{tag:"component",attrs:{context:this.context,"remove-item":this.removeItem}})],1),this._v(" "),this._t("default")],2)};ot._withStripped=!0;var nt=_({render:ot,staticRenderFns:[]},void 0,it,void 0,!1,void 0,!1,void 0,void 0,void 0);function st(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&-1===e.indexOf(i)&&(r[i]=t[i]);return r}var at={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subType:function(){return"group"===this.context.type?"grouping":"inputs"},optionsWithContext:function(){var t=this,e=this.context,r=e.attributes,i=(r.id,st(r,["id"])),o=(e.blurHandler,e.classification,e.component,e.getValidationErrors,e.hasLabel,e.hasValidationErrors,e.isSubField,e.labelPosition,e.options,e.performValidation,e.setErrors,e.slotComponents,e.validationErrors,e.visibleValidationErrors,e.help,st(e,["attributes","blurHandler","classification","component","getValidationErrors","hasLabel","hasValidationErrors","isSubField","labelPosition","options","performValidation","setErrors","slotComponents","validationErrors","visibleValidationErrors","help"]));return this.options.map((function(e){return t.groupItemContext(o,e,i)}))},canAddMore:function(){return this.context.repeatable&&this.items.length<this.context.limit},items:function(){return Array.isArray(this.context.model)?this.context.model:[{}]}},methods:{addItem:function(){Array.isArray(this.context.model)?this.context.model.push(m({})):this.context.model=this.items.concat([m({})])},groupItemContext:function(t,e,r){return Object.assign({},t,e,r,{},t.hasGivenName?{}:{name:!0})}}},lt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-group",attrs:{"data-is-repeatable":t.context.repeatable}},["grouping"!==t.subType?t._l(t.optionsWithContext,(function(e){return r("FormulateInput",t._b({key:e.id,staticClass:"formulate-input-group-item",attrs:{"disable-errors":!0},on:{blur:t.context.blurHandler},model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"FormulateInput",e,!1))})):[r("FormulateGrouping",{attrs:{context:t.context}},[t._t("default")],2),t._v(" "),t.canAddMore?r("FormulateSlot",{attrs:{name:"addmore",context:t.context,"add-more":t.addItem}},[r(t.context.slotComponents.addMore,{tag:"component",attrs:{context:t.context,"add-more":t.addItem},on:{add:t.addItem}})],1):t._e()]],2)};lt._withStripped=!0;var ut=_({render:lt,staticRenderFns:[]},void 0,at,void 0,!1,void 0,!1,void 0,void 0,void 0),ct={provide:function(){var t=this;return Object.assign({},S(this),{formulateSetter:function(e,r){return t.setFieldValue(e,r)}})},inject:{registerProvider:"registerProvider",deregisterProvider:"deregisterProvider"},props:{index:{type:Number,required:!0},context:{type:Object,required:!0},setFieldValue:{type:Function,required:!0}},data:function(){return Object.assign({},w(this),{isGrouping:!0})},computed:Object.assign({},O()),created:function(){this.registerProvider(this)},beforeDestroy:function(){this.deregisterProvider(this)},methods:Object.assign({},j(["setFieldValue"]),{removeItem:function(){this.$emit("remove",this.index)}})},ht=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("FormulateSlot",{attrs:{name:"repeatable",context:t.context,index:t.index,"remove-item":t.removeItem}},[r(t.context.slotComponents.repeatable,{tag:"component",attrs:{context:t.context,index:t.index,"remove-item":t.removeItem}},[r("FormulateSlot",{attrs:{context:t.context,index:t.index,name:"default"}})],1)],1)};ht._withStripped=!0;var dt=_({render:ht,staticRenderFns:[]},void 0,ct,void 0,!1,void 0,!1,void 0,void 0,void 0),ft={props:{context:{type:Object,required:!0},removeItem:{type:Function,required:!0}}},pt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.context.repeatable?r("a",{staticClass:"formulate-input-group-repeatable-remove",attrs:{role:"button"},domProps:{textContent:t._s("Remove")},on:{click:function(e){return e.preventDefault(),t.removeItem(e)},keypress:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.removeItem(e)}}}):t._e()};pt._withStripped=!0;var mt=_({render:pt,staticRenderFns:[]},void 0,ft,void 0,!1,void 0,!1,void 0,void 0,void 0),vt=function(){this.options={},this.defaults={components:{FormulateSlot:E,FormulateForm:R,FormulateHelp:Y,FormulateLabel:Q,FormulateInput:M,FormulateErrors:T,FormulateAddMore:rt,FormulateGrouping:Z,FormulateRepeatable:nt,FormulateInputGroup:ut,FormulateRepeatableRemove:mt,FormulateRepeatableProvider:dt},slotComponents:{label:"FormulateLabel",help:"FormulateHelp",errors:"FormulateErrors",repeatable:"FormulateRepeatable",addMore:"FormulateAddMore",remove:"FormulateRepeatableRemove"},library:n,rules:v,mimes:g,locale:!1,uploader:b,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,errorHandler:function(t){return t},plugins:[i],locales:{},idPrefix:"formulate-"},this.registry=new Map,this.idRegistry={}};vt.prototype.install=function(t,e){var r=this;t.prototype.$formulate=this,this.options=this.defaults;var i=this.defaults.plugins;for(var o in e&&Array.isArray(e.plugins)&&e.plugins.length&&(i=i.concat(e.plugins)),i.forEach((function(t){return"function"==typeof t?t(r):null})),this.extend(e||{}),this.options.components)t.component(o,this.options.components[o])},vt.prototype.nextId=function(t){var e=!(!t.$route||!t.$route.path)&&t.$route.path?t.$route.path.replace(/[/\\.\s]/g,"-"):"global";return Object.prototype.hasOwnProperty.call(this.idRegistry,e)||(this.idRegistry[e]=0),""+this.options.idPrefix+e+"-"+ ++this.idRegistry[e]},vt.prototype.extend=function(t){if("object"==typeof t)return this.options=this.merge(this.options,t),this;throw new Error("VueFormulate extend() should be passed an object (was "+typeof t+")")},vt.prototype.merge=function(t,e,i){void 0===i&&(i=!0);var o={};for(var n in t)e.hasOwnProperty(n)?r(e[n])&&r(t[n])?o[n]=this.merge(t[n],e[n],i):i&&Array.isArray(t[n])&&Array.isArray(e[n])?o[n]=t[n].concat(e[n]):o[n]=e[n]:o[n]=t[n];for(var s in e)o.hasOwnProperty(s)||(o[s]=e[s]);return o},vt.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},vt.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},vt.prototype.slotComponent=function(t,e){var r=this.options.library[t];return r&&r.slotComponents&&r.slotComponents[e]?r.slotComponents[e]:this.options.slotComponents[e]},vt.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},vt.prototype.i18n=function(t){if(t.$i18n)switch(typeof t.$i18n.locale){case"string":return t.$i18n.locale;case"function":return t.$i18n.locale()}return!1},vt.prototype.getLocale=function(t){var e=this;return this.selectedLocale||(this.selectedLocale=[this.options.locale,this.i18n(t),"en"].reduce((function(t,r){if(t)return t;if(r){var i=function(t){return t.split("-").reduce((function(t,e){return t.length&&t.unshift(t[0]+"-"+e),t.length?t:[e]}),[])}(r).find((function(t){return p(e.options.locales,t)}));i&&(t=i)}return t}),!1)),this.selectedLocale},vt.prototype.validationMessage=function(t,e,r){var i=this.options.locales[this.getLocale(r)];return i.hasOwnProperty(t)?i[t](e):"_"===t[0]&&i.hasOwnProperty(t.substr(1))?i[t.substr(1)](e):i.hasOwnProperty("default")?i.default(e):"This field does not have a valid value"},vt.prototype.register=function(t){"FormulateForm"===t.$options.name&&t.name&&this.registry.set(t.name,t)},vt.prototype.deregister=function(t){"FormulateForm"===t.$options.name&&t.name&&this.registry.has(t.name)&&this.registry.delete(t.name)},vt.prototype.handle=function(t,e,r){void 0===r&&(r=!1);var i=r?t:this.options.errorHandler(t,e);return e&&this.registry.has(e)&&this.registry.get(e).applyErrors({formErrors:c(i.formErrors),inputErrors:i.inputErrors||{}}),i},vt.prototype.reset=function(t,e){void 0===e&&(e={}),this.resetValidation(t),this.setValues(t,e)},vt.prototype.resetValidation=function(t){var e=this.registry.get(t);e.hideErrors(t),e.namedErrors=[],e.namedFieldErrors={}},vt.prototype.setValues=function(t,e){e&&!Array.isArray(e)&&"object"==typeof e&&this.registry.get(t).setValues(Object.assign({},e))},vt.prototype.getUploader=function(){return this.options.uploader||!1},vt.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},vt.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},vt.prototype.createUpload=function(t,e){return new s(t,e,this.options)};var yt=new vt;export default yt;
|