From c7a3e1a015b878d0f81dc4a17ac1c6a02982f25d Mon Sep 17 00:00:00 2001 From: Justin Schroeder Date: Mon, 2 Mar 2020 14:01:54 -0500 Subject: [PATCH 1/8] 2.1.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4e2a8ce..333710a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@braid/vue-formulate", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 44f54cf..2719209 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@braid/vue-formulate", - "version": "2.1.0", + "version": "2.1.1", "description": "The easiest way to build forms in Vue.", "main": "dist/formulate.umd.js", "module": "dist/formulate.esm.js", From 4bfe43719d8cfde4716642ee863cd9570304441f Mon Sep 17 00:00:00 2001 From: Andrew Boyd Date: Tue, 3 Mar 2020 06:53:04 -0500 Subject: [PATCH 2/8] Adds startsWith and endsWith validation rules (#9) * adds language definitions for new rules * re-order rules file to order rule definitions alphabetically * adds support for endsWith validation rule and converts snake_case rules to camelCase function calls * adds support for startsWith field validation * better en.js definitions for new validations * adds tests for snakeCaseToCamelCase function --- dist/formulate.esm.js | 2 +- dist/formulate.min.js | 4 +- dist/formulate.umd.js | 2 +- src/libs/rules.js | 70 ++++-- src/libs/utils.js | 15 +- src/locales/en.js | 20 ++ test/rules.test.js | 548 +++++++++++++++++++++++------------------- test/utils.test.js | 24 +- 8 files changed, 407 insertions(+), 278 deletions(-) diff --git a/dist/formulate.esm.js b/dist/formulate.esm.js index 9ae3d8d..ad830a1 100644 --- a/dist/formulate.esm.js +++ b/dist/formulate.esm.js @@ -1 +1 @@ -import t from"is-url";import e from"nanoid/non-secure";import o from"is-plain-object";var n={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},i={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},r=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function s(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),i=o.length;if(n.length!==i)return!1;for(var r=0;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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},r.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}},r.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)}}))},r.prototype.getFileList=function(){return this.fileList},r.prototype.getFiles=function(){return this.files},r.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var d={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&i>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&ie&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof r?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},url:function(e){var o=e.value;return Promise.resolve(t(o))}},m={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be after "+o[0]+".":u(e)+" must be a later date."},alpha:function(t){return u(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return u(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be before "+o[0]+".":u(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?u(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":u(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return u(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" is not a valid, please use the format "+o[0]:u(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+u(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return u(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be less than or equal to "+n[0]+".":u(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return u(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be more than "+n[0]+".":u(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return u(t.name)+" must be a number."},required:function(t){return u(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function f(t,e,o,n){return new Promise((function(o,i){var r=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,i=Math.min(100,Math.round(n/r*100));if(e(i),i>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var h={context:function(){return y.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:x.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:v.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,o){return v.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:v.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return l(this.errors).concat(l(this.error)).concat(l(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function v(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var o=[];for(var n in t)o.push({value:n,label:t[n],id:this.elementAttributes.id+"_"+n});return o}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function x(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:g.bind(this),set:b.bind(this)})}function g(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){s(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function w(t,e,o,n,i,r,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,i&&(p.functional=!0)),n&&(p._scopeId=n),r?(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(r)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var m=p.beforeCreate;p.beforeCreate=m?[].concat(m,c):[c]}return o}var F={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},h,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||s(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!s(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!s(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){s(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=c(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],i=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(i=i instanceof Promise?i:Promise.resolve(i)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},_=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var P=w({render:_,staticRenderFns:[]},void 0,F,void 0,!1,void 0,!1,void 0,void 0,void 0),V=function(t){this.form=t};V.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},V.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],i=function t(e){var o={};for(var n in e)e[n]instanceof r||p(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(i,((o={})[e]=t,o))})))};for(var s in i)a(s);Promise.all(n).then((function(){return e(i)})).catch((function(t){return o(t)}))}))};var A={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||s(t[o],this.internalFormModelProxy[o])||s(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||s(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new V(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},O=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};O._withStripped=!0;var j=w({render:O,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),$={props:{errors:{type:[Boolean,Array],required:!0}}},N=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var I=w({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);function E(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var S={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,E(o,["id"])),i=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,E(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(i,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},C=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};C._withStripped=!0;var D=w({render:C,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0),U={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},k={name:"FormulateInputBox",mixins:[U]},B=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t.context.value,a=t._i(o,r);n.checked?a<0&&t.$set(t.context,"model",o.concat([r])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};B._withStripped=!0;var M=w({render:B,staticRenderFns:[]},void 0,k,void 0,!1,void 0,!1,void 0,void 0,void 0),L={name:"FormulateInputText",mixins:[U]},T=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};T._withStripped=!0;var R=w({render:T,staticRenderFns:[]},void 0,L,void 0,!1,void 0,!1,void 0,void 0,void 0),z={name:"FormulateFiles",props:{files:{type:r,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},H=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};H._withStripped=!0;var q={name:"FormulateInputFile",components:{FormulateFiles:w({render:H,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[U],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof r&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},G=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};G._withStripped=!0;var Y=w({render:G,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateInputButton",mixins:[U]},K=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};K._withStripped=!0;var Z=w({render:K,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"FormulateInputSelect",mixins:[U],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};X._withStripped=!0;var Q=w({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputSlider",mixins:[U]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};et._withStripped=!0;var ot=w({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputTextArea",mixins:[U]},it=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};it._withStripped=!0;var rt=w({render:it,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at=function(){this.options={},this.defaults={components:{FormulateForm:j,FormulateInput:P,FormulateInputErrors:I,FormulateInputBox:M,FormulateInputText:R,FormulateInputFile:Y,FormulateInputGroup:D,FormulateInputButton:Z,FormulateInputSelect:Q,FormulateInputSlider:ot,FormulateInputTextArea:rt},library:n,rules:d,locale:"en",uploader:f,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:m}}};at.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},at.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+")")},at.prototype.merge=function(t,e,n){void 0===n&&(n=!0);var i={};for(var r in t)e.hasOwnProperty(r)?o(e[r])&&o(t[r])?i[r]=this.merge(t[r],e[r],n):n&&Array.isArray(t[r])&&Array.isArray(e[r])?i[r]=t[r].concat(e[r]):i[r]=e[r]:i[r]=t[r];for(var a in e)i.hasOwnProperty(a)||(i[a]=e[a]);return i},at.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},at.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},at.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},at.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},at.prototype.getUploader=function(){return this.options.uploader||!1},at.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},at.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},at.prototype.createUpload=function(t,e){return new r(t,e,this.options)};var st=new at;export default st; +import t from"is-url";import e from"nanoid/non-secure";import o from"is-plain-object";var n={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},i={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},r=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function s(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),i=o.length;if(n.length!==i)return!1;for(var r=0;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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},r.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}},r.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)}}))},r.prototype.getFileList=function(){return this.fileList},r.prototype.getFiles=function(){return this.files},r.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var d={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&i>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&ie&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.endsWith(t)})))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof r?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.startsWith(t)})))},url:function(e){var o=e.value;return Promise.resolve(t(o))}},f={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be after "+o[0]+".":u(e)+" must be a later date."},alpha:function(t){return u(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return u(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be before "+o[0]+".":u(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?u(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":u(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return u(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" is not a valid, please use the format "+o[0]:u(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+u(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return u(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be less than or equal to "+n[0]+".":u(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return u(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be more than "+n[0]+".":u(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return u(t.name)+" must be a number."},required:function(t){return u(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,o,n){return new Promise((function(o,i){var r=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,i=Math.min(100,Math.round(n/r*100));if(e(i),i>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var h={context:function(){return y.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:x.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:v.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,o){return v.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:v.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return l(this.errors).concat(l(this.error)).concat(l(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function v(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var o=[];for(var n in t)o.push({value:n,label:t[n],id:this.elementAttributes.id+"_"+n});return o}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function x(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:g.bind(this),set:b.bind(this)})}function g(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){s(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function w(t,e,o,n,i,r,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,i&&(p.functional=!0)),n&&(p._scopeId=n),r?(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(r)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var F={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},h,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||s(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!s(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!s(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){s(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=c(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],i=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(i=i instanceof Promise?i:Promise.resolve(i)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},_=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var P=w({render:_,staticRenderFns:[]},void 0,F,void 0,!1,void 0,!1,void 0,void 0,void 0),V=function(t){this.form=t};V.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},V.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],i=function t(e){var o={};for(var n in e)e[n]instanceof r||p(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(i,((o={})[e]=t,o))})))};for(var s in i)a(s);Promise.all(n).then((function(){return e(i)})).catch((function(t){return o(t)}))}))};var A={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||s(t[o],this.internalFormModelProxy[o])||s(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||s(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new V(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},O=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};O._withStripped=!0;var j=w({render:O,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),$={props:{errors:{type:[Boolean,Array],required:!0}}},N=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var I=w({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);function E(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var S={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,E(o,["id"])),i=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,E(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(i,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},C=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};C._withStripped=!0;var D=w({render:C,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0),U={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},k={name:"FormulateInputBox",mixins:[U]},B=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t.context.value,a=t._i(o,r);n.checked?a<0&&t.$set(t.context,"model",o.concat([r])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};B._withStripped=!0;var M=w({render:B,staticRenderFns:[]},void 0,k,void 0,!1,void 0,!1,void 0,void 0,void 0),T={name:"FormulateInputText",mixins:[U]},L=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};L._withStripped=!0;var R=w({render:L,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0),z={name:"FormulateFiles",props:{files:{type:r,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},H=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};H._withStripped=!0;var q={name:"FormulateInputFile",components:{FormulateFiles:w({render:H,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[U],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof r&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},W=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};W._withStripped=!0;var G=w({render:W,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[U]},K=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};K._withStripped=!0;var Z=w({render:K,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"FormulateInputSelect",mixins:[U],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};X._withStripped=!0;var Q=w({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputSlider",mixins:[U]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};et._withStripped=!0;var ot=w({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputTextArea",mixins:[U]},it=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};it._withStripped=!0;var rt=w({render:it,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at=function(){this.options={},this.defaults={components:{FormulateForm:j,FormulateInput:P,FormulateInputErrors:I,FormulateInputBox:M,FormulateInputText:R,FormulateInputFile:G,FormulateInputGroup:D,FormulateInputButton:Z,FormulateInputSelect:Q,FormulateInputSlider:ot,FormulateInputTextArea:rt},library:n,rules:d,locale:"en",uploader:m,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:f}}};at.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},at.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+")")},at.prototype.merge=function(t,e,n){void 0===n&&(n=!0);var i={};for(var r in t)e.hasOwnProperty(r)?o(e[r])&&o(t[r])?i[r]=this.merge(t[r],e[r],n):n&&Array.isArray(t[r])&&Array.isArray(e[r])?i[r]=t[r].concat(e[r]):i[r]=e[r]:i[r]=t[r];for(var a in e)i.hasOwnProperty(a)||(i[a]=e[a]);return i},at.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},at.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},at.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},at.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},at.prototype.getUploader=function(){return this.options.uploader||!1},at.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},at.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},at.prototype.createUpload=function(t,e){return new r(t,e,this.options)};var st=new at;export default st; diff --git a/dist/formulate.min.js b/dist/formulate.min.js index 067afec..2538c9c 100644 --- a/dist/formulate.min.js +++ b/dist/formulate.min.js @@ -1,4 +1,4 @@ -var VueFormulate=function(){"use strict";var t={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},e=function(t){if("string"!=typeof t)return!1;var e=t.match(o);if(!e)return!1;var i=e[1];if(!i)return!1;if(n.test(i)||r.test(i))return!0;return!1},o=/^(?:\w+:)?\/\/(\S+)$/,n=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,r=/^[^\s\.]+\.\S{2,}$/;for(var i="-_",a=36;a--;)i+=a.toString(36);for(a=36;a---10;)i+=a.toString(36).toUpperCase();var s=function(t){var e="";for(a=t||21;a--;)e+=i[64*Math.random()|0];return e},l={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},u=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function c(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function p(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),r=o.length;if(n.length!==r)return!1;for(var i=0;i=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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},u.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}},u.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)}}))},u.prototype.getFileList=function(){return this.fileList},u.prototype.getFiles=function(){return this.files},u.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 o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),r=Date.parse(o);return Promise.resolve(!isNaN(r)&&r>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},r=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[r].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},r=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[r].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),r=Date.parse(o);return Promise.resolve(!isNaN(r)&&re&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?p(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof u)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?p(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof u?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},url:function(t){var o=t.value;return Promise.resolve(e(o))}},y={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" must be after "+o[0]+".":f(e)+" must be a later date."},alpha:function(t){return f(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return f(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" must be before "+o[0]+".":f(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?f(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":f(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return f(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" is not a valid, please use the format "+o[0]:f(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+f(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return f(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var r=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==r||"value"===r?f(e)+" must be less than or equal to "+n[0]+".":f(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return f(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var r=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==r||"value"===r?f(e)+" must be more than "+n[0]+".":f(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return f(t.name)+" must be a number."},required:function(t){return f(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}}; +var VueFormulate=function(){"use strict";var t={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},e=function(t){if("string"!=typeof t)return!1;var e=t.match(o);if(!e)return!1;var i=e[1];if(!i)return!1;if(n.test(i)||r.test(i))return!0;return!1},o=/^(?:\w+:)?\/\/(\S+)$/,n=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,r=/^[^\s\.]+\.\S{2,}$/;for(var i="-_",a=36;a--;)i+=a.toString(36);for(a=36;a---10;)i+=a.toString(36).toUpperCase();var s=function(t){var e="";for(a=t||21;a--;)e+=i[64*Math.random()|0];return e},l={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},u=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function c(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function p(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),r=o.length;if(n.length!==r)return!1;for(var i=0;i=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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},u.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}},u.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)}}))},u.prototype.getFileList=function(){return this.fileList},u.prototype.getFiles=function(){return this.files},u.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 o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),r=Date.parse(o);return Promise.resolve(!isNaN(r)&&r>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},r=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[r].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},r=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[r].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),r=Date.parse(o);return Promise.resolve(!isNaN(r)&&re&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.endsWith(t)})))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?p(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof u)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?p(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof u?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.startsWith(t)})))},url:function(t){var o=t.value;return Promise.resolve(e(o))}},y={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" must be after "+o[0]+".":f(e)+" must be a later date."},alpha:function(t){return f(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return f(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" must be before "+o[0]+".":f(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?f(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":f(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return f(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" is not a valid, please use the format "+o[0]:f(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+f(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return f(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var r=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==r||"value"===r?f(e)+" must be less than or equal to "+n[0]+".":f(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return f(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var r=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==r||"value"===r?f(e)+" must be more than "+n[0]+".":f(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return f(t.name)+" must be a number."},required:function(t){return f(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}}; /*! * is-plain-object * @@ -12,4 +12,4 @@ function x(t){return!0==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e)) * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ -var e}function g(t){var e,o;return!1!==x(t)&&("function"==typeof(e=t.constructor)&&(!1!==x(o=e.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))}function b(t,e,o,n){return new Promise((function(o,r){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,r=Math.min(100,Math.round(n/i*100));if(e(r),r>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var w={context:function(){return P.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:_.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:F.call(this,this.options),optionGroups:!!this.optionGroups&&c(this.optionGroups,(function(e,o){return F.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:F.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return d(this.errors).concat(d(this.error)).concat(d(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function F(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var o in t)e.push({value:o,label:t[o],id:this.elementAttributes.id+"_"+o});return e}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||s(9)}]:t}function _(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function P(t){return Object.defineProperty(t,"model",{get:V.bind(this),set:A.bind(this)})}function V(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function A(t){p(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function O(t,e,o,n,r,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,r&&(p.functional=!0)),n&&(p._scopeId=n),i?(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(i)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var j={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:s(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},w,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||p(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!p(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!p(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){p(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=m(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],r=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(r=r instanceof Promise?r:Promise.resolve(r)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},$=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};$._withStripped=!0;var N=O({render:$,staticRenderFns:[]},void 0,j,void 0,!1,void 0,!1,void 0,void 0,void 0),I=function(t){this.form=t};I.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},I.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],r=function t(e){var o={};for(var n in e)e[n]instanceof u||h(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),i=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof u&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(r,((o={})[e]=t,o))})))};for(var a in r)i(a);Promise.all(n).then((function(){return e(r)})).catch((function(t){return o(t)}))}))};var E={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||p(t[o],this.internalFormModelProxy[o])||p(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||p(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new I(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},S=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};S._withStripped=!0;var C=O({render:S,staticRenderFns:[]},void 0,E,void 0,!1,void 0,!1,void 0,void 0,void 0),D={props:{errors:{type:[Boolean,Array],required:!0}}},U=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};U._withStripped=!0;var k=O({render:U,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0);function B(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var M={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,B(o,["id"])),r=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,B(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(r,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},L=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};L._withStripped=!0;var T=O({render:L,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),R={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},z={name:"FormulateInputBox",mixins:[R]},H=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t.context.value,a=t._i(o,i);n.checked?a<0&&t.$set(t.context,"model",o.concat([i])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};H._withStripped=!0;var q=O({render:H,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0),G={name:"FormulateInputText",mixins:[R]},Y=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t._i(o,null);n.checked?i<0&&t.$set(t.context,"model",o.concat([null])):i>-1&&t.$set(t.context,"model",o.slice(0,i).concat(o.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};Y._withStripped=!0;var W=O({render:Y,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateFiles",props:{files:{type:u,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},Z=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};Z._withStripped=!0;var J={name:"FormulateInputFile",components:{FormulateFiles:O({render:Z,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[R],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof u&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof u&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};X._withStripped=!0;var Q=O({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputButton",mixins:[R]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};et._withStripped=!0;var ot=O({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputSelect",mixins:[R],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},rt=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};rt._withStripped=!0;var it=O({render:rt,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at={name:"FormulateInputSlider",mixins:[R]},st=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t._i(o,null);n.checked?i<0&&t.$set(t.context,"model",o.concat([null])):i>-1&&t.$set(t.context,"model",o.slice(0,i).concat(o.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};st._withStripped=!0;var lt=O({render:st,staticRenderFns:[]},void 0,at,void 0,!1,void 0,!1,void 0,void 0,void 0),ut={name:"FormulateInputTextArea",mixins:[R]},ct=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};ct._withStripped=!0;var pt=O({render:ct,staticRenderFns:[]},void 0,ut,void 0,!1,void 0,!1,void 0,void 0,void 0),dt=function(){this.options={},this.defaults={components:{FormulateForm:C,FormulateInput:N,FormulateInputErrors:k,FormulateInputBox:q,FormulateInputText:W,FormulateInputFile:Q,FormulateInputGroup:T,FormulateInputButton:ot,FormulateInputSelect:it,FormulateInputSlider:lt,FormulateInputTextArea:pt},library:t,rules:v,locale:"en",uploader:b,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:y}}};return dt.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},dt.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+")")},dt.prototype.merge=function(t,e,o){void 0===o&&(o=!0);var n={};for(var r in t)e.hasOwnProperty(r)?g(e[r])&&g(t[r])?n[r]=this.merge(t[r],e[r],o):o&&Array.isArray(t[r])&&Array.isArray(e[r])?n[r]=t[r].concat(e[r]):n[r]=e[r]:n[r]=t[r];for(var i in e)n.hasOwnProperty(i)||(n[i]=e[i]);return n},dt.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},dt.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},dt.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},dt.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},dt.prototype.getUploader=function(){return this.options.uploader||!1},dt.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},dt.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},dt.prototype.createUpload=function(t,e){return new u(t,e,this.options)},new dt}(); +var e}function g(t){var e,o;return!1!==x(t)&&("function"==typeof(e=t.constructor)&&(!1!==x(o=e.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))}function b(t,e,o,n){return new Promise((function(o,r){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,r=Math.min(100,Math.round(n/i*100));if(e(r),r>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var w={context:function(){return P.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:_.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:F.call(this,this.options),optionGroups:!!this.optionGroups&&c(this.optionGroups,(function(e,o){return F.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:F.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return d(this.errors).concat(d(this.error)).concat(d(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function F(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var o in t)e.push({value:o,label:t[o],id:this.elementAttributes.id+"_"+o});return e}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||s(9)}]:t}function _(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function P(t){return Object.defineProperty(t,"model",{get:V.bind(this),set:A.bind(this)})}function V(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function A(t){p(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function O(t,e,o,n,r,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,r&&(p.functional=!0)),n&&(p._scopeId=n),i?(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(i)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var j={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:s(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},w,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||p(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!p(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!p(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){p(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=m(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],r=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(r=r instanceof Promise?r:Promise.resolve(r)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},$=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};$._withStripped=!0;var N=O({render:$,staticRenderFns:[]},void 0,j,void 0,!1,void 0,!1,void 0,void 0,void 0),I=function(t){this.form=t};I.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},I.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],r=function t(e){var o={};for(var n in e)e[n]instanceof u||h(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),i=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof u&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(r,((o={})[e]=t,o))})))};for(var a in r)i(a);Promise.all(n).then((function(){return e(r)})).catch((function(t){return o(t)}))}))};var E={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||p(t[o],this.internalFormModelProxy[o])||p(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||p(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new I(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},S=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};S._withStripped=!0;var C=O({render:S,staticRenderFns:[]},void 0,E,void 0,!1,void 0,!1,void 0,void 0,void 0),D={props:{errors:{type:[Boolean,Array],required:!0}}},U=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};U._withStripped=!0;var k=O({render:U,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0);function B(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var M={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,B(o,["id"])),r=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,B(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(r,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},T=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};T._withStripped=!0;var L=O({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),R={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},z={name:"FormulateInputBox",mixins:[R]},H=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t.context.value,a=t._i(o,i);n.checked?a<0&&t.$set(t.context,"model",o.concat([i])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};H._withStripped=!0;var q=O({render:H,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateInputText",mixins:[R]},G=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t._i(o,null);n.checked?i<0&&t.$set(t.context,"model",o.concat([null])):i>-1&&t.$set(t.context,"model",o.slice(0,i).concat(o.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};G._withStripped=!0;var Y=O({render:G,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateFiles",props:{files:{type:u,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},Z=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};Z._withStripped=!0;var J={name:"FormulateInputFile",components:{FormulateFiles:O({render:Z,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[R],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof u&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof u&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};X._withStripped=!0;var Q=O({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputButton",mixins:[R]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};et._withStripped=!0;var ot=O({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputSelect",mixins:[R],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},rt=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};rt._withStripped=!0;var it=O({render:rt,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at={name:"FormulateInputSlider",mixins:[R]},st=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t._i(o,null);n.checked?i<0&&t.$set(t.context,"model",o.concat([null])):i>-1&&t.$set(t.context,"model",o.slice(0,i).concat(o.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};st._withStripped=!0;var lt=O({render:st,staticRenderFns:[]},void 0,at,void 0,!1,void 0,!1,void 0,void 0,void 0),ut={name:"FormulateInputTextArea",mixins:[R]},ct=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};ct._withStripped=!0;var pt=O({render:ct,staticRenderFns:[]},void 0,ut,void 0,!1,void 0,!1,void 0,void 0,void 0),dt=function(){this.options={},this.defaults={components:{FormulateForm:C,FormulateInput:N,FormulateInputErrors:k,FormulateInputBox:q,FormulateInputText:Y,FormulateInputFile:Q,FormulateInputGroup:L,FormulateInputButton:ot,FormulateInputSelect:it,FormulateInputSlider:lt,FormulateInputTextArea:pt},library:t,rules:v,locale:"en",uploader:b,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:y}}};return dt.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},dt.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+")")},dt.prototype.merge=function(t,e,o){void 0===o&&(o=!0);var n={};for(var r in t)e.hasOwnProperty(r)?g(e[r])&&g(t[r])?n[r]=this.merge(t[r],e[r],o):o&&Array.isArray(t[r])&&Array.isArray(e[r])?n[r]=t[r].concat(e[r]):n[r]=e[r]:n[r]=t[r];for(var i in e)n.hasOwnProperty(i)||(n[i]=e[i]);return n},dt.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},dt.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},dt.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},dt.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},dt.prototype.getUploader=function(){return this.options.uploader||!1},dt.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},dt.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},dt.prototype.createUpload=function(t,e){return new u(t,e,this.options)},new dt}(); diff --git a/dist/formulate.umd.js b/dist/formulate.umd.js index f5841d7..ea3f9e2 100644 --- a/dist/formulate.umd.js +++ b/dist/formulate.umd.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("is-url"),require("nanoid/non-secure"),require("is-plain-object")):"function"==typeof define&&define.amd?define(["is-url","nanoid/non-secure","is-plain-object"],e):(t=t||self).Formulate=e(t.isUrl,t.nanoid,t.isPlainObject)}(this,(function(t,e,o){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,o=o&&o.hasOwnProperty("default")?o.default:o;var n={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},i={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},r=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function s(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),i=o.length;if(n.length!==i)return!1;for(var r=0;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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},r.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}},r.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)}}))},r.prototype.getFileList=function(){return this.fileList},r.prototype.getFiles=function(){return this.files},r.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var d={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&i>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&ie&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof r?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},url:function(e){var o=e.value;return Promise.resolve(t(o))}},f={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be after "+o[0]+".":u(e)+" must be a later date."},alpha:function(t){return u(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return u(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be before "+o[0]+".":u(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?u(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":u(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return u(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" is not a valid, please use the format "+o[0]:u(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+u(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return u(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be less than or equal to "+n[0]+".":u(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return u(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be more than "+n[0]+".":u(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return u(t.name)+" must be a number."},required:function(t){return u(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,o,n){return new Promise((function(o,i){var r=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,i=Math.min(100,Math.round(n/r*100));if(e(i),i>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var h={context:function(){return y.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:x.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:v.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,o){return v.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:v.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return l(this.errors).concat(l(this.error)).concat(l(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function v(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var o=[];for(var n in t)o.push({value:n,label:t[n],id:this.elementAttributes.id+"_"+n});return o}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function x(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:g.bind(this),set:b.bind(this)})}function g(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){s(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function w(t,e,o,n,i,r,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,i&&(p.functional=!0)),n&&(p._scopeId=n),r?(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(r)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var F={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},h,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||s(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!s(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!s(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){s(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=c(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],i=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(i=i instanceof Promise?i:Promise.resolve(i)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},_=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var P=w({render:_,staticRenderFns:[]},void 0,F,void 0,!1,void 0,!1,void 0,void 0,void 0),V=function(t){this.form=t};V.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},V.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],i=function t(e){var o={};for(var n in e)e[n]instanceof r||p(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(i,((o={})[e]=t,o))})))};for(var s in i)a(s);Promise.all(n).then((function(){return e(i)})).catch((function(t){return o(t)}))}))};var A={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||s(t[o],this.internalFormModelProxy[o])||s(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||s(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new V(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},O=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};O._withStripped=!0;var j=w({render:O,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),$={props:{errors:{type:[Boolean,Array],required:!0}}},N=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var I=w({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);function E(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var S={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,E(o,["id"])),i=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,E(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(i,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},C=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};C._withStripped=!0;var D=w({render:C,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0),U={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},k={name:"FormulateInputBox",mixins:[U]},B=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t.context.value,a=t._i(o,r);n.checked?a<0&&t.$set(t.context,"model",o.concat([r])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};B._withStripped=!0;var M=w({render:B,staticRenderFns:[]},void 0,k,void 0,!1,void 0,!1,void 0,void 0,void 0),L={name:"FormulateInputText",mixins:[U]},T=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};T._withStripped=!0;var R=w({render:T,staticRenderFns:[]},void 0,L,void 0,!1,void 0,!1,void 0,void 0,void 0),q={name:"FormulateFiles",props:{files:{type:r,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},z=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};z._withStripped=!0;var H={name:"FormulateInputFile",components:{FormulateFiles:w({render:z,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[U],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof r&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},G=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};G._withStripped=!0;var Y=w({render:G,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateInputButton",mixins:[U]},K=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};K._withStripped=!0;var Z=w({render:K,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"FormulateInputSelect",mixins:[U],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};X._withStripped=!0;var Q=w({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputSlider",mixins:[U]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};et._withStripped=!0;var ot=w({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputTextArea",mixins:[U]},it=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};it._withStripped=!0;var rt=w({render:it,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at=function(){this.options={},this.defaults={components:{FormulateForm:j,FormulateInput:P,FormulateInputErrors:I,FormulateInputBox:M,FormulateInputText:R,FormulateInputFile:Y,FormulateInputGroup:D,FormulateInputButton:Z,FormulateInputSelect:Q,FormulateInputSlider:ot,FormulateInputTextArea:rt},library:n,rules:d,locale:"en",uploader:m,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:f}}};return at.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},at.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+")")},at.prototype.merge=function(t,e,n){void 0===n&&(n=!0);var i={};for(var r in t)e.hasOwnProperty(r)?o(e[r])&&o(t[r])?i[r]=this.merge(t[r],e[r],n):n&&Array.isArray(t[r])&&Array.isArray(e[r])?i[r]=t[r].concat(e[r]):i[r]=e[r]:i[r]=t[r];for(var a in e)i.hasOwnProperty(a)||(i[a]=e[a]);return i},at.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},at.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},at.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},at.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},at.prototype.getUploader=function(){return this.options.uploader||!1},at.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},at.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},at.prototype.createUpload=function(t,e){return new r(t,e,this.options)},new at})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("is-url"),require("nanoid/non-secure"),require("is-plain-object")):"function"==typeof define&&define.amd?define(["is-url","nanoid/non-secure","is-plain-object"],e):(t=t||self).Formulate=e(t.isUrl,t.nanoid,t.isPlainObject)}(this,(function(t,e,o){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,o=o&&o.hasOwnProperty("default")?o.default:o;var n={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},i={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},r=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function s(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),i=o.length;if(n.length!==i)return!1;for(var r=0;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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},r.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}},r.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)}}))},r.prototype.getFileList=function(){return this.fileList},r.prototype.getFiles=function(){return this.files},r.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var d={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&i>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&ie&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.endsWith(t)})))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof r?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.startsWith(t)})))},url:function(e){var o=e.value;return Promise.resolve(t(o))}},f={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be after "+o[0]+".":u(e)+" must be a later date."},alpha:function(t){return u(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return u(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be before "+o[0]+".":u(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?u(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":u(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return u(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" is not a valid, please use the format "+o[0]:u(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+u(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return u(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be less than or equal to "+n[0]+".":u(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return u(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be more than "+n[0]+".":u(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return u(t.name)+" must be a number."},required:function(t){return u(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,o,n){return new Promise((function(o,i){var r=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,i=Math.min(100,Math.round(n/r*100));if(e(i),i>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var h={context:function(){return y.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:x.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:v.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,o){return v.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:v.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return l(this.errors).concat(l(this.error)).concat(l(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function v(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var o=[];for(var n in t)o.push({value:n,label:t[n],id:this.elementAttributes.id+"_"+n});return o}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function x(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:g.bind(this),set:b.bind(this)})}function g(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){s(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function w(t,e,o,n,i,r,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,i&&(p.functional=!0)),n&&(p._scopeId=n),r?(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(r)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var F={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},h,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||s(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!s(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!s(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){s(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=c(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],i=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(i=i instanceof Promise?i:Promise.resolve(i)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},_=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var P=w({render:_,staticRenderFns:[]},void 0,F,void 0,!1,void 0,!1,void 0,void 0,void 0),V=function(t){this.form=t};V.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},V.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],i=function t(e){var o={};for(var n in e)e[n]instanceof r||p(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(i,((o={})[e]=t,o))})))};for(var s in i)a(s);Promise.all(n).then((function(){return e(i)})).catch((function(t){return o(t)}))}))};var A={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||s(t[o],this.internalFormModelProxy[o])||s(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||s(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new V(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},O=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};O._withStripped=!0;var j=w({render:O,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),$={props:{errors:{type:[Boolean,Array],required:!0}}},N=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var I=w({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);function E(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var S={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,E(o,["id"])),i=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,E(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(i,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},C=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};C._withStripped=!0;var D=w({render:C,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0),U={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},k={name:"FormulateInputBox",mixins:[U]},B=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t.context.value,a=t._i(o,r);n.checked?a<0&&t.$set(t.context,"model",o.concat([r])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};B._withStripped=!0;var M=w({render:B,staticRenderFns:[]},void 0,k,void 0,!1,void 0,!1,void 0,void 0,void 0),T={name:"FormulateInputText",mixins:[U]},L=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};L._withStripped=!0;var R=w({render:L,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0),z={name:"FormulateFiles",props:{files:{type:r,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},q=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};q._withStripped=!0;var H={name:"FormulateInputFile",components:{FormulateFiles:w({render:q,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[U],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof r&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},W=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};W._withStripped=!0;var G=w({render:W,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[U]},K=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};K._withStripped=!0;var Z=w({render:K,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"FormulateInputSelect",mixins:[U],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};X._withStripped=!0;var Q=w({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputSlider",mixins:[U]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};et._withStripped=!0;var ot=w({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputTextArea",mixins:[U]},it=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};it._withStripped=!0;var rt=w({render:it,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at=function(){this.options={},this.defaults={components:{FormulateForm:j,FormulateInput:P,FormulateInputErrors:I,FormulateInputBox:M,FormulateInputText:R,FormulateInputFile:G,FormulateInputGroup:D,FormulateInputButton:Z,FormulateInputSelect:Q,FormulateInputSlider:ot,FormulateInputTextArea:rt},library:n,rules:d,locale:"en",uploader:m,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:f}}};return at.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},at.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+")")},at.prototype.merge=function(t,e,n){void 0===n&&(n=!0);var i={};for(var r in t)e.hasOwnProperty(r)?o(e[r])&&o(t[r])?i[r]=this.merge(t[r],e[r],n):n&&Array.isArray(t[r])&&Array.isArray(e[r])?i[r]=t[r].concat(e[r]):i[r]=e[r]:i[r]=t[r];for(var a in e)i.hasOwnProperty(a)||(i[a]=e[a]);return i},at.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},at.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},at.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},at.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},at.prototype.getUploader=function(){return this.options.uploader||!1},at.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},at.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},at.prototype.createUpload=function(t,e){return new r(t,e,this.options)},new at})); diff --git a/src/libs/rules.js b/src/libs/rules.js index 0f585ca..4ca6d09 100644 --- a/src/libs/rules.js +++ b/src/libs/rules.js @@ -113,6 +113,20 @@ export default { return Promise.resolve(isEmail.test(value)) }, + /** + * Rule: Value ends with one of the given Strings + */ + endsWith: function ({ value }, ...stack) { + return Promise.resolve((() => { + if (stack.length) { + return stack.find(item => { + return value.endsWith(item) + }) !== undefined + } + return true + })()) + }, + /** * Rule: Value is in an array (stack). */ @@ -137,27 +151,6 @@ export default { })) }, - /** - * Check the maximum value of a particular. - */ - max: function ({ value }, maximum = 10, force) { - return Promise.resolve((() => { - if (Array.isArray(value)) { - maximum = !isNaN(maximum) ? Number(maximum) : maximum - return value.length <= maximum - } - if ((!isNaN(value) && force !== 'length') || force === 'value') { - value = !isNaN(value) ? Number(value) : value - return value <= maximum - } - if (typeof value === 'string' || (force === 'length')) { - value = !isNaN(value) ? value.toString() : value - return value.length <= maximum - } - return false - })()) - }, - /** * Check the file type is correct. */ @@ -197,6 +190,27 @@ export default { })()) }, + /** + * Check the maximum value of a particular. + */ + max: function ({ value }, maximum = 10, force) { + return Promise.resolve((() => { + if (Array.isArray(value)) { + maximum = !isNaN(maximum) ? Number(maximum) : maximum + return value.length <= maximum + } + if ((!isNaN(value) && force !== 'length') || force === 'value') { + value = !isNaN(value) ? Number(value) : value + return value <= maximum + } + if (typeof value === 'string' || (force === 'length')) { + value = !isNaN(value) ? value.toString() : value + return value.length <= maximum + } + return false + })()) + }, + /** * Rule: Value is not in stack. */ @@ -240,6 +254,20 @@ export default { })()) }, + /** + * Rule: Value starts with one of the given Strings + */ + startsWith: function ({ value }, ...stack) { + return Promise.resolve((() => { + if (stack.length) { + return stack.find(item => { + return value.startsWith(item) + }) !== undefined + } + return true + })()) + }, + /** * Rule: checks if a string is a valid url */ diff --git a/src/libs/utils.js b/src/libs/utils.js index 28e770b..6e7179a 100644 --- a/src/libs/utils.js +++ b/src/libs/utils.js @@ -71,6 +71,19 @@ export function shallowEqualObjects (objA, objB) { return true } +/** + * Given a string, convert snake_case to camelCase + * @param {String} string + */ +export function snakeCaseToCamelCase (string) { + return string.replace(/([_][a-z])/ig, ($1) => { + if (string.indexOf($1) !== 0 && string[string.indexOf($1) - 1] !== '_') { + return $1.toUpperCase().replace('_', '') + } + return $1 + }) +} + /** * Given a string, object, falsey, or array - return an array. * @param {mixed} item @@ -138,7 +151,7 @@ function parseRule (rule, rules) { } if (typeof rule === 'string') { const segments = rule.split(':') - const functionName = segments.shift() + const functionName = snakeCaseToCamelCase(segments.shift()) if (rules.hasOwnProperty(functionName)) { return [rules[functionName], segments.length ? segments.join(':').split(',') : []] } else { diff --git a/src/locales/en.js b/src/locales/en.js index aa9b5f1..313adcb 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -89,6 +89,16 @@ export default { return `“${value}” is not a valid email address.` }, + /** + * Ends with specified value + */ + endsWith: function ({ name, value }) { + if (!value) { + return `This field doesn’t end with a valid value.` + } + return `“${value}” doesn’t end with a valid value.` + }, + /** * Value is an allowed value. */ @@ -162,6 +172,16 @@ export default { return `${s(name)} is required.` }, + /** + * Starts with specified value + */ + startsWith: function ({ name, value }) { + if (!value) { + return `This field doesn’t start with a valid value.` + } + return `“${value}” doesn’t start with a valid value.` + }, + /** * Value is not a url. */ diff --git a/test/rules.test.js b/test/rules.test.js index fbb0bd8..b0b64b6 100644 --- a/test/rules.test.js +++ b/test/rules.test.js @@ -1,35 +1,238 @@ import rules from '@/libs/rules' import FileUpload from '../src/FileUpload' + /** - * Required rule + * Accepted rule */ -describe('required', () => { - it('fails on empty string', async () => expect(await rules.required({ value: '' })).toBe(false)) +describe('accepted', () => { + it('passes with true', async () => expect(await rules.accepted({ value: 'yes' })).toBe(true)) - it('fails on empty array', async () => expect(await rules.required({ value: [] })).toBe(false)) + it('passes with on', async () => expect(await rules.accepted({ value: 'on' })).toBe(true)) - it('fails on empty object', async () => expect(await rules.required({ value: {} })).toBe(false)) + it('passes with 1', async () => expect(await rules.accepted({ value: '1' })).toBe(true)) - it('fails on null', async () => expect(await rules.required({ value: null })).toBe(false)) + it('passes with number 1', async () => expect(await rules.accepted({ value: 1 })).toBe(true)) - it('passes with the number zero', async () => expect(await rules.required({ value: 0 })).toBe(true)) + it('passes with boolean true', async () => expect(await rules.accepted({ value: true })).toBe(true)) - it('passes with the boolean false', async () => expect(await rules.required({ value: false })).toBe(true)) + it('fail with boolean false', async () => expect(await rules.accepted({ value: false })).toBe(false)) - it('passes with a non empty array', async () => expect(await rules.required({ value: ['123'] })).toBe(true)) - - it('passes with a non empty object', async () => expect(await rules.required({ value: {a: 'b'} })).toBe(true)) - - it('passes with empty value if second argument is false', async () => expect(await rules.required({ value: '' }, false)).toBe(true)) - - it('passes with empty value if second argument is false string', async () => expect(await rules.required({ value: '' }, 'false')).toBe(true)) - - it('passes with FileUpload', async () => expect(await rules.required({ value: new FileUpload({ files: [{ name: 'j.png' }] }) })).toBe(true)) - - it('fails with empty FileUpload', async () => expect(await rules.required({ value: new FileUpload({ files: [] }) })).toBe(false)) + it('fail with "false"', async () => expect(await rules.accepted({ value: 'false' })).toBe(false)) }) +/** + * Checks if a date is after another date + */ +describe('after', () => { + const today = new Date() + const tomorrow = new Date() + const yesterday = new Date() + tomorrow.setDate(today.getDate() + 1) + yesterday.setDate(today.getDate() - 1) + + it('passes with tomorrow’s date object', async () => expect(await rules.after({ value: tomorrow })).toBe(true)) + + it('passes with future date', async () => expect(await rules.after({ value: 'January 15, 2999' })).toBe(true)) + + it('passes with long past date', async () => expect(await rules.after({ value: yesterday }, 'Jan 15, 2000')).toBe(true)) + + it('fails with yesterday’s date', async () => expect(await rules.after({ value: yesterday })).toBe(false)) + + it('fails with old date string', async () => expect(await rules.after({ value: 'January, 2000' })).toBe(false)) + + it('fails with invalid value', async () => expect(await rules.after({ value: '' })).toBe(false)) +}) + +/** + * Checks if a date is after another date + */ +describe('alpha', () => { + it('passes with simple string', async () => expect(await rules.alpha({ value: 'abc' })).toBe(true)) + + it('passes with long string', async () => expect(await rules.alpha({ value: 'lkashdflaosuihdfaisudgflakjsdbflasidufg' })).toBe(true)) + + it('passes with single character', async () => expect(await rules.alpha({ value: 'z' })).toBe(true)) + + it('passes with accented character', async () => expect(await rules.alpha({ value: 'jüstin' })).toBe(true)) + + it('passes with lots of accented characters', async () => expect(await rules.alpha({ value: 'àáâäïíôöÆ' })).toBe(true)) + + it('passes with lots of accented characters if invalid set', async () => expect(await rules.alpha({ value: 'àáâäïíôöÆ' }, 'russian')).toBe(true)) + + it('fails with lots of accented characters if latin', async () => expect(await rules.alpha({ value: 'àáâäïíôöÆ' }, 'latin')).toBe(false)) + + it('fails with numbers', async () => expect(await rules.alpha({ value: 'justin83' })).toBe(false)) + + it('fails with symbols', async () => expect(await rules.alpha({ value: '-justin' })).toBe(false)) +}) + +/** + * Checks if a date alpha and numeric + */ +describe('alphanumeric', () => { + it('passes with simple string', async () => expect(await rules.alphanumeric({ value: '567abc' })).toBe(true)) + + it('passes with long string', async () => expect(await rules.alphanumeric({ value: 'lkashdfla234osuihdfaisudgflakjsdbfla567sidufg' })).toBe(true)) + + it('passes with single character', async () => expect(await rules.alphanumeric({ value: 'z' })).toBe(true)) + + it('passes with accented character', async () => expect(await rules.alphanumeric({ value: 'jüst56in' })).toBe(true)) + + it('passes with lots of accented characters', async () => expect(await rules.alphanumeric({ value: 'àáâ7567567äïíôöÆ' })).toBe(true)) + + it('passes with lots of accented characters if invalid set', async () => expect(await rules.alphanumeric({ value: '123123àáâäï67íôöÆ' }, 'russian')).toBe(true)) + + it('fails with lots of accented characters if latin', async () => expect(await rules.alphanumeric({ value: 'àáâäï123123íôöÆ' }, 'latin')).toBe(false)) + + it('fails with decimals in', async () => expect(await rules.alphanumeric({ value: 'abcABC99.123' })).toBe(false)) +}) + +/** + * Checks if a date is after another date + */ +describe('before', () => { + const today = new Date() + const tomorrow = new Date() + const yesterday = new Date() + tomorrow.setDate(today.getDate() + 1) + yesterday.setDate(today.getDate() - 1) + + it('fails with tomorrow’s date object', async () => expect(await rules.before({ value: tomorrow })).toBe(false)) + + it('fails with future date', async () => expect(await rules.before({ value: 'January 15, 2999' })).toBe(false)) + + it('fails with long past date', async () => expect(await rules.before({ value: yesterday }, 'Jan 15, 2000')).toBe(false)) + + it('passes with yesterday’s date', async () => expect(await rules.before({ value: yesterday })).toBe(true)) + + it('passes with old date string', async () => expect(await rules.before({ value: 'January, 2000' })).toBe(true)) + + it('fails with invalid value', async () => expect(await rules.after({ value: '' })).toBe(false)) +}) + +/** + * Checks if between + */ +describe('between', () => { + it('passes with simple number', async () => expect(await rules.between({ value: 5 }, 0, 10)).toBe(true)) + + it('passes with simple number string', async () => expect(await rules.between({ value: '5' }, '0', '10')).toBe(true)) + + it('passes with decimal number string', async () => expect(await rules.between({ value: '0.5' }, '0', '1')).toBe(true)) + + it('passes with string length', async () => expect(await rules.between({ value: 'abc' }, 2, 4)).toBe(true)) + + it('fails with string length too long', async () => expect(await rules.between({ value: 'abcdef' }, 2, 4)).toBe(false)) + + it('fails with string length too short', async () => expect(await rules.between({ value: 'abc' }, 3, 10)).toBe(false)) + + it('fails with number to small', async () => expect(await rules.between({ value: 0 }, 3, 10)).toBe(false)) + + it('fails with number to large', async () => expect(await rules.between({ value: 15 }, 3, 10)).toBe(false)) +}) + +/** + * Confirm + */ +describe('confirm', () => { + it('passes when the values are the same strings', async () => expect(await rules.confirm( + { value: 'abc', name: 'password', getFormValues: () => ({ password_confirm: 'abc' }) } + )).toBe(true)) + + it('passes when the values are the same integers', async () => expect(await rules.confirm( + { value: 4422132, name: 'xyz', getFormValues: () => ({ xyz_confirm: 4422132 }) } + )).toBe(true)) + + it('passes when using a custom field', async () => expect(await rules.confirm( + { value: 4422132, name: 'name', getFormValues: () => ({ other_field: 4422132 }) }, + 'other_field' + )).toBe(true)) + + it('passes when using a field ends in _confirm', async () => expect(await rules.confirm( + { value: '$ecret', name: 'password_confirm', getFormValues: () => ({ password: '$ecret' }) } + )).toBe(true)) + + it('fails when using different strings', async () => expect(await rules.confirm( + { value: 'Justin', name: 'name', getFormValues: () => ({ name_confirm: 'Daniel' }) }, + )).toBe(false)) + + it('fails when the types are different', async () => expect(await rules.confirm( + { value: '1234', name: 'num', getFormValues: () => ({ num_confirm: 1234 }) }, + )).toBe(false)) +}) + +/** + * Determines if the string is a date + */ +describe('date', () => { + it('passes with month day year', async () => expect(await rules.date({ value: 'December 17, 2020' })).toBe(true)) + + it('passes with month day', async () => expect(await rules.date({ value: 'December 17' })).toBe(true)) + + it('passes with short month day', async () => expect(await rules.date({ value: 'Dec 17' })).toBe(true)) + + it('passes with short month day', async () => expect(await rules.date({ value: 'Dec 17 12:34:15' })).toBe(true)) + + it('passes with out of bounds number', async () => expect(await rules.date({ value: 'January 77' })).toBe(true)) + + it('passes with only month', async () => expect(await rules.date({ value: 'January' })).toBe(false)) + + it('passes with valid date format', async () => expect(await rules.date({ value: '12/17/1987' }, 'MM/DD/YYYY')).toBe(true)) + + it('fails with simple number and date format', async () => expect(await rules.date({ value: '1234' }, 'MM/DD/YYYY')).toBe(false)) + + it('fails with only day of week', async () => expect(await rules.date({ value: 'saturday' })).toBe(false)) + + it('fails with random string', async () => expect(await rules.date({ value: 'Pepsi 17' })).toBe(false)) + + it('fails with random number', async () => expect(await rules.date({ value: '1872301237' })).toBe(false)) + +}) + +/** + * Checks if email. + * + * Note: testing is light, regular expression used is here: http://jsfiddle.net/ghvj4gy9/embedded/result,js/ + */ +describe('email', () => { + it('passes normal email', async () => expect(await rules.email({ value: 'dev+123@wearebraid.com' })).toBe(true)) + + it('passes numeric email', async () => expect(await rules.email({ value: '12345@google.com' })).toBe(true)) + + it('passes unicode email', async () => expect(await rules.email({ value: 'àlphä@❤️.ly' })).toBe(true)) + + it('passes numeric with new tld', async () => expect(await rules.email({ value: '12345@google.photography' })).toBe(true)) + + it('fails string without tld', async () => expect(await rules.email({ value: '12345@localhost' })).toBe(false)) + + it('fails string without invalid name', async () => expect(await rules.email({ value: '1*(123)2345@localhost' })).toBe(false)) +}) + +/** + * Checks if value ends with a one of the specified Strings. + */ +describe('endsWith', () => { + it('fails when value ending is not in stack of single value', async () => { + expect(await rules.endsWith({ value: 'andrew@wearebraid.com' }, '@gmail.com')).toBe(false) + }) + + it('fails when value ending is not in stack of multiple values', async () => { + expect(await rules.endsWith({ value: 'andrew@wearebraid.com' }, '@gmail.com', '@yahoo.com')).toBe(false) + }) + + it('passes when stack consists of zero values', async () => { + expect(await rules.endsWith({ value: 'andrew@wearebraid.com' })).toBe(true) + }) + + it('passes when value ending is in stack of single value', async () => { + expect(await rules.endsWith({ value: 'andrew@wearebraid.com' }, '@wearebraid.com')).toBe(true) + }) + + it('passes when value ending is in stack of multiple values', async () => { + expect(await rules.endsWith({ value: 'andrew@wearebraid.com' }, '@yahoo.com', '@wearebraid.com', '@gmail.com')).toBe(true) + }) +}) /** * In rule @@ -85,217 +288,6 @@ describe('matches', () => { }) }) -/** - * Accepted rule - */ -describe('accepted', () => { - it('passes with true', async () => expect(await rules.accepted({ value: 'yes' })).toBe(true)) - - it('passes with on', async () => expect(await rules.accepted({ value: 'on' })).toBe(true)) - - it('passes with 1', async () => expect(await rules.accepted({ value: '1' })).toBe(true)) - - it('passes with number 1', async () => expect(await rules.accepted({ value: 1 })).toBe(true)) - - it('passes with boolean true', async () => expect(await rules.accepted({ value: true })).toBe(true)) - - it('fail with boolean false', async () => expect(await rules.accepted({ value: false })).toBe(false)) - - it('fail with "false"', async () => expect(await rules.accepted({ value: 'false' })).toBe(false)) -}) - - -/** - * Url rule. - * - * Note: these are just sanity checks because the actual package we use is - * well tested: https://github.com/segmentio/is-url/blob/master/test/index.js - */ -describe('url', () => { - it('passes with http://google.com', async () => expect(await rules.url({ value: 'http://google.com' })).toBe(true)) - - it('fails with google.com', async () => expect(await rules.url({ value: 'google.com' })).toBe(false)) -}) - -/** - * Determines if the string is a date - */ -describe('date', () => { - it('passes with month day year', async () => expect(await rules.date({ value: 'December 17, 2020' })).toBe(true)) - - it('passes with month day', async () => expect(await rules.date({ value: 'December 17' })).toBe(true)) - - it('passes with short month day', async () => expect(await rules.date({ value: 'Dec 17' })).toBe(true)) - - it('passes with short month day', async () => expect(await rules.date({ value: 'Dec 17 12:34:15' })).toBe(true)) - - it('passes with out of bounds number', async () => expect(await rules.date({ value: 'January 77' })).toBe(true)) - - it('passes with only month', async () => expect(await rules.date({ value: 'January' })).toBe(false)) - - it('passes with valid date format', async () => expect(await rules.date({ value: '12/17/1987' }, 'MM/DD/YYYY')).toBe(true)) - - it('fails with simple number and date format', async () => expect(await rules.date({ value: '1234' }, 'MM/DD/YYYY')).toBe(false)) - - it('fails with only day of week', async () => expect(await rules.date({ value: 'saturday' })).toBe(false)) - - it('fails with random string', async () => expect(await rules.date({ value: 'Pepsi 17' })).toBe(false)) - - it('fails with random number', async () => expect(await rules.date({ value: '1872301237' })).toBe(false)) - -}) - - -/** - * Checks if a date is after another date - */ -describe('after', () => { - const today = new Date() - const tomorrow = new Date() - const yesterday = new Date() - tomorrow.setDate(today.getDate() + 1) - yesterday.setDate(today.getDate() - 1) - - it('passes with tomorrow’s date object', async () => expect(await rules.after({ value: tomorrow })).toBe(true)) - - it('passes with future date', async () => expect(await rules.after({ value: 'January 15, 2999' })).toBe(true)) - - it('passes with long past date', async () => expect(await rules.after({ value: yesterday }, 'Jan 15, 2000')).toBe(true)) - - it('fails with yesterday’s date', async () => expect(await rules.after({ value: yesterday })).toBe(false)) - - it('fails with old date string', async () => expect(await rules.after({ value: 'January, 2000' })).toBe(false)) - - it('fails with invalid value', async () => expect(await rules.after({ value: '' })).toBe(false)) -}) - -/** - * Checks if a date is after another date - */ -describe('before', () => { - const today = new Date() - const tomorrow = new Date() - const yesterday = new Date() - tomorrow.setDate(today.getDate() + 1) - yesterday.setDate(today.getDate() - 1) - - it('fails with tomorrow’s date object', async () => expect(await rules.before({ value: tomorrow })).toBe(false)) - - it('fails with future date', async () => expect(await rules.before({ value: 'January 15, 2999' })).toBe(false)) - - it('fails with long past date', async () => expect(await rules.before({ value: yesterday }, 'Jan 15, 2000')).toBe(false)) - - it('passes with yesterday’s date', async () => expect(await rules.before({ value: yesterday })).toBe(true)) - - it('passes with old date string', async () => expect(await rules.before({ value: 'January, 2000' })).toBe(true)) - - it('fails with invalid value', async () => expect(await rules.after({ value: '' })).toBe(false)) -}) - - -/** - * Checks if a date is after another date - */ -describe('alpha', () => { - it('passes with simple string', async () => expect(await rules.alpha({ value: 'abc' })).toBe(true)) - - it('passes with long string', async () => expect(await rules.alpha({ value: 'lkashdflaosuihdfaisudgflakjsdbflasidufg' })).toBe(true)) - - it('passes with single character', async () => expect(await rules.alpha({ value: 'z' })).toBe(true)) - - it('passes with accented character', async () => expect(await rules.alpha({ value: 'jüstin' })).toBe(true)) - - it('passes with lots of accented characters', async () => expect(await rules.alpha({ value: 'àáâäïíôöÆ' })).toBe(true)) - - it('passes with lots of accented characters if invalid set', async () => expect(await rules.alpha({ value: 'àáâäïíôöÆ' }, 'russian')).toBe(true)) - - it('fails with lots of accented characters if latin', async () => expect(await rules.alpha({ value: 'àáâäïíôöÆ' }, 'latin')).toBe(false)) - - it('fails with numbers', async () => expect(await rules.alpha({ value: 'justin83' })).toBe(false)) - - it('fails with symbols', async () => expect(await rules.alpha({ value: '-justin' })).toBe(false)) -}) - -/** - * Checks if a date is after another date - */ -describe('number', () => { - it('passes with simple number string', async () => expect(await rules.number({ value: '123' })).toBe(true)) - - it('passes with simple number', async () => expect(await rules.number({ value: 19832461234 })).toBe(true)) - - it('passes with float', async () => expect(await rules.number({ value: 198.32464 })).toBe(true)) - - it('passes with decimal in string', async () => expect(await rules.number({ value: '567.23' })).toBe(true)) - - it('fails with comma in number string', async () => expect(await rules.number({ value: '123,456' })).toBe(false)) - - it('fails with alpha', async () => expect(await rules.number({ value: '123sdf' })).toBe(false)) -}) - -/** - * Checks if a date alpha and numeric - */ -describe('alphanumeric', () => { - it('passes with simple string', async () => expect(await rules.alphanumeric({ value: '567abc' })).toBe(true)) - - it('passes with long string', async () => expect(await rules.alphanumeric({ value: 'lkashdfla234osuihdfaisudgflakjsdbfla567sidufg' })).toBe(true)) - - it('passes with single character', async () => expect(await rules.alphanumeric({ value: 'z' })).toBe(true)) - - it('passes with accented character', async () => expect(await rules.alphanumeric({ value: 'jüst56in' })).toBe(true)) - - it('passes with lots of accented characters', async () => expect(await rules.alphanumeric({ value: 'àáâ7567567äïíôöÆ' })).toBe(true)) - - it('passes with lots of accented characters if invalid set', async () => expect(await rules.alphanumeric({ value: '123123àáâäï67íôöÆ' }, 'russian')).toBe(true)) - - it('fails with lots of accented characters if latin', async () => expect(await rules.alphanumeric({ value: 'àáâäï123123íôöÆ' }, 'latin')).toBe(false)) - - it('fails with decimals in', async () => expect(await rules.alphanumeric({ value: 'abcABC99.123' })).toBe(false)) -}) - -/** - * Checks if between - */ -describe('between', () => { - it('passes with simple number', async () => expect(await rules.between({ value: 5 }, 0, 10)).toBe(true)) - - it('passes with simple number string', async () => expect(await rules.between({ value: '5' }, '0', '10')).toBe(true)) - - it('passes with decimal number string', async () => expect(await rules.between({ value: '0.5' }, '0', '1')).toBe(true)) - - it('passes with string length', async () => expect(await rules.between({ value: 'abc' }, 2, 4)).toBe(true)) - - it('fails with string length too long', async () => expect(await rules.between({ value: 'abcdef' }, 2, 4)).toBe(false)) - - it('fails with string length too short', async () => expect(await rules.between({ value: 'abc' }, 3, 10)).toBe(false)) - - it('fails with number to small', async () => expect(await rules.between({ value: 0 }, 3, 10)).toBe(false)) - - it('fails with number to large', async () => expect(await rules.between({ value: 15 }, 3, 10)).toBe(false)) -}) - -/** - * Checks if email. - * - * Note: testing is light, regular expression used is here: http://jsfiddle.net/ghvj4gy9/embedded/result,js/ - */ -describe('email', () => { - it('passes normal email', async () => expect(await rules.email({ value: 'dev+123@wearebraid.com' })).toBe(true)) - - it('passes numeric email', async () => expect(await rules.email({ value: '12345@google.com' })).toBe(true)) - - it('passes unicode email', async () => expect(await rules.email({ value: 'àlphä@❤️.ly' })).toBe(true)) - - it('passes numeric with new tld', async () => expect(await rules.email({ value: '12345@google.photography' })).toBe(true)) - - it('fails string without tld', async () => expect(await rules.email({ value: '12345@localhost' })).toBe(false)) - - it('fails string without tld', async () => expect(await rules.email({ value: '12345@localhost' })).toBe(false)) - - it('fails string without invalid name', async () => expect(await rules.email({ value: '1*(123)2345@localhost' })).toBe(false)) -}) - /** * Mime types. */ @@ -395,31 +387,85 @@ describe('not', () => { }) /** - * Confirm + * Checks if a date is after another date */ -describe('confirm', () => { - it('passes when the values are the same strings', async () => expect(await rules.confirm( - { value: 'abc', name: 'password', getFormValues: () => ({ password_confirm: 'abc' }) } - )).toBe(true)) +describe('number', () => { + it('passes with simple number string', async () => expect(await rules.number({ value: '123' })).toBe(true)) - it('passes when the values are the same integers', async () => expect(await rules.confirm( - { value: 4422132, name: 'xyz', getFormValues: () => ({ xyz_confirm: 4422132 }) } - )).toBe(true)) + it('passes with simple number', async () => expect(await rules.number({ value: 19832461234 })).toBe(true)) - it('passes when using a custom field', async () => expect(await rules.confirm( - { value: 4422132, name: 'name', getFormValues: () => ({ other_field: 4422132 }) }, - 'other_field' - )).toBe(true)) + it('passes with float', async () => expect(await rules.number({ value: 198.32464 })).toBe(true)) - it('passes when using a field ends in _confirm', async () => expect(await rules.confirm( - { value: '$ecret', name: 'password_confirm', getFormValues: () => ({ password: '$ecret' }) } - )).toBe(true)) + it('passes with decimal in string', async () => expect(await rules.number({ value: '567.23' })).toBe(true)) - it('fails when using different strings', async () => expect(await rules.confirm( - { value: 'Justin', name: 'name', getFormValues: () => ({ name_confirm: 'Daniel' }) }, - )).toBe(false)) + it('fails with comma in number string', async () => expect(await rules.number({ value: '123,456' })).toBe(false)) - it('fails when the types are different', async () => expect(await rules.confirm( - { value: '1234', name: 'num', getFormValues: () => ({ num_confirm: 1234 }) }, - )).toBe(false)) + it('fails with alpha', async () => expect(await rules.number({ value: '123sdf' })).toBe(false)) +}) + + +/** + * Required rule + */ +describe('required', () => { + it('fails on empty string', async () => expect(await rules.required({ value: '' })).toBe(false)) + + it('fails on empty array', async () => expect(await rules.required({ value: [] })).toBe(false)) + + it('fails on empty object', async () => expect(await rules.required({ value: {} })).toBe(false)) + + it('fails on null', async () => expect(await rules.required({ value: null })).toBe(false)) + + it('passes with the number zero', async () => expect(await rules.required({ value: 0 })).toBe(true)) + + it('passes with the boolean false', async () => expect(await rules.required({ value: false })).toBe(true)) + + it('passes with a non empty array', async () => expect(await rules.required({ value: ['123'] })).toBe(true)) + + it('passes with a non empty object', async () => expect(await rules.required({ value: {a: 'b'} })).toBe(true)) + + it('passes with empty value if second argument is false', async () => expect(await rules.required({ value: '' }, false)).toBe(true)) + + it('passes with empty value if second argument is false string', async () => expect(await rules.required({ value: '' }, 'false')).toBe(true)) + + it('passes with FileUpload', async () => expect(await rules.required({ value: new FileUpload({ files: [{ name: 'j.png' }] }) })).toBe(true)) + + it('fails with empty FileUpload', async () => expect(await rules.required({ value: new FileUpload({ files: [] }) })).toBe(false)) +}) + +/** + * Checks if value starts with a one of the specified Strings. + */ +describe('startsWith', () => { + it('fails when value starting is not in stack of single value', async () => { + expect(await rules.startsWith({ value: 'taco tuesday' }, 'pizza')).toBe(false) + }) + + it('fails when value starting is not in stack of multiple values', async () => { + expect(await rules.startsWith({ value: 'taco tuesday' }, 'pizza', 'coffee')).toBe(false) + }) + + it('passes when stack consists of zero values', async () => { + expect(await rules.startsWith({ value: 'taco tuesday' })).toBe(true) + }) + + it('passes when value starting is in stack of single value', async () => { + expect(await rules.startsWith({ value: 'taco tuesday' }, 'taco')).toBe(true) + }) + + it('passes when value starting is in stack of multiple values', async () => { + expect(await rules.startsWith({ value: 'taco tuesday' }, 'pizza', 'taco', 'coffee')).toBe(true) + }) +}) + +/** + * Url rule. + * + * Note: these are just sanity checks because the actual package we use is + * well tested: https://github.com/segmentio/is-url/blob/master/test/index.js + */ +describe('url', () => { + it('passes with http://google.com', async () => expect(await rules.url({ value: 'http://google.com' })).toBe(true)) + + it('fails with google.com', async () => expect(await rules.url({ value: 'google.com' })).toBe(false)) }) diff --git a/test/utils.test.js b/test/utils.test.js index 73089f8..f64f1f6 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -1,4 +1,4 @@ -import { parseRules, regexForFormat, cloneDeep, isValueType } from '@/libs/utils' +import { parseRules, regexForFormat, cloneDeep, isValueType, snakeCaseToCamelCase } from '@/libs/utils' import rules from '@/libs/rules' import FileUpload from '@/FileUpload'; @@ -117,3 +117,25 @@ describe('cloneDeep', () => { expect(clone.b === c).toBe(false) }) }) + +describe('snakeCaseToCamelCase', () => { + it('converts underscore separated words to camelCase', () => { + expect(snakeCaseToCamelCase('this_is_snake_case')).toBe('thisIsSnakeCase') + }) + + it('has no effect on already camelCase words', () => { + expect(snakeCaseToCamelCase('thisIsCamelCase')).toBe('thisIsCamelCase') + }) + + it('does not capitalize the first word or strip first underscore if a phrase starts with an underscore', () => { + expect(snakeCaseToCamelCase('_this_starts_with_an_underscore')).toBe('_thisStartsWithAnUnderscore') + }) + + it('ignores double underscores anywhere in a word', () => { + expect(snakeCaseToCamelCase('__unlikely__thing__')).toBe('__unlikely__thing__') + }) + + it('has no effect hyphenated words', () => { + expect(snakeCaseToCamelCase('not-a-good-name')).toBe('not-a-good-name') + }) +}) From 4b36b9c4ba7b41eb24fbee10cdbb967b139e81b5 Mon Sep 17 00:00:00 2001 From: Justin Schroeder Date: Wed, 4 Mar 2020 13:45:37 -0500 Subject: [PATCH 3/8] Adds validation rules endsWith, startsWith and fixes box classification blur handler * adds language definitions for new rules * re-order rules file to order rule definitions alphabetically * adds support for endsWith validation rule and converts snake_case rules to camelCase function calls * adds support for startsWith field validation * better en.js definitions for new validations * adds tests for snakeCaseToCamelCase function * coerces all validation messages and validation rules to be camelCase under the hood * ensures that array syntax rules are properly converted internally to camelCase * adds more robust tests for non-string type data for endsWith and startsWith validation rules * adds support for words that start with numbers to snakeToCamel method renames snakeCaseToCamelCase to snakeToCamel to reduce package size * Reduces some property name lengths for byte savings * Fixes bug that caused validation rules to not be displayed on blur for the box classification Co-authored-by: Justin Schroeder --- dist/formulate.esm.js | 2 +- dist/formulate.min.js | 6 +++--- dist/formulate.umd.js | 2 +- src/FormulateInput.vue | 29 ++++++++++++++++++++++------- src/FormulateInputGroup.vue | 1 + src/libs/context.js | 1 + src/libs/rules.js | 12 ++++++++---- src/libs/utils.js | 23 +++++++++++++---------- test/FormulateInputBox.test.js | 20 ++++++++++++++++++++ test/rules.test.js | 24 ++++++++++++++++++++++++ test/utils.test.js | 18 +++++++++++------- 11 files changed, 105 insertions(+), 33 deletions(-) diff --git a/dist/formulate.esm.js b/dist/formulate.esm.js index ad830a1..72933ca 100644 --- a/dist/formulate.esm.js +++ b/dist/formulate.esm.js @@ -1 +1 @@ -import t from"is-url";import e from"nanoid/non-secure";import o from"is-plain-object";var n={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},i={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},r=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function s(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),i=o.length;if(n.length!==i)return!1;for(var r=0;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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},r.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}},r.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)}}))},r.prototype.getFileList=function(){return this.fileList},r.prototype.getFiles=function(){return this.files},r.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var d={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&i>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&ie&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.endsWith(t)})))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof r?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.startsWith(t)})))},url:function(e){var o=e.value;return Promise.resolve(t(o))}},f={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be after "+o[0]+".":u(e)+" must be a later date."},alpha:function(t){return u(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return u(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be before "+o[0]+".":u(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?u(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":u(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return u(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" is not a valid, please use the format "+o[0]:u(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+u(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return u(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be less than or equal to "+n[0]+".":u(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return u(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be more than "+n[0]+".":u(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return u(t.name)+" must be a number."},required:function(t){return u(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,o,n){return new Promise((function(o,i){var r=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,i=Math.min(100,Math.round(n/r*100));if(e(i),i>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var h={context:function(){return y.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:x.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:v.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,o){return v.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:v.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return l(this.errors).concat(l(this.error)).concat(l(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function v(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var o=[];for(var n in t)o.push({value:n,label:t[n],id:this.elementAttributes.id+"_"+n});return o}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function x(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:g.bind(this),set:b.bind(this)})}function g(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){s(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function w(t,e,o,n,i,r,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,i&&(p.functional=!0)),n&&(p._scopeId=n),r?(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(r)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var F={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},h,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||s(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!s(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!s(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){s(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=c(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],i=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(i=i instanceof Promise?i:Promise.resolve(i)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},_=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var P=w({render:_,staticRenderFns:[]},void 0,F,void 0,!1,void 0,!1,void 0,void 0,void 0),V=function(t){this.form=t};V.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},V.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],i=function t(e){var o={};for(var n in e)e[n]instanceof r||p(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(i,((o={})[e]=t,o))})))};for(var s in i)a(s);Promise.all(n).then((function(){return e(i)})).catch((function(t){return o(t)}))}))};var A={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||s(t[o],this.internalFormModelProxy[o])||s(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||s(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new V(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},O=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};O._withStripped=!0;var j=w({render:O,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),$={props:{errors:{type:[Boolean,Array],required:!0}}},N=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var I=w({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);function E(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var S={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,E(o,["id"])),i=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,E(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(i,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},C=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};C._withStripped=!0;var D=w({render:C,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0),U={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},k={name:"FormulateInputBox",mixins:[U]},B=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t.context.value,a=t._i(o,r);n.checked?a<0&&t.$set(t.context,"model",o.concat([r])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};B._withStripped=!0;var M=w({render:B,staticRenderFns:[]},void 0,k,void 0,!1,void 0,!1,void 0,void 0,void 0),T={name:"FormulateInputText",mixins:[U]},L=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};L._withStripped=!0;var R=w({render:L,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0),z={name:"FormulateFiles",props:{files:{type:r,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},H=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};H._withStripped=!0;var q={name:"FormulateInputFile",components:{FormulateFiles:w({render:H,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[U],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof r&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},W=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};W._withStripped=!0;var G=w({render:W,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[U]},K=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};K._withStripped=!0;var Z=w({render:K,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"FormulateInputSelect",mixins:[U],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};X._withStripped=!0;var Q=w({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputSlider",mixins:[U]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};et._withStripped=!0;var ot=w({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputTextArea",mixins:[U]},it=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};it._withStripped=!0;var rt=w({render:it,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at=function(){this.options={},this.defaults={components:{FormulateForm:j,FormulateInput:P,FormulateInputErrors:I,FormulateInputBox:M,FormulateInputText:R,FormulateInputFile:G,FormulateInputGroup:D,FormulateInputButton:Z,FormulateInputSelect:Q,FormulateInputSlider:ot,FormulateInputTextArea:rt},library:n,rules:d,locale:"en",uploader:m,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:f}}};at.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},at.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+")")},at.prototype.merge=function(t,e,n){void 0===n&&(n=!0);var i={};for(var r in t)e.hasOwnProperty(r)?o(e[r])&&o(t[r])?i[r]=this.merge(t[r],e[r],n):n&&Array.isArray(t[r])&&Array.isArray(e[r])?i[r]=t[r].concat(e[r]):i[r]=e[r]:i[r]=t[r];for(var a in e)i.hasOwnProperty(a)||(i[a]=e[a]);return i},at.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},at.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},at.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},at.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},at.prototype.getUploader=function(){return this.options.uploader||!1},at.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},at.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},at.prototype.createUpload=function(t,e){return new r(t,e,this.options)};var st=new at;export default st; +import t from"is-url";import e from"nanoid/non-secure";import o from"is-plain-object";var n={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},i={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},r=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function s(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),i=o.length;if(n.length!==i)return!1;for(var r=0;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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},r.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}},r.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)}}))},r.prototype.getFileList=function(){return this.fileList},r.prototype.getFiles=function(){return this.files},r.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var f={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&i>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&ie&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve("string"==typeof e&&o.length?void 0!==o.find((function(t){return e.endsWith(t)})):"string"==typeof e&&0===o.length)},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof r?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve("string"==typeof e&&o.length?void 0!==o.find((function(t){return e.startsWith(t)})):"string"==typeof e&&0===o.length)},url:function(e){var o=e.value;return Promise.resolve(t(o))}},m={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?c(e)+" must be after "+o[0]+".":c(e)+" must be a later date."},alpha:function(t){return c(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return c(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?c(e)+" must be before "+o[0]+".":c(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?c(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":c(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return c(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?c(e)+" is not a valid, please use the format "+o[0]:c(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+c(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return c(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?c(e)+" must be less than or equal to "+n[0]+".":c(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return c(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?c(e)+" must be more than "+n[0]+".":c(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return c(t.name)+" must be a number."},required:function(t){return c(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}};function h(t,e,o,n){return new Promise((function(o,i){var r=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,i=Math.min(100,Math.round(n/r*100));if(e(i),i>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var v={context:function(){return g.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:y.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:x.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,o){return x.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:x.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return u(this.errors).concat(u(this.error)).concat(u(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function x(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var o=[];for(var n in t)o.push({value:n,label:t[n],id:this.elementAttributes.id+"_"+n});return o}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function y(){this.$emit("blur"),"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function g(t){return Object.defineProperty(t,"model",{get:b.bind(this),set:w.bind(this)})}function b(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function w(t){s(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function F(t,e,o,n,i,r,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,i&&(p.functional=!0)),n&&(p._scopeId=n),r?(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(r)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var _={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},v,{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(o){e[l(o)]=t.validationRules[o]})),e},messages:function(){var t=this,e={};return Object.keys(this.validationMessages).forEach((function(o){e[l(o)]=t.validationMessages[o]})),e}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||s(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!s(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!s(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){s(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=p(this.validation,this.$formulate.rules(this.parsedValidationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],i=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(i=i instanceof Promise?i:Promise.resolve(i)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(o=l(o),this.messages&&"object"==typeof this.messages&&void 0!==this.messages[o])switch(typeof this.messages[o]){case"function":return this.messages[o];case"string":return function(){return e.messages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},P=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};P._withStripped=!0;var V=F({render:P,staticRenderFns:[]},void 0,_,void 0,!1,void 0,!1,void 0,void 0,void 0),A=function(t){this.form=t};A.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},A.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],i=function t(e){var o={};for(var n in e)e[n]instanceof r||d(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(i,((o={})[e]=t,o))})))};for(var s in i)a(s);Promise.all(n).then((function(){return e(i)})).catch((function(t){return o(t)}))}))};var O={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||s(t[o],this.internalFormModelProxy[o])||s(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||s(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new A(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},j=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};j._withStripped=!0;var $=F({render:j,staticRenderFns:[]},void 0,O,void 0,!1,void 0,!1,void 0,void 0,void 0),N={props:{errors:{type:[Boolean,Array],required:!0}}},E=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};E._withStripped=!0;var I=F({render:E,staticRenderFns:[]},void 0,N,void 0,!1,void 0,!1,void 0,void 0,void 0);function S(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var C={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,S(o,["id"])),i=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,S(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(i,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},D=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",on:{blur:t.context.blurHandler},model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};D._withStripped=!0;var k=F({render:D,staticRenderFns:[]},void 0,C,void 0,!1,void 0,!1,void 0,void 0,void 0),U={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},B={name:"FormulateInputBox",mixins:[U]},R=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t.context.value,a=t._i(o,r);n.checked?a<0&&t.$set(t.context,"model",o.concat([r])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};R._withStripped=!0;var T=F({render:R,staticRenderFns:[]},void 0,B,void 0,!1,void 0,!1,void 0,void 0,void 0),M={name:"FormulateInputText",mixins:[U]},L=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};L._withStripped=!0;var z=F({render:L,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),H={name:"FormulateFiles",props:{files:{type:r,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},q=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};q._withStripped=!0;var W={name:"FormulateInputFile",components:{FormulateFiles:F({render:q,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[U],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof r&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},G=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};G._withStripped=!0;var Y=F({render:G,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputButton",mixins:[U]},Z=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};Z._withStripped=!0;var J=F({render:Z,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),X={name:"FormulateInputSelect",mixins:[U],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},Q=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};Q._withStripped=!0;var tt=F({render:Q,staticRenderFns:[]},void 0,X,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputSlider",mixins:[U]},ot=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};ot._withStripped=!0;var nt=F({render:ot,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),it={name:"FormulateInputTextArea",mixins:[U]},rt=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};rt._withStripped=!0;var at=F({render:rt,staticRenderFns:[]},void 0,it,void 0,!1,void 0,!1,void 0,void 0,void 0),st=function(){this.options={},this.defaults={components:{FormulateForm:$,FormulateInput:V,FormulateInputErrors:I,FormulateInputBox:T,FormulateInputText:z,FormulateInputFile:Y,FormulateInputGroup:k,FormulateInputButton:J,FormulateInputSelect:tt,FormulateInputSlider:nt,FormulateInputTextArea:at},library:n,rules:f,locale:"en",uploader:h,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:m}}};st.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},st.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+")")},st.prototype.merge=function(t,e,n){void 0===n&&(n=!0);var i={};for(var r in t)e.hasOwnProperty(r)?o(e[r])&&o(t[r])?i[r]=this.merge(t[r],e[r],n):n&&Array.isArray(t[r])&&Array.isArray(e[r])?i[r]=t[r].concat(e[r]):i[r]=e[r]:i[r]=t[r];for(var a in e)i.hasOwnProperty(a)||(i[a]=e[a]);return i},st.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},st.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},st.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},st.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},st.prototype.getUploader=function(){return this.options.uploader||!1},st.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},st.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},st.prototype.createUpload=function(t,e){return new r(t,e,this.options)};var lt=new st;export default lt; diff --git a/dist/formulate.min.js b/dist/formulate.min.js index 2538c9c..500ed8e 100644 --- a/dist/formulate.min.js +++ b/dist/formulate.min.js @@ -1,15 +1,15 @@ -var VueFormulate=function(){"use strict";var t={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},e=function(t){if("string"!=typeof t)return!1;var e=t.match(o);if(!e)return!1;var i=e[1];if(!i)return!1;if(n.test(i)||r.test(i))return!0;return!1},o=/^(?:\w+:)?\/\/(\S+)$/,n=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,r=/^[^\s\.]+\.\S{2,}$/;for(var i="-_",a=36;a--;)i+=a.toString(36);for(a=36;a---10;)i+=a.toString(36).toUpperCase();var s=function(t){var e="";for(a=t||21;a--;)e+=i[64*Math.random()|0];return e},l={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},u=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function c(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function p(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),r=o.length;if(n.length!==r)return!1;for(var i=0;i=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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},u.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}},u.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)}}))},u.prototype.getFileList=function(){return this.fileList},u.prototype.getFiles=function(){return this.files},u.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 o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),r=Date.parse(o);return Promise.resolve(!isNaN(r)&&r>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},r=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[r].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},r=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[r].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),r=Date.parse(o);return Promise.resolve(!isNaN(r)&&re&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.endsWith(t)})))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?p(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof u)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?p(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof u?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.startsWith(t)})))},url:function(t){var o=t.value;return Promise.resolve(e(o))}},y={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" must be after "+o[0]+".":f(e)+" must be a later date."},alpha:function(t){return f(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return f(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" must be before "+o[0]+".":f(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?f(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":f(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return f(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?f(e)+" is not a valid, please use the format "+o[0]:f(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+f(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return f(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var r=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==r||"value"===r?f(e)+" must be less than or equal to "+n[0]+".":f(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return f(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var r=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==r||"value"===r?f(e)+" must be more than "+n[0]+".":f(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return f(t.name)+" must be a number."},required:function(t){return f(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}}; +var VueFormulate=function(){"use strict";var t={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},e=function(t){if("string"!=typeof t)return!1;var e=t.match(o);if(!e)return!1;var i=e[1];if(!i)return!1;if(n.test(i)||r.test(i))return!0;return!1},o=/^(?:\w+:)?\/\/(\S+)$/,n=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,r=/^[^\s\.]+\.\S{2,}$/;for(var i="-_",a=36;a--;)i+=a.toString(36);for(a=36;a---10;)i+=a.toString(36).toUpperCase();var s=function(t){var e="";for(a=t||21;a--;)e+=i[64*Math.random()|0];return e},l={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},u=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function c(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function p(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),r=o.length;if(n.length!==r)return!1;for(var i=0;i=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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},u.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}},u.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)}}))},u.prototype.getFileList=function(){return this.fileList},u.prototype.getFiles=function(){return this.files},u.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var y={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),r=Date.parse(o);return Promise.resolve(!isNaN(r)&&r>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},r=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[r].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},r=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[r].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),r=Date.parse(o);return Promise.resolve(!isNaN(r)&&re&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve("string"==typeof e&&o.length?void 0!==o.find((function(t){return e.endsWith(t)})):"string"==typeof e&&0===o.length)},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?p(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof u)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?p(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof u?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve("string"==typeof e&&o.length?void 0!==o.find((function(t){return e.startsWith(t)})):"string"==typeof e&&0===o.length)},url:function(t){var o=t.value;return Promise.resolve(e(o))}},x={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?m(e)+" must be after "+o[0]+".":m(e)+" must be a later date."},alpha:function(t){return m(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return m(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?m(e)+" must be before "+o[0]+".":m(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?m(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":m(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return m(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?m(e)+" is not a valid, please use the format "+o[0]:m(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+m(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return m(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var r=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==r||"value"===r?m(e)+" must be less than or equal to "+n[0]+".":m(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return m(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var r=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==r||"value"===r?m(e)+" must be more than "+n[0]+".":m(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return m(t.name)+" must be a number."},required:function(t){return m(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}}; /*! * is-plain-object * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ -function x(t){return!0==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t); +function g(t){return!0==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t); /*! * isobject * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ -var e}function g(t){var e,o;return!1!==x(t)&&("function"==typeof(e=t.constructor)&&(!1!==x(o=e.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))}function b(t,e,o,n){return new Promise((function(o,r){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,r=Math.min(100,Math.round(n/i*100));if(e(r),r>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var w={context:function(){return P.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:_.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:F.call(this,this.options),optionGroups:!!this.optionGroups&&c(this.optionGroups,(function(e,o){return F.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:F.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return d(this.errors).concat(d(this.error)).concat(d(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function F(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var o in t)e.push({value:o,label:t[o],id:this.elementAttributes.id+"_"+o});return e}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||s(9)}]:t}function _(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function P(t){return Object.defineProperty(t,"model",{get:V.bind(this),set:A.bind(this)})}function V(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function A(t){p(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function O(t,e,o,n,r,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,r&&(p.functional=!0)),n&&(p._scopeId=n),i?(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(i)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var j={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:s(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},w,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||p(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!p(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!p(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){p(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=m(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],r=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(r=r instanceof Promise?r:Promise.resolve(r)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},$=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};$._withStripped=!0;var N=O({render:$,staticRenderFns:[]},void 0,j,void 0,!1,void 0,!1,void 0,void 0,void 0),I=function(t){this.form=t};I.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},I.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],r=function t(e){var o={};for(var n in e)e[n]instanceof u||h(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),i=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof u&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(r,((o={})[e]=t,o))})))};for(var a in r)i(a);Promise.all(n).then((function(){return e(r)})).catch((function(t){return o(t)}))}))};var E={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||p(t[o],this.internalFormModelProxy[o])||p(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||p(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new I(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},S=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};S._withStripped=!0;var C=O({render:S,staticRenderFns:[]},void 0,E,void 0,!1,void 0,!1,void 0,void 0,void 0),D={props:{errors:{type:[Boolean,Array],required:!0}}},U=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};U._withStripped=!0;var k=O({render:U,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0);function B(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var M={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,B(o,["id"])),r=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,B(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(r,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},T=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};T._withStripped=!0;var L=O({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),R={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},z={name:"FormulateInputBox",mixins:[R]},H=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t.context.value,a=t._i(o,i);n.checked?a<0&&t.$set(t.context,"model",o.concat([i])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};H._withStripped=!0;var q=O({render:H,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateInputText",mixins:[R]},G=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t._i(o,null);n.checked?i<0&&t.$set(t.context,"model",o.concat([null])):i>-1&&t.$set(t.context,"model",o.slice(0,i).concat(o.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};G._withStripped=!0;var Y=O({render:G,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateFiles",props:{files:{type:u,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},Z=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};Z._withStripped=!0;var J={name:"FormulateInputFile",components:{FormulateFiles:O({render:Z,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[R],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof u&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof u&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};X._withStripped=!0;var Q=O({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputButton",mixins:[R]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};et._withStripped=!0;var ot=O({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputSelect",mixins:[R],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},rt=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};rt._withStripped=!0;var it=O({render:rt,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at={name:"FormulateInputSlider",mixins:[R]},st=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t._i(o,null);n.checked?i<0&&t.$set(t.context,"model",o.concat([null])):i>-1&&t.$set(t.context,"model",o.slice(0,i).concat(o.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};st._withStripped=!0;var lt=O({render:st,staticRenderFns:[]},void 0,at,void 0,!1,void 0,!1,void 0,void 0,void 0),ut={name:"FormulateInputTextArea",mixins:[R]},ct=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};ct._withStripped=!0;var pt=O({render:ct,staticRenderFns:[]},void 0,ut,void 0,!1,void 0,!1,void 0,void 0,void 0),dt=function(){this.options={},this.defaults={components:{FormulateForm:C,FormulateInput:N,FormulateInputErrors:k,FormulateInputBox:q,FormulateInputText:Y,FormulateInputFile:Q,FormulateInputGroup:L,FormulateInputButton:ot,FormulateInputSelect:it,FormulateInputSlider:lt,FormulateInputTextArea:pt},library:t,rules:v,locale:"en",uploader:b,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:y}}};return dt.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},dt.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+")")},dt.prototype.merge=function(t,e,o){void 0===o&&(o=!0);var n={};for(var r in t)e.hasOwnProperty(r)?g(e[r])&&g(t[r])?n[r]=this.merge(t[r],e[r],o):o&&Array.isArray(t[r])&&Array.isArray(e[r])?n[r]=t[r].concat(e[r]):n[r]=e[r]:n[r]=t[r];for(var i in e)n.hasOwnProperty(i)||(n[i]=e[i]);return n},dt.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},dt.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},dt.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},dt.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},dt.prototype.getUploader=function(){return this.options.uploader||!1},dt.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},dt.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},dt.prototype.createUpload=function(t,e){return new u(t,e,this.options)},new dt}(); +var e}function b(t){var e,o;return!1!==g(t)&&("function"==typeof(e=t.constructor)&&(!1!==g(o=e.prototype)&&!1!==o.hasOwnProperty("isPrototypeOf")))}function w(t,e,o,n){return new Promise((function(o,r){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,r=Math.min(100,Math.round(n/i*100));if(e(r),r>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var F={context:function(){return V.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:P.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:_.call(this,this.options),optionGroups:!!this.optionGroups&&c(this.optionGroups,(function(e,o){return _.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:_.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return f(this.errors).concat(f(this.error)).concat(f(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function _(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var o in t)e.push({value:o,label:t[o],id:this.elementAttributes.id+"_"+o});return e}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||s(9)}]:t}function P(){this.$emit("blur"),"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function V(t){return Object.defineProperty(t,"model",{get:A.bind(this),set:O.bind(this)})}function A(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function O(t){p(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function j(t,e,o,n,r,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,r&&(p.functional=!0)),n&&(p._scopeId=n),i?(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(i)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var $={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:s(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},F,{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(o){e[d(o)]=t.validationRules[o]})),e},messages:function(){var t=this,e={};return Object.keys(this.validationMessages).forEach((function(o){e[d(o)]=t.validationMessages[o]})),e}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||p(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!p(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!p(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){p(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=h(this.validation,this.$formulate.rules(this.parsedValidationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],r=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(r=r instanceof Promise?r:Promise.resolve(r)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(o=d(o),this.messages&&"object"==typeof this.messages&&void 0!==this.messages[o])switch(typeof this.messages[o]){case"function":return this.messages[o];case"string":return function(){return e.messages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},N=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};N._withStripped=!0;var E=j({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0),I=function(t){this.form=t};I.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},I.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],r=function t(e){var o={};for(var n in e)e[n]instanceof u||v(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),i=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof u&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(r,((o={})[e]=t,o))})))};for(var a in r)i(a);Promise.all(n).then((function(){return e(r)})).catch((function(t){return o(t)}))}))};var S={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||p(t[o],this.internalFormModelProxy[o])||p(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||p(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new I(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},C=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};C._withStripped=!0;var D=j({render:C,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0),U={props:{errors:{type:[Boolean,Array],required:!0}}},k=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};k._withStripped=!0;var B=j({render:k,staticRenderFns:[]},void 0,U,void 0,!1,void 0,!1,void 0,void 0,void 0);function M(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var R={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,M(o,["id"])),r=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,M(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(r,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},T=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",on:{blur:t.context.blurHandler},model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};T._withStripped=!0;var L=j({render:T,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0),z={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},H={name:"FormulateInputBox",mixins:[z]},q=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t.context.value,a=t._i(o,i);n.checked?a<0&&t.$set(t.context,"model",o.concat([i])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};q._withStripped=!0;var W=j({render:q,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0),G={name:"FormulateInputText",mixins:[z]},Y=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t._i(o,null);n.checked?i<0&&t.$set(t.context,"model",o.concat([null])):i>-1&&t.$set(t.context,"model",o.slice(0,i).concat(o.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};Y._withStripped=!0;var K=j({render:Y,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"FormulateFiles",props:{files:{type:u,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},J=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};J._withStripped=!0;var X={name:"FormulateInputFile",components:{FormulateFiles:j({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[z],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof u&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof u&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},Q=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};Q._withStripped=!0;var tt=j({render:Q,staticRenderFns:[]},void 0,X,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputButton",mixins:[z]},ot=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};ot._withStripped=!0;var nt=j({render:ot,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),rt={name:"FormulateInputSelect",mixins:[z],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},it=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};it._withStripped=!0;var at=j({render:it,staticRenderFns:[]},void 0,rt,void 0,!1,void 0,!1,void 0,void 0,void 0),st={name:"FormulateInputSlider",mixins:[z]},lt=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,r=!!n.checked;if(Array.isArray(o)){var i=t._i(o,null);n.checked?i<0&&t.$set(t.context,"model",o.concat([null])):i>-1&&t.$set(t.context,"model",o.slice(0,i).concat(o.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};lt._withStripped=!0;var ut=j({render:lt,staticRenderFns:[]},void 0,st,void 0,!1,void 0,!1,void 0,void 0,void 0),ct={name:"FormulateInputTextArea",mixins:[z]},pt=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};pt._withStripped=!0;var dt=j({render:pt,staticRenderFns:[]},void 0,ct,void 0,!1,void 0,!1,void 0,void 0,void 0),ft=function(){this.options={},this.defaults={components:{FormulateForm:D,FormulateInput:E,FormulateInputErrors:B,FormulateInputBox:W,FormulateInputText:K,FormulateInputFile:tt,FormulateInputGroup:L,FormulateInputButton:nt,FormulateInputSelect:at,FormulateInputSlider:ut,FormulateInputTextArea:dt},library:t,rules:y,locale:"en",uploader:w,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:x}}};return ft.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},ft.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+")")},ft.prototype.merge=function(t,e,o){void 0===o&&(o=!0);var n={};for(var r in t)e.hasOwnProperty(r)?b(e[r])&&b(t[r])?n[r]=this.merge(t[r],e[r],o):o&&Array.isArray(t[r])&&Array.isArray(e[r])?n[r]=t[r].concat(e[r]):n[r]=e[r]:n[r]=t[r];for(var i in e)n.hasOwnProperty(i)||(n[i]=e[i]);return n},ft.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ft.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ft.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ft.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},ft.prototype.getUploader=function(){return this.options.uploader||!1},ft.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},ft.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},ft.prototype.createUpload=function(t,e){return new u(t,e,this.options)},new ft}(); diff --git a/dist/formulate.umd.js b/dist/formulate.umd.js index ea3f9e2..da2da86 100644 --- a/dist/formulate.umd.js +++ b/dist/formulate.umd.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("is-url"),require("nanoid/non-secure"),require("is-plain-object")):"function"==typeof define&&define.amd?define(["is-url","nanoid/non-secure","is-plain-object"],e):(t=t||self).Formulate=e(t.isUrl,t.nanoid,t.isPlainObject)}(this,(function(t,e,o){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,o=o&&o.hasOwnProperty("default")?o.default:o;var n={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},i={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},r=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function s(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),i=o.length;if(n.length!==i)return!1;for(var r=0;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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},r.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}},r.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)}}))},r.prototype.getFileList=function(){return this.fileList},r.prototype.getFiles=function(){return this.files},r.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var d={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&i>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&ie&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.endsWith(t)})))},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof r?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!o.length||void 0!==o.find((function(t){return e.startsWith(t)})))},url:function(e){var o=e.value;return Promise.resolve(t(o))}},f={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be after "+o[0]+".":u(e)+" must be a later date."},alpha:function(t){return u(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return u(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" must be before "+o[0]+".":u(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?u(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":u(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return u(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?u(e)+" is not a valid, please use the format "+o[0]:u(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+u(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return u(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be less than or equal to "+n[0]+".":u(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return u(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?u(e)+" must be more than "+n[0]+".":u(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return u(t.name)+" must be a number."},required:function(t){return u(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,o,n){return new Promise((function(o,i){var r=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,i=Math.min(100,Math.round(n/r*100));if(e(i),i>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var h={context:function(){return y.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:x.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:v.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,o){return v.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:v.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return l(this.errors).concat(l(this.error)).concat(l(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function v(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var o=[];for(var n in t)o.push({value:n,label:t[n],id:this.elementAttributes.id+"_"+n});return o}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function x(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:g.bind(this),set:b.bind(this)})}function g(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){s(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function w(t,e,o,n,i,r,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,i&&(p.functional=!0)),n&&(p._scopeId=n),r?(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(r)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var F={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},h,{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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||s(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!s(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!s(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){s(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=c(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],i=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(i=i instanceof Promise?i:Promise.resolve(i)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[o])switch(typeof this.validationMessages[o]){case"function":return this.validationMessages[o];case"string":return function(){return e.validationMessages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},_=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var P=w({render:_,staticRenderFns:[]},void 0,F,void 0,!1,void 0,!1,void 0,void 0,void 0),V=function(t){this.form=t};V.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},V.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],i=function t(e){var o={};for(var n in e)e[n]instanceof r||p(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(i,((o={})[e]=t,o))})))};for(var s in i)a(s);Promise.all(n).then((function(){return e(i)})).catch((function(t){return o(t)}))}))};var A={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||s(t[o],this.internalFormModelProxy[o])||s(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||s(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new V(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},O=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};O._withStripped=!0;var j=w({render:O,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),$={props:{errors:{type:[Boolean,Array],required:!0}}},N=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var I=w({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);function E(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var S={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,E(o,["id"])),i=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,E(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(i,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},C=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};C._withStripped=!0;var D=w({render:C,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0),U={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},k={name:"FormulateInputBox",mixins:[U]},B=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t.context.value,a=t._i(o,r);n.checked?a<0&&t.$set(t.context,"model",o.concat([r])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};B._withStripped=!0;var M=w({render:B,staticRenderFns:[]},void 0,k,void 0,!1,void 0,!1,void 0,void 0,void 0),T={name:"FormulateInputText",mixins:[U]},L=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};L._withStripped=!0;var R=w({render:L,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0),z={name:"FormulateFiles",props:{files:{type:r,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},q=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};q._withStripped=!0;var H={name:"FormulateInputFile",components:{FormulateFiles:w({render:q,staticRenderFns:[]},void 0,z,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[U],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof r&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},W=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};W._withStripped=!0;var G=w({render:W,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[U]},K=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};K._withStripped=!0;var Z=w({render:K,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"FormulateInputSelect",mixins:[U],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},X=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};X._withStripped=!0;var Q=w({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),tt={name:"FormulateInputSlider",mixins:[U]},et=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};et._withStripped=!0;var ot=w({render:et,staticRenderFns:[]},void 0,tt,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputTextArea",mixins:[U]},it=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};it._withStripped=!0;var rt=w({render:it,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),at=function(){this.options={},this.defaults={components:{FormulateForm:j,FormulateInput:P,FormulateInputErrors:I,FormulateInputBox:M,FormulateInputText:R,FormulateInputFile:G,FormulateInputGroup:D,FormulateInputButton:Z,FormulateInputSelect:Q,FormulateInputSlider:ot,FormulateInputTextArea:rt},library:n,rules:d,locale:"en",uploader:m,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:f}}};return at.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},at.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+")")},at.prototype.merge=function(t,e,n){void 0===n&&(n=!0);var i={};for(var r in t)e.hasOwnProperty(r)?o(e[r])&&o(t[r])?i[r]=this.merge(t[r],e[r],n):n&&Array.isArray(t[r])&&Array.isArray(e[r])?i[r]=t[r].concat(e[r]):i[r]=e[r]:i[r]=t[r];for(var a in e)i.hasOwnProperty(a)||(i[a]=e[a]);return i},at.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},at.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},at.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},at.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},at.prototype.getUploader=function(){return this.options.uploader||!1},at.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},at.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},at.prototype.createUpload=function(t,e){return new r(t,e,this.options)},new at})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("is-url"),require("nanoid/non-secure"),require("is-plain-object")):"function"==typeof define&&define.amd?define(["is-url","nanoid/non-secure","is-plain-object"],e):(t=t||self).Formulate=e(t.isUrl,t.nanoid,t.isPlainObject)}(this,(function(t,e,o){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,o=o&&o.hasOwnProperty("default")?o.default:o;var n={text:{classification:"text",component:"FormulateInputText"},email:{classification:"text",component:"FormulateInputText"},number:{classification:"text",component:"FormulateInputText"},color:{classification:"text",component:"FormulateInputText"},date:{classification:"text",component:"FormulateInputText"},hidden:{classification:"text",component:"FormulateInputText"},month:{classification:"text",component:"FormulateInputText"},password:{classification:"text",component:"FormulateInputText"},search:{classification:"text",component:"FormulateInputText"},tel:{classification:"text",component:"FormulateInputText"},time:{classification:"text",component:"FormulateInputText"},url:{classification:"text",component:"FormulateInputText"},week:{classification:"text",component:"FormulateInputText"},"datetime-local":{classification:"text",component:"FormulateInputText"},range:{classification:"slider",component:"FormulateInputSlider"},textarea:{classification:"textarea",component:"FormulateInputTextArea"},checkbox:{classification:"box",component:"FormulateInputBox"},radio:{classification:"box",component:"FormulateInputBox"},submit:{classification:"button",component:"FormulateInputButton"},button:{classification:"button",component:"FormulateInputButton"},select:{classification:"select",component:"FormulateInputSelect"},file:{classification:"file",component:"FormulateInputFile"},image:{classification:"file",component:"FormulateInputFile"}},i={aac:"audio/aac",abw:"application/x-abiword",arc:"application/x-freearc",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bmp:"image/bmp",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gz:"application/gzip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/vnd.microsoft.icon",ics:"text/calendar",jar:"application/java-archive",jpg:"image/jpeg",jpeg:"image/jpeg",js:"text/javascript",json:"application/json",jsonld:"application/ld+json",midi:"audio/x-midi",mid:"audio/midi",mjs:"text/javascript",mp3:"audio/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",opus:"audio/opus",otf:"font/otf",png:"image/png",pdf:"application/pdf",php:"application/php",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",rar:"application/vnd.rar",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"video/mp2t",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xml:"text/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","7z":"application/x-7z-compressed"},r=function(t,e,o){this.input=t,this.fileList=t.files,this.files=[],this.options=o,this.results=!1,this.context=e,Array.isArray(this.fileList)?this.rehydrateFileList(this.fileList):this.addFileList(this.fileList)};function a(t,e){var o={};for(var n in t)o[n]=e(n,t[n]);return o}function s(t,e){if(t===e)return!0;if(!t||!e)return!1;var o=Object.keys(t),n=Object.keys(e),i=o.length;if(n.length!==i)return!1;for(var r=0;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(o){t.results=o,e(o)})).catch((function(t){throw new Error(t)}))}))},r.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}},r.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)}}))},r.prototype.getFileList=function(){return this.fileList},r.prototype.getFiles=function(){return this.files},r.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var f={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&i>n)},alpha:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},alphanumeric:function(t,e){var o=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},i=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[i].test(o))},before:function(t,e){var o=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),i=Date.parse(o);return Promise.resolve(!isNaN(i)&&ie&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},endsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve("string"==typeof e&&o.length?void 0!==o.find((function(t){return e.endsWith(t)})):"string"==typeof e&&0===o.length)},in:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0!==o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},matches:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(!!o.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},mime:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFiles(),n=0;n=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length>=e)},max:function(t,e,o){var n=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(n)?(e=isNaN(e)?e:Number(e),n.length<=e):!isNaN(n)&&"length"!==o||"value"===o?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===o)&&(n=isNaN(n)?n:n.toString()).length<=e)},not:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve(void 0===o.find((function(t){return"object"==typeof t?s(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var o=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e))||(Array.isArray(o)?!!o.length:o instanceof r?o.getFiles().length>0:"string"==typeof o?!!o:"object"!=typeof o||!!o&&!!Object.keys(o).length))},startsWith:function(t){for(var e=t.value,o=[],n=arguments.length-1;n-- >0;)o[n]=arguments[n+1];return Promise.resolve("string"==typeof e&&o.length?void 0!==o.find((function(t){return e.startsWith(t)})):"string"==typeof e&&0===o.length)},url:function(e){var o=e.value;return Promise.resolve(t(o))}},m={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?c(e)+" must be after "+o[0]+".":c(e)+" must be a later date."},alpha:function(t){return c(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return c(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?c(e)+" must be before "+o[0]+".":c(e)+" must be an earlier date."},between:function(t){var e=t.name,o=t.value,n=t.args;return isNaN(o)?c(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":c(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return c(e)+" does not match."},date:function(t){var e=t.name,o=t.args;return Array.isArray(o)&&o.length?c(e)+" is not a valid, please use the format "+o[0]:c(e)+" is not a valid date."},default:function(t){t.name;return"This field isn’t valid."},email:function(t){t.name;var e=t.value;return e?"“"+e+"” is not a valid email address.":"Please enter a valid email address."},endsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t end with a valid value.":"This field doesn’t end with a valid value."},in:function(t){var e=t.name,o=t.value;return"string"==typeof o&&o?"“"+c(o)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return c(t.name)+" is not an allowed value."},max:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You may only select "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?c(e)+" must be less than or equal to "+n[0]+".":c(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,o=t.args;return c(e)+" must be of the the type: "+(o[0]||"No file formats allowed.")},min:function(t){var e=t.name,o=t.value,n=t.args;if(Array.isArray(o))return"You must select at least "+n[0]+" "+e+".";var i=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(o)&&"length"!==i||"value"===i?c(e)+" must be more than "+n[0]+".":c(e)+" must be more than "+n[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return c(t.name)+" must be a number."},required:function(t){return c(t.name)+" is required."},startsWith:function(t){t.name;var e=t.value;return e?"“"+e+"” doesn’t start with a valid value.":"This field doesn’t start with a valid value."},url:function(t){t.name;return"Please include a valid url."}};function h(t,e,o,n){return new Promise((function(o,i){var r=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,i=Math.min(100,Math.round(n/r*100));if(e(i),i>=100)return o({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var v={context:function(){return g.call(this,Object.assign({},{type:this.type,value:this.value,name:this.nameOrFallback,classification:this.classification,component:this.component,id:this.id||this.defaultId,hasLabel:this.label&&"button"!==this.classification,label:this.label,labelPosition:this.logicalLabelPosition,attributes:this.elementAttributes,performValidation:this.performValidation.bind(this),blurHandler:x.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.mergedUploadUrl,uploader:this.uploader||this.$formulate.getUploader(),uploadBehavior:this.uploadBehavior,preventWindowDrops:this.preventWindowDrops,hasValidationErrors:this.hasValidationErrors},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},typeContext:function(){var t=this;switch(this.classification){case"select":return{options:y.call(this,this.options),optionGroups:!!this.optionGroups&&a(this.optionGroups,(function(e,o){return y.call(t,o)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:y.call(this,this.options)}:{}}},elementAttributes:function(){var t=Object.assign({},this.localAttributes);this.id?t.id=this.id:t.id=this.defaultId;return t},logicalLabelPosition:function(){if(this.labelPosition)return this.labelPosition;switch(this.classification){case"box":return"after";default:return"before"}},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},mergedErrors:function(){return u(this.errors).concat(u(this.error)).concat(u(this.validationErrors)).reduce((function(t,e){return t.includes(e)?t:t.concat(e)}),[])},hasErrors:function(){return!!this.mergedErrors.length},showFieldErrors:function(){if(this.showErrors||this.formShouldShowErrors)return!0;return this.behavioralErrorVisibility},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},mergedUploadUrl:function(){return this.uploadUrl||this.$formulate.getUploadUrl()}};function y(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var o=[];for(var n in t)o.push({value:n,label:t[n],id:this.elementAttributes.id+"_"+n});return o}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function x(){this.$emit("blur"),"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function g(t){return Object.defineProperty(t,"model",{get:b.bind(this),set:w.bind(this)})}function b(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function w(t){s(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function F(t,e,o,n,i,r,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,p="function"==typeof o?o.options:o;if(t&&t.render&&(p.render=t.render,p.staticRenderFns=t.staticRenderFns,p._compiled=!0,i&&(p.functional=!0)),n&&(p._scopeId=n),r?(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(r)},p._ssrRegister=c):e&&(c=a?function(t){e.call(this,u(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,s(t))}),c)if(p.functional){var d=p.render;p.render=function(t,e){return c.call(e),d(t,e)}}else{var f=p.beforeCreate;p.beforeCreate=f?[].concat(f,c):[c]}return o}var _={name:"FormulateInput",inheritAttrs:!1,inject:{formulateFormSetter:{default:void 0},formulateFormRegister:{default:void 0},getFormValues:{default:function(){return function(){return{}}}}},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},help:{type:[String,Boolean],default:!1},debug:{type:Boolean,default:!1},errors:{type:[String,Array,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"].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}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.getInitialValue(),behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},v,{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(o){e[l(o)]=t.validationRules[o]})),e},messages:function(){var t=this,e={};return Object.keys(this.validationMessages).forEach((function(o){e[l(o)]=t.validationMessages[o]})),e}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||s(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!s(t,e)&&(this.context.model=t)}},created:function(){this.applyInitialValue(),this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{getInitialValue:function(){var t=this.$formulate.classify(this.type);return"box"===(t="box"===t&&this.options?"group":t)&&this.checked?this.value||!0:Object.prototype.hasOwnProperty.call(this.$options.propsData,"value")&&"box"!==t?this.value:Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")?this.formulateValue:""},applyInitialValue:function(){!s(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){s(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=p(this.validation,this.$formulate.rules(this.parsedValidationRules));return this.pendingValidation=Promise.all(e.map((function(e){var o=e[0],n=e[1],i=o.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(i=i instanceof Promise?i:Promise.resolve(i)).then((function(e){return!e&&t.getValidationMessage(o,n)}))}))).then((function(t){return t.filter((function(t){return t}))})).then((function(e){t.validationErrors=e})),this.pendingValidation},getValidationMessage:function(t,e){return this.getValidationFunction(t)({args:e,name:this.mergedValidationName,value:this.context.model,vm:this,formValues:this.getFormValues()})},getValidationFunction:function(t){var e=this,o="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(o=l(o),this.messages&&"object"==typeof this.messages&&void 0!==this.messages[o])switch(typeof this.messages[o]){case"function":return this.messages[o];case"string":return function(){return e.messages[o]}}return function(o){return e.$formulate.validationMessage(t.name,o)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},P=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input",attrs:{"data-classification":t.classification,"data-has-errors":t.hasErrors,"data-is-showing-errors":t.hasErrors&&t.showFieldErrors,"data-type":t.type}},[o("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--before",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context):t._e(),t._v(" "),t._t("element",[o(t.context.component,{tag:"component",attrs:{context:t.context}},[t._t("default",null,null,t.context)],2)],null,t.context),t._v(" "),t.context.hasLabel&&"after"===t.context.labelPosition?t._t("label",[o("label",{staticClass:"formulate-input-label formulate-input-label--after",attrs:{for:t.context.attributes.id},domProps:{textContent:t._s(t.context.label)}})],null,t.context.label):t._e()],2),t._v(" "),t.help?o("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?o("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};P._withStripped=!0;var V=F({render:P,staticRenderFns:[]},void 0,_,void 0,!1,void 0,!1,void 0,void 0,void 0),A=function(t){this.form=t};A.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},A.prototype.values=function(){var t=this;return new Promise((function(e,o){var n=[],i=function t(e){var o={};for(var n in e)e[n]instanceof r||d(e[n])?o[n]=e[n]:o[n]=t(e[n]);return o}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var o;return Object.assign(i,((o={})[e]=t,o))})))};for(var s in i)a(s);Promise.all(n).then((function(){return e(i)})).catch((function(t){return o(t)}))}))};var O={provide:function(){return{formulateFormSetter:this.setFieldValue,formulateFormRegister:this.register,getFormValues:this.getFormValues}},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}},data:function(){return{registry:{},internalFormModelProxy:{},formShouldShowErrors:!1}},computed:{hasInitialValue:function(){return this.formulateValue&&"object"==typeof this.formulateValue||this.values&&"object"==typeof this.values},isVmodeled:function(){return!!(this.$options.propsData.hasOwnProperty("formulateValue")&&this._events&&Array.isArray(this._events.input)&&this._events.input.length)},initialValues:function(){return Object.prototype.hasOwnProperty.call(this.$options.propsData,"formulateValue")&&"object"==typeof this.formulateValue?Object.assign({},this.formulateValue):Object.prototype.hasOwnProperty.call(this.$options.propsData,"values")&&"object"==typeof this.values?Object.assign({},this.values):{}}},watch:{formulateValue:{handler:function(t,e){if(this.isVmodeled&&t&&"object"==typeof t)for(var o in t)!this.registry.hasOwnProperty(o)||s(t[o],this.internalFormModelProxy[o])||s(t[o],this.registry[o].internalModelProxy[o])||(this.setFieldValue(o,t[o]),this.registry[o].context.model=t[o])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var o;Object.assign(this.internalFormModelProxy,((o={})[t]=e,o)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},getUniqueRegistryName:function(t,e){return void 0===e&&(e=0),Object.prototype.hasOwnProperty.call(this.registry,t+(e||""))?this.getUniqueRegistryName(t,e+1):t+(e||"")},register:function(t,e){if(Object.prototype.hasOwnProperty.call(this.registry,t))return!1;this.registry[t]=e;var o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!o&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!o&&!n||s(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new A(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}))},showErrors:function(){for(var t in this.registry)this.registry[t].formShouldShowErrors=!0},getFormValues:function(){return this.internalFormModelProxy},hasValidationErrors:function(){var t=[];for(var e in this.registry)"function"==typeof this.registry[e].hasValidationErrors&&t.push(this.registry[e].hasValidationErrors());return Promise.all(t).then((function(t){return!!t.find((function(t){return t}))}))}}},j=function(){var t=this,e=t.$createElement;return(t._self._c||e)("form",{on:{submit:function(e){return e.preventDefault(),t.formSubmitted(e)}}},[t._t("default")],2)};j._withStripped=!0;var $=F({render:j,staticRenderFns:[]},void 0,O,void 0,!1,void 0,!1,void 0,void 0,void 0),N={props:{errors:{type:[Boolean,Array],required:!0}}},E=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.errors.length?o("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return o("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};E._withStripped=!0;var I=F({render:E,staticRenderFns:[]},void 0,N,void 0,!1,void 0,!1,void 0,void 0,void 0);function S(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(o[n]=t[n]);return o}var C={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},subComponent:function(){return"FormulateInput"},optionsWithContext:function(){var t=this,e=this.context,o=(e.options,e.labelPosition,e.attributes),n=(o.id,S(o,["id"])),i=(e.classification,e.blurHandler,e.performValidation,e.hasValidationErrors,e.component,e.hasLabel,S(e,["options","labelPosition","attributes","classification","blurHandler","performValidation","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(i,e,n)}))}},methods:{groupItemContext:function(t,e,o){return Object.assign({},t,e,o,{})}}},D=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return o(t.subComponent,t._b({key:e.id,tag:"component",staticClass:"formulate-input-group-item",on:{blur:t.context.blurHandler},model:{value:t.context.model,callback:function(e){t.$set(t.context,"model",e)},expression:"context.model"}},"component",e,!1))})),1)};D._withStripped=!0;var U=F({render:D,staticRenderFns:[]},void 0,C,void 0,!1,void 0,!1,void 0,void 0,void 0),k={props:{context:{type:Object,required:!0}},computed:{type:function(){return this.context.type},id:function(){return this.context.id},attributes:function(){return this.context.attributes||{}},hasValue:function(){return!!this.context.model}}},B={name:"FormulateInputBox",mixins:[k]},R=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{value:t.context.value,checked:Array.isArray(t.context.model)?t._i(t.context.model,t.context.value)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t.context.value,a=t._i(o,r);n.checked?a<0&&t.$set(t.context,"model",o.concat([r])):a>-1&&t.$set(t.context,"model",o.slice(0,a).concat(o.slice(a+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{value:t.context.value,checked:t._q(t.context.model,t.context.value)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",t.context.value)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.value,value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),o("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};R._withStripped=!0;var T=F({render:R,staticRenderFns:[]},void 0,B,void 0,!1,void 0,!1,void 0,void 0,void 0),M={name:"FormulateInputText",mixins:[k]},L=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1))])};L._withStripped=!0;var z=F({render:L,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),q={name:"FormulateFiles",props:{files:{type:r,required:!0},imagePreview:{type:Boolean,default:!1}},computed:{fileUploads:function(){return this.files.files||[]}},watch:{files:function(){this.imagePreview&&this.files.loadPreviews()}},mounted:function(){this.imagePreview&&this.files.loadPreviews()}},H=function(){var t=this,e=t.$createElement,o=t._self._c||e;return t.fileUploads.length?o("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return o("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[o("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?o("div",{staticClass:"formulate-file-image-preview"},[o("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),o("div",{staticClass:"formulate-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?o("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[o("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?o("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?o("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};H._withStripped=!0;var W={name:"FormulateInputFile",components:{FormulateFiles:F({render:H,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[k],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},created:function(){Array.isArray(this.context.model)&&"string"==typeof this.context.model[0][this.$formulate.getFileUrlKey()]&&(this.context.model=this.$formulate.createUpload({files:this.context.model},this.context))},mounted:function(){window&&this.context.preventWindowDrops&&(window.addEventListener("dragover",this.preventDefault),window.addEventListener("drop",this.preventDefault))},destroyed:function(){window&&this.context.preventWindowDrops&&(window.removeEventListener("dragover",this.preventDefault),window.removeEventListener("drop",this.preventDefault))},methods:{preventDefault:function(t){"INPUT"!==t.target.tagName&&"file"!==t.target.getAttribute("type")&&(t=t||event).preventDefault()},handleFile:function(){var t=this;this.isOver=!1;var e=this.$refs.file;e.files.length&&(this.context.model=this.$formulate.createUpload(e,this.context),this.$nextTick((function(){return t.attemptImmediateUpload()})))},attemptImmediateUpload:function(){var t=this;"live"===this.context.uploadBehavior&&this.context.model instanceof r&&this.context.hasValidationErrors().then((function(e){e||t.context.model.upload()}))},handleDragOver:function(t){t.preventDefault(),this.isOver=!0},handleDragLeave:function(t){t.preventDefault(),this.isOver=!1}}},G=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[o("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[o("input",t._b({ref:"file",attrs:{"data-is-drag-hover":t.isOver,type:"file"},on:{blur:t.context.blurHandler,change:t.handleFile,dragover:t.handleDragOver,dragleave:t.handleDragLeave}},"input",t.attributes,!1)),t._v(" "),o("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?o("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};G._withStripped=!0;var Y=F({render:G,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputButton",mixins:[k]},Z=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[o("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};Z._withStripped=!0;var J=F({render:Z,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),X={name:"FormulateInputSelect",mixins:[k],computed:{options:function(){return this.context.options||{}},optionGroups:function(){return this.context.optionGroups||!1},placeholderSelected:function(){return!(this.hasValue||!this.context.attributes||!this.context.attributes.placeholder)}}},Q=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[o("select",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{"data-placeholder-selected":t.placeholderSelected},on:{blur:t.context.blurHandler,change:function(e){var o=Array.prototype.filter.call(e.target.options,(function(t){return t.selected})).map((function(t){return"_value"in t?t._value:t.value}));t.$set(t.context,"model",e.target.multiple?o:o[0])}}},"select",t.attributes,!1),[t.context.placeholder?o("option",{attrs:{value:"",disabled:""},domProps:{selected:!t.hasValue}},[t._v("\n "+t._s(t.context.placeholder)+"\n ")]):t._e(),t._v(" "),t.optionGroups?t._l(t.optionGroups,(function(e,n){return o("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))})),0)})):t._l(t.options,(function(e){return o("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};Q._withStripped=!0;var tt=F({render:Q,staticRenderFns:[]},void 0,X,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputSlider",mixins:[k]},ot=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"checkbox"},domProps:{checked:Array.isArray(t.context.model)?t._i(t.context.model,null)>-1:t.context.model},on:{blur:t.context.blurHandler,change:function(e){var o=t.context.model,n=e.target,i=!!n.checked;if(Array.isArray(o)){var r=t._i(o,null);n.checked?r<0&&t.$set(t.context,"model",o.concat([null])):r>-1&&t.$set(t.context,"model",o.slice(0,r).concat(o.slice(r+1)))}else t.$set(t.context,"model",i)}}},"input",t.attributes,!1)):"radio"===t.type?o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:"radio"},domProps:{checked:t._q(t.context.model,null)},on:{blur:t.context.blurHandler,change:function(e){return t.$set(t.context,"model",null)}}},"input",t.attributes,!1)):o("input",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],attrs:{type:t.type},domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"input",t.attributes,!1)),t._v(" "),t.context.showValue?o("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};ot._withStripped=!0;var nt=F({render:ot,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),it={name:"FormulateInputTextArea",mixins:[k]},rt=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[o("textarea",t._b({directives:[{name:"model",rawName:"v-model",value:t.context.model,expression:"context.model"}],domProps:{value:t.context.model},on:{blur:t.context.blurHandler,input:function(e){e.target.composing||t.$set(t.context,"model",e.target.value)}}},"textarea",t.attributes,!1))])};rt._withStripped=!0;var at=F({render:rt,staticRenderFns:[]},void 0,it,void 0,!1,void 0,!1,void 0,void 0,void 0),st=function(){this.options={},this.defaults={components:{FormulateForm:$,FormulateInput:V,FormulateInputErrors:I,FormulateInputBox:T,FormulateInputText:z,FormulateInputFile:Y,FormulateInputGroup:U,FormulateInputButton:J,FormulateInputSelect:tt,FormulateInputSlider:nt,FormulateInputTextArea:at},library:n,rules:f,locale:"en",uploader:h,uploadUrl:!1,fileUrlKey:"url",uploadJustCompleteDuration:1e3,plugins:[],locales:{en:m}}};return st.prototype.install=function(t,e){var o=this;for(var n in t.prototype.$formulate=this,this.options=this.merge(this.defaults,e||{}),Array.isArray(this.options.plugins)&&this.options.plugins.length&&this.options.plugins.forEach((function(t){return"function"==typeof t?t(o):null})),this.options.components)t.component(n,this.options.components[n])},st.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+")")},st.prototype.merge=function(t,e,n){void 0===n&&(n=!0);var i={};for(var r in t)e.hasOwnProperty(r)?o(e[r])&&o(t[r])?i[r]=this.merge(t[r],e[r],n):n&&Array.isArray(t[r])&&Array.isArray(e[r])?i[r]=t[r].concat(e[r]):i[r]=e[r]:i[r]=t[r];for(var a in e)i.hasOwnProperty(a)||(i[a]=e[a]);return i},st.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},st.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},st.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},st.prototype.validationMessage=function(t,e){var o=this.options.locales[this.options.locale];return o.hasOwnProperty(t)?o[t](e):"_"===t[0]&&o.hasOwnProperty(t.substr(1))?o[t.substr(1)](e):o.hasOwnProperty("default")?o.default(e):"This field does not have a valid value"},st.prototype.getUploader=function(){return this.options.uploader||!1},st.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},st.prototype.getFileUrlKey=function(){return this.options.fileUrlKey||"url"},st.prototype.createUpload=function(t,e){return new r(t,e,this.options)},new st})); diff --git a/src/FormulateInput.vue b/src/FormulateInput.vue index 24764ec..b4df507 100644 --- a/src/FormulateInput.vue +++ b/src/FormulateInput.vue @@ -55,7 +55,7 @@ diff --git a/src/FormulateForm.vue b/src/FormulateForm.vue index 92a3bad..848680d 100644 --- a/src/FormulateForm.vue +++ b/src/FormulateForm.vue @@ -1,13 +1,20 @@ diff --git a/src/FormulateInputGroup.vue b/src/FormulateInputGroup.vue index eaa2f57..d25f41f 100644 --- a/src/FormulateInputGroup.vue +++ b/src/FormulateInputGroup.vue @@ -6,6 +6,7 @@ :key="optionContext.id" v-model="context.model" v-bind="optionContext" + :disable-errors="true" class="formulate-input-group-item" @blur="context.blurHandler" /> diff --git a/src/libs/context.js b/src/libs/context.js index 744faaf..89b0e95 100644 --- a/src/libs/context.js +++ b/src/libs/context.js @@ -30,16 +30,21 @@ export default { ...this.typeContext }) }, + // Used in sub-context nameOrFallback, typeContext, elementAttributes, logicalLabelPosition, + mergedUploadUrl, + + // These items are not passed as context isVmodeled, - mergedErrors, - hasErrors, - showFieldErrors, mergedValidationName, - mergedUploadUrl + explicitErrors, + allErrors, + hasErrors, + hasVisibleErrors, + showValidationErrors } /** @@ -125,7 +130,7 @@ function mergedUploadUrl () { * Determines if the field should show it's error (if it has one) * @return {boolean} */ -function showFieldErrors () { +function showValidationErrors () { if (this.showErrors || this.formShouldShowErrors) { return true } @@ -176,20 +181,33 @@ function createOptionList (options) { } /** - * The merged errors computed property. + * These are errors we that have been explicity passed to us. */ -function mergedErrors () { +function explicitErrors () { return arrayify(this.errors) .concat(arrayify(this.error)) - .concat(arrayify(this.validationErrors)) - .reduce((errors, err) => !errors.includes(err) ? errors.concat(err) : errors, []) } /** - * Does this computed property have errors. + * The merged errors computed property. + */ +function allErrors () { + return this.explicitErrors + .concat(arrayify(this.validationErrors)) +} + +/** + * Does this computed property have errors */ function hasErrors () { - return !!this.mergedErrors.length + return !!this.allErrors.length +} + +/** + * Checks if form has actively visible errors. + */ +function hasVisibleErrors () { + return ((this.validationErrors && this.showValidationErrors) || !!this.explicitErrors.length) } /** diff --git a/src/libs/handler.js b/src/libs/handler.js new file mode 100644 index 0000000..b387c77 --- /dev/null +++ b/src/libs/handler.js @@ -0,0 +1,11 @@ +/** + * The default backend error handler assumes a failed axios instance. You can + * easily override this function with fetch. The expected output is defined + * on the documentation site vueformulate.com. + */ +export default function (err) { + if (typeof err === 'object' && err.response) { + + } + return {} +} diff --git a/src/libs/library.js b/src/libs/library.js index 5596885..d1b114d 100644 --- a/src/libs/library.js +++ b/src/libs/library.js @@ -1,108 +1,51 @@ +/** + * library.js + * + * Note: We're shipping front end code here, file size is critical. This file is + * overly terse for that reason alone, we wouldn't necessarily recommend this. + */ +const fi = 'FormulateInput' +const add = (n, c) => ({ + classification: n, + component: fi + (c || (n[0].toUpperCase() + n.substr(1))) +}) export default { // === SINGLE LINE TEXT STYLE INPUTS - text: { - classification: 'text', - component: 'FormulateInputText' - }, - email: { - classification: 'text', - component: 'FormulateInputText' - }, - number: { - classification: 'text', - component: 'FormulateInputText' - }, - color: { - classification: 'text', - component: 'FormulateInputText' - }, - date: { - classification: 'text', - component: 'FormulateInputText' - }, - hidden: { - classification: 'text', - component: 'FormulateInputText' - }, - month: { - classification: 'text', - component: 'FormulateInputText' - }, - password: { - classification: 'text', - component: 'FormulateInputText' - }, - search: { - classification: 'text', - component: 'FormulateInputText' - }, - tel: { - classification: 'text', - component: 'FormulateInputText' - }, - time: { - classification: 'text', - component: 'FormulateInputText' - }, - url: { - classification: 'text', - component: 'FormulateInputText' - }, - week: { - classification: 'text', - component: 'FormulateInputText' - }, - 'datetime-local': { - classification: 'text', - component: 'FormulateInputText' - }, + ...[ + 'text', + 'email', + 'number', + 'color', + 'date', + 'hidden', + 'month', + 'password', + 'search', + 'tel', + 'time', + 'url', + 'week', + 'datetime-local' + ].reduce((lib, type) => ({ ...lib, [type]: add('text') }), {}), // === SLIDER INPUTS - range: { - classification: 'slider', - component: 'FormulateInputSlider' - }, + range: add('slider'), // === MULTI LINE TEXT INPUTS - textarea: { - classification: 'textarea', - component: 'FormulateInputTextArea' - }, + textarea: add('textarea', 'TextArea'), // === BOX STYLE INPUTS - checkbox: { - classification: 'box', - component: 'FormulateInputBox' - }, - radio: { - classification: 'box', - component: 'FormulateInputBox' - }, + checkbox: add('box'), + radio: add('box'), // === BUTTON STYLE INPUTS - submit: { - classification: 'button', - component: 'FormulateInputButton' - }, - button: { - classification: 'button', - component: 'FormulateInputButton' - }, + submit: add('button'), + button: add('button'), // === SELECT STYLE INPUTS - select: { - classification: 'select', - component: 'FormulateInputSelect' - }, + select: add('select'), // === FILE TYPE - - file: { - classification: 'file', - component: 'FormulateInputFile' - }, - image: { - classification: 'file', - component: 'FormulateInputFile' - } + file: add('file'), + image: add('file') } diff --git a/src/libs/mimes.js b/src/libs/mimes.js index 749d8b8..2d62fd2 100644 --- a/src/libs/mimes.js +++ b/src/libs/mimes.js @@ -1,74 +1,10 @@ +const i = 'image/' export default { - 'aac': 'audio/aac', - 'abw': 'application/x-abiword', - 'arc': 'application/x-freearc', - 'avi': 'video/x-msvideo', - 'azw': 'application/vnd.amazon.ebook', - 'bin': 'application/octet-stream', - 'bmp': 'image/bmp', - 'bz': 'application/x-bzip', - 'bz2': 'application/x-bzip2', - 'csh': 'application/x-csh', - 'css': 'text/css', 'csv': 'text/csv', - 'doc': 'application/msword', - 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'eot': 'application/vnd.ms-fontobject', - 'epub': 'application/epub+zip', - 'gz': 'application/gzip', - 'gif': 'image/gif', - 'htm': 'text/html', - 'html': 'text/html', - 'ico': 'image/vnd.microsoft.icon', - 'ics': 'text/calendar', - 'jar': 'application/java-archive', - 'jpg': 'image/jpeg', - 'jpeg': 'image/jpeg', - 'js': 'text/javascript', - 'json': 'application/json', - 'jsonld': 'application/ld+json', - 'midi': 'audio/x-midi', - 'mid': 'audio/midi', - 'mjs': 'text/javascript', - 'mp3': 'audio/mpeg', - 'mpeg': 'video/mpeg', - 'mpkg': 'application/vnd.apple.installer+xml', - 'odp': 'application/vnd.oasis.opendocument.presentation', - 'ods': 'application/vnd.oasis.opendocument.spreadsheet', - 'odt': 'application/vnd.oasis.opendocument.text', - 'oga': 'audio/ogg', - 'ogv': 'video/ogg', - 'ogx': 'application/ogg', - 'opus': 'audio/opus', - 'otf': 'font/otf', - 'png': 'image/png', + 'gif': i + 'gif', + 'jpg': i + 'jpeg', + 'jpeg': i + 'jpeg', + 'png': i + 'png', 'pdf': 'application/pdf', - 'php': 'application/php', - 'ppt': 'application/vnd.ms-powerpoint', - 'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'rar': 'application/vnd.rar', - 'rtf': 'application/rtf', - 'sh': 'application/x-sh', - 'svg': 'image/svg+xml', - 'swf': 'application/x-shockwave-flash', - 'tar': 'application/x-tar', - 'tif': 'image/tiff', - 'tiff': 'image/tiff', - 'ts': 'video/mp2t', - 'ttf': 'font/ttf', - 'txt': 'text/plain', - 'vsd': 'application/vnd.visio', - 'wav': 'audio/wav', - 'weba': 'audio/webm', - 'webm': 'video/webm', - 'webp': 'image/webp', - 'woff': 'font/woff', - 'woff2': 'font/woff2', - 'xhtml': 'application/xhtml+xml', - 'xls': 'application/vnd.ms-excel', - 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml': 'text/xml', - 'xul': 'application/vnd.mozilla.xul+xml', - 'zip': 'application/zip', - '7z': 'application/x-7z-compressed' + 'svg': i + 'svg+xml' } diff --git a/src/libs/utils.js b/src/libs/utils.js index 27ef582..a08cd57 100644 --- a/src/libs/utils.js +++ b/src/libs/utils.js @@ -13,34 +13,6 @@ export function map (original, callback) { return obj } -/** - * Function to filter an object's properties - * @param {Object} original - * @param {Function} callback - */ -export function filter (original, callback) { - let obj = {} - for (let key in original) { - if (callback(key, original[key])) { - obj[key] = original[key] - } - } - return obj -} - -/** - * Function to reduce an object's properties - * @param {Object} original - * @param {Function} callback - * @param {*} accumulator - */ -export function reduce (original, callback, accumulator) { - for (let key in original) { - accumulator = callback(accumulator, key, original[key]) - } - return accumulator -} - /** * Shallow equal. * @param {} objA @@ -144,6 +116,7 @@ function parseRule (rule, rules) { return [rule, []] } if (Array.isArray(rule) && rule.length) { + rule = rule.map(r => r) // light clone rule[0] = snakeToCamel(rule[0]) if (typeof rule[0] === 'string' && rules.hasOwnProperty(rule[0])) { return [rules[rule.shift()], rule] diff --git a/test/Formulate.test.js b/test/Formulate.test.js index d2926fa..608ff5d 100644 --- a/test/Formulate.test.js +++ b/test/Formulate.test.js @@ -63,7 +63,7 @@ test('installs on vue instance', () => { const components = [ 'FormulateForm', 'FormulateInput', - 'FormulateInputErrors', + 'FormulateErrors', 'FormulateInputBox', 'FormulateInputText', 'FormulateInputFile', diff --git a/test/FormulateForm.test.js b/test/FormulateForm.test.js index e6215f1..9af3bcd 100644 --- a/test/FormulateForm.test.js +++ b/test/FormulateForm.test.js @@ -221,4 +221,172 @@ describe('FormulateForm', () => { await flushPromises() expect(wrapper.find('.formulate-input-error').exists()).toBe(true) }) + + it('automatically registers with root plugin', async () => { + const wrapper = mount(FormulateForm, { + propsData: { formulateValue: { box3: [] }, name: 'login' } + }) + expect(wrapper.vm.$formulate.registry.has('login')).toBe(true) + expect(wrapper.vm.$formulate.registry.get('login')).toBe(wrapper.vm) + }) + + it('errors are displayed on correctly named components', async () => { + const wrapper = mount({ + template: ` +
+ + +
+ ` + }) + expect(wrapper.vm.$formulate.registry.has('login') && wrapper.vm.$formulate.registry.has('register')).toBe(true) + wrapper.vm.$formulate.handle({ formErrors: ['This is an error message'] }, 'login') + await flushPromises() + expect(wrapper.findAll('.formulate-form').length).toBe(2) + expect(wrapper.find('.formulate-form--login .formulate-form-errors').exists()).toBe(true) + expect(wrapper.find('.formulate-form--register .formulate-form-errors').exists()).toBe(false) + }) + + it('hides root FormError if another form error exists and renders in new location', async () => { + const wrapper = mount({ + template: ` + +

Login

+ + +
+ ` + }) + wrapper.vm.$formulate.handle({ formErrors: ['This is an error message'] }, 'login') + await flushPromises() + expect(wrapper.findAll('.formulate-form-errors').length).toBe(1) + // Ensure that we moved the position of the errors + expect(wrapper.find('h1 + *').is('.formulate-form-errors')).toBe(true) + }) + + it('allows rendering multiple locations', async () => { + const wrapper = mount({ + template: ` + +

Login

+ + + +
+ ` + }) + wrapper.vm.$formulate.handle({ formErrors: ['This is an error message'] }, 'login') + await flushPromises() + expect(wrapper.findAll('.formulate-form-errors').length).toBe(2) + }) + + it('receives a form-errors prop and displays it', async () => { + const wrapper = mount(FormulateForm, { + propsData: { formErrors: ['first', 'second'] }, + slots: { + default: '' + } + }) + await flushPromises() + expect(wrapper.findAll('.formulate-form-error').length).toBe(2) + }) + + it('it aggregates form-errors prop with form-named errors', async () => { + const wrapper = mount(FormulateForm, { + propsData: { formErrors: ['first', 'second'], name: 'login' } + }) + wrapper.vm.$formulate.handle({ formErrors: ['third'] }, 'login') + await flushPromises() + expect(wrapper.findAll('.formulate-form-error').length).toBe(3) + }) + + it('displays field errors on inputs with errors prop', async () => { + const wrapper = mount(FormulateForm, { + propsData: { errors: { sipple: ['This field has an error'] }}, + slots: { + default: '' + } + }) + await wrapper.vm.$nextTick() + expect(wrapper.find('.formulate-input .formulate-input-error').exists()).toBe(true) + }) + + it('is able to display multiple errors on multiple elements', async () => { + const wrapper = mount({ + template: ` + + + + + + ` + }) + await wrapper.vm.$nextTick() + expect(wrapper.findAll('.formulate-input-error').length).toBe(4) + }) + + it('it can set multiple field errors with handle()', async () => { + const wrapper = mount({ + template: ` + + + + + + ` + }) + expect(wrapper.findAll('.formulate-input-error').length).toBe(0) + wrapper.vm.$formulate.handle({ inputErrors: {inputA: ['first', 'second'], inputB: 'only one here', inputC: ['and one here']} }, "register") + await wrapper.vm.$nextTick() + await flushPromises() + expect(wrapper.findAll('.formulate-input-error').length).toBe(4) + }) + + it('only sets 1 error when used on a FormulateGroup input', async () => { + const wrapper = mount({ + template: ` + + + + ` + }) + await wrapper.vm.$nextTick() + expect(wrapper.findAll('.formulate-input-error').length).toBe(1) + }) + + it('properly de-registers an observer when removed', async () => { + const wrapper = mount({ + data () { + return { + hasField: true + } + }, + template: ` + + + + ` + }) + await flushPromises() + expect(wrapper.find(FormulateForm).vm.errorObservers.length).toBe(1) + wrapper.setData({ hasField: false }) + await flushPromises() + expect(wrapper.find(FormulateForm).vm.errorObservers.length).toBe(0) + }) }) diff --git a/test/FormulateInputText.test.js b/test/FormulateInputText.test.js index c3cd0d7..95707b1 100644 --- a/test/FormulateInputText.test.js +++ b/test/FormulateInputText.test.js @@ -172,8 +172,8 @@ describe('FormulateInputText', () => { expect(wrapper.find('.formulate-input-errors').exists()).toBe(false) }) - it('accepts a single string as an error prop', () => { - const wrapper = mount(FormulateInput, { propsData: { type: 'text', errorBehavior: 'live', error: 'This is an error' } }) + it('accepts a single string as an error prop', async () => { + const wrapper = mount(FormulateInput, { propsData: { type: 'text', error: 'This is an error' } }) expect(wrapper.find('.formulate-input-errors').exists()).toBe(true) }) @@ -192,16 +192,23 @@ describe('FormulateInputText', () => { expect(wrapper.find('[data-has-errors]').exists()).toBe(true) }) - it('does not initially show error-behavior blur errors', () => { - const wrapper = mount(FormulateInput, { propsData: { type: 'text', errorBehavior: 'blur', errors: ['Bad input'] } }) + it('Should always show explicitly set errors, but not validation errors', () => { + const wrapper = mount(FormulateInput, { propsData: { type: 'text', validation: 'required', errorBehavior: 'blur', errors: ['Bad input'] } }) expect(wrapper.find('[data-has-errors]').exists()).toBe(true) - expect(wrapper.find('[data-is-showing-errors]').exists()).toBe(false) - expect(wrapper.findAll('.formulate-input-errors').exists()).toBe(false) + expect(wrapper.find('[data-is-showing-errors]').exists()).toBe(true) + expect(wrapper.findAll('.formulate-input-error').length).toBe(1) }) + it('Should show no errors when there are no errors', () => { + const wrapper = mount(FormulateInput, { propsData: { type: 'text' } }) + expect(wrapper.find('[data-has-errors]').exists()).toBe(false) + expect(wrapper.find('[data-is-showing-errors]').exists()).toBe(false) + expect(wrapper.findAll('.formulate-input-error').exists()).toBe(false) + }) - it('allows error-behavior blur to be overridden with show-errors', () => { - const wrapper = mount(FormulateInput, { propsData: { type: 'text', errorBehavior: 'blur', showErrors: true, errors: ['Bad input'] } }) + it('allows error-behavior blur to be overridden with show-errors', async () => { + const wrapper = mount(FormulateInput, { propsData: { type: 'text', errorBehavior: 'blur', showErrors: true, validation: 'required' } }) + await flushPromises() expect(wrapper.find('[data-has-errors]').exists()).toBe(true) expect(wrapper.find('[data-is-showing-errors]').exists()).toBe(true) expect(wrapper.findAll('.formulate-input-errors').exists()).toBe(true) @@ -209,14 +216,29 @@ describe('FormulateInputText', () => { }) it('shows errors on blur with error-behavior blur', async () => { - const wrapper = mount(FormulateInput, { propsData: { type: 'text', errorBehavior: 'blur', errors: ['Bad input'] } }) + const wrapper = mount(FormulateInput, { propsData: { type: 'text', errorBehavior: 'blur', validation: 'required' } }) + await wrapper.vm.$nextTick() + await flushPromises() expect(wrapper.find('[data-has-errors]').exists()).toBe(true) expect(wrapper.find('[data-is-showing-errors]').exists()).toBe(false) - expect(wrapper.findAll('.formulate-input-errors').exists()).toBe(false) + expect(wrapper.findAll('.formulate-input-error').exists()).toBe(false) + expect(wrapper.vm.showValidationErrors).toBe(false) wrapper.find('input').trigger('blur') await flushPromises() + expect(wrapper.vm.showValidationErrors).toBe(true) expect(wrapper.find('[data-is-showing-errors]').exists()).toBe(true) - expect(wrapper.findAll('.formulate-input-errors').exists()).toBe(true) - expect(wrapper.findAll('.formulate-input-error').length).toBe(1) + // expect(wrapper.findAll('.formulate-input-errors').exists()).toBe(true) + // expect(wrapper.findAll('.formulate-input-error').length).toBe(1) + }) + + it('continues to show errors if validation fires more than one time', async () => { + const wrapper = mount(FormulateInput, { propsData: { type: 'date', errorBehavior: 'live', validation: [['after', '01/01/2021']] , value: '01/01/1999' } }) + await wrapper.vm.$nextTick() + await flushPromises() + expect(wrapper.find('[data-has-errors]').exists()).toBe(true) + wrapper.find('input').trigger('input') + await wrapper.vm.$nextTick() + await flushPromises() + expect(wrapper.find('[data-has-errors]').exists()).toBe(true) }) }) diff --git a/themes/boilerplate/boilerplate.scss b/themes/boilerplate/boilerplate.scss index 0306780..38e2a64 100644 --- a/themes/boilerplate/boilerplate.scss +++ b/themes/boilerplate/boilerplate.scss @@ -107,3 +107,15 @@ // image uploads } } + + +// Form-level errors +// ----------------------------------------------------------------------------- + +.formulate-form-errors { + + .formulate-form-error { + // form errors (not specific to a field) + } +} + diff --git a/themes/snow/_inputs.scss b/themes/snow/_inputs.scss index 0268576..a941510 100644 --- a/themes/snow/_inputs.scss +++ b/themes/snow/_inputs.scss @@ -632,7 +632,27 @@ } } } - - + } +} + +.formulate-form-errors { + margin: .75em 0; + padding: 0; + list-style-type: none; + + &:first-child { + margin-top: 0; + } + + &:last-child { + margin-bottom: 0; + } + + .formulate-form-error { + color: $formulate-error; + font-size: .9em; + font-weight: 300; + line-height: 1.5; + margin-bottom: .25em; } } From 34de4ba6dcf9dd3dd915210c01c82f81bf6c27b1 Mon Sep 17 00:00:00 2001 From: Justin Schroeder Date: Sat, 7 Mar 2020 09:03:59 -0500 Subject: [PATCH 5/8] Adds support for @braid/vue-formulate-i18n * Adds support form FormulateError form errors * Adds support for form-errors prop Also includes tests for both named-form-errors as well, form-errors prop, positioning form errors with the component, and allowing multiple * Adds form error support, error handling, and supporting tests * Remove unused util functions * Adds german localization locales/de.js (#14) * Create de.js * Added startsWith and endsWith * adds build process for localization support, removes dist * Adds danish localization * fixes bug that resulted in validation failing if run more than once Credit to @luan-nk-nguyen for discovering the bug * Moves locales to vue-formulate-i18n * Adds dist files for locales * Adds vue-formulate-i18n 1.0.1 * Uses i18n 1.0.3 * Build files * Fixes #19 * Update src/locales/README.md Co-Authored-By: Andrew Boyd * changes v-html to v-text for error message output credit to @skix123 for the bug report! Co-authored-by: Andrew Boyd --- build/rollup.config.js | 23 +- build/rollup.iife.config.js | 9 +- dist/formulate.esm.js | 2 +- dist/formulate.min.js | 6 +- dist/formulate.min.js.map | 1 - dist/formulate.umd.js | 2 +- package-lock.json | 1009 ++++++++++++++++-- package.json | 7 +- src/Formulate.js | 46 +- src/FormulateErrors.vue | 4 +- src/FormulateInput.vue | 2 +- src/libs/context.js | 3 + src/libs/utils.js | 25 +- src/locales/README.md | 9 + src/locales/en.js | 191 ---- test/Formulate.test.js | 101 -- test/unit/Formulate.test.js | 169 +++ test/{ => unit}/FormulateForm.test.js | 4 +- test/{ => unit}/FormulateInput.test.js | 2 +- test/{ => unit}/FormulateInputBox.test.js | 2 +- test/{ => unit}/FormulateInputButton.test.js | 2 +- test/{ => unit}/FormulateInputFile.test.js | 14 +- test/{ => unit}/FormulateInputSlider.test.js | 6 +- test/{ => unit}/FormulateInputText.test.js | 2 +- test/{ => unit}/rules.test.js | 2 +- test/{ => unit}/utils.test.js | 13 +- 26 files changed, 1234 insertions(+), 422 deletions(-) delete mode 100644 dist/formulate.min.js.map create mode 100644 src/locales/README.md delete mode 100644 src/locales/en.js delete mode 100644 test/Formulate.test.js create mode 100644 test/unit/Formulate.test.js rename test/{ => unit}/FormulateForm.test.js (99%) rename test/{ => unit}/FormulateInput.test.js (98%) rename test/{ => unit}/FormulateInputBox.test.js (99%) rename test/{ => unit}/FormulateInputButton.test.js (98%) rename test/{ => unit}/FormulateInputFile.test.js (62%) rename test/{ => unit}/FormulateInputSlider.test.js (84%) rename test/{ => unit}/FormulateInputText.test.js (99%) rename test/{ => unit}/rules.test.js (99%) rename test/{ => unit}/utils.test.js (93%) diff --git a/build/rollup.config.js b/build/rollup.config.js index 4c4debb..b41087a 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -1,20 +1,23 @@ +import commonjs from '@rollup/plugin-commonjs' // Convert CommonJS modules to ES6 +import buble from '@rollup/plugin-buble' // Transpile/polyfill with reasonable browser support import autoExternal from 'rollup-plugin-auto-external' -import commonjs from 'rollup-plugin-commonjs' // Convert CommonJS modules to ES6 import vue from 'rollup-plugin-vue' // Handle .vue SFC files -import buble from 'rollup-plugin-buble' // Transpile/polyfill with reasonable browser support import { terser } from 'rollup-plugin-terser' export default { input: 'src/Formulate.js', // Path relative to package.json - output: { - name: 'Formulate', - exports: 'default', - globals: { - 'is-plain-object': 'isPlainObject', - 'nanoid/non-secure': 'nanoid', - 'is-url': 'isUrl' + output: [ + { + name: 'Formulate', + exports: 'default', + globals: { + 'is-plain-object': 'isPlainObject', + 'nanoid/non-secure': 'nanoid', + 'is-url': 'isUrl', + '@braid/vue-formulate-i18n': 'VueFormulateI18n' + } } - }, + ], external: ['nanoid/non-secure'], plugins: [ commonjs(), diff --git a/build/rollup.iife.config.js b/build/rollup.iife.config.js index a8d025a..c60f3b0 100644 --- a/build/rollup.iife.config.js +++ b/build/rollup.iife.config.js @@ -1,7 +1,7 @@ import resolve from '@rollup/plugin-node-resolve' -import commonjs from 'rollup-plugin-commonjs' // Convert CommonJS modules to ES6 +import commonjs from '@rollup/plugin-commonjs' // Convert CommonJS modules to ES6 +import buble from '@rollup/plugin-buble' // Transpile/polyfill with reasonable browser support import vue from 'rollup-plugin-vue' // Handle .vue SFC files -import buble from 'rollup-plugin-buble' // Transpile/polyfill with reasonable browser support import internal from 'rollup-plugin-internal' import { terser } from 'rollup-plugin-terser' @@ -14,7 +14,8 @@ export default { globals: { 'is-plain-object': 'isPlainObject', 'nanoid/non-secure': 'nanoid', - 'is-url': 'isUrl' + 'is-url': 'isUrl', + '@braid/vue-formulate-i18n': 'VueFormulateI18n' } }, plugins: [ @@ -23,7 +24,7 @@ export default { preferBuiltins: false }), commonjs(), - internal(['is-plain-object', 'nanoid/non-secure', 'is-url']), + internal(['is-plain-object', 'nanoid/non-secure', 'is-url', '@braid/vue-formulate-i18n']), vue({ css: true, // Dynamically inject css as a