From 3fcfa759a93553dc92ed793c9464882946e7771c Mon Sep 17 00:00:00 2001 From: Justin Schroeder Date: Sun, 1 Mar 2020 13:28:46 -0500 Subject: [PATCH 1/3] Patches axios uploader behavior --- dist/formulate.esm.js | 2 +- dist/formulate.min.js | 4 ++-- dist/formulate.umd.js | 2 +- src/FileUpload.js | 20 ++++++++++++++------ src/Formulate.js | 8 ++++++++ src/libs/context.js | 13 +++++++++++-- 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/dist/formulate.esm.js b/dist/formulate.esm.js index 0e03141..c631f56 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 n from"is-plain-object";var r={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"}},o=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var r in t)n[r]=e(r,t[r]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),r=Object.keys(e),o=n.length;if(r.length!==o)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(n){t.results=n,e(n)})).catch((function(t){throw new Error(t)}))}))},o.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},o.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)}}))},o.prototype.getFileList=function(){return this.fileList},o.prototype.getFiles=function(){return this.files},o.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 n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&o>r)},alpha:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},alphanumeric:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},before:function(t,e){var n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&oe&&r.lengthe&&r()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0!==n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},matches:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(!!n.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,n){var r=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(r)?(e=isNaN(e)?e:Number(e),r.length<=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))<=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length<=e)},mime:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(function(){if(e instanceof o)for(var t=e.getFileList(),r=0;r=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))>=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length>=e)},not:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0===n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var n=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(n)?!n.length:"string"==typeof n?!n:!("object"!=typeof n||n&&Object.keys(n).length))))},url:function(e){var n=e.value;return Promise.resolve(t(n))}},p={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be after "+n[0]+".":l(e)+" must be a later date."},alpha:function(t){return l(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return l(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be before "+n[0]+".":l(e)+" must be an earlier date."},between:function(t){var e=t.name,n=t.value,r=t.args;return isNaN(n)?l(e)+" must be between "+r[0]+" and "+r[1]+" characters long.":l(e)+" must be between "+r[0]+" and "+r[1]+"."},confirm:function(t){var e=t.name;t.args;return l(e)+" does not match."},date:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" is not a valid, please use the format "+n[0]:l(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,n=t.value;return"string"==typeof n&&n?"“"+l(n)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return l(t.name)+" is not an allowed value."},max:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You may only select "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be less than or equal to "+r[0]+".":l(e)+" must be less than or equal to "+r[0]+" characters long."},mime:function(t){var e=t.name,n=t.args;return l(e)+" must be of the the type: "+(n[0]||"No file formats allowed.")},min:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You must select at least "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be more than "+r[0]+".":l(e)+" must be more than "+r[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return l(t.name)+" must be a number."},required:function(t){return l(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,n,r){return new Promise((function(n,o){var i=(r.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var r=performance.now()-a,o=Math.min(100,Math.round(r/i*100));if(e(o),o>=100)return n({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var f={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,blurHandler:v.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:h.call(this,this.options),optionGroups:!!this.optionGroups&&i(this.optionGroups,(function(e,n){return h.call(t,n)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:h.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 s(this.errors).concat(s(this.error)).concat(s(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}};function h(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var n=[];for(var r in t)n.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return n}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function v(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:x.bind(this),set:b.bind(this)})}function x(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function g(t,e,n,r,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof n?n.options:n;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),r&&(d._scopeId=r),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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var m=d.beforeCreate;d.beforeCreate=m?[].concat(m,c):[c]}return n}var w={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{}}}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||a(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!a(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){a(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=u(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var n=e[0],r=e[1],o=n.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(r));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(n,r)}))}))).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,n="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[n])switch(typeof this.validationMessages[n]){case"function":return this.validationMessages[n];case"string":return function(){return e.validationMessages[n]}}return function(n){return e.$formulate.validationMessage(t.name,n)}},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,n=t._self._c||e;return n("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}},[n("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[n("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",[n(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",[n("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?n("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?n("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var F=g({render:_,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),P=function(t){this.form=t};P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,n){var r=[],i=function t(e){var n={};for(var r in e)e[r]instanceof o||c(e[r])?n[r]=e[r]:n[r]=t(e[r]);return n}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof o&&r.push(t.form.internalFormModelProxy[e].upload().then((function(t){var n;return Object.assign(i,((n={})[e]=t,n))})))};for(var s in i)a(s);Promise.all(r).then((function(){return e(i)})).catch((function(t){return n(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 n in t)!this.registry.hasOwnProperty(n)||a(t[n],this.internalFormModelProxy[n])||a(t[n],this.registry[n].internalModelProxy[n])||(this.setFieldValue(n,t[n]),this.registry[n].context.model=t[n])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var n;Object.assign(this.internalFormModelProxy,((n={})[t]=e,n)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!n&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!n&&!r||a(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},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}))}))}}},V=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)};V._withStripped=!0;var N=g({render:V,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),$={props:{errors:{type:[Boolean,Array],required:!0}}},O=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.errors.length?n("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return n("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};O._withStripped=!0;var E=g({render:O,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);var I={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,n=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(n[r]=t[r]);return n}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(n,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},S=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return n(e.component,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)};S._withStripped=!0;var j=g({render:S,staticRenderFns:[]},void 0,I,void 0,!1,void 0,!1,void 0,void 0,void 0),C={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}}},D={name:"FormulateInputBox",mixins:[C]},k=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t.context.value,a=t._i(n,i);r.checked?a<0&&t.$set(t.context,"model",n.concat([i])):a>-1&&t.$set(t.context,"model",n.slice(0,a).concat(n.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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(" "),n("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};k._withStripped=!0;var B=g({render:k,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0),M={name:"FormulateInputText",mixins:[C]},T=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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 U=g({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),R={name:"FormulateFiles",props:{files:{type:o,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()}},L=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.fileUploads.length?n("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return n("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[n("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?n("div",{staticClass:"formulate-file-image-preview"},[n("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),n("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?n("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[n("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?n("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?n("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};L._withStripped=!0;var H={name:"FormulateInputFile",components:{FormulateFiles:g({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[C],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof o&&this.context.model.files.length)}},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 o&&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,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[n("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[n("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(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?n("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};q._withStripped=!0;var G=g({render:q,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[C]},W=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[n("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};W._withStripped=!0;var z=g({render:W,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"FormulateInputSelect",mixins:[C],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)}}},J=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("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 n=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?n:n[0])}}},"select",t.attributes,!1),[t.context.placeholder?n("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,r){return n("optgroup",{key:r,attrs:{label:r}},t._l(e,(function(e){return n("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 n("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};J._withStripped=!0;var X=g({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputSlider",mixins:[C]},Q=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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?n("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};Q._withStripped=!0;var tt=g({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputTextArea",mixins:[C]},nt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[n("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))])};nt._withStripped=!0;var rt=g({render:nt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot=function(){this.options={},this.defaults={components:{FormulateForm:N,FormulateInput:F,FormulateInputErrors:E,FormulateInputBox:B,FormulateInputText:U,FormulateInputFile:G,FormulateInputGroup:j,FormulateInputButton:z,FormulateInputSelect:X,FormulateInputSlider:tt,FormulateInputTextArea:rt},library:r,rules:d,locale:"en",uploader:m,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:p}}};ot.prototype.install=function(t,e){var n=this;for(var r 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(n):null})),this.options.components)t.component(r,this.options.components[r])},ot.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+")")},ot.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var o={};for(var i in t)e.hasOwnProperty(i)?n(e[i])&&n(t[i])?o[i]=this.merge(t[i],e[i],r):r&&Array.isArray(t[i])&&Array.isArray(e[i])?o[i]=t[i].concat(e[i]):o[i]=e[i]:o[i]=t[i];for(var a in e)o.hasOwnProperty(a)||(o[a]=e[a]);return o},ot.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ot.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ot.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ot.prototype.validationMessage=function(t,e){var n=this.options.locales[this.options.locale];return n.hasOwnProperty(t)?n[t](e):"_"===t[0]&&n.hasOwnProperty(t.substr(1))?n[t.substr(1)](e):n.hasOwnProperty("default")?n.default(e):"This field does not have a valid value"},ot.prototype.getUploader=function(){return this.options.uploader||!1},ot.prototype.createUpload=function(t,e){return new o(t,e,this.options)};var it=new ot;export default it; +import t from"is-url";import e from"nanoid/non-secure";import n from"is-plain-object";var r={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"}},o=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var r in t)n[r]=e(r,t[r]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),r=Object.keys(e),o=n.length;if(r.length!==o)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(n){t.results=n,e(n)})).catch((function(t){throw new Error(t)}))}))},o.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},o.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)}}))},o.prototype.getFileList=function(){return this.fileList},o.prototype.getFiles=function(){return this.files},o.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 n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&o>r)},alpha:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},alphanumeric:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},before:function(t,e){var n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&oe&&r.lengthe&&r()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0!==n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},matches:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(!!n.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,n){var r=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(r)?(e=isNaN(e)?e:Number(e),r.length<=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))<=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length<=e)},mime:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(function(){if(e instanceof o)for(var t=e.getFileList(),r=0;r=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))>=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length>=e)},not:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0===n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var n=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(n)?!n.length:"string"==typeof n?!n:!("object"!=typeof n||n&&Object.keys(n).length))))},url:function(e){var n=e.value;return Promise.resolve(t(n))}},p={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be after "+n[0]+".":l(e)+" must be a later date."},alpha:function(t){return l(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return l(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be before "+n[0]+".":l(e)+" must be an earlier date."},between:function(t){var e=t.name,n=t.value,r=t.args;return isNaN(n)?l(e)+" must be between "+r[0]+" and "+r[1]+" characters long.":l(e)+" must be between "+r[0]+" and "+r[1]+"."},confirm:function(t){var e=t.name;t.args;return l(e)+" does not match."},date:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" is not a valid, please use the format "+n[0]:l(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,n=t.value;return"string"==typeof n&&n?"“"+l(n)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return l(t.name)+" is not an allowed value."},max:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You may only select "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be less than or equal to "+r[0]+".":l(e)+" must be less than or equal to "+r[0]+" characters long."},mime:function(t){var e=t.name,n=t.args;return l(e)+" must be of the the type: "+(n[0]||"No file formats allowed.")},min:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You must select at least "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be more than "+r[0]+".":l(e)+" must be more than "+r[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return l(t.name)+" must be a number."},required:function(t){return l(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,n,r){return new Promise((function(n,o){var i=(r.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var r=performance.now()-a,o=Math.min(100,Math.round(r/i*100));if(e(o),o>=100)return n({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var f={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,blurHandler:v.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:h.call(this,this.options),optionGroups:!!this.optionGroups&&i(this.optionGroups,(function(e,n){return h.call(t,n)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:h.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 s(this.errors).concat(s(this.error)).concat(s(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 h(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var n=[];for(var r in t)n.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return n}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function v(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:x.bind(this),set:b.bind(this)})}function x(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function g(t,e,n,r,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof n?n.options:n;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),r&&(d._scopeId=r),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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var m=d.beforeCreate;d.beforeCreate=m?[].concat(m,c):[c]}return n}var w={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{}}}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||a(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!a(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){a(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=u(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var n=e[0],r=e[1],o=n.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(r));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(n,r)}))}))).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,n="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[n])switch(typeof this.validationMessages[n]){case"function":return this.validationMessages[n];case"string":return function(){return e.validationMessages[n]}}return function(n){return e.$formulate.validationMessage(t.name,n)}},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,n=t._self._c||e;return n("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}},[n("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[n("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",[n(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",[n("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?n("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?n("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var F=g({render:_,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),P=function(t){this.form=t};P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,n){var r=[],i=function t(e){var n={};for(var r in e)e[r]instanceof o||c(e[r])?n[r]=e[r]:n[r]=t(e[r]);return n}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof o&&r.push(t.form.internalFormModelProxy[e].upload().then((function(t){var n;return Object.assign(i,((n={})[e]=t,n))})))};for(var s in i)a(s);Promise.all(r).then((function(){return e(i)})).catch((function(t){return n(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 n in t)!this.registry.hasOwnProperty(n)||a(t[n],this.internalFormModelProxy[n])||a(t[n],this.registry[n].internalModelProxy[n])||(this.setFieldValue(n,t[n]),this.registry[n].context.model=t[n])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var n;Object.assign(this.internalFormModelProxy,((n={})[t]=e,n)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!n&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!n&&!r||a(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},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}))}))}}},V=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)};V._withStripped=!0;var $=g({render:V,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),N={props:{errors:{type:[Boolean,Array],required:!0}}},O=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.errors.length?n("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return n("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};O._withStripped=!0;var E=g({render:O,staticRenderFns:[]},void 0,N,void 0,!1,void 0,!1,void 0,void 0,void 0);var I={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,n=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(n[r]=t[r]);return n}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(n,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},S=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return n(e.component,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)};S._withStripped=!0;var j=g({render:S,staticRenderFns:[]},void 0,I,void 0,!1,void 0,!1,void 0,void 0,void 0),C={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}}},D={name:"FormulateInputBox",mixins:[C]},k=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t.context.value,a=t._i(n,i);r.checked?a<0&&t.$set(t.context,"model",n.concat([i])):a>-1&&t.$set(t.context,"model",n.slice(0,a).concat(n.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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(" "),n("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};k._withStripped=!0;var B=g({render:k,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0),U={name:"FormulateInputText",mixins:[C]},M=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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))])};M._withStripped=!0;var T=g({render:M,staticRenderFns:[]},void 0,U,void 0,!1,void 0,!1,void 0,void 0,void 0),R={name:"FormulateFiles",props:{files:{type:o,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()}},L=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.fileUploads.length?n("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return n("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[n("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?n("div",{staticClass:"formulate-file-image-preview"},[n("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),n("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?n("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[n("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?n("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?n("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};L._withStripped=!0;var H={name:"FormulateInputFile",components:{FormulateFiles:g({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[C],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof o&&this.context.model.files.length)}},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 o&&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,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[n("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[n("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(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?n("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};q._withStripped=!0;var G=g({render:q,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[C]},W=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[n("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};W._withStripped=!0;var z=g({render:W,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"FormulateInputSelect",mixins:[C],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)}}},J=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("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 n=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?n:n[0])}}},"select",t.attributes,!1),[t.context.placeholder?n("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,r){return n("optgroup",{key:r,attrs:{label:r}},t._l(e,(function(e){return n("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 n("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};J._withStripped=!0;var X=g({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputSlider",mixins:[C]},Q=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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?n("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};Q._withStripped=!0;var tt=g({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputTextArea",mixins:[C]},nt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[n("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))])};nt._withStripped=!0;var rt=g({render:nt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot=function(){this.options={},this.defaults={components:{FormulateForm:$,FormulateInput:F,FormulateInputErrors:E,FormulateInputBox:B,FormulateInputText:T,FormulateInputFile:G,FormulateInputGroup:j,FormulateInputButton:z,FormulateInputSelect:X,FormulateInputSlider:tt,FormulateInputTextArea:rt},library:r,rules:d,locale:"en",uploader:m,uploadUrl:!1,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:p}}};ot.prototype.install=function(t,e){var n=this;for(var r 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(n):null})),this.options.components)t.component(r,this.options.components[r])},ot.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+")")},ot.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var o={};for(var i in t)e.hasOwnProperty(i)?n(e[i])&&n(t[i])?o[i]=this.merge(t[i],e[i],r):r&&Array.isArray(t[i])&&Array.isArray(e[i])?o[i]=t[i].concat(e[i]):o[i]=e[i]:o[i]=t[i];for(var a in e)o.hasOwnProperty(a)||(o[a]=e[a]);return o},ot.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ot.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ot.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ot.prototype.validationMessage=function(t,e){var n=this.options.locales[this.options.locale];return n.hasOwnProperty(t)?n[t](e):"_"===t[0]&&n.hasOwnProperty(t.substr(1))?n[t.substr(1)](e):n.hasOwnProperty("default")?n.default(e):"This field does not have a valid value"},ot.prototype.getUploader=function(){return this.options.uploader||!1},ot.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},ot.prototype.createUpload=function(t,e){return new o(t,e,this.options)};var it=new ot;export default it; diff --git a/dist/formulate.min.js b/dist/formulate.min.js index 7c19bd6..0173e77 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(r);if(!e)return!1;var i=e[1];if(!i)return!1;if(n.test(i)||o.test(i))return!0;return!1},r=/^(?:\w+:)?\/\/(\S+)$/,n=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,o=/^[^\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=function(t,e,r){this.input=t,this.fileList=t.files,this.files=[],this.options=r,this.addFileList(this.fileList),this.context=e,this.results=!1};function u(t,e){var r={};for(var n in t)r[n]=e(n,t[n]);return r}function c(t,e){if(t===e)return!0;if(!t||!e)return!1;var r=Object.keys(t),n=Object.keys(e),o=r.length;if(n.length!==o)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(r){t.results=r,e(r)})).catch((function(t){throw new Error(t)}))}))},l.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},l.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)}}))},l.prototype.getFileList=function(){return this.fileList},l.prototype.getFiles=function(){return this.files},l.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var h={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var r=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),o=Date.parse(r);return Promise.resolve(!isNaN(o)&&o>n)},alpha:function(t,e){var r=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[o].test(r))},alphanumeric:function(t,e){var r=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[o].test(r))},before:function(t,e){var r=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),o=Date.parse(r);return Promise.resolve(!isNaN(o)&&oe&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Promise.resolve(void 0!==r.find((function(t){return"object"==typeof t?c(t,e):t===e})))},matches:function(t){for(var e=t.value,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Promise.resolve(!!r.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,r){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"!==r||"value"===r?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===r)&&(n=isNaN(n)?n:n.toString()).length<=e)},mime:function(t){for(var e=t.value,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof l)for(var t=e.getFileList(),n=0;n=e):!isNaN(n)&&"length"!==r||"value"===r?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===r)&&(n=isNaN(n)?n:n.toString()).length>=e)},not:function(t){for(var e=t.value,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Promise.resolve(void 0===r.find((function(t){return"object"==typeof t?c(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var r=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(r)?!r.length:"string"==typeof r?!r:!("object"!=typeof r||r&&Object.keys(r).length))))},url:function(t){var r=t.value;return Promise.resolve(e(r))}},v={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?p(e)+" must be after "+r[0]+".":p(e)+" must be a later date."},alpha:function(t){return p(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return p(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?p(e)+" must be before "+r[0]+".":p(e)+" must be an earlier date."},between:function(t){var e=t.name,r=t.value,n=t.args;return isNaN(r)?p(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":p(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return p(e)+" does not match."},date:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?p(e)+" is not a valid, please use the format "+r[0]:p(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,r=t.value;return"string"==typeof r&&r?"“"+p(r)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return p(t.name)+" is not an allowed value."},max:function(t){var e=t.name,r=t.value,n=t.args;if(Array.isArray(r))return"You may only select "+n[0]+" "+e+".";var o=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(r)&&"length"!==o||"value"===o?p(e)+" must be less than or equal to "+n[0]+".":p(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,r=t.args;return p(e)+" must be of the the type: "+(r[0]||"No file formats allowed.")},min:function(t){var e=t.name,r=t.value,n=t.args;if(Array.isArray(r))return"You must select at least "+n[0]+" "+e+".";var o=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(r)&&"length"!==o||"value"===o?p(e)+" must be more than "+n[0]+".":p(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 p(t.name)+" must be a number."},required:function(t){return p(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(r);if(!e)return!1;var i=e[1];if(!i)return!1;if(n.test(i)||o.test(i))return!0;return!1},r=/^(?:\w+:)?\/\/(\S+)$/,n=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,o=/^[^\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=function(t,e,r){this.input=t,this.fileList=t.files,this.files=[],this.options=r,this.addFileList(this.fileList),this.context=e,this.results=!1};function u(t,e){var r={};for(var n in t)r[n]=e(n,t[n]);return r}function c(t,e){if(t===e)return!0;if(!t||!e)return!1;var r=Object.keys(t),n=Object.keys(e),o=r.length;if(n.length!==o)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(r){t.results=r,e(r)})).catch((function(t){throw new Error(t)}))}))},l.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},l.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)}}))},l.prototype.getFileList=function(){return this.fileList},l.prototype.getFiles=function(){return this.files},l.prototype.toString=function(){var t=this.files.length?this.files.length+" files":"empty";return this.results?JSON.stringify(this.results,null," "):"FileUpload("+t+")"};var h={accepted:function(t){var e=t.value;return Promise.resolve(["yes","on","1",1,!0,"true"].includes(e))},after:function(t,e){var r=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),o=Date.parse(r);return Promise.resolve(!isNaN(o)&&o>n)},alpha:function(t,e){var r=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[o].test(r))},alphanumeric:function(t,e){var r=t.value;void 0===e&&(e="default");var n={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=n.hasOwnProperty(e)?e:"default";return Promise.resolve(n[o].test(r))},before:function(t,e){var r=t.value;void 0===e&&(e=!1);var n=Date.parse(e||new Date),o=Date.parse(r);return Promise.resolve(!isNaN(o)&&oe&&n.lengthe&&n()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Promise.resolve(void 0!==r.find((function(t){return"object"==typeof t?c(t,e):t===e})))},matches:function(t){for(var e=t.value,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Promise.resolve(!!r.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,r){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"!==r||"value"===r?(n=isNaN(n)?n:Number(n))<=e:("string"==typeof n||"length"===r)&&(n=isNaN(n)?n:n.toString()).length<=e)},mime:function(t){for(var e=t.value,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Promise.resolve(function(){if(e instanceof l)for(var t=e.getFileList(),n=0;n=e):!isNaN(n)&&"length"!==r||"value"===r?(n=isNaN(n)?n:Number(n))>=e:("string"==typeof n||"length"===r)&&(n=isNaN(n)?n:n.toString()).length>=e)},not:function(t){for(var e=t.value,r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Promise.resolve(void 0===r.find((function(t){return"object"==typeof t?c(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var r=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(r)?!r.length:"string"==typeof r?!r:!("object"!=typeof r||r&&Object.keys(r).length))))},url:function(t){var r=t.value;return Promise.resolve(e(r))}},v={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?p(e)+" must be after "+r[0]+".":p(e)+" must be a later date."},alpha:function(t){return p(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return p(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?p(e)+" must be before "+r[0]+".":p(e)+" must be an earlier date."},between:function(t){var e=t.name,r=t.value,n=t.args;return isNaN(r)?p(e)+" must be between "+n[0]+" and "+n[1]+" characters long.":p(e)+" must be between "+n[0]+" and "+n[1]+"."},confirm:function(t){var e=t.name;t.args;return p(e)+" does not match."},date:function(t){var e=t.name,r=t.args;return Array.isArray(r)&&r.length?p(e)+" is not a valid, please use the format "+r[0]:p(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,r=t.value;return"string"==typeof r&&r?"“"+p(r)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return p(t.name)+" is not an allowed value."},max:function(t){var e=t.name,r=t.value,n=t.args;if(Array.isArray(r))return"You may only select "+n[0]+" "+e+".";var o=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(r)&&"length"!==o||"value"===o?p(e)+" must be less than or equal to "+n[0]+".":p(e)+" must be less than or equal to "+n[0]+" characters long."},mime:function(t){var e=t.name,r=t.args;return p(e)+" must be of the the type: "+(r[0]||"No file formats allowed.")},min:function(t){var e=t.name,r=t.value,n=t.args;if(Array.isArray(r))return"You must select at least "+n[0]+" "+e+".";var o=!(!Array.isArray(n)||!n[1])&&n[1];return!isNaN(r)&&"length"!==o||"value"===o?p(e)+" must be more than "+n[0]+".":p(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 p(t.name)+" must be a number."},required:function(t){return p(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}}; /*! * is-plain-object * @@ -12,4 +12,4 @@ function y(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 x(t){var e,r;return!1!==y(t)&&("function"==typeof(e=t.constructor)&&(!1!==y(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}function b(t,e,r,n){return new Promise((function(r,o){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,o=Math.min(100,Math.round(n/i*100));if(e(o),o>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var g={context:function(){return F.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,blurHandler:_.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:w.call(this,this.options),optionGroups:!!this.optionGroups&&u(this.optionGroups,(function(e,r){return w.call(t,r)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:w.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}};function w(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var r in t)e.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return e}return 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 F(t){return Object.defineProperty(t,"model",{get:P.bind(this),set:A.bind(this)})}function P(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function A(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function V(t,e,r,n,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof r?r.options:r;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),n&&(d._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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,c):[c]}return r}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{}}}},data:function(){return{defaultId:s(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},g,{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||c(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!c(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){c(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=f(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var r=e[0],n=e[1],o=r.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(r,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,r="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[r])switch(typeof this.validationMessages[r]){case"function":return this.validationMessages[r];case"string":return function(){return e.validationMessages[r]}}return function(r){return e.$formulate.validationMessage(t.name,r)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},O=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("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}},[r("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[r("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",[r(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",[r("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?r("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?r("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};O._withStripped=!0;var N=V({render:O,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0),S=function(t){this.form=t};S.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},S.prototype.values=function(){var t=this;return new Promise((function(e,r){var n=[],o=function t(e){var r={};for(var n in e)e[n]instanceof l||m(e[n])?r[n]=e[n]:r[n]=t(e[n]);return r}(t.form.internalFormModelProxy),i=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof l&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var r;return Object.assign(o,((r={})[e]=t,r))})))};for(var a in o)i(a);Promise.all(n).then((function(){return e(o)})).catch((function(t){return r(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 r in t)!this.registry.hasOwnProperty(r)||c(t[r],this.internalFormModelProxy[r])||c(t[r],this.registry[r].internalModelProxy[r])||(this.setFieldValue(r,t[r]),this.registry[r].context.model=t[r])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var r;Object.assign(this.internalFormModelProxy,((r={})[t]=e,r)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!r&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!r&&!n||c(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new S(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 I=V({render:j,staticRenderFns:[]},void 0,E,void 0,!1,void 0,!1,void 0,void 0,void 0),C={props:{errors:{type:[Boolean,Array],required:!0}}},D=function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.errors.length?r("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return r("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};D._withStripped=!0;var k=V({render:D,staticRenderFns:[]},void 0,C,void 0,!1,void 0,!1,void 0,void 0,void 0);var B={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,r=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(r[n]=t[n]);return r}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(r,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},M=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return r(e.component,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)};M._withStripped=!0;var T=V({render:M,staticRenderFns:[]},void 0,B,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}}},R={name:"FormulateInputBox",mixins:[U]},L=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t.context.value,a=t._i(r,i);n.checked?a<0&&t.$set(t.context,"model",r.concat([i])):a>-1&&t.$set(t.context,"model",r.slice(0,a).concat(r.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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(" "),r("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};L._withStripped=!0;var H=V({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0),q={name:"FormulateInputText",mixins:[U]},G=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&t.$set(t.context,"model",r.concat([null])):i>-1&&t.$set(t.context,"model",r.slice(0,i).concat(r.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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=V({render:G,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateFiles",props:{files:{type:l,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,r=t._self._c||e;return t.fileUploads.length?r("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return r("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[r("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?r("div",{staticClass:"formulate-file-image-preview"},[r("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),r("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?r("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[r("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?r("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?r("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};z._withStripped=!0;var Z={name:"FormulateInputFile",components:{FormulateFiles:V({render:z,staticRenderFns:[]},void 0,W,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 l&&this.context.model.files.length)}},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 l&&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}}},J=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[r("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[r("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(" "),r("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?r("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};J._withStripped=!0;var X=V({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputButton",mixins:[U]},Q=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[r("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[r("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};Q._withStripped=!0;var tt=V({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={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)}}},rt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[r("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 r=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?r:r[0])}}},"select",t.attributes,!1),[t.context.placeholder?r("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 r("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return r("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 r("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};rt._withStripped=!0;var nt=V({render:rt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot={name:"FormulateInputSlider",mixins:[U]},it=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&t.$set(t.context,"model",r.concat([null])):i>-1&&t.$set(t.context,"model",r.slice(0,i).concat(r.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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?r("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};it._withStripped=!0;var at=V({render:it,staticRenderFns:[]},void 0,ot,void 0,!1,void 0,!1,void 0,void 0,void 0),st={name:"FormulateInputTextArea",mixins:[U]},lt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[r("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))])};lt._withStripped=!0;var ut=V({render:lt,staticRenderFns:[]},void 0,st,void 0,!1,void 0,!1,void 0,void 0,void 0),ct=function(){this.options={},this.defaults={components:{FormulateForm:I,FormulateInput:N,FormulateInputErrors:k,FormulateInputBox:H,FormulateInputText:Y,FormulateInputFile:X,FormulateInputGroup:T,FormulateInputButton:tt,FormulateInputSelect:nt,FormulateInputSlider:at,FormulateInputTextArea:ut},library:t,rules:h,locale:"en",uploader:b,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:v}}};return ct.prototype.install=function(t,e){var r=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(r):null})),this.options.components)t.component(n,this.options.components[n])},ct.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+")")},ct.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var n={};for(var o in t)e.hasOwnProperty(o)?x(e[o])&&x(t[o])?n[o]=this.merge(t[o],e[o],r):r&&Array.isArray(t[o])&&Array.isArray(e[o])?n[o]=t[o].concat(e[o]):n[o]=e[o]:n[o]=t[o];for(var i in e)n.hasOwnProperty(i)||(n[i]=e[i]);return n},ct.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ct.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ct.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ct.prototype.validationMessage=function(t,e){var r=this.options.locales[this.options.locale];return r.hasOwnProperty(t)?r[t](e):"_"===t[0]&&r.hasOwnProperty(t.substr(1))?r[t.substr(1)](e):r.hasOwnProperty("default")?r.default(e):"This field does not have a valid value"},ct.prototype.getUploader=function(){return this.options.uploader||!1},ct.prototype.createUpload=function(t,e){return new l(t,e,this.options)},new ct}(); +var e}function x(t){var e,r;return!1!==y(t)&&("function"==typeof(e=t.constructor)&&(!1!==y(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}function b(t,e,r,n){return new Promise((function(r,o){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,o=Math.min(100,Math.round(n/i*100));if(e(o),o>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var g={context:function(){return F.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,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:w.call(this,this.options),optionGroups:!!this.optionGroups&&u(this.optionGroups,(function(e,r){return w.call(t,r)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:w.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 w(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var r in t)e.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return e}return 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 F(t){return Object.defineProperty(t,"model",{get:P.bind(this),set:A.bind(this)})}function P(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function A(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function V(t,e,r,n,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof r?r.options:r;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),n&&(d._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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,c):[c]}return r}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{}}}},data:function(){return{defaultId:s(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},g,{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||c(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!c(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){c(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=f(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var r=e[0],n=e[1],o=r.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(r,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,r="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[r])switch(typeof this.validationMessages[r]){case"function":return this.validationMessages[r];case"string":return function(){return e.validationMessages[r]}}return function(r){return e.$formulate.validationMessage(t.name,r)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},O=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("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}},[r("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[r("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",[r(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",[r("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?r("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?r("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};O._withStripped=!0;var N=V({render:O,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0),S=function(t){this.form=t};S.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},S.prototype.values=function(){var t=this;return new Promise((function(e,r){var n=[],o=function t(e){var r={};for(var n in e)e[n]instanceof l||m(e[n])?r[n]=e[n]:r[n]=t(e[n]);return r}(t.form.internalFormModelProxy),i=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof l&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var r;return Object.assign(o,((r={})[e]=t,r))})))};for(var a in o)i(a);Promise.all(n).then((function(){return e(o)})).catch((function(t){return r(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 r in t)!this.registry.hasOwnProperty(r)||c(t[r],this.internalFormModelProxy[r])||c(t[r],this.registry[r].internalModelProxy[r])||(this.setFieldValue(r,t[r]),this.registry[r].context.model=t[r])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var r;Object.assign(this.internalFormModelProxy,((r={})[t]=e,r)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!r&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!r&&!n||c(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new S(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 I=V({render:j,staticRenderFns:[]},void 0,E,void 0,!1,void 0,!1,void 0,void 0,void 0),C={props:{errors:{type:[Boolean,Array],required:!0}}},D=function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.errors.length?r("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return r("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};D._withStripped=!0;var k=V({render:D,staticRenderFns:[]},void 0,C,void 0,!1,void 0,!1,void 0,void 0,void 0);var B={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,r=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(r[n]=t[n]);return r}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(r,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},U=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return r(e.component,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)};U._withStripped=!0;var M=V({render:U,staticRenderFns:[]},void 0,B,void 0,!1,void 0,!1,void 0,void 0,void 0),T={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}}},R={name:"FormulateInputBox",mixins:[T]},L=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t.context.value,a=t._i(r,i);n.checked?a<0&&t.$set(t.context,"model",r.concat([i])):a>-1&&t.$set(t.context,"model",r.slice(0,a).concat(r.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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(" "),r("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};L._withStripped=!0;var H=V({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0),q={name:"FormulateInputText",mixins:[T]},G=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&t.$set(t.context,"model",r.concat([null])):i>-1&&t.$set(t.context,"model",r.slice(0,i).concat(r.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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=V({render:G,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateFiles",props:{files:{type:l,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,r=t._self._c||e;return t.fileUploads.length?r("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return r("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[r("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?r("div",{staticClass:"formulate-file-image-preview"},[r("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),r("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?r("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[r("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?r("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?r("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};z._withStripped=!0;var Z={name:"FormulateInputFile",components:{FormulateFiles:V({render:z,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[T],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof l&&this.context.model.files.length)}},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 l&&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}}},J=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[r("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[r("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(" "),r("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?r("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};J._withStripped=!0;var X=V({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputButton",mixins:[T]},Q=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[r("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[r("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};Q._withStripped=!0;var tt=V({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputSelect",mixins:[T],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,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[r("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 r=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?r:r[0])}}},"select",t.attributes,!1),[t.context.placeholder?r("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 r("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return r("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 r("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};rt._withStripped=!0;var nt=V({render:rt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot={name:"FormulateInputSlider",mixins:[T]},it=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&t.$set(t.context,"model",r.concat([null])):i>-1&&t.$set(t.context,"model",r.slice(0,i).concat(r.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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?r("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};it._withStripped=!0;var at=V({render:it,staticRenderFns:[]},void 0,ot,void 0,!1,void 0,!1,void 0,void 0,void 0),st={name:"FormulateInputTextArea",mixins:[T]},lt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[r("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))])};lt._withStripped=!0;var ut=V({render:lt,staticRenderFns:[]},void 0,st,void 0,!1,void 0,!1,void 0,void 0,void 0),ct=function(){this.options={},this.defaults={components:{FormulateForm:I,FormulateInput:N,FormulateInputErrors:k,FormulateInputBox:H,FormulateInputText:Y,FormulateInputFile:X,FormulateInputGroup:M,FormulateInputButton:tt,FormulateInputSelect:nt,FormulateInputSlider:at,FormulateInputTextArea:ut},library:t,rules:h,locale:"en",uploader:b,uploadUrl:!1,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:v}}};return ct.prototype.install=function(t,e){var r=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(r):null})),this.options.components)t.component(n,this.options.components[n])},ct.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+")")},ct.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var n={};for(var o in t)e.hasOwnProperty(o)?x(e[o])&&x(t[o])?n[o]=this.merge(t[o],e[o],r):r&&Array.isArray(t[o])&&Array.isArray(e[o])?n[o]=t[o].concat(e[o]):n[o]=e[o]:n[o]=t[o];for(var i in e)n.hasOwnProperty(i)||(n[i]=e[i]);return n},ct.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ct.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ct.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ct.prototype.validationMessage=function(t,e){var r=this.options.locales[this.options.locale];return r.hasOwnProperty(t)?r[t](e):"_"===t[0]&&r.hasOwnProperty(t.substr(1))?r[t.substr(1)](e):r.hasOwnProperty("default")?r.default(e):"This field does not have a valid value"},ct.prototype.getUploader=function(){return this.options.uploader||!1},ct.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},ct.prototype.createUpload=function(t,e){return new l(t,e,this.options)},new ct}(); diff --git a/dist/formulate.umd.js b/dist/formulate.umd.js index 0cd8027..3e76e49 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,n){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;var r={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"}},o=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var r in t)n[r]=e(r,t[r]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),r=Object.keys(e),o=n.length;if(r.length!==o)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(n){t.results=n,e(n)})).catch((function(t){throw new Error(t)}))}))},o.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},o.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)}}))},o.prototype.getFileList=function(){return this.fileList},o.prototype.getFiles=function(){return this.files},o.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 n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&o>r)},alpha:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},alphanumeric:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},before:function(t,e){var n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&oe&&r.lengthe&&r()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0!==n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},matches:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(!!n.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,n){var r=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(r)?(e=isNaN(e)?e:Number(e),r.length<=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))<=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length<=e)},mime:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(function(){if(e instanceof o)for(var t=e.getFileList(),r=0;r=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))>=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length>=e)},not:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0===n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var n=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(n)?!n.length:"string"==typeof n?!n:!("object"!=typeof n||n&&Object.keys(n).length))))},url:function(e){var n=e.value;return Promise.resolve(t(n))}},p={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be after "+n[0]+".":l(e)+" must be a later date."},alpha:function(t){return l(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return l(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be before "+n[0]+".":l(e)+" must be an earlier date."},between:function(t){var e=t.name,n=t.value,r=t.args;return isNaN(n)?l(e)+" must be between "+r[0]+" and "+r[1]+" characters long.":l(e)+" must be between "+r[0]+" and "+r[1]+"."},confirm:function(t){var e=t.name;t.args;return l(e)+" does not match."},date:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" is not a valid, please use the format "+n[0]:l(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,n=t.value;return"string"==typeof n&&n?"“"+l(n)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return l(t.name)+" is not an allowed value."},max:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You may only select "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be less than or equal to "+r[0]+".":l(e)+" must be less than or equal to "+r[0]+" characters long."},mime:function(t){var e=t.name,n=t.args;return l(e)+" must be of the the type: "+(n[0]||"No file formats allowed.")},min:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You must select at least "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be more than "+r[0]+".":l(e)+" must be more than "+r[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return l(t.name)+" must be a number."},required:function(t){return l(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function f(t,e,n,r){return new Promise((function(n,o){var i=(r.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var r=performance.now()-a,o=Math.min(100,Math.round(r/i*100));if(e(o),o>=100)return n({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var m={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,blurHandler:v.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:h.call(this,this.options),optionGroups:!!this.optionGroups&&i(this.optionGroups,(function(e,n){return h.call(t,n)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:h.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 s(this.errors).concat(s(this.error)).concat(s(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}};function h(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var n=[];for(var r in t)n.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return n}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function v(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:x.bind(this),set:b.bind(this)})}function x(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function g(t,e,n,r,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof n?n.options:n;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),r&&(d._scopeId=r),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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,c):[c]}return n}var w={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{}}}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},m,{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||a(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!a(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){a(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=u(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var n=e[0],r=e[1],o=n.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(r));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(n,r)}))}))).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,n="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[n])switch(typeof this.validationMessages[n]){case"function":return this.validationMessages[n];case"string":return function(){return e.validationMessages[n]}}return function(n){return e.$formulate.validationMessage(t.name,n)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},F=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("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}},[n("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[n("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",[n(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",[n("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?n("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?n("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};F._withStripped=!0;var _=g({render:F,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),P=function(t){this.form=t};P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,n){var r=[],i=function t(e){var n={};for(var r in e)e[r]instanceof o||c(e[r])?n[r]=e[r]:n[r]=t(e[r]);return n}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof o&&r.push(t.form.internalFormModelProxy[e].upload().then((function(t){var n;return Object.assign(i,((n={})[e]=t,n))})))};for(var s in i)a(s);Promise.all(r).then((function(){return e(i)})).catch((function(t){return n(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 n in t)!this.registry.hasOwnProperty(n)||a(t[n],this.internalFormModelProxy[n])||a(t[n],this.registry[n].internalModelProxy[n])||(this.setFieldValue(n,t[n]),this.registry[n].context.model=t[n])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var n;Object.assign(this.internalFormModelProxy,((n={})[t]=e,n)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!n&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!n&&!r||a(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},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}))}))}}},V=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)};V._withStripped=!0;var O=g({render:V,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),N={props:{errors:{type:[Boolean,Array],required:!0}}},$=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.errors.length?n("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return n("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};$._withStripped=!0;var E=g({render:$,staticRenderFns:[]},void 0,N,void 0,!1,void 0,!1,void 0,void 0,void 0);var j={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,n=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(n[r]=t[r]);return n}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(n,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},I=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return n(e.component,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)};I._withStripped=!0;var S=g({render:I,staticRenderFns:[]},void 0,j,void 0,!1,void 0,!1,void 0,void 0,void 0),C={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}}},D={name:"FormulateInputBox",mixins:[C]},k=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t.context.value,a=t._i(n,i);r.checked?a<0&&t.$set(t.context,"model",n.concat([i])):a>-1&&t.$set(t.context,"model",n.slice(0,a).concat(n.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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(" "),n("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};k._withStripped=!0;var B=g({render:k,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0),M={name:"FormulateInputText",mixins:[C]},T=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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 U=g({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),R={name:"FormulateFiles",props:{files:{type:o,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()}},L=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.fileUploads.length?n("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return n("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[n("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?n("div",{staticClass:"formulate-file-image-preview"},[n("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),n("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?n("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[n("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?n("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?n("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};L._withStripped=!0;var q={name:"FormulateInputFile",components:{FormulateFiles:g({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[C],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof o&&this.context.model.files.length)}},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 o&&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}}},H=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[n("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[n("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(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?n("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};H._withStripped=!0;var G=g({render:H,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[C]},W=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[n("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};W._withStripped=!0;var z=g({render:W,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"FormulateInputSelect",mixins:[C],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)}}},J=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("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 n=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?n:n[0])}}},"select",t.attributes,!1),[t.context.placeholder?n("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,r){return n("optgroup",{key:r,attrs:{label:r}},t._l(e,(function(e){return n("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 n("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};J._withStripped=!0;var X=g({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputSlider",mixins:[C]},Q=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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?n("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};Q._withStripped=!0;var tt=g({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputTextArea",mixins:[C]},nt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[n("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))])};nt._withStripped=!0;var rt=g({render:nt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot=function(){this.options={},this.defaults={components:{FormulateForm:O,FormulateInput:_,FormulateInputErrors:E,FormulateInputBox:B,FormulateInputText:U,FormulateInputFile:G,FormulateInputGroup:S,FormulateInputButton:z,FormulateInputSelect:X,FormulateInputSlider:tt,FormulateInputTextArea:rt},library:r,rules:d,locale:"en",uploader:f,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:p}}};return ot.prototype.install=function(t,e){var n=this;for(var r 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(n):null})),this.options.components)t.component(r,this.options.components[r])},ot.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+")")},ot.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var o={};for(var i in t)e.hasOwnProperty(i)?n(e[i])&&n(t[i])?o[i]=this.merge(t[i],e[i],r):r&&Array.isArray(t[i])&&Array.isArray(e[i])?o[i]=t[i].concat(e[i]):o[i]=e[i]:o[i]=t[i];for(var a in e)o.hasOwnProperty(a)||(o[a]=e[a]);return o},ot.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ot.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ot.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ot.prototype.validationMessage=function(t,e){var n=this.options.locales[this.options.locale];return n.hasOwnProperty(t)?n[t](e):"_"===t[0]&&n.hasOwnProperty(t.substr(1))?n[t.substr(1)](e):n.hasOwnProperty("default")?n.default(e):"This field does not have a valid value"},ot.prototype.getUploader=function(){return this.options.uploader||!1},ot.prototype.createUpload=function(t,e){return new o(t,e,this.options)},new ot})); +!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,n){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;var r={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"}},o=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var r in t)n[r]=e(r,t[r]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),r=Object.keys(e),o=n.length;if(r.length!==o)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(n){t.results=n,e(n)})).catch((function(t){throw new Error(t)}))}))},o.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},o.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)}}))},o.prototype.getFileList=function(){return this.fileList},o.prototype.getFiles=function(){return this.files},o.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 n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&o>r)},alpha:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},alphanumeric:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},before:function(t,e){var n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&oe&&r.lengthe&&r()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0!==n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},matches:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(!!n.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,n){var r=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(r)?(e=isNaN(e)?e:Number(e),r.length<=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))<=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length<=e)},mime:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(function(){if(e instanceof o)for(var t=e.getFileList(),r=0;r=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))>=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length>=e)},not:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0===n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var n=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(n)?!n.length:"string"==typeof n?!n:!("object"!=typeof n||n&&Object.keys(n).length))))},url:function(e){var n=e.value;return Promise.resolve(t(n))}},p={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be after "+n[0]+".":l(e)+" must be a later date."},alpha:function(t){return l(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return l(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be before "+n[0]+".":l(e)+" must be an earlier date."},between:function(t){var e=t.name,n=t.value,r=t.args;return isNaN(n)?l(e)+" must be between "+r[0]+" and "+r[1]+" characters long.":l(e)+" must be between "+r[0]+" and "+r[1]+"."},confirm:function(t){var e=t.name;t.args;return l(e)+" does not match."},date:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" is not a valid, please use the format "+n[0]:l(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,n=t.value;return"string"==typeof n&&n?"“"+l(n)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return l(t.name)+" is not an allowed value."},max:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You may only select "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be less than or equal to "+r[0]+".":l(e)+" must be less than or equal to "+r[0]+" characters long."},mime:function(t){var e=t.name,n=t.args;return l(e)+" must be of the the type: "+(n[0]||"No file formats allowed.")},min:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You must select at least "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be more than "+r[0]+".":l(e)+" must be more than "+r[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return l(t.name)+" must be a number."},required:function(t){return l(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function f(t,e,n,r){return new Promise((function(n,o){var i=(r.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var r=performance.now()-a,o=Math.min(100,Math.round(r/i*100));if(e(o),o>=100)return n({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var m={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,blurHandler:v.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:h.call(this,this.options),optionGroups:!!this.optionGroups&&i(this.optionGroups,(function(e,n){return h.call(t,n)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:h.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 s(this.errors).concat(s(this.error)).concat(s(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 h(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var n=[];for(var r in t)n.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return n}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function v(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:x.bind(this),set:b.bind(this)})}function x(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function g(t,e,n,r,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof n?n.options:n;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),r&&(d._scopeId=r),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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,c):[c]}return n}var w={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{}}}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},m,{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||a(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!a(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){a(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=u(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var n=e[0],r=e[1],o=n.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(r));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(n,r)}))}))).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,n="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[n])switch(typeof this.validationMessages[n]){case"function":return this.validationMessages[n];case"string":return function(){return e.validationMessages[n]}}return function(n){return e.$formulate.validationMessage(t.name,n)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},F=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("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}},[n("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[n("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",[n(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",[n("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?n("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?n("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};F._withStripped=!0;var _=g({render:F,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),P=function(t){this.form=t};P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,n){var r=[],i=function t(e){var n={};for(var r in e)e[r]instanceof o||c(e[r])?n[r]=e[r]:n[r]=t(e[r]);return n}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof o&&r.push(t.form.internalFormModelProxy[e].upload().then((function(t){var n;return Object.assign(i,((n={})[e]=t,n))})))};for(var s in i)a(s);Promise.all(r).then((function(){return e(i)})).catch((function(t){return n(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 n in t)!this.registry.hasOwnProperty(n)||a(t[n],this.internalFormModelProxy[n])||a(t[n],this.registry[n].internalModelProxy[n])||(this.setFieldValue(n,t[n]),this.registry[n].context.model=t[n])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var n;Object.assign(this.internalFormModelProxy,((n={})[t]=e,n)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!n&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!n&&!r||a(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},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}))}))}}},V=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)};V._withStripped=!0;var O=g({render:V,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,n=t._self._c||e;return t.errors.length?n("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return n("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var E=g({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);var j={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,n=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(n[r]=t[r]);return n}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(n,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},I=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return n(e.component,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)};I._withStripped=!0;var S=g({render:I,staticRenderFns:[]},void 0,j,void 0,!1,void 0,!1,void 0,void 0,void 0),C={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}}},D={name:"FormulateInputBox",mixins:[C]},k=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t.context.value,a=t._i(n,i);r.checked?a<0&&t.$set(t.context,"model",n.concat([i])):a>-1&&t.$set(t.context,"model",n.slice(0,a).concat(n.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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(" "),n("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};k._withStripped=!0;var B=g({render:k,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0),U={name:"FormulateInputText",mixins:[C]},M=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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))])};M._withStripped=!0;var T=g({render:M,staticRenderFns:[]},void 0,U,void 0,!1,void 0,!1,void 0,void 0,void 0),R={name:"FormulateFiles",props:{files:{type:o,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()}},L=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.fileUploads.length?n("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return n("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[n("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?n("div",{staticClass:"formulate-file-image-preview"},[n("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),n("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?n("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[n("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?n("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?n("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};L._withStripped=!0;var q={name:"FormulateInputFile",components:{FormulateFiles:g({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[C],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof o&&this.context.model.files.length)}},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 o&&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}}},H=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[n("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[n("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(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?n("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};H._withStripped=!0;var G=g({render:H,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[C]},W=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[n("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};W._withStripped=!0;var z=g({render:W,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"FormulateInputSelect",mixins:[C],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)}}},J=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("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 n=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?n:n[0])}}},"select",t.attributes,!1),[t.context.placeholder?n("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,r){return n("optgroup",{key:r,attrs:{label:r}},t._l(e,(function(e){return n("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 n("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};J._withStripped=!0;var X=g({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputSlider",mixins:[C]},Q=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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?n("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};Q._withStripped=!0;var tt=g({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputTextArea",mixins:[C]},nt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[n("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))])};nt._withStripped=!0;var rt=g({render:nt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot=function(){this.options={},this.defaults={components:{FormulateForm:O,FormulateInput:_,FormulateInputErrors:E,FormulateInputBox:B,FormulateInputText:T,FormulateInputFile:G,FormulateInputGroup:S,FormulateInputButton:z,FormulateInputSelect:X,FormulateInputSlider:tt,FormulateInputTextArea:rt},library:r,rules:d,locale:"en",uploader:f,uploadUrl:!1,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:p}}};return ot.prototype.install=function(t,e){var n=this;for(var r 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(n):null})),this.options.components)t.component(r,this.options.components[r])},ot.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+")")},ot.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var o={};for(var i in t)e.hasOwnProperty(i)?n(e[i])&&n(t[i])?o[i]=this.merge(t[i],e[i],r):r&&Array.isArray(t[i])&&Array.isArray(e[i])?o[i]=t[i].concat(e[i]):o[i]=e[i]:o[i]=t[i];for(var a in e)o.hasOwnProperty(a)||(o[a]=e[a]);return o},ot.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ot.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ot.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ot.prototype.validationMessage=function(t,e){var n=this.options.locales[this.options.locale];return n.hasOwnProperty(t)?n[t](e):"_"===t[0]&&n.hasOwnProperty(t.substr(1))?n[t.substr(1)](e):n.hasOwnProperty("default")?n.default(e):"This field does not have a valid value"},ot.prototype.getUploader=function(){return this.options.uploader||!1},ot.prototype.getUploadUrl=function(){return this.options.uploadUrl||!1},ot.prototype.createUpload=function(t,e){return new o(t,e,this.options)},new ot})); diff --git a/src/FileUpload.js b/src/FileUpload.js index ccc4399..0c20dd8 100644 --- a/src/FileUpload.js +++ b/src/FileUpload.js @@ -54,15 +54,18 @@ class FileUpload { } /** - * Check if the given uploader is axios instance. + * Check if the given uploader is axios instance. This isn't a great way of + * testing if it is or not, but AFIK there isn't a better way right now: + * + * https://github.com/axios/axios/issues/737 */ uploaderIsAxios () { if ( this.hasUploader && - typeof this.hasUploader.request === 'function' && - typeof this.hasUploader.get === 'function' && - typeof this.hasUploader.delete === 'function' && - typeof this.hasUploader.post === 'function' + typeof this.context.uploader.request === 'function' && + typeof this.context.uploader.get === 'function' && + typeof this.context.uploader.delete === 'function' && + typeof this.context.uploader.post === 'function' ) { return true } @@ -76,14 +79,19 @@ class FileUpload { if (this.uploaderIsAxios()) { const formData = new FormData() formData.append(this.context.name || 'file', args[0]) - return this.uploader.post(this.context.uploadUrl, formData, { + if (this.context.uploadUrl === false) { + throw new Error('No uploadURL specified: https://vueformulate.com/guide/inputs/file/#props') + } + return this.context.uploader.post(this.context.uploadUrl, formData, { headers: { 'Content-Type': 'multipart/form-data' }, onUploadProgress: progressEvent => { + // args[1] here is the upload progress handler function args[1](Math.round((progressEvent.loaded * 100) / progressEvent.total)) } }) + .then(res => res.data) .catch(err => args[2](err)) } return this.context.uploader(...args) diff --git a/src/Formulate.js b/src/Formulate.js index 41df065..0e8c253 100644 --- a/src/Formulate.js +++ b/src/Formulate.js @@ -43,6 +43,7 @@ class Formulate { rules, locale: 'en', uploader: fauxUploader, + uploadUrl: false, uploadJustCompleteDuration: 1000, plugins: [], locales: { @@ -162,6 +163,13 @@ class Formulate { return this.options.uploader || false } + /** + * Get the global upload url. + */ + getUploadUrl () { + return this.options.uploadUrl || false + } + /** * Create a new instance of an upload. */ diff --git a/src/libs/context.js b/src/libs/context.js index 30729de..b012046 100644 --- a/src/libs/context.js +++ b/src/libs/context.js @@ -21,7 +21,7 @@ export default { attributes: this.elementAttributes, blurHandler: blurHandler.bind(this), imageBehavior: this.imageBehavior, - uploadUrl: this.uploadUrl, + uploadUrl: this.mergedUploadUrl, uploader: this.uploader || this.$formulate.getUploader(), uploadBehavior: this.uploadBehavior, preventWindowDrops: this.preventWindowDrops, @@ -37,7 +37,8 @@ export default { mergedErrors, hasErrors, showFieldErrors, - mergedValidationName + mergedValidationName, + mergedUploadUrl } /** @@ -111,6 +112,14 @@ function mergedValidationName () { return this.type } +/** + * Use the uploadURL on the input if it exists, otherwise use the uploadURL + * that is defined as a plugin option. + */ +function mergedUploadUrl () { + return this.uploadUrl || this.$formulate.getUploadUrl() +} + /** * Determines if the field should show it's error (if it has one) * @return {boolean} From cf9396e0d644702d31e557f2cb1ef81cd671d9bd Mon Sep 17 00:00:00 2001 From: Justin Schroeder Date: Sun, 1 Mar 2020 22:29:54 -0500 Subject: [PATCH 2/3] Fixes issue with grouped options hydrating initial values --- dist/formulate.esm.js | 2 +- dist/formulate.min.js | 2 +- dist/formulate.umd.js | 2 +- src/FormulateForm.vue | 12 +- src/FormulateInput.vue | 34 ++++- src/FormulateInputGroup.vue | 33 ++++- src/libs/context.js | 6 +- test/FormulateForm.test.js | 28 +++- test/FormulateInputBox.test.js | 242 +++++++++++++++++++++++--------- test/FormulateInputText.test.js | 4 +- 10 files changed, 271 insertions(+), 94 deletions(-) diff --git a/dist/formulate.esm.js b/dist/formulate.esm.js index 0e03141..e1ad3d6 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 n from"is-plain-object";var r={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"}},o=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var r in t)n[r]=e(r,t[r]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),r=Object.keys(e),o=n.length;if(r.length!==o)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(n){t.results=n,e(n)})).catch((function(t){throw new Error(t)}))}))},o.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},o.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)}}))},o.prototype.getFileList=function(){return this.fileList},o.prototype.getFiles=function(){return this.files},o.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 n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&o>r)},alpha:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},alphanumeric:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},before:function(t,e){var n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&oe&&r.lengthe&&r()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0!==n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},matches:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(!!n.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,n){var r=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(r)?(e=isNaN(e)?e:Number(e),r.length<=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))<=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length<=e)},mime:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(function(){if(e instanceof o)for(var t=e.getFileList(),r=0;r=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))>=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length>=e)},not:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0===n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var n=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(n)?!n.length:"string"==typeof n?!n:!("object"!=typeof n||n&&Object.keys(n).length))))},url:function(e){var n=e.value;return Promise.resolve(t(n))}},p={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be after "+n[0]+".":l(e)+" must be a later date."},alpha:function(t){return l(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return l(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be before "+n[0]+".":l(e)+" must be an earlier date."},between:function(t){var e=t.name,n=t.value,r=t.args;return isNaN(n)?l(e)+" must be between "+r[0]+" and "+r[1]+" characters long.":l(e)+" must be between "+r[0]+" and "+r[1]+"."},confirm:function(t){var e=t.name;t.args;return l(e)+" does not match."},date:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" is not a valid, please use the format "+n[0]:l(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,n=t.value;return"string"==typeof n&&n?"“"+l(n)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return l(t.name)+" is not an allowed value."},max:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You may only select "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be less than or equal to "+r[0]+".":l(e)+" must be less than or equal to "+r[0]+" characters long."},mime:function(t){var e=t.name,n=t.args;return l(e)+" must be of the the type: "+(n[0]||"No file formats allowed.")},min:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You must select at least "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be more than "+r[0]+".":l(e)+" must be more than "+r[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return l(t.name)+" must be a number."},required:function(t){return l(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,n,r){return new Promise((function(n,o){var i=(r.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var r=performance.now()-a,o=Math.min(100,Math.round(r/i*100));if(e(o),o>=100)return n({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var f={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,blurHandler:v.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:h.call(this,this.options),optionGroups:!!this.optionGroups&&i(this.optionGroups,(function(e,n){return h.call(t,n)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:h.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 s(this.errors).concat(s(this.error)).concat(s(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}};function h(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var n=[];for(var r in t)n.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return n}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function v(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:x.bind(this),set:b.bind(this)})}function x(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function g(t,e,n,r,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof n?n.options:n;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),r&&(d._scopeId=r),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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var m=d.beforeCreate;d.beforeCreate=m?[].concat(m,c):[c]}return n}var w={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{}}}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||a(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!a(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){a(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=u(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var n=e[0],r=e[1],o=n.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(r));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(n,r)}))}))).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,n="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[n])switch(typeof this.validationMessages[n]){case"function":return this.validationMessages[n];case"string":return function(){return e.validationMessages[n]}}return function(n){return e.$formulate.validationMessage(t.name,n)}},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,n=t._self._c||e;return n("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}},[n("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[n("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",[n(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",[n("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?n("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?n("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var F=g({render:_,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),P=function(t){this.form=t};P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,n){var r=[],i=function t(e){var n={};for(var r in e)e[r]instanceof o||c(e[r])?n[r]=e[r]:n[r]=t(e[r]);return n}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof o&&r.push(t.form.internalFormModelProxy[e].upload().then((function(t){var n;return Object.assign(i,((n={})[e]=t,n))})))};for(var s in i)a(s);Promise.all(r).then((function(){return e(i)})).catch((function(t){return n(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 n in t)!this.registry.hasOwnProperty(n)||a(t[n],this.internalFormModelProxy[n])||a(t[n],this.registry[n].internalModelProxy[n])||(this.setFieldValue(n,t[n]),this.registry[n].context.model=t[n])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var n;Object.assign(this.internalFormModelProxy,((n={})[t]=e,n)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!n&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!n&&!r||a(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},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}))}))}}},V=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)};V._withStripped=!0;var N=g({render:V,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),$={props:{errors:{type:[Boolean,Array],required:!0}}},O=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.errors.length?n("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return n("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};O._withStripped=!0;var E=g({render:O,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);var I={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,n=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(n[r]=t[r]);return n}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(n,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},S=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return n(e.component,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)};S._withStripped=!0;var j=g({render:S,staticRenderFns:[]},void 0,I,void 0,!1,void 0,!1,void 0,void 0,void 0),C={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}}},D={name:"FormulateInputBox",mixins:[C]},k=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t.context.value,a=t._i(n,i);r.checked?a<0&&t.$set(t.context,"model",n.concat([i])):a>-1&&t.$set(t.context,"model",n.slice(0,a).concat(n.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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(" "),n("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};k._withStripped=!0;var B=g({render:k,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0),M={name:"FormulateInputText",mixins:[C]},T=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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 U=g({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),R={name:"FormulateFiles",props:{files:{type:o,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()}},L=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.fileUploads.length?n("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return n("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[n("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?n("div",{staticClass:"formulate-file-image-preview"},[n("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),n("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?n("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[n("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?n("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?n("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};L._withStripped=!0;var H={name:"FormulateInputFile",components:{FormulateFiles:g({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[C],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof o&&this.context.model.files.length)}},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 o&&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,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[n("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[n("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(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?n("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};q._withStripped=!0;var G=g({render:q,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[C]},W=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[n("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};W._withStripped=!0;var z=g({render:W,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"FormulateInputSelect",mixins:[C],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)}}},J=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("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 n=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?n:n[0])}}},"select",t.attributes,!1),[t.context.placeholder?n("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,r){return n("optgroup",{key:r,attrs:{label:r}},t._l(e,(function(e){return n("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 n("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};J._withStripped=!0;var X=g({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputSlider",mixins:[C]},Q=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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?n("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};Q._withStripped=!0;var tt=g({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputTextArea",mixins:[C]},nt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[n("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))])};nt._withStripped=!0;var rt=g({render:nt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot=function(){this.options={},this.defaults={components:{FormulateForm:N,FormulateInput:F,FormulateInputErrors:E,FormulateInputBox:B,FormulateInputText:U,FormulateInputFile:G,FormulateInputGroup:j,FormulateInputButton:z,FormulateInputSelect:X,FormulateInputSlider:tt,FormulateInputTextArea:rt},library:r,rules:d,locale:"en",uploader:m,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:p}}};ot.prototype.install=function(t,e){var n=this;for(var r 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(n):null})),this.options.components)t.component(r,this.options.components[r])},ot.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+")")},ot.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var o={};for(var i in t)e.hasOwnProperty(i)?n(e[i])&&n(t[i])?o[i]=this.merge(t[i],e[i],r):r&&Array.isArray(t[i])&&Array.isArray(e[i])?o[i]=t[i].concat(e[i]):o[i]=e[i]:o[i]=t[i];for(var a in e)o.hasOwnProperty(a)||(o[a]=e[a]);return o},ot.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ot.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ot.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ot.prototype.validationMessage=function(t,e){var n=this.options.locales[this.options.locale];return n.hasOwnProperty(t)?n[t](e):"_"===t[0]&&n.hasOwnProperty(t.substr(1))?n[t.substr(1)](e):n.hasOwnProperty("default")?n.default(e):"This field does not have a valid value"},ot.prototype.getUploader=function(){return this.options.uploader||!1},ot.prototype.createUpload=function(t,e){return new o(t,e,this.options)};var it=new ot;export default it; +import t from"is-url";import e from"nanoid/non-secure";import n from"is-plain-object";var o={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"}},r=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var o in t)n[o]=e(o,t[o]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),o=Object.keys(e),r=n.length;if(o.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(n){t.results=n,e(n)})).catch((function(t){throw new Error(t)}))}))},r.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){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 n=t.value;void 0===e&&(e=!1);var o=Date.parse(e||new Date),r=Date.parse(n);return Promise.resolve(!isNaN(r)&&r>o)},alpha:function(t,e){var n=t.value;void 0===e&&(e="default");var o={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},r=o.hasOwnProperty(e)?e:"default";return Promise.resolve(o[r].test(n))},alphanumeric:function(t,e){var n=t.value;void 0===e&&(e="default");var o={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},r=o.hasOwnProperty(e)?e:"default";return Promise.resolve(o[r].test(n))},before:function(t,e){var n=t.value;void 0===e&&(e=!1);var o=Date.parse(e||new Date),r=Date.parse(n);return Promise.resolve(!isNaN(r)&&re&&o.lengthe&&o()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return Promise.resolve(void 0!==n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},matches:function(t){for(var e=t.value,n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return Promise.resolve(!!n.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,n){var o=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(o)?(e=isNaN(e)?e:Number(e),o.length<=e):!isNaN(o)&&"length"!==n||"value"===n?(o=isNaN(o)?o:Number(o))<=e:("string"==typeof o||"length"===n)&&(o=isNaN(o)?o:o.toString()).length<=e)},mime:function(t){for(var e=t.value,n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFileList(),o=0;o=e):!isNaN(o)&&"length"!==n||"value"===n?(o=isNaN(o)?o:Number(o))>=e:("string"==typeof o||"length"===n)&&(o=isNaN(o)?o:o.toString()).length>=e)},not:function(t){for(var e=t.value,n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return Promise.resolve(void 0===n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var n=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(n)?!n.length:"string"==typeof n?!n:!("object"!=typeof n||n&&Object.keys(n).length))))},url:function(e){var n=e.value;return Promise.resolve(t(n))}},p={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be after "+n[0]+".":l(e)+" must be a later date."},alpha:function(t){return l(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return l(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be before "+n[0]+".":l(e)+" must be an earlier date."},between:function(t){var e=t.name,n=t.value,o=t.args;return isNaN(n)?l(e)+" must be between "+o[0]+" and "+o[1]+" characters long.":l(e)+" must be between "+o[0]+" and "+o[1]+"."},confirm:function(t){var e=t.name;t.args;return l(e)+" does not match."},date:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" is not a valid, please use the format "+n[0]:l(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,n=t.value;return"string"==typeof n&&n?"“"+l(n)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return l(t.name)+" is not an allowed value."},max:function(t){var e=t.name,n=t.value,o=t.args;if(Array.isArray(n))return"You may only select "+o[0]+" "+e+".";var r=!(!Array.isArray(o)||!o[1])&&o[1];return!isNaN(n)&&"length"!==r||"value"===r?l(e)+" must be less than or equal to "+o[0]+".":l(e)+" must be less than or equal to "+o[0]+" characters long."},mime:function(t){var e=t.name,n=t.args;return l(e)+" must be of the the type: "+(n[0]||"No file formats allowed.")},min:function(t){var e=t.name,n=t.value,o=t.args;if(Array.isArray(n))return"You must select at least "+o[0]+" "+e+".";var r=!(!Array.isArray(o)||!o[1])&&o[1];return!isNaN(n)&&"length"!==r||"value"===r?l(e)+" must be more than "+o[0]+".":l(e)+" must be more than "+o[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return l(t.name)+" must be a number."},required:function(t){return l(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function m(t,e,n,o){return new Promise((function(n,r){var i=(o.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var o=performance.now()-a,r=Math.min(100,Math.round(o/i*100));if(e(r),r>=100)return n({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var f={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,blurHandler:v.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:h.call(this,this.options),optionGroups:!!this.optionGroups&&i(this.optionGroups,(function(e,n){return h.call(t,n)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:h.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 s(this.errors).concat(s(this.error)).concat(s(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}};function h(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var n=[];for(var o in t)n.push({value:o,label:t[o],id:this.elementAttributes.id+"_"+o});return n}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function v(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:x.bind(this),set:b.bind(this)})}function x(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){a(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function g(t,e,n,o,r,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof n?n.options:n;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,r&&(d.functional=!0)),o&&(d._scopeId=o),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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var m=d.beforeCreate;d.beforeCreate=m?[].concat(m,c):[c]}return n}var w={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({},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)}}),watch:{$attrs:{handler:function(t){this.updateLocalAttributes(t)},deep:!0},internalModelProxy:function(t,e){this.performValidation(),this.isVmodeled||a(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!a(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(){!a(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){a(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=u(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var n=e[0],o=e[1],r=n.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(o));return(r=r instanceof Promise?r:Promise.resolve(r)).then((function(e){return!e&&t.getValidationMessage(n,o)}))}))).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,n="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[n])switch(typeof this.validationMessages[n]){case"function":return this.validationMessages[n];case"string":return function(){return e.validationMessages[n]}}return function(n){return e.$formulate.validationMessage(t.name,n)}},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,n=t._self._c||e;return n("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}},[n("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[n("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",[n(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",[n("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?n("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?n("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};_._withStripped=!0;var F=g({render:_,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),P=function(t){this.form=t};P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,n){var o=[],i=function t(e){var n={};for(var o in e)e[o]instanceof r||c(e[o])?n[o]=e[o]:n[o]=t(e[o]);return n}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&o.push(t.form.internalFormModelProxy[e].upload().then((function(t){var n;return Object.assign(i,((n={})[e]=t,n))})))};for(var s in i)a(s);Promise.all(o).then((function(){return e(i)})).catch((function(t){return n(t)}))}))};var V={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 n in t)!this.registry.hasOwnProperty(n)||a(t[n],this.internalFormModelProxy[n])||a(t[n],this.registry[n].internalModelProxy[n])||(this.setFieldValue(n,t[n]),this.registry[n].context.model=t[n])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var n;Object.assign(this.internalFormModelProxy,((n={})[t]=e,n)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!n&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!n&&!o||a(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},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}))}))}}},A=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)};A._withStripped=!0;var $=g({render:A,staticRenderFns:[]},void 0,V,void 0,!1,void 0,!1,void 0,void 0,void 0),O={props:{errors:{type:[Boolean,Array],required:!0}}},N=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.errors.length?n("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return n("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var E=g({render:N,staticRenderFns:[]},void 0,O,void 0,!1,void 0,!1,void 0,void 0,void 0);function I(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&-1===e.indexOf(o)&&(n[o]=t[o]);return n}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,n=(e.options,e.labelPosition,e.attributes),o=(n.id,I(n,["id"])),r=(e.classification,e.blurHandler,e.hasValidationErrors,e.component,e.hasLabel,I(e,["options","labelPosition","attributes","classification","blurHandler","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(r,e,o)}))}},methods:{groupItemContext:function(t,e,n){return Object.assign({},t,e,n,{})}}},j=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return n(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)};j._withStripped=!0;var C=g({render:j,staticRenderFns:[]},void 0,S,void 0,!1,void 0,!1,void 0,void 0,void 0),D={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:[D]},B=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,o=e.target,r=!!o.checked;if(Array.isArray(n)){var i=t.context.value,a=t._i(n,i);o.checked?a<0&&t.$set(t.context,"model",n.concat([i])):a>-1&&t.$set(t.context,"model",n.slice(0,a).concat(n.slice(a+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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(" "),n("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};B._withStripped=!0;var M=g({render:B,staticRenderFns:[]},void 0,k,void 0,!1,void 0,!1,void 0,void 0,void 0),T={name:"FormulateInputText",mixins:[D]},U=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,o=e.target,r=!!o.checked;if(Array.isArray(n)){var i=t._i(n,null);o.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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))])};U._withStripped=!0;var R=g({render:U,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0),L={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,n=t._self._c||e;return t.fileUploads.length?n("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return n("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[n("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?n("div",{staticClass:"formulate-file-image-preview"},[n("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),n("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?n("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[n("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?n("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?n("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:g({render:H,staticRenderFns:[]},void 0,L,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[D],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},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,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[n("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[n("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(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?n("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};G._withStripped=!0;var Y=g({render:G,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateInputButton",mixins:[D]},z=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[n("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 Z=g({render:z,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"FormulateInputSelect",mixins:[D],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,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("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 n=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?n:n[0])}}},"select",t.attributes,!1),[t.context.placeholder?n("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,o){return n("optgroup",{key:o,attrs:{label:o}},t._l(e,(function(e){return n("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 n("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};X._withStripped=!0;var K=g({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),Q={name:"FormulateInputSlider",mixins:[D]},tt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,o=e.target,r=!!o.checked;if(Array.isArray(n)){var i=t._i(n,null);o.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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?n("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};tt._withStripped=!0;var et=g({render:tt,staticRenderFns:[]},void 0,Q,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputTextArea",mixins:[D]},ot=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[n("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))])};ot._withStripped=!0;var rt=g({render:ot,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),it=function(){this.options={},this.defaults={components:{FormulateForm:$,FormulateInput:F,FormulateInputErrors:E,FormulateInputBox:M,FormulateInputText:R,FormulateInputFile:Y,FormulateInputGroup:C,FormulateInputButton:Z,FormulateInputSelect:K,FormulateInputSlider:et,FormulateInputTextArea:rt},library:o,rules:d,locale:"en",uploader:m,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:p}}};it.prototype.install=function(t,e){var n=this;for(var o 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(n):null})),this.options.components)t.component(o,this.options.components[o])},it.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+")")},it.prototype.merge=function(t,e,o){void 0===o&&(o=!0);var r={};for(var i in t)e.hasOwnProperty(i)?n(e[i])&&n(t[i])?r[i]=this.merge(t[i],e[i],o):o&&Array.isArray(t[i])&&Array.isArray(e[i])?r[i]=t[i].concat(e[i]):r[i]=e[i]:r[i]=t[i];for(var a in e)r.hasOwnProperty(a)||(r[a]=e[a]);return r},it.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},it.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},it.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},it.prototype.validationMessage=function(t,e){var n=this.options.locales[this.options.locale];return n.hasOwnProperty(t)?n[t](e):"_"===t[0]&&n.hasOwnProperty(t.substr(1))?n[t.substr(1)](e):n.hasOwnProperty("default")?n.default(e):"This field does not have a valid value"},it.prototype.getUploader=function(){return this.options.uploader||!1},it.prototype.createUpload=function(t,e){return new r(t,e,this.options)};var at=new it;export default at; diff --git a/dist/formulate.min.js b/dist/formulate.min.js index 7c19bd6..ba9f89d 100644 --- a/dist/formulate.min.js +++ b/dist/formulate.min.js @@ -12,4 +12,4 @@ function y(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 x(t){var e,r;return!1!==y(t)&&("function"==typeof(e=t.constructor)&&(!1!==y(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}function b(t,e,r,n){return new Promise((function(r,o){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,o=Math.min(100,Math.round(n/i*100));if(e(o),o>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var g={context:function(){return F.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,blurHandler:_.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:w.call(this,this.options),optionGroups:!!this.optionGroups&&u(this.optionGroups,(function(e,r){return w.call(t,r)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:w.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}};function w(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var r in t)e.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return e}return 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 F(t){return Object.defineProperty(t,"model",{get:P.bind(this),set:A.bind(this)})}function P(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function A(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function V(t,e,r,n,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof r?r.options:r;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),n&&(d._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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,c):[c]}return r}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{}}}},data:function(){return{defaultId:s(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},g,{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||c(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!c(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){c(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=f(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var r=e[0],n=e[1],o=r.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(r,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,r="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[r])switch(typeof this.validationMessages[r]){case"function":return this.validationMessages[r];case"string":return function(){return e.validationMessages[r]}}return function(r){return e.$formulate.validationMessage(t.name,r)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},O=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("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}},[r("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[r("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",[r(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",[r("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?r("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?r("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};O._withStripped=!0;var N=V({render:O,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0),S=function(t){this.form=t};S.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},S.prototype.values=function(){var t=this;return new Promise((function(e,r){var n=[],o=function t(e){var r={};for(var n in e)e[n]instanceof l||m(e[n])?r[n]=e[n]:r[n]=t(e[n]);return r}(t.form.internalFormModelProxy),i=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof l&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var r;return Object.assign(o,((r={})[e]=t,r))})))};for(var a in o)i(a);Promise.all(n).then((function(){return e(o)})).catch((function(t){return r(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 r in t)!this.registry.hasOwnProperty(r)||c(t[r],this.internalFormModelProxy[r])||c(t[r],this.registry[r].internalModelProxy[r])||(this.setFieldValue(r,t[r]),this.registry[r].context.model=t[r])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var r;Object.assign(this.internalFormModelProxy,((r={})[t]=e,r)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!r&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!r&&!n||c(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new S(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 I=V({render:j,staticRenderFns:[]},void 0,E,void 0,!1,void 0,!1,void 0,void 0,void 0),C={props:{errors:{type:[Boolean,Array],required:!0}}},D=function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.errors.length?r("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return r("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};D._withStripped=!0;var k=V({render:D,staticRenderFns:[]},void 0,C,void 0,!1,void 0,!1,void 0,void 0,void 0);var B={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,r=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(r[n]=t[n]);return r}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(r,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},M=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return r(e.component,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)};M._withStripped=!0;var T=V({render:M,staticRenderFns:[]},void 0,B,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}}},R={name:"FormulateInputBox",mixins:[U]},L=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t.context.value,a=t._i(r,i);n.checked?a<0&&t.$set(t.context,"model",r.concat([i])):a>-1&&t.$set(t.context,"model",r.slice(0,a).concat(r.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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(" "),r("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};L._withStripped=!0;var H=V({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0),q={name:"FormulateInputText",mixins:[U]},G=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&t.$set(t.context,"model",r.concat([null])):i>-1&&t.$set(t.context,"model",r.slice(0,i).concat(r.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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=V({render:G,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateFiles",props:{files:{type:l,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,r=t._self._c||e;return t.fileUploads.length?r("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return r("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[r("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?r("div",{staticClass:"formulate-file-image-preview"},[r("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),r("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?r("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[r("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?r("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?r("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};z._withStripped=!0;var Z={name:"FormulateInputFile",components:{FormulateFiles:V({render:z,staticRenderFns:[]},void 0,W,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 l&&this.context.model.files.length)}},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 l&&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}}},J=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[r("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[r("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(" "),r("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?r("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};J._withStripped=!0;var X=V({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputButton",mixins:[U]},Q=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[r("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[r("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};Q._withStripped=!0;var tt=V({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={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)}}},rt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[r("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 r=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?r:r[0])}}},"select",t.attributes,!1),[t.context.placeholder?r("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 r("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return r("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 r("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};rt._withStripped=!0;var nt=V({render:rt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot={name:"FormulateInputSlider",mixins:[U]},it=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&t.$set(t.context,"model",r.concat([null])):i>-1&&t.$set(t.context,"model",r.slice(0,i).concat(r.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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?r("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};it._withStripped=!0;var at=V({render:it,staticRenderFns:[]},void 0,ot,void 0,!1,void 0,!1,void 0,void 0,void 0),st={name:"FormulateInputTextArea",mixins:[U]},lt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[r("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))])};lt._withStripped=!0;var ut=V({render:lt,staticRenderFns:[]},void 0,st,void 0,!1,void 0,!1,void 0,void 0,void 0),ct=function(){this.options={},this.defaults={components:{FormulateForm:I,FormulateInput:N,FormulateInputErrors:k,FormulateInputBox:H,FormulateInputText:Y,FormulateInputFile:X,FormulateInputGroup:T,FormulateInputButton:tt,FormulateInputSelect:nt,FormulateInputSlider:at,FormulateInputTextArea:ut},library:t,rules:h,locale:"en",uploader:b,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:v}}};return ct.prototype.install=function(t,e){var r=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(r):null})),this.options.components)t.component(n,this.options.components[n])},ct.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+")")},ct.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var n={};for(var o in t)e.hasOwnProperty(o)?x(e[o])&&x(t[o])?n[o]=this.merge(t[o],e[o],r):r&&Array.isArray(t[o])&&Array.isArray(e[o])?n[o]=t[o].concat(e[o]):n[o]=e[o]:n[o]=t[o];for(var i in e)n.hasOwnProperty(i)||(n[i]=e[i]);return n},ct.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ct.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ct.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ct.prototype.validationMessage=function(t,e){var r=this.options.locales[this.options.locale];return r.hasOwnProperty(t)?r[t](e):"_"===t[0]&&r.hasOwnProperty(t.substr(1))?r[t.substr(1)](e):r.hasOwnProperty("default")?r.default(e):"This field does not have a valid value"},ct.prototype.getUploader=function(){return this.options.uploader||!1},ct.prototype.createUpload=function(t,e){return new l(t,e,this.options)},new ct}(); +var e}function x(t){var e,r;return!1!==y(t)&&("function"==typeof(e=t.constructor)&&(!1!==y(r=e.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")))}function b(t,e,r,n){return new Promise((function(r,o){var i=(n.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var n=performance.now()-a,o=Math.min(100,Math.round(n/i*100));if(e(o),o>=100)return r({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var g={context:function(){return F.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,blurHandler:_.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:w.call(this,this.options),optionGroups:!!this.optionGroups&&u(this.optionGroups,(function(e,r){return w.call(t,r)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:w.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}};function w(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var e=[];for(var r in t)e.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return e}return 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 F(t){return Object.defineProperty(t,"model",{get:P.bind(this),set:V.bind(this)})}function P(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function V(t){c(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function A(t,e,r,n,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof r?r.options:r;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),n&&(d._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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,c):[c]}return r}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({},g,{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||c(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!c(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(){!c(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){c(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=f(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var r=e[0],n=e[1],o=r.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(n));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(r,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,r="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[r])switch(typeof this.validationMessages[r]){case"function":return this.validationMessages[r];case"string":return function(){return e.validationMessages[r]}}return function(r){return e.$formulate.validationMessage(t.name,r)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},O=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("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}},[r("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[r("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",[r(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",[r("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?r("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?r("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};O._withStripped=!0;var N=A({render:O,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0),S=function(t){this.form=t};S.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},S.prototype.values=function(){var t=this;return new Promise((function(e,r){var n=[],o=function t(e){var r={};for(var n in e)e[n]instanceof l||m(e[n])?r[n]=e[n]:r[n]=t(e[n]);return r}(t.form.internalFormModelProxy),i=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof l&&n.push(t.form.internalFormModelProxy[e].upload().then((function(t){var r;return Object.assign(o,((r={})[e]=t,r))})))};for(var a in o)i(a);Promise.all(n).then((function(){return e(o)})).catch((function(t){return r(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 r in t)!this.registry.hasOwnProperty(r)||c(t[r],this.internalFormModelProxy[r])||c(t[r],this.registry[r].internalModelProxy[r])||(this.setFieldValue(r,t[r]),this.registry[r].context.model=t[r])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var r;Object.assign(this.internalFormModelProxy,((r={})[t]=e,r)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!r&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!r&&!n||c(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new S(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}))}))}}},I=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)};I._withStripped=!0;var j=A({render:I,staticRenderFns:[]},void 0,E,void 0,!1,void 0,!1,void 0,void 0,void 0),C={props:{errors:{type:[Boolean,Array],required:!0}}},D=function(){var t=this,e=t.$createElement,r=t._self._c||e;return t.errors.length?r("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return r("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};D._withStripped=!0;var k=A({render:D,staticRenderFns:[]},void 0,C,void 0,!1,void 0,!1,void 0,void 0,void 0);function B(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(r[n]=t[n]);return r}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,r=(e.options,e.labelPosition,e.attributes),n=(r.id,B(r,["id"])),o=(e.classification,e.blurHandler,e.hasValidationErrors,e.component,e.hasLabel,B(e,["options","labelPosition","attributes","classification","blurHandler","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(o,e,n)}))}},methods:{groupItemContext:function(t,e,r){return Object.assign({},t,e,r,{})}}},T=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return r(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 U=A({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}}},L={name:"FormulateInputBox",mixins:[R]},H=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t.context.value,a=t._i(r,i);n.checked?a<0&&t.$set(t.context,"model",r.concat([i])):a>-1&&t.$set(t.context,"model",r.slice(0,a).concat(r.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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(" "),r("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};H._withStripped=!0;var q=A({render:H,staticRenderFns:[]},void 0,L,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,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&t.$set(t.context,"model",r.concat([null])):i>-1&&t.$set(t.context,"model",r.slice(0,i).concat(r.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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=A({render:Y,staticRenderFns:[]},void 0,G,void 0,!1,void 0,!1,void 0,void 0,void 0),z={name:"FormulateFiles",props:{files:{type:l,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,r=t._self._c||e;return t.fileUploads.length?r("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return r("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[r("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?r("div",{staticClass:"formulate-file-image-preview"},[r("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),r("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?r("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[r("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?r("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?r("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:A({render:Z,staticRenderFns:[]},void 0,z,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 l&&this.context.model.files.length)}},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 l&&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,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[r("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[r("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(" "),r("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?r("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};X._withStripped=!0;var K=A({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),Q={name:"FormulateInputButton",mixins:[R]},tt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[r("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[r("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};tt._withStripped=!0;var et=A({render:tt,staticRenderFns:[]},void 0,Q,void 0,!1,void 0,!1,void 0,void 0,void 0),rt={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)}}},nt=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[r("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 r=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?r:r[0])}}},"select",t.attributes,!1),[t.context.placeholder?r("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 r("optgroup",{key:n,attrs:{label:n}},t._l(e,(function(e){return r("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 r("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};nt._withStripped=!0;var ot=A({render:nt,staticRenderFns:[]},void 0,rt,void 0,!1,void 0,!1,void 0,void 0,void 0),it={name:"FormulateInputSlider",mixins:[R]},at=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?r("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 r=t.context.model,n=e.target,o=!!n.checked;if(Array.isArray(r)){var i=t._i(r,null);n.checked?i<0&&t.$set(t.context,"model",r.concat([null])):i>-1&&t.$set(t.context,"model",r.slice(0,i).concat(r.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?r("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)):r("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?r("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};at._withStripped=!0;var st=A({render:at,staticRenderFns:[]},void 0,it,void 0,!1,void 0,!1,void 0,void 0,void 0),lt={name:"FormulateInputTextArea",mixins:[R]},ut=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[r("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))])};ut._withStripped=!0;var ct=A({render:ut,staticRenderFns:[]},void 0,lt,void 0,!1,void 0,!1,void 0,void 0,void 0),dt=function(){this.options={},this.defaults={components:{FormulateForm:j,FormulateInput:N,FormulateInputErrors:k,FormulateInputBox:q,FormulateInputText:W,FormulateInputFile:K,FormulateInputGroup:U,FormulateInputButton:et,FormulateInputSelect:ot,FormulateInputSlider:st,FormulateInputTextArea:ct},library:t,rules:h,locale:"en",uploader:b,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:v}}};return dt.prototype.install=function(t,e){var r=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(r):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,r){void 0===r&&(r=!0);var n={};for(var o in t)e.hasOwnProperty(o)?x(e[o])&&x(t[o])?n[o]=this.merge(t[o],e[o],r):r&&Array.isArray(t[o])&&Array.isArray(e[o])?n[o]=t[o].concat(e[o]):n[o]=e[o]:n[o]=t[o];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 r=this.options.locales[this.options.locale];return r.hasOwnProperty(t)?r[t](e):"_"===t[0]&&r.hasOwnProperty(t.substr(1))?r[t.substr(1)](e):r.hasOwnProperty("default")?r.default(e):"This field does not have a valid value"},dt.prototype.getUploader=function(){return this.options.uploader||!1},dt.prototype.createUpload=function(t,e){return new l(t,e,this.options)},new dt}(); diff --git a/dist/formulate.umd.js b/dist/formulate.umd.js index 0cd8027..6cf38f2 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,n){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;var r={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"}},o=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var r in t)n[r]=e(r,t[r]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),r=Object.keys(e),o=n.length;if(r.length!==o)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(n){t.results=n,e(n)})).catch((function(t){throw new Error(t)}))}))},o.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){var e=new DataTransfer;this.files.map((function(t){return e.items.add(t.file)})),this.fileList=e.files,this.input.files=this.fileList}},o.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)}}))},o.prototype.getFileList=function(){return this.fileList},o.prototype.getFiles=function(){return this.files},o.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 n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&o>r)},alpha:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},alphanumeric:function(t,e){var n=t.value;void 0===e&&(e="default");var r={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},o=r.hasOwnProperty(e)?e:"default";return Promise.resolve(r[o].test(n))},before:function(t,e){var n=t.value;void 0===e&&(e=!1);var r=Date.parse(e||new Date),o=Date.parse(n);return Promise.resolve(!isNaN(o)&&oe&&r.lengthe&&r()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0!==n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},matches:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(!!n.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,n){var r=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(r)?(e=isNaN(e)?e:Number(e),r.length<=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))<=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length<=e)},mime:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(function(){if(e instanceof o)for(var t=e.getFileList(),r=0;r=e):!isNaN(r)&&"length"!==n||"value"===n?(r=isNaN(r)?r:Number(r))>=e:("string"==typeof r||"length"===n)&&(r=isNaN(r)?r:r.toString()).length>=e)},not:function(t){for(var e=t.value,n=[],r=arguments.length-1;r-- >0;)n[r]=arguments[r+1];return Promise.resolve(void 0===n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var n=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(n)?!n.length:"string"==typeof n?!n:!("object"!=typeof n||n&&Object.keys(n).length))))},url:function(e){var n=e.value;return Promise.resolve(t(n))}},p={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be after "+n[0]+".":l(e)+" must be a later date."},alpha:function(t){return l(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return l(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be before "+n[0]+".":l(e)+" must be an earlier date."},between:function(t){var e=t.name,n=t.value,r=t.args;return isNaN(n)?l(e)+" must be between "+r[0]+" and "+r[1]+" characters long.":l(e)+" must be between "+r[0]+" and "+r[1]+"."},confirm:function(t){var e=t.name;t.args;return l(e)+" does not match."},date:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" is not a valid, please use the format "+n[0]:l(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,n=t.value;return"string"==typeof n&&n?"“"+l(n)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return l(t.name)+" is not an allowed value."},max:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You may only select "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be less than or equal to "+r[0]+".":l(e)+" must be less than or equal to "+r[0]+" characters long."},mime:function(t){var e=t.name,n=t.args;return l(e)+" must be of the the type: "+(n[0]||"No file formats allowed.")},min:function(t){var e=t.name,n=t.value,r=t.args;if(Array.isArray(n))return"You must select at least "+r[0]+" "+e+".";var o=!(!Array.isArray(r)||!r[1])&&r[1];return!isNaN(n)&&"length"!==o||"value"===o?l(e)+" must be more than "+r[0]+".":l(e)+" must be more than "+r[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return l(t.name)+" must be a number."},required:function(t){return l(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function f(t,e,n,r){return new Promise((function(n,o){var i=(r.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var r=performance.now()-a,o=Math.min(100,Math.round(r/i*100));if(e(o),o>=100)return n({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var m={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,blurHandler:v.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:h.call(this,this.options),optionGroups:!!this.optionGroups&&i(this.optionGroups,(function(e,n){return h.call(t,n)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:h.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 s(this.errors).concat(s(this.error)).concat(s(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}};function h(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var n=[];for(var r in t)n.push({value:r,label:t[r],id:this.elementAttributes.id+"_"+r});return n}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function v(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:x.bind(this),set:b.bind(this)})}function x(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){this.internalModelProxy=t,this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function g(t,e,n,r,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof n?n.options:n;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,o&&(d.functional=!0)),r&&(d._scopeId=r),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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,c):[c]}return n}var w={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{}}}},data:function(){return{defaultId:e(9),localAttributes:{},internalModelProxy:this.formulateValue||this.value,behavioralErrorVisibility:"live"===this.errorBehavior,formShouldShowErrors:!1,validationErrors:[],pendingValidation:Promise.resolve()}},computed:Object.assign({},m,{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||a(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!a(t,e)&&(this.context.model=t)}},created:function(){this.formulateFormRegister&&"function"==typeof this.formulateFormRegister&&this.formulateFormRegister(this.nameOrFallback,this),this.updateLocalAttributes(this.$attrs),this.performValidation()},methods:{updateLocalAttributes:function(t){a(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=u(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var n=e[0],r=e[1],o=n.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(r));return(o=o instanceof Promise?o:Promise.resolve(o)).then((function(e){return!e&&t.getValidationMessage(n,r)}))}))).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,n="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[n])switch(typeof this.validationMessages[n]){case"function":return this.validationMessages[n];case"string":return function(){return e.validationMessages[n]}}return function(n){return e.$formulate.validationMessage(t.name,n)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},F=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("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}},[n("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[n("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",[n(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",[n("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?n("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?n("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};F._withStripped=!0;var _=g({render:F,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),P=function(t){this.form=t};P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,n){var r=[],i=function t(e){var n={};for(var r in e)e[r]instanceof o||c(e[r])?n[r]=e[r]:n[r]=t(e[r]);return n}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof o&&r.push(t.form.internalFormModelProxy[e].upload().then((function(t){var n;return Object.assign(i,((n={})[e]=t,n))})))};for(var s in i)a(s);Promise.all(r).then((function(){return e(i)})).catch((function(t){return n(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 n in t)!this.registry.hasOwnProperty(n)||a(t[n],this.internalFormModelProxy[n])||a(t[n],this.registry[n].internalModelProxy[n])||(this.setFieldValue(n,t[n]),this.registry[n].context.model=t[n])},deep:!0,immediate:!1}},created:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},methods:{setFieldValue:function(t,e){var n;Object.assign(this.internalFormModelProxy,((n={})[t]=e,n)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),r=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!n&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!n&&!r||a(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},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}))}))}}},V=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)};V._withStripped=!0;var O=g({render:V,staticRenderFns:[]},void 0,A,void 0,!1,void 0,!1,void 0,void 0,void 0),N={props:{errors:{type:[Boolean,Array],required:!0}}},$=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.errors.length?n("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return n("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};$._withStripped=!0;var E=g({render:$,staticRenderFns:[]},void 0,N,void 0,!1,void 0,!1,void 0,void 0,void 0);var j={name:"FormulateInputGroup",props:{context:{type:Object,required:!0}},computed:{options:function(){return this.context.options||[]},optionsWithContext:function(){var t=this,e=this.context,n=(e.options,e.labelPosition,e.attributes,e.classification,function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&-1===e.indexOf(r)&&(n[r]=t[r]);return n}(e,["options","labelPosition","attributes","classification"]));return this.options.map((function(e){return t.groupItemContext(n,e)}))}},methods:{groupItemContext:function(){for(var t=[],e=arguments.length;e--;)t[e]=arguments[e];return Object.assign.apply(Object,[{}].concat(t,[{component:"FormulateInput"}]))}}},I=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return n(e.component,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)};I._withStripped=!0;var S=g({render:I,staticRenderFns:[]},void 0,j,void 0,!1,void 0,!1,void 0,void 0,void 0),C={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}}},D={name:"FormulateInputBox",mixins:[C]},k=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t.context.value,a=t._i(n,i);r.checked?a<0&&t.$set(t.context,"model",n.concat([i])):a>-1&&t.$set(t.context,"model",n.slice(0,a).concat(n.slice(a+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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(" "),n("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};k._withStripped=!0;var B=g({render:k,staticRenderFns:[]},void 0,D,void 0,!1,void 0,!1,void 0,void 0,void 0),M={name:"FormulateInputText",mixins:[C]},T=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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 U=g({render:T,staticRenderFns:[]},void 0,M,void 0,!1,void 0,!1,void 0,void 0,void 0),R={name:"FormulateFiles",props:{files:{type:o,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()}},L=function(){var t=this,e=t.$createElement,n=t._self._c||e;return t.fileUploads.length?n("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return n("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[n("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?n("div",{staticClass:"formulate-file-image-preview"},[n("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),n("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?n("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[n("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?n("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?n("div",{staticClass:"formulate-file-upload-error",domProps:{textContent:t._s(e.error)}}):t._e()])})),0):t._e()};L._withStripped=!0;var q={name:"FormulateInputFile",components:{FormulateFiles:g({render:L,staticRenderFns:[]},void 0,R,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[C],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof o&&this.context.model.files.length)}},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 o&&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}}},H=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[n("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[n("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(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?n("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};H._withStripped=!0;var G=g({render:H,staticRenderFns:[]},void 0,q,void 0,!1,void 0,!1,void 0,void 0,void 0),Y={name:"FormulateInputButton",mixins:[C]},W=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[n("span",{class:"formulate-input-element--"+t.context.type+"--label",domProps:{textContent:t._s(t.context.value||t.context.label||t.context.name||"Submit")}})])],2)])};W._withStripped=!0;var z=g({render:W,staticRenderFns:[]},void 0,Y,void 0,!1,void 0,!1,void 0,void 0,void 0),Z={name:"FormulateInputSelect",mixins:[C],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)}}},J=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("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 n=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?n:n[0])}}},"select",t.attributes,!1),[t.context.placeholder?n("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,r){return n("optgroup",{key:r,attrs:{label:r}},t._l(e,(function(e){return n("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 n("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};J._withStripped=!0;var X=g({render:J,staticRenderFns:[]},void 0,Z,void 0,!1,void 0,!1,void 0,void 0,void 0),K={name:"FormulateInputSlider",mixins:[C]},Q=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,r=e.target,o=!!r.checked;if(Array.isArray(n)){var i=t._i(n,null);r.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",o)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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?n("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};Q._withStripped=!0;var tt=g({render:Q,staticRenderFns:[]},void 0,K,void 0,!1,void 0,!1,void 0,void 0,void 0),et={name:"FormulateInputTextArea",mixins:[C]},nt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[n("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))])};nt._withStripped=!0;var rt=g({render:nt,staticRenderFns:[]},void 0,et,void 0,!1,void 0,!1,void 0,void 0,void 0),ot=function(){this.options={},this.defaults={components:{FormulateForm:O,FormulateInput:_,FormulateInputErrors:E,FormulateInputBox:B,FormulateInputText:U,FormulateInputFile:G,FormulateInputGroup:S,FormulateInputButton:z,FormulateInputSelect:X,FormulateInputSlider:tt,FormulateInputTextArea:rt},library:r,rules:d,locale:"en",uploader:f,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:p}}};return ot.prototype.install=function(t,e){var n=this;for(var r 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(n):null})),this.options.components)t.component(r,this.options.components[r])},ot.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+")")},ot.prototype.merge=function(t,e,r){void 0===r&&(r=!0);var o={};for(var i in t)e.hasOwnProperty(i)?n(e[i])&&n(t[i])?o[i]=this.merge(t[i],e[i],r):r&&Array.isArray(t[i])&&Array.isArray(e[i])?o[i]=t[i].concat(e[i]):o[i]=e[i]:o[i]=t[i];for(var a in e)o.hasOwnProperty(a)||(o[a]=e[a]);return o},ot.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},ot.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},ot.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},ot.prototype.validationMessage=function(t,e){var n=this.options.locales[this.options.locale];return n.hasOwnProperty(t)?n[t](e):"_"===t[0]&&n.hasOwnProperty(t.substr(1))?n[t.substr(1)](e):n.hasOwnProperty("default")?n.default(e):"This field does not have a valid value"},ot.prototype.getUploader=function(){return this.options.uploader||!1},ot.prototype.createUpload=function(t,e){return new o(t,e,this.options)},new ot})); +!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,n){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;var o={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"}},r=function(t,e,n){this.input=t,this.fileList=t.files,this.files=[],this.options=n,this.addFileList(this.fileList),this.context=e,this.results=!1};function i(t,e){var n={};for(var o in t)n[o]=e(o,t[o]);return n}function a(t,e){if(t===e)return!0;if(!t||!e)return!1;var n=Object.keys(t),o=Object.keys(e),r=n.length;if(o.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(n){t.results=n,e(n)})).catch((function(t){throw new Error(t)}))}))},r.prototype.removeFile=function(t){if(this.files=this.files.filter((function(e){return e.uuid!==t})),window){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 n=t.value;void 0===e&&(e=!1);var o=Date.parse(e||new Date),r=Date.parse(n);return Promise.resolve(!isNaN(r)&&r>o)},alpha:function(t,e){var n=t.value;void 0===e&&(e="default");var o={default:/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z]+$/},r=o.hasOwnProperty(e)?e:"default";return Promise.resolve(o[r].test(n))},alphanumeric:function(t,e){var n=t.value;void 0===e&&(e="default");var o={default:/^[a-zA-Z0-9À-ÖØ-öø-ÿ]+$/,latin:/^[a-zA-Z0-9]+$/},r=o.hasOwnProperty(e)?e:"default";return Promise.resolve(o[r].test(n))},before:function(t,e){var n=t.value;void 0===e&&(e=!1);var o=Date.parse(e||new Date),r=Date.parse(n);return Promise.resolve(!isNaN(r)&&re&&o.lengthe&&o()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(e))},in:function(t){for(var e=t.value,n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return Promise.resolve(void 0!==n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},matches:function(t){for(var e=t.value,n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return Promise.resolve(!!n.find((function(t){return t instanceof RegExp?t.test(e):t===e})))},max:function(t,e,n){var o=t.value;return void 0===e&&(e=10),Promise.resolve(Array.isArray(o)?(e=isNaN(e)?e:Number(e),o.length<=e):!isNaN(o)&&"length"!==n||"value"===n?(o=isNaN(o)?o:Number(o))<=e:("string"==typeof o||"length"===n)&&(o=isNaN(o)?o:o.toString()).length<=e)},mime:function(t){for(var e=t.value,n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return Promise.resolve(function(){if(e instanceof r)for(var t=e.getFileList(),o=0;o=e):!isNaN(o)&&"length"!==n||"value"===n?(o=isNaN(o)?o:Number(o))>=e:("string"==typeof o||"length"===n)&&(o=isNaN(o)?o:o.toString()).length>=e)},not:function(t){for(var e=t.value,n=[],o=arguments.length-1;o-- >0;)n[o]=arguments[o+1];return Promise.resolve(void 0===n.find((function(t){return"object"==typeof t?a(t,e):t===e})))},number:function(t){var e=t.value;return Promise.resolve(!isNaN(e))},required:function(t,e){var n=t.value;return void 0===e&&(e=!0),Promise.resolve(!(e&&!["no","false"].includes(e)&&(Array.isArray(n)?!n.length:"string"==typeof n?!n:!("object"!=typeof n||n&&Object.keys(n).length))))},url:function(e){var n=e.value;return Promise.resolve(t(n))}},p={accepted:function(t){return"Please accept the "+t.name+"."},after:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be after "+n[0]+".":l(e)+" must be a later date."},alpha:function(t){return l(t.name)+" can only contain alphabetical characters."},alphanumeric:function(t){return l(t.name)+" can only contain letters and numbers."},before:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" must be before "+n[0]+".":l(e)+" must be an earlier date."},between:function(t){var e=t.name,n=t.value,o=t.args;return isNaN(n)?l(e)+" must be between "+o[0]+" and "+o[1]+" characters long.":l(e)+" must be between "+o[0]+" and "+o[1]+"."},confirm:function(t){var e=t.name;t.args;return l(e)+" does not match."},date:function(t){var e=t.name,n=t.args;return Array.isArray(n)&&n.length?l(e)+" is not a valid, please use the format "+n[0]:l(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,n=t.value;return"string"==typeof n&&n?"“"+l(n)+"” is not an allowed "+e+".":"This is not an allowed "+e+"."},matches:function(t){return l(t.name)+" is not an allowed value."},max:function(t){var e=t.name,n=t.value,o=t.args;if(Array.isArray(n))return"You may only select "+o[0]+" "+e+".";var r=!(!Array.isArray(o)||!o[1])&&o[1];return!isNaN(n)&&"length"!==r||"value"===r?l(e)+" must be less than or equal to "+o[0]+".":l(e)+" must be less than or equal to "+o[0]+" characters long."},mime:function(t){var e=t.name,n=t.args;return l(e)+" must be of the the type: "+(n[0]||"No file formats allowed.")},min:function(t){var e=t.name,n=t.value,o=t.args;if(Array.isArray(n))return"You must select at least "+o[0]+" "+e+".";var r=!(!Array.isArray(o)||!o[1])&&o[1];return!isNaN(n)&&"length"!==r||"value"===r?l(e)+" must be more than "+o[0]+".":l(e)+" must be more than "+o[0]+" characters long."},not:function(t){var e=t.name;return"“"+t.value+"” is not an allowed "+e+"."},number:function(t){return l(t.name)+" must be a number."},required:function(t){return l(t.name)+" is required."},url:function(t){t.name;return"Please include a valid url."}};function f(t,e,n,o){return new Promise((function(n,r){var i=(o.fauxUploaderDuration||2e3)*(.5+Math.random()),a=performance.now(),s=function(){return setTimeout((function(){var o=performance.now()-a,r=Math.min(100,Math.round(o/i*100));if(e(r),r>=100)return n({url:"http://via.placeholder.com/350x150.png",name:t.name});s()}),20)};s()}))}var m={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,blurHandler:v.bind(this),imageBehavior:this.imageBehavior,uploadUrl:this.uploadUrl,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:h.call(this,this.options),optionGroups:!!this.optionGroups&&i(this.optionGroups,(function(e,n){return h.call(t,n)})),placeholder:this.$attrs.placeholder||!1};case"slider":return{showValue:!!this.showValue};default:return this.options?{options:h.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 s(this.errors).concat(s(this.error)).concat(s(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}};function h(t){if(!Array.isArray(t)&&t&&"object"==typeof t){var n=[];for(var o in t)n.push({value:o,label:t[o],id:this.elementAttributes.id+"_"+o});return n}return Array.isArray(t)&&!t.length?[{value:this.value,label:this.label||this.name,id:this.context.id||e(9)}]:t}function v(){"blur"===this.errorBehavior&&(this.behavioralErrorVisibility=!0)}function y(t){return Object.defineProperty(t,"model",{get:x.bind(this),set:b.bind(this)})}function x(){var t=this.isVmodeled?"formulateValue":"internalModelProxy";return"checkbox"===this.type&&!Array.isArray(this[t])&&this.options?[]:this[t]?this[t]:""}function b(t){a(t,this.internalModelProxy)||(this.internalModelProxy=t),this.$emit("input",t),this.context.name&&"function"==typeof this.formulateFormSetter&&this.formulateFormSetter(this.context.name,t)}function g(t,e,n,o,r,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);var c,d="function"==typeof n?n.options:n;if(t&&t.render&&(d.render=t.render,d.staticRenderFns=t.staticRenderFns,d._compiled=!0,r&&(d.functional=!0)),o&&(d._scopeId=o),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)},d._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(d.functional){var p=d.render;d.render=function(t,e){return c.call(e),p(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,c):[c]}return n}var w={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({},m,{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||a(t,e)||(this.context.model=t)},formulateValue:function(t,e){this.isVmodeled&&!a(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(){!a(this.context.model,this.internalModelProxy)&&Object.prototype.hasOwnProperty(this.$options.propsData,"options")&&"box"===this.classification&&(this.context.model=this.internalModelProxy)},updateLocalAttributes:function(t){a(t,this.localAttributes)||(this.localAttributes=t)},performValidation:function(){var t=this,e=u(this.validation,this.$formulate.rules(this.validationRules));return this.pendingValidation=Promise.all(e.map((function(e){var n=e[0],o=e[1],r=n.apply(void 0,[{value:t.context.model,getFormValues:t.getFormValues.bind(t),name:t.context.name}].concat(o));return(r=r instanceof Promise?r:Promise.resolve(r)).then((function(e){return!e&&t.getValidationMessage(n,o)}))}))).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,n="_"===t.name.substr(0,1)?t.name.substr(1):t.name;if(this.validationMessages&&"object"==typeof this.validationMessages&&void 0!==this.validationMessages[n])switch(typeof this.validationMessages[n]){case"function":return this.validationMessages[n];case"string":return function(){return e.validationMessages[n]}}return function(n){return e.$formulate.validationMessage(t.name,n)}},hasValidationErrors:function(){var t=this;return new Promise((function(e){t.$nextTick((function(){t.pendingValidation.then((function(){return e(!!t.validationErrors.length)}))}))}))}}},F=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("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}},[n("div",{staticClass:"formulate-input-wrapper"},[t.context.hasLabel&&"before"===t.context.labelPosition?t._t("label",[n("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",[n(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",[n("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?n("div",{staticClass:"formulate-input-help",domProps:{textContent:t._s(t.help)}}):t._e(),t._v(" "),t.showFieldErrors?n("FormulateInputErrors",{attrs:{errors:t.mergedErrors}}):t._e()],1)};F._withStripped=!0;var _=g({render:F,staticRenderFns:[]},void 0,w,void 0,!1,void 0,!1,void 0,void 0,void 0),P=function(t){this.form=t};P.prototype.hasValidationErrors=function(){return this.form.hasValidationErrors()},P.prototype.values=function(){var t=this;return new Promise((function(e,n){var o=[],i=function t(e){var n={};for(var o in e)e[o]instanceof r||c(e[o])?n[o]=e[o]:n[o]=t(e[o]);return n}(t.form.internalFormModelProxy),a=function(e){"object"==typeof t.form.internalFormModelProxy[e]&&t.form.internalFormModelProxy[e]instanceof r&&o.push(t.form.internalFormModelProxy[e].upload().then((function(t){var n;return Object.assign(i,((n={})[e]=t,n))})))};for(var s in i)a(s);Promise.all(o).then((function(){return e(i)})).catch((function(t){return n(t)}))}))};var V={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 n in t)!this.registry.hasOwnProperty(n)||a(t[n],this.internalFormModelProxy[n])||a(t[n],this.registry[n].internalModelProxy[n])||(this.setFieldValue(n,t[n]),this.registry[n].context.model=t[n])},deep:!0}},created:function(){this.applyInitialValues()},methods:{applyInitialValues:function(){this.hasInitialValue&&(this.internalFormModelProxy=this.initialValues)},setFieldValue:function(t,e){var n;Object.assign(this.internalFormModelProxy,((n={})[t]=e,n)),this.$emit("input",Object.assign({},this.internalFormModelProxy))},register:function(t,e){this.registry[t]=e;var n=Object.prototype.hasOwnProperty.call(e.$options.propsData,"formulateValue"),o=Object.prototype.hasOwnProperty.call(e.$options.propsData,"value");!n&&this.hasInitialValue&&this.initialValues[t]?e.context.model=this.initialValues[t]:!n&&!o||a(e.internalModelProxy,this.initialValues[t])||this.setFieldValue(t,e.internalModelProxy)},formSubmitted:function(){var t=this;this.showErrors();var e=new P(this);return this.$emit("submit-raw",e),e.hasValidationErrors().then((function(t){return t?void 0:e.values()})).then((function(e){if(void 0!==e)return t.$emit("submit",e),e}))},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}))}))}}},A=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)};A._withStripped=!0;var O=g({render:A,staticRenderFns:[]},void 0,V,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,n=t._self._c||e;return t.errors.length?n("ul",{staticClass:"formulate-input-errors"},t._l(t.errors,(function(e){return n("li",{key:e,staticClass:"formulate-input-error",domProps:{innerHTML:t._s(e)}})})),0):t._e()};N._withStripped=!0;var E=g({render:N,staticRenderFns:[]},void 0,$,void 0,!1,void 0,!1,void 0,void 0,void 0);function I(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&-1===e.indexOf(o)&&(n[o]=t[o]);return n}var j={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,n=(e.options,e.labelPosition,e.attributes),o=(n.id,I(n,["id"])),r=(e.classification,e.blurHandler,e.hasValidationErrors,e.component,e.hasLabel,I(e,["options","labelPosition","attributes","classification","blurHandler","hasValidationErrors","component","hasLabel"]));return this.options.map((function(e){return t.groupItemContext(r,e,o)}))}},methods:{groupItemContext:function(t,e,n){return Object.assign({},t,e,n,{})}}},S=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-group"},t._l(t.optionsWithContext,(function(e){return n(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)};S._withStripped=!0;var C=g({render:S,staticRenderFns:[]},void 0,j,void 0,!1,void 0,!1,void 0,void 0,void 0),D={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:[D]},B=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,o=e.target,r=!!o.checked;if(Array.isArray(n)){var i=t.context.value,a=t._i(n,i);o.checked?a<0&&t.$set(t.context,"model",n.concat([i])):a>-1&&t.$set(t.context,"model",n.slice(0,a).concat(n.slice(a+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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(" "),n("label",{staticClass:"formulate-input-element-decorator",attrs:{for:t.id}})])};B._withStripped=!0;var M=g({render:B,staticRenderFns:[]},void 0,k,void 0,!1,void 0,!1,void 0,void 0,void 0),T={name:"FormulateInputText",mixins:[D]},U=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,o=e.target,r=!!o.checked;if(Array.isArray(n)){var i=t._i(n,null);o.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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))])};U._withStripped=!0;var R=g({render:U,staticRenderFns:[]},void 0,T,void 0,!1,void 0,!1,void 0,void 0,void 0),L={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,n=t._self._c||e;return t.fileUploads.length?n("ul",{staticClass:"formulate-files"},t._l(t.fileUploads,(function(e){return n("li",{key:e.uuid,attrs:{"data-has-error":!!e.error,"data-has-preview":t.imagePreview&&e.previewData}},[n("div",{staticClass:"formulate-file"},[t.imagePreview&&e.previewData?n("div",{staticClass:"formulate-file-image-preview"},[n("img",{attrs:{src:e.previewData}})]):t._e(),t._v(" "),n("div",{staticClass:"formualte-file-name",domProps:{textContent:t._s(e.name)}}),t._v(" "),!1!==e.progress?n("div",{staticClass:"formulate-file-progress",attrs:{"data-just-finished":e.justFinished,"data-is-finished":!e.justFinished&&e.complete}},[n("div",{staticClass:"formulate-file-progress-inner",style:{width:e.progress+"%"}})]):t._e(),t._v(" "),e.complete&&!e.justFinished||!1===e.progress?n("div",{staticClass:"formulate-file-remove",on:{click:e.removeFile}}):t._e()]),t._v(" "),e.error?n("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:g({render:q,staticRenderFns:[]},void 0,L,void 0,!1,void 0,!1,void 0,void 0,void 0)},mixins:[D],data:function(){return{isOver:!1}},computed:{hasFiles:function(){return!!(this.context.model instanceof r&&this.context.model.files.length)}},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,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type,"data-has-files":t.hasFiles}},[n("div",{staticClass:"formulate-input-upload-area",attrs:{"data-has-files":t.hasFiles}},[n("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(" "),n("div",{directives:[{name:"show",rawName:"v-show",value:!t.hasFiles,expression:"!hasFiles"}],staticClass:"formulate-input-upload-area-mask"}),t._v(" "),t.hasFiles?n("FormulateFiles",{attrs:{files:t.context.model,"image-preview":"image"===t.context.type&&"preview"===t.context.imageBehavior}}):t._e()],1)])};G._withStripped=!0;var Y=g({render:G,staticRenderFns:[]},void 0,H,void 0,!1,void 0,!1,void 0,void 0,void 0),W={name:"FormulateInputButton",mixins:[D]},z=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("button",t._b({attrs:{type:t.type}},"button",t.attributes,!1),[t._t("default",[n("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 Z=g({render:z,staticRenderFns:[]},void 0,W,void 0,!1,void 0,!1,void 0,void 0,void 0),J={name:"FormulateInputSelect",mixins:[D],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,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},[n("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 n=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?n:n[0])}}},"select",t.attributes,!1),[t.context.placeholder?n("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,o){return n("optgroup",{key:o,attrs:{label:o}},t._l(e,(function(e){return n("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 n("option",t._b({key:e.id,domProps:{value:e.value,textContent:t._s(e.label)}},"option",e.attributes||{},!1))}))],2)])};X._withStripped=!0;var K=g({render:X,staticRenderFns:[]},void 0,J,void 0,!1,void 0,!1,void 0,void 0,void 0),Q={name:"FormulateInputSlider",mixins:[D]},tt=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{class:"formulate-input-element formulate-input-element--"+t.context.type,attrs:{"data-type":t.context.type}},["checkbox"===t.type?n("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 n=t.context.model,o=e.target,r=!!o.checked;if(Array.isArray(n)){var i=t._i(n,null);o.checked?i<0&&t.$set(t.context,"model",n.concat([null])):i>-1&&t.$set(t.context,"model",n.slice(0,i).concat(n.slice(i+1)))}else t.$set(t.context,"model",r)}}},"input",t.attributes,!1)):"radio"===t.type?n("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)):n("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?n("div",{staticClass:"formulate-input-element-range-value",domProps:{textContent:t._s(t.context.model)}}):t._e()])};tt._withStripped=!0;var et=g({render:tt,staticRenderFns:[]},void 0,Q,void 0,!1,void 0,!1,void 0,void 0,void 0),nt={name:"FormulateInputTextArea",mixins:[D]},ot=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"formulate-input-element formulate-input-element--textarea",attrs:{"data-type":"textarea"}},[n("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))])};ot._withStripped=!0;var rt=g({render:ot,staticRenderFns:[]},void 0,nt,void 0,!1,void 0,!1,void 0,void 0,void 0),it=function(){this.options={},this.defaults={components:{FormulateForm:O,FormulateInput:_,FormulateInputErrors:E,FormulateInputBox:M,FormulateInputText:R,FormulateInputFile:Y,FormulateInputGroup:C,FormulateInputButton:Z,FormulateInputSelect:K,FormulateInputSlider:et,FormulateInputTextArea:rt},library:o,rules:d,locale:"en",uploader:f,uploadJustCompleteDuration:1e3,plugins:[],locales:{en:p}}};return it.prototype.install=function(t,e){var n=this;for(var o 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(n):null})),this.options.components)t.component(o,this.options.components[o])},it.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+")")},it.prototype.merge=function(t,e,o){void 0===o&&(o=!0);var r={};for(var i in t)e.hasOwnProperty(i)?n(e[i])&&n(t[i])?r[i]=this.merge(t[i],e[i],o):o&&Array.isArray(t[i])&&Array.isArray(e[i])?r[i]=t[i].concat(e[i]):r[i]=e[i]:r[i]=t[i];for(var a in e)r.hasOwnProperty(a)||(r[a]=e[a]);return r},it.prototype.classify=function(t){return this.options.library.hasOwnProperty(t)?this.options.library[t].classification:"unknown"},it.prototype.component=function(t){return!!this.options.library.hasOwnProperty(t)&&this.options.library[t].component},it.prototype.rules=function(t){return void 0===t&&(t={}),Object.assign({},this.options.rules,t)},it.prototype.validationMessage=function(t,e){var n=this.options.locales[this.options.locale];return n.hasOwnProperty(t)?n[t](e):"_"===t[0]&&n.hasOwnProperty(t.substr(1))?n[t.substr(1)](e):n.hasOwnProperty("default")?n.default(e):"This field does not have a valid value"},it.prototype.getUploader=function(){return this.options.uploader||!1},it.prototype.createUpload=function(t,e){return new r(t,e,this.options)},new it})); diff --git a/src/FormulateForm.vue b/src/FormulateForm.vue index e08e72b..aa11416 100644 --- a/src/FormulateForm.vue +++ b/src/FormulateForm.vue @@ -92,16 +92,18 @@ export default { } } }, - deep: true, - immediate: false + deep: true } }, created () { - if (this.hasInitialValue) { - this.internalFormModelProxy = this.initialValues - } + this.applyInitialValues() }, methods: { + applyInitialValues () { + if (this.hasInitialValue) { + this.internalFormModelProxy = this.initialValues + } + }, setFieldValue (field, value) { Object.assign(this.internalFormModelProxy, { [field]: value }) this.$emit('input', Object.assign({}, this.internalFormModelProxy)) diff --git a/src/FormulateInput.vue b/src/FormulateInput.vue index 2005879..24764ec 100644 --- a/src/FormulateInput.vue +++ b/src/FormulateInput.vue @@ -173,16 +173,17 @@ export default { validationRules: { type: Object, default: () => ({}) + }, + checked: { + type: [String, Boolean], + default: false } }, data () { return { - /** - * @todo consider swapping out nanoid for this._uid - */ defaultId: nanoid(9), localAttributes: {}, - internalModelProxy: this.formulateValue || this.value, + internalModelProxy: this.getInitialValue(), behavioralErrorVisibility: (this.errorBehavior === 'live'), formShouldShowErrors: false, validationErrors: [], @@ -219,6 +220,7 @@ export default { } }, created () { + this.applyInitialValue() if (this.formulateFormRegister && typeof this.formulateFormRegister === 'function') { this.formulateFormRegister(this.nameOrFallback, this) } @@ -226,6 +228,30 @@ export default { this.performValidation() }, methods: { + getInitialValue () { + // Manually request classification, pre-computed props + var classification = this.$formulate.classify(this.type) + classification = (classification === 'box' && this.options) ? 'group' : classification + if (classification === 'box' && this.checked) { + return this.value || true + } else if (Object.prototype.hasOwnProperty.call(this.$options.propsData, 'value') && classification !== 'box') { + return this.value + } else if (Object.prototype.hasOwnProperty.call(this.$options.propsData, 'formulateValue')) { + return this.formulateValue + } + return '' + }, + applyInitialValue () { + // This should only be run immediately on created and ensures that the + // proxy and the model are both the same before any additional registration. + if ( + !shallowEqualObjects(this.context.model, this.internalModelProxy) && + // we dont' want to set the model if we are a sub-box of a multi-box field + (Object.prototype.hasOwnProperty(this.$options.propsData, 'options') && this.classification === 'box') + ) { + this.context.model = this.internalModelProxy + } + }, updateLocalAttributes (value) { if (!shallowEqualObjects(value, this.localAttributes)) { this.localAttributes = value diff --git a/src/FormulateInputGroup.vue b/src/FormulateInputGroup.vue index c4203b9..9440e09 100644 --- a/src/FormulateInputGroup.vue +++ b/src/FormulateInputGroup.vue @@ -1,7 +1,7 @@